/** * Returns all folder names for all the subdirectories. * * @param string $page Which page of subalbums to display. * @param string $sorttype The sort strategy * @param string $sortdirection The direction of the sort * @param bool $care set to false if the order does not matter * @param bool $mine set true/false to override ownership * @return array */ function getAlbums($page = 0, $sorttype = null, $sortdirection = null, $care = true, $mine = NULL) { global $_zp_gallery; if (!$this->exists) { return array(); } if ($mine || is_null($this->subalbums) || $care && $sorttype . $sortdirection !== $this->lastsubalbumsort) { if (is_null($sorttype)) { $sorttype = $this->getSortType('album'); } if (is_null($sortdirection)) { if ($this->getSortDirection('album')) { $sortdirection = 'DESC'; } else { $sortdirection = ''; } } $searchengine = $this->getSearchEngine(); $subalbums = $searchengine->getAlbums(0, $sorttype, $sortdirection, $care, $mine); $key = $this->getAlbumSortKey($sorttype); $this->subalbums = $_zp_gallery->sortAlbumArray($this, $subalbums, $key, $sortdirection, $mine); $this->lastsubalbumsort = $sorttype . $sortdirection; } return parent::getAlbums($page); }
/** * Returns all folder names for all the subdirectories. * * @param string $page Which page of subalbums to display. * @param string $sorttype The sort strategy * @param string $sortdirection The direction of the sort * @param bool $care set to false if the order does not matter * @param bool $mine set true/false to override ownership * @return array */ function getAlbums($page = 0, $sorttype = null, $sortdirection = null, $care = true, $mine = NULL) { global $_zp_gallery; if ($mine || is_null($this->subalbums) || $care && $sorttype . $sortdirection !== $this->lastsubalbumsort) { $results = array(); $result = query('SELECT * FROM ' . prefix('plugin_storage') . ' WHERE `type`="favorites" AND `aux`=' . db_quote($this->getInstance()) . ' AND `data` LIKE "%s:4:\\"type\\";s:6:\\"albums\\";%"'); if ($result) { while ($row = db_fetch_assoc($result)) { $data = getSerializedArray($row['data']); $albumobj = newAlbum($data['id'], true, true); if ($albumobj->exists) { // fail to instantiate? $results[$data['id']] = $albumobj->getData(); } else { query("DELETE FROM " . prefix('plugin_storage') . ' WHERE `id`=' . $row['id']); } } db_free_result($result); if (is_null($sorttype)) { $sorttype = $this->getSortType('album'); } if (is_null($sortdirection)) { if ($this->getSortDirection('album')) { $sortdirection = 'DESC'; } else { $sortdirection = ''; } } $sortkey = $this->getAlbumSortKey($sorttype); if ($sortkey == '`sort_order`' || $sortkey == 'RAND()') { // manual sort is always ascending $order = false; } else { if (!is_null($sortdirection)) { $order = strtoupper($sortdirection) == 'DESC'; } else { $order = $obj->getSortDirection('album'); } } $results = sortByKey($results, $sortkey, $order); $this->subalbums = array_keys($results); $this->lastsubalbumsort = $sorttype . $sortdirection; } } return parent::getAlbums($page); }