Пример #1
0
 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);
     }
 }
Пример #2
0
/**
 * 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);
        }
    }
}
Пример #3
0
    function showResults($result, $searchtext)
    {
        global $rsgConfig;
        html_rsg2_search::showSearchBox();
        //Format number of hits
        $count = count($result);
        $count = "<span style=\"font-weight:bold;\">" . $count . "</span>";
        ?>
		<table width="100%" style="border-bottom: thin solid #CCCCCC;">
		<tr>
			<td><div align="right"><a href="index.php?option=com_rsgallery2"><?php 
        echo JText::_('Main gallery page');
        ?>
</a></div></td>
		</tr>
		<tr>
			<td><h3><?php 
        echo JText::_('RSGallery2 Search Results');
        ?>
</h3></td>
		</tr>
		<tr>
			<td>
				<span style="font-style:italic;">
				<?php 
        echo JText::_('There are ') . $count . JText::_(' results for ');
        ?>
					<span style="font-weight:bold;";><?php 
        echo $searchtext;
        ?>
</span>
				<span>
			</td>
		</tr>
		</table>
		<br />
		<?php 
        if ($result) {
            foreach ($result as $match) {
                ?>
				<table width="100%" border="0" style="border-bottom: thin solid #CCCCCC;">
				<tr>
					<td width="<?php 
                echo $rsgConfig->get('thumb_width');
                ?>
">
					<div class="img-shadow">
						<a href="index.php?option=com_rsgallery2&page=inline&id=<?php 
                echo $match->item_id;
                ?>
">
						<img border="0" src="<?php 
                echo JURI_SITE . $rsgConfig->get('imgPath_thumb') . "/" . imgUtils::getImgNameThumb($match->itemname);
                ?>
" alt="image" />
						</a>
					</div>
					</td>
					<td valign="top">
						<a href="index.php?option=com_rsgallery2&page=inline&id=<?php 
                echo $match->item_id;
                ?>
">
							<span style="font-weight:bold;"><?php 
                echo galleryUtils::highlight_keywords($match->title, $searchtext);
                ?>
</span>
						</a>
						<p><?php 
                echo galleryUtils::highlight_keywords($match->descr, $searchtext);
                ?>
</p>
						<p style="color: #999999;font-size:10px;">
				[<?php 
                echo JText::_('Gallery name');
                ?>
:<a href="<?php 
                echo JRoute::_("index.php?option=com_rsgallery2&gid=" . $match->gallery_id);
                ?>
"><?php 
                echo $match->name;
                ?>
</a>]
							<?php 
                if ($match->userid > 0) {
                    echo "[" . JText::_('Owner') . ":&nbsp;" . galleryUtils::genericGetUsername($match->userid) . "]";
                }
                ?>
						</p>
					</td>
				</tr>
				</table>
				<br />
				<?php 
            }
        }
    }
Пример #4
0
/**
* 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!'));
}
Пример #5
0
 /**
  * @param string name of the image
  * @param boolean return a local path instead of URL
  * @return complete URL of the image
  */
 function getImgThumb($name, $local = false)
 {
     global $rsgConfig, $mainframe;
     $locale = $local ? JPATH_ROOT : JURI_SITE;
     $locale = trim($locale, '/');
     // if thumb image exists return that, otherwise the original image width <= $thumb_width so we return the original image instead.
     if (file_exists(JPATH_ROOT . $rsgConfig->get('imgPath_thumb') . '/' . imgUtils::getImgNameThumb($name))) {
         return $locale . $rsgConfig->get('imgPath_thumb') . '/' . rawurlencode(imgUtils::getImgNameThumb($name));
     } else {
         return $locale . $rsgConfig->get('imgPath_original') . '/' . rawurlencode($name);
     }
 }