/** * Get an HTML representation of the gallery path returned by getGalleryPath() * * @param array $pPath Path returned by getGalleryPath() * @access public * @return HTML links */ function getDisplayPath($pPath) { $ret = ""; if (!empty($pPath) && is_array($pPath)) { $ret .= " » "; foreach ($pPath as $node) { $ret .= (@BitBase::verifyId($node['parent_id']) ? ' » ' : '') . '<a title="' . htmlspecialchars($node['title']) . '" href="' . TreasuryGallery::getDisplayUrlFromHash($node['content_id']) . '">' . htmlspecialchars($node['title']) . '</a>'; } } return $ret; }
/** * batchStore * * @param array $pStoreHash * @access public * @return TRUE on success, FALSE on failure - mErrors will contain reason for failure * note: files are taken from $_FILES directly */ function batchStore(&$pStoreHash) { global $gBitUser, $gBitSystem; // we will use the information in $_FILES $i = 0; if (!empty($pStoreHash['import']['file']) && $gBitUser->hasPermission('p_treasury_import_item')) { // don't allow sneaky shits to import stuff outside our specified jail $jail = $gBitSystem->getConfig('treasury_file_import_path'); $file = realpath($jail . $pStoreHash['import']['file']); if (strpos($file, $jail) !== FALSE && is_file($file)) { // this will copy a file instead of move it $import['copy_file'] = TRUE; $import['tmp_name'] = $file; $import['name'] = basename($file); $import['size'] = filesize($file); $import['error'] = 0; $import['type'] = $gBitSystem->verifyMimeType($file); if ($import['type'] == 'application/binary' || $import['type'] == 'application/octet-stream' || $import['type'] == 'application/octetstream') { $import['type'] = $gBitSystem->lookupMimeType(basename($file)); } // pass on details to correct place $pStoreHash['file'][] = $pStoreHash['import']; $_FILES[] = $import; } else { $this->mErrors['import'] = "The file path given was not valid."; } } foreach ($_FILES as $upload) { if (!empty($upload['tmp_name'])) { // we start with a fresh copy every cycle to ensure that our store hash is pristine $item = new TreasuryItem(); $storeHash = $pStoreHash; if (!empty($storeHash['file'][$i])) { $storeHash = array_merge($storeHash, $storeHash['file'][$i]); } $storeHash['upload'] = $upload; $item->store($storeHash); } else { $item->mErrors['upload'] = tra("There was an error uploading the file: ") . $upload['name']; } $i++; } if ($i > 1) { $pStoreHash['redirect'] = TreasuryGallery::getDisplayUrlFromHash($storeHash['galleryContentIds'][0]); } elseif (!empty($storeHash['content_id'])) { $pStoreHash['redirect'] = self::getDisplayUrlFromHash($storeHash['content_id']); } $this->mErrors = array_merge($this->mErrors, $item->mErrors); return count($this->mErrors) == 0; }
/** * Returns HTML link to display a gallery or item * * @param $pTitle is the gallery we want to see * @param $pContentId content id of the gallery in question * @return the link to display the page. **/ function getDisplayLink($pLinkText = NULL, $pMixed = NULL, $pAnchor = NULL) { global $gBitSystem; if (empty($pLinkText) && !empty($this)) { $pLinkText = $this->getTitle(); } if (empty($pMixed) && !empty($this)) { $pMixed = $this->mInfo; } $ret = $pLinkText; if (!empty($pLinkText) && !empty($pMixed)) { if ($gBitSystem->isPackageActive('treasury')) { $ret = '<a title="' . htmlspecialchars($pLinkText) . '" href="' . TreasuryGallery::getDisplayUrlFromHash($pMixed) . '">' . htmlspecialchars($pLinkText) . '</a>'; } } return $ret; }