コード例 #1
0
ファイル: File.php プロジェクト: johnstyle/sjo
 /**
  * @param     $file
  * @param     $content
  * @param int $options
  *
  * @return int
  * @throws \sJo\Exception\Exception
  */
 public static function write($file, $content, $options = LOCK_EX)
 {
     if (!is_writable(Path::parent($file))) {
         throw new Exception(I18n::__('Unable to write to file %s', $file));
     }
     return file_put_contents($file, $content, $options);
 }
コード例 #2
0
ファイル: Style.php プロジェクト: johnstyle/sjo
 public static function create($registered)
 {
     $cssPath = SJO_ROOT_PUBLIC_HTML . '/css/' . strtolower(Router::$interface);
     if (is_dir($cssPath)) {
         if ($files = Path::listFiles($cssPath)) {
             foreach ($files as $file) {
                 array_push($registered['elements'], preg_replace("#^" . SJO_ROOT_PUBLIC_HTML . "/#", "", $file->path));
             }
         }
     }
     foreach ($registered['elements'] as &$el) {
         $el = self::createStatic('Element', Lib\Arr::extend(self::$element, array('tagname' => 'link', 'attributes' => array('href' => $el))));
     }
     return parent::create($registered);
 }
コード例 #3
0
ファイル: Ini.php プロジェクト: johnstyle/sjo
 /**
  * Chargement d'un dossier contenant des fichiers ini
  *
  * @param $paths
  * @param bool $regexp
  * @param string $method
  * @return $this
  */
 public function path($paths, $regexp = false, $method = '{name}')
 {
     $regexp = $regexp ? $regexp : "^(.+)\\.ini\$";
     foreach (Arr::to($paths) as $path) {
         $files = Path::listFiles($path, $regexp);
         if ($files) {
             foreach ($files as $file) {
                 $name = str_replace('-', '_', $file->match[1]);
                 $name = $file->parentname == $name ? $name : str_replace('{name}', $name, $method);
                 $this->parseIniFile($file->path, $name);
             }
         }
     }
     return $this;
 }
コード例 #4
0
ファイル: I18n.php プロジェクト: johnstyle/sjo
 public static function availableLanguages()
 {
     $languages = false;
     foreach (self::$directories as $directory) {
         $items = Path::listDirectories($directory);
         if ($items) {
             foreach ($items as $item) {
                 if (!isset($languages[$item->title])) {
                     $languages[$item->title] = (object) array('locale' => $item->title, 'country' => self::country($item->title), 'language' => self::language($item->title));
                 }
                 $languages[$item->title]->paths[] = $item->path;
             }
         }
     }
     return $languages;
 }