# GetDocContent -- Etomite 0.6.1
# Author: Ralph A. Dahlgren
# Date: 2005-04-17
# Purpose: Returns additional document content for inclusion in a page template, for example
# Usage: [[GetDocContent?id=nn]] where nn is the id of the document content being requested
if(isset($id)){
$fields = "content";
$doc = $etomite->getDocument($id, $fields);
if($doc){
return $doc['content'];
}else{
return "";
}
}
else return "";
Etomite 0.6.1.0 Prelude Snippets All of the snippets as shipped
#16
Posted 31 May 2006 - 09:10 AM
#17
Posted 31 May 2006 - 09:11 AM
// Snippet name: GetKeywords
// Snippet description: Fetches the keywords attached to the document.
// Revision: 1.00
$keywords = $etomite->getKeywords();
if(count($keywords)>0) {
$keys = join($keywords, ", ");
return '<meta http-equiv="keywords" content="'.$keys.'" />';
} else {
return false;
}
#18
Posted 31 May 2006 - 09:12 AM
// Snippet name: GetStats // Snippet description: Fetches the visitor statistics totals from the database // Revision: 1.1 ships with Etomite 0.6.1-Final $tmpArray = $etomite->getSiteStats(); $output = " <table class=\"stats\" cellspacing=\"1\"> <thead> <tr class=\"fancyRow\"> <td width=\"25%\"> </td> <td width=\"25%\"><b>Page Impressions</b></td> <td width=\"25%\"><b>Visits</b></td> <td width=\"25%\"><b>Visitors</b></td> </tr> </thead> <tr> <td><b>Today</b></td> <td>".number_format($tmpArray['piDay'])."</td> <td>".number_format($tmpArray['viDay'])."</td> <td>".number_format($tmpArray['visDay'])."</td> </tr> <tr> <td><b>This Month</b></td> <td>".number_format($tmpArray['piMonth'])."</td> <td>".number_format($tmpArray['viMonth'])."</td> <td>".number_format($tmpArray['visMonth'])."</td> </tr> <tr> <td><b>All Time</b></td> <td>".number_format($tmpArray['piAll'])."</td> <td>".number_format($tmpArray['viAll'])."</td> <td>".number_format($tmpArray['visAll'])."</td> </tr> </table> "; return $output;
#19
Posted 31 May 2006 - 09:13 AM
/* GoogleSiteMap_XML Snippet for Etomite CMS
Ryan Nutt - http://blog.nutt.net
v0.1 - June 4, 2005
v0.2 - June 5, 2005 - Fixed a stupid mistake :-)
Changes by Lloyd Borrett - http://www.borrett.id.au
v0.3 - Sep 22, 2005
Only list searchable pages (Mod suggested by mplx)
Added configuration settings.
Made the site URL a configuration option.
Made displaying lastmoddate, priority and/or changefreq optional.
Added ability to display long date & time for lastmoddate
Made the long or short timeformat optional.
v0.4 - 05-Feb-2006
Changed the snippet to output the local time for all date values
based on the Etomite server offset time
v0.5 - 15-Feb-2006
Fixed incorrect local GMT offset value
v0.6 - 7-Apr-2006
Get the base URL from Etomite instead of it being a configuration option.
Based on the ListSiteMap snippet by
JaredDC
datediff function from
www.ilovejackdaniels.com
*/
// Overcome single use limitation on functions
global $MakeMapDefined;
global $server_offset_time;
global $GMT_value;
// Determine values required to convert the lastmod date and
// time to local time.
// get the Etomite server offset time in seconds
$server_offset_time = $etomite->config['server_offset_time'];
if (!$server_offset_time) {
$server_offset_time = 0;
}
// Get the server GMT offset in seconds
$GMT_offset = date("O");
$GMT_hr = substr($GMT_offset,1,2);
$GMT_min = substr($GMT_offset,4,2);
$GMT_sign = substr($GMT_offset,0,1);
$GMT_secs = (intval($GMT_hr) * 3600) + (intval($GMT_min) * 60);
if ($GMT_sign == '-') { $GMT_secs = $GMT_secs * (-1); }
// Get the local GMT offset in seconds
$GMT_local_seconds = $GMT_secs + $server_offset_time;
$GMT_local_secs = abs($GMT_local_seconds);
//round down to the number of hours
$GMT_local_hours = intval($GMT_local_secs / 3600);
// round down to the number of minutes
$GMT_local_minutes = intval(($GMT_local_secs - ($GMT_local_hours * 3600)) / 60);
if ($GMT_local_seconds < 0) {
$GMT_value = "-";
} else {
$GMT_value = "+";
}
$GMT_value .= sprintf("%02d:%02d", $GMT_local_hours, $GMT_local_minutes);
if (!function_exists(datediff)) {
function datediff($interval, $datefrom, $dateto, $using_timestamps = false) {
/*
$interval can be:
yyyy - Number of full years
q - Number of full quarters
m - Number of full months
y - Difference between day numbers
(eg 1st Jan 2004 is "1", the first day. 2nd Feb 2003 is "33". The datediff is "-32".)
d - Number of full days
w - Number of full weekdays
ww - Number of full weeks
h - Number of full hours
n - Number of full minutes
s - Number of full seconds (default)
*/
if (!$using_timestamps) {
$datefrom = strtotime($datefrom, 0);
$dateto = strtotime($dateto, 0);
}
$difference = $dateto - $datefrom; // Difference in seconds
switch($interval) {
case 'yyyy': // Number of full years
$years_difference = floor($difference / 31536000);
if (mktime(date("H", $datefrom), date("i", $datefrom), date("s", $datefrom), date("n", $datefrom), date("j", $datefrom), date("Y", $datefrom)+$years_difference) > $dateto) {
$years_difference--;
}
if (mktime(date("H", $dateto), date("i", $dateto), date("s", $dateto), date("n", $dateto), date("j", $dateto), date("Y", $dateto)-($years_difference+1)) > $datefrom) {
$years_difference++;
}
$datediff = $years_difference;
break;
case "q": // Number of full quarters
$quarters_difference = floor($difference / 8035200);
while (mktime(date("H", $datefrom), date("i", $datefrom), date("s", $datefrom), date("n", $datefrom)+($quarters_difference*3), date("j", $dateto), date("Y", $datefrom)) < $dateto) {
$months_difference++;
}
$quarters_difference--;
$datediff = $quarters_difference;
break;
case "m": // Number of full months
$months_difference = floor($difference / 2678400);
while (mktime(date("H", $datefrom), date("i", $datefrom), date("s", $datefrom), date("n", $datefrom)+($months_difference), date("j", $dateto), date("Y", $datefrom)) < $dateto) {
$months_difference++;
}
$months_difference--;
$datediff = $months_difference;
break;
case 'y': // Difference between day numbers
$datediff = date("z", $dateto) - date("z", $datefrom);
break;
case "d": // Number of full days
$datediff = floor($difference / 86400);
break;
case "w": // Number of full weekdays
$days_difference = floor($difference / 86400);
$weeks_difference = floor($days_difference / 7); // Complete weeks
$first_day = date("w", $datefrom);
$days_remainder = floor($days_difference % 7);
$odd_days = $first_day + $days_remainder; // Do we have a Saturday or Sunday in the remainder?
if ($odd_days > 7) { // Sunday
$days_remainder--;
}
if ($odd_days > 6) { // Saturday
$days_remainder--;
}
$datediff = ($weeks_difference * 5) + $days_remainder;
break;
case "ww": // Number of full weeks
$datediff = floor($difference / 604800);
break;
case "h": // Number of full hours
$datediff = floor($difference / 3600);
break;
case "n": // Number of full minutes
$datediff = floor($difference / 60);
break;
default: // Number of full seconds (default)
$datediff = $difference;
break;
}
return $datediff;
}
}
if (!isset($MakeMapDefined)) {
function MakeMap($funcEtomite, $listParent) {
global $server_offset_time;
global $GMT_value;
// Configuration Settings
// $websiteURL [string]
// Provide the full URL of your web site.
// For example: http://www.yourdomain.com/
// NOTE: You must put a / on the end of the web site URL.
global $ETOMITE_PAGE_BASE;
$websiteurl = $ETOMITE_PAGE_BASE['www'];
// $showlastmoddate [true | false]
// You can choose to disable providing the last modification
// date, or get it from the documents.
// true - Get time from documents
// false - Disabled, do not write it
$showlastmoddate = true;
// $showlongtimeformat [ true | false ]
// You can choose to provide:
// true - Long time format (with time)
// false - Short time format (date only)
$showlongtimeformat = true;
// $showpriority [ true | false ]
// You can choose to disable prividing the priority
// of a document relative to the whole set of documents,
// or calculate it based on the date difference.
// true - Provide the priority
// false - Disabled, do not write it
$showpriority = true;
// $showchangefreq [true | false]
// You can choose to disable prividing the update
// (change) frequency of a document relative to the
// whole set of documents, or calculate it based on
// the date difference.
// true - Calculate change frequency from last mod date
// false - Disabled, do not write it
$showchangefreq = true;
// ***********************************
// END CONFIG SETTINGS
// THE REST SHOULD TAKE CARE OF ITSELF
// ***********************************
$children = $funcEtomite->getActiveChildren($listParent, "menuindex", "ASC", "id, editedon, searchable");
foreach($children as $child) {
$id = $child['id'];
$url = $websiteurl."[~".$id."~]";
$date = $child['editedon'];
$lastmoddate = $date;
$date = date("Y-m-d", $date);
$searchable = $child['searchable'];
if ($searchable) {
// Get the date difference
$datediff = datediff("d", $date, date("Y-m-d"));
if ($datediff <=1) {
$priority = "1.0";
$update = "daily";
}
elseif (($datediff >1) && ($datediff<=7)) {
$priority = "0.75";
$update = "weekly";
}
elseif (($datediff >7) && ($datediff<=30)) {
$priority = "0.50";
$update = "weekly";
}
else {
$priority = "0.25";
$update = "monthly";
}
$output .= "<url>\n";
$output .= "<loc>$url</loc>\n";
if ($showlastmoddate) {
if (!$showlongtimeformat) {
$lastmoddate = date("Y-m-d", $lastmoddate + $server_offset_time);
}
else {
$lastmoddate = date("Y-m-d\TH:i:s", $lastmoddate + $server_offset_time).$GMT_value;
}
$output .= "<lastmod>$lastmoddate</lastmod>\n";
}
if ($showchangefreq) {
$output .= "<changefreq>$update</changefreq>\n";
}
if ($showpriority) {
$output .= "<priority>$priority</priority>\n";
}
$output .= "</url>\n";
}
if ($funcEtomite->getActiveChildren($child['id'])) {
$output .= MakeMap($funcEtomite, $child['id']);
}
}
return $output;
}
$MakeMapDefined = true;
}
$out = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
$out .= "<urlset xmlns=\"http://www.google.com/schemas/sitemap/0.84\">\n";
$out .= MakeMap($etomite, 0);
$out .= "</urlset>";
return $out;
#20
Posted 31 May 2006 - 09:14 AM
// Snippet name: ListDocuments
// Snippet description: Displays document listings based on provided criteria
// Revision: 1.2 ships with Etomite 0.6.1-Final
// Advanced version of the NewsListing snippet created by Ralph A. Dahlgren
// from the earlier version by Alex Butter
// Displays brief listing of new article summaries with links to full articles
// All passed variable assignments are optional and can be customized as needed
// Usage: [!ListDocuments?ids=123&numListings=5&maxListings=20&maxChars=200!]
/// Or: [!ListDocuments!] to use default settings for curent folder document
// Or: [!ListDocuments?ids=11,27,34,119&numListings=5&maxListings=5&maxChars=400!]
// Or: [!ListDocuments?createdby=1&createdon=20050514!]
// Note: createdon = YYYYMMDD or MM/DD/YY[YY] formats
// createdby = user/manager internalKey number
// Changes:
// v1.1 by Ralph A. Dahlgren -- 2005-07-13
// v1.2 by Lloyd Borrett -- 2006-04-07
// Return local time based on Etomite server offset time
//---------- Start of inline style variables ----------//
// can be changed to use CSS by using: $object_css = "class='object_class_name'";
$entry_box_css = "style=\"background-color:#F0F8FF; padding:5px; border:1px solid black;\"";
$title_css = "style=\"color:red; font-weight:bold; display:block;\"";
$author_css = "style=\"color:green; font-weight:bold; display:inline;\"";
$date_css = "style=\"color:green; display:inline;\"";
$parent_css = "style=\"color:#FFA500; font-weight:bold\"";
$text_css = "style=\"color:black; font-weight:normal; margin-top:.5em;\"";
$more_css = "style=\"float:right; color:#FFA500; font-weight:bold;\"";
//---------- Start of configuration variable assignments ----------//
// array of folder id's that contain news listings, or current folder document (default)
$ids = isset($ids) ? $ids : $etomite->documentIdentifier;
// number of news listings to summarize
$numListings = isset($numListings) ? $numListings : 3;
// maximum number of news listings to display
$maxListings = isset($maxListings) ? $maxListings : 100;
// maximum character count of news listing summaries to display
$maxChars = isset($maxChars) ? $maxChars : 150;
// assign message to return if no news listings are found
$noResults = "No entries were found.<br />";
// Date & Time format based on PHP function strftime() {"%d-%m-%y %H:%M:%S"}
$date_time_format = "%Y-%m-%d";
// text for author label
$author = "Author: ";
// Text to display as link to full news listing
$more = "Read the complete article »";
// Text to display above additional articles list
$olderNews = "Additional Recent Articles:";
// Text to display between Author and Date fields
$between = "—";
//---------- End of configuration variable assignments ----------//
// get the Etomite server offset time in seconds
$server_offset_time = $etomite->config['server_offset_time'];
if (!$server_offset_time) {
$server_offset_time = 0;
}
// initialize the data variable to be returned
$output = '';
// assign which data fields to extract from table rows
$fields = '
id,
pagetitle,
description,
content,
createdon,
createdby
';
// assign selection criteria for WHERE clause
$where = "parent IN($ids) AND published=1 AND deleted=0";
// if $createdon was sent, convert it to a timestamp and use it
if(isset($createdon)) $where .= " AND createdon=".strtotime($createdon);
// if $createdby (user internalKey) was sent, add to where clause
if(isset($createdby)) $where .= " AND createdby=".$createdby;
// retrieve child documents that are published and not deleted using getIntTableRows() API function
$rs = $etomite->getIntTableRows(
$fields,
$from="site_content",
$where,
$sort="createdon",
$dir="DESC",
$limit
);
// return a message if no listings were found
$limit = count($rs);
if($limit < 1) {
$output .= $noResults;
} else {
// determine how many listings to process
$numListings = ($numListings < $limit) ? $numListings : $limit;
// process the proper number of listings
for ($x = 0; $x < $numListings; $x++) {
// retrieve the authors full username using getAuthorData() API function
$userdata = $etomite->getAuthorData($rs[$x]['createdby']);
$username = $userdata['fullname'];
// if the listing is longer than $maxChars, strip the HTML tags from the content
$stripped = strip_tags($rs[$x]['content']);
if(strlen($stripped)>$maxChars) {
$rest = substr($stripped, 0, $maxChars);
$rest .= "...<br />";
} else {
$rest = $rs[$x]['content'];
}
// format the news listing for display
$output .= "
<div ".$entry_box_css.">
<div ".$title_css.">
".$rs[$x]['pagetitle']."
</div>
<div ".$text_css.">
".$rest."
<div style=\"clear:both; margin-bottom:.5em;\"></div>
<div style=\"text-align:left; float:left;\">
".$author."
<div ".$author_css.">
".$username."
</div>
".$between." ".strftime($date_time_format, $rs[$x]['createdon'] + $server_offset_time)."
</div>
<div style='text-align:right; float:right;'>
<a href=\"[~".$rs[$x]['id']."~]\">".$more."</a>
</div>
</div>
<br />
</div>
<br />";
}
}
// display list of links to older news articles
if(($limit > $numListings) && ($numListings < $maxListings)) {
$output .= "<br /><br /><b>".$olderNews."</b><br />";
for ($x = $numListings; $x < $limit; $x++) {
$output .= "<a href=\"[~".$rs[$x]['id']."~]\">".$rs[$x]['pagetitle']."</a><br />";
}
}
// return snippet results for display
return $output;
#21
Posted 31 May 2006 - 09:15 AM
// --------------------
// Snippet: ListMenu
// --------------------
// Version: 0.6f
// Date: 2005.08.04
// jaredc@honeydewdesign.com
//
// This snippet was designed to show navigation
// in a nested lists of arbitrary depth.
// Configuration Settings
// $removeNewLines
// This setting will remove white space from between <ul> and <li>
// items so the list can be styled in IE. This makes it hard to read
// the source code- set to false for troubleshooting before launch.
// False is also handy if the list will be horizontal.
$removeNewLines = true;
// $currentAsLink
// If you would like to turn off the link for the
// current page, set to false.
$currentAsLink = true;
// $LM_node [ int ]
// Settable in snippet call only. Allows you to set an arbitrary
// anchor for this menu. Should be id number of initial document.
// For ListMenu this is typically the current page so that the
// snippet will generate a list back to the site root.
// [[ListMenu?LM_node=56]]
// $levelsDeep [ int ]
// Specifies how many levels of menu you want to show starting
// with the children of current document working back to root. For
// example, 3 levels would give you the children of the current
// page, the current page and its siblings, and the current page's
// parent and its siblings. The child generation is counted regardless
// of wether or not there are children.
//
// You can also specify negative values. Negative values indicate
// how many levels NOT to include, starting at the root. For example,
// if you want all BUT the root level showing, you can declare -1.
// This would be a main section menu - but without the "global" options.
//
// The default of 0 will show current children all the back to root.
// This represents the complete menu. You can also set this in a snippet
// call with LM_levels:
// [[ListMenu?LM_levels=1]]
$levelsDeep = 0;
// $directGeneology [ true | false ]
// Set this option if you only want to show the direct geneolgy. For
// instance, with this set to true, and you were on examplePage 5
// levels deep, you would see all of examplePage's child pages (if
// any), examplePage's parent, but NOT siblings of any parent above
// the current page.
$directGeneology = true;
// $showGlobals [ true | false ]
// Leave the root level folders showing, even if $directGeneology is
// true. NOTE- this will NOT override a set $levelsDeep. Settable in
// snippet call with LM_globals (0=false, 1=true)
// [[ListMenu?LM_globals=1]]
$showGlobals = true;
// $sortWiz [ array ]
// You can specify any number of sort columns and directions, so you
// are not limited to menuindex - for instance you might want alphabetic
// or folders first or whatever. Format each sort like this:
// $sortWiz[] = array("sortColumn","direction");
// Where sortColumn is the sort column like isfolder, pagetitle, etc.
// and direction is "ASC" for ascending and "DESC" is descending.
// Default is:
// $sortWiz[] = array("menuindex","ASC");
// If you wanted folders first, THEN contents in alphabetical order:
// $sortWiz[] = array("isfolder","ASC");
// $sortWiz[] = array("pagetitle","ASC");
$sortWiz[] = array("menuindex","ASC");
// $alternateRows [ true | false ]
// Append "_alt" to style class of alternate rows (true)
$alternateRows = false;
// $showDescription [ true | false ]
// Show the description under the link- usually not necessary
// Set in snippet call with LM_desc:
// [[ListMenu?LM_desc=1]]
$showDescription = false;
// STYLES used
//
// #LM_level_N menu level where N is the number of the depth
// starting at 0
// #LM_youAreHere menu item of current location
// .LM_expanded expanded menu item with children
// .LM_collapsed menu item with childen, but not expanded
// .LM_endPage menu item with children
// .LM_description menu item description
//
// ########################################
// End Config
// The rest takes care of itself
// ########################################
// Adjust for snippet variables
$showGlobals = (isset($LM_globals))? $LM_globals : $showGlobals;
$levelsDeep = (isset($LM_levels))? $LM_levels : $levelsDeep;
$showDescription = (isset($LM_desc))? $LM_desc : $showDescription;
// Make adjustment for new lines
$ieSpace = ($removeNewLines)? "" : "\n";
// Create Geneology
$fullGeneology = array();
$geneologyMarker = (isset($LM_node))? $LM_node : $etomite->documentIdentifier;
while ($currentMarker=$etomite->getPageInfo($geneologyMarker, null, 'id,parent')){
$fullGeneology[] = $currentMarker['id'];
$geneologyMarker = $currentMarker['parent'];
}
$fullGeneology[] = 0;
// alter geneology for correct depth
$geneology = array();
if (($levelsDeep > 0) && (count($fullGeneology) > $levelsDeep)){
for($i = 0; $i < $levelsDeep; $i++){
$geneology[] = $fullGeneology[$i];
}
} elseif (($levelsDeep) < 0 && (count($fullGeneology) > abs($levelsDeep))){
for ($i = 0; $i < -$levelsDeep; $i++){
array_pop($fullGeneology);
}
$geneology = $fullGeneology;
} else {
$geneology = $fullGeneology;
}
// Build lists
// Initialize
$currentParent = $geneology[0];
$listSoFar = '';
$lookForChild = 0;
// Assemble sort string
$sortString = '';
foreach($sortWiz as $sortCriteria){
$sortString .= $sortCriteria[0] . " " . $sortCriteria[1] . ", ";
}
$sortString = substr($sortString,0,strlen($sortString)-2);
for($geneCount=0;$geneCount < count($geneology);$geneCount++){
$childrenList = $etomite->getActiveChildren($geneology[$geneCount], $sortString, null,'id, pagetitle, longtitle, parent, isfolder, description');
if ($childrenList){
$currentLevelList = '<ul id="LM_level_'.(count($geneology)-$geneCount).'">'."\n".$ieSpace;
$listPosition = 0;
foreach ($childrenList as $childItem){
if (!$directGeneology || $geneCount==0 || (($geneCount==1)&&(!$etomite->getActiveChildren($geneology[0]))) || ($directGeneology && in_array($childItem['id'],$geneology)) || ($showGlobals && ($geneology[$geneCount]==0))){
if ($childItem['isfolder']){
$cssStyle = (in_array($childItem['id'], $geneology))? ' class="LM_expanded': ' class="LM_collapsed';
} else {
$cssStyle = ' class="LM_endPage';
}
$cssStyle .= ($alternateRows && ($listPosition%2))? '_alt"' : '"';
$currentLevelList .= '<li'.$cssStyle.'>';
if((!$currentAsLink) && ($childItem['id'] == $etomite->documentIdentifier)){
$currentLevelList .= '<span id="LM_youAreHere">';
$currentLevelList .= $childItem['pagetitle'].'</span>';
} else {
$linkTitle = ($childItem['longtitle'])? $childItem['longtitle'] : $childItem['pagetitle'];
$currentLevelList .= '<a href="[~'.$childItem['id'].'~]" title="' . $linkTitle .'">';
$currentLevelList .= $childItem['pagetitle'].'</a>';
}
$currentLevelList .= ($showDescription)? '<div class="LM_description">'.$childItem['description'].'</div>' : '';
if ($lookForChild == $childItem['id']) {
$currentLevelList .= $listSoFar;
}
$currentLevelList .= "</li>\n".$ieSpace;
}
$listPosition++;
}
$currentLevelList .= "</ul>\n".$ieSpace;
}
$listSoFar = $currentLevelList;
$lookForChild = $geneology[$geneCount];
}
// send to parser
return $listSoFar;
#22
Posted 31 May 2006 - 09:16 AM
// --------------------
// Snippet: ListSiteMap
// --------------------
// Version: 0.6h
// Date: 2005.07.08
// jaredc@honeydewdesign.com
//
// This snippet was designed to show a nested
// list site map with each pagetitle being a
// link to that page. It will not include
// unpublished folders/pages OR its children,
// even if the children ARE published.
// Config
// $siteMapRoot [int]
// The parent ID of your root. Default 0. Can be set in
// snippet call with LSM_root (to doc id 10 for example):
// [[ListSiteMap?LSM_root=10]]
$siteMapRoot = 0;
// $showDescription [true | false]
// Specify if you would like to include the description
// with the page title link.
$showDescription = true;
// $titleOfLinks [ string ]
// What database field do you want the title of your links to be?
// The default is pagetitle because it is always a valid (not empty)
// value, but if you prefer it can be any of the following:
// id, pagetitle, description, parent, alias, longtitle
$titleOfLinks = 'pagetitle';
// $removeNewLines [ true | false ]
// If you want new lines removed from code, set to true. This is generally
// better for IE when lists are styled vertically.
$removeNewLines = true;
// $maxLevels [ int ]
// Maximum number of levels to include. The default 0 will allow all
// levels. Also settable with snippet variable LSM_levels:
// [[ListSiteMap?LSM_levels=2]]
$maxLevels = 0;
// $selfAsLink [ true | false ]
// Define if the current page should be a link (true) or not
// (false)
$selfAsLink = false;
// $showUnpubs [ true | false ]
// Decide to include items in unpublished folders. This will show the
// unpublished items as well. No links will be made for the unpublished items
// but they will be shown in the structure. You will not likely want to do
// this but the option is yours.
$showUnpubs = false;
// Styles
//
// .LSM_currentPage span surrounding current page if $selfAsLink is false
// .LSM_description description of page
// .LSM_N ul style where N is the level of nested list- starting at 0
// ###########################################
// End config, the rest takes care of itself #
// ###########################################
// Initialize
$siteMapRoot = (isset($LSM_root))? $LSM_root : $siteMapRoot;
$maxLevels = (isset($LSM_levels))? $LSM_levels : $maxLevels;
$ie = ($removeNewLines)? '' : "\n";
// Overcome single use limitation on functions
global $MakeMapDefined;
if(!isset($MakeMapDefined)){
function MakeMap($funcEtomite, $listParent, $listLevel, $description, $titleOfLinks,$maxLevels,$su){
$children = $funcEtomite->getAllChildren($listParent, 'menuindex', 'ASC', 'id, pagetitle, description, parent, alias, longtitle, published');
$output .= '<ul class="LSM_'.$listLevel.'">'.$ie;
foreach($children as $child){
// skip unpubs unless desired
if (!$su && !$child['published']) continue;
$descText = ($description)? ' <span class="LSM_description">'.$child['description'].'</span>' : '';
$output .= '<li>';
if (!$selfAsLink && ($child['id'] == $funcEtomite->documentIdentifier)){
$output .= '<span class="LSM_currentPage">'.$child['pagetitle'].'</span>';
} else if (!$child['published']){
$output .= '<span class="LSM_unpubPage">'.$child['pagetitle'].'</span>';
} else {
$output .= '<a href="[~'.$child['id'].'~]" title="'.$child[$titleOfLinks].'">'.$child['pagetitle'].'</a>';
}
$output .= $descText;
if ($funcEtomite->getAllChildren($child['id']) && (($maxLevels==0) || ($maxLevels > $listLevel+1 ))){
$output .= MakeMap($funcEtomite,$child['id'],$listLevel+1,$description,$titleOfLinks,$maxLevels,$su);
}
$output .= '</li>'.$ie;
}
$output .= '</ul>'.$ie;
return $output;
}
$MakeMapDefined = true;
}
return MakeMap($etomite, $siteMapRoot, 0, $showDescription, $titleOfLinks,$maxLevels,$showUnpubs);
#23
Posted 31 May 2006 - 09:17 AM
// Snippet name: MenuBuilder
// Snippet description: Builds the site menu
// Revision: 1.00 ships with Etomite 0.6.1-Final
$id = isset($id) ? $id : $etomite->documentIdentifier;
$sortby = "menuindex";
$sortdir = "ASC";
$fields = "id, pagetitle, description, parent, alias";
$indentString="";
if(!isset($indent)) {
$indent = "";
$indentString .= "";
} else {
for($in=0; $in<$indent; $in++) {
$indentString .= " ";
}
$indentString .= "» ";
}
$children = $etomite->getActiveChildren($id, $sortby, $sortdir, $fields);
$menu = "";
$childrenCount = count($children);
$active="";
if($children==false) {
return false;
}
for($x=0; $x<$childrenCount; $x++) {
if($children[$x]['id']==$etomite->documentIdentifier) {
$active="class=\"highLight\"";
} else {
$active="";
}
if($children[$x]['id']==$etomite->documentIdentifier || $children[$x]['id']==$etomite->documentObject['parent']) {
$menu .= "<a ".$active." href=\"[~".$children[$x]['id']."~]\">$indentString".$children[$x]['pagetitle']."</a>[[MenuBuilder?id=".$children[$x]['id']."&indent=2]]";
} else {
$menu .= "<a href=\"[~".$children[$x]['id']."~]\">$indentString".$children[$x]['pagetitle']."</a>";
}
}
return $menu."";
#24
Posted 31 May 2006 - 09:18 AM
// --------------------------------------------
// Snippet: MenuHori by summean
// --------------------------------------------
// Based on the MenuBuilder snippet, however
// MenuHori does not show subchildren. Inserts
// into a template just like MenuBuilder:
// [[MenuHori?id=__]] where __ is the folder
// containing the links/documents.
// --Config:--
// Insert what you would like to appear between
// the links in the " " below.
$seperator=" | ";
// --End Config--
$children = $etomite->getActiveChildren($id); $menu = ""; $childrenCount = count($children);
if($children==false) {
return false;
}
for($x=0; $x<$childrenCount; $x++) {
//If its the last link/document, we don't want the seperator after it. (Thanks Alex)
if($x==($childrenCount-1)){
$menu .= "<a href='[~".$children[$x]['id']."~]'>".$children[$x]['pagetitle']."</a>";
} else {
$menu .= "<a href='[~".$children[$x]['id']."~]'>".$children[$x]['pagetitle']."</a>$seperator";
}
}
return $menu;
#25
Posted 31 May 2006 - 09:19 AM
/*
Snippet Title: MetaTagsExtra
Snippet Version: 2.2
Etomite Version: 0.6 +
Description:
Returns XHTML for document meta tags:
Content-Type, Content-Language, Generator,
Title, Description, Keywords, Abstract, Author, Copyright,
Robots, Googlebot, Cache-Control, Pragma, Expires, Last Modified,
Distribution and Rating.
Can also return XHTML for Dublin Core Metadata Initiative meta tags:
DC.format, DC.language, DC.title,
DC.description, DC.subject, DC.title.alternative,
DC.publisher, DC.creator, DC.rights,
DC.date.created, DC.date.modified, DC.date.valid and DC.identifier.
Can also return the GeoURL and GeoTags meta tags:
DC.title, ICBM, geo.position, geo.placename and geo.region.
Snippet Author:
Miels with mods by Lloyd Borrett (lloyd@borrett.id.au)
Version History:
1.3 - Lloyd Borrett added the Robots meta tag based
on the idea in the SearchableSE snippet by jaredc
1.4 - Lloyd Borrett added the Abstract meta tag
based on the Site Name and the Long Title.
Also added the Generator meta tag based on the Etomite version details.
The Robots meta tag is now only output if the document is non-searchable,
to reduce XHTML bloat. The Googlebot meta tag is now also output
when the document is non-searchable.
1.5 - Lloyd Borrett added no-cache directives via the Cache-Control
and Pragma meta tags if the document is non-cacheable.
Abstract meta tag uses the document description if long title not set.
Cleaned up some other tests.
1.6 - 2006-01-26 - Lloyd Borrett cleaned up some code.
1.7 - 2006-01-27 - Lloyd Borrett
Added support for the Distribution and Rating meta tags.
Copyright meta tag can now include a year range being from either
a site creation year to the current year, or from the year the
document was created to the current year, e.g. 2005-2006.
Added ability to specify a site wide author, and thus be able to
skip looking up document author details.
1.8 - 2006-01-27 - Lloyd Borrett
Current year now based on local time using the Etomite
Server Offset Time configuration setting
1.9 - 2006-03-08 - Lloyd Borrett
Dates in meta tags can be output in your choice of ISO 8601
or RFC 822 formats.
Dates in the meta tags are now corrected to local time.
Fixed problem with the generation of the "description" meta tag.
2.0 - 2006-03-10 - Lloyd Borrett
Moved the generation of the "content-type", "content-language"
and "title" meta tags into this snippet.
Added in support for the Dublin Core Metadata Initiative meta tags.
2.1 - 2006-03-15 - Lloyd Borrett
Dropped the choice of date formats. Dublin Core tags now use ISO dates.
Others tags use RFC 822 dates. This is what is properly supported.
Added in support for GeoURL (www.geourl.org) and
GeoTags (www.geotags.com) meta tags.
2.2 - 2006-04-07 - Lloyd Borrett
Get the base URL from Etomite instead of it being a configuration option.
Snippet Category:
Search Engines
Usage:
Insert [[MetaTagsExtra]] anywhere in the head section of your template.
Don't forget to set the full name of all document authors.
You can find it at "Manage users" -> your username -> "full name".
This value is used for the Author and Copyright meta tags.
When you mark a page as "NOT searchable" - a Robots meta tag
with "noindex, nofollow" is inserted to keep web search engines
from indexing that document. After all, there's little value in
making your Etomite document unsearchable to Etomite, when
Google still knows where it is! For "searchable" documents, no
Robots meta tag is inserted. The default is "index, follow", so not
putting it in reduced HTML bloat.
A Googlebot meta tag with "noindex, nofollow, noarchive, nosnippet"
is also output, to tell Google to clean out its cache.
When you mark a page as "non cacheable", no-cache directives
are inserted via the Cache-Control and Pragma meta tags.
*/
// *** Configuration Settings ***
// Provide the content type setting.
$content_type = "text/html; charset=iso-8859-1";
// Provide the language setting.
$language = "en";
// Distribution can be "global", "local" or "iu"
// If you want no Distribution meta tag use ''
$distribution = 'global';
// Rating can be "14 years", "general", "mature", "restricted" or "safe for kids"
// If you want no Rating meta tag use ''
$rating = 'general';
// Start Date of the web site as used for the copyright meta tag
// To use the document creation date, set this to ''
$site_start_year = '';
// Site Author can be used for the Author and Copyright meta tags
// To use the document author details of each document, set this to ''
$site_author = $etomite->config['site_name'];
// Provide the full URL of your web site.
// For example: http://www.yourdomain.com
// NOTE: Do not put a / on the end of the web site URL.
// Used to build the DC.identifier tag
global $ETOMITE_PAGE_BASE;
$websiteurl = $ETOMITE_PAGE_BASE['www'];
// Provide the latitude of the resource
$latitude = "";
// Provide the longitude of the resource
$longitude = "";
// Provide the place name of the resource
$placename = "";
// Provide the ISO 3166 region code of the resource
$region = "";
// DC Tags is used to specify if the Dublin Core Metadata Initiative
// meta tags should also be generated.
// Set to true to generate them, false otherwise.
$dc_tags = true;
// Geo Tags is used to specify if the Geo Tags
// meta tags should also be generated.
// Set to true to generate them, false otherwise.
$geo_tags = true;
// Initialise variables
$MetaType = "";
$MetaLanguage = "";
$MetaTitle = "";
$MetaGenerator = "";
$MetaDesc = "";
$MetaKeys = "";
$MetaAbstract = "";
$MetaAuthor = "";
$MetaCopyright = "";
$MetaRobots = "";
$MetaGooglebot = "";
$MetaCache = "";
$MetaPragma = "";
$MetaExpires = "";
$MetaEditedOn = "";
$MetaDistribution = "";
$MetaRating = "";
// The data format of the resource
$DC_format = "";
// The language of the content of the resource
$DC_language = "";
// The name given to the resource
$DC_title = "";
// A textual description of the content and/or purpose of the resource
// Equivalent to "description"
$DC_description = "";
// The subject and topic of the resource that succinctly
// describes the content of the resource.
// Equivalent to "keywords"
$DC_subject = "";
// Any form of the title used as a substitute or alternative
// to the formal title of the resource.
// Equivalent to "abstract"
$DC_title_alternative = "";
// The name of the entity responsible for making the resource available
// Equivalent to "author"
$DC_publisher = "";
// An entity primarily responsible for making the content of the resource
// Equivalent to "author"
$DC_creator = "";
// A statement or pointer to a statement about the
// rights management information for the resource
// Equivalent to "copyright"
$DC_rights = "";
// The date the resource was created in its current form
$DC_date_created = "";
// The date the resource was last modified or updated
$DC_date_modified = "";
// The date of validity of the resource.
// Specified as from the creation date to the expiry date
$DC_date_valid = "";
// A unique identifier for the resource
$DC_identifier = "";
// The latitude and longitude of the resource
$Geo_position = "";
// The latitude and longitude of the resource
$Geo_icbm = "";
// The place name of the resource
$Geo_placename = "";
// The region of the resource
$Geo_region = "";
// *** FUNCTIONS ***
function get_local_GMT_offset($server_offset_time) {
// Get the local GMT offset when given the
// local to Etomite server offset time in seconds
$GMT_offset = date("O");
$GMT_hr = substr($GMT_offset,1,2);
$GMT_min = substr($GMT_offset,4,2);
$GMT_sign = substr($GMT_offset,0,1);
$GMT_secs = (intval($GMT_hr) * 3600) + (intval($GMT_min) * 60);
if ($GMT_sign == '-') { $GMT_secs = $GMT_secs * (-1); }
// Get the local GMT offset in seconds
$GMT_local_seconds = $GMT_secs + $server_offset_time;
$GMT_local_secs = abs($GMT_local_seconds);
// round down to the number of hours
$GMT_local_hours = intval($GMT_local_secs / 3600);
// round down to the number of minutes
$GMT_local_minutes = intval(($GMT_local_secs - ($GMT_local_hours * 3600)) / 60);
if ($GMT_local_seconds < 0) {
$GMT_value = "-";
} else {
$GMT_value = "+";
}
$GMT_value .= sprintf("%02d:%02d", $GMT_local_hours, $GMT_local_minutes);
return $GMT_value;
}
function get_local_iso_8601_date($int_date, $server_offset_time) {
// Return an ISO 8601 style local date
// $int_date: current date in UNIX timestamp
$GMT_value = get_local_GMT_offset($server_offset_time);
$local_date = date("Y-m-d\TH:i:s", $int_date + $server_offset_time);
$local_date .= $GMT_value;
return $local_date;
}
function get_local_rfc_822_date($int_date, $server_offset_time) {
// return an RFC 822 style local date
// $int_date: current date in UNIX timestamp
$GMT_value = get_local_GMT_offset($server_offset_time);
$local_date = date("D, d M Y H:i:s", $int_date + $server_offset_time);
$local_date .= " ".str_replace(':', '', $GMT_value);
return $local_date;
}
// *** Start Creating Meta Tags ***
// *** CONTENT-TYPE ***
$MetaType = " <meta http-equiv=\"content-type\" content=\"".$content_type."\" />\n";
// *** DC.FORMAT ***
if ($dc_tags) {
$DC_format = " <meta name=\"DC.format\" content=\"".$content_type."\" />\n";
}
// *** CONTENT-LANGUAGE ***
$MetaLanguage = " <meta http-equiv=\"content-language\" content=\"".$language."\" />\n";
// *** DC.LANGUAGE ***
if ($dc_tags) {
$DC_language = " <meta name=\"DC.language\" content=\"".$language."\" />\n";
}
// *** GENERATOR ***
$version = $etomite->getVersionData();
$version['version'] = trim($version['version']);
$version['code_name'] = trim($version['code_name']);
if (($version['version'] != "") || ($version['code_name'] != "")) {
$MetaGenerator = " <meta name=\"generator\" content=\"Etomite";
if($version['version'] != ""){
$MetaGenerator .= " ".$version['version'];
}
if($version['code_name'] != ""){
$MetaGenerator .= " (".$version['code_name'].")";
}
$MetaGenerator .= "\" />\n";
}
$docInfo = $etomite->getDocument($etomite->documentIdentifier);
// *** DESCRIPTION ***
// Trim and replace double quotes with entity
$description = $docInfo['description'];
$description = str_replace('"', '"', trim($description));
if(!$description == ""){
$MetaDesc = " <meta name=\"description\" content=\"$description\" />\n";
// *** DC.DESCRIPTION ***
if ($dc_tags) {
$DC_description = " <meta name=\"DC.description\"";
$DC_description .= " content=\"$description\" />\n";
}
}
// *** KEYWORDS ***
$keywords = $etomite->getKeywords();
if(count($keywords)>0) {
$keys = join($keywords, ", ");
$MetaKeys = " <meta name=\"keywords\" content=\"$keys\" />\n";
// *** DC.SUBJECT ***
if ($dc_tags) {
$keys = join($keywords, "; ");
$DC_subject = " <meta name=\"DC.subject\"";
$DC_subject .= " content=\"$keys\" />\n";
}
}
// *** ABSTRACT ***
// Use the Site Name and the documents Long Title (or Description)
// to build an Abstract meta tag.
$sitename = $etomite->config['site_name'];
// Trim and replace double quotes with entity
$sitename = str_replace('"', '"', trim($sitename));
$abstract = trim($docInfo['longtitle']);
if($abstract == ""){
$abstract = $description;
}
// Replace double quotes with entity
$abstract = str_replace('"', '"', $abstract);
if(($sitename != "") || ($abstract != "")) {
$separator = " - ";
if($sitename == ""){
$separator = "";
}
$MetaAbstract = " <meta name=\"abstract\" content=\"".$sitename.$separator.$abstract."\" />\n";
// *** DC.TITLE.ALTERNATIVE ***
if ($dc_tags) {
$DC_title_alternative = " <meta name=\"DC.title.atlernative\"";
$DC_title_alternative .= " content=\"".$sitename.$separator.$abstract."\" />\n";
}
}
// *** TITLE ***
// Use the Site Name and the documents Page Title and Long Title
// to build the Title meta tag.
// Start with the site name
$title = $sitename;
// Get the pagetitle, trim and replace double quotes with entity
$pagetitle = str_replace('"', '"', trim($docInfo['pagetitle']));
if ($pagetitle != "") {
if ($title == "") {
$title = $pagetitle;
} else {
$title .= " - ".$pagetitle;
}
}
// Get the longtitle, trim and replace double quotes with entity
$longtitle = str_replace('"', '"', trim($docInfo['longtitle']));
if ($longtitle != "") {
if ($title == "") {
$title = $longtitle;
} else {
$title .= " - ".$longtitle;
}
}
if ($title != "") {
$MetaTitle = " <title>".$title."</title>\n";
// *** DC.TITLE ***
if ($dc_tags || $geo_tags) {
$DC_title = " <meta name=\"DC.title\"";
$DC_title .= " content=\"".$title."\" />\n";
}
}
// *** AUTHOR ***
if ($site_author == '') {
$authorid = $docInfo['createdby'];
$tbl = $etomite->dbConfig['dbase'].".".$etomite->dbConfig['table_prefix']."user_attributes";
$query = "SELECT fullname FROM $tbl WHERE $tbl.id = $authorid";
$rs = $etomite->dbQuery($query);
$limit = $etomite->recordCount($rs);
if($limit=1) {
$resourceauthor = $etomite->fetchRow($rs);
$authorname = $resourceauthor['fullname'];
}
// Trim and replace double quotes with entity
$authorname = str_replace('"', '"', trim($authorname));
} else {
$authorname = $site_author;
}
if (!$authorname == ""){
$MetaAuthor = " <meta name=\"author\" content=\"$authorname\" />\n";
// *** DC.PUBLISHER & DC.CREATOR ***
if ($dc_tags) {
$DC_publisher = " <meta name=\"DC.publisher\" content=\"$authorname\" />\n";
$DC_creator = " <meta name=\"DC.creator\" content=\"$authorname\" />\n";
}
}
// *** COPYRIGHT ***
// get the Etomite server offset time in seconds
$server_offset_time = $etomite->config['server_offset_time'];
if (!$server_offset_time) {
$server_offset_time = 0;
}
// get the current time and apply the offset
$timestamp = time() + $server_offset_time;
// Set the current year
$today_year = date('Y',$timestamp);
$createdon = date('Y',$docInfo['createdon']);
if ($site_start_year == '') {
if ($today_year != $createdon) {
$copydate = $createdon."–".$today_year;
} else {
$copydate = $today_year;
}
} else {
if ($today_year != $site_start_year) {
$copydate = $site_start_year."–".$today_year;
} else {
$copydate = $today_year;
}
}
if ($authorname == '') {
$copyname = $authorname;
} else {
$copyname = " by ".$authorname;
}
$MetaCopyright = " <meta name=\"copyright\" content=\"Copyright © ";
$MetaCopyright .= $copydate.$copyname.". All rights reserved.\" />\n";
// *** DC.RIGHTS ***
if ($dc_tags) {
$DC_rights = " <meta name=\"DC.rights\" content=\"Copyright © ";
$DC_rights .= $copydate.$copyname.". All rights reserved.\" />\n";
}
// *** ROBOTS and GOOGLEBOT ***
// Determine if this document has been set to non-searchable.
// As the default for the Robots and Googlebot Meta Tags are index and follow,
// these tags are only needed when we don't want the document searched.
if(!$etomite->documentObject['searchable']){
$MetaRobots = " <meta name=\"robots\" content=\"noindex, nofollow\" />\n";
$MetaGooglebot = " <meta name=\"googlebot\" content=\"noindex, nofollow, noarchive, nosnippet\" />\n";
}
// *** CACHE-CONTROL and PRAGMA ***
// Output no-cache directives via the Cache-Control and Pragma meta tags
// if this document is set to non-cacheable.
$cacheable = $docInfo['cacheable'];
if (!$cacheable) {
$MetaCache = " <meta http-equiv=\"cache-control\" content=\"no-cache\" />\n";
$MetaPragma = " <meta http-equiv=\"pragma\" content=\"no-cache\" />\n";
}
// *** DC.DATE.CREATED ***
if ($dc_tags) {
$createdon = get_local_iso_8601_date($docInfo['createdon'], $server_offset_time);
$created = substr($createdon,0,10);
$DC_date_created = " <meta name=\"DC.date.created\" content=\"";
$DC_date_created .= $created."\" />\n";
}
// *** EXPIRES ***
$unpub_date = $docInfo['unpub_date'];
if ($unpub_date > 0) {
$unpubdate = get_local_rfc_822_date($unpub_date, $server_offset_time);
$MetaExpires = " <meta http-equiv=\"expires\" content=\"$unpubdate\" />\n";
// *** DC.DATE.VALID ***
if ($dc_tags) {
$dcunpubdate = get_local_iso_8601_date($unpub_date, $server_offset_time);
$valid = substr($dcunpubdate,0,10);
$DC_date_valid = " <meta name=\"DC.date.valid\" content=\"";
$DC_date_valid .= $created."/".$valid."\" />\n";
}
}
// *** LAST MODIFIED ***
$editedon = get_local_rfc_822_date($docInfo['editedon'], $server_offset_time);
$MetaEditedOn = " <meta http-equiv=\"last-modified\" content=\"$editedon\" />\n";
// *** DC.DATE.MODIFIED ***
if ($dc_tags) {
$dceditedon = get_local_iso_8601_date($docInfo['editedon'], $server_offset_time);
$modified = substr($dceditedon,0,10);
$DC_date_modified = " <meta name=\"DC.date.modified\" content=\"";
$DC_date_modified .= $modified."\" />\n";
}
// *** DISTRIBUTION ***
if (!$distribution == '') {
$MetaDistribution = " <meta name=\"distribution\" content=\"".$distribution."\" />\n";
}
// *** RATING ***
if (!$rating == '') {
$MetaRating = " <meta name=\"rating\" content=\"".$rating."\" />\n";
}
if ($dc_tags) {
// *** DC.IDENTIFIER ***
$url = $websiteurl."[~".$etomite->documentIdentifier."~]";
$DC_identifier = " <meta name=\"DC.identifier\" content=\"".$url."\" />\n";
}
if ($geo_tags) {
if (($latitude != "") && (longitude != "")) {
// *** GEO.ICBM ***
$Geo_icbm = " <meta name=\"ICBM\"";
$Geo_icbm .= " content=\"".$latitude.", ".$longitude."\" />\n";
// *** GEO.POSITION ***
$Geo_position = " <meta name=\"geo.position\"";
$Geo_position .= " content=\"".$latitude.";".$longitude."\" />\n";
}
if ($region != "") {
// *** GEO.REGION ***
$Geo_region = " <meta name=\"geo.region\"";
$Geo_region .= " content=\"".$region."\" />\n";
}
if ($placename != "") {
// *** GEO.PLACENAME ***
$Geo_placename = " <meta name=\"geo.placename\"";
$Geo_placename .= " content=\"".$placename."\" />\n";
}
}
// *** RETURN RESULTS ***
$output = $MetaType.$MetaLanguage.$MetaGenerator;
$output .= $MetaTitle.$MetaDesc.$MetaKeys;
$output .= $MetaAbstract.$MetaAuthor.$MetaCopyright;
$output .= $MetaRobots.$MetaGooglebot;
$output .= $MetaCache.$MetaPragma.$MetaExpires.$MetaEditedOn;
$output .= $MetaDistribution.$MetaRating;
if ($dc_tags) {
$dc_output = $DC_format.$DC_language.$DC_title;
$dc_output .= $DC_description.$DC_subject.$DC_title_alternative;
$dc_output .= $DC_publisher.$DC_creator.$DC_rights;
$dc_output .= $DC_date_created.$DC_date_modified.$DC_date_valid;
$dc_output .= $DC_identifier;
if ($dc_output != "") {
$output .= " \n".$dc_output;
}
}
if ($geo_tags) {
$geo_output = "";
if (!$dc_tags) {
$geo_output .= $DC_title;
}
$geo_output .= $Geo_icbm;
$geo_output .= $Geo_position.$Geo_region.$Geo_placename;
if ($geo_output != "") {
$output .= " \n".$geo_output;
}
}
return $output;
#26
Posted 31 May 2006 - 09:21 AM
// Snippet name: MollioCrumbs
// Snippet description: Outputs the page trail for Mollio templates
// Revision: 1.0 ships with Etomite 0.6.1-Final
// Author: jaredc@honeydewdesign.com - 2005-05-26
//
// This snippet was designed to show the
// path through the various levels of
// site structure back to the root. It
// is NOT necessarily the path the user
// took to arrive at a given page. Based on
// PageTrail snippet by: Bill Wilson.
// Changes by Lloyd Borrett - 2006-04-08
// Adapted to produce output for Mollio templates
// Configuration Settings
// $maxCrumbs [number]
// Max number of elements to have in a path.
// 100 is an arbitrary high number.
// If you make it smaller, like say 2, but you
// you are 5 levels deep, it will appear as:
// Home > ... > Level 4 > Level 5
// It should be noted that "Home" and the current
// page do not count. Each of these are configured
// separately.
$maxCrumbs = 5;
// $pathThruUnPub [ true | false ]
// When you path includes an unpublished folder, setting this to
// true will show all documents in path EXCEPT the unpublished.
// Example path (unpublished in caps)
// home > news > CURRENT > SPORTS > skiiing > article
// $pathThruUnPub = true would give you this:
// home > news > skiiing > article
// $pathThruUnPub = false would give you this:
// home > skiiing > article (assuming you have home crumb turned on)
$pathThruUnPub = true;
// $showHomeCrumb [true | false]
// Would you like your crumb string to start
// with a link to home? Some would not because
// a home link is usually found in the site logo
// or elsewhere in the navigation scheme.
$showHomeCrumb = true;
// $showCrumbsAtHome [ true | false ]
// You can use this to turn off the breadcrumbs on the
// home page.
$showCrumbsAtHome = true;
// $showCurrentCrumb [true | false]
// Show the current page in path
$showCurrentCrumb = true;
// $currentAsLink [true | false]
// If you want the current page crumb to be a
// link (to itself) then make true.
$currentAsLink = false;
// $crumbSeparator [string]
// Define what you want between the crumbs
$crumbSeparator = "/";
// $homeCrumbTitle [string]
// Just in case you want to have a home link,
// but want to call it something else
$homeCrumbTitle = 'Home';
// ***********************************
// END CONFIG SETTINGS
// THE REST SHOULD TAKE CARE OF ITSELF
// ***********************************
// Check for home page
if ($showCrumbsAtHome || (!$showCrumbsAtHome && ($etomite->documentIdentifier != $etomite->config['site_start'])) ){
//initialize crumb array
$ptarr = array();
// get current page parent id
$docInfo = $etomite->getDocument($etomite->documentIdentifier);
$pid = $docInfo['parent'];
// show current page, as link or not
if ($showCurrentCrumb){
if ($currentAsLink){
$ptarr[] = '<a href="[~'.$etomite->documentIdentifier.'~]" title="'.$docInfo['pagetitle'].'">'.$docInfo['pagetitle']."</a>\n";
} else {
$ptarr[] = "<strong>".$docInfo['pagetitle']."</strong>\n";
}
}
// assemble intermediate crumbs
$crumbCount = 0;
$activeOnly = ($pathThruUnPub)? 0 : 1;
while (($parent=$etomite->getPageInfo($pid,$activeOnly,"id,pagetitle,published,deleted,parent")) && ($crumbCount < $maxCrumbs)) {
if ($parent['published'] && !$parent['deleted'] && $parent['id'] != $etomite->config['site_start']){
$ptarr[] = '<a href="[~'.$parent['id'].'~]" title="'.$parent['pagetitle'].'">'.$parent['pagetitle']."</a>\n";
}
$pid = $parent['parent'];
$crumbCount++;
}
// insert '...' if maximum number of crumbs exceded
if ($parent != 0){
$ptarr[] = '...';
}
// add home link if desired
if ($showHomeCrumb && ($etomite->documentIdentifier != $etomite->config['site_start'])){
$ptarr[] = '<a href="[~'.$etomite->config['site_start'].'~]" title="'.$homeCrumbTitle.'">'.$homeCrumbTitle."</a>\n";
}
$ptarr = array_reverse($ptarr);
$output = join($ptarr, " $crumbSeparator ");
return $output;
} // end check if home page
#27
Posted 31 May 2006 - 09:22 AM
// Snippet name: MollioMainMenu
// Snippet description: Outputs the Main Menu for Mollio templates
// Revision: 1.0 ships with Etomite 0.6.1-Final
// Author: Lloyd Borrett - 2006-04-09
//
// Based on elements from the ListSiteMap and ListMenu snippets
// by jaredc@honeydewdesign.com
//
// This snippet was designed to show a nested
// list menu with each pagetitle being a
// link to that page. It will not include
// unpublished folders/pages OR its children,
// even if the children ARE published.
// List items are marked with CSS class values of
// active, last or first as appropriate.
// Configuration
// $menuRoot [int]
// The parent ID of your root. Default 0. Can be set in
// snippet call with MMM_root (to doc id 10 for example):
// [[MollioMainMenu?MMM_root=10]]
$menuRoot = 0;
// $titleOfLinks [ string ]
// What database field do you want the title of your links to be?
// it can be any of the following:
// id, pagetitle, description, parent, alias, longtitle.
// If the field you choose is empty for any given document,
// the the pagetitle of the document is used.
$titleOfLinks = 'longtitle';
// $maxLevels [ int ]
// Maximum number of levels to include. The default 2 is the number
// of levels supported by the CSS styles.
// A value of 0 will allow all levels.
// Also settable with snippet variable MMM_levels:
// [[MollioMainMenu?MMM_levels=2]]
$maxLevels = 2;
// ###########################################
// End config, the rest takes care of itself #
// ###########################################
// Initialize
$menuRoot = (isset($MMM_root))? $MMM_root : $menuRoot;
$maxLevels = (isset($MMM_levels))? $MMM_levels : $maxLevels;
// Overcome single use limitation on functions
global $MakeMainMenuDefined;
if(!isset($MakeMainMenuDefined)){
function MakeMainMenu($funcEtomite, $listParent, $listLevel, $titleOfLinks, $maxLevels, $fullGeneology){
$children = $funcEtomite->getActiveChildren($listParent, 'menuindex', 'ASC', 'id, pagetitle, parent, alias, longtitle, published');
$childrenCount = count($children);
$ie = "\n";
$pad = str_pad($pad,($listLevel * 2)," ");
// start this level
if ($listLevel == 0) {
$output .= $pad.'<ul id="nav">'.$ie;
} else {
$output .= $pad.'<ul>'.$ie;
}
for($x=0; $x<$childrenCount; $x++) {
$child = $children[$x];
// Is this the current document or an ancestor?
$ancestor = in_array($child['id'], $fullGeneology);
// Set the class to active, last, first or none
if ($ancestor) {
$cssStyle = ' class="active"';
} else {
if (($x+1) == $childrenCount) {
$cssStyle = ' class="last"';
} else {
if ($x == 0) {
$cssStyle = ' class="first"';
} else {
$cssStyle = '';
}
}
}
$output .= $pad.'<li'.$cssStyle.'>';
$output .= '<a href="[~'.$child['id'].'~]" title="';
if ($child[$titleOfLinks] != "") {
$output .= str_replace('"',"'",$child[$titleOfLinks]);
} else {
$output .= str_replace('"',"'",$child['pagetitle']);
}
$output .= '">'.$child['pagetitle'].'</a>';
if ($funcEtomite->getActiveChildren($child['id']) && (($maxLevels==0) || ($maxLevels > $listLevel+1 ))){
$output .= MakeMainMenu($funcEtomite, $child['id'], $listLevel+1, $titleOfLinks, $maxLevels, $fullGeneology);
}
$output .= '</li>'.$ie;
}
$output .= $pad.'</ul>'.$ie;
return $output;
}
$MakeMainMenuDefined = true;
}
// Create Geneology
$fullGeneology = array();
$geneologyMarker = $etomite->documentIdentifier;
while ($currentMarker=$etomite->getPageInfo($geneologyMarker, null, 'id,parent')){
$fullGeneology[] = $currentMarker['id'];
$geneologyMarker = $currentMarker['parent'];
}
$fullGeneology[] = 0;
return MakeMainMenu($etomite, $menuRoot, 0, $titleOfLinks, $maxLevels, $fullGeneology);
#28
Posted 31 May 2006 - 09:23 AM
// Snippet name: MollioSecondaryMenu
// Snippet description: Outputs the Secondary Menu for Mollio templates
// Revision: 1.0 ships with Etomite 0.6.1-Final
// Author: Lloyd Borrett - 2006-04-09
//
// Based on elements from the ListSiteMap and ListMenu snippets
// by jaredc@honeydewdesign.com
//
// This snippet was designed to show a nested
// list menu with each pagetitle being a
// link to that page. It will not include
// unpublished folders/pages OR its children,
// even if the children ARE published.
// List items are marked with CSS class values of
// active, last or first as appropriate.
// Configuration
// $titleOfLinks [ string ]
// What database field do you want the title of your links to be?
// it can be any of the following:
// id, pagetitle, description, parent, alias, longtitle.
// If the field you choose is empty for any given document,
// the the pagetitle of the document is used.
$titleOfLinks = 'longtitle';
// $maxLevels [ int ]
// Maximum number of levels to include. The default 4 is the number
// of levels supported by the CSS styles.
// A value of 0 will allow all levels.
// Also settable with snippet variable MMM_levels:
// [[MollioSecondaryMenu?MSM_levels=2]]
$maxLevels = 4;
// ###########################################
// End config, the rest takes care of itself #
// ###########################################
// Initialize
$maxLevels = (isset($MSM_levels))? $MSM_levels : $maxLevels;
// Overcome single use limitation on functions
global $MakeSecMenuDefined;
if(!isset($MakeSecMenuDefined)){
function MakeSecMenu($funcEtomite, $listParent, $listLevel, $titleOfLinks, $maxLevels, $fullGeneology){
$children = $funcEtomite->getActiveChildren($listParent, 'menuindex', 'ASC', 'id, pagetitle, parent, alias, longtitle, published');
$childrenCount = count($children);
$ie = "\n";
$pad = str_pad($pad,($listLevel * 2)," ");
// start this level
if ($listLevel == 0) {
$output .= $pad.'<ul id="nav-secondary">'.$ie;
} else {
$output .= $ie.$pad.'<ul>'.$ie;
}
for($x=0; $x<$childrenCount; $x++) {
$child = $children[$x];
// Is this the current document or an ancestor?
$ancestor = in_array($child['id'], $fullGeneology);
// Set the class to active, last, first or none
if ($ancestor) {
$cssStyle = ' class="active"';
} else {
if (($x+1) == $childrenCount) {
$cssStyle = ' class="last"';
} else {
if ($x == 0) {
$cssStyle = ' class="first"';
} else {
$cssStyle = '';
}
}
}
$output .= $pad.'<li'.$cssStyle.'>';
$output .= '<a href="[~'.$child['id'].'~]" title="';
if ($child[$titleOfLinks] != "") {
$output .= str_replace('"',"'",$child[$titleOfLinks]);
} else {
$output .= str_replace('"',"'",$child['pagetitle']);
}
$output .= '">'.$child['pagetitle'].'</a>';
// Does this document have children?
$hasChildren = $funcEtomite->getActiveChildren($child['id']);
if ($hasChildren && $ancestor && (($maxLevels==0) || ($maxLevels > $listLevel+1 ))){
$output .= MakeSecMenu($funcEtomite, $child['id'], $listLevel+1, $titleOfLinks, $maxLevels, $fullGeneology);
}
$output .= '</li>'.$ie;
}
$output .= $pad.'</ul>'.$ie;
return $output;
}
$MakeSecMenuDefined = true;
}
$id = $etomite->documentIdentifier; //current document
// If we're at home, do nothing
$atHome = ($id == $etomite->config['site_start'])? true : false;
if ($atHome) {
return "";
}
// Create Geneology
$fullGeneology = array();
$geneologyMarker = $id;
while (($currentMarker = $etomite->getPageInfo($geneologyMarker, null, 'id,parent')) && ($currentMarker['parent'] != 0 ) ) {
$fullGeneology[] = $currentMarker['id'];
$geneologyMarker = $currentMarker['parent'];
}
$fullGeneology[] = 0;
return MakeSecMenu($etomite, $geneologyMarker, 0, $titleOfLinks, $maxLevels, $fullGeneology);
#29
Posted 31 May 2006 - 09:24 AM
// --------------------
// Snippet: NewsListing
// --------------------
// Originated as NewsListing v1.0 by Alex
// Revised as NewsListingRevised by mrruben5
// Revised as NewsListingRev02 by LePrince
// Revised as NewsListingRev03 by Lloyd Borrett (lloyd@borrett.id.au)
// Revised as NewsListing v1.3 by Lloyd Borrett (lloyd@borrett.id.au)
//
// This version takes many of the ideas of NewsListingRev02 back
// into the tableless form of NewsListingRevised. Plus adds some other ideas.
//
// Showing the date-time is now optional.
//
// Option to output dates and times as local time.
// This would be typically done using the Etomite configuration
// "server offset time" value. But you can specify a different value.
//
// Option to get only active documents, or all documents, in the folder.
//
// Last Modified: 07-Apr-2006
//===== USAGE: ===============
// [[NewsListing]]
// [[NewsListing?newsid=8]]
// [[NewsListing?newsid=8&complete_news_id=10]]
// and so on for all the acceptable arguments.
//===== ARGUMENTS: ===============
// the folder that contains news entries
// passed as argument "newsid" or default to current document id
$resourceparent = isset($newsid) ? $newsid : $etomite->documentIdentifier;
// set this to the id of the document which contains the
// snippetcall where ALL news-articles are to be shown.
// the "Older news" text serves as hyperlink
// -1 = ignore this
if (!isset($complete_news_id)) {$complete_news_id = -1;}
// should the author be displayed? 1=yes, 0=no
if (!isset($show_author)) {$show_author = 1;}
// should the date-time be displayed? 1=yes, 0=no
if (!isset($show_date)) {$show_date = 1;}
// how many "older news" shall be displayed
// -1 = all of them
if (!isset($older_news)) {$older_news = -1;}
// should the pagetitle, which is used as heading, be clickable? 1=yes, 0=no
if (!isset($title_as_link)) {$title_as_link = 0;}
// should the news item text be omitted? 1=yes, 0=no
// goes nicely with $title_as_link!
if (!isset($title_only)) {$title_only = 0;}
// should only active documents be displayed? 1=yes, 0=no
// yes - returns only active documents (i.e. published and not deleted) in the folder
// no - returns all documents (i.e. published, unpublished, deleted) in the folder
if (!isset($show_only_active)) {$show_only_active = 1;}
//===== end of arguments =========
//===== CONFIGURATION: ===============
// number of news items to show a "short story" of
$nrblogs = 3;
// total number of news items to retrieve
// archives is $nrblogstotal minus $nrblogs
$nrblogstotal = 30;
// how many characters to show of news item if splitter not being used
$lentoshow = 150;
// what indicates the "full story", i.e. the end of the
// short portion and the beginning of the
// "full story" - this has to be "written" manually in
// the article's text in HTML-mode (without the apostrophes of course)!
// the <!-- --> makes it a comment which is automatically
// invisible within the article.
$splitter = "<!--FullStory-->";
// the text to show as full story link
$fullstorytext = "Full Story";
// shall the article be cut off at the *splitter*? 1=yes, 0=no
$use_splitter = 1;
// the text to show for no entries found
$noentriestext = "No entries found.";
// the text to show as heading for older news
// Note that you must write special characters as html entities.
$oldernewstext = "Older news";
// the default author name
$noauthortext = "anonymous";
// the date-time format to display based on strftime()
$timeformat = "%A, %d-%b-%Y %H:%M %p"; # ( Thursday, 08-Oct-2005 02:00 PM )
// get server offset time in hours
$server_offset_time = $etomite->config['server_offset_time'];
if (!$server_offset_time) {
$server_offset_time = 0;
} else {
$server_offset_time = ($server_offset_time / 60 / 60);
}
// default time offset (+/-) in hours to use
// typically set to the Etomite configuration "server offset time" value
// using the $server_offset_time value calculated above
$default_time_diff = $server_offset_time;
//===== end of configuration =========
// initialise the news variable
$output = '';
// time adjustment
$timeadjust = ($default_time_diff * 60 * 60);
if ($show_only_active == 1) {
$resource = $etomite->getActiveChildren($resourceparent, 'createdon', 'DESC', $fields='id, pagetitle, description, content, createdon, createdby');
} else {
$resource = $etomite->getAllChildren($resourceparent, 'createdon', 'DESC', $fields='id, pagetitle, description, content, createdon, createdby');
}
$limit = count($resource);
if ($limit < 1) {
$output .= $noentriestext."<br />\n";
}
$nrblogs = $nrblogs<$limit ? $nrblogs : $limit;
if ($limit > 0) {
for ($x = 0; $x < $nrblogs; $x++) {
$tbl = $this->dbConfig['dbase'].".".$this->dbConfig['table_prefix']."manager_users";
$sql = "SELECT username FROM $tbl WHERE $tbl.id = ".$resource[$x]['createdby'];
$rs2 = $etomite->dbQuery($sql);
$limit2 = $etomite->recordCount($rs2);
if ($limit2 < 1) {
$username .= $noauthortext;
} else {
$resourceuser = $etomite->fetchRow($rs2);
$username = $resourceuser['username'];
//====== Splitter to be used? =====
if ($use_splitter == 1) {
if (is_string(strstr ($resource[$x]['content'], $splitter))) {
// Does the content contain the socalled "splitter"?
$rest = array();
// HTMLarea/XINHA encloses it in paragraph's
$rest = explode('<p>'.$splitter.'</p>',$resource[$x]['content']);
// For TinyMCE or if it isn't wrapped inside paragraph tags
$rest = explode($splitter,$rest['0']);
$rest = $rest['0'].'<p><a href="[~'.$resource[$x]['id'].'~]">'.$fullstorytext."</a></p>\n";
} else {
$rest = $resource[$x]['content'];
}
//======= End of splitter part ===
} else {
//=== no splitter ... normal behaviour: ===
// strip the content
if (strlen($resource[$x]['content']) > $lentoshow) {
$rest = substr($resource[$x]['content'], 0, $lentoshow);
$rest .= "...<br />\n";
$rest .= "<a href=\"[~".$resource[$x]['id']."~]\">< More on this story ></a>";
} else {
$rest = $resource[$x]['content'];
}
//======= End of no splitter part ===
}
$output .= "\n<fieldset><legend>";
if ($title_as_link == 1) {
$output .= "<a href=[~".$resource[$x]['id']."~]>";
}
$output .= $resource[$x]['pagetitle'];
if ($title_as_link == 1) {
$output .= "</a>";
}
$output .= "</legend>\n";
if ($title_only != 1) {
$output .= $rest."\n";
}
if (($show_author == 1) || ($show_date == 1)) {
$output .= "<p style=\"text-align:right;\">Posted ";
if ($show_author == 1) {
$output .= "by ".$username." ";
}
if ($show_date == 1) {
$output .= "on ".strftime($timeformat, $resource[$x]['createdon'] + $timeadjust);
}
$output .= "</p>";
}
$output .= "</fieldset>\n";
}
}
}
if ($limit > $nrblogs) {
$output .= "<p><b>";
//=== is there a document where *all* news are to be displayed? If so
//=== here is the hyperlink
if ($complete_news_id != -1) {
$output .= "<a href=\"[~$complete_news_id~]\">";
}
//=== older news text:
$output .= "$oldernewstext";
//=== is there a document where *all* news are to be displayed? If so
//=== close the hyperlink
if ($complete_news_id != -1) {
$output .= "</a>";
}
$output .= "</b><br />\n";
//=== count of older news to be shown:
if ($older_news == -1) {
$older_news = $limit;
} else {
$older_news += $nrblogs;
}
for ($x = $nrblogs; $x < $limit; $x++) {
//=== show only a certain amount of older news:
if ($x < $older_news) {
$output .= "> <a href=\"[~".$resource[$x]['id']."~]\"";
if (($show_author == 1) || ($show_date == 1)) {
$output .= " title=\"Posted ";
if ($show_author == 1) {
$output .= "by ".$username." ";
}
if ($show_date == 1) {
$output .= "on ".strftime($timeformat, $resource[$x]['createdon'] + $timeadjust);
}
$output .= "\"";
}
$output .= ">".$resource[$x]['pagetitle']."</a><br />\n";
}
}
$output .= "<br />\n</p>\n";
}
return $output;
#30
Posted 31 May 2006 - 09:25 AM
// Snippet name: PageTrail
// Snippet description: Outputs the page trail, based on Bill Wilson's script
// Revision: 1.00 ships with Etomite 0.6.1-Final
$sep = " » ";
// end config
$ptarr = array();
$pid = $etomite->documentObject['parent'];
$ptarr[] = "<a href='[~".$etomite->documentObject['id']."~]'>".$etomite->documentObject['pagetitle']."</a>";
while ($parent=$etomite->getParent($pid)) {
$ptarr[] = "<a href='[~".$parent['id']."~]'>".$parent['pagetitle']."</a>";
$pid = $parent['parent'];
}
$ptarr = array_reverse($ptarr);
return join($ptarr, $sep);


Help
This topic is locked
Back to top
MultiQuote








