function showSlideShow() { global $rsgConfig; $gallery = rsgGalleryManager::get(); // show nothing if there are no items if (!$gallery->itemCount()) { return; } $k = 0; $text = ""; foreach ($gallery->items() as $item) { if ($item->type != 'image') { return; } $display = $item->display(); $thumb = $item->thumb(); //The subtitleSelector for jd.gallery.js is p. This interferes with any //p-tags in the item desciption. Changing p tag to div.descr tag works for Firefox //but not for IE (tested IE7). So removing p tags from item description: $search[] = '<p>'; $search[] = '</p>'; $replace = ' '; $item->descr = str_replace($search, $replace, $item->descr); $text .= "<div class=\"imageElement\">" . "<h3>{$item->title}</h3>" . "<p>{$item->descr}</p>" . "<a href=\"#\" title=\"open image\" class=\"open\"></a>" . "<img src=\"" . $display->url() . "\" class=\"full\" />" . "<img src=\"" . $thumb->url() . "\" class=\"thumbnail\" />" . "</div>"; $k++; } $this->slides = $text; $this->galleryname = $gallery->name; $this->gid = $gallery->id; $this->display('slideshow.php'); }
/** prints gallery id, name and id, name of all items, recursively @param int id of gallery **/ function listEverything($parent = 0) { global $rsgConfig; if (!$rsgConfig->get('debug')) { echo '<p>Error: Debug must be enabled to use this debug tool.</p>'; return; } require_once JPATH_RSGALLERY2_ADMIN . '/includes/gallery.class.php'; $g = rsgGalleryManager::get($parent); function printItemsList($gallery) { echo <<<EOD <br />Images:<table border='1' class='rsg-image-table' > <tr> <th>id</th> <th>ordering</th> <th>name</th> <th>thumbnail</th> </tr> EOD; foreach ($gallery->itemRows() as $item) { echo "<tr>"; echo '<td>'; echo $item['id']; echo '</td>'; echo '<td>'; echo $item['ordering']; echo '</td>'; echo '<td>'; echo $item['name']; echo '</td>'; echo '<td>'; echo "<img src='" . imgUtils::getImgThumb($item['name']) . "' width='30' height='30' />"; echo '</td>'; echo "</tr>"; } echo "</table>"; } function printList($gallery) { echo "<ul>"; foreach ($gallery->kids() as $kid) { echo "<li>" . $kid->get('id') . " " . $kid->get('name'); printItemsList($kid); printList($kid); echo "</li>"; } echo "</ul>"; } printList($g); }
/** * Forces a download box to download single images * Thanks to Rich Malak <*****@*****.**>for his invaluable contribution * to this very important feature! * @param int Id of the file to download */ function downloadFile($id) { global $rsgConfig; //Clean and delete current output buffer ob_end_clean(); $gallery = rsgGalleryManager::getGalleryByItemID(); $item = $gallery->getItem(); $original = $item->original(); $file = $original->filePath(); //Open up the file if ($fd = fopen($file, "r")) { $fsize = filesize($file); $path_parts = pathinfo($file); $ext = strtolower($path_parts["extension"]); //Check the extension and provide the right headers for the file switch ($ext) { case "pdf": header("Content-type: application/pdf"); // add here more headers for diff. extensions header("Content-Disposition: attachment; filename=\"" . $path_parts["basename"] . "\""); // use 'attachement' to force a download break; case "jpg": header("Content-type: image/jpeg"); header("Content-Disposition: attachment; filename=\"" . $path_parts["basename"] . "\""); break; case "gif": header("Content-type: image/gif"); header("Content-Disposition: attachment; filename=\"" . $path_parts["basename"] . "\""); break; case "png": header("Content-type: image/png"); header("Content-Disposition: attachment; filename=\"" . $path_parts["basename"] . "\""); break; default: header("Content-type: application/octet-stream"); header("Content-Disposition: attachment; filename=\"" . $path_parts["basename"] . "\""); } header("Content-length: {$fsize}"); header("Cache-control: private"); //Read the contents of the file while (!feof($fd)) { $buffer = fread($fd, 4096); echo $buffer; } } //Close file after use! fclose($fd); }
/** * Samples a random thumb from the specified gallery and compares dimensions against Config settings * @param Integer Gallery ID * @return Boolean True if size has changed, false if not. */ function thumbSizeChanged($gid) { global $rsgConfig; $gallery = rsgGalleryManager::_get($gid); $images = $gallery->items(); foreach ($images as $image) { $imgname[] = $image->name; } $image = array_rand($imgname); $imgdata = getimagesize(imgUtils::getImgThumb($imgname[$image], true)); if ($imgdata[0] == $rsgConfig->get('thumb_width')) { return false; } else { return true; } }
function showSlideShow() { global $rsgConfig; $gallery = rsgGalleryManager::get(); // show nothing if there are no items if (!$gallery->itemCount()) { return; } $k = 0; $text = ""; foreach ($gallery->items() as $item) { if ($item->type != 'image') { return; } $display = $item->display(); $text .= "SLIDES[" . $k . "] = ['" . $display->url() . "', '{$item->title}'];\n"; $k++; } $this->slides = $text; $this->display('slideshow.php'); }
function showSlideShow() { global $rsgConfig; $gallery = rsgGalleryManager::get(); // show nothing if there are no items if (!$gallery->itemCount()) { return; } $k = 0; $text = ""; foreach ($gallery->items() as $item) { if ($item->type != 'image') { return; } $display = $item->display(); $thumb = $item->thumb(); $text .= "<a href=\"" . $display->url() . "\" class=\"slideshowThumbnail\"><img src=\"" . $thumb->url() . "\" border=\"0\" /></a>"; $k++; } $this->slides = $text; $this->galleryname = $gallery->name; $this->gid = $gallery->id; $this->display('slideshow.php'); }
/** * Shows details of image */ function showDisplayImageDetails() { global $rsgConfig, $rsgAccess; $gallery = rsgGalleryManager::get(); // if no details need to be displayed then exit if (!($rsgConfig->get("displayDesc") || $rsgConfig->get("displayVoting") || $rsgConfig->get("displayComments") || $rsgConfig->get("displayEXIF"))) { return; } jimport("joomla.html.pane"); $tabs =& JPane::getInstance("Tabs", array("useCookies" => true)); echo $tabs->startPane('tabs'); if ($rsgConfig->get("displayDesc")) { echo $tabs->startPanel(JText::_('Description'), 'rs-description'); $this->_showDescription(); echo $tabs->endPanel(); } if ($rsgConfig->get("displayVoting")) { echo $tabs->startPanel(JText::_('Voting'), 'Voting'); $this->_showVotes(); echo $tabs->endPanel(); } if ($rsgConfig->get("displayComments")) { echo $tabs->startPanel(JText::_('Comments'), 'Comments'); $this->_showComments(); echo $tabs->endPanel(); } if ($rsgConfig->get("displayEXIF")) { echo $tabs->startPanel(JText::_('EXIF'), 'EXIF'); $this->_showEXIF(); echo $tabs->endPanel(); } echo $tabs->endPanel(); }
/** * Returns the selected gallery. * * @static * @deprecated Use rsgGalleryManager::get(); instead! */ function getGallery() { return rsgGalleryManager::get(); }
/** * Deletes one or more records * @param array An array of unique category id numbers * @param string The current url option */ function removeReal($cid, $option) { global $rsgOption, $rsgConfig, $mainframe; $result = rsgGalleryManager::deleteArray($cid); if (!$rsgConfig->get('debug')) { $mainframe->redirect("index2.php?option={$option}&rsgOption={$rsgOption}"); } }
/** * Function will regenerate thumbs for a specific gallery or set of galleries * @todo Check if width really changed, else no resize needed. * Perhaps by sampling the oldest thumb from the gallery and checking dimensions against current setting. */ function executeRegenerateImages() { global $rsgConfig, $mainframe; $error = 0; $gid = rsgInstance::getVar('gid', array()); if (empty($gid)) { $mainframe->redirect("index2.php?option=com_rsgallery2&rsgOption=maintenance&task=regenerateThumbs", JText::_('NO_GALLERY_SELECTED')); return; } foreach ($gid as $id) { if ($id > 0) { //Check if resize is really needed. It takes a lot of resources when changing thumbs when dimensions did not change! if (!rsg2_maintenance::thumbSizeChanged($id)) { $mainframe->redirect("index2.php?option=com_rsgallery2&rsgOption=maintenance&task=regenerateThumbs", JText::_('THUMBNAIL_SIZE_DID_NOT_CHANGE_REGENERATION_NOT_NEEDED')); return; } else { $gallery = rsgGalleryManager::_get($id); $images = $gallery->items(); foreach ($images as $image) { $imagename = imgUtils::getImgOriginal($image->name, true); if (!imgUtils::makeThumbImage($imagename)) { //Error counter $error++; } } } } } if ($error > 0) { $msg = JText::_('MAINT_REGEN_ERRORS'); } else { $msg = JText::_('MAINT_REGEN_NO_ERRORS'); } $mainframe->redirect("index2.php?option=com_rsgallery2&rsgOption=maintenance&task=regenerateThumbs", $msg); }
function copyImage($cid, $option) { global $mainframe; $database =& JFactory::getDBO(); //For each error that is found, store error message in array $errors = array(); $cat_id = rsgInstance::getInt('move_id', ''); //get gallery id to copy item to if (!$cat_id) { echo "<script> alert('No gallery selected to move to'); window.history.go(-1);</script>\n"; exit; } //Create unique copy name $tmpdir = uniqid('rsgcopy_'); //Get full path to copy directory $copyDir = JPath::clean(JPATH_ROOT . '/media/' . $tmpdir . '/'); if (!JFolder::create($copyDir)) { $errors[] = 'Unable to create temp directory ' . $copyDir; } else { foreach ($cid as $id) { $gallery = rsgGalleryManager::getGalleryByItemID($id); $item = $gallery->getItem($id); $original = $item->original(); $source = $original->filePath(); $destination = $copyDir . $item->name; if (is_dir($copyDir)) { if (file_exists($source)) { if (!JFile::copy($source, $destination)) { $errors[] = 'The file could not be copied!'; } else { //Actually importing the image $e = fileUtils::importImage($destination, $item->name, $cat_id, $item->title, $item->description); if ($e !== true) { $errors[] = $e; } if (!JFile::delete($destination)) { $errors[] = 'Unable to delete the file' . $item->name; } } } } } if (!rmdir($copyDir)) { $errors[] = 'Unable to delete the temp directory' . $copyDir; } } //Error handling if necessary if (count($errors) == 0) { $mainframe->redirect("index2.php?option={$option}&rsgOption=images", JText::_('Item(s) copied successfully!')); } else { //Show error message for each error encountered foreach ($errors as $e) { echo $e->toString(); } //If there were more files than errors, assure the user the rest went well if (count($errors) < count($files["error"])) { echo "<br>" . JText::_('Rest of the items copied successfully!'); } } }
/** * Shows the voting screen */ function _showVotes() { global $mainframe, $rsgConfig, $rsgAccess; $gallery = rsgGalleryManager::get(); $vote_view = $rsgConfig->get('voting') && ($rsgAccess->checkGallery("vote_view", $gallery->id) || $rsgAccess->checkGallery("vote_vote", $gallery->id)); if ($vote_view) { $css = "<link rel=\"stylesheet\" href=\"" . JURI_SITE . "/components/com_rsgallery2/lib/rsgvoting/rsgvoting.css\" type=\"text/css\" />"; $mainframe->addCustomHeadTag($css); $voting = new rsgVoting(); if ($rsgAccess->checkGallery("vote_view", $gallery->id)) { $voting->showScore(); } if ($rsgAccess->checkGallery("vote_vote", $gallery->id)) { $voting->showVoting(); } } else { echo JText::_('Voting is disabled!'); } }
/** get local path to gallery * @param string char to separate path with (default = DS) * @return path to gallery **/ function getPath($path_separator = '/') { global $rsgConfig; static $path = null; // return cached path if it is available if ($path != null) { return $path; } // check if the galleries are stored in separate folders if ($rsgConfig->get('gallery_folders')) { // if the gallery is in the root, return empty string if ($this->parent == null) { $path = ''; } else { // if gallery is a sub gallery the get the path ftrom the parent $parent_gallery = rsgGalleryManager::get($this->parent); $path = $parent_gallery->getPath($path_separator) . $path_separator . $this->id; } } else { $path = $path_separator; } return $path; }
/** * recursively deletes a tree of galleries * @param id of the gallery * @todo this is a quick hack. galleryUtils and imgUtils need to be reorganized; and a rsgImage class created to do this proper */ function _deleteTree($galleries) { global $rsgAccess; $database =& JFactory::getDBO(); foreach ($galleries as $gallery) { rsgGalleryManager::_deleteTree($gallery->kids()); // delete images in gallery foreach ($gallery->items() as $item) { imgUtils::deleteImage(galleryUtils::getFileNameFromId($item->id)); } // delete gallery $id = $gallery->get('id'); if (!is_numeric($id)) { return false; } $query = "DELETE FROM #__rsgallery2_galleries WHERE id = {$id}"; echo "<br>deleting gallery {$id}"; $database->setQuery($query); if (!$database->query()) { echo $database->error(); } // Delete permissions here $rsgAccess->deletePermissions($id); } }
/** * Checks if it is allowed to vote in this gallery * @return True or False */ function voteAllowed() { global $rsgConfig, $rsgAccess; //Check if voting is enabled if ($rsgConfig->get('voting') < 1) { return false; } else { $gallery = rsgGalleryManager::get(); return $rsgAccess->checkGallery("vote_vote", $gallery->id); } }
/** * show list of galleries */ function show(&$rows, &$lists, &$search, &$pageNav) { global $rsgOption; $option = JRequest::getCmd('option'); $my =& JFactory::getUser(); JHTML::_("behavior.mootools"); //Create 'lookup array' to find whether or not galleries with the same parent // can move up/down in their order: $orderLookup[id parent][#] = id child $orderLookup = array(); foreach ($rows as $row) { $orderLookup[$row->parent][] = $row->id; } ?> <form action="index.php" method="post" name="adminForm"> <table border="0" width="100%"> <tr> <td width="50%"> </td> <td nowrap="true" width="50%" align="right"> <?php echo JText::_('Max Levels'); ?> <?php echo $lists['levellist']; ?> <?php echo JText::_('Filter'); ?> : <input type="text" name="search" value="<?php echo $search; ?> " class="text_area" onChange="document.adminForm.submit();" /> </td> </tr> </table> <table class="adminlist"> <thead> <tr> <th width="1%"> ID </th> <th width="1%"> <input type="checkbox" name="toggle" value="" onclick="checkAll(<?php echo count($rows); ?> );" /> </th> <th class="Name"> <?php echo JText::_('Name'); ?> </th> <th width="5%"> <?php echo JText::_('Published'); ?> </th> <th colspan="2" width="5%"> <?php echo JText::_('Reorder'); ?> </th> <th width="2%"> <?php echo JText::_('Order'); ?> </th> <th width="2%"> <?php echo JHtml::_('grid.order', $rows); ?> </th> <th width="4%"><?php echo JText::_('Items'); ?> </th> <th width="25%"> <?php echo JText::_('Hits'); ?> </th> </tr> </thead> <tbody> <?php $k = 0; for ($i = 0, $n = count($rows); $i < $n; $i++) { $row =& $rows[$i]; $link = "index2.php?option={$option}&rsgOption={$rsgOption}&task=editA&hidemainmenu=1&id=" . $row->id; $task = $row->published ? 'unpublish' : 'publish'; $img = $row->published ? 'publish_g.png' : 'publish_x.png'; $alt = $row->published ? 'Published' : 'Unpublished'; $checked = JHTML::_('grid.checkedout', $row, $i); //Use the $orderLookup array to determine if for the same // parent one can still move up/down. First look up the parent info. $orderkey = array_search($row->id, $orderLookup[$row->parent]); $showMoveUpIcon = isset($orderLookup[$row->parent][$orderkey - 1]); $showMoveDownIcon = isset($orderLookup[$row->parent][$orderkey + 1]); ?> <tr class="<?php echo "row{$k}"; ?> "> <td> <?php echo $row->id; ?> </td> <td> <?php echo $checked; ?> </td> <td> <?php if ($row->checked_out && $row->checked_out != $my->id) { echo stripslashes($row->name); } else { ?> <a href="<?php echo $link; ?> " name="Edit Gallery"> <?php echo stripslashes($row->treename); ?> </a> <?php } ?> <a href="<?php echo JRoute::_('index.php?option=com_rsgallery2&rsgOption=images&gallery_id=' . $row->id); ?> " > <img src="images/forward_f2.png" width="12" height="12" style="margin: 0px 20px" alt="<?php echo JText::_('ITEMS'); ?> " /> </a> </td> <td align="center"> <a href="javascript: void(0);" onclick="return listItemTask('cb<?php echo $i; ?> ','<?php echo $task; ?> ')"> <img src="images/<?php echo $img; ?> " width="12" height="12" alt="<?php echo $alt; ?> " /> </a> </td> <td> <?php echo $pageNav->orderUpIcon($i, $showMoveUpIcon); ?> </td> <td> <?php echo $pageNav->orderDownIcon($i, $n, $showMoveDownIcon); ?> </td> <td colspan="2" align="center"> <input type="text" name="order[]" size="5" value="<?php echo $row->ordering; ?> " class="text_area" style="text-align: center" /> </td> <td align="center"> <?php $gallery = rsgGalleryManager::get($row->id); echo $gallery->itemCount(); ?> </td> <td align="left"> <?php echo $row->hits; ?> </td> </tr> <?php $k = 1 - $k; } ?> </tbody> <tfoot> <tr> <td colspan="10"><?php echo $pageNav->getListFooter(); ?> </td> </tr> </tfoot> </table> <input type="hidden" name="option" value="<?php echo $option; ?> " /> <input type="hidden" name="rsgOption" value="<?php echo $rsgOption; ?> " /> <input type="hidden" name="task" value="" /> <input type="hidden" name="boxchecked" value="0" /> <input type="hidden" name="hidemainmenu" value="0" /> </form> <?php }
/** * 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 mosWeblink The weblink object * @param array An array of select lists * @param object Parameters * @param string The option */ function editImage(&$row, &$lists, &$params, $option) { global $rsgOption; jimport("joomla.filter.output"); JFilterOutput::objectHTMLSafe($row, ENT_QUOTES); JHTML::_('behavior.formvalidation'); $editor =& JFactory::getEditor(); ?> <script type="text/javascript"> function submitbutton(pressbutton) { var form = document.adminForm; if (pressbutton == 'cancel') { submitform( pressbutton ); return; } // do field validation if (form.title.value == ""){ alert( "<?php echo JText::_('PLEASE PROVIDE A VALID IMAGE TITLE'); ?> " ); } else if (form.gallery_id.value <= "0"){ alert( "<?php echo JText::_('YOU MUST SELECT A GALLERY.'); ?> " ); } else { <?php echo $editor->save('descr'); ?> submitform( pressbutton ); } } </script> <form action="index2.php" method="post" name="adminForm" id="adminForm" class="form-validate" > <table class="adminheading"> <tr> <th><?php echo JText::_('Item'); ?> :<small><?php echo $row->id ? JText::_('Edit') : JText::_('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="title" size="50" maxlength="250" value="<?php echo $row->title; ?> " /> </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 $row->alias; ?> " /> </td> </tr> <tr> <td width="20%" align="right"><?php echo JText::_('Filename'); ?> </td> <td width="80%"><?php echo $row->name; ?> </td> </tr> <tr> <td valign="top" align="right"><?php echo JText::_('Gallery'); ?> </td> <td><?php echo $lists['gallery_id']; ?> </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('descr', $row->descr, '100%', '200', '10', '20', false); ?> </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::_('Item preview'); ?> </th> </tr> <tr> <td> <div align="center"> <?php $item = rsgGalleryManager::getItem($row->id); $original = $item->original(); $thumb = $item->thumb(); switch ($item->type) { case "audio": ?> <object type="application/x-shockwave-flash" width="400" height="15" data="<?php echo JURI_SITE; ?> /components/com_rsgallery2/flash/xspf/xspf_player_slim.swf?song_title=<?php echo $row->name; ?> &song_url=<?php echo audioUtils::getAudio($row->name); ?> "><param name="movie" value="<?php echo JURI_SITE; ?> /components/com_rsgallery2/flash/xspf/xspf_player_slim.swf?song_title=<?php echo $item->title; ?> &song_url=<?php echo $original->url(); ?> " /></object> <?php break; case "video": // OS flv player from http://www.osflv.com ?> <object type="application/x-shockwave-flash" width="400" height="300" data="<?php echo JURI_SITE; ?> /components/com_rsgallery2/flash/player.swf?movie=<?php echo $display->name; ?> " > <param name="movie" value="<?php echo JURI_SITE; ?> /components/com_rsgallery2/flash/player.swf?movie=<?php echo $display->name; ?> " /> <embed src="<?php echo JURI_SITE; ?> /components/com_rsgallery2/flash/player.swf?movie=<?php echo $display->url(); ?> " width="400" height="340" allowFullScreen="false" type="application/x-shockwave-flash"> </object> <?php break; case "image": $display = $item->display(); ?> <img src="<?php echo $display->url(); ?> " alt="<?php echo htmlspecialchars(stripslashes($item->descr), ENT_QUOTES); ?> " /> <?php break; default: ?> Unsuported item <?php break; } ?> <br /> </div> </td> </tr> </table> <table class="adminform"> <tr> <th colspan="1"><?php echo JText::_('Parameters'); ?> </th> </tr> <tr> <td><?php echo $params->render(); ?> </td> </tr> </table> <table class="adminform"> <tr> <th colspan="1"><?php echo JText::_('Links to image'); ?> </th> </tr> <tr> <td> <table width="100%" class="imagelist"> <?php if ($item->type == 'image' || $item->type == "video") { ?> <tr> <td width="40%" align="right" valign="top"> <a href="<?php echo $thumb->url(); ?> " target="_blank" alt="<?php echo $item->name; ?> "><?php echo JText::_('Thumb'); ?> </a>:</td> <td><input type="text" name="thumb_url" class="text_area" size="50" value="<?php echo $thumb->url(); ?> " /></td> </tr> <tr> <td width="40%" align="right" valign="top"><a href="<?php echo $display->url(); ?> " target="_blank" alt="<?php echo $item->name; ?> "><?php echo JText::_('Display'); ?> </a>:</td> <td ><input type="text" name="display_url" class="text_area" size="50" value="<?php echo $display->url(); ?> " /></td> </tr> <?php } ?> <tr> <td width="40%" align="right" valign="top"><a href="<?php echo $original->url(); ?> " target="_blank" alt="<?php echo $item->name; ?> "><?php echo JText::_('Original'); ?> </a>:</td> <td><input type="text" name="original_url" class="text_area" size="50" value="<?php echo $original->url(); ?> " /></td> </tr> </table> </td> </tr> </table> </td> </tr> </table> <input type="hidden" name="id" value="<?php echo $row->id; ?> " /> <input type="hidden" name="name" value="<?php echo $row->name; ?> " /> <input type="hidden" name="option" value="<?php echo $option; ?> " /> <input type="hidden" name="rsgOption" value="<?php echo $rsgOption; ?> " /> <input type="hidden" name="task" value="" /> </form> <?php }