function display($tpl = null) { $this->state = $this->get('State'); $this->item = $this->get('Item'); $this->form = $this->get('Form'); $this->params = JComponentHelper::getParams('com_igallery'); if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode("\n", $errors)); return false; } $model = $this->getModel(); if ($this->item->parent != 0) { $parentCat = $model->getCategory($this->item->parent); $profile = $model->getProfile($parentCat->profile); } else { $profile = $model->getProfile($this->item->profile); } if (!empty($this->item->menu_image_filename)) { if (!($this->fileArray = igFileHelper::originalToResized($this->item->menu_image_filename, $profile->menu_max_width, $profile->menu_max_height, $profile->img_quality, $profile->crop_menu, 0, $profile->round_menu, $profile->round_fill))) { return false; } } JHTML::_('behavior.framework'); $document = JFactory::getDocument(); $document->addScript(JURI::root(true) . '/media/com_igallery/js/admin.js'); $document->addStyleSheet(JURI::root(true) . '/media/com_igallery/css/admin.css'); parent::display($tpl); }
function display($tpl = null) { $this->state = $this->get('State'); $this->item = $this->get('Item'); $this->form = $this->get('Form'); $this->isSite = JFactory::getApplication()->isSite(); $this->params = JComponentHelper::getParams('com_igallery'); if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode("\n", $errors)); return false; } $model = $this->getModel(); if ($this->item->parent != 0) { $parentCat = $model->getCategory($this->item->parent); $profile = $model->getProfile($parentCat->profile); } else { $profile = $model->getProfile($this->item->profile); } if (!empty($this->item->menu_image_filename)) { if (!($this->fileArray = igFileHelper::originalToResized($this->item->menu_image_filename, $profile->menu_max_width, $profile->menu_max_height, $profile->img_quality, $profile->crop_menu, 0, $profile->round_menu, $profile->round_fill))) { return false; } } $this->addToolbar($this->item); parent::display($tpl); }
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'); } }
function display($tpl = null) { $this->state = $this->get('State'); $this->items = $this->get('Items'); $this->pagination = $this->get('Pagination'); if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode("\n", $errors)); return false; } for ($i = 0; $i < count($this->items); $i++) { $row = $this->items[$i]; if (!($this->thumbFiles[$i] = igFileHelper::originalToResized($row->filename, $row->thumb_width, $row->thumb_height, $row->img_quality, $row->crop_thumbs, $row->rotation, $row->round_thumb, $row->round_fill))) { return false; } } $this->addToolbar(); igHtmlHelper::addSubmenu(); parent::display($tpl); }
function display($tpl = null) { $this->state = $this->get('State'); $this->item = $this->get('Item'); $this->form = $this->get('Form'); $this->isSite = JFactory::getApplication()->isSite(); $this->params = JComponentHelper::getParams('com_igallery'); $model = $this->getModel(); $this->category = $model->getCategory($this->item->gallery_id); $profile = $model->getProfile($this->category->profile); if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode("\n", $errors)); return false; } if (!($this->thumbFile = igFileHelper::originalToResized($this->item->filename, $profile->thumb_width, $profile->thumb_height, $profile->img_quality, $profile->crop_thumbs, $this->item->rotation, $profile->round_thumb, $profile->round_fill))) { return false; } $this->addToolbar(); parent::display($tpl); }
function display($tpl = null) { $this->state = $this->get('State'); $this->items = $this->get('Items'); $this->pagination = $this->get('Pagination'); $this->isSite = JFactory::getApplication()->isSite(); $this->user = JFactory::getUser(); $model = $this->getModel(); $this->category = $model->getCategory(JRequest::getInt('catid', 0)); if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode("\n", $errors)); return false; } $this->params = JComponentHelper::getParams('com_igallery'); $this->moderate = $this->params->get('moderate_img', 0); $this->catDropDown = igHtmlHelper::getCategorySelect('catid', 'id', 'name', null, true, 1, true, $this->category->id); if (!empty($this->category->id)) { $selectItems = array(); $selectItems[] = JHTML::_('select.option', 'copy', JText::_('IG_COPY')); $selectItems[] = JHTML::_('select.option', 'move', JText::_('IG_MOVE')); $this->copyMove = JHTML::_('select.genericlist', $selectItems, 'copy_move', 'class="inputbox" size="1"'); $this->catCopyMove = igHtmlHelper::getCategorySelect('cat_id_copy_move', 'id', 'name', $this->category->id, true, 1, false, 0); } $this->thumbFiles = array(); $this->mainFiles = array(); for ($i = 0; $i < count($this->items); $i++) { $row = $this->items[$i]; if (!($this->thumbFiles[$i] = igFileHelper::originalToResized($row->filename, $row->thumb_width, $row->thumb_height, $row->img_quality, $row->crop_thumbs, $row->rotation, $row->round_thumb, $row->round_fill))) { return false; } if (!($this->mainFiles[$i] = igFileHelper::originalToResized($row->filename, $row->max_width, $row->max_height, $row->img_quality, $row->crop_main, $row->rotation, $row->round_large, $row->round_fill, $row->watermark, $row->watermark_text, $row->watermark_text_color, $row->watermark_text_size, $row->watermark_filename, $row->watermark_position, $row->watermark_transparency, 1))) { return false; } } $this->showImportServer = false; if ($this->params->get('show_import_server', 0) && $this->category->id > 0 && $this->isSite == false && igGeneralHelper::authorise('core.create', $this->category->id)) { $this->showImportServer = true; } if ($this->showImportServer) { $data = ' <?xml version="1.0" encoding="utf-8"?> <form><fieldset> <field name="server_import" type="ifolderlist" directory="images" label="SERVER_IMPORT" addfieldpath="administrator/components/com_igallery/models/fields"/> </fieldset></form>'; $this->imagesForm = JForm::getInstance('images', $data); } if (igGeneralHelper::authorise('core.create', $this->category->id)) { if (!empty($this->category->id)) { $uploader = $this->params->get('file_uploader', 'plupload'); $uploaderFileName = IG_UPLOAD_PATH . '/' . $uploader . '/' . $uploader . '.php'; $uploaderClassName = 'igUpload' . ucfirst($uploader); $headJsFunctionName = $uploader . 'HeadJs'; $htmlFunctionName = $uploader . 'HTML'; require_once $uploaderFileName; call_user_func(array($uploaderClassName, $headJsFunctionName)); call_user_func(array($uploaderClassName, $htmlFunctionName)); } else { echo '<p style="padding: 5px 15px;">' . JText::_('PLEASE_SELECT_CATEGORY_TO_UPLOAD') . '<p>'; } } if ($this->params->get('import_exif_data', 0) == 1 && !function_exists('exif_read_data')) { JFactory::getApplication()->enqueueMessage('Warning, importing of exif descriptions has been enabled in the component options - upload tab, but the php extension exif has not been enabled in php.ini, no exif data will be imported.'); } if (JFactory::getSession()->get('ig_uploaded', 0) == 1) { JFactory::getApplication()->enqueueMessage(JText::_('NEW_IMAGES_ADDED')); JFactory::getSession()->set('ig_uploaded', 0); } $this->addToolbar($this->category); igHtmlHelper::addSubmenu(); parent::display($tpl); }
static function makeResizedOnUpload($fileData, $profile, $refresh) { if (!igFileHelper::originalToResized($fileData['filename'], $profile->thumb_width, $profile->thumb_height, $profile->img_quality, $profile->crop_thumbs, 0, $profile->round_thumb, $profile->round_fill, 0, '', '', '', '', '', 100, 0, $refresh)) { return false; } if (!igFileHelper::originalToResized($fileData['filename'], $profile->max_width, $profile->max_height, $profile->img_quality, $profile->crop_main, 0, $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, $refresh)) { return false; } if (!igFileHelper::originalToResized($fileData['filename'], $profile->lbox_thumb_width, $profile->lbox_thumb_height, $profile->img_quality, $profile->lbox_crop_thumbs, 0, $profile->round_thumb, $profile->round_fill, 0, '', '', '', '', '', 100, 0, $refresh)) { return false; } if (!igFileHelper::originalToResized($fileData['filename'], $profile->lbox_max_width, $profile->lbox_max_height, $profile->img_quality, $profile->crop_lbox, 0, $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, $refresh)) { return false; } return true; }
function getCategoryChildren($catId, $profile, $type, $source, $limit) { $db = $this->getDbo(); $user = JFactory::getUser(); $query = $db->getQuery(true); $query->select('c.*'); $query->from('#__igallery AS c'); $query->where('c.published = 1'); $query->where('c.moderate = 1'); $nullDate = $db->Quote($db->getNullDate()); $nowDate = $db->Quote(JFactory::getDate()->toSql()); $query->where('(c.publish_up = ' . $nullDate . ' OR c.publish_up <= ' . $nowDate . ')'); $query->where('(c.publish_down = ' . $nullDate . ' OR c.publish_down >= ' . $nowDate . ')'); $query->select('p.menu_max_width, p.menu_max_height, p.img_quality, p.menu_access'); $query->join('INNER', '`#__igallery_profiles` AS p ON p.id = c.profile'); $groups = implode(',', $user->getAuthorisedViewLevels()); $query->where('p.menu_access IN (' . $groups . ')'); $query->select('u.name AS displayname, u.username'); $query->join('LEFT', '`#__users` AS u ON c.user = u.id'); $query->select('COUNT(i.id) AS numimages'); $query->group('c.id'); switch ($type) { case 'latest_menu_images': $children = $this->getChildIds($catId); $query->where('FIND_IN_SET(c.id,"' . implode(',', $children) . '")'); $query->join('INNER', '#__igallery_img AS i ON (i.gallery_id = c.id AND i.published = 1 AND i.moderate = 1)'); $query->order('c.date DESC'); break; case 'hits_menu_images': $children = $this->getChildIds($catId); $query->where('FIND_IN_SET(c.id,"' . implode(',', $children) . '")'); $query->join('INNER', '#__igallery_img AS i ON (i.gallery_id = c.id AND i.published = 1 AND i.moderate = 1)'); $query->order('c.hits DESC'); break; case 'random_menu_images': $children = $this->getChildIds($catId); $query->where('FIND_IN_SET(c.id,"' . implode(',', $children) . '")'); $query->join('INNER', '#__igallery_img AS i ON (i.gallery_id = c.id AND i.published = 1 AND i.moderate = 1)'); $query->order('RAND()'); break; default: $query->where('c.parent = ' . (int) $catId); $query->join('LEFT', '#__igallery_img AS i ON (i.gallery_id = c.id AND i.published = 1 AND i.moderate = 1)'); $query->order('ordering'); break; } $this->menuTotal = $this->_getListCount($query); if ($profile->menu_pagination == 1) { $categoryChildren = $this->_getList($query, JRequest::getInt('menu_limitstart', 0), $profile->menu_pagination_amount); } else { if ($limit > 0) { $categoryChildren = $this->_getList($query, 0, $limit); } else { $categoryChildren = $this->_getList($query); } } $this->addSelectedMenuImages($categoryChildren); $this->addFirstMenuImages($categoryChildren); $categoryChildren = array_values($categoryChildren); for ($i = 0; $i < count($categoryChildren); $i++) { if ($source != 'component' && JRequest::getInt('igpid', 0) > 0) { $profileId = JRequest::getInt('igpid', 0); } else { if (empty($categoryChildren[$i]->parent)) { $profileId = $categoryChildren[$i]->profile; } else { $parentCat = $this->getCategory($categoryChildren[$i]->parent); $profileId = $parentCat->profile; } } $profile = $this->getProfile($profileId); $categoryChildren[$i]->menu_max_width = $profile->menu_max_width; $categoryChildren[$i]->menu_max_height = $profile->menu_max_height; $menuPhoto = new stdClass(); if (!empty($categoryChildren[$i]->menu_image_filename)) { $menuPhoto = new stdClass(); $menuPhoto->filename = $categoryChildren[$i]->menu_image_filename; $menuPhoto->rotation = 0; } elseif (!empty($categoryChildren[$i]->selected_menu_filename)) { $menuPhoto = new stdClass(); $menuPhoto->filename = $categoryChildren[$i]->selected_menu_filename; $menuPhoto->rotation = $categoryChildren[$i]->selected_menu_rotation; } elseif (!empty($categoryChildren[$i]->first_menu_filename) && $profile->menu_image_defaults == 1) { $menuPhoto = new stdClass(); $menuPhoto->filename = $categoryChildren[$i]->first_menu_filename; $menuPhoto->rotation = $categoryChildren[$i]->first_menu_rotation; } if (!empty($menuPhoto->filename)) { $categoryChildren[$i]->fileArray = igFileHelper::originalToResized($menuPhoto->filename, $profile->menu_max_width, $profile->menu_max_height, $profile->img_quality, $profile->crop_menu, $menuPhoto->rotation, $profile->round_menu, $profile->round_fill); } } return $categoryChildren; }
function display($tpl = null) { $this->state = $this->get('State'); $this->items = $this->get('Items'); $this->pagination = $this->get('Pagination'); $this->user = JFactory::getUser(); $model = $this->getModel(); $this->category = $model->getCategory(JRequest::getInt('catid', 0)); if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode("\n", $errors)); return false; } if (empty($this->category->id)) { JError::raiseError(500, 'Error: No Category id in the page url'); return false; } $this->params = JComponentHelper::getParams('com_igallery'); $this->moderate = $this->params->get('moderate_img', 0); $this->thumbFiles = array(); $this->mainFiles = array(); for ($i = 0; $i < count($this->items); $i++) { $row = $this->items[$i]; if (!($this->thumbFiles[$i] = igFileHelper::originalToResized($row->filename, $row->thumb_width, $row->thumb_height, $row->img_quality, $row->crop_thumbs, $row->rotation, $row->round_thumb, $row->round_fill))) { return false; } if (!($this->mainFiles[$i] = igFileHelper::originalToResized($row->filename, $row->max_width, $row->max_height, $row->img_quality, $row->crop_main, $row->rotation, $row->round_large, $row->round_fill, $row->watermark, $row->watermark_text, $row->watermark_text_color, $row->watermark_text_size, $row->watermark_filename, $row->watermark_position, $row->watermark_transparency, 1))) { return false; } $imgStateUsed = false; $imgDeleteUsed = false; $deleteImageOk = igGeneralHelper::authorise('core.igalleryfront.deleteimage', null, $row->id, $row->id_of_profile, $row->user); $editImageStateOk = igGeneralHelper::authorise('core.igalleryfront.editimage.state', null, $row->id, $row->id_of_profile, $row->user); if ($editImageStateOk && $imgStateUsed == false) { JRequest::setVar('igImgStateUsed', 1); $imgStateUsed = true; } if ($deleteImageOk && $imgDeleteUsed == false) { JRequest::setVar('igImgDeleteUsed', 1); $imgDeleteUsed = true; } } if (igGeneralHelper::authorise('core.igalleryfront.upload', $this->category->id)) { $uploader = $this->params->get('file_uploader', 'plupload'); $uploaderFileName = IG_UPLOAD_PATH . '/' . $uploader . '/' . $uploader . '.php'; $uploaderClassName = 'igUpload' . ucfirst($uploader); $headJsFunctionName = $uploader . 'HeadJs'; $htmlFunctionName = $uploader . 'HTML'; require_once $uploaderFileName; call_user_func(array($uploaderClassName, $headJsFunctionName)); call_user_func(array($uploaderClassName, $htmlFunctionName)); } if (JFactory::getSession()->get('ig_uploaded', 0) == 1) { JFactory::getApplication()->enqueueMessage(JText::_('NEW_IMAGES_ADDED')); JFactory::getSession()->set('ig_uploaded', 0); } JHTML::_('behavior.framework'); $document = JFactory::getDocument(); $document->addScript(JURI::root(true) . '/media/com_igallery/js/admin.js'); $document->addStyleSheet(JURI::root(true) . '/media/com_igallery/css/admin.css'); parent::display($tpl); }
function getMetaData() { $metaData = array(); if (empty($this->ajaxUrlImageName)) { if (!empty($this->urlImageName)) { $this->ajaxUrlImageName = $this->urlImageName; } } if (!empty($this->ajaxUrlImageName) && !empty($this->photoList)) { for ($i = 0; $i < count($this->photoList); $i++) { $fileNameNoExt = JFile::stripExt($this->photoList[$i]->filename); $fileNameNoRef = substr($fileNameNoExt, 0, strpos($fileNameNoExt, '-')); if ($fileNameNoRef == $this->ajaxUrlImageName) { $this->activeImage = $i; $metaData['image'] = IG_IMAGE_HTML_RESIZE_ABSOLUTE . $this->mainFiles[$i]['folderName'] . '/' . $this->mainFiles[$i]['fullFileName']; if (!empty($this->photoList[$i]->alt_text)) { $metaData['title'] = $this->photoList[$i]->alt_text; } if (!empty($this->photoList[$i]->description)) { $metaData['description'] = $this->photoList[$i]->description; } break; } } } if ($this->source == 'component') { if (!isset($metaData['title']) && strlen($this->category->page_title) > 1) { $metaData['title'] = $this->category->page_title; } if (!isset($metaData['title']) && strlen($this->category->name) > 1) { $metaData['title'] = $this->category->name; } if (!isset($metaData['description']) && strlen($this->category->metadesc) > 1) { $metaData['description'] = $this->category->metadesc; } if (!isset($metaData['description']) && strlen($this->category->gallery_description) > 1) { $metaData['description'] = $this->category->gallery_description; } if (!isset($metaData['image']) && !empty($this->category->menu_image_filename)) { $menuImageFileArray = igFileHelper::originalToResized($this->category->menu_image_filename, $this->profile->menu_max_width, $this->profile->menu_max_height, $this->profile->img_quality, $this->profile->crop_menu, 0, $this->profile->round_menu, $this->profile->round_fill); $metaData['image'] = IG_IMAGE_HTML_RESIZE_ABSOLUTE . $menuImageFileArray['folderName'] . '/' . $menuImageFileArray['fullFileName']; } } return $metaData; }