/** * Copy this album to the location specified by $newfolder, copying all * metadata, subalbums, and subalbums' metadata with it. * @param $newfolder string the folder to copy to, including the name of the current folder (possibly renamed). * @return int 0 on success and error indicator on failure. * */ function copy($newfolder) { // album name to destination folder if (substr($newfolder, -1, 1) != '/') { $newfolder .= '/'; } $newfolder .= basename($this->localpath); // First, ensure the new base directory exists. $oldfolder = $this->name; $dest = ALBUM_FOLDER_SERVERPATH . internalToFilesystem($newfolder); // Check to see if the destination directory already exists if (file_exists($dest)) { // Disallow moving an album over an existing one. return 3; } if (substr($newfolder, count($oldfolder)) == $oldfolder) { // Disallow copying to a subfolder of the current folder (infinite loop). return 4; } $success = $this->succeed($dest); $filemask = substr($this->localpath, 0, -1) . '.*'; if ($success) { // replicate the album metadata and sub-files $uniqueset = array('folder' => $newfolder); $parentname = dirname($newfolder); if (empty($parentname) || $parentname == '/' || $parentname == '.') { $uniqueset['parentid'] = NULL; } else { $parent = newAlbum($parentname); $uniqueset['parentid'] = $parent->getID(); } $newID = parent::copy($uniqueset); if ($newID) { // replicate the tags storeTags(readTags($this->getID(), 'albums'), $newID, 'albums'); // copy the sidecar files $filestocopy = safe_glob($filemask); foreach ($filestocopy as $file) { if (in_array(strtolower(getSuffix($file)), $this->sidecars)) { $success = $success && @copy($file, dirname($dest) . '/' . basename($file)); } } } } if ($success) { return 0; } else { return 1; } }
/** * Returns the tag data * * @return string */ function getTags() { return readTags($this->id, $this->table); }
/** * Returns the tag data * * @return string */ function getTags() { return readTags($this->getID(), $this->table); }
/** * Returns the tags of the image * * @return string */ function getTags() { return readTags($this->id, 'images'); }
/** * Copies the image to a new album, along with all metadata. * * @param string $newalbum the destination album */ function copy($newalbum) { if (is_string($newalbum)) { $newalbum = new Album($this->album->gallery, $newalbum, false); } if ($newalbum->id == $this->album->id) { // Nothing to do - moving the file to the same place. return 2; } $newpath = $newalbum->localpath . internalToFilesystem($this->filename); if (file_exists($newpath)) { // If the file exists, don't overwrite it. return 2; } $filename = basename($this->localpath); $result = @copy($this->localpath, $newpath); if ($result) { $filestocopy = safe_glob(substr($this->localpath, 0, strrpos($this->localpath, '.')) . '.*'); foreach ($filestocopy as $file) { if (in_array(strtolower(getSuffix($file)), $this->sidecars)) { $result = $result && @copy($file, $newalbum->localpath . basename($file)); } } } if ($result) { if ($newID = parent::copy(array('filename' => $filename, 'albumid' => $newalbum->id))) { storeTags(readTags($this->getID(), 'images'), $newID, 'images'); query('UPDATE ' . prefix('images') . ' SET `mtime`=' . filemtime($newpath) . ' WHERE `filename`="' . $filename . '" AND `albumid`=' . $newalbum->id); return 0; } } return 1; }
/** * Returns the tag data of an album * * @return string */ function getTags() { return readTags($this->id, 'albums'); }
$dfd = opendir($servicesdir); while (($entry = readdir($dfd)) !== false) { if ($entry == ".") { continue; } if ($entry == "..") { continue; } $jsondata = file_get_contents($servicesdir . "/" . $entry); $json = json_decdat($jsondata); $json["networkname"] = $networkname; $GLOBALS["services"][$entry] = $json; } closedir($dfd); } readTags(); readChannels(); readNetworks(); function readEPG($epgdatabase) { $fd = fopen($epgdatabase, "r"); while (!feof($fd)) { $length = readInt($fd, 4); if ($length < 0) { break; } //echo "$length\n"; $json = array(); decodeLength($fd, $length, $json); if (isset($json["__section__"])) { $section = $json["__section__"];
/** * Returns the tag data * * @param string $language * @return string */ function getTags($language = NULL) { return readTags($this->getID(), $this->table, $language); }