function regenerateImages()
{
    //Select the right gallery, multiple galleries or select them all
    $lists['gallery_dropdown'] = galleryUtils::galleriesSelectList(null, "gid[]", true, "MULTIPLE");
    html_rsg2_maintenance::regenerateImages($lists);
}
    function showUploadStep1()
    {
        ?>
        <script type="text/javascript">
        function submitbutton( pressbutton ) {
        var form = document.form;
        if ( pressbutton == 'controlPanel' ) {
        	location = "index2.php?option=com_rsgallery2";
        	return;
        }
        
        if ( pressbutton == 'upload' ) {
        	// do field validation
        	if (form.catid.value == "0")
            	alert( "<?php 
        echo JText::_('You must select a gallery.');
        ?>
" );
            else
            	form.submit();
        }
        	
  
        }
        </script>
        
        <table width="100%">
        <tr>
            <td width="300">&nbsp;</td>
            <td>
                <form name="form" action="index2.php?option=com_rsgallery2&task=upload" method="post">
                <input type="hidden" name="uploadStep" value="2" />
                <table class="adminform">
                <tr>
                    <th colspan="2"><font size="4"><?php 
        echo JText::_('Step 1');
        ?>
</font></th>
                </tr>
                <tr>
                    <td colspan="2">&nbsp;</td>
                </tr>
                <tr>
                    <td width="200">

                    <?php 
        echo JText::_('Pick a gallery');
        ?>
                    </td>
                    <td>
                        <?php 
        echo galleryUtils::galleriesSelectList(NULL, 'catid', false);
        ?>
                    </td>
                </tr>
                <tr>
                    <td colspan="2">&nbsp;</td>
                </tr>
                <tr class="row1">
                    <td colspan="2"><div style=text-align:center;></div></td>
                </tr>
                </table>
                </form>
               </td>
            <td width="300">&nbsp;</td>
       </tr>
       </table>
        <?php 
    }
Exemple #3
0
/**
 * Uploads single images
 */
function uploadImage($option)
{
    $database =& JFactory::getDBO();
    //Check if there are galleries created
    $database->setQuery("SELECT id FROM #__rsgallery2_galleries");
    $database->query();
    if ($database->getNumRows() == 0) {
        HTML_RSGALLERY::requestCatCreation();
        return;
    }
    //Create gallery selectlist
    $lists['gallery_id'] = galleryUtils::galleriesSelectList(NULL, 'gallery_id', false);
    html_rsg2_images::uploadImage($lists, $option);
}
    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">&nbsp;</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 
    }
    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%">&nbsp;</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'>&nbsp;</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>&nbsp;</th>
			        <th align="center"><?php 
        echo JText::_('Image');
        ?>
</th>
			        <th align="center"><?php 
        echo JText::_('Action');
        ?>
</th>
			    </tr>
			    <tr>
			        <td colspan="9">&nbsp;</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>&nbsp;</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 '[&nbsp;' . JText::_('Delete_from_database') . '&nbsp;]';
                ?>
</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 '[&nbsp;' . JText::_('Create_missing_images') . '&nbsp;]';
                    ?>
</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 '[&nbsp;' . JText::_('Create_Database_entry') . '&nbsp;]';
                ?>
</a><br />
			                <a href="index2.php?option=com_rsgallery2&rsgOption=maintenance&task=deleteImages&name=<?php 
                echo $diff;
                ?>
"><?php 
                echo '[&nbsp;' . JText::_('Delete_images'), '&nbsp;]';
                ?>
</a>&nbsp;
			                <?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 '[&nbsp;' . JText::_('Create missing images') . '&nbsp;]';
                    ?>
</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>&nbsp;|&nbsp; 
			    		<a href="javascript:void();" onClick="javascript:alert('<?php 
        echo JText::_('Not working yet');
        ?>
');"><?php 
        echo JText::_('Create missing images');
        ?>
