Jump to content


Etomite 0.6.1.0 Prelude Snippets


35 replies to this topic

#21 lloyd_borrett

    Loves Etomite Forums!

  • Member
  • PipPipPipPip
  • 605 posts
  • Gender:Male

Posted 31 May 2006 - 09:15 AM

ListMenu - Feature-rich menu snippet

// --------------------
// 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 lloyd_borrett

    Loves Etomite Forums!

  • Member
  • PipPipPipPip
  • 605 posts
  • Gender:Male

Posted 31 May 2006 - 09:16 AM

ListSiteMap - Output a nested list site map

// --------------------
// 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 lloyd_borrett

    Loves Etomite Forums!

  • Member
  • PipPipPipPip
  • 605 posts
  • Gender:Male

Posted 31 May 2006 - 09:17 AM

MenuBuilder - Builds the site menu

// 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 .= "&nbsp;";
	}
	$indentString .= "&raquo;&nbsp;";
}

$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 lloyd_borrett

    Loves Etomite Forums!

  • Member
  • PipPipPipPip
  • 605 posts
  • Gender:Male

Posted 31 May 2006 - 09:18 AM

MenuHori - [TEMPLATE] MenuHori Snippet

//  --------------------------------------------
//		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="&nbsp; | &nbsp;";

// --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 lloyd_borrett

    Loves Etomite Forums!

  • Member
  • PipPipPipPip
  • 605 posts
  • Gender:Male

Posted 31 May 2006 - 09:19 AM

MetaTagsExtra - Output page related meta tags

