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); } }
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>"; }
/** * 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; } }
/** * 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 consolidateDB($db_name, $file_display, $file_original, $file_thumb, $files_total) { global $rsgConfig; require_once JPATH_RSGALLERY2_ADMIN . '/config.rsgallery2.php'; $file_diff = array_diff($files_total, $db_name); ?> <script language="Javascript"> function db_create() { alert('Database creation does not work yet!'); } function db_createX() { var form = document.adminForm; form.t_id.value = t_id; form.g_id.value = g_id; form.submit(); } </script> <form method="post" action="index2.php?option=com_rsgallery2&rsgOption=maintenance&task=createDbEntries" name="adminForm"> <input type="hidden" name="t_id" value="" /> <input type="hidden" name="g_id" value="" /> <table width="100%" border="0"> <tr> <td width="15%"> </td> <td width="70%"> <table class="adminlist" border="0"> <tr> <td colspan="9" align="center"> <div style="clear: both; margin: 3px; margin-top: 10px; padding: 5px 15px; display: block; float: left; border: 1px solid #cc0000; background: #ffffcc; text-align: left; width: 80%;"> <p style="color: #CC0000;"> <img src="<?php echo JURI_SITE; ?> /includes/js/ThemeOffice/warning.png" alt="Warning icon" /> NOTICE:<br />Experimental at this stage. Single image regeneration works. <br /> Database entries do NOT work!. <?php //echo JText::_('CONSDB_NOTICE'); ?> </p> </div> <div class='rsg2-clr'> </div> </td> </tr> <tr> <th>#</th> <th><?php echo JText::_('Filename'); ?> </th> <th align="center"><?php echo JText::_('In<br>database'); ?> </th> <th align="center"><?php echo JText::_('Display<br>folder'); ?> </th> <th align="center"><?php echo JText::_('Original<br>folder'); ?> </th> <th align="center"><?php echo JText::_('Thumb<br>folder'); ?> </th> <th> </th> <th align="center"><?php echo JText::_('Image'); ?> </th> <th align="center"><?php echo JText::_('Action'); ?> </th> </tr> <tr> <td colspan="9"> </td> </tr> <?php $yes = "<td align=\"center\"><img src=\"" . JURI_SITE . "administrator/images/tick.png\" alt=\"" . JText::_('Image in folder') . "\" border=\"0\"></td>"; $no = "<td align=\"center\"><img src=\"" . JURI_SITE . "administrator/images/publish_x.png\" alt=\"" . JText::_('Image NOT in folder') . "\" border=\"0\"></td>"; $z = 0; $c = 0; //Check database and crossreference against filesystem foreach ($db_name as $name) { $c++; $i = 0; $fid = galleryUtils::getFileIdFromName($name); $html = "<tr><td><input type=\"checkbox\" id=\"cb{$c}\" name=\"xid[]\" value=\"{$name}\" onclick=\"isChecked(this.checked);\" /></td><td>{$name}</td>" . $yes; if (in_array($name, $file_display)) { $i++; $html .= $yes; $display = true; } else { $z++; $html .= $no; $display = false; } if (in_array($name, $file_original)) { $i++; $html .= $yes; $original = true; } else { $z++; $html .= $no; $original = false; } if (in_array($name, $file_thumb)) { $i++; $html .= $yes; $thumb = true; } else { $z++; $html .= $no; $thumb = false; } if ($i < 3) { echo $html; ?> <td> </td> <td> <img src="<?php echo imgUtils::getImgThumb($name); ?> " name="image" width="<?php echo $rsgConfig->get('thumb_width'); ?> " alt="<?php echo $name; ?> "/> </td> <td align="center"> <a href="index2.php?option=com_rsgallery2&rsgOption=maintenance&task=deleteImages&name=<?php echo $name; ?> "><?php echo '[ ' . JText::_('Delete_from_database') . ' ]'; ?> </a><br /> <?php if ($original == true or $display == true) { ?> <a href="index2.php?option=com_rsgallery2&rsgOption=maintenance&task=createImages&id=<?php echo $fid; ?> "><?php echo '[ ' . JText::_('Create_missing_images') . ' ]'; ?> </a> <?php } ?> </td></tr> <?php } else { continue; } } ?> </tr> <?php $zz = 0; $t = 0; //Check filesystem and crossreference against database foreach ($file_diff as $diff) { $t++; $y = 0; $html2 = "<tr><td><input type=\"checkbox\" id=\"cb{$t}\" name=\"xid[]\" value=\"{$t}\" onclick=\"isChecked(this.checked);\" /></td><td><font color=\"#FF0000\">{$diff}</font></td>{$no}"; if (in_array($diff, $file_display)) { $y++; $html2 .= $yes; $display2 = true; } else { $zz++; $html2 .= $no; $display2 = false; } if (in_array($diff, $file_original)) { $y++; $html2 .= $yes; $original2 = true; } else { $zz++; $html2 .= $no; $original2 = false; } if (in_array($diff, $file_thumb)) { $y++; $html2 .= $yes; $thumb2 = true; } else { $zz++; $html2 .= $no; $thumb2 = false; } if ($y < 4) { echo $html2; ?> <td> <?php echo galleryUtils::galleriesSelectList(NULL, 'gallery_id[]', false, false); ?> <input type="hidden" name="name[]" value="<?php echo $diff; ?> " /> </td> <td> <img src="<?php echo imgUtils::getImgThumb($diff); ?> " name="image" width="<?php echo $rsgConfig->get('thumb_width'); ?> " /> </td> <td align="center"> <a href="javascript:void();" onClick="javascript:db_create();"><?php echo '[ ' . JText::_('Create_Database_entry') . ' ]'; ?> </a><br /> <a href="index2.php?option=com_rsgallery2&rsgOption=maintenance&task=deleteImages&name=<?php echo $diff; ?> "><?php echo '[ ' . JText::_('Delete_images'), ' ]'; ?> </a> <?php if ($original2 == true and $display2 == true and $thumb2 == true) { continue; } else { ?> <br /><a href="index2.php?option=com_rsgallery2&rsgOption=maintenance&task=createImages&name=<?php echo $diff; ?> "><?php echo '[ ' . JText::_('Create missing images') . ' ]'; ?> </a> <?php } ?> </td> <?php } else { continue; } } if ($t == 0 and $z == 0) { echo "<tr><td colspan=\"8\"><font color=\"#008000\"><strong>" . JText::_('No inconsistencies in database') . "</strong></font></td>"; } ?> </tr> <tr> <th colspan="9" align="center"> <a href="index2.php?option=com_rsgallery2&rsgOption=maintenance&task=consolidateDB">Refresh</a> </th> </tr> <!-- <tr> <td colspan="2"><input type="checkbox" name="toggle" value="" onclick="checkAll(<?php echo count($db_name) + count($file_diff); ?> );" /></td> <td colspan="5"> With selection:<br /> <a href="javascript:void();" onClick="javascript:alert('<?php echo JText::_('Not working yet'); ?> ');"><?php echo JText::_('Delete from filesystem'); ?> </a> | <a href="javascript:void();" onClick="javascript:alert('<?php echo JText::_('Not working yet'); ?> ');"><?php echo JText::_('Create missing images'); ?> </a> | <a href="javascript:void();" onClick="javascript:alert('<?php echo JText::_('Not working yet'); ?> ');"><?php echo JText::_('Create database entries'); ?> </a> </td> </tr> --> </table> </td> <td width="15%"> </td> </tr> </table> </form> <?php }
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')); } }
/** * 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); } } }
/** * Takes an image file, moves the file and adds database entry * @param the verified REAL name of the local file including path * @param name of file according to user/browser or just the name excluding path * @param desired category * @param title of image, if empty will be created from $name * @param description of image, if empty will remain empty * @todo deleteImage (video) * @return returns true if successfull otherwise returns an ImageUploadError */ function importImage($tmpName, $name, $cat, $title = '', $desc = '') { global $rsgConfig; $my =& JFactory::getUser(); $database =& JFactory::getDBO(); $destination = fileUtils::move_uploadedFile_to_orignalDir($tmpName, $name); if (is_a($destination, imageUploadError)) { return $destination; } $parts = pathinfo($destination); // fill $imgTitle if empty if ($imgTitle == '') { $imgTitle = substr($parts['basename'], 0, -(strlen($parts['extension']) + ($parts['extension'] == '' ? 0 : 1))); } // replace names with the new name we will actually use $parts = pathinfo($destination); $newName = $parts['basename']; $imgName = $parts['basename']; //Destination becomes original video, just for readability $original_video = $destination; $result = true; do { // New video will be located in display folder $newVideo = JPATH_DISPLAY . DS . $newName . "." . $rsgConfig->get("videoConverter_extension"); $result = Ffmpeg::convertVideo($original_video, $newVideo); if (!$result) { $result = new imageUploadError($imgName, "error converting video: <pre>" . print_r($result->getMessage(), true) . "</pre>"); break; } // get first frame of the video to genetrate a thumbnail from $videoPreviewImage = JPATH_ORIGINAL . DS . $newName . ".png"; $result = Ffmpeg::capturePreviewImage($original_video, $videoPreviewImage); if (!$result) { $result = new imageUploadError($imgName, "error capturing preview image: <pre>" . print_r($result->getMessage(), true) . "</pre>"); break; } //Get details of the original image. $width = getimagesize($videoPreviewImage); if (!$width) { $result = new imageUploadError($videoPreviewImage, "not an image OR can't read {$videoPreviewImage}"); break; } else { //the actual image width $width = $width[0]; } $result = imgUtils::makeThumbImage($videoPreviewImage, $newName); // remove the temporary preview image JFile::delete($videoPreviewImage); if (!$result) { $result = new imageUploadError($imgName, JText::_('ERROR CREATING THUMB IMAGE') . ": " . $videoPreviewImage); break; } // determine ordering $database->setQuery("SELECT COUNT(1) FROM #__rsgallery2_files WHERE gallery_id = '{$cat}'"); $ordering = $database->loadResult() + 1; //Store image details in database $alias = mysql_real_escape_string(JFilterOutput::stringURLSafe($title)); $desc = mysql_real_escape_string($desc); $title = mysql_real_escape_string($title); $database->setQuery("INSERT INTO #__rsgallery2_files" . " (title, name, descr, gallery_id, date, ordering, userid, alias) VALUES" . " ('{$title}', '{$newName}', '{$desc}', '{$cat}', now(), '{$ordering}', '{$my->id}', '{$alias}')"); if (!$database->query()) { $result = new imageUploadError($parts['basename'], $database->stderr(true)); break; } } while (false); if ($result !== true) { // clean up if (JFile::exists($newVideo)) { JFile::delete($newVideo); } if (JFile::exists($videoPreviewImage)) { JFile::delete($videoPreviewImage); } imgUtils::deleteImage($newName); } return $result; }
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!')); } }
/** * 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); } }
function editItem($rows) { global $rsgConfig; $my = JFactory::getUser(); $editor = JFactory::getEditor(); require_once JPATH_ROOT . '/includes/HTML_toolbar.php'; foreach ($rows as $row) { $filename = $row->name; $title = htmlspecialchars($row->title, ENT_QUOTES); //$description = $row->descr; $description = htmlspecialchars($row->descr, ENT_QUOTES); $id = $row->id; $limitstart = $row->ordering - 1; $catid = $row->gallery_id; } ?> <script type="text/javascript"> function submitbutton(pressbutton) { var form = document.form1; if (pressbutton == 'cancel') { form.reset(); history.back(); return; } <?php echo $editor->save('descr'); ?> // do field validation if (form.catid.value == "0") { alert( "<?php echo JText::_('You must provide a gallery name.'); ?> " ); } else if (form.descr.value == ""){ alert( "<?php echo JText::_('You must provide a description.'); ?> " ); } else{ submitform( pressbutton ); } } </script> <?php echo "<h3>" . JText::_('Edit image') . "</h3>"; ?> <form name="form1" method="post" action="<?php echo JRoute::_("index.php?option=com_rsgallery2&rsgOption=myGalleries&task=saveItem"); ?> "> <input type="hidden" name="id" value="<?php echo $id; ?> " /> <table width="100%"> <tr> <td align="right"> <img onClick="form1.submit();" src="<?php echo JURI_SITE; ?> /administrator/images/save.png" alt="<?php echo JText::_('Upload'); ?> " name="upload" onMouseOver="document.upload.src='<?php echo JURI_SITE; ?> /administrator/images/save_f2.png';" onMouseOut="document.upload.src='<?php echo JURI_SITE; ?> /administrator/images/save.png';" /> <img onClick="history.back();" src="<?php echo JURI_SITE; ?> /administrator/images/cancel.png" alt="<?php echo JText::_('Cancel'); ?> " name="cancel" onMouseOver="document.cancel.src='<?php echo JURI_SITE; ?> /administrator/images/cancel_f2.png';" onMouseOut="document.cancel.src='<?php echo JURI_SITE; ?> /administrator/images/cancel.png';" /> </td> </tr> </table> <table class="adminlist" border="2" width="100%"> <tr> <th colspan="3"><?php echo JText::_('Edit image'); ?> </th> </tr> <tr> <td align="left"><?php echo JText::_('Category name'); ?> </td> <td align="left"> <?php galleryUtils::showUserGalSelectList('up_mod_img', 'catid', $catid); ?> </td> <td rowspan="2"><img src="<?php echo imgUtils::getImgThumb($filename); ?> " alt="<?php echo $title; ?> " /></td> </tr> <tr> <td align="left"><?php echo JText::_('Filename'); ?> </td> <td align="left"><strong><?php echo $filename; ?> </strong></td> </tr> <tr> <td align="left"><?php echo JText::_('Title'); ?> </td> <td align="left"><input type="text" name="title" size="30" value="<?php echo $title; ?> " /></td> </tr> <tr> <td align="left" valign="top"><?php echo JText::_('Description'); ?> </td> <td align="left" colspan="2"> <?php echo $editor->display('descr', stripslashes($description), '100%', '200', '10', '20', false); ?> </td> </tr> <tr> <th colspan="3"> </th> </tr> </table> </form> <?php }
<a title="<?php echo $row->title; ?> " href="<?php echo JRoute::_('index.php?option=com_rsgallery2&page=inline&Itemid=' . $RSG2Itemid . '&id=' . $row->id . '&catid=' . $row->gallery_id . '&limitstart=' . $limitstart); ?> "> <?php } elseif ($link2gal == 'gal') { ?> <a title="<?php echo $row->title; ?> " href="<?php echo JRoute::_('index.php?option=com_rsgallery2&Itemid=' . $RSG2Itemid . '&id=' . $row->id . '&catid=' . $row->gallery_id); ?> "> <?php } } // The <img> tag echo "<img src='" . imgUtils::getImgThumb($filename) . "' alt='" . $row->title . "'>"; // Insert a </a> tag if the images are clickable. if ($Clickornot) { echo "</a>"; } } ?> </div> </marquee> </div>
* @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 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); } }
echo '<div class="rsscroller_thumb">'; // Loop through the images. foreach ($ImageList as $dbImage) { $Filename = $dbImage['name']; $LimitStart = $dbImage['ordering'] - 1; /* // Insert an <a> tag if the images are clickable. if ($Clickornot) { //display or gallery view if($link2gal == 'dis'){ ?> <a title="<?php echo $dbImage->title;?>" href="<?php echo JRoute::_('index.php?option=com_rsgallery2&page=inline&Itemid='.$RSG2Itemid.'&id='.$dbImage->id.'&catid='.$dbImage->gallery_id.'&limitstart='.$limitstart);?>"> <?php } elseif($link2gal == 'gal'){ ?> <a title="<?php echo $dbImage->title;?>" href="<?php echo JRoute::_('index.php?option=com_rsgallery2&Itemid='.$RSG2Itemid.'&id='.$dbImage->id.'&catid='.$dbImage->gallery_id);?>"> <?php } } */ // The <img> tag echo "<img src='" . imgUtils::getImgThumb($Filename) . "' alt='" . $dbImage['title'] . "'>"; // Insert a </a> tag if the images are clickable. // if ($Clickornot){echo "</a>";} // } } echo ' </marquee>'; echo ' </div>'; echo '</div>';
<?php defined('_JEXEC') or die('Restricted access'); $item = $this->currentItem; $watermark = $rsgConfig->get('watermark'); $imageOriginalUrl = $watermark ? waterMarker::showMarkedImage($item->name, 'original') : imgUtils::getImgOriginal($item->name); $imageUrl = $watermark ? waterMarker::showMarkedImage($item->name) : imgUtils::getImgDisplay($item->name); switch ($rsgConfig->get('displayPopup')) { //No popup case 0: ?> <img class="rsg2-displayImage" src="<?php echo $imageUrl; ?> " alt="<?php echo $item->name; ?> " title="<?php echo $item->name; ?> " /> <?php break; //Normal popup //Normal popup case 1: ?> <a href="<?php echo $imageOriginalUrl; ?> " target="_blank">
/** * Creates new thumbnails with new settings * @param Category ID */ function regenerateThumbs($catid = NULL) { global $database, $rsgConfig; $i = 0; $files = mosReadDirectory(JPATH_ROOT . $rsgConfig->get('imgPath_original')); //check if size is changed foreach ($files as $file) { if (imgUtils::makeThumbImage(JPATH_ROOT . $rsgConfig->get('imgPath_original') . $file)) { continue; } else { $error[] = $file; } $i++; } }
function determineHandle($filename) { require_once JPATH_RSGALLERY2_ADMIN . '/includes/audio.utils.php'; require_once JPATH_RSGALLERY2_ADMIN . '/includes/video.utils.php'; $ext = strtolower(JFile::getExt($filename)); if (in_array($ext, imgUtils::allowedFileTypes())) { return 'imgUtils'; } else { if (in_array($ext, videoUtils::allowedFileTypes())) { return 'videoUtils'; } else { if (in_array($ext, audioUtils::allowedFileTypes())) { return 'audioUtils'; } else { return false; } } } }
/** * Shows either random or latest images, depending on parameter * @param String Type of images. Options are 'latest' or 'random' * @param Int Number of images to show. Defaults to 3 * @param String Style, options are 'vert' or 'hor'.(Vertical or horizontal) * @return HTML representation of image block. */ function showImages($type = "latest", $number = 3, $style = "hor") { global $mainframe, $rsgConfig; $database = JFactory::getDBO(); //Check if backend permits showing these images if ($type == "latest" and !$rsgConfig->get('displayLatest')) { return; } elseif ($type == "random" and !$rsgConfig->get('displayRandom')) { return; } switch ($type) { case 'random': $database->setQuery("SELECT file.date, file.gallery_id, file.ordering, file.id, file.name, file.title" . " FROM #__rsgallery2_files as file, #__rsgallery2_galleries as gal" . " WHERE file.gallery_id=gal.id and gal.published=1 AND file.published=1" . " ORDER BY rand() limit {$number}"); $rows = $database->loadObjectList(); $title = JText::_('Random images'); break; case 'latest': $database->setQuery("SELECT file.date, file.gallery_id, file.ordering, file.id, file.name, file.title" . " FROM #__rsgallery2_files as file, #__rsgallery2_galleries as gal" . " WHERE file.gallery_id=gal.id AND gal.published=1 AND file.published=1" . " ORDER BY file.date DESC LIMIT {$number}"); $rows = $database->loadObjectList(); $title = JText::_('Latest images'); break; } if ($style == "vert") { ?> <ul id='rsg2-galleryList'> <li class='rsg2-galleryList-item' > <table class="table_border" cellspacing="0" cellpadding="0" border="0" width="100%"> <tr> <td><?php echo $title; ?> </td> </tr> <tr> <td> </td> </tr> <?php foreach ($rows as $row) { $l_start = $row->ordering - 1; $url = JRoute::_("index.php?option=com_rsgallery2&page=inline&id=" . $row->id); ?> <tr> <td align="center"> <div class="shadow-box"> <div class="img-shadow"> <a href="<?php echo $url; ?> "> <img src="<?php echo imgUtils::getImgThumb($row->name); ?> " alt="<?php echo $row->title; ?> " width="<?php echo $rsgConfig->get('thumb_width'); ?> " /> </a> </div> <div class="rsg2-clr"></div> <div class="rsg2_details"><?php echo JHTML::_("date", $row->date); ?> </div> </div> </td> </tr> <tr> <td> </td> </tr> <?php } ?> </table> </li> </ul> <?php } else { ?> <ul id='rsg2-galleryList'> <li class='rsg2-galleryList-item' > <table class="table_border" cellspacing="0" cellpadding="0" border="0" width="100%"> <tr> <td colspan="3"><?php echo $title; ?> </td> </tr> <tr> <td colspan="3"> </td> </tr> <tr> <?php foreach ($rows as $row) { $l_start = $row->ordering - 1; $url = JRoute::_("index.php?option=com_rsgallery2&page=inline&id=" . $row->id); ?> <td align="center"> <div class="shadow-box"> <div class="img-shadow"> <a href="<?php echo $url; ?> "> <img src="<?php echo imgUtils::getImgThumb($row->name); ?> " alt="<?php echo $row->title; ?> " width="<?php echo $rsgConfig->get('thumb_width'); ?> " /> </a> </div> <div class="rsg2-clr"></div> <div class="rsg2_details"><?php echo JText::_('Uploaded'); ?> <?php echo JHTML::_("date", $row->date); ?> </div> </div> </td> <?php } ?> </tr> <tr> <td colspan="3"> </td> </tr> </table> </li> </ul> <?php } }
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') . ": " . galleryUtils::genericGetUsername($match->userid) . "]"; } ?> </p> </td> </tr> </table> <br /> <?php } } }
if ($displayType == 1) { // *** display ***: $watermark = $rsgConfig->get('watermark'); //$imageUrl = $watermark ? waterMarker::showMarkedImage( $ItemIdxName ) : imgUtils::getImgDisplayPath( $ItemIdxName ); $imageUrl = $watermark ? waterMarker::showMarkedImage($ItemIdxName) : imgUtils::getImgDisplay($ItemIdxName); $HTML .= '<img class="rsg2-displayImage" src="' . $imageUrl . '" alt="' . $ItemIdxName . '" title="' . $ItemIdxName . '" ' . $imgAttributes . '/>'; } elseif ($displayType == 2) { // *** original *** $watermark = $rsgConfig->get('watermark'); //$imageOriginalUrl = $watermark ? waterMarker::showMarkedImage( $ItemIdxName, 'original' ) : imgUtils::getImgOriginalPath( $ItemIdxName ); $imageOriginalUrl = $watermark ? waterMarker::showMarkedImage($ItemIdxName, 'original') : imgUtils::getImgOriginalPath($ItemIdxName); $HTML .= '<img class="rsg2-displayImage" src="' . $imageOriginalUrl . '" alt="' . $ItemIdxName . '" title="' . $ItemIdxName . '" ' . $imgAttributes . '/>'; } else { // *** thumb *** //$imageThumbUrl = imgUtils::getImgThumbPath( $ItemIdxName ); $imageThumbUrl = imgUtils::getImgThumb($ItemIdxName); $HTML .= '<img class="rsg2-displayImage" src="' . $imageThumbUrl . '" alt="' . $ItemIdxName . '" title="' . $ItemIdxName . '" ' . $imgAttributes . '/>'; } $name = $image['name']; $date = $image['date']; // Click on image shall lead to gallery view if ($ImageLinkType > 0) { $HTML .= "</a>"; } // echo '<br>(3)\$HTML: "'.htmlentities($HTML).'"<br> '; // Show it ?> <div class="mod_rsgallery2_latest_images_attibutes" <?php echo $divAttributes; ?> >
// Get the gallery of the item to show $gallery = new rsgGallery($latestGalleries[$ItemIdx]); // Get the name of the item to show $ItemIdxName = $gallery->thumb->name; // Create HTML for image: get the url (with/without watermark) with img attributes if ($displayType == 1) { // *** display ***: $watermark = $rsgConfig->get('watermark'); //$imageUrl = $watermark ? waterMarker::showMarkedImage( $ItemIdxName ) : imgUtils::getImgDisplayPath( $ItemIdxName ); $imageUrl = $watermark ? waterMarker::showMarkedImage($ItemIdxName) : imgUtils::getImgDisplay($ItemIdxName); $HTML = '<img class="rsg2-displayImage" src="' . $imageUrl . '" alt="' . $ItemIdxName . '" title="' . $ItemIdxName . '" ' . $imgAttributes . '/>'; } elseif ($displayType == 2) { // *** original *** $watermark = $rsgConfig->get('watermark'); //$imageOriginalUrl = $watermark ? waterMarker::showMarkedImage( $ItemIdxName, 'original' ) : imgUtils::getImgOriginalPath( $ItemIdxName ); $imageOriginalUrl = $watermark ? waterMarker::showMarkedImage($ItemIdxName, 'original') : imgUtils::getImgOriginal($ItemIdxName); $HTML = '<img class="rsg2-displayImage" src="' . $imageOriginalUrl . '" alt="' . $ItemIdxName . '" title="' . $ItemIdxName . '" ' . $imgAttributes . '/>'; } else { // *** thumb *** $HTML = galleryUtils::getThumb($gallery->get('id'), $imageHeight, $imageWidth, "mod_rsgallery2_latest_galleries_img"); // thumbid, height, width, class } $name = $gallery->name; $date = $gallery->date; // Show it ?> <div class="mod_rsgallery2_latest_galleries_attributes" <?php echo $divAttributes; ?> > <div class="mod_rsgallery2_latest_galleries-cell">
/** * Copies original images from Pony Gallery to the RSGallery2 file structure * and then creates display and thumb images. * @param string full path to the original Pony Images * @return True id succesfull, false if not */ function copyImages($basedir, $prefix = "easy_") { global $rsgConfig; $database = JFactory::getDBO(); $sql = "SELECT * FROM #__easygallery"; $database->setQuery($sql); $result = $database->loadObjectList(); $i = 0; foreach ($result as $image) { $source = $basedir . "/" . $image->path; $filename = array_reverse(explode("/", $image->path)); $destination = JPATH_ORIGINAL . "/" . $prefix . $filename[0]; //First move image to original folder $newpath = fileUtils::move_uploadedFile_to_orignalDir($source, $destination); if ($newpath) { imgUtils::makeDisplayImage($newpath, '', $rsgConfig->get('image_width')); imgUtils::makeThumbImage($newpath); } else { $i++; } } if ($i > 0) { return false; } else { return true; } }