/** @param templates the input or output form of View::parseTemplateString where subtemplates is the passed into get as $templates. In the case of subtemplates, named ouput of each subtemplate along with the total previous output of the subtemplates is passed to the supertemplate. The output of each subtemplate is passed by name in a $templates array, and the total output is available under the variable $input. @return output from the templates */ protected function get($templates, $parseTemplates = true) { if ($parseTemplates) { //this parses all levels, so only need to run on non-recursive call if (!is_array($templates)) { $templates = self::parseTemplateString($templates); } $templates = $this->parseAliases($templates); $templates = self::attachChildren($templates); } $return['collect'] = array(); while ($templates) { $template = array_pop($templates); if (is_array($template)) { if ($template[2]) { $got = self::get($template[2], false); if ($template[0]) { $output = $this->getTemplate($template[0], array('templates' => $got['collect'], 'input' => $got['combine'])); } Arrays::addOnKey($template[1] ? $template[1] : $template[0], $output, $return['collect']); } else { $output = $this->getTemplate($template[0]); Arrays::addOnKey($template[1] ? $template[1] : $template[0], $output, $return['collect']); } } else { $output = $this->getTemplate($template); Arrays::addOnKey($template, $output, $return['collect']); } $return['combine'] .= $output; } return $return; }
/** @param options various options: hookName : sets hookname, so as to allow identifying it for deletion or modification deleteAfter : #, deletes after # of uses */ static function add($spotName, $callback, $options = null) { $hook = array('callback' => $callback, 'options' => $options); return Arrays::addOnKey($options['hookName'], $hook, self::$hooks[$spotName]); }