/*
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 lloyd_borrett

    Loves Etomite Forums!

  • Member
  • PipPipPipPip
  • 605 posts
  • Gender:Male

Posted 31 May 2006 - 09:21 AM

MollioCrumbs - [TEMPLATE] Outputs the page trail for Mollio templates

// 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 lloyd_borrett

    Loves Etomite Forums!

  • Member
  • PipPipPipPip
  • 605 posts
  • Gender:Male

Posted 31 May 2006 - 09:22 AM

MollioMainMenu - [TEMPLATE] Outputs the Main menu for Mollio templates

// 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 lloyd_borrett

    Loves Etomite Forums!

  • Member
  • PipPipPipPip
  • 605 posts
  • Gender:Male

Posted 31 May 2006 - 09:23 AM

MollioSecondaryMenu - [TEMPLATE] Outputs the Secondary Menu for Mollio templates

// 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 lloyd_borrett

    Loves Etomite Forums!

  • Member
  • PipPipPipPip
  • 605 posts
  • Gender:Male

Posted 31 May 2006 - 09:24 AM

NewsListing - Displays news.

// --------------------
// 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']."~]\">&lt; More on this story &gt;</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 .= "&gt; <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 lloyd_borrett

    Loves Etomite Forums!

  • Member
  • PipPipPipPip
  • 605 posts
  • Gender:Male

Posted 31 May 2006 - 09:25 AM

PageTrail - Outputs the page trail, based on Bill Wilson's script

// 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 = " &raquo; ";

// 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);


#31 lloyd_borrett

    Loves Etomite Forums!

  • Member
  • PipPipPipPip
  • 605 posts
  • Gender:Male

Posted 31 May 2006 - 09:26 AM

PoweredBy - A little link to Etomite

// Snippet name: PoweredBy
// Snippet description: A little link to Etomite.
// Revision: 1.00 ships with Etomite 0.6.1-Final

$version = $etomite->getVersionData();
return '<a href="http://etomite.com" title="Etomite Website">Powered by Etomite <b>'.$version['version'].$version['patch_level'].'</b> <i>('.$version['code_name'].')</i>.</a>';


#32 lloyd_borrett

    Loves Etomite Forums!

  • Member
  • PipPipPipPip
  • 605 posts
  • Gender:Male

Posted 31 May 2006 - 09:27 AM

RelatedInfo - Output a related chunk into the document

// Snippet name: RelatedInfo
// Snippet description: Outputs a related chunk into the document
// Revision: 1.0 ships with Etomite 0.6.1-Final
// Author: Lloyd Borrett - 2006-04-09

// Description:
//   Outputs a chunk into the document based on the 
//   document's alias/id, and optionally, a prefix 
//   passed to the chunk.

// Usage:
//   Insert [[RelatedInfo]] or [[RelatedInfo?prefix=<YourPrefix>]]
//   in your template where you want the required document 
//   specific content to appear.
//   e.g. [[RelatedInfo]], [[RelatedInfo?prefix=RightColumn]],
//   [[RelatedInfo?prefix=MiddleColumn]] etc.
//   Create a chunk called "RelatedInfo-<value>" and/or 
//   "<YourPrefix>-<value>" for each document where you want 
//   to display document related content.

//   "<value>" is the document alias (if specified), or the 
//   document id number if there is no alias value.
//   "<YourPrefix>" is a prefix value passed to the chunk.

//   For example: "RelatedInfo-home", "RelatedInfo-1",
//   "MiddleColumn-home", "MiddleColumn-1" etc.

//   The snippet will insert the content of your "RelatedInfo-<value>" and/or
//   "<YourPrefix>-<value>" chunks into the appropriate document.

//   If there is no output from "RelatedInfo-<value>" and/or "<YourPrefix>-<value>",
//   typically because the chunks don't exist, the you can request that the default
//   "RelatedInfo" or "<YourPrefix>" chunks are used, if they exist.

// Problem 1:
//   You want to be able to put some content into a section of 
//   your document template. But you would like to be able to have 
//   different content for different documents.
//   Typically this might be document related content for another 
//   column or something similar.

// Solution 1:
//   Insert [[RelatedInfo]] into your template where you want the content to appear.
//   Now create a chunk called "RelatedInfo-<value>" for each document where you want
//   document specific content to appear.
//   For example, if you have a document with an alias "productx", 
//   the chunk would be called "RelatedInfo-productx".
//   If the document has no alias, then it's id value is used, 
//   for example "RelatedInfo-23".
//   Into the "RelatedInfo-<value>" chunk you can put the content you want,
//   and/or calls to other chunks and snippets.
//   If you don't have document specific content for that document, 
//   then you can let the default content from the "RelatedInfo" chunk 
//   be output, if it exists.
//   If there is no "RelatedInfo-<value>" or "RelatedInfo" chunks, 
//   then nothing is output.

// Problem 2:
//   Okay so you can use [[RelatedInfo]] to do document specific 
//   content for say your middle column.
//   But on some documents you might also might want some page 
//   specific extra content in another part of the document. 
//   For example, the right column.

// Solution 2:
//   Insert [[RelatedInfo?prefix=<YourPrefix>]] into your template 
//   where you want the content to appear.
//   Now create a chunk called "<YourPrefix>-<value>" for each page 
//   where you want this document specific content to appear.
//   For example, you want to put some content into the right 
//   column of your template.
//   So you put [[RelatedInfo?prefix=RightColumn]] into your template.
//   And if you have a document with an alias "productx", the chunk would be
//   called "RightColumn-productx". If the document has no alias, 
//   then it's id value is used, for example "RightColumn-23".
//   Into the "<YourPrefix>-<value>" chunk you can put the content you want,
//   and/or calls to other chunks and snippets.
//   If you don't have document specific content for that document, 
//   you can let the default content from the "<YourPrefix>" chunk 
//   be output, if it exists.
//   If there is no "<YourPrefix>-<alias>" or "<YourPrefix>" chunks, 
//   then nothing is output.

// Explanation:
//   The power of this snippet is that a chunk doesn't have to just 
//   contain raw HTML code.
//   The chunk can also have calls to other chunks, and even calls to snippets.
//   Thus each document specific chunk you create can be extremely 
//   flexible in what gets  put into your document, with you having 
//   to duplicate raw HTML code here, there and everywhere.

//   (So much to explain such a simple snippet!)


// Configuration Setting

// $showDefaultCrumb [true | false]
// If there is no output from calling the crumb for the specific document, 
// which typically occurs if you haven't created the crumb, 
// instead of getting nothing you can ask for a default crumb 
// to be used by setting this value to true. 
// Of course, if you don't set up a default crumb, you still get nothing. 
// If you don't want to have this feature enabled just set this value to false.
$showDefaultCrumb = true;

$output = "";

if (!isset($prefix)) {
	$prefix = "RelatedInfo";
} else {
	if ($prefix == "") {
		$prefix = "RelatedInfo";
	}
}

$alias = $etomite->documentObject['alias'];
if ($alias == "") {
	$alias = $etomite->documentIdentifier;
}

$output .= $etomite->putChunk($prefix.'-'.$alias);
if ($output == "" && $showDefaultCrumb) {
	$output .= $etomite->putChunk($prefix);
}

return $output;


#33 lloyd_borrett

    Loves Etomite Forums!

  • Member
  • PipPipPipPip
  • 605 posts
  • Gender:Male

Posted 31 May 2006 - 09:28 AM

SearchForm - All-in-one snippet to search the site

// Snippet name: SearchForm
// Snippet description: All-in-one snippet to search the site
// Revision: 1.1 ships with Etomite 0.6.1-Final

$searchString = 
isset($_POST['search']) && 
$_POST['search']!= "{{" && 
$_POST['search']!= "[[" && 
$_POST['search']!= "[(" && 
$_POST['search']!= "[~" && 
$_POST['search']!= "[*" ?
$_POST['search'] : "";


$SearchForm .= '<form name="SearchForm" action="" method="post">'."\n"; 
$SearchForm .= '<input type="text" name="search" class="text" value="'.$searchString.'" /><br />'."\n"; 
$SearchForm .= '<input type="submit" name="sub" class="button" value="Search" />'."\n"; 
$SearchForm .= '</form>'; 

if(isset($_POST['search']) && $_POST['search']!='') { 
   $search = explode(" ", $_POST['search']); 
   $tbl = $etomite->dbConfig['dbase'].".".$etomite->dbConfig['table_prefix']."site_content";
   $sql = "SELECT id, pagetitle, parent, description FROM $tbl WHERE ($tbl.content LIKE '%".$search[0]."%'"; 
   for ($x=1;$x < count($search); $x++) { 
	   $sql .= " AND $tbl.content like '%$search[$x]%'"; 
   } 
   $sql .= " OR $tbl.pagetitle LIKE '%".$search[0]."%' "; 
   for ($x=1;$x < count($search); $x++) { 
	   $sql .= " AND $tbl.pagetitle like '%$search[$x]%'"; 
   } 
   $sql .= " OR $tbl.description LIKE '%".$search[0]."%' "; 
   for ($x=1;$x < count($search); $x++) { 
	   $sql .= " AND $tbl.description like '%$search[$x]%'"; 
   } 
   $sql .= ") AND $tbl.published = 1 AND $tbl.searchable=1 AND $tbl.deleted=0;"; 
   $rs = $etomite->dbQuery($sql); 
   $limit = $etomite->recordCount($rs); 
   if($limit>0) { 
	  $SearchForm .= "<p>The following results were found:</p>\n";
	  $SearchForm .= "<table cellspacing=\"0\" cellpadding=\"0\">\n"; 
	  for ($y = 0; $y < $limit; $y++) { 
		 $SearchFormsrc=$etomite->fetchRow($rs); 
		 $SearchForm.="<tr><td style=\"padding: 1px\"><a href=\"[~".$SearchFormsrc['id']."~]\"><b>".$SearchFormsrc['pagetitle']."</b></a></td>\n";
		 $SearchForm.="<td style=\"padding: 1px\">"; 
		 $SearchForm.=$SearchFormsrc['description']!='' ? " - <small>".$SearchFormsrc['description']."</small>" : ""; 
		 $SearchForm .= "</td></tr>";
	  } 
	  $SearchForm .= "</table>";
   } else { 
	  $SearchForm.="<p>Sorry, couldn't find anything!</p>"; 
   } 
} 

return $SearchForm;


#34 lloyd_borrett

    Loves Etomite Forums!

  • Member
  • PipPipPipPip
  • 605 posts
  • Gender:Male

Posted 31 May 2006 - 09:29 AM

SearchPrompt - Search prompt snippet for use with SearchResults

// Snippet name: SearchPrompt
// Snippet description: Search prompt snippet for use with SearchResults
// Revision: 1.00 ships with Etomite 0.6.1-Final
// Use: [!SearchPrompt?resultsid=###!] snippet call where ### is the
//   document id of the page which contains the [!SearchResults!] snippet call

$resultsDefault = "16";  // Document id to use if $resultsid not sent
$resultsid = isset($resultsid) ? $resultsid : $resultsDefault;

$prompt = "<br />Search this site<br />";  // Search box label text
$submit = "Search";  // Submit button label

$output = '
<div class="searchbox" style="text-align:center;">'.$prompt.'
  <form name="SearchForm" action="[~'.$resultsid.'~]" method="post"> 
	<p><input type="text" name="search" value="" /></p>
	<p><input type="submit" name="sub" class="button" value="'.$submit.'" /></p>
  </form>
</div>
';

return $output;


#35 lloyd_borrett

    Loves Etomite Forums!

  • Member
  • PipPipPipPip
  • 605 posts
  • Gender:Male

Posted 31 May 2006 - 09:30 AM

SearchResults - Displays results of SearchPrompt snippet

//  SearchResults
//  Displays results of SearchPrompt snippet

$noResults = "<p>No search results were found.</p>";
$resultsText = "<p>The following results were found:</p>";
$searchString = 
isset($_POST['search']) && 
$_POST['search']!= "{{" && 
$_POST['search']!= "[[" && 
$_POST['search']!= "[(" && 
$_POST['search']!= "[~" && 
$_POST['search']!= "[*" ?
$_POST['search'] : "";

if(isset($_POST['search']) && $_POST['search']!='') { 
   $search = explode(" ", $_POST['search']); 
   $sql = "SELECT id, pagetitle, parent, description FROM ".$etomite->db.site_content." WHERE (content LIKE '%".$search[0]."%'"; 
   for ($x=1;$x < count($search); $x++) { 
	   $sql .= " AND content like '%$search[$x]%'"; 
   } 
   $sql .= " OR pagetitle LIKE '%".$search[0]."%' "; 
   for ($x=1;$x < count($search); $x++) { 
	   $sql .= " AND pagetitle like '%$search[$x]%'"; 
   } 
   $sql .= " OR description LIKE '%".$search[0]."%' "; 
   for ($x=1;$x < count($search); $x++) { 
	   $sql .= " AND description like '%$search[$x]%'"; 
   } 
   $sql .= ") AND published = 1 AND searchable=1 AND deleted=0;"; 
   $rs = $etomite->dbQuery($sql); 
   $limit = $etomite->recordCount($rs); 
   if($limit>0) { 
	  $SearchForm .= $resultsText."<p><table cellspacing='0' cellpadding='0'>"; 
	  for ($y = 0; $y < $limit; $y++) { 
		 $SearchFormsrc=$etomite->fetchRow($rs); 
		 $SearchForm.="<tr><td style='padding: 1px'><a href='[~".$SearchFormsrc['id']."~]'><b>".$SearchFormsrc['pagetitle']."</b></a></td><td style='padding: 1px'>"; 
		 $SearchForm.=$SearchFormsrc['description']!='' ? " - <small>".$SearchFormsrc['description']."</small>" : ""; 
		 $SearchForm .= "</td></tr>";
	  } 
	  $SearchForm .= "</table>";
   } else { 
	  $SearchForm .= $noResults; 
   } 
} 

return $SearchForm;


#36 lloyd_borrett

    Loves Etomite Forums!

  • Member
  • PipPipPipPip
  • 605 posts
  • Gender:Male

Posted 31 May 2006 - 09:31 AM

SiteUpdate - Returns date of most recent document update

// Snippet name: SiteUpdate
// Snippet description: Returns date of most recent document update
// Revision: 1.1 ships with Etomite 0.6.1-Final

// Author: Ralph A. Dahlgren -- 2005-07-13
// Usage: [!SiteUpdate?dateFormat=%B %e, %Y!] Returns date formatted: July 13, 2005 
// See strftime() documentation for additional formatting options

// Changes:
//   v1.1 by Lloyd Borrett -- 2006-04-07
//   Return local time based on Etomite server offset time

// Default Date/Time format to use if not sent in snippet call
$format = isset($dateFormat) ? $dateFormat : "%B %e, %Y";

// get the Etomite server offset time in seconds
$server_offset_time = $etomite->config['server_offset_time'];
if (!$server_offset_time) {
  $server_offset_time = 0;
}

$sql = "SELECT editedon FROM ".$etomite->db."site_content ORDER BY editedon DESC";
$rs = $etomite->dbQuery($sql);

if ($etomite->recordCount($rs) >= 1){
  $row = $etomite->fetchRow($rs);
  $update= strftime($format,$row['editedon'] + $server_offset_time);
} else {
  $update="";
}

return $update;






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users