Esempio n. 1
0
 public function index($params)
 {
     $view = new View();
     $view->setSource(Config::get('ext.acl.dir.views') . '/index.tpl');
     return $view;
 }
Esempio n. 2
0
 /**
  * Adds external stylesheet sources to the View.
  * The first argument given is special and can take the form of either a URL, a
  * conditional IE statement or one of the following key phrases:
  *        screen | print | all | screen,print
  *
  * If one of these phrases is used then it will be included in the "media"
  * attribute of the <link> nodes.
  *
  * If a conditional statement
  *
  * @example From within a PHP template:
  * <code>
  * $this->addStylesheets('/css/resource1.css', '/css/resource2.css');
  * $this->addStylesheets('print', '/css/resource3.css');
  * </code>
  *
  * @param string $src,... Unlimited list of external stylesheet URLs
  * @return void
  */
 public function addStylesheets()
 {
     // Determine conditional
     $args = func_get_args();
     $conditional = strpos($args[0], " IE ") !== false ? array_shift($args) : null;
     // Determine media
     $media = 'all';
     $medium = ['screen', 'print', 'screen,print', 'print,screen', 'all'];
     if (in_array(strtolower(str_replace(" ", "", $args[0])), $medium)) {
         $media = array_shift($args);
     }
     $add = $this->getAssetVersion();
     // Add stylesheets
     $view = $this->getStylesheetsView();
     if (!empty($args)) {
         /*if(!isset($this->stylesheets[$media])) {
               $this->stylesheets[$media] = array();
           }
           $this->stylesheets[$media] = array_unique(array_merge($this->stylesheets[$media], $args));*/
         foreach ($args as $a) {
             $this->stylesheets[] = (object) ['conditional' => $conditional, 'media' => $media, 'url' => $a];
         }
     }
     // Update the stylesheets View's source
     $output = '';
     $done = [];
     foreach ($this->stylesheets as $m => $src) {
         if (!isset($done[$src->url])) {
             if (substr($src->url, 0, 4) == 'http' || substr($src->url, 0, 2) == '//') {
                 // Don't add the variable if we're loading a remote script.
                 $thisSrc = $src->url;
             } else {
                 if (substr($src->url, -4) == ".css") {
                     $thisSrc = $src->url . $add;
                 } else {
                     $thisSrc = $src->url;
                 }
             }
             $output .= $src->conditional !== null ? "<!--[if {$src->conditional}]><link rel=\"stylesheet\" type=\"text/css\" href=\"{$thisSrc}\" media=\"{$src->media}\"  /><![endif]-->\n" : "<link rel=\"stylesheet\" type=\"text/css\" href=\"{$thisSrc}\" media=\"{$src->media}\" />\n";
             $done[$src->url] = true;
         }
     }
     $this->stylesheetsView->setSource($output);
 }