Changeset 1411

Show
Ignore:
Timestamp:
12/07/07 15:27:21 (7 months ago)
Author:
rho
Message:

Included default pages templates

Signed-off: Rolando Espinoza La fuente <rho@prosoftpeople.com>

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • devel/mod/pages/lib.php

    r1383 r1411  
    2020    pages_dbsetup(); 
    2121 
    22     // legacy pages 
     22    //DEPRECATED: legacy pages 
     23    /* 
    2324    $PAGE->pages->old_compat = array( 
    2425        'about.php' => array( 
     
    5556        'function' => 'pages:frontpage_loggedout', 
    5657        ); 
    57  
     58     */ 
    5859} 
    5960 
     
    6566    $CFG->templates->variables_substitute['pagesmenu'][] = 'pages_tplkw_menu'; 
    6667    $CFG->templates->variables_substitute['page'][] = 'pages_tplkw_page'; 
     68    $CFG->templates->variables_substitute['sysadminemail'][] = 'pages_tplkw_sysadminemail'; 
    6769 
    6870    if (defined('context') && context == 'pages') { 
     
    134136            // insert first page 
    135137            $page = new StdClass; 
    136             $page->name = __gettext('Main'); 
    137             $page->uri = pages_build_uri($page->name)
    138             $page->title = __gettext('Main page'); 
    139             $page->content = pages_html_wrap('p', __gettext('This is your first page. Edit me!')); 
    140             $page->content .= pages_html_wrap('p', __gettext('Installed on ') . pages_html_wrap('a', '{{url}}', array('href' => '{{url}}'))); 
    141             if (pages_php_allowed()) { 
    142                 $page->content .= pages_html_wrap('p', __gettext('Current time: ') . ' <?php echo strftime("%Y-%m-%d, %H:%m") ?>'); 
    143             } 
    144             $page->content .= pages_html_wrap('h2', __gettext('Blog summary')); 
    145             $page->content .= pages_html_wrap('div', '{{blogsummary:5}}')
    146  
    147             $rs = insert_record('pages', $page); 
    148             $page->ident = $rs
    149  
    150             set_config('pages_default', $page->ident); 
    151  
    152             if ($rs) { 
    153                 // first child 
    154                 $page2 = new StdClass
    155                 $page2->name = 'Example page'
    156                 $page2->uri = pages_build_uri('Example page')
    157                 $page2->title = __gettext('Example page for ') . $CFG->sitename
    158                 $page2->content = pages_html_wrap('p', __gettext('Example content')); 
    159                 $page2->content .= pages_html_wrap('p', __gettext('Random users: {{randomusers}}')); 
    160                 $page2->content .= pages_html_wrap('p', __gettext('Top tags: {{toptags}}'))
    161                 $page2->parent = $page->ident
    162  
    163                 $rs = insert_record('pages', $page2); 
    164                 $page2->ident = $rs; 
    165             } 
     138            $page->name = __gettext('About'); 
     139            $page->title = __gettext('About') . " {{sitename}}"
     140            $page->content = @file_get_contents(dirname(__FILE__).'/legacy/content_about.html'); 
     141 
     142            $page = pages_create_page($page); 
     143 
     144            if ($page) { 
     145                set_config('pages_default', $page->ident); 
     146 
     147                $_page = new StdClass
     148                $_page->uri = 'privacy.php'; //backward compatibility 
     149                $_page->title = __gettext('Privacy Policy'); 
     150                $_page->content = @file_get_contents(dirname(__FILE__).'/legacy/content_privacy.html')
     151                $_page->parent = $page->ident; 
     152                $_page = pages_create_page($_page); 
     153 
     154                $_page = new StdClass; 
     155                $_page->uri = 'terms.php'; //backward compatibility 
     156                $_page->title = __gettext('Terms and Conditions')
     157                $_page->content = @file_get_contents(dirname(__FILE__).'/legacy/content_terms.html')
     158                $_page->parent = $page->ident
     159                $_page = pages_create_page($_page)
     160            } 
     161 
     162            $page = new StdClass
     163            $page->name = __gettext('FAQ')
     164            $page->title = __gettext('Frequently Asked Questions'); 
     165            $page->content = @file_get_contents(dirname(__FILE__).'/legacy/content_faq.html'); 
     166 
     167            $page = pages_create_page($page); 
    166168 
    167169        } else { 
     
    287289} 
    288290 
     291function pages_tplkw_sysadminemail() { 
     292    global $CFG; 
     293    return $CFG->sysadminemail; 
     294} 
     295 
    289296function pages_frontpage($logged=false) { 
    290297    require_once(dirname(__FILE__) . '/lib/pages.inc.php'); 
     
    469476 
    470477    return pages_html_wrap('input', null, $attrs); 
     478} 
     479 
     480function pages_html_form($name, $body, $method='post', $action='', $attrs=null) { 
     481    $body .= pages_html_input('hidden', array('name'=>'form_key', 'value'=>elggform_get_key())); 
     482    $attrs = array_merge(array('id'=>$name, 'name'=>$name, 'method'=>$method, 'action'=>$action,), $attrs); 
     483    return pages_html_wrap('form', $body, $attrs); 
    471484} 
    472485 
  • devel/mod/pages/lib/pages.inc.php

    r1383 r1411  
    227227} 
    228228 
     229function pages_create_page($page) { 
     230    global $messages; 
     231    if (!is_object($page)) { 
     232        trigger_error(__FUNCTION__.": invalid argument (page: is not an object)", E_USER_ERROR); 
     233    } 
     234 
     235    if (empty($page->title) || empty($page->content)) { 
     236        trigger_error(__FUNCTION__.": invalid argument (page title or content empty)", E_USER_ERROR); 
     237    } 
     238 
     239    if (empty($page->name)) { 
     240        $page->name = $page->title; 
     241    } 
     242 
     243    if (empty($page->uri)) { 
     244        $page->uri = pages_build_uri($page->name); 
     245    } 
     246 
     247    $rs = insert_record('pages', $page); 
     248    if ($rs) { 
     249        $page->ident = $rs; 
     250        return $page; 
     251    } else { 
     252        return false;  
     253    } 
     254} 
     255 
    229256function pages_get_page($page_name, $owner=-1) { 
    230257