Exemplo n.º 1
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 
}
Exemplo n.º 2
0
$var1 = getRequestVarAtIndex(1);
$var2 = getRequestVarAtIndex(2);
$var3 = getRequestVarAtIndex(3);
if (BLOG_INSTALL && $var0 == BLOG_STATIC_AREA) {
    $blogarea = Areas::FindById(3);
    // Might need to change this on a per project basis
    $page_title = $blogarea->get_seo_title(" | " . SITE_NAME);
    $bodyclass = "blog archive";
    if ($var1 == "category") {
        $category = Categories::FindByName($var2);
        $description = $category->get_excerpt(160);
        $page_title = $category->get_seo_title(" | " . $blogarea->get_seo_title() . " | " . SITE_NAME);
        $bodyclass = "blog category-archive";
    }
    if ($var1 == "view" && $var2 != "") {
        $blogitem = Blog_Entries::FindById($var2);
        $description = $blogitem->get_excerpt(160);
        $page_title = $blogitem->get_seo_title(" | " . $blogarea->get_seo_title() . " | " . SITE_NAME);
        $bodyclass = "blog single-entry";
    }
} elseif (CALENDAR_INSTALL && $var0 == CALENDAR_STATIC_AREA) {
    $page_title = "Event Calendar | " . SITE_NAME;
    $bodyclass = "calendar";
    if (getRequestVarAtIndex(5)) {
        $event = Events::FindById(getRequestVarAtIndex(5));
        $description = $event->get_excerpt(160);
        $page_title = $event->get_seo_title(" | Event Calendar | " . SITE_NAME);
        $bodyclass = "calendar single-event";
    } elseif (getRequestVarAtIndex(4)) {
        $page_title = "Event Calendar for " . date('F j, Y', mktime(0, 0, 0, $var3, getRequestVarAtIndex(4), $var2)) . " | " . SITE_NAME;
        $bodyclass = "calendar events-for-day";
Exemplo n.º 3
0
 function list_entries_and_group_by_date($blogpost_id = "", $hvalue_years = "h2", $hvalue_months = "h3")
 {
     /* This function draws a sub nav broken down by year and month. Also draws the parts needed to make months collapse. We pass the function an event id in case we want to keep a month open. 
     		Items needed in the CSS:
     			#wrapper h2
     			#wrapper h3
     			#wrapper .month_wrapper
     			#wrapper .month_wrapper a
     		*/
     $blogentries = $this->getEntries(true, true);
     $year = "";
     $month = "";
     $a_month_has_been_opened = false;
     if ($blogpost_id != "") {
         $thisblogpost = Blog_Entries::FindById($blogpost_id);
         $thisblogpost_month = date("Y-m", strtotime($thisblogpost->date));
     }
     if (isset($thisblogpost_month)) {
         //$whereat = $thisblogpost_month;
         $year = date("Y", strtotime($thisblogpost->date));
     } else {
         // Find the first month, and then reset the variables...
         $firstentry = array_shift($blogentries);
         $year = date("Y", strtotime($firstentry->date));
         $month = date("m", strtotime($firstentry->date));
         //$whereat = $year."-".$month;
         array_unshift($blogentries, $firstentry);
     }
     // be sure to reset this variable back to null, as we need it to be null the first time through the foreach
     $month = "";
     /*$string_of_entries = <<<EOT
     <script type="text/javascript">		
     	//<![CDATA[
     	function BlogAlreadyOpen(ul_id)
     	{
     		$('#' + ul_id).show();
     		$('div.month_wrapper').each(function() {
     			if ( $(this).attr('href') == '#' + ul_id ) { $(this).slideDown(); }
     		});
     		return true;
     	}
     	
     	$().ready(function() {
     		BlogAlreadyOpen('{$whereat}');
     		var loc = "";
     		
     		$("a.month_trigger").click(function() {
     			$('.month_wrapper').slideUp();
     			
     			if (loc != $(this).attr('href')) {
     				$($(this).attr('href')).slideDown();
     				loc = $(this).attr('href');
     			} else {
     				loc = "";			
     			}
     			return false;
     		});
     	});
     	//]]>
     </script>	
     EOT;*/
     // First: Output the first year header
     $string_of_entries = "<{$hvalue_years}>{$year}</{$hvalue_years}>\n";
     foreach ($blogentries as $theentry) {
         // Now output the month and save it
         $thisentrymonth = date("Y-m", strtotime($theentry->date));
         $ProperMonth = date("F", strtotime($theentry->date));
         $thisblogpost_month = $showthediv = "";
         if ($month == "") {
             // This is the first time through the loop, as the month is not set yet
             $string_of_entries .= "<{$hvalue_months}><a href=\"#{$thisentrymonth}\" class=\"month_trigger\">{$ProperMonth}</a></{$hvalue_months}>\n";
             $month = $thisentrymonth;
             // First time through, check if there a particular entry to show
             //if ( isset($thisblogpost_month) && $thisblogpost_month != "" ) { $showthediv = " hideme"; }
             // Open the entry wrapper
             $string_of_entries .= "<div id=\"{$month}\" class=\"month_wrapper hideme\">\n";
         } elseif ($month != $thisentrymonth) {
             // Month is set, and it is not the same as this entry's month, so we need a new header
             $string_of_entries .= "</div>\n";
             // Next, check if the year has changed. Output it between the divs
             $thisentryyear = date("Y", strtotime($theentry->date));
             if ($year != $thisentryyear) {
                 $string_of_entries .= "<{$hvalue_years}>{$thisentryyear}</{$hvalue_years}>\n";
                 $year = $thisentryyear;
             }
             $string_of_entries .= "<{$hvalue_months}><a href=\"#{$thisentrymonth}\" class=\"month_trigger\">{$ProperMonth}</a></{$hvalue_months}>\n";
             $month = $thisentrymonth;
             // Second or third time through... check if there is a particular post to show, and whether or not it matches this month we are trying to draw
             //if ( $thisblogpost_month != $thisentrymonth ) { $showthediv = " hideme"; }
             // Open the entry wrapper
             $string_of_entries .= "<div id=\"{$month}\" class=\"month_wrapper hideme\">\n";
         }
         // Finally output the post name and a link
         $string_of_entries .= "<a href=\"" . $theentry->get_URL() . "\">" . $theentry->get_title() . "</a>\n";
     }
     // Close the last month that got opened
     $string_of_entries .= "</div>\n";
     return $string_of_entries;
 }