Changeset 1307

Show
Ignore:
Timestamp:
11/22/07 17:21:31 (9 months ago)
Author:
rho
Message:

Patch #171, new function templates_page_output()

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

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • devel/index.php

    r614 r1307  
    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?> 
  • devel/lib/elgglib.php

    r1288 r1307  
    10731073 * @return string The remote IP address 
    10741074 */ 
    1075  function getremoteaddr() { 
     1075function getremoteaddr() { 
    10761076    if (!empty($_SERVER['HTTP_CLIENT_IP'])) { 
    10771077        return cleanremoteaddr($_SERVER['HTTP_CLIENT_IP']); 
     
    43714371} 
    43724372 
     4373/** 
     4374 * Returns an array of results from each relevant module 
     4375 * 
     4376 * This function runs the specified hook function for each module 
     4377 * that has the hook (possibly restricted to a supplied list of module names).  
     4378 * 
     4379 * @param string $hook the name of the module hook we want to invoke 
     4380 * @param int  $object_id the object id to apply the hook to (can be empty) 
     4381 * @param string  $object_type the type of the object to apply the hook to (can be empty) 
     4382 * @param array $modules an array of module names (can be empty) 
     4383 * @param array $modules an array of values keyed by keyed by parameter names to pass to the hook function (can be empty) 
     4384 * @return array an array of results keyed by module name 
     4385 */ 
     4386 
     4387function action($hook,$object_id=0, $object_type='', $modules = NULL, $parameters = NULL ) { 
     4388    global $CFG; 
     4389 
     4390    $results = array(); 
     4391    if (!$modules) { 
     4392        //if (!$CFG->plugins) { 
     4393            $CFG->plugins = get_list_of_plugins('mod'); 
     4394        //} 
     4395        $modules = $CFG->plugins; 
     4396    } 
     4397    foreach ($modules as $mod) { 
     4398        $mod_function = $mod . '_'.$hook; 
     4399        if (function_exists($mod_function)) { 
     4400           if ($parameters) { 
     4401                $results[$mod] = $mod_function($object_id,$object_type,$parameters); 
     4402            } else { 
     4403                $results[$mod] = $mod_function($object_id,$object_type); 
     4404            } 
     4405        } 
     4406    } 
     4407     
     4408    return $results; 
     4409} 
     4410 
    43734411?> 
  • devel/lib/templates.php

    r1278 r1307  
    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?> 
  • devel/login/index.php

    r659 r1307  
    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?> 
  • devel/mod/generic_comments/lib.php

    r1278 r1307  
    601601} 
    602602 
    603 // this is a temporary location - the code should be moved into elgglib 
    604  
    605 /** 
    606  * Returns an array of results from each relevant module 
    607  * 
    608  * This function runs the specified hook function for each module 
    609  * that has the hook (possibly restricted to a supplied list of module names).  
    610  * 
    611  * @param string $hook the name of the module hook we want to invoke 
    612  * @param int  $object_id the object id to apply the hook to (can be empty) 
    613  * @param string  $object_type the type of the object to apply the hook to (can be empty) 
    614  * @param array $modules an array of module names (can be empty) 
    615  * @param array $modules an array of values keyed by keyed by parameter names to pass to the hook function (can be empty) 
    616  * @return array an array of results keyed by module name 
    617  */ 
    618  
    619 function action($hook,$object_id=0, $object_type='', $modules = NULL, $parameters = NULL ) { 
    620     global $CFG; 
    621  
    622     $results = array(); 
    623     if (!$modules) { 
    624         //if (!$CFG->plugins) { 
    625             $CFG->plugins = get_list_of_plugins('mod'); 
    626         //} 
    627         $modules = $CFG->plugins; 
    628     } 
    629     foreach ($modules as $mod) { 
    630         $mod_function = $mod . '_'.$hook; 
    631         if (function_exists($mod_function)) { 
    632            if ($parameters) { 
    633                 $results[$mod] = $mod_function($object_id,$object_type,$parameters); 
    634             } else { 
    635                 $results[$mod] = $mod_function($object_id,$object_type); 
    636             } 
    637         } 
    638     } 
    639      
    640     return $results; 
    641 } 
    642  
    643603 
    644604/** 
  • devel/profile/edit.php

    r1054 r1307  
    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) { 
  • devel/profile/index.php

    r1215 r1307  
    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?>