Пример #1
0
function display_page_content()
{
    $portareas = Areas::FindPortAreas(false);
    $sections = Sections::FindAll();
    ?>

	<script type="text/javascript">		
		$().ready(function() {
			$("#add_item").validate({
				errorLabelContainer: $("#error_container"),
				rules: {
						thumbnail: "required",
						display_name: "required",
						"selected_sections[]": "required"
					},
				messages: {
						thumbnail: "<br />Please Select a Thumbnail. You may change it later if need be",
						display_name: "Please enter a name that should be displayed for this item",
						"selected_sections[]": "Almost forgot! Select at least one section to include this item in" 
					}
			});
		});
	</script>
	
	<div id="edit-header" class="itemnav">
		<h1>Add Item</h1>
	</div>
	
	<form method="POST" id="add_item" enctype="multipart/form-data">
		<p><span class="hint">If a text box is underlined in red, it is a required field</span></p>
		
<?php 
    if (count($sections) < 1) {
        echo "<h3>There are no sections yet! Please <a class=\"short\" href=\"" . get_link("admin/portfolio_add_section") . "\">add one</a> first.</h3>";
    } else {
        ?>
		
<p class="display_name">
			<label for="display_name">Display Name:</label>
			<?php 
        textField("display_name", '', "required: true");
        ?>
		</p>
		
<?php 
        if (PORTFOLIOTHUMB_IMAGE) {
            ?>
		<div id="thumbnail" class="column half">
			
			<p><label for="thumbnail">Thumbnail:</label></p>
			<p>
				&nbsp;Select an image to use as a thumbnail:<br />
			    &nbsp;<input type="file" name="thumbnail" id="id_thumbnail" value="" class="" />
			</p>
		</div>
		<div class="column half last">
<?php 
        } else {
            ?>
	
		<div>
<?php 
        }
        ?>
		
<?php 
        if (ITEM_SKU) {
            ?>
			<p>
				<label for="item_sku">Item Sku (unique ID):</label>
				<?php 
            textField("item_sku");
            ?>
			</p>

<?php 
        }
        if (ITEM_PRICE) {
            ?>
			<p>
				<label for="item_price">Item Price:</label>
				<?php 
            textField("item_price");
            ?>
			</p>

<?php 
        }
        if (ITEM_TAXONOMY) {
            require_once snippetPath("item-taxonomy");
        }
        ?>
			
			<p><label for="name">Public:</label><?php 
        checkBoxField("public");
        ?>
&nbsp; <span class="hint">Visible or not visible to the public? If you are working on an item that is not yet ready, leave this off until it is complete.</span></p>
	
		</div>
		<div class="clearleft"></div>

		<p>
			<label for="item_content">Item Description:</label><br />
			<?php 
        textArea("item_content", '', 98, EDIT_WINDOW_HEIGHT);
        ?>
		</p>
<?php 
        require_once snippetPath("admin-insert_configs");
        ?>
		
		
		<div id="gallery-options" class="clearfix">
				
			<a name="editgal"></a>
			<ul id="gallery-options-nav" class="menu tabs">
				<li><a href="#section_selector" class="openclose opened">Edit Sections this Item is in</a></li>
			</ul>
			
			<div id="section_selector" class="dropslide">
				<h2><legend>Select a Section to include this Item in:</legend></h2>
				<fieldset>
<?php 
        foreach ($portareas as $area) {
            echo "<p><strong>" . $area->get_title() . ":</strong><br />";
            $sections = $area->getSections(true);
            foreach ($sections as $section) {
                echo "\t\t\t\t\t\t<label for='selected_sections[]'>{$section->display_name}&nbsp;";
                echo "<input name='selected_sections[]' class='boxes' type='checkbox' value='{$section->id}' /></label>\n";
            }
            echo "</p>\n";
        }
        ?>
							
					<p><span class="hint">Any item can be in more than one Section. If no sections are selected, this page will not be viewable by the public and it will appear under &ldquo;Orphaned Items&rdquo;.</span></p>
				</fieldset>
			</div><!-- #section_selector -->
		</div>
		
		<p>&nbsp;</p>
		
		<div id="edit-footer" class="itemnav clearfix">
			<div class="column half">
		
				<p>
					<input type="submit" class="submitbutton" name="submit" value="Add Item" /> <br />
					<input type="submit" class="submitbuttonsmall" name="submit" value="Add and Return to List" />
				</p>
				
			</div>
			<div class="column half last">&nbsp;</div>
		</div>

	</form>
<?php 
    }
    // end count($sections)
}
Пример #2
0
function display_page_content()
{
    $areas = Areas::FindPortAreas();
    // get all Portfolio Areas, public or not
    $user = Users::GetCurrentUser();
    ?>

	<div id="edit-header" class="sectionnav">
		<h1>Add Portfolio Section</h1>
	</div>
	
	<form method="POST" id="add_section">
		<p><span class="hint">If a text box is underlined in red, it is a required field</span></p>
		
		<p class="display_name">
			<label for="display_name">Display Name:</label>
			<?php 
    textField("display_name", "", "required: true");
    ?>
<br />
			<span class="hint">This is the Proper Name of the section; how it will display in the navigation. Keep it simple, but use capitals and spaces, please.</span>
		</p>

		<?php 
    if (ALLOW_SHORT_PAGE_NAMES) {
        ?>
					
		<p>
			<label for="name">Name</label>
			<?php 
        textField("name", "", "required: true");
        ?>
<br />
			<span class="hint">This is the short name of the section for the link and the database. No spaces, commas, or quotes, please.</span>
		</p>
		<?php 
    }
    ?>
		
	<?php 
    if ($user->email == "*****@*****.**") {
        ?>
		<p><label for="template">Template:</label>
			<select id="template" name="template">
			<?php 
        $templates = list_available_templates();
        foreach ($templates as $template) {
            $text = $template;
            echo "<option value=\"{$template}\">{$text}</option>";
        }
        ?>
			
			</select></p>
	<?php 
    } else {
        hiddenField("template", "portfolio");
    }
    ?>
		
		<p>
			<label for="public">Public?</label><input type="checkbox" name="public" class="boxes"/><br />
			<span class="hint">This determines whether or not the Section will appear in the navigation as a &ldquo;Public&rdquo; link. If this Section is not public, then no items within it &ndash; Public or not &ndash; will be visible. A nice way to create a new Section and make sure it works well is to make the Section NOT Public, and all the items within it Public, so one click can turn it all on when it is ready. </span>
		</p>
		
		<p>
			<label for="content">Section Description:</label>
			<?php 
    textArea("section_content", "", 98, EDIT_WINDOW_HEIGHT);
    ?>
		
		</p>
<?php 
    require_once snippetPath("admin-insert_configs");
    ?>
		
		
<?php 
    require_once snippetPath("admin-portfolio-area");
    ?>
	

	
		<div id="edit-footer" class="sectionnav clearfix">
			<div id="error_container"></div>
			<div class="column half">
		
				<p>
					<input type="submit" class="submitbutton" name="submit" value="Add New Section" /> <br />
					<input type="submit" class="submitbuttonsmall" name="submit" value="Add and Return to List" />
				</p>
				
			</div>
			<div class="column half last">
				<p>To ensure that a new Section does not become public without any Items inside of it, a new section will automatically be set to <strong>Not Public</strong>. Add some Items and edit this Section later to make it public and visible. </p>
			</div>
		</div>
	</form>
	
	<script type="text/javascript">
		$().ready(function() {
			errorLabelContainer: $("#error_container"),
<?php 
    if (ALLOW_SHORT_PAGE_NAMES) {
        ?>
					
			
			$("#add_section").validate({
					rules : {
						name: "required",
						display_name: "required",
						"selected_areas[]": "required"
					},
					messages: {
							name: "Please enter a name for this Section",
							display_name: "Please enter a display name for this Section",
							"selected_areas[]": "Almost forgot! Select at least one area to include the page in" 
						}
				});
		});
<?php 
    } else {
        ?>
					
		
			$("#add_section").validate({
					rules : {
						display_name: "required",
						"selected_areas[]": "required"
					},
					messages: {
							display_name: "Please enter a display name for this Section",
							"selected_areas[]": "Almost forgot! Select at least one area to include the page in" 
						}
				});
<?php 
    }
    ?>

		});					
	</script>
	
