function getData($number) { require_once JPATH_ADMINISTRATOR . '/components/com_igallery/defines.php'; nextendimport('nextend.database.database'); $db = NextendDatabase::getInstance(); $data = array(); $category = array_map('intval', explode('||', $this->_data->get('ignitegallerysourcecategory', ''))); $query = 'SELECT '; $query .= 'con.id, '; $query .= 'con.filename, '; $query .= 'con.description, '; $query .= 'con.alt_text, '; $query .= 'con.link, '; $query .= 'con.hits, '; $query .= 'con.rotation, '; $query .= 'con.gallery_id, '; $query .= 'cat.name AS cat_title, '; $query .= 'cat.alias AS cat_alias '; $query .= 'FROM #__igallery_img AS con '; $query .= 'LEFT JOIN #__igallery AS cat ON cat.id = con.gallery_id '; $where = array(); if (count($category) > 0 && !in_array('0', $category)) { $where[] = 'con.gallery_id IN (' . implode(',', $category) . ') '; } if ($this->_data->get('ignitegallerysourcepublished', 1)) { $where[] = 'con.published = 1 '; } if (count($where)) { $query .= ' WHERE ' . implode(' AND ', $where); } $order = NextendParse::parse($this->_data->get('ignitegalleryorder1', 'con.ordering|*|asc')); if ($order[0]) { $query .= 'ORDER BY ' . $order[0] . ' ' . $order[1] . ' '; $order = NextendParse::parse($this->_data->get('ignitegalleryorder2', 'con.ordering|*|asc')); if ($order[0]) { $query .= ', ' . $order[0] . ' ' . $order[1] . ' '; } } $query .= 'LIMIT 0, ' . $number . ' '; $db->setQuery($query); $result = $db->loadAssocList(); for ($i = 0; $i < count($result); $i++) { $fileHashNoExt = JFile::stripExt($result[$i]['filename']); $fileHashNoRef = substr($fileHashNoExt, 0, strrpos($fileHashNoExt, '-')); $result[$i]['url'] = 'index.php?option=com_igallery&view=category&igid=' . $result[$i]['gallery_id'] . '#!' . $fileHashNoRef; $result[$i]['categoryurl'] = 'index.php?option=com_igallery&view=category&igid=' . $result[$i]['gallery_id']; $increment = igFileHelper::getIncrementFromFilename($result[$i]['filename']); $folderName = igFileHelper::getFolderName($increment); $sourceFile = IG_ORIG_PATH . '/' . $folderName . '/' . $result[$i]['filename']; $size = getimagesize($sourceFile); $fileArray = igFileHelper::originalToResized($result[$i]['filename'], $size[0], $size[1], 100, 0, $result[$i]['rotation'], 0, 0); $result[$i]['thumbnail'] = $result[$i]['image'] = IG_IMAGE_HTML_RESIZE . $fileArray['folderName'] . '/' . $fileArray['fullFileName']; $result[$i]['title'] = $result[$i]['alt_text']; $result[$i]['author_name'] = ''; $result[$i]['author_url'] = '#'; } return $result; }
function download() { $linkSource = JRequest::getCmd('type', 'main'); $model = $this->getModel(); $photo = $model->getPhoto(JRequest::getInt('id', 0)); $category = $model->getCategory($photo->gallery_id); $profile = $model->getProfile($category->profile); if ($linkSource == 'lbox') { $imageType = $profile->lbox_download_image; } else { $imageType = $profile->download_image; } if ($imageType == 'none') { echo JText::_('JERROR_ALERTNOAUTHOR'); return; } switch ($imageType) { case 'large': $fileDetails = igFileHelper::originalToResized($photo->filename, $profile->max_width, $profile->max_height, $profile->img_quality, $profile->crop_main, $photo->rotation, $profile->round_large, $profile->round_fill, $profile->watermark, $profile->watermark_text, $profile->watermark_text_color, $profile->watermark_text_size, $profile->watermark_filename, $profile->watermark_position, $profile->watermark_transparency, 0); $path = IG_RESIZE_PATH . '/' . $fileDetails['folderName'] . '/' . $fileDetails['fullFileName']; break; case 'lightbox': $fileDetails = igFileHelper::originalToResized($photo->filename, $profile->lbox_max_width, $profile->lbox_max_height, $profile->img_quality, $profile->crop_lbox, $photo->rotation, $profile->round_large, $profile->round_fill, $profile->watermark, $profile->watermark_text, $profile->watermark_text_color, $profile->watermark_text_size, $profile->watermark_filename, $profile->watermark_position, $profile->watermark_transparency, 0); $path = IG_RESIZE_PATH . '/' . $fileDetails['folderName'] . '/' . $fileDetails['fullFileName']; break; default: $increment = igFileHelper::getIncrementFromFilename($photo->filename); $folderName = igFileHelper::getFolderName($increment); $path = IG_ORIG_PATH . '/' . $folderName . '/' . $photo->filename; } if (file_exists($path)) { preg_match_all('/-[0-9]+/', $photo->filename, $matches); $filename = str_replace($matches[0][0], '', $photo->filename); header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename=' . $filename); header('Content-Transfer-Encoding: binary'); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); header('Content-Length: ' . filesize($path)); ob_clean(); flush(); readfile($path); exit; } else { echo JText::_('FILESYSTEM_CANNOT_FIND_SOURCE_FILE'); } }
static function checkUniqueName($folderPath, $file) { if (JFile::exists($folderPath . '/' . $file)) { $increment = igFileHelper::getIncrementFromFilename($file); $fileNameExt = JFile::getExt($file); $fileNameNoExt = JFile::stripExt($file); $fileNameNoIncrement = substr($fileNameNoExt, 0, strrpos($fileNameNoExt, '-')); $i = 1; while (JFile::exists($folderPath . '/' . $fileNameNoIncrement . $i . '-' . $increment . '.' . $fileNameExt)) { $i++; } $file = $fileNameNoIncrement . $i . '-' . $increment . '.' . $fileNameExt; } return $file; }