Changeset 1471
- Timestamp:
- 12/17/07 03:55:33 (8 months ago)
- Files:
-
- devel/mod/pages/index.php (modified) (2 diffs)
- devel/mod/pages/lib.php (modified) (10 diffs)
- devel/mod/pages/lib/function_frontpage_loggedin.php (deleted)
- devel/mod/pages/lib/function_frontpage_loggedout.php (deleted)
- devel/mod/pages/lib/pages.config.php (added)
- devel/mod/pages/lib/pages.inc.php (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
devel/mod/pages/index.php
r1466 r1471 26 26 if (page_owner() < 1) { 27 27 // remove all but pages block 28 sidebar_remove(array('pages_sidebar' , 'sidebar-profile'), true);28 sidebar_remove(array('pages_sidebar'), true); 29 29 } 30 30 … … 32 32 $do_action = optional_param('do'); 33 33 34 if ($do_action == 'edit') { 35 $page = pages_edit_page($page_id, page_owner()); 34 if (!pages_enabled()) { 35 $page = new StdClass; 36 $page->title = __gettext('Plugin disabled for users'); 37 $page->content = __gettext('This plugin is currently disabled by site administrator'); 36 38 } else { 37 $page = pages_get_page($page_id, page_owner()); 39 if ($do_action == 'edit') { 40 $page = pages_edit_page($page_id, page_owner()); 41 } else { 42 $page = pages_get_page($page_id, page_owner()); 43 } 38 44 } 45 39 46 40 47 if (!empty($page->ident)) { devel/mod/pages/lib.php
r1468 r1471 11 11 12 12 function pages_init() { 13 global $CFG, $function, $PAGE; 14 15 define('pages_allow_php_admin', true); 16 define('pages_allow_php_user', false); 17 define('pages_parse_keywords', true); 18 define('pages_blog_textproc', false); // breaks content with br's 13 global $CFG; 14 15 require_once($CFG->dirroot . 'mod/pages/lib/pages.config.php'); 19 16 20 17 pages_dbsetup(); 21 22 //DEPRECATED: legacy pages23 /*24 $PAGE->pages->old_compat = array(25 'about.php' => array(26 'title' => sprintf(__gettext('About %s'), $CFG->sitename),27 'function' => 'content:about',28 ),29 'faq.php' => array(30 'title' => sprintf(__gettext('%s FAQ'), $CFG->sitename),31 'function' => 'content:faq',32 ),33 'privacy.php' => array(34 'title' => sprintf(__gettext('%s Privacy Police'), $CFG->sitename),35 'function' => 'content:privacy',36 ),37 'terms.php' => array(38 'title' => sprintf(__gettext('%s Terms & Conditions'), $CFG->sitename),39 'function' => 'content:terms',40 ),41 'run_your_own.php' => array(42 'title' => sprintf(__gettext('Running your own %s'), $CFG->sitename),43 'function' => 'content:run_your_own',44 ),45 );46 47 $function["pages:frontpage_loggedin"][] = dirname(__FILE__) . "/lib/function_frontpage_loggedin.php";48 $function["pages:frontpage_loggedout"][] = dirname(__FILE__) . "/lib/function_frontpage_loggedout.php";49 50 $PAGE->pages->old_compat['frontpage_loggedin'] = array(51 'title' => sprintf(__gettext('Welcome {{username}}')),52 'function' => 'pages:frontpage_loggedin',53 );54 $PAGE->pages->old_compat['frontpage_loggedout'] = array(55 'title' => sprintf(__gettext('Welcome Guest')),56 'function' => 'pages:frontpage_loggedout',57 );58 */59 18 } 60 19 … … 69 28 70 29 if (defined('context') && context == 'pages' || defined('pages_external')) { 71 if (p ermissions_check('pages::edit', page_owner())) {30 if (pages_enabled() && permissions_check('pages::edit', page_owner())) { 72 31 $page_name = optional_param('page'); 73 32 $do_action = optional_param('do'); 74 33 75 34 if ($do_action != 'edit') { 76 pages_submenu_add('pages:edit', __gettext('Edit this page'), pages_url($page_name, 'pages::edit', page_owner()), 0); 77 } 78 } 79 } 80 81 if (isloggedin()) { 82 pages_menu_add('pages', __gettext('Your Pages'), get_url($_SESSION['userid'], 'pages::')); 83 } 84 85 // not show main site pages on sidebar 86 sidebar_add(25, 'pages_sidebar', null, true, __gettext('Your pages')); 35 // new page link 36 pages_submenu_add('pages:edit', __gettext('New page'), pages_url('New_page', 'pages::edit', page_owner()), 0); 37 // edit this page link 38 pages_submenu_add('pages:edit', __gettext('Edit this page'), pages_url($page_name, 'pages::edit', page_owner()), 1); 39 } 40 } 41 } 42 43 if (!PAGES_DISABLE_USERS && isloggedin()) { 44 pages_menu_add('pages', __gettext('Your Content'), get_url($_SESSION['userid'], 'pages::')); 45 } 46 47 if (pages_enabled()) { 48 // not show main site pages on sidebar 49 sidebar_add(25, 'pages_sidebar', null, true, __gettext('Your Content')); 50 } 87 51 } 88 52 89 53 function pages_php_allowed() { 90 54 if (page_owner() == -1 91 || pages_allow_php_user92 || ( pages_allow_php_admin&& user_flag_get('admin', page_owner())))55 || PAGES_ALLOW_PHP_USER 56 || (PAGES_ALLOW_PHP_ADMIN && user_flag_get('admin', page_owner()))) 93 57 { 94 58 return true; … … 107 71 switch ($type) { 108 72 case 'pages::edit': 109 if ( $ident > 0) {73 if (pages_enabled() && $ident > 0) { 110 74 $result = run('permissions:check', 'profile'); 111 75 } else { … … 147 111 $_page = new StdClass; 148 112 $_page->uri = 'privacy.php'; //backward compatibility 113 $_page->name = 'privacy.php'; //backward compatibility 149 114 $_page->title = __gettext('Privacy Policy'); 150 115 $_page->content = @file_get_contents(dirname(__FILE__).'/legacy/content_privacy.html'); … … 154 119 $_page = new StdClass; 155 120 $_page->uri = 'terms.php'; //backward compatibility 121 $_page->name = 'terms.php'; //backward compatibility 156 122 $_page->title = __gettext('Terms and Conditions'); 157 123 $_page->content = @file_get_contents(dirname(__FILE__).'/legacy/content_terms.html'); … … 202 168 if ($id > 0) { 203 169 $url = get_url($id, 'profile::'); 204 if (!empty($url)) $url .= ' pages/'; // url for user's pages170 if (!empty($url)) $url .= 'content/'; // url for user's pages 205 171 } else { 206 $url = $CFG->wwwroot . ' pages/'; // url for site pages172 $url = $CFG->wwwroot . 'content/'; // url for site pages 207 173 } 208 174 break; … … 321 287 if ($owner > 0) { 322 288 if ($_SESSION['userid'] == $owner) { 323 $title = __gettext('Your pages');289 $title = __gettext('Your Content'); 324 290 }else { 325 291 //$title = sprintf(__gettext("%s's pages"), htmlspecialchars(user_name($owner), ENT_COMPAT, 'utf-8')); 326 $title = __gettext(" Pages");292 $title = __gettext("Content"); 327 293 } 328 294 } else { … … 337 303 338 304 return $body; 305 } 306 307 function pages_enabled() { 308 if (page_owner() == -1 || 309 (page_owner() > 0 && !PAGES_DISABLE_USERS) ) { 310 return true; 311 } else { 312 return false; 313 } 339 314 } 340 315 … … 415 390 $main_link = pages_html_a(pages_url(__gettext('Main'), 'pages::page', $owner), __gettext('Main')); 416 391 $menu .= pages_html_wrap('li', $main_link, array('class' => 'menu-item')); 417 }418 419 // "add new" page link420 if (permissions_check('pages::edit',$owner)) {421 $new_page_link = pages_html_wrap('small', __gettext('New page'));422 $menu .= pages_html_wrap('li', pages_html_wrap('a', $new_page_link, array('href'=>pages_url('New_page', 'pages::edit', $owner), 'title'=>__gettext('New page')), array('class' => 'menu-item')));423 392 } 424 393 … … 721 690 } 722 691 } 692 693 if (!function_exists('html_entity_decode')) { 694 function html_entity_decode($string) { 695 // replace numeric entities 696 $string = preg_replace('/&#x([0-9a-f]+);/ei', 'chr(hexdec("\\1"))', $string); 697 $string = preg_replace('/&#([0-9]+);/e', 'char("\\1")', $string); 698 // replace literal entities 699 $trans_tbl = get_html_translation_table(HTML_ENTITIES); 700 $trans_tbl = array_flip($trans_tbl); 701 return strtr($string, $trans_tbl); 702 703 } 704 } 723 705 ?> devel/mod/pages/lib/pages.inc.php
r1456 r1471 30 30 $owner = ($owner > 0) ? $owner : -1; 31 31 32 if ( defined('context') && context == 'pages'&& $action == 'pages:edit' && $do_action == 'edit' && permissions_check('pages::edit', $owner)) {32 if ((defined('context') && context == 'pages' || defined('pages_external')) && $action == 'pages:edit' && $do_action == 'edit' && permissions_check('pages::edit', $owner)) { 33 33 $submit = optional_param('submit'); 34 34 // get page id … … 157 157 $content = trim(optional_param('page-content')); 158 158 } 159 $content = html_entity_decode($content); 159 160 $name = trim(optional_param('page-name')); 160 161 $parent = optional_param('menu-parent', 0, PARAM_INT); … … 338 339 339 340 // parse elgg template keywords 340 if ( pages_parse_keywords) {341 if (PAGES_PARSE_KEYWORDS) { 341 342 // wrap into templates_draw 342 343 global $template; … … 352 353 353 354 // process with blog filters 354 if ( pages_blog_textproc) {355 if (PAGES_BLOG_TEXTPROC) { 355 356 $content = run('weblogs:text:process', $content); 356 357 } … … 378 379 $PAGE->pages->editing = true; 379 380 380 if ( !empty($page_name) && permissions_check('pages::edit', $owner)) {381 if (pages_enabled() && !empty($page_name) && permissions_check('pages::edit', $owner)) { 381 382 if ($owner == -1 && pages_is_frontpage($page_name)) { 382 383 $is_frontpage = true; … … 409 410 $title_enc = htmlspecialchars($page->title, ENT_QUOTES, 'utf-8'); 410 411 //$page->content = htmlspecialchars(stripslashes($page->content), ENT_COMPAT, 'utf-8'); 411 $page->content = $page->content;412 $page->content = trim($page->content); 412 413 $page->name = htmlspecialchars($page->name, ENT_QUOTES, 'utf-8'); 413 414 … … 426 427 $input_content = pages_html_wrap('label', __gettext('Content:'), array('for' => 'page-content')); 427 428 $input_content .= pages_html_wrap( 428 'textarea', $page->content,429 'textarea', htmlentities($page->content), 429 430 array( 430 431 'id' => 'page-content',
