/** * returns a gallery * @param id of the gallery * @todo move published check to rsgAccess */ function get($id = null) { global $rsgAccess, $rsgConfig; $my =& JFactory::getUser(); if ($id === null) { $id = rsgInstance::getInt('catid', 0); $id = rsgInstance::getInt('gid', $id); if (!$id) { // check if an item id is set and if so return the gallery for that item id if (rsgInstance::getInt('id', 0)) { return rsgGalleryManager::getGalleryByItemID(); } } } // since the user will never be offered the chance to view a gallery they can't, unauthorized attempts at viewing are a hacking attempt, so it is ok to print an unfriendly error. $rsgAccess->checkGallery('view', $id) or die("RSGallery2: Access denied to gallery {$id}"); $gallery = rsgGalleryManager::_get($id); // if gallery is unpublished don't show it unless ACL is enabled and users has permissions to modify (owners can view their unpublished galleries). if ($gallery->get('published') < 1) { // if user is admin or superadmin then always return the gallery if ($my->gid > 23) { return $gallery; } if ($rsgConfig->get('acl_enabled')) { if (!$rsgAccess->checkGallery('create_mod_gal', $id)) { die("RSGallery2: Access denied to gallery {$id}"); } } else { die("RSGallery2: Access denied to gallery {$id}"); } } return $gallery; }
function saveVote($option) { global $rsgConfig, $mainframe; $database = JFactory::getDBO(); $my = JFactory::getUser(); if ($rsgConfig->get('voting') < 1) { $mainframe->redirect(JRoute::_("index.php?option=com_rsgallery2"), JText::_('Voting is disabled!')); } else { $rating = rsgInstance::getInt('rating', ''); $id = rsgInstance::getInt('id', ''); $vote = new rsgVoting(); //Check if user can vote if (!$vote->voteAllowed()) { $mainframe->redirect(JRoute::_("index.php?option=com_rsgallery2&page=inline&id={$id}"), JText::_('You are not authorized to vote!')); } //Check if user has already voted for this image if ($vote->alreadyVoted($id)) { $mainframe->redirect(JRoute::_("index.php?option=com_rsgallery2&page=inline&id={$id}"), JText::_('You already voted for this item!')); } //All checks OK, store vote in DB $total = $vote->getTotal($id) + $rating; $votecount = $vote->getVoteCount($id) + 1; $sql = "UPDATE #__rsgallery2_files SET rating = '{$total}', votes = '{$votecount}' WHERE id = '{$id}'"; $database->setQuery($sql); if (!$database->query()) { $msg = JText::_('Vote could not be added to the database!'); } else { $msg = JText::_('Vote added to database!'); //Store cookie on system setcookie($rsgConfig->get('cookie_prefix') . $id, $my->id, time() + 60 * 60 * 24 * 365, "/"); } $mainframe->redirect(JRoute::_("index.php?option=com_rsgallery2&page=inline&id={$id}"), $msg); } }
function showResults() { $database = JFactory::getDBO(); //Retrieve search string $searchtext = rsgInstance::getVar('searchtext', ''); //Check searchtext against database $sql = "SELECT *, a.name as itemname, a.id as item_id FROM #__rsgallery2_files as a, #__rsgallery2_galleries as b " . "WHERE a.gallery_id = b.id " . "AND (" . "a.title LIKE '%{$searchtext}%' OR " . "a.descr LIKE '%{$searchtext}%'" . ") " . "AND a.published = 1 " . "AND b.published = 1 " . "GROUP BY a.id " . "ORDER BY a.id DESC"; $database->setQuery($sql); $result = $database->loadObjectList(); //show results html_rsg2_search::showResults($result, $searchtext); }
function xmlFile() { $template = preg_replace('#\\W#', '', rsgInstance::getVar('xmlTemplate', 'meta')); $template = strtolower($template); // require generic template which all other templates should extend require_once JPATH_RSGALLERY2_SITE . '/templates/meta/xml.php'; // require the template specified to be used require_once JPATH_RSGALLERY2_SITE . '/templates/' . $template . '/xml.php'; // prepare and output xml $xmlTemplate = "rsgXmlGalleryTemplate_{$template}"; $xmlTemplate = new $xmlTemplate(rsgInstance::getGallery()); ob_start(); $xmlTemplate->prepare(); $content = ob_get_clean(); $xmlTemplate->printHead(); echo $content; die; // quit now so that only the xml is sent and not the joomla template // this is a saftey measure that should not be needed }
function batchupload_2($ziplist, $extractDir) { /* Info for javascript on input element names and values: Step 2 Button: Upload --> task=save_batchupload Delete checkbox name: delete[1] Item title field name: ptitle[] Gallery select name: category[] Description area name: descr[] */ global $rsgOption; JHTML::_('behavior.mootools'); $database = JFactory::getDBO(); //Get variables from form $selcat = rsgInstance::getInt('selcat', null); $ftppath = rsgInstance::getVar('ftppath', null); $xcat = rsgInstance::getInt('xcat', null); $batchmethod = rsgInstance::getVar('batchmethod', null); ?> <script language="javascript" type="text/javascript"> <!-- function submitbutton(pressbutton) { var form = document.adminForm, missingCat = false, categories = $$('#adminForm input[name^=category]', '#adminForm select[name^=category]'); for (i=0 ; i<categories.length ; i++) { if (categories[i].value <= 0) { alert("<?php echo JText::_('All images must be part of a galery'); ?> "+' (#'+i+')'); return; missingCat = true; break; } } if (pressbutton == 'save_batchupload'){ if (missingCat == true) { alert("<?php echo JText::_('All images must be part of a galery'); ?> "); } else { form.submit(); } } } //--> </script> <form action="index2.php" method="post" name="adminForm" id="adminForm"> <table class="adminform"> <tr> <th colspan="5" class="sectionname"><font size="4"><?php echo JText::_('Step 2'); ?> </font></th> </tr> <tr> <?php // Initialize k (the column reference) to zero. $k = 0; $i = 0; foreach ($ziplist as $filename) { $k++; //Check if filename is dir if (is_dir(JPATH_ROOT . '/media/' . $extractDir . '/' . $filename)) { continue; } else { //Check if file is allowed $allowed_ext = array('gif', 'jpg', 'png'); $allowedVideo_ext = array('flv', 'avi', 'mov'); $ext = fileHandler::getImageType(JPATH_ROOT . '/media/' . $extractDir . '/' . $filename); if (in_array($ext, $allowedVideo_ext)) { // build preview image $basePath = JPATH_SITE . '/media/' . $extractDir . '/'; require_once JPATH_RSGALLERY2_ADMIN . 'includes/video.utils.php'; Ffmpeg::capturePreviewImage($basePath . $filename, $basePath . $filename . '.png'); $displayImage = $filename . '.png'; $i++; } else { if (!in_array($ext, $allowed_ext)) { continue; } else { $displayImage = $filename; $i++; } } } ?> <td align="center" valign="top" bgcolor="#CCCCCC"> <table class="adminform" border="0" cellspacing="1" cellpadding="1"> <tr> <th colspan="2"> </th> </tr> <tr> <td colspan="2" align="right"><?php echo JText::_('Delete'); ?> #<?php echo $i - 1; ?> : <input type="checkbox" name="delete[<?php echo $i - 1; ?> ]" value="true" /></td> </tr> <tr> <td align="center" colspan="2"><img src="<?php echo JURI_SITE . "/media/" . $extractDir . "/" . $displayImage; ?> " alt="" border="1" width="100" align="center" /></td> </tr> <input type="hidden" value="<?php echo $filename; ?> " name="filename[]" /> <tr> <td><?php echo JText::_('Title'); ?> </td> <td> <input type="text" name="ptitle[]" size="15" /> </td> </tr> <tr> <td><?php echo JText::_('Gallery'); ?> </td> <td><?php if ($selcat == 1 && $xcat !== '0') { ?> <input type="text" name="cat_text" value="<?php echo htmlspecialchars(stripslashes(galleryUtils::getCatnameFromId($xcat))); ?> " readonly /> <input type="hidden" name="category[]" value="<?php echo $xcat; ?> " /> <?php } else { echo galleryUtils::galleriesSelectList(null, 'category[]', false); } ?> </td> </tr> <tr> <td><?php echo JText::_('Description'); ?> </td> <td><textarea cols="15" rows="2" name="descr[]"></textarea></td> </tr> </table> </td> <?php if ($k == 5) { echo "</tr><tr>"; $k = 0; } } ?> </table> <input type="hidden" name="teller" value="<?php echo $i; ?> " /> <input type="hidden" name="extractdir" value="<?php echo $extractDir; ?> " /> <input type="hidden" name="option" value="com_rsgallery2" /> <input type="hidden" name="rsgOption" value="<?php echo $rsgOption; ?> " /> <input type="hidden" name="task" value="save_batchupload" /> </form> <?php }
<?php defined('_JEXEC') or die('Restricted access'); JHTML::_('behavior.mootools'); $item = $this->currentItem; $templatePath = JURI_SITE . "components/com_rsgallery2/templates/" . rsgInstance::getVar('rsgTemplate', $rsgConfig->get('template')); $jsSwf = ' window.addEvent("domready", function() { var flashvars = {movie:"' . $item->display->url() . '", fgcolor: "0x000000", bgcolor: "0x000000", autoload: "on", autorewind: "on", volume: "70"}; swfobject.embedSWF("' . JURI_SITE . '/components/com_rsgallery2/flash/player.swf", "rsg2-flashMovie", "320", "240", "7", "' . JURI_SITE . '/components/com_rsgallery2/flash/expressInstall.swf", flashvars, { wmode: "transparent", loop:false, autoPlay:true } ); });'; $doc =& JFactory::getDocument(); $doc->addScriptDeclaration($jsSwf); $doc->addScript(JURI_SITE . '/components/com_rsgallery2/flash/script/swfobject.js'); ?> <div id="rsg2-flashMovie"><p><?php echo JText::_("The movie should appear here."); ?> </p></div>
/** * asks user to choose what files to upload */ function showUploadStep3() { $catid = rsgInstance::getInt('catid', null); $uploadstep = rsgInstance::getInt('uploadstep', null); $numberOfUploads = rsgInstance::getInt('numberOfUploads', null); ?> <script language="javascript" type="text/javascript"> function submitbutton(pressbutton) { var form = document.form3; form.submit(); } </script> <form name="form3" action="index2.php?option=com_rsgallery2&task=upload" method="post" enctype="multipart/form-data"> <input type="hidden" name="uploadStep" value="4" /> <input type="hidden" name="catid" value="<?php echo $catid; ?> " /> <input type="hidden" name="numberOfUploads" value="<?php echo $numberOfUploads; ?> " /> <table width="100%"> <tr> <td width="300"> </td> <td> <table class="adminform"> <tr> <th colspan="2"><font size="4"><?php echo JText::_('Step 3'); ?> </font></td> </tr> <?php for ($t = 1; $t < $numberOfUploads + 1; $t++) { ?> <tr> <td colspan="2"> <table width="100%" cellpadding="1" cellspacing="1"> <tr> <td colspan="2"><strong><?php echo JText::_('Image'); echo " " . $t; ?> </strong></td> </tr> <tr> <td><?php echo JText::_('Gallery name'); ?> :</td> <td><strong><?php echo galleryUtils::getCatnameFromId($catid); ?> </strong></td> </tr> <tr> <td valign="top" width="100"><?php echo JText::_('Title') . " " . $t; ?> :</td> <td> <input name="imgTitle[]" type="text" class="inputbox" size="40" /> </td> </tr> <tr> <td valign="top"><?php echo JText::_('File') . " " . $t; ?> :</td> <td> <input class="inputbox" name="images[]" type="file" size="30" /> </td> </tr> <tr> <td valign="top"><?php echo JText::_('Description') . " " . $t; ?> </td> <td> <textarea class="inputbox" cols="35" rows="3" name="descr[]"></textarea> </td> </tr> <tr class="row1"> <th colspan="2"> </th> </tr> </table> </td> </tr> <?php } ?> </table> </td> <td width="300"> </td> </tr> </table> </form> <?php }
function save_batchupload() { global $rsgConfig, $mainframe; $database = JFactory::getDBO(); //Try to bypass max_execution_time as set in php.ini set_time_limit(0); $FTP_path = $rsgConfig->get('ftp_path'); $teller = rsgInstance::getInt('teller', null); $delete = rsgInstance::getVar('delete', null); $filename = rsgInstance::getVar('filename', null); $ptitle = rsgInstance::getVar('ptitle', null); $descr = rsgInstance::getVar('descr', array(0)); $extractdir = rsgInstance::getVar('extractdir', null); //Check if all categories are chosen if (isset($_REQUEST['category'])) { $category = rsgInstance::getVar('category', array(0)); } else { $category = array(0); } if (in_array('0', $category) || in_array('-1', $category)) { $mainframe->redirect("index2.php?option=com_rsgallery2&task=batchupload", JText::_('_RSGALLERY_ALERT_NOCATSELECTED')); } for ($i = 0; $i < $teller; $i++) { //If image is marked for deletion, delete and continue with next iteration if (isset($delete[$i]) and $delete[$i] == 'true') { //Delete file from server unlink(JPATH_ROOT . "/media/" . $extractdir . '/' . $filename[$i]); continue; } else { //Setting variables for importImage() $imgTmpName = JPATH_ROOT . "/media/" . $extractdir . '/' . $filename[$i]; $imgName = $filename[$i]; $imgCat = $category[$i]; $imgTitle = $ptitle[$i]; $imgDesc = $descr[$i]; //Import image $e = imgUtils::importImage($imgTmpName, $imgName, $imgCat, $imgTitle, $imgDesc); //Check for errors if ($e !== true) { $errors[] = $e; } } } //Clean up mediadir fileHandler::cleanMediaDir($extractdir); // Error handling if (isset($errors)) { if (count($errors) == 0) { echo JText::_('Item uploaded succesfully!'); } else { foreach ($errors as $err) { echo $err->toString(); } } } else { //Everything went smoothly, back to Control Panel global $mainframe; $mainframe->redirect("index2.php?option=com_rsgallery2", JText::_('Item uploaded succesfully!')); } }
/** * @todo if thumbname size has changed, advise user to regenerate thumbs */ function saveConfig() { global $rsgConfig; $rsgConfig = new rsgConfig(); if ($rsgConfig->saveConfig($_REQUEST)) { HTML_RSGALLERY::printAdminMsg(JText::_('Configuration Saved')); // save successful, try creating some image directories if we were asked to if (rsgInstance::getVar('createImgDirs')) { HTML_RSGALLERY::printAdminMsg(JText::_('Creating Image directories not Implemented yet.'), true); } } else { HTML_RSGALLERY::printAdminMsg(JText::_('Error Saving Configuration')); } }
/** * Method to get a pagination object for the the gallery items * * @access public * @return integer */ function getPagination() { // Lets load the content if it doesn't already exist if (empty($this->_pagination)) { jimport('joomla.html.pagination'); $this->_pagination = new JPagination($this->itemCount(), rsgInstance::getInt('limitstart', 0), rsgInstance::getInt('limit', 1)); } return $this->_pagination; }
function deleteCat() { global $rsgConfig, $mainframe; $my = JFactory::getUser(); $database = JFactory::getDBO(); //Get values from URL $catid = rsgInstance::getInt('gid', null); //Mirjam: catid is gid as of v1.14 //Set redirect URL $redirect = JRoute::_("index.php?option=com_rsgallery2&rsgOption=myGalleries", false); //Get category details $database->setQuery("SELECT * FROM #__rsgallery2_galleries WHERE id = '{$catid}'"); $rows = $database->LoadObjectList(); foreach ($rows as $row) { $uid = $row->uid; $parent = $row->parent; } //Check if gallery has children $database->setQuery("SELECT COUNT(1) FROM #__rsgallery2_galleries WHERE parent = '{$catid}'"); $count = $database->loadResult(); if ($count > 0) { $mainframe->redirect($redirect, JText::_('USERCAT_SUBCATS')); } //No children from here, so lets continue if ($uid == $my->id or $my->usertype == 'Super Administrator') { //Delete images $database->setQuery("SELECT name FROM #__rsgallery2_files WHERE gallery_id = '{$catid}'"); $result = $database->loadResultArray(); $error = 0; foreach ($result as $filename) { if (!imgUtils::deleteImage($filename)) { $error++; } } //Error checking if ($error == 0) { //Gallery can be deleted $database->setQuery("DELETE FROM #__rsgallery2_galleries WHERE id = '{$catid}'"); if (!$database->query()) { //Error message, gallery could not be deleted $mainframe->redirect($redirect, JText::_('Gallery could not be deleted!')); } else { //Ok, goto mainpage $mainframe->redirect($redirect, JText::_('Gallery deleted!')); } } else { //There were errors. Gallery will not be deleted $mainframe->redirect($redirect, JText::_('Gallery could not be deleted!')); } } else { //Abort and return to mainscreen $mainframe->redirect($redirect, JText::_('USER_CAT_NOTOWNER')); } }
function set($array, $hash = 'default', $overwrite = true) { foreach ($array as $key => $value) { rsgInstance::setVar($key, $value, $hash, $overwrite); } }
/** * Publishes or Unpublishes one or more records * @param array An array of unique category id numbers * @param integer 0 if unpublishing, 1 if publishing * @param string The current url option */ function publish($cid = null, $publish = 1, $option) { global $rsgOption, $mainframe; $database =& JFactory::getDBO(); $my =& JFactory::getUser(); $catid = rsgInstance::getInt('catid', array(0)); if (!is_array($cid) || count($cid) < 1) { $action = $publish ? 'publish' : 'unpublish'; echo "<script> alert('Select an item to {$action}'); window.history.go(-1);</script>\n"; exit; } $cids = implode(',', $cid); $query = "UPDATE #__rsgallery2_galleries" . "\n SET published = " . intval($publish) . "\n WHERE id IN ( {$cids} )" . "\n AND ( checked_out = 0 OR ( checked_out = {$my->id} ) )"; $database->setQuery($query); if (!$database->query()) { echo "<script> alert('" . $database->getErrorMsg() . "'); window.history.go(-1); </script>\n"; exit; } if (count($cid) == 1) { $row = new rsgGalleriesItem($database); $row->checkin($cid[0]); } $mainframe->redirect("index2.php?option={$option}&rsgOption={$rsgOption}"); }
/** * 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); } } }
/** * Provides unformatted EXIF data for the current item * @result Array with EXIF values */ function _showEXIF() { require_once JPATH_ROOT . "/components/com_rsgallery2/lib/exifreader/exifReader.php"; $image = rsgInstance::getItem(); $filename = JPATH_ROOT . $image->original->name; $exif = new phpExifReader($filename); $exif->showFormattedEXIF(); }
<?php /** * Prep for slideshow * @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('Restricted Access'); // bring in display code $templatePath = JPATH_RSGALLERY2_SITE . '/templates/slideshowone'; require_once $templatePath . '/display.class.php'; $rsgDisplay = new rsgDisplay_slideshowone(); $rsgDisplay->cleanStart = rsgInstance::getBool('cleanStart'); $rsgDisplay->showSlideShow();
/** * Must have debug enabled to use this template. Lists all galleries and items. * @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('Restricted Access'); // bring in display code $templatePath = JPATH_RSGALLERY2_SITE . '/templates/debug_listeverything'; require_once $templatePath . '/display.class.php'; global $mainframe; $template_dir = "JURI_SITE/components/com_rsgallery2/templates/debug_listeverything"; ?> <link href="<?php echo $template_dir; ?> /css/template.css" rel="stylesheet" type="text/css" /> <?php $gid = rsgInstance::getInt('gid', 0); echo "Listing contents of Gallery #{$gid}"; switch (rsgInstance::getCmd('task', 'listEverything')) { case 'dumpGallery': dumpGallery($gid); break; case 'listEverything': default: listEverything($gid); break; }
/** * Show description */ function _showDescription() { global $rsgConfig; $item = rsgInstance::getItem(); if ($rsgConfig->get('displayHits')) { ?> <p class="rsg2_hits"><?php echo JText::_('Hits'); ?> <span><?php echo $item->hits; ?> </span></p> <?php } if ($item->descr) { ?> <p class="rsg2_description"><?php echo stripslashes($item->descr); ?> </p> <?php } }
/** * Shows the form for the */ function editComment($item_id) { global $rsgConfig, $mainframe; $my =& JFactory::getUser(); /* JPATH_SITE is only there to accomodate SecurityImages for now*/ $doc =& JFactory::getDocument(); $doc->addScript(JURI_SITE . "/components/com_rsgallery2/lib/rsgcomments/js/client.js"); $doc->addStyleSheet(JURI_SITE . "/components/com_rsgallery2/lib/rsgcomments/rsgcomments.css"); if (!$rsgConfig->get('comment_allowed_public')) { if (!$my->id) { return; } } ?> <script type="text/javascript"> function submitbutton(pressbutton) { var form = document.rsgcommentform; if (pressbutton == 'cancel') { form.reset(); return; } // do field validation if (form.tname.value == "") { alert( '<?php echo JText::_('You should enter your name'); ?> ' ); } else if (form.tcomment.value == ""){ alert( '<?php echo JText::_('No comment entered'); ?> ' ); } else{ form.submit(); } } </script> <form name="rsgcommentform" method="post" action="<?php echo JRoute::_("index.php?option=com_rsgallery2&rsgOption=rsgComments&task=save"); ?> "> <table border="0" width="100%" class="adminForm"> <tr> <td colspan="2"><h2><?php echo JText::_('Add Comment'); ?> </h2></td> </tr> <tr> <td><?php echo JText::_('Your Name'); ?> :</td> <td><input name='tname' type='text' class='inputbox' size='40' value='<?php if (!$my->username == '') { echo $my->username; } ?> ' /></td> </tr> <tr> <td><?php echo JText::_('Title'); ?> :</td> <td><input name='ttitle' type='text' class='inputbox' size='40'/></td> </tr> <tr> <td><?php echo JText::_('Comment text'); ?> :</td> <td><div class='buttoncontainer'><?php rsgComments::showButtons(); ?> </div></td> </tr> <tr> <td><?php rsgComments::showSmilies(); ?> </td> <td><textarea name='tcomment' class='inputbox' cols='40' rows='10'></textarea></td> </tr> <tr> <td> </td> <td> <?php //Implement security images only for if ($rsgConfig->get('comment_security') == 1) { ?> <img src="<?php echo JRoute::_("index.php?option=com_securityimages&task=displayCaptcha"); ?> "> <br /> <?php echo JText::_('Enter what you see in the image above:'); ?> <input type="text" name="securityImageRSGallery2" /> <?php } ?> </td> </tr> <tr> <td> </td> <td align="center"> <input type="button" class="button" value="<?php echo JText::_('COM_RSGALLERY2_POST'); ?> " onclick="submitbutton('save')" /> </td> </tr> </table> <input type="hidden" name="item_id" value="<?php echo $item_id; ?> " /> <input type="hidden" name="rsgOption" value="rsgComments" /> <input type="hidden" name="catid" value="<?php echo rsgInstance::getInt('catid', null); ?> " /> </form> <a name="comment2"></a> <?php }
<?php /** * Initialize default instance of RSGallery2 * @version $Id: 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; // initialize RSG2 core functionality require_once JPATH_ADMINISTRATOR . "/components/com_rsgallery2/init.rsgallery2.php"; // create a new instance of RSGallery2 rsgInstance::instance();
/** * Writes the edit form for new and existing record * * A new record is defined when <var>$row</var> is passed with the <var>id</var> * property set to 0. * @param rsgGallery The gallery object * @param array An array of select lists * @param object Parameters * @param string The option */ function edit(&$row, &$lists, &$params, $option) { global $rsgOption, $rsgAccess, $rsgConfig; jimport("joomla.filter.output"); $my =& JFactory::getUser(); $editor =& JFactory::getEditor(); JFilterOutput::objectHTMLSafe($row, ENT_QUOTES); $task = rsgInstance::getVar('task', ''); JHTML::_('behavior.formvalidation'); JHTML::_("Behavior.mootools"); ?> <script type="text/javascript"> function submitbutton(pressbutton) { var form = document.adminForm; if (pressbutton == 'cancel') { submitform( pressbutton ); return; } // do field validation if (form.name.value == ""){ alert("<?php echo JText::_('YOU MUST PROVIDE A GALLERY NAME.'); ?> "); } else { <?php echo $editor->save('description'); ?> submitform( pressbutton ); } } function selectAll() { if(document.adminForm.checkbox0.checked) { for (i = 0; i < 12; i++) { document.getElementById('p' + i).checked=true; } } else { for (i = 0; i < 12; i++) { document.getElementById('p' + i).checked=false; } } } </script> <form action="index2.php" method="post" name="adminForm" id="adminForm" class="form-validate"> <table class="adminheading"> <tr> <th> <?php echo JText::_('Gallery'); ?> : <small> <?php echo $row->id ? 'Edit' : 'New'; ?> </small> </th> </tr> </table> <table width="100%"> <tr> <td width="60%" valign="top"> <table class="adminform"> <tr> <th colspan="2"> <?php echo JText::_('Details'); ?> </th> </tr> <tr> <td width="20%" align="right"> <?php echo JText::_('Name'); ?> </td> <td width="80%"> <input class="text_area required" type="text" name="name" size="50" maxlength="250" value="<?php echo stripslashes($row->name); ?> " /> </td> </tr> <tr> <td width="20%" align="right"> <?php echo JText::_('COM_RSGALLERY2_ALIAS'); ?> </td> <td width="80%"> <input class="text_area" type="text" name="alias" size="50" maxlength="250" value="<?php echo stripslashes($row->alias); ?> " /> </td> </tr> <tr> <td align="right"> <?php echo JText::_('Owner'); ?> </td> <td> <?php echo $lists['uid']; ?> </td> </tr> <tr> <td valign="top" align="right"> <?php echo JText::_('Description'); ?> </td> <td> <?php // parameters : areaname, content, hidden field, width, height, rows, cols echo $editor->display('description', stripslashes($row->description), '100%', '300', '10', '20', false); ?> </td> </tr> <tr> <td align="right"> <?php echo JText::_('Parent Item'); ?> </td> <td> <?php echo $lists['parent']; ?> </td> </tr> <tr> <td valign="top" align="right"> <?php echo JText::_('Gallery thumbnail'); ?> </td> <td> <?php echo imgUtils::showThumbNames($row->id, $row->thumb_id); ?> </td> </tr> <tr> <td valign="top" align="right"> <?php echo JText::_('Ordering'); ?> </td> <td> <?php echo $lists['ordering']; ?> </td> </tr> <tr> <td valign="top" align="right"> <?php echo JText::_('Published'); ?> </td> <td> <?php echo $lists['published']; ?> </td> </tr> </table> </td> <td width="40%" valign="top"> <table class="adminform"> <tr> <th colspan="1"> <?php echo JText::_('Parameters'); ?> </th> </tr> <tr> <td> <?php echo $params->render(); ?> </td> </tr> </table><br/> <table class="adminform"> <?php if ($rsgConfig->get('acl_enabled')) { ?> <tr> <th colspan="1"><?php echo JText::_('Permissions'); ?> </th> </tr> <?php if (!isset($row->id)) { ?> <tr> <td><?php echo JText::_('_RSGALLERY_GAL_DEF_PERM_CREATE'); ?> </td> </tr> <?php } else { $perms = $rsgAccess->returnPermissions($row->id); if (!$perms) { ?> <tr> <td colspan="6"><?php echo JText::_('RSGALLERY_GAL_NO_PERM_FOUND'); ?> </td> </tr> <?php } else { ?> <tr> <td> <table class="adminform" border="0" width="100%"> <tr> <td valign="top" width="50"><span style="font-weight:bold;"><?php echo JText::_('Usertype'); ?> </span></td> <td valign="top" width="50"><span style="font-weight:bold;"><?php echo JText::_('View<br/>Gallery</span>'); ?> </td> <td valign="top" width="50"><span style="font-weight:bold;"><?php echo JText::_('Upload/Edit<br/>images</span>'); ?> </td> <td valign="top" width="50"><span style="font-weight:bold;"><?php echo JText::_('Delete Image</span>'); ?> </td> <td valign="top" width="50"><span style="font-weight:bold;"><?php echo JText::_('Modify<br/>Gallery</span>'); ?> </td> <td valign="top" width="50"><span style="font-weight:bold;"><?php echo JText::_('Delete<br/>Gallery</span>'); ?> </td> <td valign="top" width="50"><span style="font-weight:bold;"><?php echo JText::_('View votes'); ?> </td> <td valign="top" width="50"><span style="font-weight:bold;"><?php echo JText::_('Vote'); ?> </td> </tr> <tr> <td><span style="font-weight:bold;"><?php echo JText::_('Public</span>'); ?> </td> <td><input id="p0" type="checkbox" name="perm[0]" value="1" <?php if ($perms->public_view == 1) { echo "CHECKED"; } ?> ></td> <td><input id="p1" type="checkbox" name="perm[1]" value="1" <?php if ($perms->public_up_mod_img == 1) { echo "CHECKED"; } ?> ></td> <td><input id="p2" type="checkbox" name="perm[2]" value="1" <?php if ($perms->public_del_img == 1) { echo "CHECKED"; } ?> ></td> <td><input id="p3" type="checkbox" name="perm[3]" value="1" <?php if ($perms->public_create_mod_gal == 1) { echo "CHECKED"; } ?> ></td> <td><input id="p4" type="checkbox" name="perm[4]" value="1" <?php if ($perms->public_del_gal == 1) { echo "CHECKED"; } ?> ></td> <td><input id="p5" type="checkbox" name="perm[5]" value="1" <?php if ($perms->public_vote_view == 1) { echo "CHECKED"; } ?> ></td> <td><input id="p6" type="checkbox" name="perm[6]" value="1" <?php if ($perms->public_vote_vote == 1) { echo "CHECKED"; } ?> ></td> </tr> <tr> <td><span style="font-weight:bold;"><?php echo JText::_('Registered</span>'); ?> </td> <td><input id="p7" type="checkbox" name="perm[7]" value="1" <?php if ($perms->registered_view == 1) { echo "CHECKED"; } ?> ></td> <td><input id="p8" type="checkbox" name="perm[8]" value="1" <?php if ($perms->registered_up_mod_img == 1) { echo "CHECKED"; } ?> ></td> <td><input id="p9" type="checkbox" name="perm[9]" value="1" <?php if ($perms->registered_del_img == 1) { echo "CHECKED"; } ?> ></td> <td><input id="p10" type="checkbox" name="perm[10]" value="1" <?php if ($perms->registered_create_mod_gal == 1) { echo "CHECKED"; } ?> ></td> <td><input id="p11" type="checkbox" name="perm[11]" value="1" <?php if ($perms->registered_del_gal == 1) { echo "CHECKED"; } ?> ></td> <td><input id="p12" type="checkbox" name="perm[12]" value="1" <?php if ($perms->registered_vote_view == 1) { echo "CHECKED"; } ?> ></td> <td><input id="p13" type="checkbox" name="perm[13]" value="1" <?php if ($perms->registered_vote_vote == 1) { echo "CHECKED"; } ?> ></td> </tr> <tr> <td colspan="6"><input type="checkbox" name="checkbox0" value="true" onClick='selectAll()'><?php echo ' ' . JText::_('Select/Deselect All'); ?> </td> </tr> </table> </td> </tr> <?php } } } ?> </table> </td> </tr> </table> <input type="hidden" name="id" value="<?php echo $row->id; ?> " /> <input type="hidden" name="rsgOption" value="<?php echo $rsgOption; ?> " /> <input type="hidden" name="option" value="<?php echo $option; ?> " /> <input type="hidden" name="task" value="" /> </form> <?php }
function image_batchUpload() { JToolBarHelper::title(JText::_('Batch Upload'), 'generic.png'); if (rsgInstance::getVar('uploaded', null)) { JToolBarHelper::custom('save_batchupload', 'upload.png', 'upload.png', JText::_('Upload'), false); } else { JToolBarHelper::custom('batchupload', 'forward.png', 'forward.png', JText::_('Next'), false); } //JToolBarHelper::save('save_image'); //JToolBarHelper::cancel(); //JToolBarHelper::back(); JToolBarHelper::spacer(); JToolBarHelper::help('screen.rsgallery2', true); }
function showScore() { $item = rsgInstance::getItem(); $id = $item->id; require_once JPATH_RSGALLERY2_SITE . '/lib/rsgvoting/tmpl/result.php'; }
/** * Deletes a comment * @param array An array of unique comment id numbers * @param string The current url option */ function deleteComments($option) { global $mainframe; $database =& JFactory::getDBO(); // Get the current JUser object $user =& JFactory::getUser(); if ($user->get('gid') < 23) { die('Only admins can delete comments.'); } //Get parameters $id = rsgInstance::getInt('id', ''); $item_id = rsgInstance::getInt('item_id', ''); $catid = rsgInstance::getInt('catid', ''); if (!empty($id)) { $query = "DELETE FROM #__rsgallery2_comments WHERE id = '{$id}'"; $database->setQuery($query); if (!$database->query()) { echo "<script> alert('" . $database->getErrorMsg() . "'); window.history.go(-1); </script>\n"; } } $mainframe->redirect(JRoute::_("index.php?option=" . $option . "&page=inline&id=" . $item_id . "&catid=" . $catid), JText::_('Comment deleted succesfully')); }
/** * This function is called when you select batchupload from the backend. It * detects whether you choose ZIP or FTP and acts accordingly. * When you choose ZIP it unzips the file you upload to "/media" for further * handling, if you choose FTP it reads the files from the directory you uploaded * the files to and copies them to "/media".(this dir must be on the local server). * @todo Better error trapping * @todo Check FTP handling bit */ function batch_uploadX($option) { global $mainframe, $rsgConfig; $database = JFactory::getDBO(); $FTP_path = $rsgConfig->get('ftp_path'); //Retrieve data from submit form $batchmethod = rsgInstance::getVar('batchmethod', null); $uploaded = rsgInstance::getVar('uploaded', null); $selcat = rsgInstance::getInt('selcat', null); $zip_file = rsgInstance::getVar('zip_file', null, 'FILES'); $ftppath = rsgInstance::getVar('ftppath', null); $xcat = rsgInstance::getInt('xcat', null); //Check if a gallery exists, if not link to gallery creation $database->setQuery("SELECT id FROM #__rsgallery2_galleries"); $database->query(); if ($database->getNumRows() == 0) { HTML_RSGALLERY::requestCatCreation(); return; } //New instance of fileHandler $uploadfile = new fileHandler(); if (isset($uploaded)) { if ($batchmethod == "zip") { //Check if file is really a ZIP-file if (!eregi('.zip$', $zip_file['name'])) { $mainframe->redirect("index2.php?option=com_rsgallery2&task=batchupload", $zip_file['name'] . ' ' . JText::_('NO_VALID_ARCHIVE_ONLY_ZIP_ALLOWED')); } else { //Valid ZIP-file, continue if ($uploadfile->checkSize($zip_file) == 1) { $ziplist = $uploadfile->handleZIP($zip_file); } else { //Error message $mainframe->redirect("index2.php?option=com_rsgallery2&task=batchupload", JText::_('ZIP-file is too big!')); } } } else { $ziplist = $uploadfile->handleFTP($ftppath); } HTML_RSGALLERY::batch_upload_2($ziplist, $uploadfile->extractDir); } else { HTML_RSGALLERY::batch_upload($option); } }