/home/suroeste/public_html/wp-content/plugins/akeebabackupwp/app/vendor/akeeba/awf/src/Mvc
NameSizeModeActions
Compiler/-0755rm
DataModel/-0755rm
DataView/-0755rm
Engine/-0755rm
Controller.php188190644editdlrm
DataController.php276420644editdlrm
DataModel.php816850644editdlrm
Factory.php59030644editdlrm
Model.php130510644editdlrm
TreeModel.php592870644editdlrm
View.php312020644editdlrm
ViewTemplateFinder.php120570644editdlrm
Edit: /home/suroeste/public_html/wp-content/plugins/akeebabackupwp/app/vendor/akeeba/awf/src/Mvc/View.php (31202B)
'users/profile') * * allows you to do something like $this->loadAnyTemplate('userProfile') to display the view template users/profile. * You can also alias one view template with another, e.g. 'users/profile' => 'clients/record' * * @var array */ protected $viewTemplateAliases = []; /** * The object used to locate view templates in the filesystem * * @var ViewTemplateFinder */ protected $viewFinder = null; /** * Used when loading template files to avoid variable scope issues * * @var null */ protected $_tempFilePath = null; /** * Maps view template extensions to view engine classes * * @var array */ protected $viewEngineMap = [ '.blade.php' => 'Awf\\Mvc\\Engine\\BladeEngine', '.php' => 'Awf\\Mvc\\Engine\\PhpEngine', ]; /** * All of the finished, captured sections. * * @var array */ protected $sections = []; /** * The stack of in-progress sections. * * @var array */ protected $sectionStack = []; /** * The number of active rendering operations. * * @var int */ protected $renderCount = 0; /** * Should I be strict about the subtemplate being loaded? * * When false, trying to load template `foo_bar` will fall back to `foo` is `foo_bar` does not exist. * * When true, trying to load template `foo_bar` will throw if `foo_bar` does not exist. * * @var bool * @since 1.0.1 */ protected $strictTpl = false; /** * Should I be strict about the layout being loaded? * * When false, trying to load layout `foo` will fall back to `default` if `foo` does not exist. * * When true, trying to load layout `foo` will throw if `foo` does not exist. * * @var bool * @since 1.0.1 */ protected $strictLayout = false; /** * Constructor * * @param Container|null $container The DI Container.
* Inside it you can have an 'mvc_config' array with the following options:
* name: the name (optional) of the view (defaults to the view class name * suffix).
escape: the name (optional) of the function to use for escaping * strings
template_path: the path (optional) of the layout directory * (defaults to base_path + /views/ + view name
layout: the layout (optional) * to use to display the view
* * @throws App */ public function __construct(?Container $container = null, ?Language $language = null) { /** @deprecated 2.0 You must provide the container */ if (empty($container)) { trigger_error( sprintf('The container argument is mandatory in %s', __METHOD__), E_USER_DEPRECATED ); $container = Application::getInstance()->getContainer(); } $this->setContainer($container); $this->setLanguage($language ?? $container->language); $container->eventDispatcher->trigger('onViewBeforeConstruct', [$this, $container]); $container = $this->getContainer(); // Cache some useful references in the class $this->input = $container->input; $this->config = isset($container['mvc_config']) ? $container['mvc_config'] : []; // Get the view name $this->name = $this->getName(); // Set the default template search path if (array_key_exists('template_path', $this->config)) { // User-defined dirs $this->setTemplatePath($this->config['template_path']); } else { $this->setTemplatePath($this->container->basePath . '/View/' . ucfirst($this->name) . '/tmpl'); } // Set the layout if (array_key_exists('layout', $this->config)) { $this->setLayout($this->config['layout']); } $templatePath = $this->container->templatePath; $fallback = $templatePath . '/' . $this->container->application->getTemplate() . '/html/' . ucfirst($this->container->application->getName()) . '/' . $this->name; $this->addTemplatePath($fallback); // Get extra directories through event dispatchers $extraPathsResults = $this->container->eventDispatcher->trigger('onGetViewTemplatePaths', [$this->getName()]); if (is_array($extraPathsResults) && !empty($extraPathsResults)) { foreach ($extraPathsResults as $somePaths) { if (!empty($somePaths)) { foreach ($somePaths as $aPath) { $this->addTemplatePath($aPath); } } } } // Apply the viewEngineMap if (isset($this->config['viewEngineMap'])) { if (!is_array($this->config['viewEngineMap'])) { $temp = explode(',', $this->config['viewEngineMap']); $this->config['viewEngineMap'] = []; foreach ($temp as $assignment) { $parts = explode('=>', $assignment, 2); if (count($parts) != 2) { continue; } $parts = array_map(function ($x) { return trim($x); }, $parts); $this->config['viewEngineMap'][$parts[0]] = $parts[1]; } } $this->viewEngineMap = array_merge($this->viewEngineMap, $this->config['viewEngineMap']); } // Set the ViewFinder $this->viewFinder = new ViewTemplateFinder($this); if (isset($this->config['viewFinder']) && !empty($this->config['viewFinder']) && is_object($this->config['viewFinder']) && ($this->config['viewFinder'] instanceof ViewTemplateFinder)) { $this->viewFinder = $this->config['viewFinder']; } // Apply the registered view template extensions to the view finder $this->viewFinder->setExtensions(array_keys($this->viewEngineMap)); $this->baseurl = Uri::base(true, $this->container); $container->eventDispatcher->trigger('onViewAfterConstruct', [$this, $container]); } /** * Returns an instance of a view class * * @param string|null $appName The application name [optional] Default: from container or default app if no * container is provided * @param string|null $viewName The view name [optional] Default: the "view" input parameter * @param string|null $viewType The view type [optional] Default: the "format" input parameter or, if not * defined, "html" * @param Container|null $container The container to be attached to the view * * @deprecated 2.0 Use the MVCFactory in the Container instead * @return self * @throws App */ public static function getInstance(?string $appName = null, ?string $viewName = null, ?string $viewType = null, ?Container $container = null, ?Language $language = null) { trigger_error( sprintf( 'Calling %s is deprecated. Use the MVCFactory service of the container instead.', __METHOD__ ), E_USER_DEPRECATED ); return ($container ?? Application::getInstance($appName)->getContainer()) ->mvcFactory->makeView($viewName, $viewType, $language); } /** * Method to get the view name * * The model name by default parsed using the classname, or it can be set * by passing a $config['name'] in the class constructor * * @return string The name of the model * * @throws RuntimeException */ public function getName() { if (empty($this->name)) { $r = null; if (!preg_match('/(.*)\\\\View\\\\(.*)\\\\(.*)/i', get_class($this), $r)) { throw new RuntimeException($this->getContainer()->language->text('AWF_APPLICATION_ERROR_VIEW_GET_NAME'), 500); } $this->name = $r[2]; } return $this->name; } /** * Escapes a value for output in a view script. * * @param mixed $var The output to escape. * * @return mixed The escaped value. */ public function escape($var) { return htmlspecialchars($var ?? '', ENT_COMPAT, 'UTF-8'); } /** * Method to get data from a registered model or a property of the view * * @param string $property The name of the method to call on the Model or the property to get * @param string $default The default value [optional] * @param string $modelName The name of the Model to reference [optional] * * @return mixed The return value of the method */ public function get($property, $default = null, $modelName = null) { // If $model is null we use the default model if (is_null($modelName)) { $model = $this->defaultModel; } else { $model = strtolower($modelName); } // First check to make sure the model requested exists if (isset($this->modelInstances[$model])) { // Model exists, let's build the method name $method = 'get' . ucfirst($property); // Does the method exist? if (method_exists($this->modelInstances[$model], $method)) { // The method exists, let's call it and return what we get $result = $this->modelInstances[$model]->$method(); return $result; } else { $result = $this->modelInstances[$model]->$property(); if (is_null($result)) { return $default; } return $result; } } // If the model doesn't exist, try to fetch a View property else { if (@isset($this->$property)) { return $this->$property; } else { return $default; } } } /** * Returns a named Model object * * @param string $name The Model name. If null we'll use the modelName * variable or, if it's empty, the same name as * the Controller * @param array $config Configuration parameters to the Model. If skipped * we will use $this->config * * @return Model The instance of the Model known to this Controller */ public function getModel($name = null, $config = []) { if (!empty($name)) { $modelName = strtolower($name); } elseif (!empty($this->defaultModel)) { $modelName = strtolower($this->defaultModel); } else { $modelName = strtolower($this->name); } if (!array_key_exists($modelName, $this->modelInstances)) { $mvcConfig = $this->container['mvc_config'] ?? []; $this->container['mvc_config'] = ($config ?: $this->config); $this->modelInstances[$modelName] = $this->container->mvcFactory->makeModel($modelName, $this->getLanguage()); $this->container['mvc_config'] = $mvcConfig; } return $this->modelInstances[$modelName]; } /** * Pushes the default Model to the View * * @param Model $model The model to push */ public function setDefaultModel(Model &$model) { $name = $model->getName(); $this->setDefaultModelName($name); $this->setModel($this->defaultModel, $model); } /** * Set the name of the Model to be used by this View * * @param string $modelName The name of the Model * * @return void */ public function setDefaultModelName($modelName) { $this->defaultModel = $modelName; } /** * Pushes a named model to the View * * @param string $modelName The name of the Model * @param Model $model The actual Model object to push * * @return void */ public function setModel($modelName, Model &$model) { $this->modelInstances[strtolower($modelName)] = $model; } /** * Overrides the default method to execute and display a template script. * Instead of loadTemplate is uses loadAnyTemplate. * * @param string $tpl The name of the template file to parse * * @return boolean True on success * * @throws Exception When the layout file is not found */ public function display($tpl = null) { $this->viewOutput = ''; $method = 'onBefore' . ucfirst($this->doTask); if (method_exists($this, $method)) { $result = $this->$method($tpl); if (!$result) { throw new Exception($this->getContainer()->language->text('AWF_APPLICATION_ERROR_ACCESS_FORBIDDEN'), 403); } } $results = $this->container->eventDispatcher->trigger('onViewBefore' . ucfirst($this->doTask), [$this]) ?: []; if (in_array(false, $results, true)) { return false; } $this->viewOutput .= $this->loadTemplate($tpl); $method = 'onAfter' . ucfirst($this->doTask); if (method_exists($this, $method)) { if (!($this->$method($tpl))) { throw new Exception($this->getContainer()->language->text('AWF_APPLICATION_ERROR_ACCESS_FORBIDDEN'), 403); } } $results = $this->container->eventDispatcher->trigger('onViewAfter' . ucfirst($this->doTask), [ $this, &$this->viewOutput, ]) ?: []; if (in_array(false, $results, true)) { return false; } if (is_object($this->viewOutput) && ($this->viewOutput instanceof Exception)) { throw $this->viewOutput; } else { echo $this->viewOutput; return true; } } /** * Our function uses loadAnyTemplate to provide smarter view template loading. * * @param string $tpl The name of the template file to parse * @param boolean $strict Should we use strict naming, i.e. force a non-empty $tpl? * * @return mixed A string if successful, otherwise an Exception */ public function loadTemplate($tpl = null, $strict = false) { $basePath = $this->name . '/'; $strict = $strict || $this->strictTpl; if ($strict) { $paths = [$basePath . $this->getLayout() . ($tpl ? "_$tpl" : '')]; if (!$this->strictLayout) { $paths[] = $basePath . 'default' . ($tpl ? "_$tpl" : ''); } } else { $paths = [ $basePath . $this->getLayout() . ($tpl ? "_$tpl" : ''), $basePath . $this->getLayout(), ]; if (!$this->strictLayout) { $paths[] = $basePath . 'default' . ($tpl ? "_$tpl" : ''); $paths[] = $basePath . 'default'; } } $paths = array_unique($paths); foreach ($paths as $path) { try { $result = $this->loadAnyTemplate($path); } catch (Exception $e) { $result = $e; } if (!($result instanceof Exception)) { break; } } return $result; } /** * Get the layout. * * @return string The layout name */ public function getLayout() { return $this->layout; } /** * Sets the layout name to use * * @param string $layout The layout name or a string in format