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; } }
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>';
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 }
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; ?> >
/** * 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 } }
/** * Retrieves the thumbnail image. presented in the category overview * @param int Category id * @param int image height * @param int image width * @param string Class name to format thumb view in css files * @return string html tag, showing the thumbnail * @todo being depreciated in favor of $rsgGallery->thumb() and $rsgDisplay functions */ function getThumb($catid, $height = 0, $width = 0, $class = "") { global $mainframe; $database = JFactory::getDBO(); //Setting attributes for image tag $imgatt = ""; if ($height > 0) { $imgatt .= " height=\"{$height}\" "; } if ($width > 0) { $imgatt .= " width=\"{$width}\" "; } if ($class != "") { $imgatt .= " class=\"{$class}\" "; } else { $imgatt .= " class=\"rsg2-galleryList-thumb\" "; } //If no thumb, show default image. if (galleryUtils::getFileCount($catid) == 0) { $thumb_html = "<img {$imgatt} src=\"" . JURI_SITE . "/components/com_rsgallery2/images/no_pics.gif\" alt=\"No pictures in gallery\" />"; } else { //Select thumb setting for specific gallery("Random" or "Specific thumb") $sql = "SELECT thumb_id FROM #__rsgallery2_galleries WHERE id = '{$catid}'"; $database->setQuery($sql); $thumb_id = $database->loadResult(); $list = galleryUtils::getChildList($catid); if ($thumb_id == 0) { //Random thumbnail $sql = "SELECT name FROM #__rsgallery2_files WHERE gallery_id IN ({$list}) AND published=1 ORDER BY rand() LIMIT 1"; $database->setQuery($sql); $thumb_name = $database->loadResult(); } else { //Specific thumbnail $thumb_name = galleryUtils::getFileNameFromId($thumb_id); } $thumb_html = "<img {$imgatt} src=\"" . imgUtils::getImgThumb($thumb_name) . "\" alt=\"\" />"; } return $thumb_html; }
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>