</a>&nbsp;|&nbsp;
			    		<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%">&nbsp;</td>
	    </tr>
	    </table>
	    </form>
	    <?php 
    }
    function editCat($rows = null)
    {
        //Mirjam: In v1.13 catid was used where since v1.14 gid is used, but locally in a function catid is fine
        global $rsgConfig;
        $my = JFactory::getUser();
        $editor =& JFactory::getEditor();
        //Load frontend toolbar class
        require_once JPATH_ROOT . '/includes/HTML_toolbar.php';
        ?>
    <script type="text/javascript">
        function submitbutton(pressbutton) {
            var form = document.form2;
            if (pressbutton == 'cancel') {
                form.reset();
                history.back();
                return;
            }

         <?php 
        echo $editor->save('description');
        ?>
        
        // do field validation
		if (form.parent.value < 0) {
            alert( "<?php 
        echo JText::_('You must select a gallery.');
        ?>
" );
			return;
        }
        if (form.catname1.value == "") {
            alert( "<?php 
        echo JText::_('You must provide a gallery name.');
        ?>
" );
        }
        else if (form.description.value == ""){
            alert( "<?php 
        echo JText::_('You must provide a description.');
        ?>
" );
        }
        else{
            form.submit();
        }
        }
    </script>
    <?php 
        if ($rows) {
            foreach ($rows as $row) {
                $catname = htmlspecialchars($row->name, ENT_QUOTES);
                $description = htmlspecialchars($row->description, ENT_QUOTES);
                $ordering = $row->ordering;
                $uid = $row->uid;
                $catid = $row->id;
                $published = $row->published;
                $user = $row->user;
                $parent = $row->parent;
            }
        } else {
            $catname = "";
            $description = "";
            $ordering = "";
            $uid = "";
            $catid = "";
            $published = "";
            $user = "";
            $parent = "";
        }
        ?>
        <form name="form2" id="form2" method="post" action="<?php 
        echo JRoute::_("index.php?option=com_rsgallery2&rsgOption=myGalleries&task=saveCat");
        ?>
">
        <table width="100%">
        <tr>
            <td colspan="2"><h3><?php 
        echo JText::_('Create Gallery');
        ?>
</h3></td>
        </tr>
        <tr>

            <td align="right">
                <div style="float: right;">
                    <img onClick="submitbutton('save');" 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';" />&nbsp;&nbsp;
                    <img onClick="submitbutton('cancel')" 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';" />
                </div>
            </td>

        </tr>
        </table>
        <input type="hidden" name="catid" value="<?php 
        echo $catid;
        ?>
" />
        <input type="hidden" name="ordering" value="<?php 
        echo $ordering;
        ?>
" />
        <table class="adminlist" border="1">
        <tr>
            <th colspan="2"><?php 
        echo JText::_('Create Gallery');
        ?>
</th>
        </tr>
        <tr>
            <td><?php 
        echo JText::_('Top gallery');
        ?>
</td>
            <td>
                <?php 
        //galleryUtils::showCategories(NULL, $my->id, 'parent');
        ?>
                <?php 
        echo galleryUtils::galleriesSelectList($parent, 'parent', false);
        ?>
                <?php 
        //galleryUtils::createGalSelectList( NULL, $listName='parent', true );
        ?>
            </td>
        </tr>
        <tr>
            <td><?php 
        echo JText::_('Gallery name');
        ?>
</td>
            <td align="left"><input type="text" name="catname1" size="30" value="<?php 
        echo $catname;
        ?>
" /></td>
        </tr>
        <tr>
            <td colspan="2"><?php 
        echo JText::_('Description');
        ?>
                <?php 
        echo $editor->display('description', $description, '600', '200', '35', '15');
        ?>
            </td>
        </tr>
        <tr>
            <td><?php 
        echo JText::_('Published');
        ?>
</td>
            <td align="left"><input type="checkbox" name="published" value="1" <?php 
        if ($published == 1) {
            echo "checked";
        }
        ?>
 /></td>
        </tr>
        </table>
        </form>
        <?php 
    }