Ejemplo n.º 1
0
 protected function actionSaveHandler($params)
 {
     //		\GO::config()->save_setting('fh_'.$, $value)
     $fh = \GO\Files\Model\FileHandler::model()->findByPk(array('extension' => strtolower($params['extension']), 'user_id' => \GO::user()->id));
     if (!$fh) {
         $fh = new \GO\Files\Model\FileHandler();
     }
     $fh->extension = strtolower($params['extension']);
     $fh->cls = $params['cls'];
     return array('success' => empty($params['cls']) ? $fh->delete() : $fh->save());
 }
Ejemplo n.º 2
0
 /**
  *
  * @return \GO\Files\Filehandler\FilehandlerInterface
  */
 public function getDefaultHandler()
 {
     $ex = strtolower($this->extension);
     if (!isset(self::$defaultHandlers[$ex])) {
         $fh = FileHandler::model()->findByPk(array('extension' => $ex, 'user_id' => \GO::user()->id));
         if ($fh && class_exists($fh->cls)) {
             self::$defaultHandlers[$ex] = new $fh->cls();
         } else {
             $classes = \GO\Files\FilesModule::getAllFileHandlers();
             foreach ($classes as $class) {
                 /* @var $class ReflectionClass */
                 $fileHandler = new $class->name();
                 if ($fileHandler->isDefault($this)) {
                     self::$defaultHandlers[$ex] = $fileHandler;
                     break;
                 }
             }
             if (!isset(self::$defaultHandlers[$ex])) {
                 self::$defaultHandlers[$ex] = new \GO\Files\Filehandler\Download();
             }
         }
     }
     return self::$defaultHandlers[$ex];
 }