示例#1
0
 /**
  * Gets a directory from the application directory
  *
  * @param string $dirName
  *
  * @return Directory
  */
 public static function system($dirName)
 {
     $path = App::system();
     $dir_parts = explode('.', $dirName);
     //foreach loop is possible here
     $path .= '/' . implode('/', $dir_parts);
     return new Directory($path);
 }
示例#2
0
 /**
  * Gets a file from the application directory
  *
  * @param string $fileName
  * @param integer $ext_count
  *
  * @return File
  */
 public static function system($fileName, $ext_count = 1)
 {
     $path = App::system();
     $file_parts = explode('.', $fileName);
     //for loop here since we need to exclude the last part of the array -> extension
     $file_parts_count = count($file_parts) - $ext_count;
     $path .= '/' . implode('/', array_slice($file_parts, 0, $file_parts_count));
     //add extension part
     if ($ext_count > 0) {
         $path .= '.' . implode('.', array_slice($file_parts, $file_parts_count));
     }
     return new File($path);
 }
示例#3
0
 /**
  * Creates a backup if needed or forced
  *
  * @param boolean $force
  */
 public static function create($force = false)
 {
     if (!self::needs() && !$force) {
         return false;
     }
     $bakdir = App::backups();
     $bak = new Archive($bakdir->file(time() . '-' . date('YmdHis') . '.zip'));
     //add system files
     $sysdir_len = strlen(App::system()->parent());
     $files = App::system()->files(true);
     foreach ($files as $file) {
         if ($file->parent() != $bakdir) {
             $bak->addFile($file, substr($file, $sysdir_len + 1));
         }
     }
     //add public
     $pubdir_len = strlen(App::public()->parent());
     $files = App::public()->files(true);
     foreach ($files as $file) {
         $bak->addFile($file, substr($file, $pubdir_len + 1));
     }
     $bak->save();
     self::clean();
 }