public function __construct() { parent::__construct(); /* Attivazione plugin `first`. */ require_once 'class.Plugin.php'; if ($this->config[0]->plugin == 1) { $plugins = Plugin::listPlugins(); $varList = parent::getValues(); foreach ($plugins as $element) { if (Plugin::getMetadata($element, 'enabled', '') == 'true' && Plugin::getMetadata($element, 'working', '') == 'first' && file_exists($this->config[0]->root_index . '/plugin/plugins/' . Plugin::getMetadata($element, 'path', ''))) { try { $plugin = Plugin::loadPlugin($element); $output = $plugin->main($varList); if (is_array($output)) { foreach ($output as $name => $value) { if ($name !== '' && $value !== '') { parent::addValue($name, $value); } } } } catch (Exception $e) { if ($ocarina->config[0]->log == 1) { $ocarina->log($element, $e->getMessage()); } echo '<!-- ' . $e->getMessage() . ' -->'; } } } unset($plugins); } }
function response() { $ajax = Request::ajax(); $ajax === 'd' and Request::ajax(true); $naked = Input::get(Block::$nakedVar, $ajax); $onlyBlocks = Input::get('_blocks'); if (!isset($onlyBlocks) and $ajax) { $onlyBlocks = ''; } $singleBlock = (isset($onlyBlocks) and !is_array($onlyBlocks)); $firstServed = in_array(head((array) $onlyBlocks), array('!', '1', '')); if ($singleBlock and !$naked) { // preventing DoubleEdge from wrapping response into $fullView. Input::merge(array(Block::$nakedVar => 1)); } $rendering = new Rendering($this, $onlyBlocks); $rendering->slugs = $this->slugs; $response = null; if ($singleBlock and $firstServed or $this->breaksout()) { isset($this->served) or Log::info_Layout('No specific server on this route.'); $rendering->result = array($this->servedResponse()); $ajax and $response = $rendering->result[0]; } elseif ($singleBlock) { $rendering->render($this); $rendering->result = array_slice($rendering->result, 1, -1, true); foreach ($rendering->result as $block) { foreach (arrize($block) as $blockResponse) { is_object($blockResponse) and $blockResponse->isServed = true; } } } else { $rendering->render($this); } Request::ajax(null); if ($response) { // do nothing. } elseif ($onlyBlocks and !$rendering->result) { $paths = join(', ', (array) $onlyBlocks); Log::warn_Layout("No blocks to render have matched given path(s): {$paths}."); $response = $this->servedResponse(E_INPUT); } else { $naked and $rendering->unwrap(); $response = $rendering->served ?: Response::adapt(''); $content = $rendering->join($ajax); if (!$naked and !$singleBlock and is_scalar($content) and $full = $this->view()) { $content = $full->with(compact('content')); } if (method_exists($response, 'set')) { $response->set($content); } else { $response->content = $content; } } // restoring value that could have been set in the beginning. Input::merge(array(Block::$nakedVar => $naked)); return Response::postprocess($response); }