Ticket #171: 021_templates_page_output.diff

File 021_templates_page_output.diff, 4.5 kB (added by rho, 1 year ago)
  • a/index.php

    old new  
    55    require_once(dirname(__FILE__)."/includes.php"); 
    66    templates_page_setup(); 
    77    if (logged_on) { 
    8         $body = templates_draw(array( 
    9                                         'context' => 'frontpage_loggedin' 
    10                                 )    
    11                                 ); 
     8        templates_page_output($CFG->sitename, null, 'frontpage_loggedin'); 
    129    } else { 
    13         $body = templates_draw(array( 
    14                                         'context' => 'frontpage_loggedout' 
    15                                 )    
    16                                 ); 
     10        templates_page_output($CFG->sitename, null, 'frontpage_loggedout'); 
    1711    } 
    18      
    19     echo templates_page_draw( array( 
    20                     $CFG->sitename, 
    21                     $body 
    22             ) 
    23             ); 
    2412             
    2513?> 
  • a/lib/templates.php

    old new  
    15881588    } 
    15891589} 
    15901590 
     1591/** 
     1592 * Outputs html page 
     1593 * @param string $title   The title of the page 
     1594 * @param string $body    The body of the content     
     1595 * @param string $context Optional template context 
     1596 * @param string $sidebar Optional sidebar content  
     1597 */ 
     1598function templates_page_output($title, $body, $context='contentholder', $sidebar=null) { 
     1599    // hook pre-output page 
     1600    // @rho i think no needed because there is already 
     1601    //      _init and _pagesetup 
     1602 
     1603    // allow title with html tags or specialchars 
     1604    $body = templates_draw(array( 
     1605        'context' => $context, 
     1606        'title' => $title, 
     1607        'body' => $body, 
     1608        )); 
     1609 
     1610    // clean title for <title> tag 
     1611    $title = htmlspecialchars_decode(strip_tags($title), ENT_COMPAT); 
     1612 
     1613    // print output! 
     1614    echo templates_page_draw(array($title, $body, $sidebar)); 
     1615 
     1616    // hook post-output 
     1617    action('end'); 
     1618 
     1619    // end execution 
     1620    exit(); 
     1621} 
     1622 
     1623// backward compatiblity for php < 5 
     1624if (!function_exists('htmlspecialchars_decode')) { 
     1625    function htmlspecialchars_decode($string, $quote_style=ENT_COMPAT) { 
     1626        return strtr($string, array_flip(get_html_translation_table(HTML_SPECIALCHARS/*, $quote_style*/))); 
     1627    } 
     1628} 
     1629 
     1630 
    15911631?> 
  • a/login/index.php

    old new  
    4949$body = __gettext('Please log in'); 
    5050templates_page_setup(); 
    5151// display the form. 
    52 echo templates_page_draw( array( 
    53                                       sitename, 
    54                                       templates_draw(array( 
    55                                                            'body' => $body, 
    56                                                            'title' => __gettext('Log On'), 
    57                                                            'context' => 'contentholder' 
    58                                                            ) 
    59                                                      ) 
    60                                       ) 
    61         ); 
     52templates_page_output($CFG->sitename, $body); 
    6253 
    6354?> 
  • a/profile/edit.php

    old new  
    5353} else { 
    5454    $body = $profile->display_form(); 
    5555}    
    56 $body = templates_draw(array( 'context' => 'contentholder', 
    57                               'title' => $title, 
    58                               'body' => $body   )); 
    5956 
    60 print templates_page_draw(array($title, $body)); 
    61  
    62  
     57templates_page_output($title, $body); 
    6358 
    6459function profile_update($profile_new) { 
    6560 
  • a/profile/index.php

    old new  
    308308// $title = 'Profile'; 
    309309$view  = $profile->view(); 
    310310 
    311 $body  = templates_draw( array( 
    312                                'context' => 'contentholder', 
    313                                'title' => $title, 
    314                                'body' => $view['body'], 
    315                                )); 
    316  
    317 //echo templates_page_draw(array($title, $body, NULL, $view['widgets'])); 
    318 echo templates_page_draw(array($title, $body)); 
     311templates_page_output($title, $view['body']); 
    319312 
    320313?>