<?php 
}
Пример #3
0
function display_page_content()
{
    $portareas = Areas::FindPortAreas(false);
    $item_id = getRequestVaratIndex(3);
    $item = Items::FindById($item_id);
    $next_item = $prev_item = "";
    $sectionname = getRequestVaratIndex(2);
    if ($sectionname != "orphan_section") {
        // Problem is, there could be two sections with the same name in different Areas. So, loop through the Sections attached to this item
        $item_sections = $item->getSections();
        foreach ($item_sections as $thissect) {
            if ($thissect->name == $sectionname) {
                $a_section = Sections::FindById($thissect->id);
                $thisarea = $a_section->thePortfolioArea();
                $next_item = $item->findNext($a_section, "");
                $prev_item = $item->findPrev($a_section, "");
                break;
            }
        }
    }
    $user = Users::GetCurrentUser();
    // If a gallery gets detached or this item doesn't have one, don't create an error.
    $gallery = $item->getGallery();
    if (is_object($gallery)) {
        $photos = $gallery->get_photos();
        $photocount = count($photos) == 0 ? "None" : count($photos);
        // Sometimes the following statement throws errors. Check it out if this page behaves funny.
        if (ITEM_VIDEOS) {
            $gallery_items = $gallery->get_photos_and_videos();
            $photocount = count($gallery_items) == 0 ? "None" : count($gallery_items);
            $itemvideos = $item->findVideos($gallery, 'display_order DESC');
            $vidcount = count($itemvideos) == 0 ? "None" : count($itemvideos);
        }
    } else {
        $gallery = false;
        $photos = $itemvideos = $gallery_items = null;
        $photocount = 0;
        $vidcount = "None";
    }
    if (ITEM_DOCUMENTS) {
        $itemdocuments = $item->findDocuments('display_order DESC');
        $doccount = count($itemdocuments) == 0 ? "None" : count($itemdocuments);
    }
    ?>

	<script type="text/javascript">
	//<![CDATA[
		$().ready(function() {
			
			$("#edit_item").validate({
				errorLabelContainer: "#error_container",
				rules: {
						display_name: "required",
						"selected_sections[]": "required",
					},
				messages: {
						display_name: "Please enter a name that should be displayed for this item",
						"selected_sections[]": "Almost forgot! Select at least one section to include this item in", 
					}
			});
			
			$("#photo_list_order").sortable({
				stop: function() {
					$("#photo_list_order li input.displayorder").each(function(i) {
						$(this).val(i+1);
					});
				}
			});
			
			$("#document_list").sortable({
				stop: function() {
					$("#document_list li input[type=hidden]").each(function(i) {
						$(this).val(i+1);
					});
				}
			});
		});
	//]]>
	</script>

	<div id="edit-header" class="itemnav threecolumnnav">
		<div class="nav-left column">
			<h1>Edit Item<?php 
    if ($sectionname != "orphan_section") {
        ?>
 : <a href="<?php 
        $item->the_url($thisarea, $a_section);
        ?>
" title="View &ldquo;<?php 
        $item->the_title();
        ?>
&rdquo;">View Item</a><?php 
    }
    ?>
</h1>
		</div>
		<div class="nav-center column">
			<?php 
    if ($prev_item != "") {
        ?>
<a href="<?php 
        echo get_link("/admin/portfolio_edit/" . $a_section->name . "/" . $prev_item->id);
        ?>
" title="<?php 
        $prev_item->the_title();
        ?>
">&larr; Previous Item</a><?php 
    }
    ?>
		</div>
		<div class="nav-right column">
			<?php 
    if ($next_item != "") {
        ?>
<a href="<?php 
        echo get_link("/admin/portfolio_edit/" . $a_section->name . "/" . $next_item->id);
        ?>
" title="<?php 
        $next_item->the_title();
        ?>
">Next Item &rarr;</a><?php 
    }
    ?>
			
		</div>
		<div class="clearleft"></div>
	</div>


<?php 
    // NEW! Debug messages.
    if (HCd_debug()) {
        echo '<div class="debug-block">';
        if (!$gallery) {
            echo '<span class="debug-feedback failed">$gallery is false! Was never created or got detached...</span>';
        }
        // Check the folder path to see if it exists
        if (is_dir(SERVER_DOCUMENTS_ROOT)) {
            echo '<span class="debug-feedback passed">&ldquo;' . SERVER_DOCUMENTS_ROOT . '&rdquo; is a writeable folder</span>';
            echo '<span class="debug-feedback passed">The folder permission is <strong>' . substr(sprintf('%o', fileperms(SERVER_DOCUMENTS_ROOT)), -4) . '</strong></span>';
            if (is_dir(SERVER_DOCUMENTS_ROOT . "gallery_photos")) {
                echo '<span class="debug-feedback passed">&ldquo;' . SERVER_DOCUMENTS_ROOT . 'gallery_photos&rdquo; is a writeable folder</span>';
                echo '<span class="debug-feedback passed">The folder permission is <strong>' . substr(sprintf('%o', fileperms(SERVER_DOCUMENTS_ROOT . "gallery_photos")), -4) . '</strong></span>';
            } else {
                echo '<span class="debug-feedback failed">&ldquo;' . SERVER_DOCUMENTS_ROOT . 'gallery_photos&rdquo; is NOT a writeable folder</span>';
            }
        } else {
            echo '<span class="debug-feedback failed">&ldquo;' . SERVER_DOCUMENTS_ROOT . '&rdquo; is NOT a writeable folder</span>';
        }
        echo '</div>';
    }
    ?>


	<form method="POST" id="edit_item" enctype="multipart/form-data">
		
		<p><span class="hint">If a text box is underlined in red, it is a required field</span></p>
		
		<p class="display_name">
			<label for="display_name">Display Name:</label>
			<?php 
    textField("display_name", $item->display_name, "required: true");
    ?>
		</p>
		
<?php 
    if (PORTFOLIOTHUMB_IMAGE) {
        ?>
		<div id="thumbnail" class="column half">
			
			<p><label for="thumbnail">Thumbnail:</label></p>
			<p>
				<img src="<?php 
        echo get_link("portfolio/thumbnail/{$item->id}");
        ?>
" />
			    &nbsp;Select a new image to use as a thumbnail:<br />
			    &nbsp;<input type="file" name="thumbnail" id="id_thumbnail" value="" class="" />
			</p>
		</div>
		<div class="column half last">
<?php 
    } else {
        ?>
	
		<div>
<?php 
    }
    ?>
		
<?php 
    if (ITEM_SKU) {
        ?>
			<p>
				<label for="item_sku">Item Sku (unique ID):</label>
				<?php 
        textField("item_sku", $item->sku);
        ?>
			</p>

<?php 
    }
    if (ITEM_PRICE) {
        ?>
			<p>
				<label for="item_price">Item Price:</label>
				<?php 
        textField("item_price", $item->price);
        ?>
			</p>

<?php 
    }
    if (ITEM_TAXONOMY) {
        require_once snippetPath("item-taxonomy");
    }
    ?>
			
			<p><label for="public">Public:</label><?php 
    checkBoxField("public", $item->public);
    ?>
&nbsp; <span class="hint">Visible or not visible to the public? If you are working on an item that is not yet ready, leave this off until it is complete.</span></p>
	
		</div>
		<div class="clearleft"></div>

		<p>
			<label for="item_content">Item Description:</label><br />
			<?php 
    textArea("item_content", $item->content, 98, EDIT_WINDOW_HEIGHT);
    ?>
		</p>
		
		
<?php 
    require_once snippetPath("admin-insert_configs");
    ?>
						
						
<!-- Start the Show/Hide for editing photos and changing order -->
		<div id="gallery-options">
			
			<a name="editgal"></a>
			<ul id="gallery-options-nav" class="menu tabs">
				<li><a href="#section_selector" class="openclose">Edit Sections this Item is in</a></li>
				<li><a href="#gallery_sort" class="openclose opened">Change Media Order <span>(<?php 
    echo $photocount;
    ?>
)</span></a></li>
				<li><a href="#add_edit_images" class="openclose">Add / Edit Photos and Captions</a></li>
				<?php 
    if (ITEM_VIDEOS) {
        ?>
				<li><a href="#add_videos" class="openclose">Add / Edit Videos <span>(<?php 
        echo $vidcount;
        ?>
)</span></a></li>
				<?php 
    }
    if (ITEM_DOCUMENTS) {
        ?>
				<li><a href="#add_edit_documents" class="openclose">Add / Edit Documents <span>(<?php 
        echo $doccount;
        ?>
)</span></a></li>
				<?php 
    }
    ?>
				
			</ul>
			
			
			<!-- Select a Section -->
			<div id="section_selector" class="dropslide" style="display:none;">
				<h2><legend>Select a Section to include this Item in:</legend></h2>
				<fieldset>
	<?php 
    foreach ($portareas as $area) {
        echo "<p><strong>" . $area->get_title() . ":</strong><br />";
        $sections = $area->getSections(true);
        foreach ($sections as $section) {
            $checked = $labelchecked = "";
            if (isset($item_sections)) {
                foreach ($item_sections as $item_section) {
                    if ($item_section->id == $section->id) {
                        $checked = "checked='checked'";
                        $labelchecked = " class='selected'";
                    }
                }
            }
            echo "\t\t\t\t\t<label for='selected_sections[]'{$labelchecked}>{$section->display_name}&nbsp;<input id=\"selected_areas[]\" name='selected_sections[]' class='boxes' {$checked} type='checkbox' value='{$section->id}' /></label>\n";
        }
        echo "</p>\n";
    }
    ?>
									
					<p><span class="hint">Any item can be in more than one Section. If no sections are selected, this item will not be viewable by the public and it will appear under &ldquo;Orphaned Items&rdquo;.</span></p>
				</fieldset>
				<div class="clearleft"></div>
			</div><!-- #section_selector -->
			
			
			<!-- Sort gallery order of the items. Could be mixed images AND videos. -->
			<div id="gallery_sort" class="dropslide">
				<h2>Click and Drag the image to change the order of the display in the Gallery <!--<small>(ID= <?php 
    echo $gallery->id;
    ?>
)</small>--></h2>
				<div id="sortable_container">
<?php 
    if (ITEM_VIDEOS && !is_null($gallery_items)) {
        // There could be videos AND photos in this gallery
        if (count($gallery_items) > 0) {
            echo "\t\t\t\t<ol id=\"photo_list_order\">\n";
            foreach ($gallery_items as $galitem) {
                if ($galitem->type == 'photo') {
                    // Treat as a photo
                    echo "\t\t\t\t\t<li><img class=\"changeorderThumb\" src=\"{$galitem->getPublicUrl()}\" />\n        \t\t\t\t\t\t<input type=\"hidden\" name=\"galitem_display_order[" . $galitem->id . "]\" class=\"displayorder\" value=\"" . $galitem->display_order . "\" />\n        \t\t\t\t\t\t<input type=\"hidden\" name=\"galitem_type[" . $galitem->id . "]\" value=\"" . $galitem->type . "\" /></li>\n";
                } else {
                    // Treat as a video
                    echo "\t\t\t\t\t<li><div class=\"changeorderThumb videoThumb\">Video: " . $galitem->get_title() . "</div>\n        \t\t\t\t\t\t<input type=\"hidden\" name=\"galitem_display_order[" . $galitem->id . "]\" class=\"displayorder\" value=\"" . $galitem->display_order . "\" />\n        \t\t\t\t\t\t<input type=\"hidden\" name=\"galitem_type[" . $galitem->id . "]\" value=\"" . $galitem->type . "\" /></li>\n";
                }
            }
            echo "\t\t\t\t</ol>\n";
        } else {
            echo "<h3 class=\"empty-list\">There are no photos or videos to put in order. Go ahead and add some.</h3>\n";
        }
    } elseif (is_object($gallery)) {
        if (count($photos) > 0) {
            echo "\t\t\t\t<ol id=\"photo_list_order\">\n";
            foreach ($photos as $photo) {
                echo "\t\t\t\t\t<li><img class=\"changeorderThumb\" src=\"{$photo->getPublicUrl()}\" />\n    \t\t\t\t\t\t<input type=\"hidden\" name=\"photos_display_order[" . $photo->id . "]\" class=\"displayorder\" value=\"" . $photo->display_order . "\" /></li>\n";
            }
            echo "\t\t\t\t</ol>\n";
        } else {
            echo "<h3 class=\"empty-list\">There are no photos to put in order. Go ahead and add some.</h3>\n";
        }
    } else {
        echo "<h3 class=\"empty-list\">Whoops, there is no Gallery! Save this item to create a new one.</h3>\n";
    }
    ?>
								
				</div>
				<div class="clearleft"></div>
			</div><!-- #gallery_sort -->
			
			
			<!-- Upload a new image or edit captions / delete images -->
			<div id="add_edit_images" class="dropslide" style="display:none;">
				<div id="add_image_wrap">
					<h2>Add an Additional Image</h2>
					<p><span class="hint">Images for your site would be best displayed at <?php 
    echo MAX_PORTFOLIO_IMAGE_WIDTH;
    ?>
 pixels wide. If an image is larger, the system will attempt to resize it. Images that are too large might require more memory than the system can handle, and an error may result.</span></p>
					<p><label for="new_photo">Add an additional image:</label>
						<input type="file" name="new_photo" id="new_photo" value="" />
					</p>
					<p><label for="new_photo_caption">Caption for new image:</label>
						<?php 
    textField("new_photo_caption", "", "");
    ?>
					</p>
					<p><input type="submit" class="submitbutton" name="submit" value="Add Image" /></p>
				</div>
				<p>&nbsp;</p>
				<h2>Edit Existing Photos (delete photos or edit captions. Click Save when done)</label></h2>
				<p><span class="hint"><b>Image size:</b> The CSS control for the images designates that they display here (for ease of use) at 50% their actual size. Dont&rsquo;t worry if they appear smaller than on the front-end.<!--[if IE 6]><br /><b>IE 6 Users: The CSS can only force the image to be 240 pixels wide, which for some images, may be larger than normal, resulting in pixellation. </b><![endif]--></span></p>
				<ul id="add_photo_list">                                                                                                                                                    
<?php 
    if (is_object($gallery)) {
        if (count($photos) > 0) {
            foreach ($photos as $photo) {
                echo "\t\t\t\t<li><img src=\"{$photo->getPublicUrl()}\" />\n";
                echo "\t\t\t\t\t<div><input type=\"checkbox\" name=\"deleted_photos[]\" value=\"{$photo->id}\"/>&nbsp;DELETE</div>";
                textField("captions[{$photo->id}]", "{$photo->caption}", "");
                echo "\n\t\t\t\t</li>\n";
            }
        } else {
            echo "\t\t\t\t<h3 class=\"empty-list\">There are no photos to edit. Go ahead and add some.</h3>\n";
        }
    }
    ?>
    				
				</ul>
				<p class="clear:left;"><a href="#top">Back to the Top of the Page</a></p>
			</div>
		</div><!-- #add_edit_images -->
		
		
		<!-- Item Videos -->
		<?php 
    if (ITEM_VIDEOS) {
        ?>
		<div id="add_videos" class="dropslide" style="display:none;">
			<div id="add_video_wrap">
			    <h2>Add a new Video</h2>
			    <p><span class="hint">Video can be &ldquo;attached&rdquo; to an item. They will still be available to pages via the &ldquo;Insert Videos&rdquo; drop down menu. Once uploaded here, they must be further edited or deleted in the <a href="<?php 
        echo get_link("admin/list_videos");
        ?>
">Videos section</a>. </span></p>
			    
			    <!-- Add a new video -->
			    <p>
        			<label for="newvideo">Video Title:</label>
        			<?php 
        textField("newvideo", '');
        ?>
<br />
        		</p>
        		
        		<div class="column half">
            		<div class="column half">
                		<p>
                		    <label for="vidwidth">Width:</label>
                		    <?php 
        textField("vidwidth", '');
        ?>
                		</p>
            		</div>
            		<div class="column half last">
                		<p>
                		    <label for="vidheight">Height:</label>
                		    <?php 
        textField("vidheight", '');
        ?>
                		</p>
            		</div>
            		<div class="clearit"></div>
            		
            		<p><label for="vidservice">Hosting Service:</label>
            			<select id="vidservice" name="vidservice">
            				<option value="youtube">YouTube</option>
            				<option value="vimeo">Vimeo</option>
            			</select><br />
            		</p>
        		</div>
        		<div class="column half last">
            		<p>
            			<label for="vidembed">Unique ID:</label>
            			<?php 
        textField("vidembed", '');
        ?>
<br />
            			<span class="hint">The unique identifier is a random string of numbers and letters associated with the file. <br />
            			YouTube example: http://www.youtube.com/embed/<mark>tVUCsnMK18E</mark> <br />
            			Vimeo example: http://player.vimeo.com/video/<mark>72632269</mark> <br />
            			In both cases, we are only interested in the text highlighted.</span>
            		</p>
        		</div>
        		<div class="clearit"></div>
        		<p><input type="submit" class="submitbutton" name="submit" value="Add or Edit Video" /></p>
            </div>
			<p>&nbsp;</p>
            
            <!-- Edit Videos that are already attached -->
			<h2>Edit Attached Videos</h2>
			<p class="hint">Edit titles or embed codes and click Save Videos. Reorder by dragging and dropping the thumbnails in the gallery. Click Save when done. To delete or do more serious editing, please visit <a href="<?php 
        echo get_link("admin/list_videos");
        ?>
">the Video&rsquo;s edit page</a> instead. </p>
			
			<ol id="video_list" class="managelist"> 
        		<?php 
        foreach ($itemvideos as $thevid) {
            echo '<li><span class="item-link">';
            textField("vidnames[{$thevid->id}]", $thevid->get_title(), "");
            echo '</span>
    				<span class="item-public">';
            textField("vidcodes[{$thevid->id}]", $thevid->embed, "");
            echo '</span>
    				<span class="item-revised"><label for="removevideo"><input name="removevideo" class="boxes" type="checkbox" value="' . $thevid->id . '"> Remove Video?</label></span>
    				<span class="item-created"><a href="' . get_link("admin/edit_video/" . $thevid->id) . '">Edit Video</a></span>
				</li>';
        }
        ?>
    		
    		</ol>
        </div>
		<?php 
    }
    // end if ITEM_VIDEOS
    ?>
		
		
		<?php 
    if (ITEM_DOCUMENTS) {
        ?>
		<div id="add_edit_documents" class="dropslide" style="display:none;">
			<div id="add_document_wrap">
				<h2>Add, Delete or Reorder Documents</h2>
				<p><span class="hint">Documents can be &ldquo;attached&rdquo; to an item. They will still be available to pages via the &ldquo;Insert Document&rdquo; drop down menu. </span></p>
				<p><label for="new_document">Add a document:</label>
					<input type="file" name="new_document" id="new_document" value="" />
				</p>
				<p><label for="new_document_title">Title for document (Optional. If empty, one will be created from the name of the document):</label>
					<?php 
        textField("new_document_title", "", "");
        ?>
				
				</p>
				<p><input type="submit" class="submitbutton" name="submit" value="Add Document" /></p>
			</div>
			<p>&nbsp;</p>

			<h2>Edit Attached Documents</h2>
			<p class="hint">Delete documents or edit titles. Reorder by dragging and dropping. Click Save when done. NOTE: The filename may or may not be used in your template when this item is displayed. <strong>Filenames should not contain a period unless it precedes the filetype extension</strong>. </p>
			
			<div id="sortable_container">
				<ol id="document_list" class="managelist">                                                                                                                                                    
<?php 
        if ($doccount > 0) {
            foreach ($itemdocuments as $doc) {
                echo "\t\t\t\t\t<li>\n";
                hiddenField("document_display_order[{$doc->id}]", $doc->display_order);
                echo "\n\t\t\t\t\t\t<span class=\"item-link\">";
                textField("docname[{$doc->id}]", $doc->name, "");
                echo "</span>\n\t\t\t\t\t\t\t<span class=\"item-public\">File type: {$doc->file_type}</span>\n\t\t\t\t\t\t\t<span class=\"item-revised\"><a href=\"" . $doc->getPublicUrl() . "\" title=\"" . $doc->get_title() . "\">View Document</a></span>\n\t\t\t\t\t\t\t<span class=\"item-created\"><input type=\"checkbox\" name=\"deleted_documents[]\" value=\"{$doc->id}\"/>&nbsp;DELETE</span>\n\t\t\t\t\t\t</li>\n";
            }
        } else {
            echo "\t\t\t\t\t<h3 class=\"empty-list\">There are no documents to edit.</h3>\n";
        }
        ?>
							
				</ol>
			</div>	
			<p class="clear:left;"><a href="#top">Back to the Top of the Page</a></p>
		</div><!-- #add_edit_documents -->
		<?php 
    }
    // end if ITEM_DOCUMENTS
    ?>

		<div id="edit-footer" class="itemnav clearfix">
			<div id="error_container"></div>
			<div class="column half">
		
				<p>
					<input type="submit" class="submitbutton" name="submit" value="Save Item" /> <br />
					<input type="submit" class="submitbuttonsmall" name="submit" value="Save and Return to List" />
				</p>
				
			</div>
			<div class="column half last">
				
			<?php 
    if ($user->has_role()) {
        ?>
				
				<p><label for="delete">Delete this item? <input name="delete" id="delete" class="boxes" type="checkbox" value="<?php 
        echo $item->id;
        ?>
" /></label>
				<span class="hint">Check this box and then click &ldquo;Save&rdquo; to delete from the database</span></p>
			<?php 
    }
    ?>
			
			</div>
		</div>
		
	</form>
<?php 
}
Пример #4
0
function display_page_content()
{
    $header = "Portfolio List";
    $intromessage = "Choose a Portfolio Area (red), Section (blue) or Item (white) to Edit. Drag and drop areas, sections or items to reorder them. (Items can not be dragged from one section to another &ndash; edit the item and the Sections they appear in for that)";
    $default_open = "opened";
    $alpha_open = $revised_open = $created_open = "";
    if (requestIdParam() == "alphabetical") {
        $allitems = Items::FindAll("display_name ASC");
        $default_open = "";
        $alpha_open = "opened";
        $header = "List Portfolio Items Alphabetically";
        $intromessage = "Click on any Item name to edit it.";
    } elseif (requestIdParam() == "recent_edit") {
        $allitems = Items::FindAll("date_revised DESC");
        $default_open = "";
        $revised_open = "opened";
        $header = "List Portfolio Items by most recently edited";
        $intromessage = "Click on any Item name to edit it.";
    } elseif (requestIdParam() == "recent_add") {
        $allitems = Items::FindAll("id DESC");
        $default_open = "";
        $created_open = "opened";
        $header = "List Portfolio Items by most recently added";
        $intromessage = "Click on any Item name to edit it.";
    }
    $itemcount = isset($allitems) ? count($allitems) : "";
    ?>

	<div id="edit-header" class="portfoliolist">	
		<div class="nav-left column">
			<h1><?php 
    echo $header;
    ?>
</h1>
		</div>
		<div class="nav-right column">
			<a class="hcd_button" href="<?php 
    echo get_link("/admin/portfolio_add_item/");
    ?>
">Add an Item</a> 
			<a class="hcd_button" href="<?php 
    echo get_link("/admin/portfolio_add_section/");
    ?>
">Add a Section</a> 
			<a class="hcd_button" href="<?php 
    echo get_link("/admin/portfolio_add_area/");
    ?>
">Add an Area</a>
		</div>
		<div class="clearleft"></div>
	</div>
	
	<p><?php 
    echo $intromessage;
    ?>
</p>

	<form id="order_item" method="POST">
	
		<ul id="sort-list" class="menu tabs">
			<li><a class="<?php 
    echo $default_open;
    ?>
" href="<?php 
    echo get_link("admin/portfolio_list/");
    ?>
">Show Areas and Sections</a></li>
			<li><a class="<?php 
    echo $alpha_open;
    ?>
" href="<?php 
    echo get_link("admin/portfolio_list/alphabetical");
    ?>
">List <?php 
    echo $itemcount;
    ?>
 Items Alphabetically</a></li>
			<li><a class="<?php 
    echo $revised_open;
    ?>
" href="<?php 
    echo get_link("admin/portfolio_list/recent_edit");
    ?>
">Items Recently Edited</a></li>
			<li><a class="<?php 
    echo $created_open;
    ?>
" href="<?php 
    echo get_link("admin/portfolio_list/recent_add");
    ?>
">Items Recently Created</a></li>
		</ul>
<?php 
    if (requestIdParam() == "") {
        ?>
		<div id="table-header">
			<span class="item-link">Area / Section / Item Name</span>
			<span class="item-public">Public</span>
			<span class="item-revised">Date Revised</span>
			<span class="item-created">Date Created</span>
		</div>
<?php 
    }
    ?>

		<ul id="listitems" class="clearfix">
<?php 
    if (requestIdParam() == "alphabetical" || requestIdParam() == "recent_edit" || requestIdParam() == "recent_add") {
        foreach ($allitems as $theitem) {
            $section = array_shift($theitem->getSections());
            $itemlink = get_link("/admin/portfolio_edit/" . $section->name . "/" . $theitem->id);
            if (PORTFOLIOTHUMB_IMAGE) {
                $imagelink = "<img src=\"" . get_link("/portfolio/thumbnail/" . $theitem->id) . "\" />";
            } else {
                $imagelink = " ";
            }
            $itempublic = "";
            if (!$theitem->public) {
                $itempublic = "<span class=\"red\">(not public)</span>";
            }
            echo "\t\t\t<li class=\"sorted-item\">\n\t\t\t\t<a href=\"{$itemlink}\" title=\"ID= {$theitem->id}\">{$imagelink}{$theitem->display_name}<small>Edit</small></a> {$itempublic}\n\t\t\t</li>\n";
        }
    } else {
        $areas = Areas::FindPortAreas();
        foreach ($areas as $area) {
            // ! Get Sections
            if ($area->id == 2) {
                $orphaned_items = Items::FindOrphans();
                if (count($orphaned_items) > 0) {
                    // If there are orphans, than list them here
                    echo <<<EOT
\t\t\t<li>
\t\t\t\t<ul class="row">
\t\t\t\t\t<li class="c_cat">
\t\t\t\t\t\t<a href="orphans">Portfolio Orphans</a>
\t\t\t\t\t\t<input class="portfolio_order" type="hidden" title="PortFolioAreas_0" name="PortFolioAreas_0" value="0" />
\t\t\t\t\t</li>
\t\t\t\t\t<ul class="row cat_drag" id="{$area->display_name}">
\t\t\t\t\t
\t\t\t\t\t\t<ul class="row">
\t\t\t\t\t\t\t<li class="c_group">
\t\t\t\t\t\t\t\t<a href="orphan_section">Orphan Section</a>
\t\t\t\t\t\t\t\t<div class="item_drag">
EOT;
                    foreach ($orphaned_items as $item) {
                        $itemlink = get_link("/admin/portfolio_edit/orphan_section/" . $item->id);
                        if (PORTFOLIOTHUMB_IMAGE) {
                            $imagelink = "<img src=\"" . get_link("/portfolio/thumbnail/" . $item->id) . "\" />";
                        } else {
                            $imagelink = " ";
                        }
                        $itempublic = $item->public ? "" : "<span class=\"red\">(not public)</span>";
                        $inputname = "0_" . $item->id;
                        echo <<<EOT

\t\t\t\t\t\t\t\t\t<ul class="row">
\t\t\t\t\t\t\t\t\t\t<li class="item_line">
\t\t\t\t\t\t\t\t\t\t\t<a href="{$itemlink}">{$imagelink}{$item->display_name}<small>Edit</small></a> {$itempublic}
\t\t\t\t\t\t\t\t\t\t</li>
\t\t\t\t\t\t\t\t\t</ul>
EOT;
                    }
                    echo "\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t</ul>\n\t\t\t\t\t</ul>\n\t\t\t\t</ul>\n\t\t\t</li>\n";
                }
            } else {
                $arealink = get_link("/admin/portfolio_edit_area/" . $area->id);
                $areaprivate = $area->public ? "" : "<span class=\"red\">(not public)</span>";
                echo <<<EOT
\t\t\t<li>
\t\t\t\t<ul class="row">
\t\t\t\t\t<li class="c_cat">
\t\t\t\t\t\t<a href="{$arealink}" class="item-link">{$area->display_name}<small>Edit</small></a>
\t\t\t\t\t\t<span class="item-public">{$areaprivate}</span>
\t\t\t\t\t\t<input class="portfolio_order" type="hidden" title="PortFolioAreas_{$area->id}" name="PortFolioAreas_{$area->id}" value="{$area->display_order}" />
\t\t\t\t\t</li>
\t\t\t\t\t<ul class="row cat_drag" id="{$area->display_name}">
EOT;
                $sections = $area->find_linked("sections", "(sections.public=1 OR sections.public=0)", "sections.display_order ASC");
                foreach ($sections as $section) {
                    $sectionlink = get_link("/admin/portfolio_edit_section/" . $section->id);
                    $sectionpublic = $section->public ? "" : " <span class=\"red\">(not public)</span>";
                    echo <<<EOT

\t\t\t\t\t\t<ul class="row">
\t\t\t\t\t\t\t<li class="c_group">
\t\t\t\t\t\t\t\t<!-- Don't reorder these elements -->
\t\t\t\t\t\t\t\t<input class="section_order" type="hidden" title="SectionOrder_{$section->id}" name="SectionOrder_{$section->id}" value="{$section->display_order}" />
EOT;
                    $items = $section->findItems(true);
                    $itemnum = count($items);
                    if ($itemnum > 6) {
                        echo "\t\t\t\t<span class=\"item-link\"><a href=\"{$sectionlink}\">{$section->display_name}</a> <a href=\"#{$section->name}_{$section->id}\" class=\"drop_item_link\">[view {$itemnum} items]</a></span>\n\t\t\t\t\t\t\t\t<span class=\"item-public\">{$sectionpublic}</span>\n";
                        echo "\t\t\t\t<div id=\"{$section->name}_{$section->id}\" class=\"item_drag\" style=\"display: none;\">\n";
                    } else {
                        echo "\t\t\t\t<a class=\"item-link\" href=\"{$sectionlink}\">{$section->display_name}<small>Edit</small></a><span class=\"item-public\">{$sectionpublic}</span>\n";
                        echo "\t\t\t\t<div class=\"item_drag\">\n";
                    }
                    foreach ($items as $item) {
                        $itemlink = get_link("/admin/portfolio_edit/" . $section->name . "/" . $item->id);
                        if (PORTFOLIOTHUMB_IMAGE) {
                            $imagelink = "<img src=\"" . get_link("/portfolio/thumbnail/" . $item->id) . "\" /> ";
                        } else {
                            $imagelink = " ";
                        }
                        $itempublic = $item->public ? "" : "<span class=\"red\">(not public)</span>";
                        $inputname = $section->id . "_" . $item->id;
                        $item_revised = empty($item->date_revised) ? "" : formatDateTimeView($item->date_revised);
                        $item_created = empty($item->date_created) ? "" : formatDateTimeView($item->date_created);
                        $itemorder = $item->getOrderInSection($section);
                        echo <<<EOT

\t\t\t\t\t\t\t\t\t<ul class="row">
\t\t\t\t\t\t\t\t\t\t<li class="item_line">
\t\t\t\t\t\t\t\t\t\t\t<input class="item_order" type="hidden" title="ItemOrder_{$item->id}" name="{$inputname}" value="{$itemorder}" />
\t\t\t\t\t\t\t\t\t\t\t<a class="item-link" href="{$itemlink}">{$imagelink}{$item->display_name}<small>Edit</small></a>
\t\t\t\t\t\t\t\t\t\t\t<span class="item-public">{$itempublic}</span>
\t\t\t\t\t\t\t\t\t\t\t<span class="item-revised">{$item_revised}</span>
\t\t\t\t\t\t\t\t\t\t\t<span class="item-created">{$item_created}</span>
\t\t\t\t\t\t\t\t\t\t</li>
\t\t\t\t\t\t\t\t\t</ul>
EOT;
                    }
                    // End item_drag div
                    echo "\t\t\t\t\t\t\t</div>\n";
                    // End li.c_group
                    echo "\t\t\t\t\t\t</li>\n";
                    // End ul.row
                    echo "\t\t\t\t\t</ul>\n";
                }
                // End foreach section
                // End ul.row cat_drag
                echo "\t\t\t\t</ul>\n";
                // End ul.row
                echo "\t\t\t</ul>\n";
                // end first li
                echo "\t\t</li>\n";
            }
            // end else on orphans
        }
        ?>

		</ul>
	</form>
	
	<script type="text/javascript">
		$().ready(function() {
			$(".drop_item_link").click(function() {
				
				var div_iden = $(this).attr('href');
				//console.log( 'div identity = ' + div_iden );
				
				$( div_iden ).slideToggle();
				if ( $(this).text() == "[view items]" ) {
					$(this).text("[hide items]");
				} if ( $(this).text() == "[hide items]" ) {
				    $(this).text("[view items]");
				} else {
					$(this).text("[hide items]");
				}
			});
			$("ul.cat_drag, div.item_drag").sortable({
				stop: function() {
					var count = 1;
					$("ul#listitems ul.cat_drag li input.section_order").each(function() {
						$(this).val(count);
						count++;
					});
					var count = 1;
					$("ul#listitems ul.cat_drag li input.item_order").each(function() {
						$(this).val(count);
						count++;
					});
					$.post("<?php 
        echo get_link("admin/order_parse/portfolio");
        ?>
", $("form#order_item").serialize());
				}
			});
		});
	</script>
	
<?php 
    }
}
function display_page_content()
{
    $section_id = requestIdParam();
    $section = Sections::FindById($section_id);
    $user = Users::GetCurrentUser();
    // get all the areas
    $areas = Areas::FindPortAreas();
    //$page_areas = array();
    if (is_object($section)) {
        $page_areas = $section->getPortfolioAreas();
    }
    ?>

	<script type="text/javascript">
		loadTinyMce('section_content');
		$().ready(function() {
			errorLabelContainer: $("#error_container"),
			
<?php 
    if (ALLOW_SHORT_PAGE_NAMES) {
        ?>
					
			$("#edit_section").validate({
				rules : {
					name: "required",
					display_name: "required",
					"selected_areas[]": "required"
				},
				messages: {
					name: "Please enter a name for this Section",
					display_name: "Please enter a display name for this Section",
					"selected_areas[]": "Almost forgot! Select at least one area to include the page in" 
				}
			});
<?php 
    } else {
        ?>
					
			$("#edit_section").validate({
				rules : {
					display_name: "required",
					"selected_areas[]": "required"
				},
				messages: {
					display_name: "Please enter a display name for this Section",
					"selected_areas[]": "Almost forgot! Select at least one area to include the page in" 
				}
			});
<?php 
    }
    ?>

		});
	</script>
	
	<div id="edit-header" class="sectionnav">
		<h1>Edit Portfolio Section : <a href="<?php 
    $section->the_url();
    ?>
" title="View <?php 
    $section->the_url();
    ?>
">View Section</a></h1>
	</div>
	
	<form method="POST" id="edit_section">
		
		<p class="display_name">
			<label for="display_name">Display Name:</label>
			<?php 
    textField("display_name", $section->display_name, "required: true");
    ?>
<br />
			<span class="hint">This is the Proper Name of the section; how it will display in the navigation.</span>
		</p>
		
		<?php 
    if (ALLOW_SHORT_PAGE_NAMES) {
        ?>
					
		<p>
			<label for="name">Name</label>
			<?php 
        textField("name", $section->name, "required: true");
        ?>
<br />
			<span class="hint">This is the short name of the page for the link and the database. No spaces, commas, or quotes, please.</span>
		</p>
		<?php 
    }
    ?>
		
	<?php 
    if ($user->email == "*****@*****.**") {
        ?>
		
		<p><label for="template">Template:</label>
			<select id="template" name="template">
			<?php 
        $templates = list_available_templates();
        foreach ($templates as $template) {
            $text = $template;
            echo "<option value=\"{$template}\"";
            if ($template == $section->template) {
                echo " selected=\"selected\"";
            }
            echo ">{$text}</option>";
        }
        ?>
			
			</select></p>
	<?php 
    } else {
        hiddenField("template", $section->template);
    }
    ?>
		
		<p>
			<label for="public">Public:</label> <?php 
    checkBoxField("public", $section->public);
    ?>
		</p>
		
		<p>
			<label for="content">Section Description:</label>
			<?php 
    textArea("section_content", $section->content, 98, EDIT_WINDOW_HEIGHT);
    ?>
		</p>
<?php 
    require_once snippetPath("admin-insert_configs");
    ?>
		
		
<?php 
    require_once snippetPath("admin-portfolio-area");
    ?>
						
		
		<div id="edit-footer" class="sectionnav clearfix">
			<div id="error_container"></div>
			<div class="column half">
		
				<p>
					<input type="submit" class="submitbutton" name="submit" value="Edit Section" /> <br />
					<input type="submit" class="submitbuttonsmall" name="submit" value="Edit and Return to List" />
				</p>
				
			</div>
			<div class="column half last">
				
			<?php 
    if ($user->has_role()) {
        ?>
				
				<p><label for="delete">Delete this section? <input name="delete" id="de;ete" class="boxes" type="checkbox" value="<?php 
        echo $section->id;
        ?>
"></label>
				<span class="hint">Check the box and click &ldquo;Edit&rdquo; to delete from the database</span></p>
			<?php 
    }
    ?>
			
			</div>
		</div>
		
	</form>
<?php 
}