/** * Wrapper for calling the self::$show-method. This wrapper is necessary to call * * @internal * * @param string $show * @throws \FeM\sPof\exception\NotImplementedException * @return mixed content */ public function executeShow($show = null) { // call show met if ($show === null) { $show = \FeM\sPof\Router::getShow($show); } if (!method_exists(get_called_class(), $show)) { throw new \FeM\sPof\exception\NotImplementedException(_s('Could not find the show method. "%s::%s"', get_called_class(), $show)); } return $this->{$show}(); }
/** * Initialize the form property. * * @api */ protected function initializeForm($namespace = null) { if ($namespace !== null) { $classname = $namespace . '\\'; } else { $classname = Application::$NAMESPACE . 'form\\'; } $classname .= Router::getModule() . 'Form'; $show = Request::getStrParam('show'); $this->form = new $classname(); if (method_exists($classname, $show)) { $this->form->{$show}(); $this->form->setActive(true); } }
/** * Wrapper for @see Router::reverse(). Additional params are _fullurl and _https, for links with https-protocol and * absolute urls. Define the route name with _name and everything else is used as arguments, you may also specify all * arguments at once using the 'arguments' param. * * @package FeM\sPof\template\smartyPlugins * @author dangerground * @since 1.0 * * @api * * @throws FeM\sPof\exception\SmartyTemplateException * * @param array $params * @param Smarty $smarty * * @return string */ function smarty_function_route($params, &$smarty) { // get array elements as single params if (isset($params['arguments']) && is_array($params['arguments'])) { $params = array_merge($params['arguments'], $params); unset($params['arguments']); } $arguments = $params; unset($arguments['_name']); $fullurl = isset($arguments['_fullurl']) ? $arguments['_fullurl'] : false; unset($arguments['_fullurl']); $https = isset($arguments['_https']) || isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'on' ? $arguments['_https'] : true; unset($arguments['_https']); try { $server = FeM\sPof\Config::get('server'); $basedir = 'https://' . $_SERVER['SERVER_NAME'] . $server['path']; return ($fullurl ? $https ? $basedir : preg_replace('#^https#', 'http', $basedir) : '') . \FeM\sPof\Router::reverse($params['_name'], $arguments); } catch (\InvalidArgumentException $e) { throw new \FeM\sPof\exception\SmartyTemplateException(__FUNCTION__ . ': ' . $e->getMessage(), $smarty->getTemplateDir()[0] . $smarty->template_resource, $e); } }
/** * Execute the show method. * * @internal * * @param string $show * @return string */ public function executeShow($show = null) { if ($show === null) { $show = Router::getShow(); } // by default use the content from the show method or the form $content = parent::executeShow($show); // if still empty, guess there is a template if ($content === null) { $templateFile = ''; if (isset(static::$TEMPLATE_DIR)) { $templateFile = static::$TEMPLATE_DIR . '/'; } else { $templateFile = lcfirst(Router::getModule()) . '/'; } $templateFile .= $show . '.tpl'; try { $content = template\HtmlTemplate::getInstance()->fetch($templateFile); } catch (\SmartyException $e) { Logger::getInstance()->info(_s('Could not find template, next trying form. (%s)', $e->getMessage())); } } // if still empty, try to generate by form if (isset($this->form) && $this->form->isActive()) { $content .= $this->form->render(); } // call show method $this->assign('content', $content); return $content; }
/** * Log the session. Module and session id are already there * * @internal * * @param array $reference other reference parameters, e.g. new generated ids * @param array $parameters url parameters, e.g. from $_GET */ protected final function trackSession(array $reference, array $parameters) { \FeM\sPof\model\LogSession::add(['session_id' => session_id(), 'view' => Router::getModule(), 'reference_parameters' => serialize($reference), 'other_parameters' => serialize($parameters)]); }
/** * * @internal * * @param array $reference reference ids * @param string $description (optional) additional information * @param bool $success (optional) */ protected final function logEvent(array $reference, $description = null, $success = false) { LogEvent::add(['event' => Router::getModule() . '.' . $this->command . '.' . ($success ? 'Success' : 'Fail'), 'user_id' => Session::getUserId(), 'reference_parameters' => json_encode($reference), 'description' => $description]); }