Example #1
0
 public function run_hook()
 {
     /// Stark__Extend->run_hook has a RESUME_TIMER at the beginning of the include (or the rhni func)
     $this->lock();
     $hooks = $this->__hooks;
     foreach ($hooks as $callback) {
         ////// Supported Formats:
         ///  Static non-class functions (without parameters)
         if (is_string($callback) || is_array($callback) && isset($callback[0]) && !is_array($callback[0]) && isset($callback[1]) && !is_array($callback[1])) {
             list($func, $params) = array($callback, array());
         } else {
             if (is_array($callback) && isset($callback[0]) && !is_object($callback[0]) && isset($callback[1]) && is_array($callback[1])) {
                 list($func, $params) = $callback;
             } else {
                 continue;
             }
         }
         // Should never happen, because of validation in hook()
         ///  Always add the Extend object as the first parameter
         array_unshift($params, $this);
         if (STARK_EXTEND_PROFILE) {
             PAUSE_TIMER('Stark__Extend->run_hook');
         }
         $ret_val = call_user_func_array($func, $params);
         if (STARK_EXTEND_PROFILE) {
             RESUME_TIMER('Stark__Extend->run_hook');
         }
         ///  If they had a non-null return value, then record it
         if (!is_null($ret_val)) {
             $this->set_return_value($ret_val);
             ///  But don't break, because the other hooks need to run...
         }
         $this->extend->leave_finished_scopes();
     }
     $this->finish();
     // This will later trigger the closing of this scope and cleanup of the vars
     if (STARK_EXTEND_PROFILE) {
         END_TIMER('Stark__Extend->run_hook');
     }
 }
Example #2
0
function dax_scrub_flatten_stuff($watch_stuff)
{
    START_TIMER('DAX_SCRUB_flatten');
    global $dax_scrub_tree, $dax_scrub_this_node, $dax_scrub_final_html;
    ###  Merge all Children into the last child
    for ($i = 0; $i < count($dax_scrub_this_node['children']); $i++) {
        ###  Merge in it's children
        if (isset($dax_scrub_this_node['children'][$i]['children']) && count($dax_scrub_this_node['children'][$i]['children']) > 0) {
            $dax_scrub_this_node_BAK =& $GLOBALS['dax_scrub_this_node'];
            $GLOBALS['dax_scrub_this_node'] =& $dax_scrub_this_node['children'][$i];
            PAUSE_TIMER('DAX_SCRUB_flatten');
            dax_scrub_flatten_stuff($watch_stuff);
            RESUME_TIMER('DAX_SCRUB_flatten');
            $GLOBALS['dax_scrub_this_node'] =& $dax_scrub_this_node_BAK;
            $last_child = $dax_scrub_this_node['children'][$i]['children'][count($dax_scrub_this_node['children'][$i]['children']) - 1];
            ###  Merge the last child into our pre_close_tag_content
            $dax_scrub_this_node['children'][$i]['pre_close_tag_content'] = $last_child['pre_tag_content'] . $last_child['tag'] . $last_child['pre_close_tag_content'] . $last_child['close_tag'] . $dax_scrub_this_node['children'][$i]['pre_close_tag_content'];
            $dax_scrub_this_node['children'][$i]['children'] = array();
            ###  Then, kill the children
        }
        ###  Merge this tag into the NEXT SIBLING, unless this is the last sibling
        if ($i < count($dax_scrub_this_node['children']) - 1) {
            $dax_scrub_this_node['children'][$i + 1]['pre_tag_content'] = $dax_scrub_this_node['children'][$i]['pre_tag_content'] . $dax_scrub_this_node['children'][$i]['tag'] . $dax_scrub_this_node['children'][$i]['pre_close_tag_content'] . $dax_scrub_this_node['children'][$i]['close_tag'] . $dax_scrub_this_node['children'][$i + 1]['pre_tag_content'];
        }
    }
    ###  Then, kill the ones we just flattened into the last child
    if (count($dax_scrub_this_node['children']) > 1) {
        array_splice($dax_scrub_this_node['children'], 0, count($dax_scrub_this_node['children']) - 1);
    }
    ###  If this is the root node, pass this content into the final HTML
    if (isset($dax_scrub_this_node['is_root_node'])) {
        $dax_scrub_final_html .= $dax_scrub_this_node['children'][0]['pre_tag_content'];
        $dax_scrub_this_node['children'][0]['pre_tag_content'] = '';
    }
    END_TIMER('DAX_SCRUB_flatten');
}