Пример #1
0
 public function generate()
 {
     set_time_limit(600);
     $this->autoRender = false;
     App::uses('Path', 'Core.Vendor');
     Configure::write('Config.language', 'rus');
     $msgFile = '../Locale/' . Configure::read('Config.language') . '/LC_MESSAGES/default.';
     $this->msgFile = $msgFile . 'po';
     file_put_contents($msgFile . 'bak', file_get_contents($msgFile . 'po'), false);
     Path::process(Path::dirContent('../'), array($this, '_process'), true);
     echo $this->count . ' label(s) processed';
 }
Пример #2
0
Файл: Path.php Проект: Fyr/frtm
 public static function process($aPath, $callbackProcessFn, $recursive = false, $aParams = array())
 {
     if (isset($aPath['files'])) {
         foreach ($aPath['files'] as $fname) {
             call_user_func($callbackProcessFn, $fname, $aPath['path'], $aParams);
         }
     }
     if ($recursive && isset($aPath['folders'])) {
         foreach ($aPath['folders'] as $folder) {
             Path::process(Path::dirContent($aPath['path'] . $folder . '/'), $callbackProcessFn, true, $aParams);
         }
     }
 }
Пример #3
0
 /**
  * Removes actual media-files before delete a record
  *
  * @param bool $cascade
  * @return bool
  */
 public function beforeDelete($cascade = true)
 {
     App::uses('Path', 'Core.Vendor');
     $media = $this->findById($this->id);
     if ($media) {
         $path = $this->PHMedia->getPath($media[$this->alias]['object_type'], $this->id);
         if (file_exists($path)) {
             // remove all files in folder
             $aPath = Path::dirContent($path);
             if (isset($aPath['files']) && $aPath['files']) {
                 foreach ($aPath['files'] as $file) {
                     unlink($aPath['path'] . $file);
                 }
             }
             rmdir($path);
         }
     }
     return true;
 }
Пример #4
0
Файл: Media.php Проект: Fyr/frtm
 /**
  * Removes all temp cached images
  *
  * @param int $id
  */
 public function cleanCache($id)
 {
     App::uses('Path', 'Core.Vendor');
     $media = $this->findById($id);
     if (Hash::get($media, $this->alias . '.media_type') == 'image') {
         $path = $this->PHMedia->getPath($media[$this->alias]['object_type'], $id);
         if (file_exists($path)) {
             // remove all files in folder
             $aPath = Path::dirContent($path);
             if (isset($aPath['files']) && $aPath['files']) {
                 foreach ($aPath['files'] as $file) {
                     if ($file != $media[$this->alias]['file'] . $media[$this->alias]['ext'] && $file != 'thumb.png') {
                         unlink($aPath['path'] . $file);
                     }
                 }
             }
         }
     }
 }
Пример #5
0
 /**
  * Removes actual media-files before delete a record
  *
  * @param bool $cascade
  * @return bool
  */
 public function beforeDelete($cascade = true)
 {
     App::uses('Path', 'Core.Vendor');
     $media = $this->findById($this->id);
     if (!empty($media['Media']['orig_fsize'])) {
         $file_size = $media['Media']['orig_fsize'];
         if ($file_size > 0) {
             App::uses('CakeSession', 'Model/Datasource');
             $user_id = CakeSession::read('Auth.User.id');
             $this->updateStorageData($user_id, 'Cloud', $file_size, $operation = 'subtract');
         }
     }
     if ($media) {
         $path = $this->PHMedia->getPath($media[$this->alias]['object_type'], $this->id);
         if (file_exists($path)) {
             // remove all files in folder
             $aPath = Path::dirContent($path);
             if (isset($aPath['files']) && $aPath['files']) {
                 foreach ($aPath['files'] as $file) {
                     unlink($aPath['path'] . $file);
                 }
             }
             rmdir($path);
         }
     }
     return true;
 }