mirror of
https://github.com/e107inc/e107.git
synced 2025-08-01 20:30:39 +02:00
Fixes #1253 - News Category Icon. Improved legacy support for news list page. toIcon() can now check for multiple legacy img paths.
This commit is contained in:
@@ -123,7 +123,7 @@ class news_cat_ui extends e_admin_ui
|
||||
protected $fields = array(
|
||||
'checkboxes' => array('title'=> '', 'type' => null, 'width' =>'5%', 'forced'=> TRUE, 'thclass'=>'center', 'class'=>'center'),
|
||||
'category_id' => array('title'=> LAN_ID, 'type' => 'number', 'width' =>'5%', 'forced'=> TRUE, 'readonly'=>TRUE),
|
||||
'category_icon' => array('title'=> LAN_ICON, 'type' => 'icon', 'data' => 'str', 'width' => '100px', 'thclass' => 'center', 'class'=>'center', 'readParms'=>'thumb=60&thumb_urlraw=0&thumb_aw=60', 'writeParms' => 'glyphs=1', 'readonly'=>FALSE, 'batch' => FALSE, 'filter'=>FALSE),
|
||||
'category_icon' => array('title'=> LAN_ICON, 'type' => 'icon', 'data' => 'str', 'width' => '100px', 'thclass' => 'center', 'class'=>'center', 'readParms'=>array('legacy'=>'{e_IMAGE}icons/'), 'writeParms' => 'glyphs=1', 'readonly'=>FALSE, 'batch' => FALSE, 'filter'=>FALSE), // thumb=60&thumb_urlraw=0&thumb_aw=60
|
||||
'category_name' => array('title'=> LAN_TITLE, 'type' => 'text', 'inline'=>true, 'width' => 'auto', 'thclass' => 'left', 'readonly'=>FALSE, 'validate' => true, 'writeParms'=>array('size'=>'xxlarge')),
|
||||
|
||||
'category_meta_description' => array('title'=> LAN_DESCRIPTION, 'type' => 'textarea', 'inline'=>true, 'width' => 'auto', 'thclass' => 'left','readParms' => 'expand=...&truncate=150&bb=1', 'readonly'=>FALSE, 'writeParms'=>array('size'=>'xxlarge')),
|
||||
|
@@ -994,8 +994,20 @@ class pluginManager{
|
||||
}
|
||||
else
|
||||
{
|
||||
$eplug_folder = null;
|
||||
$upgrade_alter_tables = null;
|
||||
$upgrade_add_prefs = null;
|
||||
$upgrade_remove_prefs = null;
|
||||
$upgrade_add_array_pref = null;
|
||||
$upgrade_remove_array_pref = null;
|
||||
$eplug_version = null;
|
||||
|
||||
|
||||
|
||||
include(e_PLUGIN.$plug['plugin_path'].'/plugin.php');
|
||||
|
||||
$text = '';
|
||||
|
||||
$func = $eplug_folder.'_upgrade';
|
||||
if (function_exists($func))
|
||||
{
|
||||
@@ -2178,6 +2190,7 @@ class pluginBuilder
|
||||
var $tableCount = 0;
|
||||
var $tableList = array();
|
||||
var $createFiles = false;
|
||||
private $buildTable = false;
|
||||
private $debug = false;
|
||||
|
||||
function __construct()
|
||||
@@ -2322,6 +2335,7 @@ class pluginBuilder
|
||||
$ns = e107::getRender();
|
||||
$mes = e107::getMessage();
|
||||
|
||||
|
||||
$newplug = $_GET['newplugin'];
|
||||
$this->pluginName = $newplug;
|
||||
|
||||
@@ -2340,6 +2354,12 @@ class pluginBuilder
|
||||
$data = file_get_contents($sqlFile);
|
||||
$ret = $dv->getTables($data);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
// $ret = $this->buildTables();
|
||||
// $this->buildTable = true;
|
||||
}
|
||||
|
||||
$text = $frm->open('newplugin-step3','post', e_SELF.'?mode=create&newplugin='.$newplug.'&createFiles='.$this->createFiles.'&step=3');
|
||||
|
||||
@@ -2352,7 +2372,16 @@ class pluginBuilder
|
||||
{
|
||||
foreach($ret['tables'] as $key=>$table)
|
||||
{
|
||||
$text .= "<li><a data-toggle='tab' href='#".$table."'>Table: ".$table."</a></li>";
|
||||
if($this->buildTable == true)
|
||||
{
|
||||
$label = "<span class='form-inline'>".$frm->checkbox('buildTable',1,false)." Build Table</span>";
|
||||
}
|
||||
else
|
||||
{
|
||||
$label = "Table: ".$table;
|
||||
}
|
||||
|
||||
$text .= "<li><a data-toggle='tab' href='#".$table."'>".$label."</a></li>";
|
||||
$this->tableList[] = $table;
|
||||
}
|
||||
}
|
||||
@@ -2414,6 +2443,40 @@ class pluginBuilder
|
||||
}
|
||||
|
||||
|
||||
|
||||
private function buildTables()
|
||||
{
|
||||
|
||||
$template = "plugin_id int(10) unsigned NOT NULL auto_increment,
|
||||
plugin_datestamp int(10) unsigned NOT NULL default '0',
|
||||
plugin_name varchar(255) NOT NULL default '',
|
||||
plugin_text text NOT NULL,
|
||||
plugin_boolean tinyint(1) unsigned NOT NULL default '0',
|
||||
plugin_author int(10) unsigned default NULL,
|
||||
plugin_visibility int(4) NOT NULL default '0',
|
||||
plugin_tags varchar(255) NOT NULL default '',
|
||||
plugin_order int(6) unsigned NOT NULL default '0',
|
||||
PRIMARY KEY (plugin_id)";
|
||||
|
||||
$ret = array();
|
||||
|
||||
$ret['tables'] = array($this->pluginName);
|
||||
|
||||
$ret['data'] = array(0=> str_replace("plugin", $this->pluginName, $template) );
|
||||
|
||||
$ret['engine'] = array('0'=> 'InnoDB');
|
||||
|
||||
return $ret;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private function createAddons($list)
|
||||
{
|
||||
|
||||
|
@@ -833,7 +833,8 @@ class news_shortcodes extends e_shortcode
|
||||
return e107::getUrl()->create('news/view/item', $this->news_item);
|
||||
}
|
||||
|
||||
function sc_newscaticon($parm = '')
|
||||
/* @deprecated - use {NEWS_CATEGORY_ICON} instead */
|
||||
function sc_newscaticon($parm = array())
|
||||
{
|
||||
// BC
|
||||
$category_icon = str_replace('../', '', trim($this->news_item['category_icon']));
|
||||
@@ -850,23 +851,29 @@ class news_shortcodes extends e_shortcode
|
||||
$src = (is_readable(e_IMAGE_ABS."newspost_images/".$category_icon)) ? e_IMAGE_ABS."newspost_images/".$category_icon : e_IMAGE_ABS."icons/".$category_icon;
|
||||
}
|
||||
|
||||
$alt_text = e107::getParser()->toHTML($this->news_item['category_name'], FALSE ,'defs');
|
||||
//TODO - remove inline styles
|
||||
if($this->param['caticon'] == ''){$this->param['caticon'] = 'border:0px';}
|
||||
|
||||
// if($this->param['caticon'] == ''){$this->param['caticon'] = 'border:0px';}
|
||||
|
||||
$parm['alt'] = e107::getParser()->toHTML($this->news_item['category_name'], FALSE ,'defs');
|
||||
$parm['legacy'] = array('{e_IMAGE}newspost_images/', '{e_IMAGE}icons/');
|
||||
$parm['class'] = 'icon news_image news-category-icon';
|
||||
|
||||
$icon = e107::getParser()->toIcon($category_icon, $parm);
|
||||
|
||||
switch($parm)
|
||||
{
|
||||
/* @deprecated - Will cause issues with glyphs */
|
||||
case 'src':
|
||||
return $src;
|
||||
break;
|
||||
|
||||
case 'tag':
|
||||
return "<img class='news_image' src='{$src}' alt='$alt_text' style='".$this->param['caticon']."' />";
|
||||
return $icon;
|
||||
break;
|
||||
|
||||
case 'url':
|
||||
default:
|
||||
return "<a href='".e107::getUrl()->create('news/list/category', $this->news_item)."'><img class='img-rounded' style='".$this->param['caticon']."' src='".$src."' alt='$alt_text' /></a>";
|
||||
return "<a href='".e107::getUrl()->create('news/list/category', $this->news_item)."'>".$icon."</a>";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@@ -3598,20 +3598,29 @@ class e_parser
|
||||
{
|
||||
$path = $this->replaceConstants($icon,'full');
|
||||
}
|
||||
elseif(vartrue($parm['legacy']))
|
||||
elseif(!empty($parm['legacy']))
|
||||
{
|
||||
$legacyList = (!is_array($parm['legacy'])) ? array($parm['legacy']) : $parm['legacy'];
|
||||
|
||||
$legacyPath = $parm['legacy'].$icon;
|
||||
$filePath = $this->replaceConstants($legacyPath,'rel');
|
||||
foreach($legacyList as $legPath)
|
||||
{
|
||||
$legacyPath = $legPath.$icon;
|
||||
$filePath = $this->replaceConstants($legacyPath);
|
||||
|
||||
if(is_readable($filePath))
|
||||
{
|
||||
$path = $this->replaceConstants($legacyPath,'full');
|
||||
break;
|
||||
}
|
||||
else
|
||||
|
||||
}
|
||||
|
||||
if(empty($path))
|
||||
{
|
||||
$log = e107::getAdminLog();
|
||||
$log->addDebug('Broken Icon Path: '.$legacyPath."\n".print_r(debug_backtrace(null,2), true), false)->save('IMALAN_00');
|
||||
$log->addDebug('Broken Icon Path: '.$icon."\n".print_r(debug_backtrace(null,2), true), false)->save('IMALAN_00');
|
||||
e107::getDebug()->log('Broken Icon Path: '.$icon);
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3621,9 +3630,10 @@ class e_parser
|
||||
}
|
||||
|
||||
|
||||
$alt = (!empty($parm['alt'])) ? $this->toAttribute($parm['alt']) : basename($path);
|
||||
$class = (!empty($parm['class'])) ? $parm['class'] : 'icon';
|
||||
|
||||
|
||||
return "<img class='icon' src='".$path."' alt='".basename($path)."' ".$dimensions." />";
|
||||
return "<img class='".$class."' src='".$path."' alt='".$alt."' ".$dimensions." />";
|
||||
}
|
||||
|
||||
|
||||
|
@@ -3776,7 +3776,8 @@ class e_form
|
||||
|
||||
case 'icon':
|
||||
|
||||
$value = $tp->toIcon($value,array('size'=>'2x'));
|
||||
$parms['size'] = '2x';
|
||||
$value = $tp->toIcon($value,$parms);
|
||||
|
||||
break;
|
||||
|
||||
|
@@ -37,7 +37,7 @@ $NEWS_TEMPLATE['list']['item'] = '
|
||||
<div class="span9 col-md-9">
|
||||
<h3 class="media-heading">{NEWSTITLELINK}</h3>
|
||||
<p>
|
||||
{NEWSSUMMARY}
|
||||
{NEWS_SUMMARY}
|
||||
</p>
|
||||
<p>
|
||||
<a href="{NEWSURL}" class="btn btn-small btn-primary">'.LAN_READ_MORE.'</a>
|
||||
@@ -96,7 +96,7 @@ $NEWS_TEMPLATE['default']['item'] = '
|
||||
{NEWSIMAGE: item=1}
|
||||
|
||||
|
||||
<p class="lead">{NEWSSUMMARY}</p>
|
||||
<p class="lead">{NEWS_SUMMARY}</p>
|
||||
{NEWSVIDEO: item=1}
|
||||
<div class="text-justify">
|
||||
{NEWSBODY}
|
||||
|
34
news.php
34
news.php
@@ -311,14 +311,38 @@ if ($action == 'cat' || $action == 'all' || vartrue($_GET['tag']))
|
||||
require_once(HEADERF);
|
||||
$action = $currentNewsAction;
|
||||
|
||||
if(vartrue($NEWSLISTSTYLE)) // Legacy v1.x
|
||||
{
|
||||
$template = array('start'=>'', 'item'=>$NEWSLISTSTYLE, 'end'=>'');
|
||||
}
|
||||
else // v2.x
|
||||
if(deftrue('BOOTSTRAP')) // v2.x
|
||||
{
|
||||
$template = e107::getTemplate('news', 'news', 'list');
|
||||
}
|
||||
else // v1.x
|
||||
{
|
||||
if(empty($NEWSLISTSTYLE))
|
||||
{
|
||||
$NEWSLISTSTYLE = "
|
||||
<div style='padding:3px;width:100%'>
|
||||
<table style='border-bottom:1px solid black;width:100%' cellpadding='0' cellspacing='0'>
|
||||
<tr>
|
||||
<td style='vertical-align:top;padding:3px;width:20px'>
|
||||
{NEWS_CATEGORY_ICON}
|
||||
</td><td style='text-align:left;padding:3px'>
|
||||
{NEWSTITLELINK=extend}
|
||||
<br />
|
||||
{NEWS_SUMMARY}
|
||||
<span class='smalltext'>
|
||||
{NEWS_DATE}
|
||||
{NEWSCOMMENTS}
|
||||
</span>
|
||||
</td><td style='width:55px'>
|
||||
{SETIMAGE: w=55&h=55&crop=1}
|
||||
{NEWSTHUMBNAIL}
|
||||
</td></tr></table>
|
||||
</div>\n";
|
||||
}
|
||||
|
||||
$template = array('start'=>'', 'item'=>$NEWSLISTSTYLE, 'end'=>'');
|
||||
|
||||
}
|
||||
|
||||
// Legacy Styling..
|
||||
$param = array();
|
||||
|
Reference in New Issue
Block a user