1: <?php
2:
3: 4: 5: 6:
7:
8:
9: define('IMAGE_SORT_DIRECTION', getOption('image_sortdirection'));
10: define('IMAGE_SORT_TYPE', getOption('image_sorttype'));
11:
12: Gallery::addAlbumHandler('alb', 'dynamicAlbum');
13:
14: 15: 16: 17: 18: 19: 20:
21: function newAlbum($folder8, $cache = true, $quiet = false) {
22: global $_zp_albumHandlers;
23: $suffix = getSuffix($folder8);
24: if (!$suffix || !array_key_exists($suffix, $_zp_albumHandlers) || is_dir(ALBUM_FOLDER_SERVERPATH . internalToFilesystem($folder8))) {
25: return new Album($folder8, $cache, $quiet);
26: } else {
27: return new $_zp_albumHandlers[$suffix]($folder8, $cache, $quiet);
28: }
29: }
30:
31: 32: 33: 34: 35: 36:
37: function isAlbumClass($album = NULL) {
38: global $_zp_current_album;
39: if (is_null($album)) {
40: if (!in_context(ZP_ALBUM))
41: return false;
42: $album = $_zp_current_album;
43: }
44: return is_object($album) && ($album->table == 'albums');
45: }
46:
47: class AlbumBase extends MediaObject {
48:
49: var $name;
50: var $linkname;
51: var $localpath;
52: var $exists = true;
53: var $images = null;
54: var $parent = null;
55: var $parentalbum = null;
56: var $sidecars = array();
57: var $manage_rights = MANAGE_ALL_ALBUM_RIGHTS;
58: var $manage_some_rights = ALBUM_RIGHTS;
59: var $view_rights = ALL_ALBUMS_RIGHTS;
60: protected $subalbums = null;
61: protected $index;
62: protected $lastimagesort = NULL;
63: protected $lastsubalbumsort = NULL;
64: protected $albumthumbnail = NULL;
65: protected $subrights = NULL;
66:
67: function __construct($folder8, $cache = true) {
68: $this->linkname = $this->name = $folder8;
69: $this->instantiate('albums', array('folder' => $this->name), 'folder', false, true);
70: $this->exists = false;
71: }
72:
73: 74: 75: 76: 77:
78: protected function setDefaults() {
79: global $_zp_gallery;
80: if (TEST_RELEASE) {
81: $bt = debug_backtrace();
82: $good = false;
83: foreach ($bt as $b) {
84: if ($b['function'] == "newAlbum") {
85: $good = true;
86: break;
87: }
88: }
89: if (!$good) {
90: zp_error(gettext('An album object was instantiated without using the newAlbum() function.'), E_USER_WARNING);
91: }
92: }
93:
94: $parentalbum = NULL;
95: $this->setShow($_zp_gallery->getAlbumPublish());
96: $this->set('mtime', time());
97: $title = trim($this->name);
98: $this->set('title', sanitize($title, 2));
99: return true;
100: }
101:
102: 103: 104: 105: 106:
107: function getFileName() {
108: return $this->name;
109: }
110:
111: 112: 113: 114: 115:
116: function getFolder() {
117: return $this->name;
118: }
119:
120: 121: 122: 123: 124:
125: function getParent() {
126: if (is_null($this->parentalbum)) {
127: $slashpos = strrpos($this->name, "/");
128: if ($slashpos) {
129: $parent = substr($this->name, 0, $slashpos);
130: $parentalbum = newAlbum($parent, true, true);
131: if ($parentalbum->exists) {
132: return $parentalbum;
133: }
134: }
135: } else if ($this->parentalbum->exists) {
136: return $this->parentalbum;
137: }
138: return NULL;
139: }
140:
141: function getParentID() {
142: return $this->get('parentid');
143: }
144:
145: 146: 147: 148: 149:
150: function getLocation($locale = NULL) {
151: $text = $this->get('location');
152: if ($locale !== 'all') {
153: $text = get_language_string($text, $locale);
154: }
155: $text = zpFunctions::unTagURLs($text);
156: return $text;
157: }
158:
159: 160: 161: 162: 163:
164: function setLocation($place) {
165: $this->set('location', zpFunctions::tagURLs($place));
166: }
167:
168: 169: 170: 171: 172: 173: 174: 175:
176: function getSortDirection($what = 'image') {
177: global $_zp_gallery;
178: if ($what == 'image') {
179: $direction = $this->get('image_sortdirection');
180: $type = $this->get('sort_type');
181: } else {
182: $direction = $this->get('album_sortdirection');
183: $type = $this->get('subalbum_sort_type');
184: }
185: if (empty($type)) {
186:
187: $parentalbum = $this->getParent();
188: if (is_null($parentalbum)) {
189: if ($what == 'image') {
190: $direction = IMAGE_SORT_DIRECTION;
191: } else {
192: $direction = $_zp_gallery->getSortDirection();
193: }
194: } else {
195: $direction = $parentalbum->getSortDirection($what);
196: }
197: }
198: return $direction;
199: }
200:
201: 202: 203: 204: 205: 206:
207: function getSortType($what = 'image') {
208: global $_zp_gallery;
209: if ($what == 'image') {
210: $type = $this->get('sort_type');
211: } else {
212: $type = $this->get('subalbum_sort_type');
213: }
214: if (empty($type)) {
215: $parentalbum = $this->getParent();
216: if (is_null($parentalbum)) {
217: if ($what == 'image') {
218: $type = IMAGE_SORT_TYPE;
219: } else {
220: $type = $_zp_gallery->getSortType();
221: }
222: } else {
223: $type = $parentalbum->getSortType($what);
224: }
225: }
226: return $type;
227: }
228:
229: 230: 231: 232: 233: 234: 235:
236: function setSortDirection($val, $what = 'image') {
237: if (is_string($val)) {
238: internal_deprecations::setSortDirection();
239: $t = $val;
240: $val = $what;
241: $what = $t;
242: }
243: if ($what == 'image') {
244: $this->set('image_sortdirection', (int) ($val && true));
245: } else {
246: $this->set('album_sortdirection', (int) ($val && true));
247: }
248: }
249:
250: 251: 252: 253: 254: 255:
256: function setSortType($sorttype, $what = 'image') {
257: if ($what == 'image') {
258: $this->set('sort_type', $sorttype);
259: } else {
260: $this->set('subalbum_sort_type', $sorttype);
261: }
262: }
263:
264: 265: 266: 267: 268: 269: 270: 271:
272: function getAlbumSortType() {
273: internal_deprecations::getAlbumSortType();
274: return $this->getSortType('album');
275: }
276:
277: 278: 279: 280: 281: 282:
283: function setSubalbumSortType($sorttype) {
284: internal_deprecations::setAlbumSortType();
285: $this->setSortType($sorttype, 'album');
286: }
287:
288: 289: 290: 291: 292: 293:
294: function getImageSortKey($sorttype = null) {
295: if (is_null($sorttype)) {
296: $sorttype = $this->getSortType();
297: }
298: return lookupSortKey($sorttype, 'filename', 'images');
299: }
300:
301: 302: 303: 304: 305: 306:
307: function getAlbumSortKey($sorttype = null) {
308: if (empty($sorttype)) {
309: $sorttype = $this->getSortType('album');
310: }
311: return lookupSortKey($sorttype, 'sort_order', 'albums');
312: }
313:
314: 315: 316: 317: 318: 319: 320: 321: 322: 323:
324: function getAlbums($page = 0, $sorttype = null, $sortdirection = null, $care = true, $mine = NULL) {
325: if ($page == 0) {
326: return $this->subalbums;
327: } else {
328: $albums_per_page = max(1, getOption('albums_per_page'));
329: return array_slice($this->subalbums, $albums_per_page * ($page - 1), $albums_per_page);
330: }
331: }
332:
333: 334: 335: 336: 337:
338: function getNumAlbums() {
339: return count($this->getAlbums(0, NULL, NULL, false));
340: }
341:
342: 343: 344: 345: 346: 347: 348: 349: 350: 351: 352: 353: 354: 355:
356: function getImages($page = 0, $firstPageCount = 0, $sorttype = null, $sortdirection = null, $care = true, $mine = NULL) {
357:
358: if ($page == 0) {
359: return $this->images;
360: } else {
361:
362: if (($page == 1) && ($firstPageCount > 0)) {
363: $pageStart = 0;
364: $images_per_page = $firstPageCount;
365: } else {
366: if ($firstPageCount > 0) {
367: $fetchPage = $page - 2;
368: } else {
369: $fetchPage = $page - 1;
370: }
371: $images_per_page = max(1, getOption('images_per_page'));
372: $pageStart = (int) ($firstPageCount + $images_per_page * $fetchPage);
373: }
374: return array_slice($this->images, $pageStart, $images_per_page);
375: }
376: }
377:
378: 379: 380: 381: 382:
383: function getNumImages() {
384: if (is_null($this->images)) {
385: return count($this->getImages(0, 0, NULL, NULL, false));
386: }
387: return count($this->images);
388: }
389:
390: 391: 392: 393: 394: 395:
396: function getImage($index) {
397: $images = $this->getImages();
398: if ($index >= 0 && $index < count($images)) {
399: return newImage($this, $this->images[$index]);
400: }
401: return false;
402: }
403:
404: 405: 406: 407: 408: 409: 410:
411: function getAlbumThumbImage() {
412: global $_zp_albumthumb_selector, $_zp_gallery;
413:
414: if (!is_null($this->albumthumbnail)) {
415: return $this->albumthumbnail;
416: }
417:
418: $albumdir = $this->localpath;
419: $thumb = $this->get('thumb');
420: if (is_null($thumb)) {
421: $this->set('thumb', $thumb = getOption('AlbumThumbSelect'));
422: }
423: $i = strpos($thumb, '/');
424: if ($root = ($i === 0)) {
425: $thumb = substr($thumb, 1);
426: $albumdir = ALBUM_FOLDER_SERVERPATH;
427: }
428: if (!empty($thumb) && !is_numeric($thumb)) {
429: if (file_exists($albumdir . internalToFilesystem($thumb))) {
430: if ($i === false) {
431: return newImage($this, $thumb);
432: } else {
433: $pieces = explode('/', $thumb);
434: $i = count($pieces);
435: $thumb = $pieces[$i - 1];
436: unset($pieces[$i - 1]);
437: $albumdir = implode('/', $pieces);
438: if (!$root) {
439: $albumdir = $this->name . "/" . $albumdir;
440: } else {
441: $albumdir = $albumdir . "/";
442: }
443: $this->albumthumbnail = newImage(newAlbum($albumdir), $thumb);
444: return $this->albumthumbnail;
445: }
446: } else {
447: $this->set('thumb', $thumb = getOption('AlbumThumbSelect'));
448: }
449: }
450: if ($shuffle = empty($thumb)) {
451: $thumbs = $this->getImages(0, 0, NULL, NULL, false);
452: } else {
453: $thumbs = $this->getImages(0, 0, $_zp_albumthumb_selector[(int) $thumb]['field'], $_zp_albumthumb_selector[(int) $thumb]['direction']);
454: }
455: if (!is_null($thumbs)) {
456: if ($shuffle) {
457: shuffle($thumbs);
458: }
459: $mine = $this->isMyItem(LIST_RIGHTS);
460: $other = NULL;
461: while (count($thumbs) > 0) {
462:
463: $thumb = array_shift($thumbs);
464: $thumb = newImage($this, $thumb);
465: if ($mine || $thumb->getShow()) {
466: if (isImagePhoto($thumb)) {
467:
468: $this->albumthumbnail = $thumb;
469: return $this->albumthumbnail;
470: } else {
471: if (!is_null($thumb->objectsThumb)) {
472:
473: $this->albumthumbnail = $thumb;
474: return $this->albumthumbnail;
475: } else {
476: if (is_null($other)) {
477: $other = $thumb;
478: }
479: }
480: }
481: }
482: }
483: if (!is_null($other)) {
484:
485: $this->albumthumbnail = $other;
486: return $this->albumthumbnail;
487: }
488: }
489:
490:
491: $subalbums = $this->getAlbums();
492: if (!is_null($subalbums)) {
493: if ($shuffle) {
494: shuffle($subalbums);
495: }
496: while (count($subalbums) > 0) {
497: $folder = array_pop($subalbums);
498: $subalbum = newAlbum($folder);
499: $pwd = $subalbum->getPassword();
500: if (($subalbum->getShow() && empty($pwd)) || $subalbum->isMyItem(LIST_RIGHTS)) {
501: $thumb = $subalbum->getAlbumThumbImage();
502: if (strtolower(get_class($thumb)) !== 'transientimage' && $thumb->exists) {
503: $this->albumthumbnail = $thumb;
504: return $thumb;
505: }
506: }
507: }
508: }
509:
510: $nullimage = SERVERPATH . '/' . ZENFOLDER . '/images/imageDefault.png';
511:
512: $theme = '';
513: $uralbum = getUralbum($this);
514: $albumtheme = $uralbum->getAlbumTheme();
515: if (!empty($albumtheme)) {
516: $theme = $albumtheme;
517: } else {
518: $theme = $_zp_gallery->getCurrentTheme();
519: }
520: if (!empty($theme)) {
521: $themeimage = SERVERPATH . '/' . THEMEFOLDER . '/' . $theme . '/images/imageDefault.png';
522: if (file_exists(internalToFilesystem($themeimage))) {
523: $nullimage = $themeimage;
524: }
525: }
526:
527: $this->albumthumbnail = new transientimage($this, $nullimage);
528: return $this->albumthumbnail;
529: }
530:
531: 532: 533: 534:
535: function getThumb() {
536: $image = $this->getAlbumThumbImage();
537: return $image->getThumb('album');
538: }
539:
540: 541: 542: 543: 544:
545: function getAlbumThumb() {
546: internal_deprecations::getAlbumThumb();
547: return $this->getThumb();
548: }
549:
550: 551: 552: 553: 554:
555: function setThumb($filename) {
556: $this->set('thumb', $filename);
557: }
558:
559: 560: 561: 562: 563: 564:
565: function setAlbumThumb($filename) {
566: internal_deprecations::setAlbumThumb();
567: $this->setThumb($filename);
568: }
569:
570: 571: 572: 573: 574: 575: 576:
577: function getAlbumLink($page = NULL) {
578: internal_deprecations::getAlbumLink();
579: return $this->getLink();
580: }
581:
582: 583: 584: 585: 586: 587:
588: function getLink($page = NULL) {
589: global $_zp_current_album;
590: global $_zp_page;
591: if (is_null($page) && $_zp_current_album && $_zp_current_album->name == $this->name) {
592: $page = $_zp_page;
593: }
594: $rewrite = pathurlencode($this->linkname) . '/';
595: $plain = '/index.php?album=' . pathurlencode($this->name);
596: if ($page > 1) {
597: $rewrite .=_PAGE_ . '/' . $page . '/';
598: $plain .= "&page=$page";
599: }
600: return zp_apply_filter('getLink', rewrite_path($rewrite, $plain), $this, $page);
601: }
602:
603: 604: 605: 606: 607: 608:
609: function remove() {
610: $rslt = false;
611: if (PersistentObject::remove()) {
612: query("DELETE FROM " . prefix('options') . "WHERE `ownerid`=" . $this->id);
613: query("DELETE FROM " . prefix('comments') . "WHERE `type`='albums' AND `ownerid`=" . $this->id);
614: query("DELETE FROM " . prefix('obj_to_tag') . "WHERE `type`='albums' AND `objectid`=" . $this->id);
615: $rslt = true;
616: $filestoremove = safe_glob(substr($this->localpath, 0, -1) . '.*');
617: foreach ($filestoremove as $file) {
618: if (in_array(strtolower(getSuffix($file)), $this->sidecars)) {
619: @chmod($file, 0777);
620: unlink($file);
621: }
622: }
623: }
624: return $rslt;
625: }
626:
627: 628: 629: 630: 631:
632: protected function _move($newfolder) {
633:
634: $dest = ALBUM_FOLDER_SERVERPATH . internalToFilesystem($newfolder);
635:
636: if (file_exists($dest)) {
637:
638: if (!(CASE_INSENSITIVE && strtolower($dest) == strtolower(rtrim($this->localpath, '/')))) {
639: return 3;
640: }
641: }
642: $oldfolders = explode('/', $this->name);
643: $newfolders = explode('/', $newfolder);
644: $sub = count($newfolders) > count($oldfolders);
645: if ($sub) {
646: for ($i = 0; $i < count($oldfolders); $i++) {
647: if ($newfolders[$i] != $oldfolders[$i]) {
648: $sub = false;
649: break;
650: }
651: }
652: if ($sub) {
653:
654: return 4;
655: }
656: }
657: $filemask = substr($this->localpath, 0, -1) . '.*';
658: $perms = FOLDER_MOD;
659: @chmod($this->localpath, 0777);
660: $success = @rename(rtrim($this->localpath, '/'), $dest);
661: @chmod($dest, $perms);
662:
663: if ($success) {
664: $this->localpath = $dest . "/";
665: $filestomove = safe_glob($filemask);
666: foreach ($filestomove as $file) {
667: if (in_array(strtolower(getSuffix($file)), $this->sidecars)) {
668: $d = stripslashes($dest) . '.' . getSuffix($file);
669: @chmod($file, 0777);
670: $success = $success && @rename($file, $d);
671: @chmod($d, FILE_MOD);
672: }
673: }
674: clearstatcache();
675: $success = self::move($newfolder);
676: if ($success) {
677: $this->updateParent($newfolder);
678:
679: $cacherename = @rename(SERVERCACHE . '/' . $this->name, SERVERCACHE . '/' . $newfolder);
680: return 0;
681: }
682: }
683: return 1;
684: }
685:
686: 687: 688: 689: 690: 691: 692:
693: function move($newfolder) {
694: return parent::move(array('folder' => $newfolder));
695: }
696:
697: 698: 699: 700: 701:
702: function rename($newfolder) {
703: return $this->move($newfolder);
704: }
705:
706: protected function succeed($dest) {
707: return false;
708: }
709:
710: 711: 712: 713: 714: 715: 716:
717: function copy($newfolder) {
718:
719: if (substr($newfolder, -1, 1) != '/')
720: $newfolder .= '/';
721: $newfolder .= basename($this->localpath);
722:
723: $oldfolder = $this->name;
724: $dest = ALBUM_FOLDER_SERVERPATH . internalToFilesystem($newfolder);
725:
726: if (file_exists($dest)) {
727:
728: return 3;
729: }
730: if (substr($newfolder, count($oldfolder)) == $oldfolder) {
731:
732: return 4;
733: }
734: $success = $this->succeed($dest);
735: $filemask = substr($this->localpath, 0, -1) . '.*';
736: if ($success) {
737:
738: $uniqueset = array('folder' => $newfolder);
739: $parentname = dirname($newfolder);
740: if (empty($parentname) || $parentname == '/' || $parentname == '.') {
741: $uniqueset['parentid'] = NULL;
742: } else {
743: $parent = newAlbum($parentname);
744: $uniqueset['parentid'] = $parent->getID();
745: }
746: $newID = parent::copy($uniqueset);
747: if ($newID) {
748:
749: storeTags(readTags($this->getID(), 'albums'), $newID, 'albums');
750:
751: $filestocopy = safe_glob($filemask);
752: foreach ($filestocopy as $file) {
753: if (in_array(strtolower(getSuffix($file)), $this->sidecars)) {
754: $success = $success && @copy($file, dirname($dest) . '/' . basename($file));
755: }
756: }
757: }
758: }
759: if ($success) {
760: return 0;
761: } else {
762: return 1;
763: }
764: }
765:
766: 767: 768: 769: 770: 771:
772: function garbageCollect($deep = false) {
773:
774: }
775:
776: 777: 778: 779: 780: 781: 782:
783: protected function loadFileNames($dirs = false) {
784:
785: }
786:
787: 788: 789: 790: 791:
792: function isDynamic() {
793: return false;
794: }
795:
796: 797: 798: 799: 800:
801: function getSearchParams() {
802: return NULL;
803: }
804:
805: 806: 807: 808: 809:
810: function setSearchParams($params) {
811:
812: }
813:
814: 815: 816: 817: 818:
819: function getSearchEngine() {
820: return NULL;
821: }
822:
823: 824: 825: 826: 827: 828:
829: function isMyItem($action) {
830: global $_zp_loggedin;
831: if ($parent = parent::isMyItem($action)) {
832: return $parent;
833: }
834: if (zp_loggedin($action)) {
835: $subRights = $this->albumSubRights();
836: if (is_null($subRights)) {
837:
838: if (GALLERY_SECURITY != 'public' && $this->getShow() && $action == LIST_RIGHTS) {
839: return LIST_RIGHTS;
840: }
841: } else {
842: $albumrights = LIST_RIGHTS;
843: if ($subRights & (MANAGED_OBJECT_RIGHTS_EDIT)) {
844: $albumrights = $albumrights | ALBUM_RIGHTS;
845: }
846: if ($subRights & MANAGED_OBJECT_RIGHTS_UPLOAD) {
847: $albumrights = $albumrights | UPLOAD_RIGHTS;
848: }
849: if ($action & $albumrights) {
850: return ($_zp_loggedin ^ (ALBUM_RIGHTS | UPLOAD_RIGHTS)) | $albumrights;
851: } else {
852: return false;
853: }
854: }
855: }
856: return false;
857: }
858:
859: 860: 861: 862: 863:
864: function checkforGuest(&$hint = NULL, &$show = NULL) {
865: if (!parent::checkForGuest()) {
866: return false;
867: }
868: return checkAlbumPassword($this, $hint);
869: }
870:
871: 872: 873: 874:
875: function isProtected() {
876: return $this->checkforGuest() != 'zp_public_access';
877: }
878:
879: 880: 881:
882: function getOwner() {
883: global $_zp_authority;
884: $owner = $this->get('owner');
885: if (empty($owner)) {
886: $p = $this->getParent();
887: if (is_object($p)) {
888: $owner = $p->getOwner();
889: } else {
890: $admin = $_zp_authority->getMasterUser();
891: $owner = $admin->getUser();
892: }
893: }
894: return $owner;
895: }
896:
897: function setOwner($owner) {
898: $this->set('owner', $owner);
899: }
900:
901: 902: 903: 904:
905: function getUpdatedDate() {
906: return $this->get('updateddate');
907: }
908:
909: function setUpdatedDate($date) {
910: return $this->set('updateddate', $date);
911: }
912:
913: 914: 915: 916: 917:
918: function getAlbumTheme() {
919: global $_zp_gallery;
920: if (in_context(ZP_SEARCH_LINKED)) {
921: return $_zp_gallery->getCurrentTheme();
922: } else {
923: return $this->get('album_theme');
924: }
925: }
926:
927: 928: 929: 930: 931:
932: function setAlbumTheme($theme) {
933: $this->set('album_theme', $theme);
934: }
935:
936: 937: 938: 939:
940: function getWatermark() {
941: return $this->get('watermark');
942: }
943:
944: 945: 946: 947:
948: function setWatermark($wm) {
949: $this->set('watermark', $wm);
950: }
951:
952: 953: 954: 955: 956:
957: function getWatermarkThumb() {
958: return $this->get('watermark_thumb');
959: }
960:
961: 962: 963: 964: 965:
966: function setWatermarkThumb($wm) {
967: $this->set('watermark_thumb', $wm);
968: }
969:
970: 971: 972: 973:
974: function albumSubRights() {
975: if (!is_null($this->subrights)) {
976: return $this->subrights;
977: }
978: global $_zp_admin_album_list;
979: if (zp_loggedin(MANAGE_ALL_ALBUM_RIGHTS)) {
980: $this->subrights = MANAGED_OBJECT_RIGHTS_EDIT | MANAGED_OBJECT_RIGHTS_UPLOAD | MANAGED_OBJECT_RIGHTS_VIEW;
981: return $this->subrights;
982: }
983: if (zp_loggedin(VIEW_UNPUBLISHED_RIGHTS)) {
984: $base = MANAGED_OBJECT_RIGHTS_VIEW;
985: } else {
986: $base = NULL;
987: }
988: getManagedAlbumList();
989: if (count($_zp_admin_album_list) > 0) {
990: $desired_folders = explode('/', $this->name);
991: foreach ($_zp_admin_album_list as $adminalbum => $rights) {
992:
993: $admin_folders = explode('/', $adminalbum);
994: $level = 0;
995: $ok = true;
996: foreach ($admin_folders as $folder) {
997: if ($level >= count($desired_folders) || $folder != $desired_folders[$level]) {
998: $ok = false;
999: break;
1000: }
1001: $level++;
1002: }
1003: if ($ok) {
1004: $this->subrights = $rights | $base;
1005: return $this->subrights;
1006: }
1007: }
1008: }
1009: $this->subrights = $base;
1010: return $this->subrights;
1011: }
1012:
1013: 1014: 1015: 1016: 1017: 1018: 1019: 1020: 1021: 1022:
1023: protected function sortImageArray($images, $sorttype, $sortdirection, $mine = NULL) {
1024: if (is_null($mine)) {
1025: $mine = $this->isMyItem(LIST_RIGHTS | MANAGE_ALL_ALBUM_RIGHTS);
1026: }
1027: if ($mine && !($mine & (MANAGE_ALL_ALBUM_RIGHTS))) {
1028:
1029: $mine = $this->albumSubRights() & (MANAGED_OBJECT_RIGHTS_EDIT | MANAGED_OBJECT_RIGHTS_VIEW);
1030: }
1031: $sortkey = $this->getImageSortKey($sorttype);
1032: if (($sortkey == '`sort_order`') || ($sortkey == 'RAND()')) {
1033:
1034: $order = false;
1035: } else {
1036: if (!is_null($sortdirection)) {
1037: $order = strtoupper($sortdirection) == 'DESC';
1038: } else {
1039: $order = $this->getSortDirection('image');
1040: }
1041: }
1042: $result = query($sql = "SELECT * FROM " . prefix("images") . " WHERE `albumid`= " . $this->getID() . ' ORDER BY ' . $sortkey . ' ' . $sortdirection);
1043: $results = array();
1044: while ($row = db_fetch_assoc($result)) {
1045: $filename = $row['filename'];
1046: if (($key = array_search($filename, $images)) !== false) {
1047:
1048: $results[] = $row;
1049: unset($images[$key]);
1050: } else {
1051: $id = $row['id'];
1052: query("DELETE FROM " . prefix('images') . " WHERE `id`=$id");
1053: query("DELETE FROM " . prefix('comments') . " WHERE `type` ='images' AND `ownerid`= '$id'");
1054: }
1055: }
1056: db_free_result($result);
1057: foreach ($images as $filename) {
1058:
1059: $imageobj = newImage($this, $filename);
1060: $results[] = $imageobj->getData();
1061: }
1062:
1063: $results = sortByKey($results, str_replace('`', '', $sortkey), $order);
1064:
1065: $images_ordered = array();
1066: foreach ($results as $key => $row) {
1067:
1068: switch (checkPublishDates($row)) {
1069: case 1:
1070: $imageobj = newImage($this, $row['filename']);
1071: $imageobj->setShow(0);
1072: $imageobj->save();
1073: case 2:
1074: $row['show'] = 0;
1075: break;
1076: }
1077: if ($row['show'] || $mine) {
1078:
1079: $images_ordered[] = $row['filename'];
1080: }
1081: }
1082: return $images_ordered;
1083: }
1084:
1085: 1086: 1087: 1088: 1089:
1090: protected function updateParent($newfolder) {
1091: $this->name = $newfolder;
1092: $parentname = dirname($newfolder);
1093: if ($parentname == '/' || $parentname == '.')
1094: $parentname = '';
1095: if (empty($parentname)) {
1096: $this->set('parentid', NULL);
1097: } else {
1098: $parent = newAlbum($parentname);
1099: $this->set('parentid', $parent->getID());
1100: }
1101: $this->save();
1102: }
1103:
1104: 1105: 1106: 1107:
1108: function preLoad() {
1109: $images = $this->getImages(0);
1110: $subalbums = $this->getAlbums(0);
1111: foreach ($subalbums as $dir) {
1112: $album = newAlbum($dir);
1113: $album->preLoad();
1114: }
1115: }
1116:
1117: 1118: 1119: 1120: 1121:
1122: function getNextAlbum() {
1123: global $_zp_gallery;
1124: if (is_null($parent = $this->getParent())) {
1125: $albums = $_zp_gallery->getAlbums(0);
1126: } else {
1127: $albums = $parent->getAlbums(0);
1128: }
1129: $inx = array_search($this->name, $albums) + 1;
1130: if ($inx >= 0 && $inx < count($albums)) {
1131: return newAlbum($albums[$inx]);
1132: }
1133: return null;
1134: }
1135:
1136: 1137: 1138: 1139: 1140:
1141: function getPrevAlbum() {
1142: global $_zp_gallery;
1143: if (is_null($parent = $this->getParent())) {
1144: $albums = $_zp_gallery->getAlbums(0);
1145: } else {
1146: $albums = $parent->getAlbums(0);
1147: }
1148: $inx = array_search($this->name, $albums) - 1;
1149: if ($inx >= 0 && $inx < count($albums)) {
1150: return newAlbum($albums[$inx]);
1151: }
1152: return null;
1153: }
1154:
1155: 1156: 1157: 1158: 1159:
1160: function getGalleryPage() {
1161: global $_zp_gallery;
1162: if ($this->index == null) {
1163: if (is_null($parent = $this->getParent())) {
1164: $albums = $_zp_gallery->getAlbums(0);
1165: } else {
1166: $albums = $parent->getAlbums(0);
1167: }
1168: $this->index = array_search($this->name, $albums);
1169: }
1170: return floor(($this->index / galleryAlbumsPerPage()) + 1);
1171: }
1172:
1173: }
1174:
1175: class Album extends AlbumBase {
1176:
1177: 1178: 1179: 1180: 1181: 1182: 1183: 1184:
1185: function __construct($folder8, $cache = true, $quiet = false) {
1186:
1187: $folder8 = trim($folder8, '/');
1188: $folderFS = internalToFilesystem($folder8);
1189: $localpath = ALBUM_FOLDER_SERVERPATH . $folderFS . "/";
1190: $this->linkname = $this->name = $folder8;
1191: $this->localpath = $localpath;
1192: if (!$this->_albumCheck($folder8, $folderFS, $quiet))
1193: return;
1194:
1195: $new = $this->instantiate('albums', array('folder' => $this->name), 'folder', $cache, empty($folder8));
1196:
1197: if ($new) {
1198: $this->save();
1199: zp_apply_filter('new_album', $this);
1200: }
1201: zp_apply_filter('album_instantiate', $this);
1202: }
1203:
1204: 1205: 1206: 1207:
1208: protected function _albumCheck($folder8, $folderFS, $quiet) {
1209: $msg = false;
1210: if (empty($folder8)) {
1211: $msg = gettext('Invalid album instantiation: No album name');
1212: } else if (filesystemToInternal($folderFS) != $folder8) {
1213:
1214: $msg = sprintf(gettext('Invalid album instantiation: %1$s!=%2$s'), html_encode(filesystemToInternal($folderFS)), html_encode($folder8));
1215: } else if (!file_exists($this->localpath) || !(is_dir($this->localpath)) || $folder8{0} == '.' || preg_match('~/\.*/~', $folder8)) {
1216: $msg = sprintf(gettext('Invalid album instantiation: %s does not exist.'), html_encode($folder8));
1217: }
1218: if ($msg) {
1219: $this->exists = false;
1220: if (!$quiet) {
1221: trigger_error($msg, E_USER_ERROR);
1222: }
1223: return false;
1224: }
1225: return true;
1226: }
1227:
1228: 1229: 1230: 1231: 1232:
1233: protected function setDefaults() {
1234: global $_zp_gallery;
1235:
1236: parent::setDefaults();
1237: $parentalbum = $this->getParent();
1238: $this->set('mtime', filemtime($this->localpath));
1239: if (!$_zp_gallery->getAlbumUseImagedate()) {
1240: $this->setDateTime(strftime('%Y-%m-%d %H:%M:%S', $this->get('mtime')));
1241: }
1242: $title = trim($this->name);
1243: if (!is_null($parentalbum)) {
1244: $this->set('parentid', $parentalbum->getID());
1245: $title = substr($title, strrpos($title, '/') + 1);
1246: }
1247: $this->set('title', sanitize($title, 2));
1248: return true;
1249: }
1250:
1251: 1252: 1253: 1254:
1255: protected function _getAlbums() {
1256: $dirs = $this->loadFileNames(true);
1257: $subalbums = array();
1258: foreach ($dirs as $dir) {
1259: $dir = $this->name . '/' . $dir;
1260: $subalbums[] = $dir;
1261: }
1262: return $subalbums;
1263: }
1264:
1265: 1266: 1267: 1268: 1269: 1270: 1271: 1272: 1273: 1274:
1275: function getAlbums($page = 0, $sorttype = null, $sortdirection = null, $care = true, $mine = NULL) {
1276: global $_zp_gallery;
1277: if (!$this->exists)
1278: return array();
1279: if ($mine || is_null($this->subalbums) || $care && $sorttype . $sortdirection !== $this->lastsubalbumsort) {
1280: if (is_null($sorttype)) {
1281: $sorttype = $this->getSortType('album');
1282: }
1283: if (is_null($sortdirection)) {
1284: if ($this->getSortDirection('album')) {
1285: $sortdirection = 'DESC';
1286: } else {
1287: $sortdirection = '';
1288: }
1289: }
1290: $dirs = $this->loadFileNames(true);
1291: $subalbums = array();
1292: foreach ($dirs as $dir) {
1293: $dir = $this->name . '/' . $dir;
1294: $subalbums[] = $dir;
1295: }
1296: $key = $this->getAlbumSortKey($sorttype);
1297: $this->subalbums = $_zp_gallery->sortAlbumArray($this, $subalbums, $key, $sortdirection, $mine);
1298: $this->lastsubalbumsort = $sorttype . $sortdirection;
1299: }
1300: return parent::getAlbums($page);
1301: }
1302:
1303: 1304: 1305: 1306: 1307: 1308: 1309: 1310: 1311: 1312: 1313: 1314: 1315: 1316:
1317: function getImages($page = 0, $firstPageCount = 0, $sorttype = null, $sortdirection = null, $care = true, $mine = NULL) {
1318: if (!$this->exists)
1319: return array();
1320: if ($mine || is_null($this->images) || $care && $sorttype . $sortdirection !== $this->lastimagesort) {
1321: if (is_null($sorttype)) {
1322: $sorttype = $this->getSortType();
1323: }
1324: if (is_null($sortdirection)) {
1325: if ($this->getSortDirection('image')) {
1326: $sortdirection = 'DESC';
1327: }
1328: }
1329: $images = $this->loadFileNames();
1330: $this->images = $this->sortImageArray($images, $sorttype, $sortdirection, $mine);
1331: $this->lastimagesort = $sorttype . $sortdirection;
1332: }
1333: return parent::getImages($page, $firstPageCount);
1334: }
1335:
1336: 1337: 1338: 1339: 1340: 1341:
1342: function remove() {
1343: $rslt = false;
1344: if (PersistentObject::remove()) {
1345: foreach ($this->getImages() as $filename) {
1346: $image = newImage($this, $filename);
1347: $image->remove();
1348: }
1349: foreach ($this->getAlbums() as $folder) {
1350: $subalbum = newAlbum($folder);
1351: $subalbum->remove();
1352: }
1353: $curdir = getcwd();
1354: chdir($this->localpath);
1355: $filelist = safe_glob('*');
1356: foreach ($filelist as $file) {
1357: if (($file != '.') && ($file != '..')) {
1358: @chmod($file, 0777);
1359: unlink($this->localpath . $file);
1360: }
1361: }
1362: chdir($curdir);
1363: clearstatcache();
1364: query("DELETE FROM " . prefix('options') . "WHERE `ownerid`=" . $this->id);
1365: query("DELETE FROM " . prefix('comments') . "WHERE `type`='albums' AND `ownerid`=" . $this->id);
1366: query("DELETE FROM " . prefix('obj_to_tag') . "WHERE `type`='albums' AND `objectid`=" . $this->id);
1367: $success = true;
1368: $filestoremove = safe_glob(substr($this->localpath, 0, strrpos($this->localpath, '.')) . '.*');
1369: foreach ($filestoremove as $file) {
1370: if (in_array(strtolower(getSuffix($file)), $this->sidecars)) {
1371: @chmod($file, 0777);
1372: $success = $success && unlink($file);
1373: }
1374: }
1375: @chmod($this->localpath, 0777);
1376: $rslt = @rmdir($this->localpath) && $success;
1377: $cachepath = SERVERCACHE.'/'.pathurlencode($this->name).'/';
1378: @chmod($cachepath, 0777);
1379: @rmdir($cachepath);
1380: }
1381: clearstatcache();
1382: return $rslt;
1383: }
1384:
1385: 1386: 1387: 1388: 1389: 1390: 1391:
1392: function move($newfolder) {
1393: $oldfolder = $this->name;
1394: $rslt = $this->_move($newfolder);
1395: if (!$rslt) {
1396:
1397:
1398: $sql = "SELECT id, folder FROM " . prefix('albums') . " WHERE folder LIKE " . db_quote(db_LIKE_escape($oldfolder) . '/%');
1399: $result = query($sql);
1400: if ($result) {
1401: while ($subrow = db_fetch_assoc($result)) {
1402: $newsubfolder = $subrow['folder'];
1403: $newsubfolder = $newfolder . substr($newsubfolder, strlen($oldfolder));
1404: $sql = "UPDATE " . prefix('albums') . " SET folder=" . db_quote($newsubfolder) . " WHERE id=" . $subrow['id'];
1405: query($sql);
1406: }
1407: }
1408: db_free_result($result);
1409: return 0;
1410: }
1411: return $rslt;
1412: }
1413:
1414: protected function succeed($dest) {
1415: return mkdir_recursive($dest, FOLDER_MOD) === TRUE;
1416: }
1417:
1418: 1419: 1420: 1421: 1422: 1423: 1424:
1425: function copy($newfolder) {
1426: $rslt = parent::copy($newfolder);
1427: if (!$rslt) {
1428: $newfolder .= '/' . basename($this->name);
1429: $success = true;
1430:
1431: $images = $this->getImages(0);
1432: foreach ($images as $imagename) {
1433: $image = newImage($this, $imagename);
1434: if ($rslt = $image->copy($newfolder)) {
1435: $success = false;
1436: }
1437: }
1438:
1439: $subalbums = $this->getAlbums(0);
1440: foreach ($subalbums as $subalbumname) {
1441: $subalbum = newAlbum($subalbumname);
1442: if ($rslt = $subalbum->copy($newfolder)) {
1443: $success = false;
1444: }
1445: }
1446: if ($success) {
1447: return 0;
1448: }
1449: return 1;
1450: }
1451: return $rslt;
1452: }
1453:
1454: 1455: 1456: 1457: 1458: 1459:
1460: function garbageCollect($deep = false) {
1461: if (is_null($this->images))
1462: $this->getImages();
1463: $result = query("SELECT * FROM " . prefix('images') . " WHERE `albumid` = '" . $this->id . "'");
1464: $dead = array();
1465: $live = array();
1466:
1467: $files = $this->loadFileNames();
1468:
1469:
1470: while ($row = db_fetch_assoc($result)) {
1471: if (!in_array($row['filename'], $files)) {
1472:
1473: $dead[] = $row['id'];
1474: } else if (in_array($row['filename'], $live)) {
1475:
1476: $dead[] = $row['id'];
1477:
1478: } else {
1479: $live[] = $row['filename'];
1480: }
1481: }
1482: db_free_result($result);
1483:
1484: if (count($dead) > 0) {
1485: $sql = "DELETE FROM " . prefix('images') . " WHERE `id` = '" . array_pop($dead) . "'";
1486: $sql2 = "DELETE FROM " . prefix('comments') . " WHERE `type`='albums' AND `ownerid` = '" . array_pop($dead) . "'";
1487: foreach ($dead as $id) {
1488: $sql .= " OR `id` = '$id'";
1489: $sql2 .= " OR `ownerid` = '$id'";
1490: }
1491: query($sql);
1492: query($sql2);
1493: }
1494:
1495:
1496: $result = query("SELECT * FROM " . prefix('albums') . " WHERE `folder` LIKE " . db_quote(db_LIKE_escape($this->name) . '%'));
1497: $dead = array();
1498: $live = array();
1499:
1500: while ($row = db_fetch_assoc($result)) {
1501: if (!is_dir(ALBUM_FOLDER_SERVERPATH . internalToFilesystem($row['folder'])) || in_array($row['folder'], $live) || substr($row['folder'], -1) == '/' || substr($row['folder'], 0, 1) == '/') {
1502: $dead[] = $row['id'];
1503: } else {
1504: $live[] = $row['folder'];
1505: }
1506: }
1507: db_free_result($result);
1508: if (count($dead) > 0) {
1509: $sql = "DELETE FROM " . prefix('albums') . " WHERE `id` = '" . array_pop($dead) . "'";
1510: $sql2 = "DELETE FROM " . prefix('comments') . " WHERE `type`='albums' AND `ownerid` = '" . array_pop($dead) . "'";
1511: foreach ($dead as $albumid) {
1512: $sql .= " OR `id` = '$albumid'";
1513: $sql2 .= " OR `ownerid` = '$albumid'";
1514: }
1515: query($sql);
1516: query($sql2);
1517: }
1518:
1519: if ($deep) {
1520: foreach ($this->getAlbums(0) as $dir) {
1521: $subalbum = newAlbum($dir);
1522:
1523: if ($subalbum->exists)
1524: $subalbum->garbageCollect($deep);
1525: }
1526: }
1527: }
1528:
1529: 1530: 1531: 1532: 1533: 1534: 1535:
1536: protected function loadFileNames($dirs = false) {
1537: clearstatcache();
1538: $albumdir = $this->localpath;
1539: $dir = @opendir($albumdir);
1540: if (!$dir) {
1541: if (is_dir($albumdir)) {
1542: $msg = sprintf(gettext("Error: The album %s is not readable."), html_encode($this->name));
1543: } else {
1544: $msg = sprintf(gettext("Error: The album named %s cannot be found."), html_encode($this->name));
1545: }
1546: trigger_error($msg, E_USER_NOTICE);
1547: return array();
1548: }
1549:
1550: $files = array();
1551: $others = array();
1552:
1553: while (false !== ($file = readdir($dir))) {
1554: $file8 = filesystemToInternal($file);
1555: if (@$file8{0} != '.') {
1556: if ($dirs && (is_dir($albumdir . $file) || hasDynamicAlbumSuffix($file))) {
1557: $files[] = $file8;
1558: } else if (!$dirs && is_file($albumdir . $file)) {
1559: if (Gallery::validImageAlt($file)) {
1560: $files[] = $file8;
1561: $others[] = $file8;
1562: } else if (Gallery::validImage($file)) {
1563: $files[] = $file8;
1564: }
1565: }
1566: }
1567: }
1568: closedir($dir);
1569: if (count($others) > 0) {
1570: $others_thumbs = array();
1571: foreach ($others as $other) {
1572: $others_root = substr($other, 0, strrpos($other, "."));
1573: foreach ($files as $image) {
1574: if ($image != $other) {
1575: $image_root = substr($image, 0, strrpos($image, "."));
1576: if ($image_root == $others_root && Gallery::validImage($image)) {
1577: $others_thumbs[] = $image;
1578: }
1579: }
1580: }
1581: }
1582: $files = array_diff($files, $others_thumbs);
1583: }
1584:
1585: if ($dirs) {
1586: return zp_apply_filter('album_filter', $files);
1587: } else {
1588: return zp_apply_filter('image_filter', $files);
1589: }
1590: }
1591:
1592: }
1593:
1594: class dynamicAlbum extends AlbumBase {
1595:
1596: var $searchengine;
1597:
1598: function __construct($folder8, $cache = true, $quiet = false) {
1599: $folder8 = trim($folder8, '/');
1600: $folderFS = internalToFilesystem($folder8);
1601: $localpath = ALBUM_FOLDER_SERVERPATH . $folderFS . "/";
1602: $this->linkname = $this->name = $folder8;
1603: $this->localpath = $localpath;
1604: if (!$this->_albumCheck($folder8, $folderFS, $quiet))
1605: return;
1606: $this->instantiate('albums', array('folder' => $this->name), 'folder', $cache, empty($folder8));
1607: $this->exists = true;
1608: if (!is_dir(stripSuffix($this->localpath))) {
1609: $this->linkname = stripSuffix($folder8);
1610: }
1611: $new = !$this->get('search_params');
1612: if ($new || (filemtime($this->localpath) > $this->get('mtime'))) {
1613: $constraints = '';
1614: $data = file_get_contents($this->localpath);
1615: while (!empty($data)) {
1616: $data1 = trim(substr($data, 0, $i = strpos($data, "\n")));
1617: if ($i === false) {
1618: $data1 = $data;
1619: $data = '';
1620: } else {
1621: $data = substr($data, $i + 1);
1622: }
1623: if (strpos($data1, 'WORDS=') !== false) {
1624: $words = "words=" . urlencode(substr($data1, 6));
1625: }
1626: if (strpos($data1, 'THUMB=') !== false) {
1627: $thumb = trim(substr($data1, 6));
1628: $this->set('thumb', $thumb);
1629: }
1630: if (strpos($data1, 'FIELDS=') !== false) {
1631: $fields = "&searchfields=" . trim(substr($data1, 7));
1632: }
1633: if (strpos($data1, 'CONSTRAINTS=') !== false) {
1634: $constraint = trim(substr($data1, 12));
1635: $constraints = '&' . $constraint;
1636: }
1637: }
1638: if (!empty($words)) {
1639: if (empty($fields)) {
1640: $fields = '&searchfields=tags';
1641: }
1642: $this->set('search_params', $words . $fields . $constraints);
1643: }
1644: $this->set('mtime', filemtime($this->localpath));
1645: if ($new) {
1646: $title = $this->get('title');
1647: $this->set('title', stripSuffix($title));
1648: $this->save();
1649: zp_apply_filter('new_album', $this);
1650: }
1651: }
1652: zp_apply_filter('album_instantiate', $this);
1653: }
1654:
1655: 1656: 1657: 1658: 1659:
1660: protected function _albumCheck($folder8, $folderFS, $quiet) {
1661: $this->localpath = rtrim($this->localpath, '/');
1662:
1663: $msg = false;
1664: if (empty($folder8)) {
1665: $msg = gettext('Invalid album instantiation: No album name');
1666: } else if (filesystemToInternal($folderFS) != $folder8) {
1667:
1668: $msg = sprintf(gettext('Invalid album instantiation: %1$s!=%2$s'), html_encode(filesystemToInternal($folderFS)), html_encode($folder8));
1669: } else if (!file_exists($this->localpath) || is_dir($this->localpath)) {
1670: $msg = sprintf(gettext('Invalid album instantiation: %s does not exist.'), html_encode($folder8));
1671: }
1672: if ($msg) {
1673: $this->exists = false;
1674: if (!$quiet) {
1675: trigger_error($msg, E_USER_ERROR);
1676: }
1677: return false;
1678: }
1679: return true;
1680: }
1681:
1682: 1683: 1684: 1685: 1686: 1687: 1688: 1689: 1690: 1691:
1692: function getAlbums($page = 0, $sorttype = null, $sortdirection = null, $care = true, $mine = NULL) {
1693: global $_zp_gallery;
1694: if (!$this->exists)
1695: return array();
1696: if ($mine || is_null($this->subalbums) || $care && $sorttype . $sortdirection !== $this->lastsubalbumsort) {
1697: if (is_null($sorttype)) {
1698: $sorttype = $this->getSortType('album');
1699: }
1700: if (is_null($sortdirection)) {
1701: if ($this->getSortDirection('album')) {
1702: $sortdirection = 'DESC';
1703: } else {
1704: $sortdirection = '';
1705: }
1706: }
1707: $searchengine = $this->getSearchEngine();
1708: $subalbums = $searchengine->getAlbums(0, $sorttype, $sortdirection, $care, $mine);
1709: $key = $this->getAlbumSortKey($sorttype);
1710: $this->subalbums = $_zp_gallery->sortAlbumArray($this, $subalbums, $key, $sortdirection, $mine);
1711: $this->lastsubalbumsort = $sorttype . $sortdirection;
1712: }
1713: return parent::getAlbums($page);
1714: }
1715:
1716: 1717: 1718: 1719: 1720:
1721: function getSearchParams() {
1722: return $this->get('search_params');
1723: }
1724:
1725: 1726: 1727: 1728: 1729:
1730: function setSearchParams($params) {
1731: $this->set('search_params', $params);
1732: }
1733:
1734: 1735: 1736: 1737: 1738:
1739: function getSearchEngine() {
1740: if (!is_null($this->searchengine))
1741: return $this->searchengine;
1742: $this->searchengine = new SearchEngine(true);
1743: $params = $this->get('search_params');
1744: $params .= '&albumname=' . $this->name;
1745: $this->searchengine->setSearchParams($params);
1746: return $this->searchengine;
1747: }
1748:
1749: 1750: 1751: 1752: 1753: 1754: 1755: 1756: 1757: 1758: 1759: 1760: 1761: 1762:
1763: function getImages($page = 0, $firstPageCount = 0, $sorttype = null, $sortdirection = null, $care = true, $mine = NULL) {
1764: if (!$this->exists)
1765: return array();
1766: if ($mine || is_null($this->images) || $care && $sorttype . $sortdirection !== $this->lastimagesort) {
1767: if (is_null($sorttype)) {
1768: $sorttype = $this->getSortType();
1769: }
1770: if (is_null($sortdirection)) {
1771: if ($this->getSortDirection('image')) {
1772: $sortdirection = 'DESC';
1773: }
1774: }
1775: $searchengine = $this->getSearchEngine();
1776: $this->images = $searchengine->getImages(0, 0, $sorttype, $sortdirection, $care, $mine);
1777: $this->lastimagesort = $sorttype . $sortdirection;
1778: }
1779: return parent::getImages($page, $firstPageCount);
1780: }
1781:
1782: 1783: 1784: 1785: 1786: 1787:
1788: function remove() {
1789: if ($rslt = parent::remove()) {
1790: @chmod($this->localpath, 0777);
1791: $rslt = @unlink($this->localpath);
1792: clearstatcache();
1793: }
1794: return $rslt;
1795: }
1796:
1797: 1798: 1799: 1800: 1801: 1802: 1803:
1804: function move($newfolder,$oldfolder="") {
1805: return $this->_move($newfolder);
1806: }
1807:
1808: protected function succeed($dest) {
1809: return @copy($this->localpath, $dest);
1810: }
1811:
1812: 1813: 1814: 1815: 1816: 1817: 1818:
1819: function copy($newfolder) {
1820: return parent::copy($newfolder);
1821: }
1822:
1823: 1824: 1825: 1826:
1827: function preLoad() {
1828: return;
1829: }
1830:
1831: protected function loadFileNames($dirs = false) {
1832: return array();
1833: }
1834:
1835: function isDynamic() {
1836: return 'alb';
1837: }
1838:
1839: 1840: 1841: 1842: 1843:
1844: protected function setDefaults() {
1845: global $_zp_gallery;
1846:
1847: parent::setDefaults();
1848: $parentalbum = $this->getParent();
1849: $this->set('mtime', filemtime($this->localpath));
1850: if (!$_zp_gallery->getAlbumUseImagedate()) {
1851: $this->setDateTime(strftime('%Y-%m-%d %H:%M:%S', $this->get('mtime')));
1852: }
1853: $title = trim($this->name);
1854: if (!is_null($parentalbum)) {
1855: $this->set('parentid', $parentalbum->getID());
1856: $title = substr($title, strrpos($title, '/') + 1);
1857: }
1858: $this->set('title', sanitize($title, 2));
1859: return true;
1860: }
1861:
1862: }
1863:
1864: ?>
1865: