Esempio n. 1
0
 function __construct($folder8, $cache = true, $quiet = false)
 {
     $folder8 = trim($folder8, '/');
     $folderFS = internalToFilesystem($folder8);
     $localpath = ALBUM_FOLDER_SERVERPATH . $folderFS;
     $this->linkname = $this->name = $folder8;
     $this->localpath = rtrim($localpath, '/');
     if (!($this->exists = AlbumBase::albumCheck($folder8, $folderFS, $quiet, !file_exists($this->localpath) || is_dir($this->localpath)))) {
         return;
     }
     $data = explode("\n", file_get_contents($localpath));
     foreach ($data as $param) {
         $parts = explode('=', $param);
         switch (trim($parts[0])) {
             case 'USER':
                 $owner = trim($parts[1]);
                 break;
             case 'TITLE':
                 $this->instance = trim($parts[1]);
                 break;
             case 'THUMB':
                 $this->set('thumb', trim($parts[1]));
                 break;
         }
     }
     $new = $this->instantiate('albums', array('folder' => $this->name), 'folder', $cache);
     $title = $this->getTitle('all');
     $desc = $this->getDesc('all');
     parent::__construct($owner);
     $this->exists = true;
     if (!is_dir(stripSuffix($this->localpath))) {
         $this->linkname = stripSuffix($folder8);
     }
     $this->name = $folder8;
     $this->setTitle($title);
     $this->setDesc($desc);
     if ($new) {
         $title = $this->get('title');
         $this->set('title', stripSuffix($title));
         // Strip the suffix
         $this->setDateTime(strftime('%Y-%m-%d %H:%M:%S', $this->get('mtime')));
         $this->save();
         zp_apply_filter('new_album', $this);
     }
     zp_apply_filter('album_instantiate', $this);
 }
Esempio n. 2
0
 function __construct($folder8, $cache = true, $quiet = false)
 {
     $folder8 = trim($folder8, '/');
     $folderFS = internalToFilesystem($folder8);
     $localpath = ALBUM_FOLDER_SERVERPATH . $folderFS;
     $this->linkname = $this->name = $folder8;
     $this->localpath = rtrim($localpath, '/');
     if (!($this->exists = AlbumBase::albumCheck($folder8, $folderFS, $quiet, !file_exists($this->localpath) || is_dir($this->localpath)))) {
         return;
     }
     $new = $this->instantiate('albums', array('folder' => $this->name), 'folder', $cache, empty($folder8));
     $this->exists = true;
     if (!is_dir(stripSuffix($this->localpath))) {
         $this->linkname = stripSuffix($folder8);
     }
     if ($new || filemtime($this->localpath) > $this->get('mtime')) {
         $constraints = '';
         $data = file_get_contents($this->localpath);
         while (!empty($data)) {
             $data1 = trim(substr($data, 0, $i = strpos($data, "\n")));
             if ($i === false) {
                 $data1 = $data;
                 $data = '';
             } else {
                 $data = substr($data, $i + 1);
             }
             if (strpos($data1, 'WORDS=') !== false) {
                 $words = "words=" . urlencode(substr($data1, 6));
             }
             if (strpos($data1, 'THUMB=') !== false) {
                 $thumb = trim(substr($data1, 6));
                 $this->set('thumb', $thumb);
             }
             if (strpos($data1, 'FIELDS=') !== false) {
                 $fields = "&searchfields=" . trim(substr($data1, 7));
             }
             if (strpos($data1, 'CONSTRAINTS=') !== false) {
                 $constraint = trim(substr($data1, 12));
                 $constraints = '&' . $constraint;
             }
         }
         if (!empty($words)) {
             if (empty($fields)) {
                 $fields = '&searchfields=tags';
             }
             $this->set('search_params', $words . $fields . $constraints);
         }
         $this->set('mtime', filemtime($this->localpath));
         if ($new) {
             $title = $this->get('title');
             $this->set('title', stripSuffix($title));
             // Strip the suffix
             $this->setDateTime(strftime('%Y-%m-%d %H:%M:%S', $this->get('mtime')));
             $this->save();
             zp_apply_filter('new_album', $this);
         }
     }
     zp_apply_filter('album_instantiate', $this);
 }