mirror of
https://github.com/e107inc/e107.git
synced 2025-06-02 08:55:18 +02:00
eURL and news administration cleanup, server caching added to various news related places, blog calendar fixes
This commit is contained in:
parent
f9ac77365f
commit
c32d6cc02e
@ -14,6 +14,9 @@
|
||||
RewriteCond %{REQUEST_FILENAME} !-d
|
||||
RewriteCond %{REQUEST_FILENAME} !-l
|
||||
|
||||
### TAGWORDS ###
|
||||
RewriteRule ^tagwords/?(.*)$ e107_plugins/tagwords/tagwords.php?q=$1 [L]
|
||||
|
||||
### NEWS SEF URLs - set 'news' to the 'URL identifier' value (news Administration area) ###
|
||||
RewriteRule ^news/?$ news.php [L]
|
||||
RewriteRule ^news/(.*)$ news.php?rewrite=$1 [L]
|
||||
|
@ -9,9 +9,9 @@
|
||||
* URL Management
|
||||
*
|
||||
* $Source: /cvs_backup/e107_0.8/e107_admin/eurl.php,v $
|
||||
* $Revision: 1.9 $
|
||||
* $Date: 2009-08-28 16:11:00 $
|
||||
* $Author: marj_nl_fr $
|
||||
* $Revision: 1.10 $
|
||||
* $Date: 2009-09-25 20:20:23 $
|
||||
* $Author: secretr $
|
||||
*/
|
||||
|
||||
require_once('../class2.php');
|
||||
@ -21,24 +21,19 @@ if (!getperms('L'))
|
||||
exit;
|
||||
}
|
||||
|
||||
include_lan(e_LANGUAGEDIR.e_LANGUAGE.'/admin/lan_'.e_PAGE);
|
||||
e107::includeLan(e_LANGUAGEDIR.e_LANGUAGE.'/admin/lan_'.e_PAGE);
|
||||
|
||||
$e_sub_cat = 'eurl';
|
||||
require_once(e_ADMIN.'auth.php');
|
||||
require_once(e_HANDLER."form_handler.php");
|
||||
require_once(e_HANDLER."form_handler.php");
|
||||
require_once(e_HANDLER."message_handler.php");
|
||||
|
||||
$frm = new e_form(); //new form handler
|
||||
$emessage = &eMessage::getInstance();
|
||||
$urlc = new admin_url_config();
|
||||
$urlc = new admin_eurl_config();
|
||||
|
||||
if (isset($_POST['update']))
|
||||
{
|
||||
//$res = $urlc->update();
|
||||
admin_update($urlc->update(), 'update', false, false, false);
|
||||
//$plug_message = $res ? LAN_UPDATED : ($res === 0 ? LAN_NO_CHANGE : LAN_UPDATED_FAILED);
|
||||
//$plug_message = "<div class='center clear'>".$plug_message."</div><br />";
|
||||
if($urlc->update())
|
||||
{
|
||||
e107::getAdminLog()->logArrayDiffs(e107::getConfig('core')->getPref('url_config'), e107::getConfig('core_backup')->getPref('url_config'), 'EURL_01');
|
||||
}
|
||||
}
|
||||
|
||||
//var_dump($pref['url_config'], $e107->url->getUrl('pm', 'main', array('f'=>'box', 'box'=>2)));
|
||||
@ -46,28 +41,39 @@ if (isset($_POST['update']))
|
||||
$urlc->renderPage();
|
||||
require_once(e_ADMIN.'footer.php');
|
||||
|
||||
class admin_url_config {
|
||||
class admin_eurl_config {
|
||||
|
||||
var $_frm;
|
||||
var $_plug;
|
||||
var $_api;
|
||||
/**
|
||||
* @var e_form
|
||||
*/
|
||||
protected $_frm;
|
||||
|
||||
/**
|
||||
* @var e107plugin
|
||||
*/
|
||||
protected $_plug;
|
||||
|
||||
/**
|
||||
* @var e_file
|
||||
*/
|
||||
protected $_fl;
|
||||
|
||||
/**
|
||||
* @var e107
|
||||
*/
|
||||
protected $_api;
|
||||
|
||||
function admin_url_config()
|
||||
function __construct()
|
||||
{
|
||||
global $e107;
|
||||
require_once(e_HANDLER.'plugin_class.php');
|
||||
require_once(e_HANDLER.'file_class.php');
|
||||
require_once(e_HANDLER."form_handler.php");
|
||||
|
||||
$this->_frm = new e_form();
|
||||
$this->_plug = new e107plugin();
|
||||
$this->_fl = new e_file();
|
||||
$this->_api = &$e107;
|
||||
$this->_api = e107::getInstance();
|
||||
$this->_frm = e107::getObject('e_form');
|
||||
$this->_plug = e107::getObject('e107Plugin');
|
||||
$this->_fl = e107::getFile();
|
||||
}
|
||||
|
||||
function renderPage()
|
||||
{
|
||||
global $emessage;
|
||||
$emessage = e107::getMessageHandler();
|
||||
$empty = "
|
||||
<tr>
|
||||
<td colspan='2'>".LAN_EURL_EMPTY."</td>
|
||||
@ -119,7 +125,7 @@ class admin_url_config {
|
||||
</form>
|
||||
";
|
||||
|
||||
$this->_api->ns->tablerender(PAGE_NAME, $emessage->render().$text);
|
||||
e107::getRender()->tablerender(PAGE_NAME, $emessage->render().$text);
|
||||
}
|
||||
|
||||
function render_sections($id)
|
||||
@ -165,7 +171,7 @@ class admin_url_config {
|
||||
{
|
||||
global $pref;
|
||||
//DEFAULT
|
||||
$checked_def = varset($pref['url_config'][$section['path']]) ? '' : ' checked="checked"';
|
||||
$checked_def = e107::findPref('url_config/'.$section['path']) ? '' : ' checked="checked"';
|
||||
$def = "
|
||||
<div class='field-spacer'>
|
||||
<input type='radio' class='radio' id='{$section['path']}-default' name='cprofile[{$section['path']}]' value='0'{$checked_def} /><label for='{$section['path']}-default'>".LAN_EURL_DEFAULT."</label>
|
||||
@ -261,12 +267,12 @@ class admin_url_config {
|
||||
|
||||
function render_shutdown($save)
|
||||
{
|
||||
global $pref, $emessage;
|
||||
global $pref;
|
||||
if($save && !isset($_POST['update']))
|
||||
{
|
||||
if(save_prefs())
|
||||
{
|
||||
$emessage->add(LAN_EURL_AUTOSAVE);
|
||||
e107::getMessageHandler()->add(LAN_EURL_AUTOSAVE);
|
||||
}
|
||||
|
||||
}
|
||||
@ -296,9 +302,9 @@ class admin_url_config {
|
||||
|
||||
function update()
|
||||
{
|
||||
global $pref;
|
||||
$pref['url_config'] = $_POST['cprofile'];
|
||||
return save_prefs();
|
||||
$core = e107::getConfig();
|
||||
$core->setPosted('url_config', $_POST['cprofile']);
|
||||
return $core->save();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,8 +9,8 @@
|
||||
* News Administration
|
||||
*
|
||||
* $Source: /cvs_backup/e107_0.8/e107_admin/newspost.php,v $
|
||||
* $Revision: 1.54 $
|
||||
* $Date: 2009-09-19 15:27:25 $
|
||||
* $Revision: 1.55 $
|
||||
* $Date: 2009-09-25 20:20:23 $
|
||||
* $Author: secretr $
|
||||
*/
|
||||
require_once("../class2.php");
|
||||
@ -351,9 +351,14 @@ class admin_newspost
|
||||
function clear_cache()
|
||||
{
|
||||
$ecache = e107::getCache();
|
||||
$ecache->clear("news.php");
|
||||
$ecache->clear("othernews");
|
||||
$ecache->clear("othernews2");
|
||||
$ecache->clear("news.php"); //TODO change it to 'news_*' everywhere
|
||||
|
||||
$ecache->clear("news_", false, true); //NEW global news cache prefix
|
||||
//$ecache->clear("nq_news_"); - supported by cache::clear() now
|
||||
//$ecache->clear("nomd5_news_"); supported by cache::clear() now
|
||||
|
||||
$ecache->clear("othernews"); //TODO change it to 'news_othernews' everywhere
|
||||
$ecache->clear("othernews2"); //TODO change it to 'news_othernews2' everywhere
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -502,7 +507,7 @@ class admin_newspost
|
||||
$this->clear_cache();
|
||||
|
||||
$data = array('method'=>'delete', 'table'=>'news', 'id'=>$del_id, 'plugin'=>'news', 'function'=>'delete');
|
||||
$this->show_message($e107->e_event->triggerHook($data), E_MESSAGE_WARNING);
|
||||
$this->show_message(e107::getEvent()->triggerHook($data), E_MESSAGE_WARNING);
|
||||
|
||||
admin_purge_related("news", $del_id);
|
||||
}
|
||||
@ -1655,7 +1660,7 @@ class admin_newspost
|
||||
}
|
||||
//triggerHook
|
||||
$data = array('method'=>'form', 'table'=>'news', 'id'=>$id, 'plugin'=>'news', 'function'=>'create_item');
|
||||
$hooks = $e107->e_event->triggerHook($data);
|
||||
$hooks = e107::getEvent()->triggerHook($data);
|
||||
if(!empty($hooks))
|
||||
{
|
||||
$text .= "
|
||||
|
@ -9,9 +9,9 @@
|
||||
* Core SQL
|
||||
*
|
||||
* $Source: /cvs_backup/e107_0.8/e107_admin/sql/core_sql.php,v $
|
||||
* $Revision: 1.27 $
|
||||
* $Date: 2009-09-17 14:25:09 $
|
||||
* $Author: e107coders $
|
||||
* $Revision: 1.28 $
|
||||
* $Date: 2009-09-25 20:20:23 $
|
||||
* $Author: secretr $
|
||||
*/
|
||||
|
||||
header("location:../index.php");
|
||||
@ -224,7 +224,7 @@ CREATE TABLE news (
|
||||
KEY news_datestamp (news_datestamp),
|
||||
KEY news_sticky (news_sticky),
|
||||
KEY news_render_type (news_render_type),
|
||||
FULLTEXT KEY news_class (news_class)
|
||||
KEY news_class (news_class)
|
||||
) TYPE=MyISAM;
|
||||
|
||||
|
||||
|
@ -1,10 +1,19 @@
|
||||
/*
|
||||
* Copyright e107 Inc e107.org, Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
|
||||
* $Id: news_categories.sc,v 1.5 2009-09-15 15:08:50 secretr Exp $
|
||||
* $Id: news_categories.sc,v 1.6 2009-09-25 20:20:23 secretr Exp $
|
||||
*
|
||||
* News Categories shortcode
|
||||
*/
|
||||
global $e107, $sql,$pref,$tp,$NEWSCAT,$NEWSCAT_ITEM;
|
||||
|
||||
$cString = 'nq_news_categories_sc';
|
||||
$cached = e107::getCache()->retrieve($cString);
|
||||
|
||||
if(false !== $cached)
|
||||
{
|
||||
return $cached;
|
||||
}
|
||||
|
||||
require_once(e_HANDLER."news_class.php");
|
||||
$ix = new news;
|
||||
|
||||
@ -72,7 +81,7 @@ $nbr_cols = (defined("NEWSCAT_COLS")) ? NEWSCAT_COLS : $nbr_cols;
|
||||
$sql2 = new db;
|
||||
$qry = "SELECT nc.*, ncr.news_rewrite_string AS news_category_rewrite_string, ncr.news_rewrite_id AS news_category_rewrite_id FROM #news_category AS nc
|
||||
LEFT JOIN #news_rewrite AS ncr ON nc.category_id=ncr.news_rewrite_source AND ncr.news_rewrite_type=2
|
||||
ORDER BY nc.category_order
|
||||
ORDER BY nc.category_order ASC
|
||||
";
|
||||
if(!$sql2->db_Select_gen($qry))
|
||||
{
|
||||
@ -145,4 +154,5 @@ $nbr_cols = (defined("NEWSCAT_COLS")) ? NEWSCAT_COLS : $nbr_cols;
|
||||
|
||||
$text3 .= "</table></div>";
|
||||
|
||||
e107::getCache()->set($cString, $text3);
|
||||
return $text3;
|
@ -9,8 +9,8 @@
|
||||
* e107 Base Model
|
||||
*
|
||||
* $Source: /cvs_backup/e107_0.8/e107_handlers/model_class.php,v $
|
||||
* $Revision: 1.8 $
|
||||
* $Date: 2009-09-08 12:13:00 $
|
||||
* $Revision: 1.9 $
|
||||
* $Date: 2009-09-25 20:20:23 $
|
||||
* $Author: secretr $
|
||||
*/
|
||||
|
||||
@ -121,7 +121,7 @@ class e_model
|
||||
*/
|
||||
public function setFieldIdName($name)
|
||||
{
|
||||
$this->_idFieldName = $name;
|
||||
$this->_field_id = $name;
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -135,7 +135,7 @@ class e_model
|
||||
*/
|
||||
public function getFieldIdName()
|
||||
{
|
||||
return $this->_idFieldName;
|
||||
return $this->_field_id;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -168,11 +168,11 @@ class e_model
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
if ($this->getIdFieldName())
|
||||
if ($this->getFieldIdName())
|
||||
{
|
||||
return $this->getData($this->getIdFieldName(), 0, null);
|
||||
return $this->get($this->getFieldIdName(), 0);
|
||||
}
|
||||
return $this->getData('id', 0, null);
|
||||
return $this->get('id', 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -439,6 +439,15 @@ class e_model
|
||||
{
|
||||
return $this->_hasData('', '_posted_data');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $key
|
||||
* @return boolean
|
||||
*/
|
||||
public function is($key)
|
||||
{
|
||||
return (isset($this->_data[$key]));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $key
|
||||
@ -448,6 +457,15 @@ class e_model
|
||||
{
|
||||
return $this->_isData($key);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $key
|
||||
* @return boolean
|
||||
*/
|
||||
public function isPosted($key)
|
||||
{
|
||||
return (isset($this->_posted_data[$key]));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $key
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
// e107 Language File.
|
||||
// $Id: lan_log_messages.php,v 1.37 2009-09-13 16:37:18 secretr Exp $
|
||||
// $Id: lan_log_messages.php,v 1.38 2009-09-25 20:20:23 secretr Exp $
|
||||
|
||||
/*
|
||||
The definitions in this file are for standard 'explanatory' messages which might be entered
|
||||
@ -350,6 +350,9 @@ define('LAN_AL_PLUGMAN_02', 'Plugin updated');
|
||||
define('LAN_AL_PLUGMAN_03', 'Plugin uninstalled');
|
||||
define('LAN_AL_PLUGMAN_04', 'Plugin refreshed');
|
||||
|
||||
// URL Manager
|
||||
//---------------
|
||||
define('LAN_AL_EURL_01', 'Site URL configuration changed');
|
||||
|
||||
// Sundry Pseudo-plugins - technically they're plugins, but not worth the file overhead of treating them separately
|
||||
//----------------------
|
||||
|
@ -11,9 +11,9 @@
|
||||
| GNU General Public License (http://gnu.org).
|
||||
|
|
||||
| $Source: /cvs_backup/e107_0.8/e107_plugins/blogcalendar_menu/archive.php,v $
|
||||
| $Revision: 1.4 $
|
||||
| $Date: 2008-10-21 19:03:16 $
|
||||
| $Author: e107steved $
|
||||
| $Revision: 1.5 $
|
||||
| $Date: 2009-09-25 20:20:22 $
|
||||
| $Author: secretr $
|
||||
+----------------------------------------------------------------------------+
|
||||
| Based on code by: Thomas Bouve (crahan@gmx.net)
|
||||
*/
|
||||
@ -92,7 +92,7 @@ for($i = $start_year; $i <= $end_year; $i++)
|
||||
list($xmonth, $xday) = explode(" ", date("n j", $news['news_datestamp']));
|
||||
if (!$day_links[$xmonth][$xday])
|
||||
{
|
||||
$day_links[$xmonth][$xday] = e_BASE."news.php?day.".formatdate($req_year, $xmonth, $xday);
|
||||
$day_links[$xmonth][$xday] = e107::getUrl()->create('core:news', 'main', 'action=day&value='.formatDate($req_year, $xmonth, $xday));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -123,7 +123,7 @@ for($i = 1; $i <= 12; $i++)
|
||||
// href the current month regardless of newsposts or any month with news
|
||||
if (($req_year == $cur_year && $i == $cur_month) || $day_links[$i])
|
||||
{
|
||||
$archive .= "<a class='forumlink' href='".e_BASE."news.php?month.".formatDate($req_year, $i)."'>".$marray[$i-1]."</a>";
|
||||
$archive .= "<a class='forumlink' href='".e107::getUrl()->create('core:news', 'main', 'action=month&value='.formatDate($req_year, $i))."'>".$marray[$i-1]."</a>";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -3,7 +3,7 @@
|
||||
+ ----------------------------------------------------------------------------+
|
||||
| e107 website system
|
||||
|
|
||||
| ©Steve Dunstan 2001-2002
|
||||
| Steve Dunstan 2001-2002
|
||||
| http://e107.org
|
||||
| jalist@e107.org
|
||||
|
|
||||
@ -11,135 +11,145 @@
|
||||
| GNU General Public License (http://gnu.org).
|
||||
|
|
||||
| $Source: /cvs_backup/e107_0.8/e107_plugins/blogcalendar_menu/blogcalendar_menu.php,v $
|
||||
| $Revision: 1.3 $
|
||||
| $Date: 2009-09-23 16:21:09 $
|
||||
| $Revision: 1.4 $
|
||||
| $Date: 2009-09-25 20:20:22 $
|
||||
| $Author: secretr $
|
||||
+----------------------------------------------------------------------------+
|
||||
| Based on code by: Thomas Bouve (crahan@gmx.net)
|
||||
*/
|
||||
if (!defined('e107_INIT')) { exit; }
|
||||
|
||||
require_once(e_PLUGIN."blogcalendar_menu/calendar.php");
|
||||
require_once(e_PLUGIN."blogcalendar_menu/functions.php");
|
||||
|
||||
// ------------------------------
|
||||
// initialization + fetch options
|
||||
// ------------------------------
|
||||
$prefix = e_PLUGIN."blogcalendar_menu";
|
||||
$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";
|
||||
|
||||
// ----------------------------------------------
|
||||
// get the requested and current date information
|
||||
// ----------------------------------------------
|
||||
list($cur_year, $cur_month, $cur_day) = explode(" ", date("Y n j"));
|
||||
if (e_PAGE == 'news.php' && strstr(e_QUERY, "day"))
|
||||
{
|
||||
//$tmp = explode(".", e_QUERY);
|
||||
$tmp = e107::getUrl()->parseRequest('core:news', 'main', urldecode(e_QUERY));
|
||||
$item = $tmp[1];
|
||||
$req_year = intval(substr($item, 0, 4));
|
||||
$req_month = intval(substr($item, 4, 2));
|
||||
// decide on the behaviour here, do we highlight
|
||||
// the day being viewed? or only 'today'?
|
||||
//$req_day = substr($item, 6, 2);
|
||||
// if the requested year and month are the current, then add
|
||||
// the current day to the mix so the calendar highlights it
|
||||
if (($req_year == $cur_year) && ($req_month == $cur_month))
|
||||
{
|
||||
$req_day = $cur_day;
|
||||
}
|
||||
else
|
||||
{
|
||||
$req_day = "";
|
||||
}
|
||||
}
|
||||
elseif(e_PAGE == 'news.php' && strstr(e_QUERY, "month"))
|
||||
{
|
||||
//$tmp = explode(".", e_QUERY);
|
||||
$tmp = e107::getUrl()->parseRequest('core:news', 'main', urldecode(e_QUERY));
|
||||
$item = $tmp[1];
|
||||
$req_year = intval(substr($item, 0, 4));
|
||||
$req_month = intval(substr($item, 4, 2));
|
||||
// if the requested year and month are the current, then add
|
||||
// the current day to the mix so the calendar highlights it
|
||||
if (($req_year == $cur_year) && ($req_month == $cur_month))
|
||||
{
|
||||
$req_day = $cur_day;
|
||||
}
|
||||
else
|
||||
{
|
||||
$req_day = "";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$req_year = $cur_year;
|
||||
$req_month = $cur_month;
|
||||
$req_day = $cur_day;
|
||||
}
|
||||
|
||||
// -------------------------------
|
||||
// create the month selection item
|
||||
// -------------------------------
|
||||
$month_selector = "<div class='forumheader' style='text-align: center; margin-bottom: 2px;'>";
|
||||
$month_selector .= "<select name='activate' onchange='urljump(this.options[selectedIndex].value)' class='tbox'>";
|
||||
$cString = 'nq_news_blogacalendar_menu_'.preg_replace('#[^\w]#', '', $parm);
|
||||
$cached = e107::getCache()->retrieve($cString);
|
||||
|
||||
// get all newsposts since the beginning of the year till now
|
||||
// -------------------------------------------
|
||||
// get links to all newsitems in current month
|
||||
// -------------------------------------------
|
||||
$month_start = mktime(0, 0, 0, $req_month, 1, $req_year);
|
||||
$lastday = date("t", $month_start);
|
||||
$month_end = mktime(23, 59, 59, $req_month, $lastday, $req_year);
|
||||
$start = mktime(0, 0, 0, 1, 1, $req_year);
|
||||
$end = time();
|
||||
$sql->db_Select("news", "news_id, news_datestamp", "news_class IN (".USERCLASS_LIST.") AND news_datestamp > ".intval($start)." AND news_datestamp < ".intval($end));
|
||||
while ($news = $sql->db_Fetch())
|
||||
if(false === $cached)
|
||||
{
|
||||
$xmonth = date("n", $news['news_datestamp']);
|
||||
if (!isset($month_links[$xmonth]) || !$month_links[$xmonth])
|
||||
require_once(e_PLUGIN."blogcalendar_menu/calendar.php");
|
||||
require_once(e_PLUGIN."blogcalendar_menu/functions.php");
|
||||
|
||||
// ------------------------------
|
||||
// initialization + fetch options
|
||||
// ------------------------------
|
||||
$prefix = e_PLUGIN."blogcalendar_menu";
|
||||
$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";
|
||||
|
||||
// ----------------------------------------------
|
||||
// get the requested and current date information
|
||||
// ----------------------------------------------
|
||||
list($cur_year, $cur_month, $cur_day) = explode(" ", date("Y n j"));
|
||||
if (e_PAGE == 'news.php' && strstr(e_QUERY, "day"))
|
||||
{
|
||||
$month_links[$xmonth] = e107::getUrl()->create('core:news', 'main', 'action=month&value='.formatDate($req_year, $xmonth));//e_BASE."news.php?month.".formatDate($req_year, $xmonth);
|
||||
}
|
||||
if($news['news_datestamp'] >= $month_start AND $news['news_datestamp'] <= $month_end)
|
||||
{
|
||||
$xday = date("j", $news['news_datestamp']);
|
||||
if (!isset($day_links[$xday]) || !$day_links[$xday])
|
||||
//$tmp = explode(".", e_QUERY);
|
||||
$tmp = e107::getUrl()->parseRequest('core:news', 'main', urldecode(e_QUERY));
|
||||
$item = $tmp[1];
|
||||
$req_year = intval(substr($item, 0, 4));
|
||||
$req_month = intval(substr($item, 4, 2));
|
||||
// decide on the behaviour here, do we highlight
|
||||
// the day being viewed? or only 'today'?
|
||||
//$req_day = substr($item, 6, 2);
|
||||
// if the requested year and month are the current, then add
|
||||
// the current day to the mix so the calendar highlights it
|
||||
if (($req_year == $cur_year) && ($req_month == $cur_month))
|
||||
{
|
||||
$day_links[$xday] = e107::getUrl()->create('core:news', 'main', 'action=day&value='.formatDate($req_year, $xmonth, $xday));//e_BASE."news.php?day.".formatDate($req_year, $req_month, $xday);
|
||||
$req_day = $cur_day;
|
||||
}
|
||||
else
|
||||
{
|
||||
$req_day = "";
|
||||
}
|
||||
}
|
||||
elseif(e_PAGE == 'news.php' && strstr(e_QUERY, "month"))
|
||||
{
|
||||
//$tmp = explode(".", e_QUERY);
|
||||
$tmp = e107::getUrl()->parseRequest('core:news', 'main', urldecode(e_QUERY));
|
||||
$item = $tmp[1];
|
||||
$req_year = intval(substr($item, 0, 4));
|
||||
$req_month = intval(substr($item, 4, 2));
|
||||
// if the requested year and month are the current, then add
|
||||
// the current day to the mix so the calendar highlights it
|
||||
if (($req_year == $cur_year) && ($req_month == $cur_month))
|
||||
{
|
||||
$req_day = $cur_day;
|
||||
}
|
||||
else
|
||||
{
|
||||
$req_day = "";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$req_year = $cur_year;
|
||||
$req_month = $cur_month;
|
||||
$req_day = $cur_day;
|
||||
}
|
||||
|
||||
// -------------------------------
|
||||
// create the month selection item
|
||||
// -------------------------------
|
||||
$month_selector = "<div class='forumheader' style='text-align: center; margin-bottom: 2px;'>";
|
||||
$month_selector .= "<select name='activate' onchange='urljump(this.options[selectedIndex].value)' class='tbox'>";
|
||||
|
||||
// get all newsposts since the beginning of the year till now
|
||||
// -------------------------------------------
|
||||
// get links to all newsitems in current month
|
||||
// -------------------------------------------
|
||||
$month_start = mktime(0, 0, 0, $req_month, 1, $req_year);
|
||||
$lastday = date("t", $month_start);
|
||||
$month_end = mktime(23, 59, 59, $req_month, $lastday, $req_year);
|
||||
$start = mktime(0, 0, 0, 1, 1, $req_year);
|
||||
$end = time();
|
||||
$sql->db_Select("news", "news_id, news_datestamp", "news_class IN (".USERCLASS_LIST.") AND news_datestamp > ".intval($start)." AND news_datestamp < ".intval($end));
|
||||
while ($news = $sql->db_Fetch())
|
||||
{
|
||||
$xmonth = date("n", $news['news_datestamp']);
|
||||
if (!isset($month_links[$xmonth]) || !$month_links[$xmonth])
|
||||
{
|
||||
$month_links[$xmonth] = e107::getUrl()->create('core:news', 'main', 'action=month&value='.formatDate($req_year, $xmonth));//e_BASE."news.php?month.".formatDate($req_year, $xmonth);
|
||||
}
|
||||
if($news['news_datestamp'] >= $month_start AND $news['news_datestamp'] <= $month_end)
|
||||
{
|
||||
$xday = date("j", $news['news_datestamp']);
|
||||
if (!isset($day_links[$xday]) || !$day_links[$xday])
|
||||
{
|
||||
$day_links[$xday] = e107::getUrl()->create('core:news', 'main', 'action=day&value='.formatDate($req_year, $xmonth, $xday));//e_BASE."news.php?day.".formatDate($req_year, $req_month, $xday);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if we're listing the current year, add the current month to the list regardless of posts
|
||||
if ($req_year == $cur_year)
|
||||
{
|
||||
$month_links[$cur_month] = e107::getUrl()->create('core:news', 'main', 'action=month&value='.formatDate($cur_year, $cur_month));//e_BASE."news.php?month.".formatDate($cur_year, $cur_month);
|
||||
}
|
||||
|
||||
// go over the link array and create the option fields
|
||||
foreach($month_links as $index => $val)
|
||||
{
|
||||
$month_selector .= "<option value='".$val."'";
|
||||
$month_selector .= ($index == $req_month)?" selected='selected'":
|
||||
"";
|
||||
$month_selector .= ">".$marray[$index-1]."</option>";
|
||||
}
|
||||
|
||||
// close the select item
|
||||
$month_selector .= "</select></div>";
|
||||
|
||||
|
||||
// ------------------------
|
||||
// create and show calendar
|
||||
// ------------------------
|
||||
$menu = "<div style='text-align: center;'><table border='0' cellspacing='7'>";
|
||||
$menu .= "<tr><td>$month_selector";
|
||||
$menu .= "<div style='text-align:center'>".calendar($req_day, $req_month, $req_year, $day_links, $pref['blogcal_ws'])."</div>";
|
||||
$menu .= "<div class='forumheader' style='text-align: center; margin-top:2px;'><span class='smalltext'><a href='$prefix/archive.php'>".BLOGCAL_L2."</a></span></div></td></tr>";
|
||||
$menu .= "</table></div>";
|
||||
$cached = $ns->tablerender(BLOGCAL_L1." ".$req_year, $menu, 'blog_calendar', true);
|
||||
|
||||
$cached = e107::getCache()->set($cString, $menu_text);
|
||||
}
|
||||
|
||||
// if we're listing the current year, add the current month to the list regardless of posts
|
||||
if ($req_year == $cur_year)
|
||||
{
|
||||
$month_links[$cur_month] = e107::getUrl()->create('core:news', 'main', 'action=month&value='.formatDate($cur_year, $cur_month));//e_BASE."news.php?month.".formatDate($cur_year, $cur_month);
|
||||
}
|
||||
|
||||
// go over the link array and create the option fields
|
||||
foreach($month_links as $index => $val)
|
||||
{
|
||||
$month_selector .= "<option value='".$val."'";
|
||||
$month_selector .= ($index == $req_month)?" selected='selected'":
|
||||
"";
|
||||
$month_selector .= ">".$marray[$index-1]."</option>";
|
||||
}
|
||||
|
||||
// close the select item
|
||||
$month_selector .= "</select></div>";
|
||||
|
||||
|
||||
// ------------------------
|
||||
// create and show calendar
|
||||
// ------------------------
|
||||
$menu = "<div style='text-align: center;'><table border='0' cellspacing='7'>";
|
||||
$menu .= "<tr><td>$month_selector";
|
||||
$menu .= "<div style='text-align:center'>".calendar($req_day, $req_month, $req_year, $day_links, $pref['blogcal_ws'])."</div>";
|
||||
$menu .= "<div class='forumheader' style='text-align: center; margin-top:2px;'><span class='smalltext'><a href='$prefix/archive.php'>".BLOGCAL_L2."</a></span></div></td></tr>";
|
||||
$menu .= "</table></div>";
|
||||
$ns->tablerender(BLOGCAL_L1." ".$req_year, $menu, 'blog_calender');
|
||||
echo $cached;
|
||||
?>
|
29
e107_plugins/news/news_categories_menu.php
Normal file
29
e107_plugins/news/news_categories_menu.php
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
if (!defined('e107_INIT')) { exit; }
|
||||
|
||||
$cacheString = 'nq_news_categories_menu_'.preg_replace('#[^\w]#', '', $parm);
|
||||
$cached = e107::getCache()->retrieve($cacheString);
|
||||
if(false === $cached)
|
||||
{
|
||||
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 = array();
|
||||
$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 />';
|
||||
|
||||
//always return
|
||||
$parms['return'] = true;
|
||||
|
||||
$cached = $ctree->loadActive()->render($parms, true, $template);
|
||||
e107::getCache()->set($cacheString, $cached);
|
||||
}
|
||||
|
||||
echo $cached;
|
Loading…
x
Reference in New Issue
Block a user