예제 #1
0
 /**
  * Get available themes for environment
  * @param $env_name
  * @return array
  */
 public function getAvailableThemes($env_name)
 {
     $path = root . '/Apps/View/' . $env_name . '/';
     if (!Directory::exist($path)) {
         return [];
     }
     $scan = Directory::scan($path);
     $response = [];
     foreach ($scan as $object) {
         $response[] = substr(strrchr($object, '/'), 1);
     }
     return $response;
 }
예제 #2
0
 /**
  * Find all bootatble instances and set it to object map
  */
 public function compileBootableClasses()
 {
     // list app root's
     foreach ($this->appRoots as $app) {
         $app .= '/Apps/Controller/' . env_name;
         $files = File::listFiles($app, ['.php'], true);
         foreach ($files as $file) {
             // define full class name with namespace
             $class = 'Apps\\Controller\\' . env_name . '\\' . Str::cleanExtension($file);
             // check if class exists (must be loaded over autoloader), boot method exist and this is controller instanceof
             if (class_exists($class) && method_exists($class, 'boot') && is_a($class, 'Ffcms\\Core\\Arch\\Controller', true)) {
                 $this->objects[] = $class;
             }
         }
     }
     // list widget root's
     foreach ($this->widgetRoots as $widget) {
         $widget .= '/Widgets/' . env_name;
         // widgets are packed in directory, classname should be the same with root directory name
         $dirs = Directory::scan($widget, GLOB_ONLYDIR, true);
         if (!Obj::isArray($dirs)) {
             continue;
         }
         foreach ($dirs as $instance) {
             $class = 'Widgets\\' . env_name . '\\' . $instance . '\\' . $instance;
             if (class_exists($class) && method_exists($class, 'boot') && is_a($class, 'Ffcms\\Core\\Arch\\Widget', true)) {
                 $this->objects[] = $class;
             }
         }
     }
 }
예제 #3
0
 /**
  * Get available languages in the filesystem
  * @return array
  */
 public function getAvailableLangs()
 {
     $langs = ['en'];
     $scan = Directory::scan(root . '/I18n/' . env_name . '/', GLOB_ONLYDIR, true);
     foreach ($scan as $row) {
         $langs[] = trim($row, '/');
     }
     return $langs;
 }
예제 #4
0
파일: Content.php 프로젝트: phpffcms/ffcms
 /**
  * Show gallery images from upload directory
  * @param int $id
  * @return string
  * @throws NotFoundException
  * @throws NativeException
  */
 public function actionGallerylist($id)
 {
     // check if id is passed
     if (Str::likeEmpty($id)) {
         throw new NativeException('Wrong input data');
     }
     // check if user have permission to access there
     if (!App::$User->isAuth() || !App::$User->identity()->getRole()->can('global/file')) {
         throw new NativeException('Permission denied');
     }
     $thumbDir = Normalize::diskFullPath('/upload/gallery/' . $id . '/orig/');
     if (!Directory::exist($thumbDir)) {
         throw new NotFoundException('Nothing found');
     }
     $files = Directory::scan($thumbDir, null, true);
     if ($files === false || !Obj::isArray($files) || count($files) < 1) {
         throw new NotFoundException('Nothing found');
     }
     $output = [];
     foreach ($files as $file) {
         $fileExt = Str::lastIn($file, '.');
         $fileName = Str::sub($file, 0, -Str::length($fileExt));
         $output[] = ['thumbnailUrl' => '/upload/gallery/' . $id . '/thumb/' . $fileName . '.jpg', 'url' => '/upload/gallery/' . $id . '/orig/' . $file, 'name' => $file, 'size' => File::size('/upload/gallery/' . $id . '/orig/' . $file)];
     }
     $this->setJsonHeader();
     return json_encode(['status' => 1, 'files' => $output]);
 }