Ejemplo n.º 1
0
 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);
 }
Ejemplo n.º 2
0
 function browserUpload()
 {
     if (!igGeneralHelper::authorise('core.igalleryfront.upload', JRequest::getInt('catid', 0))) {
         return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR'));
     }
     for ($i = 0; $i < count($_FILES['uploads']['name']); $i++) {
         $fileName = $_FILES['uploads']['name'][$i];
         $tmpPath = $_FILES['uploads']['tmp_name'][$i];
         $uploadError = $_FILES['uploads']['error'][$i];
         if (!($fileData = igFileHelper::processUploadedImage($fileName, $tmpPath, $uploadError, 'igallery_img', true))) {
             $this->setRedirect('index.php?option=com_igallery&controller=igphoto&catid=' . JRequest::getInt('catid'));
             return false;
         }
         $model = $this->getModel();
         $category = $model->getCategory(JRequest::getInt('catid', 0));
         $profile = $model->getProfile($category->profile);
         if (!igFileHelper::makeResizedOnUpload($fileData, $profile, true)) {
             return false;
         }
         if (!$model->store($fileData)) {
             return false;
         }
     }
     $this->setRedirect(JRoute::_('index.php?option=com_igallery&view=images&catid=' . JRequest::getInt('catid'), false));
 }
Ejemplo n.º 3
0
 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);
 }
Ejemplo n.º 4
0
 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');
     }
 }
Ejemplo n.º 6
0
 function serverImport()
 {
     if (!igGeneralHelper::authorise('core.admin')) {
         return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR'));
     }
     $filePathRaw = JRequest::GetVar('path');
     $filePath = str_replace('*', '\\', $filePathRaw);
     if (!($fileData = igFileHelper::processImportedImage($filePath))) {
         return false;
     }
     $model = $this->getModel();
     if (!$model->store($fileData)) {
         echo $model->getError();
         return false;
     }
     echo 1;
 }
Ejemplo n.º 7
0
 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);
 }
Ejemplo n.º 8
0
 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);
 }
Ejemplo n.º 9
0
 function plUpload()
 {
     if (!igGeneralHelper::authorise('core.igalleryfront.upload', JRequest::getInt('catid', 0))) {
         echo JText::_('JERROR_ALERTNOAUTHOR');
         return false;
     }
     $fileName = $_FILES['file']['name'];
     $tmpPath = $_FILES['file']['tmp_name'];
     $uploadError = $_FILES['file']['error'];
     if (!($fileData = igFileHelper::processUploadedImage($fileName, $tmpPath, $uploadError, 'igallery_img', false))) {
         return false;
     }
     $model = $this->getModel();
     $category = $model->getCategory(JRequest::getInt('catid', 0));
     $profile = $model->getProfile($category->profile);
     if (!igFileHelper::makeResizedOnUpload($fileData, $profile, false)) {
         return false;
     }
     if (!$model->store($fileData)) {
         return false;
     }
     JFactory::getSession()->set('ig_uploaded', 1);
     echo 1;
 }
Ejemplo n.º 10
0
 function delete(&$pks)
 {
     $db = $this->getDbo();
     $id = is_array($pks) ? (int) $pks[0] : (int) $pks;
     $query = 'SELECT * FROM #__igallery WHERE id = ' . (int) $id;
     $db->setQuery($query);
     $category = $db->loadObject();
     if (strlen($category->menu_image_filename) > 2) {
         $query = 'SELECT menu_image_filename FROM #__igallery WHERE menu_image_filename = ' . $this->_db->Quote($category->menu_image_filename);
         $db->setQuery($query);
         $db->query();
         $numRows = $db->getNumRows();
         $deleteOrig = $numRows > 1 ? false : true;
         igFileHelper::deleteImage($category->menu_image_filename, $deleteOrig);
     }
     $query = 'SELECT id, filename FROM #__igallery_img WHERE gallery_id = ' . (int) $id;
     $db->setQuery($query);
     $photoList = $db->loadObjectList();
     for ($i = 0; $i < count($photoList); $i++) {
         $photo = $photoList[$i];
         $query = 'SELECT filename FROM #__igallery_img WHERE filename = ' . $db->Quote($photo->filename);
         $db->setQuery($query);
         $db->query();
         $numRows = $db->getNumRows();
         $deleteOrig = $numRows > 1 ? false : true;
         igFileHelper::deleteImage($photo->filename, $deleteOrig);
         $query = 'DELETE FROM #__igallery_img WHERE id = ' . (int) $photo->id;
         $db->setQuery($query);
         if (!$db->query()) {
             $this->setError($db->getErrorMsg());
             return false;
         }
         $commentsPath = JPATH_SITE . '/components/com_jcomments/jcomments.php';
         if (file_exists($commentsPath)) {
             require_once $commentsPath;
             JCommentsModel::deleteComments((int) $photo->id, 'com_igallery');
         }
         $alPath = JPATH_SITE . '/components/com_alratings/classes/alratings.php';
         if (file_exists($alPath)) {
             require_once $alPath;
             ALRatings::deleteRating('com_igallery', (int) $photo->id);
         }
     }
     $query = 'DELETE FROM #__igallery WHERE id = ' . (int) $id;
     $db->setQuery($query);
     if (!$db->query()) {
         $this->setError($db->getErrorMsg());
         return false;
     }
     $query = 'UPDATE #__igallery SET parent = 0 WHERE parent = ' . (int) $id;
     $db->setQuery($query);
     if (!$db->query()) {
         $this->setError($db->getErrorMsg());
         return false;
     }
     $row = $this->getTable('igallery');
     $row->reorder('parent = ' . (int) $category->parent);
     return true;
 }
