1
0
mirror of https://github.com/e107inc/e107.git synced 2025-04-16 18:42:01 +02:00

News category menu updated (template, fixes), latest news and navigation by months menus added

This commit is contained in:
secretr 2011-12-02 12:22:33 +00:00
parent ac6f65e5d3
commit 59ae5ad937
6 changed files with 199 additions and 54 deletions

View File

@ -1,17 +1,14 @@
<?php
/*
+ ----------------------------------------------------------------------------+
| e107 website system - Language File.
|
| $Source: /cvs_backup/e107_0.8/e107_plugins/news/languages/English.php,v $
| $Revision$
| $Date$
| $Author$
+----------------------------------------------------------------------------+
*/
/**
* Copyright (C) e107 Inc (e107.org), Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
* $Id$
*
* News menu language file
*/
define("TD_MENU_L1", "Other News");
define("TD_MENU_L2", "Other News");
define("LAN_NEWSCAT_MENU_TITLE", "News Categories");
define("LAN_NEWSLATEST_MENU_TITLE", "Latest News");
?>

View File

@ -1,31 +1,30 @@
<?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; }
//require_once(e_HANDLER.'news_class.php');
parse_str($parm, $parm);
$nitem = e107::getObject('e_news_item');
$nitem->load(1);
$template = '
{NEWS_FIELD=title|format=html&arg=0,TITLE}<br />
<em>{NEWS_FIELD=datestamp|format=date}</em><br /><br />
{NEWS_FIELD=body|format=html_truncate&arg=100,...}
';
//New way of parsing batches - pass object, all sc_* methods will be auto-registered
$ret = e107::getParser()->parseTemplate($template, true, $nitem);
e107::getRender()->tablerender('Latest News', $ret, 'latest_news');
//print_a $nitem->getData();
/*
$ret .= '<br /><br />Render Tree<br />';
$ntree = new e_news_tree();
foreach ($ntree->load(1)->getTree() as $nitem)
$cacheString = 'nq_news_latest_menu_'.md5($parm);
$cached = e107::getCache()->retrieve($cacheString);
if(false === $cached)
{
$ret .= ' - '.$nitem->get('title').'<br/>';
//print_a $nitem->getData();
e107::plugLan('news');
parse_str($parm, $parms);
$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'));
$treeparm = array();
if($parms['count']) $treeparm['db_limit'] = '0, '.intval($parms['count']);
if($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, true);
e107::getCache()->set($cacheString, $cached);
}
*/
echo $cached;

View File

@ -1,32 +1,25 @@
<?php
/**
* Copyright (C) 2008-2011 e107 Inc (e107.org), Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
* $Id$
*
* News categories menu
*/
if (!defined('e107_INIT')) { exit; }
$cacheString = 'nq_news_categories_menu_'.preg_replace('#[^\w]#', '', $parm);
$cacheString = 'nq_news_categories_menu_'.md5($parm);
$cached = e107::getCache()->retrieve($cacheString);
if(false === $cached)
{
e107::includeLan(e_PLUGIN.'news/languages/'.e_LANGUAGE.'.php');
e107::plugLan('news');
parse_str($parm, $parms);
$ctree = e107::getObject('e_news_category_tree', null, e_HANDLER.'news_class.php');
//TODO real template, menu parameters
$sc_style['NEWS_CATEGORY_NEWS_COUNT']['pre'] = '(';
$sc_style['NEWS_CATEGORY_NEWS_COUNT']['post'] = ')';
$template = e107::getTemplate('news', 'news_menu', 'category');
$template = array();
$template['start'] = '';
$template['item'] = '
<img src="'.THEME_ABS.'images/bullet2.gif" alt="bullet" class="icon" /> <a class="e-menu-link newscats{active}" href="{NEWS_CATEGORY_URL}">{NEWS_CATEGORY_TITLE} {NEWS_CATEGORY_NEWS_COUNT}</a>
';
$template['separator'] = '<br />';
$template['end'] = '';
//always return
$parms['return'] = true;
$cached = $ctree->loadActive()->render($parms, true, $template);
$cached = $ctree->loadActive()->render($template, $parms, true);
e107::getCache()->set($cacheString, $cached);
}

View File

