/** * Returns a of a slice of the images for this album. They will * also be sorted according to the sort type of this album, or by filename if none * has been set. * * @param string $page Which page of images should be returned. If zero, all images are returned. * @param int $firstPageCount count of images that go on the album/image transition page * @param string $sorttype optional sort type * @param string $sortdirection optional sort direction * @param bool $care set to false if the order of the images does not matter * @param bool $mine set true/false to override ownership * * @return array */ function getImages($page = 0, $firstPageCount = 0, $sorttype = null, $sortdirection = null, $care = true, $mine = NULL) { if ($mine || is_null($this->images) || $care && $sorttype . $sortdirection !== $this->lastimagesort) { $this->images = NULL; $images = 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:\\"images\\";%"'); if ($result) { while ($row = db_fetch_assoc($result)) { $id = $row['id']; $data = getSerializedArray($row['data']); $imageObj = newImage(NULL, array('folder' => dirname($data['id']), 'filename' => basename($data['id'])), true); if ($imageObj->exists) { $images[] = array_merge(array('folder' => dirname($data['id']), 'filename' => basename($data['id'])), $imageObj->getData()); } else { query("DELETE FROM " . prefix('plugin_storage') . ' WHERE `id`=' . $row['id']); } } db_free_result($result); if (is_null($sorttype)) { $sorttype = $this->getSortType(); } $sortkey = str_replace('` ', ' ', $this->getImageSortKey($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 = $this->getSortDirection('image'); } } $images = sortByKey($images, $sortkey, $order); $this->images = array(); foreach ($images as $data) { $this->images[] = array('folder' => $data['folder'], 'filename' => $data['filename']); } $this->lastimagesort = $sorttype . $sortdirection; } } return parent::getImages($page, $firstPageCount); }
/** * Returns a of a slice of the images for this album. They will * also be sorted according to the sort type of this album, or by filename if none * has been set. * * @param int $page Which page of images should be returned. If zero, all images are returned. * @param int $firstPageCount count of images that go on the album/image transition page * @param string $sorttype optional sort type * @param string $sortdirection optional sort direction * @param bool $care set to false if the order of the images does not matter * @param bool $mine set true/false to override ownership * * @return array */ function getImages($page = 0, $firstPageCount = 0, $sorttype = null, $sortdirection = null, $care = true, $mine = NULL) { if (!$this->exists) { return array(); } if ($mine || is_null($this->images) || $care && $sorttype . $sortdirection !== $this->lastimagesort) { if (is_null($sorttype)) { $sorttype = $this->getSortType(); } if (is_null($sortdirection)) { if ($this->getSortDirection('image')) { $sortdirection = 'DESC'; } } $searchengine = $this->getSearchEngine(); $this->images = $searchengine->getImages(0, 0, $sorttype, $sortdirection, $care, $mine); $this->lastimagesort = $sorttype . $sortdirection; } return parent::getImages($page, $firstPageCount); }
/** * Returns a of a slice of the images for this album. They will * also be sorted according to the sort type of this album, or by filename if none * has been set. * * @param int $page Which page of images should be returned. If zero, all images are returned. * @param int $firstPageCount count of images that go on the album/image transition page * @param string $sorttype optional sort type * @param bol $sortdirection optional sort direction * @param bool $care set to false if the order of the images does not matter * @param bool $mine set true/false to override ownership * * @return array */ function getImages($page = 0, $firstPageCount = 0, $sorttype = null, $sortdirection = null, $care = true, $mine = NULL) { if (!$this->exists) { return array(); } if (is_null($sorttype)) { $sorttype = $this->getSortType(); } if (is_null($sortdirection)) { $sortdirection = $this->getSortDirection('image'); } $sortdirection = $sortdirection && strtolower($sortdirection) != 'asc'; if ($mine || is_null($this->images) || $care && $sorttype . $sortdirection !== $this->lastimagesort) { $searchengine = $this->getSearchEngine(); $this->images = $searchengine->getImages(0, 0, $sorttype, $sortdirection, $care, $mine); $this->lastimagesort = $sorttype . $sortdirection; $this->imageNames = array(); foreach ($this->images as $image) { $this->imageNames[$image['folder'] . '/' . $image['filename']] = $image['filename']; } ksort($this->imageNames); } return parent::getImages($page, $firstPageCount); }