A generic MVC view implementation
Ejemplo n.º 1
0
 /**
  * A mocked object will have a random name, that won't match the regex expression in the parent.
  * To prevent exceptions, we have to manually set the name
  *
  * @return string
  */
 public function getName()
 {
     if (isset($this->methods['getName'])) {
         if ($this->methods['getName'] == 'parent') {
             return parent::getName();
         }
         $func = $this->methods['getName'];
         return call_user_func_array($func, array());
     }
     return $this->name;
 }
Ejemplo n.º 2
0
 /**
  * Public constructor. The config array can contain the following keys
  * extensions       array
  * defaultLayout    string
  * defaultTpl       string
  * strictView       bool
  * strictTpl        bool
  * strictLayout     bool
  * sidePrefix       string
  * For the descriptions of each key please see the same-named property of this class
  *
  * @param   View   $view    The view we are attached to
  * @param   array  $config  The configuration for this view template finder
  */
 function __construct(View $view, array $config = array())
 {
     $this->view = $view;
     $this->container = $view->getContainer();
     if (isset($config['extensions'])) {
         if (!is_array($config['extensions'])) {
             $config['extensions'] = trim($config['extensions']);
             $config['extensions'] = explode(',', $config['extensions']);
             $config['extensions'] = array_map(function ($x) {
                 return trim($x);
             }, $config['extensions']);
         }
         $this->setExtensions($config['extensions']);
     }
     if (isset($config['defaultLayout'])) {
         $this->setDefaultLayout($config['defaultLayout']);
     }
     if (isset($config['defaultTpl'])) {
         $this->setDefaultTpl($config['defaultTpl']);
     }
     if (isset($config['strictView'])) {
         $config['strictView'] = in_array($config['strictView'], array(true, 'true', 'yes', 'on', 1));
         $this->setStrictView($config['strictView']);
     }
     if (isset($config['strictTpl'])) {
         $config['strictTpl'] = in_array($config['strictTpl'], array(true, 'true', 'yes', 'on', 1));
         $this->setStrictTpl($config['strictTpl']);
     }
     if (isset($config['strictLayout'])) {
         $config['strictLayout'] = in_array($config['strictLayout'], array(true, 'true', 'yes', 'on', 1));
         $this->setStrictLayout($config['strictLayout']);
     }
     if (isset($config['sidePrefix'])) {
         $this->setSidePrefix($config['sidePrefix']);
     }
 }
Ejemplo n.º 3
0
Archivo: Raw.php Proyecto: akeeba/fof
 /**
  * Overrides the constructor to apply Joomla! ACL permissions
  *
  * @param   Container  $container  The container we belong to
  * @param   array      $config     The configuration overrides for the view
  */
 public function __construct(Container $container, array $config = array())
 {
     parent::__construct($container, $config);
     $this->permissions = $this->getPermissions(null, $this->additionalPermissions);
 }
Ejemplo n.º 4
0
 /**
  * Creates a view template finder object for a specific View
  *
  * The default configuration is:
  * Look for .php, .blade.php files; default layout "default"; no default subtemplate;
  * look only for the specified view; do NOT fall back to the default layout or subtemplate;
  * look for templates ONLY in site or admin, depending on where we're running from
  *
  * @param   View  $view   The view this view template finder will be attached to
  * @param   array $config Configuration variables for the object
  *
  * @return  mixed
  */
 public function viewFinder(View $view, array $config = array())
 {
     // Initialise the configuration with the default values
     $defaultConfig = array('extensions' => array('.php', '.blade.php'), 'defaultLayout' => 'default', 'defaultTpl' => '', 'strictView' => true, 'strictTpl' => true, 'strictLayout' => true, 'sidePrefix' => 'auto');
     $config = array_merge($defaultConfig, $config);
     // Apply fof.xml overrides
     $appConfig = $this->container->appConfig;
     $key = "views." . ucfirst($view->getName()) . ".config";
     $fofXmlConfig = array('extensions' => $appConfig->get("{$key}.templateExtensions", $config['extensions']), 'strictView' => $appConfig->get("{$key}.templateStrictView", $config['strictView']), 'strictTpl' => $appConfig->get("{$key}.templateStrictTpl", $config['strictTpl']), 'strictLayout' => $appConfig->get("{$key}.templateStrictLayout", $config['strictLayout']), 'sidePrefix' => $appConfig->get("{$key}.templateLocation", $config['sidePrefix']));
     $config = array_merge($config, $fofXmlConfig);
     // Create the new view template finder object
     return new ViewTemplateFinder($view, $config);
 }