function display_page_content()
{
    $categories = Categories::FindAll();
    ?>
	
	<div id="edit-header" class="entrynav">		
		<div class="nav-left column">
			<h1>Edit Blog Categories</h1>
		</div>
		<div class="nav-right column">
			<a class="hcd_button" href="<?php 
    echo get_link("/admin/add_category/");
    ?>
">Add a Category</a>
		</div>
		<div class="clearleft"></div>
	</div>

	<div id="table-header" class="entries">
		<strong class="item-link">Category Name</strong>
		<span clsass="public">Entry Count</span>
	</div>
	
	<ul id="listitems" class="managelist">
	<?php 
    foreach ($categories as $cat) {
        $entries = $cat->getEntries();
        $count = count($entries);
        $count_display = $count == 0 ? "&ndash;" : $count;
        echo "\t\t<li>\n\t\t\t\t<a class=\"item-link\" href=\"" . get_link("/admin/edit_category/{$cat->id}") . "\">{$cat->display_name}</a>\n\t\t\t\t<span class=\"public\">" . $count_display . "</span>\n\t\t\t</li>\n";
    }
    ?>

	</ul>
<?php 
}
Exemple #2
0
function display_page_content()
{
    // Set all values to null by default
    $entry = $entrytitle = $entrypublic = $entrydate = $entryimage = $entrycontent = $entryexcerpt = $entryauthor = $entrytemplate = $preventry = $nextentry = null;
    // Get values from existing object if this is not the Add page
    if (requestIdParam() != 'add') {
        $entry_id = requestIdParam();
        $entry = Blog_Entries::FindById($entry_id);
        $entrytitle = $entry->title;
        $entrypublic = $entry->public;
        $entrydate = $entry->getDateStart();
        if (BLOG_ENTRY_IMAGES) {
            $possibleimage = $entry->getImage();
            if (is_object($possibleimage)) {
                $entryimage = $possibleimage;
            }
        }
        $entrycontent = $entry->content;
        $entryexcerpt = $entry->excerpt;
        $entryauthor = $entry->author_id;
        $entrytemplate = $entry->template;
    }
    // Get other needed objects
    $the_blog = Blogs::FindById(BLOG_DEFAULT_ID);
    $authors = Users::FindAll();
    $categories = Categories::FindAll();
    $thisuser = Users::GetCurrentUser();
    // Get Previous and Next links
    if (is_object($entry)) {
        $preventry = $the_blog->getPrevEntry($entry->date, false);
        $nextentry = $the_blog->getNextEntry($entry->date, false);
    }
    // Warning thrown
    // Double check that the proper columns exist
    $photo_entry_id = find_db_column('photos', 'entry_id');
    if (!$photo_entry_id) {
        echo '<h2 class="system-warning"><span>HCd&gt;CMS says:</span> The Photos table does not have a column called "entry_id"</h2>';
    }
    // Language for the header
    if (is_object($entry)) {
        $header = 'Edit ' . ucwords(BLOG_STATIC_AREA) . ' Entry :: <a href="' . get_link(BLOG_STATIC_AREA . "/view/" . $entry->id . "/" . slug($entry->title)) . '" title="Click to View this Entry (save it first!)">View Entry</a>';
    } else {
        $header = 'Create new ' . ucwords(BLOG_STATIC_AREA) . ' Entry';
    }
    ?>

	<div id="edit-header" class="entrynav threecolumnnav">
		<div class="nav-left column">
			<h1><?php 
    echo $header;
    ?>
</h1>
		</div>
		<div class="nav-center column">
			<?php 
    if (!empty($preventry)) {
        ?>
<a href="<?php 
        echo get_link("/admin/edit_entry/" . $preventry->id);
        ?>
" title="<?php 
        $preventry->the_title();
        ?>
">&larr; Previous Entry</a><?php 
    }
    ?>
		</div>
		<div class="nav-right column">
			<?php 
    if (!empty($nextentry)) {
        ?>
<a href="<?php 
        echo get_link("/admin/edit_entry/" . $nextentry->id);
        ?>
" title="<?php 
        $nextentry->the_title();
        ?>
">Next Entry &rarr;</a><?php 
    }
    ?>
			
		</div>
		<div class="clearleft"></div>
	</div>
	
	<form method="POST" id="edit_entry" 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">Title:</label>
			<span class="hint">This is the Title of the entry; how it will display in the navigation.</span><br />
			<?php 
    textField("title", $entrytitle, "required: true");
    ?>
		</p>
		
		<div id="entry_date" class="column half">
			
			<p><label for="public">Public: <input type="checkbox" name="public" id="public" <?php 
    if ($entrypublic) {
        ?>
checked="checked"<?php 
    }
    ?>
></label> &nbsp; <span class="hint">Visible or not visible to the public? If you are working on an entry that is not yet ready, leave this off until it is complete. </span></p>
			
			<p>
				<label for="date">Entry Date: </label>
				<input type="text" name="date" id="date" value="<?php 
    echo $entrydate;
    ?>
" />
			</p>
        
        <?php 
    if (!BLOG_ENTRY_IMAGES) {
        ?>
		</div>
		<div class="column half last">
		<?php 
    }
    ?>
        
			<p>
				<label for="author_id">Author:</label> &nbsp; 
				<select name="author_id" id="author_id">
				<?php 
    foreach ($authors as $theauthor) {
        $selected = $theauthor->id == $entryauthor ? ' selected="selected"' : '';
        echo "<option value=\"{$theauthor->id}\"{$selected}> " . $theauthor->get_username() . " </option>\r\n";
    }
    ?>
				
				</select>
			</p>
			
			<?php 
    if (BLOG_ENTRY_TEMPLATES) {
        ?>
			<p>
    			<label for="template">Template:</label>
    			<select id="template" name="template">
    				<?php 
        require_once snippetPath("blog_templates_array");
        foreach ($blog_templates as $template) {
            echo '<option value="' . $template . '"';
            if ($template == $entrytemplate) {
                echo ' selected="selected"';
            }
            echo '>' . $template . '</option>';
        }
        ?>
    				
    			</select>
    		</p>
    		<?php 
    }
    ?>

        <?php 
    if (BLOG_ENTRY_IMAGES) {
        ?>
		</div>
		<div id="entry-thumb" class="column half last">
			
			<!-- Entry image -->
            <div style="padding-bottom: 1em;">
                <p><label for="entry_image"><?php 
        echo empty($entryimage) ? 'Add' : 'Edit';
        ?>
 an Entry Image:</label>
    				<input type="file" name="entry_image" id="entry_image" value="" />
    			</p>
    			<p class="hint">An image may be used by your site design on landing pages or menus. </p>
			<?php 
        if (!empty($entryimage)) {
            echo '<h3>Existing Entry Image (reduced in size)</h3>';
            echo '<p><img src="' . $entryimage->getPublicUrl() . '" style="max-width:100%;" alt=""></p>';
        }
        echo '</div>';
    }
    // end if BLOG_ENTRY_IMAGES
    ?>

		</div>
		
		<p class="clearleft">
			<label for="entry_content">Content:</label><br />
			<?php 
    textArea("entry_content", $entrycontent, 98, EDIT_WINDOW_HEIGHT / 2);
    ?>
		</p>
		
<?php 
    require_once snippetPath("admin-insert_configs");
    ?>
		
		<ul id="gallery-options-nav" class="menu tabs">
			<li><a href="#section_selector" class="openclose opened">Edit Categories for this Entry</a></li>
		</ul>
		<div id="section_selector" class="dropslide">
			<h2><legend>Select a Category to include this Entry in:</legend></h2>
			<fieldset>
				<p>
			<?php 
    $entrycats = is_object($entry) ? $entry->getCategories() : false;
    foreach ($categories as $thecategory) {
        $checked = "";
        if ($entrycats) {
            foreach ($entrycats as $entry_cat) {
                if ($thecategory->id == $entry_cat->id) {
                    $checked = ' checked="checked"';
                }
            }
        }
        echo '<label for="' . slug($thecategory->display_name) . '">' . $thecategory->display_name . '&nbsp;';
        echo '<input name="selected_cats[]" id="' . slug($thecategory->display_name) . '" class="boxes"' . $checked . ' type="checkbox" value="' . $thecategory->id . '" /></label>';
    }
    ?>
				
				</p>					
				<p><span class="hint">Any entry can be in more than one Category. If no categories are selected, this entry will be categorized in the default &ldquo;Uncategorized&rdquo; category.</span></p>
			</fieldset>
		</div><!-- #section_selector -->
        
        
        <p class="clearleft">
			<label for="entry_excerpt">Excerpt:</label><br />
			<?php 
    textArea("entry_excerpt", $entryexcerpt, 98, EDIT_WINDOW_HEIGHT / 3);
    ?>
			<p><span class="hint"><i>Optional:</i> An excerpt is commonly used on landing pages or in special areas, like the meta (SEO) description. Keep it short and limit the use of HTML.</span></p>
		</p>
		
		
		<div id="edit-footer" class="entrynav clearfix">
			<div class="column half">
		
				<p>
					<input type="submit" class="submitbutton" name="submit" value="Save Entry"> <br />
					<input type="submit" class="submitbuttonsmall" name="submit" value="Save and Return to List">
				</p>
				
			</div>
			<div class="column half last">
			
				<p>
				<?php 
    if (is_object($entry)) {
        ?>
					<label for="delete">Delete this entry?</label>
					<input name="delete" class="boxes" type="checkbox" value='<?php 
        echo $entry->id;
        ?>
' />
					<span class="hint">Check the box and then click &ldquo;Save&rdquo; above to delete this entry from the database</span>
				<?php 
    } else {
        echo '&nbsp;';
    }
    ?>
				</p>
			
			</div>
		</div>
		
	</form>
	
	<script type="text/javascript">
	    var entrydate;
		
		$().ready(function() {
			
			$( "#date" ).datetimepicker({
    			showButtonPanel: true,
    			showOtherMonths: true,
    			selectOtherMonths: true,
    			timeFormat: 'hh:mm:ss tt',
    			stepMinute: 5
    		});

			$("#edit_entry").validate({
				rules: {
					title: "required",
				},
				messages: {
					title: "Please enter a title for this <?php 
    echo BLOG_STATIC_AREA;
    ?>
 entry",
				}
			});
		});
	</script>
	
<?php 
}
Exemple #3
0
function display_page_content()
{
    // We use the old way to get all entries, because the FindAll function forces an exclusion date
    $the_blog = Blogs::FindById(BLOG_DEFAULT_ID);
    $entries = $the_blog->getEntries(false, false);
    $categories = Categories::FindAll();
    $year_month = $year = $month = $extraheader = "";
    $default_open = "opened";
    $thiscategory_id = requestIdParam();
    $thiscategory = Categories::FindById($thiscategory_id);
    if (is_object($thiscategory)) {
        $default_open = "";
        $extraheader = "from &ldquo;" . $thiscategory->display_name . "&rdquo;";
        $entries = $thiscategory->getEntries(false, false);
    }
    ?>
	
	<div id="edit-header" class="entrynav">		
		<div class="nav-left column">
			<h1>Edit <?php 
    echo ucwords(BLOG_STATIC_AREA);
    ?>
 Entries <?php 
    echo $extraheader . ' :: <a href="' . get_link(BLOG_STATIC_AREA) . '" title="Click to View All Entries">View Entries</a>';
    ?>
</h1>
		</div>
		<div class="nav-right column">
			<a class="hcd_button" href="<?php 
    echo get_link("/admin/edit_entry/add");
    ?>
">Add an Entry</a>
			<a class="hcd_button" href="<?php 
    echo get_link("/admin/list_categories/");
    ?>
">Edit Categories</a>
			<a class="hcd_button" href="<?php 
    echo get_link("/admin/add_category/");
    ?>
">Add a Category</a>
		</div>
		<div class="clearleft"></div>
	</div>
	
	<ul id="sort-list" class="menu tabs">
		<li><a class="<?php 
    echo $default_open;
    ?>
" href="<?php 
    echo get_link("admin/list_entries/");
    ?>
">All Categories</a></li><?php 
    foreach ($categories as $category) {
        $posts = $category->getEntries(false, false);
        if (count($posts) > 0) {
            $openclass = $category->id == $thiscategory_id ? "opened" : "";
            echo "<li><a class=\"{$openclass}\" href=\"" . get_link("admin/list_entries/" . $category->id) . "\">{$category->display_name}</a></li>";
        }
    }
    ?>
	
	</ul>
	<div class="clearleft"></div>
	
<?php 
    if (count($entries) > 0) {
        ?>
	<div id="table-header" class="entries">
		<strong class="item-link">Entry Name</strong>
		<span class="item-public">Public</span>
		<span class="item-created">Publication Date</span>
		<span class="item-revised">Author</span>
	</div>
	
	<ul id="listitems" class="managelist">
	<?php 
        foreach ($entries as $entry) {
            $blogyear_month = parseDate($entry->date, "Y-m");
            $blogyear = parseDate($entry->date, "Y");
            $blogmonth = parseDate($entry->date, "F");
            if ($blogyear_month != $year_month) {
                echo "\t\t<li class=\"monthname\">{$blogmonth} {$blogyear}</li>";
                $year_month = $blogyear_month;
                $year = $blogyear;
                $month = $blogmonth;
            }
            $public = $entry->public ? "" : "<span class=\"red\">(not public)</span>";
            echo "\t\t<li>\n\t\t\t\t<a class=\"item-link\" href=\"" . get_link("/admin/edit_entry/{$entry->id}") . "\">{$entry->title}</a>\n\t\t\t\t<span class=\"item-public\">{$public}</span>\n\t\t\t\t<span class=\"item-created\">" . formatDateTimeView($entry->date) . "</span>\n\t\t\t\t<span class=\"item-revised\">" . $entry->get_author() . "</span>\n\t\t\t</li>\n";
        }
        ?>

	</ul>
<?php 
    } else {
        echo "\t\t<h3 class=\"empty-list\">There are no " . BLOG_STATIC_AREA . " entries to edit. <a class=\"short\" href=\"" . get_link("admin/add_entry") . "\">Add one if you like</a>.</h3>";
    }
}
Exemple #4
0
 function list_categories($hide_empty_cats = true, $show_counts = false, $hide_uncategorized = true)
 {
     $categories = Categories::FindAll();
     $catlist = '<ul class="category-list menu">';
     $output = false;
     foreach ($categories as $cat) {
         // This is a public-facing function, so we only get Public posts and ones that are not future dated
         $entries = $cat->getEntries(true, true);
         $count = count($entries);
         $counter = $show_counts ? ' (' . $count . ')' : "";
         if ($hide_uncategorized && $cat->name == 'uncategorized') {
             continue;
         }
         if ($hide_empty_cats) {
             if ($count > 0) {
                 $catlist .= '<li><a class="category-link" href="' . $cat->get_public_url() . '">' . $cat->get_title() . ' ' . $counter . '</a></li>';
             }
             $output = true;
         } else {
             $catlist .= '<li><a class="category-link" href="' . $cat->get_public_url() . '">' . $cat->get_title() . ' ' . $counter . '</a></li>';
             $output = true;
         }
     }
     $catlist .= '</ul>';
     if ($output) {
         return $catlist;
     }
 }