Exemplo n.º 1
0
 /**
  * Returns the list of available classes in ./Tools
  * @return array
  */
 private static function _getClassList()
 {
     if (count(self::$classes) == 0) {
         include_once __DIR__ . '/Tools/Dir.php';
         foreach (Sydney_Tools_Dir::getDirList(__DIR__ . '/Tools/') as $s) {
             self::$classes[] = preg_replace('/.php$/', '', $s);
         }
     }
     return self::$classes;
 }
Exemplo n.º 2
0
 /**
  *
  */
 public function unziptofilesAction()
 {
     // get the zip
     $r = $this->getRequest();
     if (isset($r->id) && preg_match('/^[0-9]{1,30}$/', $r->id)) {
         $id = $r->id;
         $fdb = new Filfiles();
         $where = "id = " . $id . " AND safinstances_id = '" . $this->safinstancesId . "' AND type = 'ZIP' ";
         $files = $fdb->fetchAll($where);
         $categories = $fdb->getCategoriesLabels($id);
         $ftype = null;
         if (count($files) == 1) {
             $fdb = $files[0];
             $ftype = Sydney_Medias_Filetypesfactory::createfiletype($fdb->path . '/' . $fdb->filename, $fdb);
         }
         $fullpath = Sydney_Tools_Paths::getCachePath() . '/' . uniqid('unziptofiles_');
         $this->view->content = array();
         // create the temp dir
         mkdir($fullpath);
         mkdir($fullpath . '/chunks');
         // unzip the file
         if ($ftype->unzipToDir($fullpath . '/chunks')) {
             // move the files to DB
             $fi = new Filfiles();
             $res = $fi->moveAllChuncks($fullpath, $this->usersId, $this->safinstancesId, $chunks = 'chunks', $desc = 'from zipped file - ' . $fdb->filename, $returnType = 'both');
             $this->view->content = $res[1];
             // link unzipped files to a category if any
             if (is_array($res[0]) && count($res[0]) > 0 && is_array($categories) && count($categories) > 0) {
                 $linkDB = new FilfoldersFilfiles();
                 foreach ($res[0] as $fileId) {
                     foreach ($categories as $categoryId => $catlabel) {
                         $row = $linkDB->createRow();
                         $row->filfolders_id = $categoryId;
                         $row->filfiles_id = $fileId;
                         $row->save();
                     }
                 }
             }
             // remove temp dir
             Sydney_Tools_Dir::rrmdir($fullpath);
         }
     }
 }