@ -0,0 +1,116 @@
<?php
/**
* Copyright (C) 2008-2011 e107 Inc (e107.org), Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
* $Id$
*
* News by month menu
*/
if (!defined('e107_INIT')) { exit; }
$cString = 'nq_news_months_menu_'.md5($parm);
$cached = e107::getCache()->retrieve($cString);
if(false === $cached)
{
if(!function_exists('newsFormatDate'))
{
function newsFormatDate($year, $month, $day = "") {
$date = $year;
$date .= (strlen($month) < 2)?"0".$month:
$month;
$date .= (strlen($day) < 2 && $day != "")?"0".$day:
$day;
return $date;
}
}
//parse_str($parm, $parms); // FIXME - menu settings...
$parms['showarchive'] = 0;
e107::plugLan('blogcalendar_menu');
$tp = e107::getParser();
$sql = e107::getDb();
$marray = array(BLOGCAL_M1, BLOGCAL_M2, BLOGCAL_M3, BLOGCAL_M4,
BLOGCAL_M5, BLOGCAL_M6, BLOGCAL_M7, BLOGCAL_M8,
BLOGCAL_M9, BLOGCAL_M10, BLOGCAL_M11, BLOGCAL_M12);
$pref['blogcal_ws'] = "monday";
// TODO parms
//$parms['year'] = "2011 0";
if($parms['year'])
{
$date = $parms['year'];
list($cur_year, $cur_month) = explode(" ", date($date));
$start = mktime(0, 0, 0, 1, 1, $cur_year);
$end = mktime(23, 59, 59, 12, 31, $cur_year);
}
else
{
$date = "Y n";
list($cur_year, $cur_month) = explode(" ", date($date));
$start = mktime(0, 0, 0, 1, 1, $cur_year);
$end = time();
}
$req_year = $cur_year;
if(e_PAGE == 'news.php' && strstr(e_QUERY, "month"))
{
$tmp = explode('.', e_QUERY);
$item = $tmp[1];
$req_month = intval(substr($item, 4, 2));
$req = 'month';
}
else
{
$req_month = $cur_month;
}
$xmonth_cnt = array();
$month_links = array();
$sql->db_Mark_Time('News months menu');
if(!$sql->db_Select("news", "news_id, news_datestamp", "news_class IN (".USERCLASS_LIST.") AND news_datestamp > ".intval($start)." AND news_datestamp < ".intval($end)." ORDER BY news_datestamp DESC"))
{
e107::getCache()->set($cString, '');
return '';
}
while ($news = $sql->db_Fetch())
{
$xmonth = date("n", $news['news_datestamp']);
if ((!isset($month_links[$xmonth]) || !$month_links[$xmonth]))
{
$xmonth_cnt[$xmonth] = 0;
$month_links[$xmonth] = e107::getUrl()->create('news/list/month', 'id='.newsFormatDate($req_year, $xmonth));
}
$xmonth_cnt[$xmonth]++;
}
// go over the link array and create the option fields
$menu_text = array();
$template = e107::getTemplate('news', 'news_menu', 'months');
$bullet = defined('BULLET') ? THEME_ABS.'images/'.BULLET : THEME_ABS.'images/bullet2.gif';
$vars = new e_vars(array('bullet' => $bullet));
foreach($month_links as $index => $val)
{
$vars->addData(array(
'active' => $index == $req_month ? " active" : '',
'url' => $val,
'month' => $marray[$index-1],
'count' => $xmonth_cnt[$index],
));
$menu_text[] = $tp->simpleParse($template['item'], $vars);
}
$cached = $template['start'].implode($template['separator'], $menu_text).$template['end'];
if($cached)
{
if(!$parms['showarchive']) $cached .= '<div class="e-menu-link archive"><a href="'.e_PLUGIN_ABS.'blogcalendar_menu/archive.php">'.BLOGCAL_L2.'</a></div>';
$cached = $ns->tablerender(BLOGCAL_L1.$req_year, $cached, 'news_months_menu', true);
}
e107::getCache()->set($cString, $cached);
}
echo $cached;

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Id: plugin.xml,v 1.1 2009-09-26 16:54:15 e107coders Exp $ -->
<!-- $Id$ -->
<e107Plugin name="News" version="1.0" compatibility="0.8" installRequired="false" >
<category>menu</category>
</e107Plugin>

View File

@ -0,0 +1,40 @@
<?php
/**
* Copyright (C) e107 Inc (e107.org), Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
* $Id$
*
* News menus templates
*/
if (!defined('e107_INIT')) exit;
global $sc_style;
$sc_style['NEWS_CATEGORY_NEWS_COUNT']['pre'] = '(';
$sc_style['NEWS_CATEGORY_NEWS_COUNT']['post'] = ')';
// category menu
$NEWS_MENU_TEMPLATE['category']['start'] = '';
$NEWS_MENU_TEMPLATE['category']['end'] = '';
$NEWS_MENU_TEMPLATE['category']['item'] = '
<img src="{bullet}" alt="bullet" class="icon" /> <a class="e-menu-link newscats{active}" href="{NEWS_CATEGORY_URL}">{NEWS_CATEGORY_TITLE} {NEWS_CATEGORY_NEWS_COUNT}</a>
';
$NEWS_MENU_TEMPLATE['category']['separator'] = '<br />';
// months menu
$NEWS_MENU_TEMPLATE['months']['start'] = '';
$NEWS_MENU_TEMPLATE['months']['end'] = '';
$NEWS_MENU_TEMPLATE['months']['item'] = '
<img src="{bullet}" alt="bullet" class="icon" /> <a class="e-menu-link newsmonths{active}" href="{url}">{month} ({count})</a>
';
$NEWS_MENU_TEMPLATE['months']['separator'] = '<br />';
// latest menu
$NEWS_MENU_TEMPLATE['latest']['start'] = '';
// Example
//$NEWS_MENU_TEMPLATE['latest']['end'] = '<br />{currentTotal} from {total}';
$NEWS_MENU_TEMPLATE['latest']['end'] = '';
$NEWS_MENU_TEMPLATE['latest']['item'] = '
<img src="{bullet}" alt="bullet" class="icon" /> <a class="e-menu-link newsmonths" href="{NEWSURL}">{NEWSTITLE} ({NEWSCOMMENTCOUNT})</a>
';
$NEWS_MENU_TEMPLATE['latest']['separator'] = '<br />';