mirror of
https://github.com/e107inc/e107.git
synced 2025-08-01 20:30:39 +02:00
Issue #1512 News Grid Menu
This commit is contained in:
@@ -380,8 +380,8 @@ TEMPL;
|
|||||||
.sortable li { border-radius: 4px }
|
.sortable li { border-radius: 4px }
|
||||||
.sortable li:hover { background-color: silver; box-shadow:3px 3px 3px silver }
|
.sortable li:hover { background-color: silver; box-shadow:3px 3px 3px silver }
|
||||||
|
|
||||||
.regularMenu { cursor:move; border-bottom:1px dotted silver; margin-bottom:6px; padding-left:3px; padding-right:3px; padding-top:10px; padding-bottom:10px }
|
.regularMenu { cursor:move; border-bottom:1px dotted silver; margin-bottom:6px; padding-left:3px; padding-right:3px; padding-top:10px; padding-bottom:10px;background-color: #E0EBF1; border-radius: 5px; }
|
||||||
|
.regularMenu span {padding:3px; font-weight:bold; color:#2F2F2F;text-align:left; }
|
||||||
.ui-draggable { background-color: rgb(245, 245, 245); min-width:100px;}
|
.ui-draggable { background-color: rgb(245, 245, 245); min-width:100px;}
|
||||||
|
|
||||||
",'jquery');
|
",'jquery');
|
||||||
|
@@ -1817,6 +1817,8 @@ Inverse 10 <span class="badge badge-inverse">10</span>
|
|||||||
global $pref;
|
global $pref;
|
||||||
$action = "";
|
$action = "";
|
||||||
|
|
||||||
|
return ;
|
||||||
|
|
||||||
$var['menumanager']['text'] = LAN_MENULAYOUT;
|
$var['menumanager']['text'] = LAN_MENULAYOUT;
|
||||||
$var['menumanager']['link'] = e_ADMIN_ABS.'menus.php';
|
$var['menumanager']['link'] = e_ADMIN_ABS.'menus.php';
|
||||||
|
|
||||||
|
@@ -60,6 +60,12 @@ class news_shortcodes extends e_shortcode
|
|||||||
$text = e107::getParser()->toAttribute($text);
|
$text = e107::getParser()->toAttribute($text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!empty($parm['limit']))
|
||||||
|
{
|
||||||
|
$text = e107::getParser()->text_truncate($text, $parm['limit']);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return $text;
|
return $text;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -485,12 +491,13 @@ class news_shortcodes extends e_shortcode
|
|||||||
|
|
||||||
function sc_newssummary($parm=null)
|
function sc_newssummary($parm=null)
|
||||||
{
|
{
|
||||||
|
$text = '';
|
||||||
|
|
||||||
if($this->news_item['news_summary'])
|
if($this->news_item['news_summary'])
|
||||||
{
|
{
|
||||||
return $this->news_item['news_summary'].'<br />';
|
$text = $this->news_item['news_summary'];
|
||||||
}
|
}
|
||||||
|
elseif($this->news_item['news_body']) // Auto-generate from first 2 sentences of news-body. //TODO Add Pref?
|
||||||
if($this->news_item['news_body']) // Auto-generate from first 2 sentences of news-body. //TODO Add Pref?
|
|
||||||
{
|
{
|
||||||
$tp = e107::getParser();
|
$tp = e107::getParser();
|
||||||
$text = $tp->toHtml($this->news_item['news_body'],true);
|
$text = $tp->toHtml($this->news_item['news_body'],true);
|
||||||
@@ -501,9 +508,17 @@ class news_shortcodes extends e_shortcode
|
|||||||
|
|
||||||
if($tmp[0])
|
if($tmp[0])
|
||||||
{
|
{
|
||||||
return trim($tmp[0]);
|
$text = trim($tmp[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!empty($parm['limit']))
|
||||||
|
{
|
||||||
|
$text = e107::getParser()->text_truncate($text, $parm['limit']);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return $text;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -1101,9 +1101,9 @@ class e_media
|
|||||||
|
|
||||||
$img_data['media_url'] = $tp->createConstants($newpath,'rel');
|
$img_data['media_url'] = $tp->createConstants($newpath,'rel');
|
||||||
$img_data['media_name'] = $tp->toDB(basename($newpath));
|
$img_data['media_name'] = $tp->toDB(basename($newpath));
|
||||||
$img_data['media_caption'] = $new_data['media_caption'];
|
$img_data['media_caption'] = vartrue($new_data['media_caption']);
|
||||||
$img_data['media_category'] = vartrue($category,'_common_image');
|
$img_data['media_category'] = vartrue($category,'_common_image');
|
||||||
$img_data['media_description'] = $new_data['media_description'];
|
$img_data['media_description'] = vartrue($new_data['media_description']);
|
||||||
$img_data['media_userclass'] = '0';
|
$img_data['media_userclass'] = '0';
|
||||||
|
|
||||||
if($sql->insert("core_media",$img_data))
|
if($sql->insert("core_media",$img_data))
|
||||||
@@ -1114,7 +1114,7 @@ class e_media
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->log("Db Insert Failed ");
|
$this->log("Db Insert Failed: ".var_export($img_data,true));
|
||||||
rename($newpath,$oldpath); //move it back.
|
rename($newpath,$oldpath); //move it back.
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@@ -1605,7 +1605,7 @@ class e_menuManager {
|
|||||||
if(!$this->dragDrop)
|
if(!$this->dragDrop)
|
||||||
{
|
{
|
||||||
|
|
||||||
return "<b class='muted' style='color:#2F2F2F;text-align:left'>".$caption."</b><br />". $text;
|
return "<span class='muted'>".$caption."</span><br />". $text;
|
||||||
// return;
|
// return;
|
||||||
|
|
||||||
|
|
||||||
|
@@ -684,10 +684,12 @@ class e_news_tree extends e_front_tree_model
|
|||||||
$parser = e107::getParser();
|
$parser = e107::getParser();
|
||||||
$batch = e107::getScBatch('news')
|
$batch = e107::getScBatch('news')
|
||||||
->setScVar('param', $param);
|
->setScVar('param', $param);
|
||||||
|
|
||||||
$batch->wrapper('news_menu/latest'); //@SecretR - Please FIXME, I'm lost in here. (Cam)
|
$wrapperKey = ($parms['tmpl'].'/'.$parms['tmpl_key']);
|
||||||
|
$batch->wrapper($wrapperKey);
|
||||||
$i = 1;
|
$i = 1;
|
||||||
|
|
||||||
|
|
||||||
$items = $this->getTree();
|
$items = $this->getTree();
|
||||||
|
|
||||||
if(!empty($items))
|
if(!empty($items))
|
||||||
|
@@ -81,7 +81,7 @@ class e_parse_shortcode
|
|||||||
*/
|
*/
|
||||||
protected $wrappers = array();
|
protected $wrappers = array();
|
||||||
protected $wrapper = null; // current wrapper being processed.
|
protected $wrapper = null; // current wrapper being processed.
|
||||||
protected $wrapperDebugDone = false;
|
protected $wrapperDebugDone = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Former $sc_style global variable. Internally used - performance reasons
|
* Former $sc_style global variable. Internally used - performance reasons
|
||||||
@@ -772,6 +772,7 @@ class e_parse_shortcode
|
|||||||
}
|
}
|
||||||
elseif(E107_DBG_BBSC)
|
elseif(E107_DBG_BBSC)
|
||||||
{
|
{
|
||||||
|
$this->wrapper = $this->addedCodes->getWrapperID();
|
||||||
// e107::getMessage()->addDebug("Wrapper Empty: ".$this->addedCodes->wrapper());
|
// e107::getMessage()->addDebug("Wrapper Empty: ".$this->addedCodes->wrapper());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1101,7 +1102,7 @@ class e_parse_shortcode
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(E107_DBG_BBSC && $this->wrapperDebugDone==false && !empty($this->wrappers))
|
if(E107_DBG_BBSC && $this->wrapperDebugDone[$this->wrapper]==false && !empty($this->wrapper))
|
||||||
{
|
{
|
||||||
list($wrapTmpl, $wrapID1, $wrapID2) = explode('/',$this->wrapper,3);
|
list($wrapTmpl, $wrapID1, $wrapID2) = explode('/',$this->wrapper,3);
|
||||||
|
|
||||||
@@ -1112,10 +1113,10 @@ class e_parse_shortcode
|
|||||||
}
|
}
|
||||||
|
|
||||||
// e107::getMessage()->addDebug("Active Wrapper: \$".$wrapActive);
|
// e107::getMessage()->addDebug("Active Wrapper: \$".$wrapActive);
|
||||||
$this->wrapperDebugDone = true;
|
$this->wrapperDebugDone[$this->wrapper] = true;
|
||||||
global $db_debug;
|
global $db_debug;
|
||||||
|
|
||||||
$db_debug->logCode(3, $this->wrapper,null, '<pre>To use, add to the '.$wrapTmpl.' template:<br />$'.$wrapActive.'[\'SHORTCODE_NAME\'] = "(html before){---}(html after)";</pre>');
|
$db_debug->logCode(3, $this->wrapper,null, '<pre>To use, add to the file '.$wrapTmpl.'_template.php:<br />$'.$wrapActive.'[\'SHORTCODE_NAME\'] = "(html before){---}(html after)";</pre>');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($ret) && ($ret != '' || is_numeric($ret)))
|
if (isset($ret) && ($ret != '' || is_numeric($ret)))
|
||||||
|
@@ -26,7 +26,7 @@ class news_menu
|
|||||||
* Configuration Fields.
|
* Configuration Fields.
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function config($menu='')
|
public function config($menu='') //TODO LAN
|
||||||
{
|
{
|
||||||
$fields = array();
|
$fields = array();
|
||||||
$categories = array();
|
$categories = array();
|
||||||
@@ -47,6 +47,16 @@ class news_menu
|
|||||||
$fields['category'] = array('title'=> LAN_CATEGORY, 'type'=>'dropdown', 'writeParms'=>array('optArray'=>$categories, 'default'=>'blank'));
|
$fields['category'] = array('title'=> LAN_CATEGORY, 'type'=>'dropdown', 'writeParms'=>array('optArray'=>$categories, 'default'=>'blank'));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case "news_grid":
|
||||||
|
$fields['caption'] = array('title'=> LAN_CAPTION, 'type'=>'text', 'multilan'=>true, 'writeParms'=>array('size'=>'xxlarge'));
|
||||||
|
$fields['category'] = array('title'=> LAN_CATEGORY, 'type'=>'dropdown', 'writeParms'=>array('optArray'=>$categories, 'default'=>'blank'));
|
||||||
|
$fields['layout'] = array('title'=> "Layout", 'type'=>'method', 'writeParms'=>'');
|
||||||
|
$fields['count'] = array('title'=> "Number of Items", 'type'=>'number', 'writeParms'=>array('pattern'=>'[0-9]*', 'default'=>4));
|
||||||
|
$fields['titleLimit'] = array('title'=> "Title Character Limit", 'type'=>'number', 'writeParms'=>'');
|
||||||
|
$fields['summaryLimit'] = array('title'=> "Summary Character Limit", 'type'=>'number', 'writeParms'=>'');
|
||||||
|
// TODO Add a field for 'latest' vs 'sticky' vs 'assigned by news item (news_render_type)'
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
case "news_categories":
|
case "news_categories":
|
||||||
$fields['caption'] = array('title'=> LAN_CAPTION, 'type'=>'text', 'multilan'=>true, 'writeParms'=>array('size'=>'xxlarge'));
|
$fields['caption'] = array('title'=> LAN_CAPTION, 'type'=>'text', 'multilan'=>true, 'writeParms'=>array('size'=>'xxlarge'));
|
||||||
@@ -74,3 +84,31 @@ class news_menu
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// optional
|
||||||
|
class news_menu_form extends e_form
|
||||||
|
{
|
||||||
|
|
||||||
|
public function layout($curVal)
|
||||||
|
{
|
||||||
|
|
||||||
|
$arr = array(
|
||||||
|
"col-md-6" => "<div class='row'><div class='col-md-6'><div class='alert alert-info'>1/2</div></div><div class='col-md-6'><div class='alert alert-info'>1/2</div></div></div>",
|
||||||
|
"col-md-4" => "<div class='row'><div class='col-md-4'><div class='alert alert-info'>1/3</div></div><div class='col-md-4'><div class='alert alert-info'>1/3</div></div><div class='col-md-4'><div class='alert alert-info'>1/3</div></div></div>",
|
||||||
|
"col-md-3" => "<div class='row'><div class='col-md-3 '><div class='alert alert-info'>1/4</div></div><div class='col-md-3'><div class='alert alert-info'>1/4</div></div><div class='col-md-3'><div class='alert alert-info'>1/4</div></div><div class='col-md-3'><div class='alert alert-info'>1/4</div></div></div>",
|
||||||
|
);
|
||||||
|
|
||||||
|
$text = '<table class="table news-menu-shade">';
|
||||||
|
|
||||||
|
foreach($arr as $k=>$v)
|
||||||
|
{
|
||||||
|
|
||||||
|
$text .= "<tr><td>".$this->radio('layout', $k, $curVal, array('label'=>$k))."</td><td>".$v."</td></tr>";
|
||||||
|
}
|
||||||
|
|
||||||
|
$text .= "</table>";
|
||||||
|
|
||||||
|
return $text;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -29,7 +29,17 @@ if(false === $cached)
|
|||||||
|
|
||||||
$ntree = e107::getObject('e_news_tree', null, e_HANDLER.'news_class.php');
|
$ntree = e107::getObject('e_news_tree', null, e_HANDLER.'news_class.php');
|
||||||
|
|
||||||
$template = e107::getTemplate('news', vartrue($parms['tmpl'], 'news_menu'), vartrue($parms['tmpl_key'], 'latest'));
|
if(empty($parms['tmpl']))
|
||||||
|
{
|
||||||
|
$parms['tmpl'] = 'news_menu';
|
||||||
|
}
|
||||||
|
|
||||||
|
if(empty($parms['tmpl_key']))
|
||||||
|
{
|
||||||
|
$parms['tmpl_key'] = 'latest';
|
||||||
|
}
|
||||||
|
|
||||||
|
$template = e107::getTemplate('news', $parms['tmpl'], $parms['tmpl_key']);
|
||||||
|
|
||||||
$treeparm = array();
|
$treeparm = array();
|
||||||
if(vartrue($parms['count'])) $treeparm['db_limit'] = '0, '.intval($parms['count']);
|
if(vartrue($parms['count'])) $treeparm['db_limit'] = '0, '.intval($parms['count']);
|
||||||
|
@@ -25,7 +25,10 @@ if(false === $cached)
|
|||||||
|
|
||||||
$ctree = e107::getObject('e_news_category_tree', null, e_HANDLER.'news_class.php');
|
$ctree = e107::getObject('e_news_category_tree', null, e_HANDLER.'news_class.php');
|
||||||
|
|
||||||
$template = e107::getTemplate('news', 'news_menu', 'category');
|
$parms['tmpl'] = 'news_menu';
|
||||||
|
$parms['tmpl_key'] = 'category';
|
||||||
|
|
||||||
|
$template = e107::getTemplate('news', $parms['tmpl'], $parms['tmpl_key']);
|
||||||
|
|
||||||
$cached = $ctree->loadActive()->render($template, $parms, true);
|
$cached = $ctree->loadActive()->render($template, $parms, true);
|
||||||
e107::getCache()->set($cacheString, $cached);
|
e107::getCache()->set($cacheString, $cached);
|
||||||
|
61
e107_plugins/news/news_grid_menu.php
Normal file
61
e107_plugins/news/news_grid_menu.php
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Copyright (C) 2008-2011 e107 Inc (e107.org), Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
|
||||||
|
* $Id$
|
||||||
|
*
|
||||||
|
* Latest news menu
|
||||||
|
*/
|
||||||
|
if (!defined('e107_INIT')) { exit; }
|
||||||
|
|
||||||
|
$cacheString = 'nq_news_grid_menu_'.md5(serialize($parm));
|
||||||
|
$cached = e107::getCache()->retrieve($cacheString);
|
||||||
|
if(false === $cached)
|
||||||
|
{
|
||||||
|
e107::plugLan('news');
|
||||||
|
|
||||||
|
if(is_string($parm))
|
||||||
|
{
|
||||||
|
parse_str($parm, $parms);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$parms = $parm;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isset($parms['caption'][e_LANGUAGE]))
|
||||||
|
{
|
||||||
|
$parms['caption'] = $parms['caption'][e_LANGUAGE];
|
||||||
|
}
|
||||||
|
|
||||||
|
$ntree = e107::getObject('e_news_tree', null, e_HANDLER.'news_class.php');
|
||||||
|
$template = e107::getTemplate('news', 'news_menu', 'grid');
|
||||||
|
$gridSize = vartrue($parms['layout'],'col-md-4');
|
||||||
|
|
||||||
|
$parmSrch = array('{NEWSGRID}', '_titleLimit_', '_summaryLimit_');
|
||||||
|
$parmReplace = array($gridSize, vartrue($parms['titleLimit'],0),vartrue($parms['summaryLimit'],0));
|
||||||
|
|
||||||
|
$template = str_replace($parmSrch , $parmReplace, $template);
|
||||||
|
|
||||||
|
$render = (empty($parms['caption'])) ? false: true;
|
||||||
|
|
||||||
|
$parms['tmpl'] = 'news_menu';
|
||||||
|
$parms['tmpl_key'] = 'grid';
|
||||||
|
|
||||||
|
if(empty($parms['count']))
|
||||||
|
{
|
||||||
|
$parms['count'] = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
$parms['order'] = 'n.news_datestamp DESC';
|
||||||
|
|
||||||
|
$treeparm = array();
|
||||||
|
if(vartrue($parms['count'])) $treeparm['db_limit'] = '0, '.intval($parms['count']);
|
||||||
|
if(vartrue($parms['order'])) $treeparm['db_order'] = e107::getParser()->toDb($parms['order']);
|
||||||
|
$parms['return'] = true;
|
||||||
|
|
||||||
|
|
||||||
|
$cached = $ntree->loadJoinActive(vartrue($parms['category'], 0), false, $treeparm)->render($template, $parms, $render);
|
||||||
|
e107::getCache()->set($cacheString, $cached);
|
||||||
|
}
|
||||||
|
|
||||||
|
echo $cached;
|
@@ -90,7 +90,16 @@ $NEWS_MENU_TEMPLATE['other2']['end'] = "</ul>";
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Grid Menu
|
||||||
|
$NEWS_MENU_TEMPLATE['grid']['start'] = '<div class="row news-menu-grid">';
|
||||||
|
$NEWS_MENU_TEMPLATE['grid']['item'] = '<div class="item {NEWSGRID}">
|
||||||
|
{SETIMAGE: w=400&h=400&crop=1}
|
||||||
|
{NEWSTHUMBNAIL=placeholder}
|
||||||
|
<h3>{NEWSTITLE: limit=_titleLimit_}</h3>
|
||||||
|
<p>{NEWSSUMMARY: limit=_summaryLimit_}</p>
|
||||||
|
<p class="text-right"><a class="btn btn-primary btn-othernews" href="{NEWSURL}">'.LAN_READ_MORE.'</a></p>
|
||||||
|
</div>';
|
||||||
|
$NEWS_MENU_TEMPLATE['grid']['end'] = '</div>';
|
||||||
|
|
||||||
|
|
||||||
|
// $NEWS_MENU_WRAPPER['grid']['NEWSTITLE'] = "<span style='color:red'>{---}</span>"; // example
|
||||||
//$NEWS_MENU_TEMPLATE['latest']['separator'] = '<br />'; // Shouldn't be needed.
|
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
if ( ! defined('e107_INIT')) { exit(); }
|
if ( ! defined('e107_INIT')) { exit(); }
|
||||||
|
|
||||||
e107::lan('theme','English');
|
e107::lan('theme');
|
||||||
|
|
||||||
e107::meta('viewport', 'width=device-width, initial-scale=1.0');
|
e107::meta('viewport', 'width=device-width, initial-scale=1.0');
|
||||||
//e107::meta('apple-mobile-web-app-capable','yes');
|
//e107::meta('apple-mobile-web-app-capable','yes');
|
||||||
|
Reference in New Issue
Block a user