Ejemplo n.º 11
0
 static function moveFile($tmpPath, $destDir, $fileName, $refresh)
 {
     $destPath = $destDir . '/' . $fileName;
     if (!JFile::upload($tmpPath, $destPath)) {
         igFileHelper::raiseError($tmpPath . ' -> ' . $destPath . ' ' . JText::_('Error Moving File To Directory'), $refresh);
         return false;
     }
     return true;
 }
Ejemplo n.º 12
0
 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);
 }
Ejemplo n.º 13
0
 static function makeImage($sourceFile, $destFile, $width, $height, $quality, $refresh, $crop = 0, $rotation = 0, $round = 0, $roundFill = '', $watermark = 0, $wmText = '', $wmTextColor = '', $wmTextSize = '', $wmFilename = '', $wmPosition = '', $wmTrans = 100)
 {
     if (!extension_loaded('gd') && !function_exists('gd_info')) {
         igFileHelper::raiseError('M1 0 :Please Check the PHP extension "GD Image Library" is installed on this server', $refresh);
         return false;
     }
     if ($width == 0 || $height == 0) {
         igFileHelper::raiseError('MI 1: ' . JText::_('Image Width Or Height In Profile Settings Must Not Be Zero'), $refresh);
         return false;
     }
     jimport('joomla.filesystem.file');
     require_once JPATH_ADMINISTRATOR . '/components/com_igallery/lib/gdimage/GdImage.php';
     if (!JFile::exists($destFile)) {
         $ext = JFile::getExt($sourceFile);
         $imageinfo = getimagesize($sourceFile);
         $image = GDImage::load($sourceFile);
         $params = JComponentHelper::getParams('com_igallery');
         $tryOriginal = $params->get('use_original', 0);
         if ($tryOriginal == 1) {
             if ($rotation == 0 && $round == 0 && $watermark == 0 && $crop == 0) {
                 if ($imageinfo[0] <= $width && $imageinfo[1] <= $height) {
                     if (!JFile::copy($sourceFile, $destFile)) {
                         igFileHelper::raiseError($sourceFile . ' -> ' . $destFile . ' ' . JText::_('Error Moving File To Directory'), $refresh);
                         return false;
                     }
                     return true;
                 }
             }
         }
         if ($crop == 1 && $imageinfo[0] > $width && $imageinfo[1] > $height) {
             $image = $image->resize((int) $width, (int) $height, 'outside')->crop('center', 'middle', (int) $width, (int) $height);
         } else {
             $image = $image->resize((int) $width, (int) $height, 'inside', 'down');
         }
         if ($rotation != 0) {
             if (!function_exists('imagerotate')) {
                 igFileHelper::raiseError(JFile::getName($sourceFile) . ': nee' / ' rotating ' . $rotation . ' degress, Please Check the php function "imagerotate" is available on this server', $refresh);
             } else {
                 $image = $image->rotate($rotation, null, false);
             }
         }
         if ($watermark == 1) {
             $positionArray = explode('_', $wmPosition);
             switch ($positionArray[0]) {
                 case 'left':
                     $leftIndent = '+5';
                     break;
                 case 'right':
                     $leftIndent = '-5';
                     break;
                 default:
                     $leftIndent = '';
             }
             switch ($positionArray[1]) {
                 case 'top':
                     $topIndent = '+5';
                     break;
                 case 'bottom':
                     $topIndent = '-5';
                     break;
                 default:
                     $topIndent = '';
             }
             if (strlen($wmText) > 0) {
                 $canvas = $image->getCanvas();
                 $fontPath = IG_ADMINISTRATOR_COMPONENT . '/fonts/font.ttf';
                 if (!JFile::exists($fontPath)) {
                     igFileHelper::raiseError('Watermarking Font File Missing, Please Upload a .ttf file to : ' . $fontPath, $refresh);
                     return false;
                 } else {
                     $colorArray = explode(',', $wmTextColor);
                     $font = new GDImage_Font_TTF($fontPath, (int) $wmTextSize, $image->allocateColorAlpha((int) $colorArray[0], (int) $colorArray[1], (int) $colorArray[2], 100 - $wmTrans));
                     $canvas->setFont($font);
                     $canvas->writeText($positionArray[0] . $leftIndent, $positionArray[1] . $topIndent, $wmText);
                 }
             }
             if (strlen($wmFilename) > 0) {
                 $extWatermark = JFile::getExt(IG_WATERMARK_PATH . '/' . $wmFilename);
                 $overlay = GDImage::load(IG_WATERMARK_PATH . '/' . $wmFilename);
                 $image = $image->merge($overlay, $positionArray[0], $positionArray[1], $wmTrans);
             }
         }
         if ($round == 1) {
             if (!function_exists('imagerotate')) {
                 igFileHelper::raiseError('Rounded Corners enabled: Please Check the php function "imagerotate" is available on this server', $refresh);
             } else {
                 if ($width < 200) {
                     $radius = 11;
                 } else {
                     $radius = 12;
                 }
                 $colorArray = explode(',', $roundFill);
                 $image = $image->roundCorners($radius, $image->allocateColor((int) $colorArray[0], (int) $colorArray[1], (int) $colorArray[2]), 255);
             }
         }
         if (preg_match("/jp/i", $ext)) {
             $image->saveToFile($destFile, $quality);
         } else {
             $image->saveToFile($destFile);
         }
         if ($rotation != 0) {
             $image = GDImage::load($destFile);
             $imageinfo = getimagesize($sourceFile);
             if ($imageinfo[0] > $width || $imageinfo[1] > $height) {
                 if ($crop == 1 && $imageinfo[0] > $width && $imageinfo[1] > $height) {
                     $image = $image->resize((int) $width, (int) $height, 'outside')->crop('center', 'middle', (int) $width, (int) $height);
                 } else {
                     $image = $image->resize((int) $width, (int) $height, 'inside', 'down');
                 }
             }
             $image->saveToFile($destFile);
         }
         return true;
     }
     return true;
 }
