Exemple #1
0
 public function loadAllFromPath($path, $url)
 {
     $folders = FS::folders($path);
     foreach ($folders as $folder) {
         $config_file = untrailingslashit($path) . DIRECTORY_SEPARATOR . $folder . DIRECTORY_SEPARATOR . "config.php";
         if (!FS::exists($config_file)) {
             continue;
         }
         $this->add($config_file, trailingslashit($url) . $folder);
     }
 }
 public function loadAll()
 {
     foreach ($this->paths as $path) {
         $files = array_filter(FS::files($path['path']), function ($file) {
             return substr($file, -4, strrpos($file, '.json')) === "json";
         });
         foreach ($files as $file) {
             $config_file = untrailingslashit($path['path']) . DIRECTORY_SEPARATOR . $file;
             $this->add($config_file, $path['url'], $path['groups']);
         }
     }
 }
Exemple #3
0
 public function style($section)
 {
     $block = $this->blockManager->get($section['slug']);
     //throw better exceptions
     if (!$block) {
         //throw new \Exception( "Block Does not exist" );
         return null;
     }
     $style_file = array_key_exists('style', $block) ? $block['style'] : null;
     //throw better exceptions
     if (!FileSystem::exists($style_file)) {
         //throw new \Exception( "Block style Does not exist" );
         return null;
     }
     //better section styles
     $style = "<style id='style-{$section['id']}'>";
     $style .= $this->view->make($style_file, $section);
     $style .= "</style>";
     return $style;
 }
 public function loadAllFromPath($path, $url, $groups = array())
 {
     try {
         if (!FS::exists($path)) {
             $msg = __("You were trying to add blocks from " . $path . " but this path does not exist. Please create this folder.", "onepager");
             throw new \Exception($msg);
         }
         $folders = FS::folders($path);
         foreach ($folders as $folder) {
             $config_file = untrailingslashit($path) . DIRECTORY_SEPARATOR . $folder . DIRECTORY_SEPARATOR . "config.php";
             if (!FS::exists($config_file)) {
                 $this->loadAllFromPath($path . DIRECTORY_SEPARATOR . $folder, trailingslashit($url) . $folder, $groups);
                 continue;
             }
             $this->add($config_file, trailingslashit($url) . $folder, $groups);
         }
     } catch (\Exception $e) {
         print 'Caught exception: ' . $e->getMessage() . "\n<br>";
     }
 }
 /**
  * @param $section
  *
  * @return null|string
  */
 public function style($section)
 {
     /** FIXME: Currently we are not smartly handling non existent blocks exceptions **/
     if (!($block = $this->isValidSection($section))) {
         return $this->noBlockDefined($section['slug']);
     }
     $style_file = $this->locateStyleFile($block);
     //throw better exceptions
     if (!FileSystem::exists($style_file)) {
         //throw new \Exception( "Block style Does not exist" );
         return null;
     }
     $section['url'] = $block['url'];
     $style = $this->getStyleHTML($section, $style_file);
     return $style;
 }