function perch_get_javascript($opts = false, $return = false) { $feathers = PerchSystem::get_registered_feathers(); $out = ''; if (PerchUtil::count($feathers)) { $count = PerchUtil::count($feathers); $i = 0; $components = array(); foreach ($feathers as $feather) { $classname = 'PerchFeather_' . $feather; $Feather = new $classname($components); $out .= $Feather->get_javascript($opts, $i, $count); $components = $Feather->get_components(); $i++; } } // Inject script when authed if (isset($_COOKIE['cmsa'])) { $out .= PerchSystem::get_helper_js(); } if ($return) { return $out; } echo $out; PerchUtil::flush_output(); }
function perch_template($tpl, $vars = array(), $return = false) { $Template = new PerchTemplate($tpl); if (!is_array($vars)) { PerchUtil::debug('Non-array content value passed to perch_template.', 'error'); $vars = array(); } if (count($vars) == 0) { $Template->use_noresults(); } if (!PerchUtil::is_assoc($vars)) { $html = $Template->render_group($vars, true); } else { $html = $Template->render($vars); } $html = $Template->apply_runtime_post_processing($html); if ($return) { return $html; } echo $html; PerchUtil::flush_output(); }