function _determineResources() { global $rsgConfig; $gallery_path = $this->gallery->getPath("/"); $thumb = $rsgConfig->get('imgPath_thumb') . $gallery_path . imgUtils::getImgNameThumb($this->name); $display = $rsgConfig->get('imgPath_display') . $gallery_path . imgUtils::getImgNameDisplay($this->name); $original = $rsgConfig->get('imgPath_original') . $gallery_path . $this->name; if (file_exists(JPATH_ROOT . $original)) { // original image exists $this->original = new rsgResource($original); } else { // original image does not exist, therefore display and thumb MUST exist $this->display = new rsgResource($display); $this->thumb = new rsgResource($thumb); $this->original =& $this->display; return; } // if original was smaller than thumb or display those won't exist if (!file_exists(JPATH_ROOT . $thumb)) { $this->thumb =& $this->original; $this->display =& $this->original; } elseif (!file_exists(JPATH_ROOT . $display)) { $this->thumb = new rsgResource($thumb); $this->display =& $this->original; } else { $this->thumb = new rsgResource($thumb); $this->display = new rsgResource($display); } }
/** * Used in the consolidate database function * Creates images based on an image id or an image name */ function regenerateImage() { global $mainframe; global $rsgConfig; $database =& JFactory::getDBO(); //Check if id or name is set if (isset($_REQUEST['id'])) { $id = rsgInstance::getInt('id', null); $name = galleryUtils::getFileNameFromId($id); } elseif (isset($_REQUEST['name'])) { $name = rsgInstance::getVar('name', null); } else { $mainframe->redirect("index2.php?option=com_rsgallery2&task=batchupload", JText::_('No fileinformation found. This should never happen!')); } //Just for readability of code $original = JPATH_ORIGINAL . '/' . $name; $display = JPATH_DISPLAY . '/' . imgUtils::getImgNameDisplay($name); $thumb = JPATH_THUMB . '/' . imgUtils::getImgNameThumb($name); if (file_exists($original)) { //Check if display image exists, if not make it. if (!file_exists($display)) { imgUtils::makeDisplayImage($original, NULL, $rsgConfig->get('image_width')); } if (!file_exists($thumb)) { imgUtils::makeThumbImage($original); } } else { if (file_exists($display)) { copy($display, $original); } if (!file_exists($thumb)) { imgUtils::makeThumbImage($display); } } }
/** * Deletes one or more records * @param array An array of unique category id numbers * @param string The current url option */ function removeImages($cid, $option) { global $rsgOption, $rsgConfig, $mainframe; $database =& JFactory::getDBO(); $return = "index.php?option={$option}&rsgOption=images"; if (!is_array($cid) || count($cid) < 1) { echo "<script> alert('Select an item to delete'); window.history.go(-1);</script>\n"; exit; } //Delete images from filesystem if (count($cid)) { //Delete images from filesystem foreach ($cid as $id) { $name = galleryUtils::getFileNameFromId($id); $thumb = JPATH_ROOT . $rsgConfig->get('imgPath_thumb') . '/' . imgUtils::getImgNameThumb($name); $display = JPATH_ROOT . $rsgConfig->get('imgPath_display') . '/' . imgUtils::getImgNameDisplay($name); $original = JPATH_ROOT . $rsgConfig->get('imgPath_original') . '/' . $name; if (file_exists($thumb)) { if (!JFile::delete($thumb)) { JError::raiseNotice('ERROR_CODE', JText::_('ERROR DELETING THUMB IMAGE') . " " . $thumb); $mainframe->redirect($return); return; } } if (file_exists($display)) { if (!JFile::delete($display)) { JError::raiseNotice('ERROR_CODE', JText::_('ERROR DELETING DISPLAY IMAGE') . " " . $display); $mainframe->redirect($return); return; } } if (file_exists($original)) { if (!JFile::delete($original)) { JError::raiseNotice('ERROR_CODE', JText::_('ERROR DELETING ORIGINAL IMAGE') . " " . $original); $mainframe->redirect($return); return; } } } //Delete from database $cids = implode(',', $cid); $query = "DELETE FROM #__rsgallery2_files" . "\n WHERE id IN ( {$cids} )"; $database->setQuery($query); if (!$database->query()) { echo "<script> alert('" . $database->getErrorMsg() . "'); window.history.go(-1); </script>\n"; } } $mainframe->redirect($return, JText::_('Image(s) deleted succesfully!')); }
* @version $Id: slideshow.rsgallery2.php 1010 2011-01-26 15:26:17Z mirjam $ * @package RSGallery2 * @copyright (C) 2003 - 2006 RSGallery2 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL * RSGallery is Free Software **/ defined('_JEXEC') or die; global $rsgConfig, $name, $mainframe, $imagepath; $imagepath = $rsgConfig->get('imgPath_display'); $k = 0; $text = ""; foreach ($rows as $row) { if ($k == 0) { $name = $row->name; } $name = imgUtils::getImgNameDisplay($row->name); $id = $row->id; $text .= "SLIDES[" . $k . "] = [\"JURI_SITE{$imagepath}/{$name}\", \"{$row->title}\"];\n"; $k++; } ?> <table class="rsg2_slideshow" border="0" cellpadding="3" cellspacing="0"> <form name="_slideShow"> <input type="Hidden" name="currSlide" value="0"> <input type="Hidden"name="delay"> <tr> <td align="center"> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr> <td align="center">
/** * @param string name of the image * @param boolean return a local path instead of URL * @return complete URL of the image */ function getImgDisplay($name, $local = false) { global $rsgConfig, $mainframe; $locale = $local ? JPATH_ROOT : JURI_SITE; $locale = trim($locale, '/'); // if display image exists return that, otherwise the original image width <= $display_width so we return the original image instead. if (file_exists(JPATH_ROOT . $rsgConfig->get('imgPath_display') . '/' . imgUtils::getImgNameDisplay($name))) { return $locale . $rsgConfig->get('imgPath_display') . '/' . rawurlencode(imgUtils::getImgNameDisplay($name)); } else { return $locale . $rsgConfig->get('imgPath_original') . '/' . rawurlencode($name); } }