Ejemplo n.º 14
0
 function delete(&$pks)
 {
     $db = $this->getDbo();
     JArrayHelper::toInteger($pks);
     for ($i = 0; $i < count($pks); $i++) {
         $query = 'SELECT filename FROM #__igallery_img WHERE id = ' . (int) $pks[$i];
         $db->setQuery($query);
         $photo = $db->loadObject();
         $query = 'SELECT filename FROM #__igallery_img WHERE filename = ' . $db->Quote($photo->filename);
         $db->setQuery($query);
         $db->query();
         $numRows = $db->getNumRows();
         $deleteOrig = $numRows > 1 ? false : true;
         igFileHelper::deleteImage($photo->filename, $deleteOrig);
         $query = 'DELETE FROM #__igallery_img WHERE id = ' . (int) $pks[$i];
         $db->setQuery($query);
         if (!$db->query()) {
             $this->setError($db->getErrorMsg());
             return false;
         }
         $commentsPath = JPATH_SITE . '/components/com_jcomments/jcomments.php';
         if (file_exists($commentsPath)) {
             require_once $commentsPath;
             JCommentsModel::deleteComments((int) $pks[$i], 'com_igallery');
         }
         $alPath = JPATH_SITE . '/components/com_alratings/classes/alratings.php';
         if (file_exists($alPath)) {
             require_once $alPath;
             ALRatings::deleteRating('com_igallery', (int) $pks[$i]);
         }
     }
     $row = $this->getTable('igallery_img');
     $row->reorder('gallery_id = ' . JRequest::getInt('catid', 0));
     return true;
 }
Ejemplo n.º 15
0
 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;
 }
Ejemplo n.º 16
0
define('IG_IMAGE_HTML_WATERMARK', JURI::root(true) . '/images/igallery/watermark/');
define('IG_IMAGE_ASSET_PATH', JURI::root(true) . '/media/com_igallery/images/');
$igJVersion = new JVersion();
if ($igJVersion->isCompatible('3.0')) {
    define('IG_J30', true);
} else {
    define('IG_J30', false);
}
define('IG_VERSION', '3.6.7');
//import some classes
jimport('joomla.environment.uri');
jimport('joomla.filesystem.file');
jimport('joomla.filesystem.folder');
require_once IG_ADMINISTRATOR_COMPONENT . '/helpers/html.php';
require_once IG_ADMINISTRATOR_COMPONENT . '/helpers/file.php';
require_once IG_ADMINISTRATOR_COMPONENT . '/helpers/upload.php';
require_once IG_ADMINISTRATOR_COMPONENT . '/helpers/general.php';
require_once IG_ADMINISTRATOR_COMPONENT . '/helpers/tree.php';
require_once IG_ADMINISTRATOR_COMPONENT . '/helpers/static.php';
require_once IG_COMPONENT . '/helpers/utility.php';
require_once IG_ADMINISTRATOR_COMPONENT . '/models/base.php';
if (!IG_J30) {
    require_once JPATH_LIBRARIES . '/joomla/application/web/webclient.php';
}
//make the base folders if needed
igFileHelper::makeFolder(IG_IMAGE_PATH);
igFileHelper::makeFolder(IG_TEMP_PATH);
igFileHelper::makeFolder(IG_ORIG_PATH);
igFileHelper::makeFolder(IG_RESIZE_PATH);
igFileHelper::makeFolder(IG_WATERMARK_PATH);
Ejemplo n.º 17
0
 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;
 }
Ejemplo n.º 18
0
 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);
 }