diff --git a/e107_core/shortcodes/batch/page_shortcodes.php b/e107_core/shortcodes/batch/page_shortcodes.php new file mode 100644 index 000000000..54601a15c --- /dev/null +++ b/e107_core/shortcodes/batch/page_shortcodes.php @@ -0,0 +1,163 @@ +toHTML($this->getParserVars()->title, true, 'TITLE'); + } + + function sc_cpagesubtitle() + { + $subtitle = $this->getParserVars()->sub_title; + return $subtitle ? e107::getParser()->toHTML($subtitle, true, 'TITLE') : ''; + } + + + function sc_cpagebody() + { + // already parsed + return $this->getParserVars()->text; + } + + function sc_cpageauthor($parm) + { + $parms = eHelper::scParams($parm); + $author = ''; + $url = e107::getUrl()->create('user/profile/view', array('name' => $this->page['user_name'], 'id' => $this->page['user_id'])); + + if(isset($parms['url'])) + { + return $url; + } + + if($this->page['page_author']) + { + // currently this field used as Real Name, no matter what the db name says + if($this->page['user_login'] && !isset($parms['user'])) $author = $this->page['user_login']; + elseif($this->page['user_name']) $author = preg_replace('/[^\w\pL\s]+/u', ' ', $this->page['user_name']); + } + + if(empty($author)) return ''; + + + + if(isset($parms['nolink'])) + { + return $author; + } + //TODO title lan + return ''.$author.''; + } + + function sc_cpagedate($parm) + { + if(empty($parm)) + { + return e107::getDateConvert()->convert_date($this->page['page_datestamp'], 'long'); + } + return e107::getDateConvert()->convert_date($this->page['page_datestamp'], $parm); + } + + function sc_cpageid() + { + return $this->page['page_id']; + } + + // Not a shortcode really, as it shouldn't be cached at all :/ + function cpagecomments() + { + $com = $this->getParserVars()->comments; + //if($parm && isset($com[$parm])) return $com[$parm]; + return $com['comment'].$com['comment_form']; + } + + function sc_cpagenav() + { + return $this->getParserVars()->np; + } + + function sc_cpagerating() + { + return $this->getParserVars()->rating; + } + + function sc_cpagemessage() + { + return e107::getMessage()->render(); + } + + /** + * Auto-thumbnailing now allowed. + * New sc parameter standards + * Exampes: + * - {CPAGETHUMBNAIL=e_MEDIA/images/someimage.jpg|type=tag&w=200} render link with thumbnail max width 200px + * - {CPAGETHUMBNAIL=images/someimage.jpg|w=200} same as above + * - {CPAGETHUMBNAIL=images/someimage.jpg|type=src&aw=200&ah=200} return thumb link only, size forced to 200px X 200px (smart thumbnailing close to how Facebook is doing it) + * + * @see eHelper::scDualParams() + * @see eHelper::scParams() + */ + function sc_cpagehumbnail($parm = '') + { + $parms = eHelper::scDualParams($parm); + if(empty($parms[1])) return ''; + + $tp = e107::getParser(); + $path = rawurldecode($parms[1]); + + if(substr($path, 0, 2) === 'e_') $path = str_replace($tp->getUrlConstants('raw'), $tp->getUrlConstants('sc'), $path); + elseif($path[0] !== '{') $path = '{e_MEDIA}'.$path; + + $thumb = $tp->thumbUrl($path); + $type = varset($parms[2]['type'], 'tag'); + + switch($type) + { + case 'src': + return $thumb; + break; + + case 'link': + return ''.varset($parms[1]['alt']).''; + break; + + case 'tag': + default: + return ''.varset($parms[1]['alt']).''; + break; + } + } + + function sc_cpagelink($parm) + { + $url = $this->sc_cpageurl(); + + if($parm == 'href' || !$url) + { + return $url; + } + return ''.$this->sc_cpagetitle().''; + } + + function sc_cpageurl() + { + return e107::getUrl()->create('page/view', $this->page, array('allow' => 'page_sef,page_title,page_id')); + } +} diff --git a/e107_core/shortcodes/single/nextprev.php b/e107_core/shortcodes/single/nextprev.php index 91ac92b12..1fdd8e705 100644 --- a/e107_core/shortcodes/single/nextprev.php +++ b/e107_core/shortcodes/single/nextprev.php @@ -43,6 +43,8 @@ * - plugin (string) [optional]: plugin name used for template loading * - tmpl_prefix (string) [optional]: template keys prefix; core supported are 'default' and 'dropdown', default depends on 'old_np' pref * - navcount (integer) [optional]: number of navigation items to be shown, minimal allowed value is 4, default is 10 + * - nonavcount (no value) [optional]: if is set it'll disable navigation counting (navcount will be ignored) + * - bullet (string) [optional]: currently it should contain the markup to be prepended to the navigation item title * * WARNING: You have to do rawuldecode() on url, caption and title parameter values (before passing them to the shortcode) * or you'll break the whole script @@ -134,15 +136,24 @@ function nextprev_shortcode($parm = '') if($total_pages <= 1) { return ''; } // urldecoded once by parse_str() - if(substr($parm['url'], 0, 5) == 'url::') + if(substr($parm['url'], 0, 7) == 'route::') { // New - use URL assembling engine - // Format is: url::route::params::options + // Format is: route::module/controller/action::urlParams::urlOptions // Example: url::news/list/category::id=xxx&name=yyy&page=--PAGE--::full=1 // WARNING - url parameter string have to be rawurlencode-ed BEFORE passed to the shortcode, or it'll break everything $urlParms = explode('::', $parm['url']); $url = str_replace(array('--FROM--', '--AMP--'), array('[FROM]', '&'), $e107->url->create($urlParms[1], $urlParms[2], varset($urlParms[3]))); } + elseif(substr($parm['url'], 0, 5) == 'url::') + { + // New - use URL assembling engine + // Format is: url::module/controller/action?id=xxx&name=yyy&page=--PAGE--::full=1 + // WARNING - url parameter string have to be rawurlencode-ed BEFORE passed to the shortcode, or it'll break everything + $urlParms = explode('::', $parm['url']); + $url = str_replace(array('--FROM--', '--AMP--'), array('[FROM]', '&'), $e107->url->create($urlParms[1], array(), varset($urlParms[2]))); + } + // just regular full or absolute URL else $url = str_replace(array('--FROM--', '--AMP--'), array('[FROM]', '&'), $parm['url']); // Simple parser vars @@ -161,11 +172,24 @@ function nextprev_shortcode($parm = '') // urldecoded by parse_str() $pagetitle = explode('|',$parm['pagetitle']); + + // new - bullet support + $bullet = vartrue($parm['bullet'], ''); - // navigation number settings - $navcount = abs(intval(vartrue($parm['navcount'], 10))); // prevent infinite loop! - if($navcount < 4) $navcount = 4; - $navmid = floor($navcount/2); + // no navigation counter + if(isset($parm['nonavcount'])) + { + $navcount = $total_pages; + $navmid = 0; + } + else + { + // navigation number settings + $navcount = abs(intval(vartrue($parm['navcount'], 10))); // prevent infinite loop! + if($navcount < 4) $navcount = 4; + $navmid = floor($navcount/2); + } + // get template - nextprev_template.php, support for plugin template locations - myplug/templates/nextprev_template.php $tmpl = e107::getTemplate(varset($parm['plugin'], null), 'nextprev'); @@ -173,9 +197,9 @@ function nextprev_shortcode($parm = '') // init advanced navigation visibility $show_first = $show_prev = ($current_page != 1); $show_last = $show_next = ($current_page != $total_pages); - + // Render - // XXX - parseTemplate vs simpleParse ??? Currently can't find a reason why we should parse via parseTemplate + // Parse via simpleParse() $tp = e107::getParser(); // Nextprev navigation start @@ -248,6 +272,7 @@ function nextprev_shortcode($parm = '') } $e_vars_loop = new e_vars(); + $e_vars_loop->bullet = $bullet; $ret_items = array(); for($c = $loop_start; $c < $loop_end; $c++) { diff --git a/e107_core/url/news/rewrite_extended_url.php b/e107_core/url/news/rewrite_extended_url.php index ab5607fd2..bb6817bfb 100644 --- a/e107_core/url/news/rewrite_extended_url.php +++ b/e107_core/url/news/rewrite_extended_url.php @@ -90,9 +90,9 @@ class core_news_rewrite_extended_url extends eUrlConfig ### View news item - kinda catch all - very bad performance when News is chosen as default namespace - two additional DB queries on every site call! ## Leading category name - uncomment to enable - '/' => array('view/item', 'mapVars' => array('news_title' => 'name', 'mapVars' => array('category_name' => 'category', 'news_title' => 'name', 'news_id' => 'id'), 'category_name' => 'category'), 'legacyQuery' => 'extend.{name}', 'parseCallback' => 'itemIdByTitle'), + '/' => array('view/item', 'mapVars' => array('category_name' => 'category', 'news_title' => 'name', 'news_id' => 'id'), 'legacyQuery' => 'extend.{name}', 'parseCallback' => 'itemIdByTitle'), // Base location as item view - fallback if category sef is missing - '' => array('view/item', 'mapVars' => array('news_title' => 'name'), 'mapVars' => array('news_id' => 'id', 'news_title' => 'name'), 'legacyQuery' => 'extend.{name}', 'parseCallback' => 'itemIdByTitle'), + '' => array('view/item', 'mapVars' => array('news_id' => 'id', 'news_title' => 'name'), 'legacyQuery' => 'extend.{name}', 'parseCallback' => 'itemIdByTitle'), // fallback if news sef is missing 'View/' => array('view/item', 'mapVars' => array('news_id' => 'id'), 'legacyQuery' => 'extend.{id}'), diff --git a/e107_core/url/page/sef_url.php b/e107_core/url/page/sef_url.php new file mode 100644 index 000000000..0d165116d --- /dev/null +++ b/e107_core/url/page/sef_url.php @@ -0,0 +1,99 @@ + array( + 'allowMain' => true, + 'noSingleEntry' => false, // [optional] default false; disallow this module to be shown via single entry point when this config is used + 'legacy' => '{e_BASE}page.php', // [optional] default empty; if it's a legacy module (no single entry point support) - URL to the entry point script + 'format' => 'path', // get|path - notify core for the current URL format, if set to 'get' rules will be ignored + 'selfParse' => false, // [optional] default false; use only this->parse() method, no core routine URL parsing + 'selfCreate' => false, // [optional] default false; use only this->create() method, no core routine URL creating + 'defaultRoute' => 'view/index',// [optional] default empty; route (no leading module) used when module is found with no additional controller/action information e.g. /news/ + 'errorRoute' => '', // [optional] default empty; route (no leading module) used when module is found but no inner route is matched, leave empty to force error 404 page + 'urlSuffix' => '', // [optional] default empty; string to append to the URL (e.g. .html) + + 'mapVars' => array( + 'page_id' => 'id', + 'page_title' => 'name', + ), + + 'allowVars' => array( + 'page', 'id', + ), + ), + + 'rules' => array( + ### using only title for pages is risky enough (non-unique title, possible bad characters) + //'' => array('view/index', 'allowVars' => array('name'),'legacyQuery' => '{name}.{page}', 'parseCallback' => 'itemIdByTitle'), + '/' => array('view/index', 'legacyQuery' => '{id}.{page}', ), + + ### fallback when assembling method don't know the title of the page - build by ID only + '' => array('view/index', 'legacyQuery' => '{id}.{page}', ), + + ### page list + 'list' => array('list/index', 'legacyQuery' => '', ), + '/' => array('list/index', 'legacyQuery' => '', ), + ) // rule set array + ); + } + + /** + * Admin callback + * Language file not loaded as all language data is inside the lan_eurl.php (loaded by default on administration URL page) + */ + public function admin() + { + // static may be used for performance + static $admin = array( + 'labels' => array( + 'name' => LAN_EURL_CORE_PAGE, // Module name + 'label' => LAN_EURL_PAGE_SEF_LABEL, // Current profile name + 'description' => LAN_EURL_PAGE_SEF_DESCR, // + ), + 'form' => array(), // Under construction - additional configuration options + 'callbacks' => array(), // Under construction - could be used for e.g. URL generator functionallity + ); + + return $admin; + } + + ### CUSTOM METHODS ### + + /** + * view/item by name callback + * @param eRequest $request + */ + public function itemIdByTitle(eRequest $request) + { + $name = $request->getRequestParam('name'); + if(($id = $request->getRequestParam('id'))) + { + $request->setRequestParam('name', $id); + return; + } + elseif(!$name) return; + elseif(is_numeric($name)) + { + return; + } + + $sql = e107::getDb('url'); + $name = e107::getParser()->toDB($name);var_dump($name); + if($sql->db_Select('page', 'page_id', "page_theme='' AND page_title='{$name}'")) // TODO - it'll be page_sef (new) field + { + $name = $sql->db_Fetch(); + $request->setRequestParam('name', $name['page_id']); + } + else $request->setRequestParam('name', 0); + } +} diff --git a/e107_core/url/page/url.php b/e107_core/url/page/url.php new file mode 100644 index 000000000..2c34c62c8 --- /dev/null +++ b/e107_core/url/page/url.php @@ -0,0 +1,79 @@ + array( + 'noSingleEntry' => true, // [optional] default false; disallow this module to be shown via single entry point when this config is used + 'legacy' => '{e_BASE}page.php', // [optional] default empty; if it's a legacy module (no single entry point support) - URL to the entry point script + 'format' => 'get', // get|path - notify core for the current URL format, if set to 'get' rules will be ignored + 'selfParse' => true, // [optional] default false; use only this->parse() method, no core routine URL parsing + 'selfCreate' => true, // [optional] default false; use only this->create() method, no core routine URL creating + 'defaultRoute' => '', // [optional] default empty; route (no leading module) used when module is found with no additional controller/action information e.g. /news/ + 'errorRoute' => '', // [optional] default empty; route (no leading module) used when module is found but no inner route is matched, leave empty to force error 404 page + 'urlSuffix' => '', // [optional] default empty; string to append to the URL (e.g. .html) + 'mapVars' => array(), + 'allowVars' => array(), + ), + + 'rules' => array() // rule set array + ); + } + + /** + * + */ + public function create($route, $params = array()) + { + if(!$params) return 'page.php'; + + if(is_string($route)) $route = explode('/', $route, 2); + if(!varset($route[1])) $route[1] = 'index'; + + ## aliases as retrieved from the DB, map vars to proper values + if(isset($params['page_title']) && !empty($params['page_title'])) $params['name'] = $params['page_title']; + if(isset($params['page_id']) && !empty($params['page_id'])) $params['id'] = $params['page_id']; + + $url = 'page.php?'; + if('--FROM--' != vartrue($params['page'])) $page = varset($params['page']) ? intval($params['page']) : '0'; + else $page = '--FROM--'; + + $url .= intval($params['id']).($page ? '.'.$page : ''); + return $url; + } + + /** + * Admin callback + * Language file not loaded as all language data is inside the lan_eurl.php (loaded by default on administration URL page) + */ + public function admin() + { + // static may be used for performance + static $admin = array( + 'labels' => array( + 'name' => LAN_EURL_CORE_PAGE, // Module name + 'label' => LAN_EURL_PAGE_DEFAULT_LABEL, // Current profile name + 'description' => LAN_EURL_PAGE_DEFAULT_DESCR, // + ), + 'form' => array(), // Under construction - additional configuration options + 'callbacks' => array(), // Under construction - could be used for e.g. URL generator functionallity + ); + + return $admin; + } + + public function parse($pathInfo) + { + // this config doesn't support parsing, it's done by the module entry script (news.php) + // this means News are not available via single entry point if this config is currently active + return false; + } +} diff --git a/e107_core/url/system/rewrite_url.php b/e107_core/url/system/rewrite_url.php index df9e44111..0745a24b5 100644 --- a/e107_core/url/system/rewrite_url.php +++ b/e107_core/url/system/rewrite_url.php @@ -1,6 +1,6 @@ assemble($route, $params, $options); + return e107::getParser()->createConstants($url, 'mix'); + } + /** * Assemble system URL * Examples: @@ -1772,7 +1786,7 @@ class eRouter if(is_string($options)) parse_str($options, $options); $options = array_merge($this->_defaultAssembleOptions, $options); $base = ($options['full'] ? SITEURLBASE : '').$request->getBasePath(); - + $anc = ''; if(is_string($params)) parse_str($params, $params); @@ -1782,6 +1796,30 @@ class eRouter usnet($params['#']); } + // Config independent - Deny parameter keys, useful for directly denying sensitive data e.g. password db fields + if(isset($options['deny'])) + { + $list = array_map('trim', explode(',', $options['deny'])); + foreach ($list as $value) + { + unset($params[$value]); + } + unset($list); + } + + // Config independent - allow parameter keys, useful to directly allow data (and not to rely on config allowVars) e.g. when retrieved from db + if(isset($options['allow'])) + { + $list = array_map('trim', explode(',', $options['allow'])); + $_params = $params; + $params = array(); + foreach ($list as $value) + { + if(isset($_params[$value])) $params[$value] = $_params[$value]; + } + unset($list, $_params); + } + # Optional convenient masks for creating system URL's if($route === '/' || empty($route)) { diff --git a/e107_handlers/e107Url.php b/e107_handlers/e107Url.php index 08184c4b7..64f0d7554 100755 --- a/e107_handlers/e107Url.php +++ b/e107_handlers/e107Url.php @@ -46,6 +46,11 @@ class eUrl return $this->router()->assemble($route, $params, $options); } + public function sc($route, $params = array(), $options = array()) + { + return $this->router()->assembleSc($route, $params, $options); + } + /** * @return eRouter */ diff --git a/e107_handlers/e107_class.php b/e107_handlers/e107_class.php index cb699a44f..35d9d6a4d 100644 --- a/e107_handlers/e107_class.php +++ b/e107_handlers/e107_class.php @@ -1631,6 +1631,9 @@ class e107 /** * Return a list of available template IDs for a plugin(eg. $MYTEMPLATE['my_id'] -> array('id' => 'My Id')) + * + * FIXME - the format of $allinfo=true array is not usable at all, convert it so that it's compatible with e_form::selectbox() method + * * @param string $plugin_name * @param string $template_id [optional] if different from $plugin_name; * @param mixed $where true - current theme, 'admin' - admin theme, 'front' (default) - front theme diff --git a/e107_handlers/e_parse_class.php b/e107_handlers/e_parse_class.php index bec71794a..15856234b 100644 --- a/e107_handlers/e_parse_class.php +++ b/e107_handlers/e_parse_class.php @@ -2151,6 +2151,7 @@ class e_parse //'{e_HANDLER}' => e_HANDLER_ABS, - no ABS path available '{e_MEDIA}' => e_MEDIA_ABS, '{e_WEB}' => e_WEB_ABS, + '{e_BASE}' => e_HTTP, ); break; @@ -2175,6 +2176,7 @@ class e_parse //'{e_HANDLER}' => e_HANDLER_ABS, - no ABS path available '{e_MEDIA}' => SITEURLBASE.e_MEDIA_ABS, '{e_WEB}' => SITEURLBASE.e_WEB_ABS, + '{e_BASE}' => SITEURL, ); break; diff --git a/e107_handlers/rate_class.php b/e107_handlers/rate_class.php index 49bb0be1f..20fc3680b 100644 --- a/e107_handlers/rate_class.php +++ b/e107_handlers/rate_class.php @@ -2,16 +2,12 @@ /* * e107 website system * - * Copyright (C) 2008-2009 e107 Inc (e107.org) + * Copyright (C) e107 Inc (e107.org) * Released under the terms and conditions of the * GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * - * - * - * $Source: /cvs_backup/e107_0.8/e107_handlers/rate_class.php,v $ - * $Revision$ - * $Date$ - * $Author$ + * $URL$ + * $Id$ */ if (!defined('e107_INIT')) { exit; } @@ -25,16 +21,17 @@ class rater { $table = preg_replace('/\W/', '', $table); $id = intval($id); - $self = $_SERVER['PHP_SELF']; - if ($_SERVER['QUERY_STRING']) { - $self .= "?".$_SERVER['QUERY_STRING']; - } + // $self = $_SERVER['PHP_SELF']; + // if ($_SERVER['QUERY_STRING']) { + // $self .= "?".$_SERVER['QUERY_STRING']; + // } + $self = e_REQUEST_URI; $jump = ""; $url = ""; if($mode==FALSE){ $jump = "onchange='urljump(this.options[selectedIndex].value)'"; - $url = e_BASE."rate.php?"; + $url = e_HTTP."rate.php?"; } $str = $text." @@ -177,14 +174,14 @@ class rater { if($ratearray = $this -> getrating($table, $id, $userid)){ if($ratearray[1] > 0){ for($c=1; $c<= $ratearray[1]; $c++){ - $rate .= ""; + $rate .= ""; } if($ratearray[1] < 10){ for($c=9; $c>=$ratearray[1]; $c--){ - $rate .= ""; + $rate .= ""; } } - $rate .= ""; + $rate .= ""; if($ratearray[2] == ""){ $ratearray[2] = 0; } $rate .= " ".$ratearray[1].".".$ratearray[2]; if(!$userid){ @@ -221,4 +218,3 @@ class rater { return $sql -> db_Delete("rate", "rate_itemid='{$id}' AND rate_table='{$table}'"); } } -?> diff --git a/e107_languages/English/admin/lan_eurl.php b/e107_languages/English/admin/lan_eurl.php index a6a62cb2d..0adc8b388 100644 --- a/e107_languages/English/admin/lan_eurl.php +++ b/e107_languages/English/admin/lan_eurl.php @@ -76,6 +76,13 @@ define("LAN_EURL_USER_DEFAULT_DESCR", "Legacy direct URLs. Example: http://yours define("LAN_EURL_USER_REWRITE_LABEL", "User Friendly URLs (mod_rewrite)"); define("LAN_EURL_USER_REWRITE_DESCR", "Search engine and user friendly URLs.
Example: http://yoursite.com/user/UserDisplayName"); +// Users +define("LAN_EURL_CORE_PAGE", "Custom Pages"); +define("LAN_EURL_PAGE_DEFAULT_LABEL", "Default"); +define("LAN_EURL_PAGE_DEFAULT_DESCR", "Legacy direct URLs. Example: http://yoursite.com/page.php?1"); +define("LAN_EURL_PAGE_SEF_LABEL", "User Friendly URLs"); +define("LAN_EURL_PAGE_SEF_DESCR", "Search engine and user friendly URLs.
Example: http://yoursite.com/page/Page-Name"); + // Search define("LAN_EURL_CORE_SEARCH", "Search"); define("LAN_EURL_SEARCH_DEFAULT_LABEL", "Default Search URL"); diff --git a/e107_plugins/page/templates/page_template.php b/e107_plugins/page/templates/page_template.php deleted file mode 100644 index 664c86f6e..000000000 --- a/e107_plugins/page/templates/page_template.php +++ /dev/null @@ -1,25 +0,0 @@ -"; - - $PAGE_TEMPLATE['other1'] = ""; - - $PAGE_TEMPLATE['other2'] = ""; - -?> \ No newline at end of file diff --git a/e107_plugins/siteinfo/e_shortcode.php b/e107_plugins/siteinfo/e_shortcode.php index b8bb1a0c6..3ec1da500 100644 --- a/e107_plugins/siteinfo/e_shortcode.php +++ b/e107_plugins/siteinfo/e_shortcode.php @@ -90,7 +90,7 @@ class siteinfo_shortcodes // must match the folder name of the plugin. function sc_theme_disclaimer($parm) { - global $pref; + $pref = e107::getPref(); return (defined('THEME_DISCLAIMER') && $pref['displaythemeinfo'] ? THEME_DISCLAIMER : ''); } diff --git a/e107_plugins/tagwords/admin_tagwords_config.php b/e107_plugins/tagwords/admin_tagwords_config.php index 7686437cc..4963c31aa 100644 --- a/e107_plugins/tagwords/admin_tagwords_config.php +++ b/e107_plugins/tagwords/admin_tagwords_config.php @@ -2,16 +2,14 @@ /* * e107 website system * - * Copyright (C) 2008-2009 e107 Inc (e107.org) + * Copyright (C) e107 Inc (e107.org) * Released under the terms and conditions of the * GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * * Tagwords Admin * - * $Source: /cvs_backup/e107_0.8/e107_plugins/tagwords/admin_tagwords_config.php,v $ - * $Revision$ - * $Date$ - * $Author$ + * $URL$ + * $Id$ * */ diff --git a/e107_plugins/tagwords/languages/English.php b/e107_plugins/tagwords/languages/English.php index eb614708b..d97eabf07 100644 --- a/e107_plugins/tagwords/languages/English.php +++ b/e107_plugins/tagwords/languages/English.php @@ -1,5 +1,10 @@ row = $this->getRecord($id); } $url = e_BASE."page.php?".$this->row['page_id']; + $url = e107::getUrl()->create('page/view', $this->row, 'allow=page_id,page_title,page_sef'); return "".$this->e107->tp->toHTML($this->row['page_title'], TRUE, '').""; } diff --git a/e107_themes/jayya/style.css b/e107_themes/jayya/style.css index 35802fd25..f022e5dca 100644 --- a/e107_themes/jayya/style.css +++ b/e107_themes/jayya/style.css @@ -814,4 +814,9 @@ h2.caption { font-size: 200%; font-weight:bold; } #core-frontpage-edit .tbox { width: 80%;} #core-frontpage-edit select.tbox { width: 50%;} #core-frontpage-edit .buttons-bar select.tbox { width: 140px; } -#core-frontpage-edit .buttons-bar { clear: both; } \ No newline at end of file +#core-frontpage-edit .buttons-bar { clear: both; } + +/** Custom Pages Front-end **/ +.cpage-nav { padding: 5px; margin: 0px 5px 10px 10px; } +a.cpage-np { font-size: 14px; } +a.cpage-np.current { text-decoration: none; } \ No newline at end of file diff --git a/e107_themes/templates/nextprev_template.php b/e107_themes/templates/nextprev_template.php index 513f8187e..6eb4c993b 100644 --- a/e107_themes/templates/nextprev_template.php +++ b/e107_themes/templates/nextprev_template.php @@ -74,4 +74,31 @@ $NEXTPREV_TEMPLATE['dropdown_items_end'] = ''; //$NEXTPREV_TEMPLATE['dropdown_separator'] = ''; $NEXTPREV_TEMPLATE['dropdown_separator'] = ''; +/** + * Default Page core area navigation + */ +$NEXTPREV_TEMPLATE['page_start'] = ' + +
+'; + +$NEXTPREV_TEMPLATE['page_end'] = ' +
+ +'; + +$NEXTPREV_TEMPLATE['page_nav_caption'] = ''; + +$NEXTPREV_TEMPLATE['page_nav_first'] = ''; +$NEXTPREV_TEMPLATE['page_nav_prev'] = ''; +$NEXTPREV_TEMPLATE['page_nav_last'] = ''; +$NEXTPREV_TEMPLATE['page_nav_next'] = ''; + +$NEXTPREV_TEMPLATE['page_items_start'] = ''; +$NEXTPREV_TEMPLATE['page_item'] = '{bullet} {label}'; +$NEXTPREV_TEMPLATE['page_item_current'] = '{bullet} {label}'; +$NEXTPREV_TEMPLATE['page_items_end'] = ''; + +//$NEXTPREV_TEMPLATE['default_separator'] = ''; +$NEXTPREV_TEMPLATE['page_separator'] = '
'; ?> \ No newline at end of file diff --git a/e107_themes/templates/page_template.php b/e107_themes/templates/page_template.php new file mode 100644 index 000000000..5c2f7029b --- /dev/null +++ b/e107_themes/templates/page_template.php @@ -0,0 +1,97 @@ +'; +$sc_style['CPAGESUBTITLE|default']['post'] = ''; + +$sc_style['CPAGEMESSAGE|default']['pre'] = ''; +$sc_style['CPAGEMESSAGE|default']['post'] = '
'; + +$sc_style['CPAGENAV|default']['pre'] = '
'; +$sc_style['CPAGENAV|default']['post'] = '
'; + +#### default template - BC #### + // used only for parsing comment outside of the page tablerender-ed content + // leave empty if you integrate page comments inside the main page template + $PAGE_TEMPLATE['default']['page'] = ' + {PAGE} + {PAGECOMMENTS} + '; + + // always used - it's inside the {PAGE} sc from 'page' template + $PAGE_TEMPLATE['default']['start'] = '
'; + + // page body + $PAGE_TEMPLATE['default']['body'] = ' + {CPAGEMESSAGE|default} + +
{CPAGEAUTHOR|default}{CPAGEDATE|default}
+ {CPAGESUBTITLE|default} +
+ + {CPAGENAV|default} + {CPAGEBODY|default} + +
+ {CPAGERATING|default} + '; + + // used only when password authorization is required + $PAGE_TEMPLATE['default']['authorize'] = ' +
+ {message} + {form_open} +

{caption}

+
{label} {password} {submit}
+ {form_close} +
+ '; + + // used when access is denied (restriction by class) + $PAGE_TEMPLATE['default']['restricted'] = ' + {text} + '; + + // used when page is not found + $PAGE_TEMPLATE['default']['notfound'] = ' + {text} + '; + + // always used + $PAGE_TEMPLATE['default']['end'] = '
'; + + // options per template - disable table render + $PAGE_TEMPLATE['default']['noTableRender'] = false; + + // define different tablerender mode here + $PAGE_TEMPLATE['default']['tableRender'] = 'cpage'; + + +#### No table render example template #### + $PAGE_TEMPLATE['custom']['start'] = '
'; + + $PAGE_TEMPLATE['custom']['body'] = ''; + + $PAGE_TEMPLATE['custom']['authorize'] = ' + + '; + + $PAGE_TEMPLATE['custom']['restricted'] = ' + + '; + + $PAGE_TEMPLATE['custom']['end'] = '
'; + + + $PAGE_TEMPLATE['custom']['noTableRender'] = true; + $PAGE_TEMPLATE['custom']['tableRender'] = ''; + diff --git a/page.php b/page.php index 147426d36..b7d2a34f3 100644 --- a/page.php +++ b/page.php @@ -1,230 +1,335 @@ setPageCookie(); -} if(!e_QUERY) { require_once(HEADERF); - $tmp = $page -> listPages(); + $tmp = $e107CorePage->listPages(); if(is_array($tmp)) { - $ns -> tablerender($tmp['title'], $tmp['text']); + $ns->tablerender($tmp['title'], $tmp['text']); require_once(FOOTERF); exit; } } else { - - $cacheString = 'page_'.$page->pageID; - $cachePageTitle = 'page-t_'.$page->pageID; - - if($cacheData = $e107cache->retrieve($cacheString)) - { - - list($pagetitle,$comment_flag) = explode("^",$e107cache->retrieve($cachePageTitle)); - define("e_PAGETITLE", $pagetitle); - require_once(HEADERF); - echo $cacheData; - - } - else - { - $e107_core_custom_pages = $page -> showPage(); - define("e_PAGETITLE", $e107_core_custom_pages['title']); - require_once(HEADERF); - - if ($e107_core_custom_pages['err']) // Need to display error block after header defined - { - $ns -> tablerender($e107_core_custom_pages['title'], $e107_core_custom_pages['text'],"cpage"); - require_once(FOOTERF); - exit; - } - - if ($e107_core_custom_pages['cachecontrol'] == TRUE) - { - ob_start(); - $ns -> tablerender($e107_core_custom_pages['title'], $e107_core_custom_pages['text'],"cpage"); - $cache_data = ob_get_flush(); - $e107cache->set($cacheString, $cache_data); - $e107cache->set($cachePageTitle, $e107_core_custom_pages['title']."^".$e107_core_custom_pages['comment_flag']); - $comment_flag = $e107_core_custom_pages['comment_flag']; - } - else - { - $ns -> tablerender($e107_core_custom_pages['title'], $e107_core_custom_pages['text'],"cpage"); - $comment_flag = $e107_core_custom_pages['comment_flag']; - } - } - - $page -> title = $e107_core_custom_pages['title']; - if($com = $page -> pageComment($comment_flag)) - { - echo $com['comment'].$com['comment_form']; - } + + $e107CorePage->processViewPage(); + + require_once(HEADERF); + + echo $e107CorePage->showPage(); + + require_once(FOOTERF); + exit; } -require_once(FOOTERF); - /* EOF */ class pageClass { - var $bullet; /* bullet image */ - var $pageText; /* main text of selected page, not parsed */ - var $multipageFlag; /* flag - true if multiple page page, false if not */ - var $pageTitles; /* array containing page titles */ - var $pageID; /* id number of page to be displayed */ - var $pageSelected; /* selected page of multiple page page */ - var $pageToRender; /* parsed page to be sent to screen */ - var $debug; /* temp debug flag */ - var $title; /* title of page, it if has one (as defined in [newpage=title] tag */ - - - function pageClass($debug=FALSE) + public $bullet; /* bullet image */ + public $pageText; /* main text of selected page, not parsed */ + public $multipageFlag; /* flag - true if multiple page page, false if not */ + public $pageTitles; /* array containing page titles */ + public $pageID; /* id number of page to be displayed */ + public $pageSelected; /* selected page of multiple page page */ + public $pageToRender; /* parsed page to be sent to screen */ + public $debug; /* temp debug flag */ + public $title; /* title of page, it if has one (as defined in [newpage=title] tag */ + public $page; /* page DB data */ + public $batch; /* shortcode batch object */ + public $template; /* current template array */ + protected $authorized; /* authorized status */ + public $cacheString; /* current page cache string */ + public $cacheTitleString; /* current page title and comment flag cache string */ + public $cacheData = null; /* cache data */ + + function __construct($debug=FALSE) { /* constructor */ $tmp = explode(".", e_QUERY); - $this -> pageID = intval($tmp[0]); - $this -> pageSelected = (isset($tmp[1]) ? intval($tmp[1]) : 0); - $this -> pageTitles = array(); + $this->pageID = intval($tmp[0]); + $this->pageSelected = (isset($tmp[1]) ? intval($tmp[1]) : 0); + $this->pageTitles = array(); $this->bullet = ''; + + // TODO nq_ (no query) cache string + $this->cacheString = 'page_'.$this->pageID.'_'.$this->pageSelected; + $this->cacheTitleString = 'page-t_'.$this->pageID.'_'.$this->pageSelected; + if(defined('BULLET')) { - $this->bullet = ''; + $this->bullet = ''; } elseif(file_exists(THEME.'images/bullet2.gif')) { - $this->bullet = ''; + $this->bullet = ''; } - $this -> debug = $debug; + $this->debug = $debug; - if($this -> debug) + if($this->debug) { - $this -> debug = "PageID ".$this -> pageID."
"; - $this -> debug .= "pageSelected ".$this -> pageSelected."
"; + $this->debug = "PageID ".$this->pageID."
"; + $this->debug .= "pageSelected ".$this->pageSelected."
"; } + + } + // TODO template for page list function listPages() { - global $pref, $sql, $ns; - - if(!isset($pref['listPages']) || !$pref['listPages']) + $sql = e107::getDb(); + if(!e107::getPref('listPages', false)) { message_handler("MESSAGE", LAN_PAGE_1); } else { - if(!$sql -> db_Select("page", "*", "page_theme='' AND page_class IN (".USERCLASS_LIST.") ")) + if(!$sql->db_Select("page", "*", "page_theme='' AND page_class IN (".USERCLASS_LIST.") ")) { $text = LAN_PAGE_2; } else { - $pageArray = $sql -> db_getList(); + $pageArray = $sql->db_getList(); foreach($pageArray as $page) { - extract($page); - $text .= $this -> bullet." ".$page_title."
"; + $url = e107::getUrl()->create('page/view', $page, 'allow=page_id,page_title,page_sef'); + $text .= $this->bullet." ".$page['page_title']."
"; } - $ns -> tablerender(LAN_PAGE_11, $text,"cpage_list"); + e107::getParser()->tablerender(LAN_PAGE_11, $text,"cpage_list"); } } } - - function showPage() + + function processViewPage() { - global $sql, $ns; - $query = "SELECT p.*, u.user_id, u.user_name FROM #page AS p - LEFT JOIN #user AS u ON p.page_author = u.user_id - WHERE p.page_id='".intval($this -> pageID)."' AND p.page_class IN (".USERCLASS_LIST.") "; + if($this->checkCache()) + { + return; + } + + $sql = e107::getDb(); - if(!$sql -> db_Select_gen($query) && !$_GET['elan']) + $query = "SELECT p.*, u.user_id, u.user_name, user_login FROM #page AS p + LEFT JOIN #user AS u ON p.page_author = u.user_id + WHERE p.page_id=".intval($this->pageID); // REMOVED AND p.page_class IN (".USERCLASS_LIST.") - permission check is done later + + if(!$sql->db_Select_gen($query)) { $ret['title'] = LAN_PAGE_12; // ***** CHANGED + $ret['sub_title'] = ''; $ret['text'] = LAN_PAGE_3; - $ret['comment_flag'] = ''; + $ret['comments'] = ''; + $ret['rating'] = ''; + $ret['np'] = ''; $ret['err'] = TRUE; - return $ret; + $ret['cachecontrol'] = false; + $this->authorized = 'nf'; + $this->template = e107::getCoreTemplate('page', 'default'); + $this->batch = e107::getScBatch('page')->setParserVars(new e_vars($ret))->setScVar('page', array()); + + define("e_PAGETITLE", $ret['title']); + return; } - extract($sql -> db_Fetch()); + $this->page = $sql->db_Fetch(); - $this -> pageText = $page_text; + $this->template = e107::getCoreTemplate('page', vartrue($this->page['page_template'], 'default')); + if(empty($this->template)) $this->template = e107::getCoreTemplate('page', 'default'); + + $this->batch = e107::getScBatch('page'); - $this -> pageCheckPerms($page_class, $page_password, $page_title); + $this->pageText = $this->page['page_text']; - if($this -> debug) + $this->pageCheckPerms($this->page['page_class'], $this->page['page_password'], $this->page['page_title']); + + if($this->debug) { - echo "pageText ".$this -> pageText."
"; + echo "pageText ".$this->pageText."
"; } - $this -> parsePage(); + $this->parsePage(); - $gen = new convert; - - $text = ''; // Notice removal - $ptitle = ""; - - if($page_author) + $pagenav = $rating = $comments = ''; + if($this->authorized === true) { - $text .= "
".$user_name.", ".$gen->convert_date($page_datestamp, "long")."

"; + $pagenav = $this->pageIndex(); + $rating = $this->pageRating($this->page['page_rating_flag']); + $comments = $this->pageComment($this->page['page_comment_flag']); } - if($this -> title) - { - $ptitle = "
".$this -> title."
"; - } - - $text .= $this -> pageToRender; - $text .= $this -> pageIndex(); - $text .= $this -> pageRating($page_rating_flag); - - $ret['title'] = $page_title; - $ret['text'] = $ptitle."
".$text."
"; - $ret['comment_flag'] = $page_comment_flag; + $ret['title'] = $this->page['page_title']; + $ret['sub_title'] = $this->title; + $ret['text'] = $this->pageToRender; + $ret['np'] = $pagenav; + $ret['rating'] = $rating; + $ret['comments'] = $comments; $ret['err'] = FALSE; - $ret['cachecontrol'] = (isset($page_password) && !$page_password); // Don't cache password protected pages - - return $ret; + $ret['cachecontrol'] = (isset($this->page['page_password']) && !$this->page['page_password'] && $this->authorized === true); // Don't cache password protected pages + + $this->batch->setParserVars(new e_vars($ret))->setScVar('page', $this->page); + + define('e_PAGETITLE', $ret['title']); + + //return $ret; } - function parsePage() + public function checkCache() { - global $tp; - $this -> pageTitles = array(); // Notice removal + $e107cache = e107::getCache(); + $cacheData = $e107cache->retrieve($this->cacheString); + if(false !== $cacheData) + { + $this->cacheData = array(); + $this->cacheData['PAGE'] = $cacheData; + list($pagetitle, $comment_flag) = explode("^",$e107cache->retrieve($this->cacheTitleString)); + $this->cacheData['TITLE'] = $pagetitle; + $this->cacheData['COMMENT_FLAG'] = $comment_flag; + } + } + + public function setCache($data, $title, $comment_flag) + { + $e107cache = e107::getCache(); + $e107cache->set($this->cacheString, $data); + $e107cache->set($this->cacheTitleString, $title."^".$this->page['page_comment_flag']); + } - if(preg_match_all("/\[newpage.*?\]/si", $this -> pageText, $pt)) + + public function renderCache() + { + $comments = ''; + if($this->cacheData['COMMENT_FLAG']) + { + $vars = new e_vars(array('comments' => $this->pageComment(true))); + $comments = e107::getScBatch('page')->setParserVars($vars)->cpagecomments(); + } + define('e_PAGETITLE', $this->cacheData['TITLE']); + if($this->debug) + { + echo "Reading page from cache
"; + } + return str_replace('[[PAGECOMMENTS]]', $comments, $this->cacheData['PAGE']); + } + + public function showPage() + { + if(null !== $this->cacheData) + { + return $this->renderCache(); + } + if(true === $this->authorized) + { + $vars = $this->batch->getParserVars(); + + $template = str_replace('{PAGECOMMENTS}', '[[PAGECOMMENTS]]', $this->template['start'].$this->template['body'].$this->template['end']); + $ret = $this->renderPage($template); + + if(!empty($this->template['page'])) + { + $ret = str_replace(array('{PAGE}', '{PAGECOMMENTS}'), array($ret, '[[PAGECOMMENTS]]'), $this->template['page']); + } + $ret = e107::getParser()->parseTemplate($ret, true, $this->batch); + + if($vars->cachecontrol) $this->setCache($ret, $this->batch->sc_cpagetitle(), $this->page['page_comment_flag']); + + return str_replace('[[PAGECOMMENTS]]', $this->batch->cpagecomments(), $ret); + } + + $extend = new e_vars; + $vars = $this->batch->getParserVars(); + + // reset batch data + $this->batch->setParserVars(null)->setScVar('page', array()); + + // copy some data + $extend->title = $vars->title; + $extend->message = e107::getMessage()->render(); + + switch ($this->authorized) + { + case 'class': + $extend->text = LAN_PAGE_6; + $template = $this->template['start'].$this->template['restricted'].$this->template['end']; + break; + + case 'pw': + $frm = e107::getForm(); + $extend->caption = LAN_PAGE_8; + $extend->label = LAN_PAGE_9; + $extend->password = $frm->password('page_pw'); + $extend->icon = e_IMAGE_ABS.'generic/password.png'; + $extend->submit = $frm->submit('submit_page_pw', LAN_PAGE_10); + // FIXME - add form open/close e_form methods + $extend->form_open = '
'; + $extend->form_close = '
'; + $template = $this->template['start'].$this->template['authorize'].$this->template['end']; + break; + + case 'nf': + default: + $extend->text = $vars->text; + $template = $this->template['start'].$this->template['notfound'].$this->template['end']; + break; + } + + return $this->renderPage($template, $extend); + } + + public function renderPage($template, $vars = null) + { + if(null === $vars) + { + $ret = e107::getParser()->parseTemplate($template, true, $this->batch); + $vars = $this->batch->getParserVars(); + } + else + { + $ret = e107::getParser()->simpleParse($template, $vars); + } + + if(vartrue($this->template['noTableRender'])) + { + return $ret; + } + + $mode = vartrue($this->template['tableRender'], 'cpage'); + $title = $vars->title; + + return e107::getRender()->tablerender($title, $ret, $mode, true); + } + + public function parsePage() + { + $tp = e107::getParser(); + $this->pageTitles = array(); // Notice removal + + if(preg_match_all("/\[newpage.*?\]/si", $this->pageText, $pt)) { if (substr($this->pageText, 0, 6) == '[html]') { // Need to strip html bbcode from wysiwyg on multi-page docs (handled automatically on single pages) @@ -237,18 +342,18 @@ class pageClass $this->pageText = substr($this->pageText, 6); } } - $pages = preg_split("/\[newpage.*?\]/si", $this -> pageText, -1, PREG_SPLIT_NO_EMPTY); - $this -> multipageFlag = TRUE; + $pages = preg_split("/\[newpage.*?\]/si", $this->pageText, -1, PREG_SPLIT_NO_EMPTY); + $this->multipageFlag = TRUE; } else { - $this -> pageToRender = $tp -> toHTML($this -> pageText, TRUE, 'BODY'); + $this->pageToRender = $tp->toHTML($this->pageText, TRUE, 'BODY'); return; } foreach($pt[0] as $title) { - $this -> pageTitles[] = $title; + $this->pageTitles[] = $title; } @@ -264,64 +369,58 @@ class pageClass } $pageCount = count($pages); - $titleCount = count($this -> pageTitles); + $titleCount = count($this->pageTitles); /* if the vars above don't match, page 1 has no [newpage] tag, so we need to create one ... */ if($pageCount != $titleCount) { - array_unshift($this -> pageTitles, "[newpage]"); + array_unshift($this->pageTitles, "[newpage]"); } /* ok, titles now match pages, rename the titles if needed ... */ $count =0; - foreach($this -> pageTitles as $title) + foreach($this->pageTitles as $title) { $titlep = preg_replace("/\[newpage=(.*?)\]/", "\\1", $title); - $this -> pageTitles[$count] = ($titlep == "[newpage]" ? LAN_PAGE_13." ".($count+1)." " : $tp -> toHTML($titlep, TRUE, 'TITLE')); + $this->pageTitles[$count] = ($titlep == "[newpage]" ? LAN_PAGE_13." ".($count+1) : $tp->toHTML($titlep, TRUE, 'TITLE')); $count++; } - $this -> pageToRender = $tp -> toHTML($pages[$this -> pageSelected], TRUE, 'BODY'); - $this -> title = (substr($this -> pageTitles[$this -> pageSelected], -1) == ";" ? "" : $this -> pageTitles[$this -> pageSelected]); + $this->pageToRender = $tp->toHTML($pages[$this->pageSelected], TRUE, 'BODY'); + $this->title = (substr($this->pageTitles[$this->pageSelected], -1) == ";" ? "" : $this->pageTitles[$this->pageSelected]); - if($this -> debug) + if($this->debug) { - echo "multipageFlag ".$this -> multipageFlag."
"; - if($this -> multipageFlag) + echo "multipageFlag ".$this->multipageFlag."
"; + if($this->multipageFlag) { echo "
"; print_r($pages); echo "
"; echo "pageCount ".$pageCount."
"; echo "titleCount ".$titleCount."
"; - echo "
"; print_r($this -> pageTitles); echo "
"; + echo "
"; print_r($this->pageTitles); echo "
"; } } } function pageIndex() { - global $tp,$pref; - $itext = ''; - if(isset($pref['old_np']) && $pref['old_np']) - { - $count = 0; - foreach($this -> pageTitles as $title) - { - if (!$count) { $itext = "

"; } - $itext .= $this -> bullet." ".($count == $this -> pageSelected ? $title : "".$title."")."
\n"; - $count++; - } - } - else - { - $titles = implode("|",$this -> pageTitles); - $total_items = count($this -> pageTitles); - $parms = $total_items.",1,".$this -> pageSelected.",".e_SELF."?".$this -> pageID.".[FROM],,$titles"; - $itext = ($total_items) ? "
".$tp->parseTemplate("{NEXTPREV={$parms}}")."
" : ""; - } + // Use always nextprev shortcode (with a special default 'page' tempalte) + $titles = implode("|",$this->pageTitles); + $total_items = count($this->pageTitles); + //$parms = $total_items.",1,".$this->pageSelected.",".e_SELF."?".$this->pageID.".[FROM],,$titles"; + + $row = $this->page; + $row['page'] = '--FROM--'; + $url = rawurlencode(e107::getUrl()->create('page/view', $row, 'allow=page_id,page_title,page_sef,page')); + + $parms = 'nonavcount&bullet='.rawurlencode($this->bullet.' ').'&caption=&'.'pagetitle='.rawurlencode($titles).'&tmpl_prefix='.deftrue('PAGE_NEXTPREV_TMPL', 'page').'&total='.$total_items.'&amount=1¤t='.$this->pageSelected.'&url='.$url; + $itext = ($total_items) ? e107::getParser()->parseTemplate("{NEXTPREV={$parms}}") : ""; + return $itext; } + // FIXME most probably will fail when cache enabled function pageRating($page_rating_flag) { $rate_text = ''; // Notice removal @@ -331,13 +430,13 @@ class pageClass $rater = new rater; $rate_text = "
"; - if ($ratearray = $rater->getrating("page", $this -> pageID)) + if ($ratearray = $rater->getrating("page", $this->pageID)) { if ($ratearray[2] == "") { $ratearray[2] = 0; } - $rate_text .= "\n"; + $rate_text .= "\n"; $rate_text .= " ".$ratearray[1].".".$ratearray[2]." - ".$ratearray[0]." "; $rate_text .= ($ratearray[0] == 1 ? "vote" : "votes"); } @@ -347,9 +446,9 @@ class pageClass } $rate_text .= ""; - if (!$rater->checkrated("page", $this -> pageID) && USER) + if (!$rater->checkrated("page", $this->pageID) && USER) { - $rate_text .= $rater->rateselect("     ".LAN_PAGE_4."", "page", $this -> pageID); + $rate_text .= $rater->rateselect("     ".LAN_PAGE_4."", "page", $this->pageID); } else if(!USER) { @@ -366,8 +465,6 @@ class pageClass function pageComment($page_comment_flag) { - global $sql, $ns, $e107cache, $tp, $comment_shortcodes,$cacheString; - if($page_comment_flag) { require_once(e_HANDLER."comment_class.php"); @@ -375,11 +472,12 @@ class pageClass if (isset($_POST['commentsubmit'])) { - $cobj->enter_comment($_POST['author_name'], $_POST['comment'], "page", $this -> pageID, $pid, $_POST['subject']); - $e107cache->clear("comment.page.".$this -> pageID); - $e107cache->clear($cacheString); + $cobj->enter_comment($_POST['author_name'], $_POST['comment'], "page", $this->pageID, $pid, $_POST['subject']); + $e107cache = e107::getCache(); + $e107cache->clear("comment.page.".$this->pageID); + $e107cache->clear($this->cacheString); } - return $cobj->compose_comment("page", "comment", $this -> pageID, 0, $this -> title); + return $cobj->compose_comment("page", "comment", $this->pageID, 0, $this->title, false, true); } } @@ -390,80 +488,64 @@ class pageClass if (!check_class($page_class)) { - define("e_PAGETITLE", $page_title); - // HEADERF requires that $tp is defined - hence declared as global above. - require_once(HEADERF); // Do header now in case wrong password was entered - message_handler("MESSAGE", LAN_PAGE_6); - require_once(FOOTERF); exit; + $this->authorized = 'class'; + return false; } if (!$page_password) { - return TRUE; + $this->authorized = true; + $cookiename = $this->getCookieName(); + if(isset($_COOKIE[$cookiename])) cookie($cookiename, '', (time() - 2592000)); + return true; } if(isset($_POST['submit_page_pw'])) { if($_POST['page_pw'] == $page_password) { - $this -> setPageCookie(); + $this->setPageCookie(); + $this->authorized = true; + return true; + } + else + { + e107::getMessage()->addError(LAN_PAGE_7); } } else { - $cookiename = "e107page_".$this -> pageID; + // TODO - e_COOKIE + $cookiename = $this->getCookieName(); if(isset($_COOKIE[$cookiename]) && ($_COOKIE[$cookiename] == md5($page_password.USERID))) { + $this->authorized = true; return TRUE; } // Invalid/empty password here } + + $this->authorized = 'pw'; + return false; + } - define("e_PAGETITLE", $page_title); - // HEADERF requires that $tp is defined - hence declared as global above. - require_once(HEADERF); // Do header now in case wrong password was entered - - // Need to prompt for password here - if (isset($_POST['submit_page_pw'])) - { - message_handler("MESSAGE", LAN_PAGE_7); // Invalid password - } - - $pw_entry_text = " -
-
- - - - - - - - - - - - -
".LAN_PAGE_8."
".LAN_PAGE_9.":
-
-
- "; - // Mustn't return to higher level code here - - $ns->tablerender($page_title, $pw_entry_text,"cpage_pw"); // HEADERF also clears $text - hence different variable - require_once(FOOTERF); - exit; + function getCookieName() + { + return e_COOKIE.'_page_'.$this->pageID; } function setPageCookie() { - global $pref; + if(!$this->pageID || !vartrue($_POST['page_pw'])) return; + $pref = e107::getPref(); + $pref['pageCookieExpire'] = max($pref['pageCookieExpire'], 120); $hash = md5($_POST['page_pw'].USERID); - cookie("e107page_".e_QUERY, $hash, (time() + $pref['pageCookieExpire'])); - header("location:".e_SELF."?".e_QUERY); - exit; + + cookie($this->getCookieName(), $hash, (time() + $pref['pageCookieExpire'])); + //header("location:".e_SELF."?".e_QUERY); + //exit; } }