Changeset 1473

Show
Ignore:
Timestamp:
12/17/07 06:54:01 (8 months ago)
Author:
misja
Message:

Misja Hoebe <misja@curverider.co.uk> Merged r1466, r1467, r1468, r1469, r1470, r1471, r1472 into 0.9 branch

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • releases/0.9/config-dist.php

    r1378 r1473  
    1515    $CFG->dbhost = "localhost"; 
    1616 
    17     $CFG->dbuser = "elgg"; 
     17    $CFG->dbuser = ""; 
    1818    $CFG->dbpass = ""; 
    1919 
    20     $CFG->dbname = "elgg"; 
     20    $CFG->dbname = ""; 
    2121    $CFG->prefix = "elgg_"; 
    2222 
  • releases/0.9/htaccess-dist

    r1463 r1473  
    8282########### 
    8383RewriteRule ^content\/?(.*)?$ mod/pages/index.php?owner=-1&page=$1 [QSA,L] 
    84 RewriteRule ^([A-Za-z0-9]+)\/pages\/?(.*)?$ mod/pages/index.php?profile_name=$1&page=$2  [QSA,L] 
     84RewriteRule ^([A-Za-z0-9]+)\/content\/(.*)?$ mod/pages/index.php?profile_name=$1&page=$2  [QSA,L] 
    8585 
    8686RewriteRule ^_templates(\/)?$ mod/template/index.php?%{QUERY_STRING} 
  • releases/0.9/install.php

    r1453 r1473  
    676676 
    677677    //$urlregex = '#https?://([\w\.-]+)+(:\d+)?(/([\w-_\./]*(\?\S+)?)?)?#'; //extended url regex 
    678     $urlregex = '#^https?://[\w\.-]+(:\d+)?([\w-_\./]*)?/$#i'; 
     678    $urlregex = '#^https?://[\w\.-]+(:\d+)?([\w-_~\./()\#@%;$\+=\\\|&]*)?/$#i'; 
    679679    $hostregex = '#^[\w\.-]+(:\d+)?$#'; 
    680680 
  • releases/0.9/mod/elggadmin/lib.php

    r1426 r1473  
    1717 
    1818        elggadmin_add_rule('mod/elggadmin/?$', 'elggadmin_page'); 
    19         elggadmin_add_rule('mod/elggadmin/(theme|frontpage)$', 'elggadmin_page'); 
    20         elggadmin_add_rule('mod/elggadmin/index.php/?(theme|frontpage)?$', 'elggadmin_page'); 
     19        elggadmin_add_rule('mod/elggadmin/(theme|frontpage|logs)$', 'elggadmin_page'); 
     20        elggadmin_add_rule('mod/elggadmin/index.php/?(theme|frontpage|logs)?$', 'elggadmin_page'); 
    2121 
    2222        elggadmin_add_function('elggadmin_page_before', 'elggadmin_actions'); 
     
    5353        // submenu options 
    5454        pages_submenu_add('elggadmin', __gettext('Configuration manager'), get_url(null, 'elggadmin::')); 
    55         pages_submenu_add('elggadmin', __gettext('Default theme editor'), get_url(null, 'elggadmin::theme')); 
    56         pages_submenu_add('elggadmin', __gettext('Frontpage template editor'), get_url(null, 'elggadmin::frontpage')); 
     55        pages_submenu_add('elggadmin:theme', __gettext('Default theme editor'), get_url(null, 'elggadmin::theme')); 
     56        pages_submenu_add('elggadmin:frontpage', __gettext('Frontpage template editor'), get_url(null, 'elggadmin::frontpage')); 
     57        pages_submenu_add('elggadmin:logs', __gettext('Error log'), get_url(null, 'elggadmin::logs')); 
    5758 
    5859        sidebar_add(50, 'sidebar-'.elggadmin_currentpage(), elggadmin_sidebar()); 
     
    8485            $url = get_url(null, 'elggadmin::') . '/frontpage'; 
    8586            break; 
     87        case 'elggadmin::logs': 
     88            $url = get_url(null, 'elggadmin::') . '/logs'; 
     89            break; 
     90 
    8691    } 
    8792 
  • releases/0.9/mod/elggadmin/lib/elggadmin.inc.php

    r1453 r1473  
    3030        $page = elggadmin_page_frontpage(); 
    3131        elggadmin_currentpage('frontpage'); 
     32    } elseif ($page_name == 'logs') { 
     33        $page = elggadmin_page_logs(); 
     34        elggadmin_currentpage('logs'); 
    3235    } else { 
    3336        $page = elggadmin_page_config(); 
     
    212215} 
    213216 
     217function elggadmin_page_logs() { 
     218    global $CFG; 
     219 
     220    $action = optional_param('action'); 
     221    if ($action == 'elggadmin:logs:clear') { 
     222        elggadmin_writefile($CFG->dataroot.'errors.log',""); 
     223        header_redirect(get_url(null,'elggadmin::logs'), __gettext('Error log cleared')); 
     224    } 
     225 
     226    $logs = elggadmin_tailfile($CFG->dataroot.'errors.log', 50); 
     227 
     228    $clear = '&raquo; ' . pages_html_a(get_url_query(1, 'elggadmin::logs', 'action=elggadmin:logs:clear'), __gettext('Clear error log')); 
     229 
     230    $page = new StdClass; 
     231    $page->title = __gettext('Error log'); 
     232    $page->body = pages_html_wrap('p', $clear); 
     233    $page->body .= pages_html_wrap('textarea', $logs, array('wrap'=>'off', 'readonly'=>'readonly')); 
     234 
     235    return $page; 
     236} 
     237 
    214238function elggadmin_page_theme() { 
    215239    $page = new StdClass; 
     
    436460} 
    437461 
    438 function elggadmin_tpltextarea($tplname, $title=null) { 
     462function elggadmin_tpltextarea($tplname, $title=null, $attrs=null) { 
    439463    $output = ''; 
     464    $_attrs = array('name' => $tplname, 'style' => 'width:95%;height:300px;margin:0px 10px 20px 10px;'); 
     465 
    440466    if (is_string($title)) { 
    441467        $output .= pages_html_wrap('h2', $title); 
     
    446472    } 
    447473 
    448     $output .= pages_html_wrap('textarea', empty($tpl) ? ' ' : $tpl, array('name' => $tplname, 'style' => 'width:95%;height:300px;margin:0px 10px 20px 10px;')); 
     474    if ($is_array($attrs)) { 
     475        $_attrs = array_merge($attrs, $_attrs); 
     476    } 
     477 
     478    $output .= pages_html_wrap('textarea', empty($tpl) ? ' ' : $tpl, $_attrs); 
    449479 
    450480    return $output; 
     
    498528} 
    499529 
     530function elggadmin_tailfile($file, $lines=20) { 
     531    if ($fp = @fopen($file, 'r')) { 
     532        $pos = -1; 
     533        $t = ' '; 
     534        $content = ''; 
     535 
     536        if ($lines < 0) { 
     537            $lines = 20; 
     538        } 
     539 
     540        while ($lines > 0) { 
     541            if (!fseek($fp, $pos, SEEK_END)) { 
     542                $t = fgetc($fp); 
     543                $pos--; 
     544                if ($t == "\n") { 
     545                    $lines--; 
     546                } 
     547                $content = $t . $content; 
     548            } else { 
     549                rewind($fp); 
     550                $lines--; 
     551            } 
     552        } 
     553 
     554        @fclose($fp); 
     555        return $content; 
     556    } else { 
     557        return null; 
     558    } 
     559} 
     560 
    500561?> 
  • releases/0.9/mod/pages/index.php

    r1453 r1473  
    1616} else { 
    1717    define('context', 'external'); 
     18    define('pages_external', true); 
    1819} 
    1920 
     
    2526if (page_owner() < 1) { 
    2627    // remove all but pages block 
    27     sidebar_remove(array('pages_sidebar', 'sidebar-profile'), true); 
     28    sidebar_remove(array('pages_sidebar'), true); 
    2829} 
    2930 
     
    3132$do_action = optional_param('do'); 
    3233 
    33 if ($do_action == 'edit') { 
    34     $page = pages_edit_page($page_id, page_owner()); 
     34if (!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'); 
    3538} else { 
    36     $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    }    
    3744} 
     45 
    3846 
    3947if (!empty($page->ident)) { 
  • releases/0.9/mod/pages/lib.php

    r1463 r1473  
    1111 
    1212function 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'); 
    1916 
    2017    pages_dbsetup(); 
    21  
    22     //DEPRECATED: legacy pages 
    23     /* 
    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      */ 
    5918} 
    6019 
     
    6827    $CFG->templates->variables_substitute['sysadminemail'][] = 'pages_tplkw_sysadminemail'; 
    6928 
    70     if (defined('context') && context == 'pages') { 
    71         if (permissions_check('pages::edit', page_owner())) { 
     29    if (defined('context') && context == 'pages' || defined('pages_external')) { 
     30        if (pages_enabled() && permissions_check('pages::edit', page_owner())) { 
    7231            $page_name = optional_param('page'); 
    7332            $do_action = optional_param('do'); 
    7433 
    7534            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    } 
    8751} 
    8852 
    8953function pages_php_allowed() { 
    9054    if (page_owner() == -1 
    91         || pages_allow_php_user 
    92         || (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()))) 
    9357    { 
    9458        return true; 
     
    10771    switch ($type) { 
    10872        case 'pages::edit': 
    109             if ($ident > 0) { 
     73            if (pages_enabled() && $ident > 0) { 
    11074                $result = run('permissions:check', 'profile'); 
    11175            } else { 
     
    147111                $_page = new StdClass; 
    148112                $_page->uri = 'privacy.php'; //backward compatibility 
     113                $_page->name = 'privacy.php'; //backward compatibility 
    149114                $_page->title = __gettext('Privacy Policy'); 
    150115                $_page->content = @file_get_contents(dirname(__FILE__).'/legacy/content_privacy.html'); 
     
    154119                $_page = new StdClass; 
    155120                $_page->uri = 'terms.php'; //backward compatibility 
     121                $_page->name = 'terms.php'; //backward compatibility 
    156122                $_page->title = __gettext('Terms and Conditions'); 
    157123                $_page->content = @file_get_contents(dirname(__FILE__).'/legacy/content_terms.html'); 
     
    202168            if ($id > 0) { 
    203169                $url = get_url($id, 'profile::'); 
    204                 if (!empty($url)) $url .= 'pages/'; // url for user's pages 
     170                if (!empty($url)) $url .= 'content/'; // url for user's pages 
    205171            } else { 
    206172                $url = $CFG->wwwroot . 'content/'; // url for site pages 
     
    321287    if ($owner > 0) { 
    322288        if ($_SESSION['userid'] == $owner) { 
    323             $title = __gettext('Your pages'); 
     289            $title = __gettext('Your Content'); 
    324290        }else { 
    325291            //$title = sprintf(__gettext("%s's pages"), htmlspecialchars(user_name($owner), ENT_COMPAT, 'utf-8')); 
    326             $title = __gettext("Pages"); 
     292            $title = __gettext("Content"); 
    327293        } 
    328294    } else { 
     
    337303 
    338304    return $body; 
     305} 
     306 
     307function pages_enabled() { 
     308    if (page_owner() == -1 || 
     309       (page_owner() > 0 && !PAGES_DISABLE_USERS) ) { 
     310        return true; 
     311    } else { 
     312        return false; 
     313    } 
    339314} 
    340315 
     
    415390        $main_link = pages_html_a(pages_url(__gettext('Main'), 'pages::page', $owner), __gettext('Main')); 
    416391        $menu .= pages_html_wrap('li', $main_link, array('class' => 'menu-item')); 
    417     } 
    418  
    419     // "add new" page link 
    420     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'))); 
    423392    } 
    424393 
     
    721690    } 
    722691} 
     692 
     693if (!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} 
    723705?> 
  • releases/0.9/mod/pages/lib/pages.inc.php

    r1463 r1473  
    3030    $owner = ($owner > 0) ? $owner : -1; 
    3131 
    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)) { 
    3333        $submit = optional_param('submit'); 
    3434        // get page id 
     
    157157            $content = trim(optional_param('page-content')); 
    158158        } 
     159        $content = html_entity_decode($content); 
    159160        $name = trim(optional_param('page-name')); 
    160161        $parent = optional_param('menu-parent', 0, PARAM_INT); 
     
    338339 
    339340    // parse elgg template keywords 
    340     if (pages_parse_keywords) { 
     341    if (PAGES_PARSE_KEYWORDS) { 
    341342        // wrap into templates_draw 
    342343        global $template; 
     
    352353 
    353354    // process with blog filters 
    354     if (pages_blog_textproc) { 
     355    if (PAGES_BLOG_TEXTPROC) { 
    355356        $content = run('weblogs:text:process', $content); 
    356357    } 
     
    378379    $PAGE->pages->editing = true; 
    379380 
    380     if (!empty($page_name) && permissions_check('pages::edit', $owner)) { 
     381    if (pages_enabled() && !empty($page_name) && permissions_check('pages::edit', $owner)) { 
    381382        if ($owner == -1 && pages_is_frontpage($page_name)) { 
    382383            $is_frontpage = true; 
     
    409410        $title_enc = htmlspecialchars($page->title, ENT_QUOTES, 'utf-8'); 
    410411        //$page->content = htmlspecialchars(stripslashes($page->content), ENT_COMPAT, 'utf-8'); 
    411         $page->content = $page->content
     412        $page->content = trim($page->content)
    412413        $page->name = htmlspecialchars($page->name, ENT_QUOTES, 'utf-8'); 
    413414 
     
    426427        $input_content = pages_html_wrap('label', __gettext('Content:'), array('for' => 'page-content')); 
    427428        $input_content .= pages_html_wrap( 
    428                         'textarea', $page->content
     429                        'textarea', htmlentities($page->content)
    429430                        array( 
    430431                            'id' => 'page-content',