Jump to content


Etomite 0.6.1.0 Prelude Snippets


  • This topic is locked This topic is locked
35 replies to this topic

#1 lloyd_borrett

    Loves Etomite Forums!

  • Member
  • PipPipPipPip
  • 605 posts
  • Gender:Male

Posted 31 May 2006 - 08:42 AM

G'day,

Here is a list of all of the snippets that shipped with Etomite 0.6.1 Prelude:

A02Menu - [TEMPLATE] Menu for Andreas02
A03Menu - [TEMPLATE] Menu for Andreas03
A05Menu - [TEMPLATE] Menu for Andreas05
A06A08A09Hori - [TEMPLATE] Menu for Andreas06,08,09
A07Menu - [TEMPLATE] Menu for Andreas07
autumnmenu - [TEMPLATE] Menu for Autumn
BGMenu - [TEMPLATE] Menu for BorrowedGoods
Copyright - Returns a copyright statement
DateTime - Makes a date and time... thingy.
DateTimePlus - Adjusts and formats document or current Date/Time
DontLogPageHit - Stops the parser from logging the page hit
FirstHit - Fetches the first ever recorded page impression from the database.
FormHandler - Saves form data to an internal or external database table (Advanced)
GetAuthorData - Returns author information based on sent parameters
GetDocContent - Example of extracting document content using API
GetKeywords - Fetches the keywords attached to the document.
GetStats - Fetches the visitor statistics totals from the database
GoogleSiteMap_XML - Output a Google XML site map
ListDocuments - Displays document listings based on provided criteria
ListMenu - Feature-rich menu snippet
ListSiteMap - Output a nested list site map
MenuBuilder - Builds the site menu
MenuHori - [TEMPLATE] MenuHori Snippet
MetaTagsExtra - Output page related meta tags
MollioCrumbs - [TEMPLATE] Outputs the page trail for Mollio templates
MollioMainMenu - [TEMPLATE] Outputs the Main menu for Mollio templates
MollioSecondaryMenu - [TEMPLATE] Outputs the Secondary Menu for Mollio templates
NewsListing - Displays news.
PageTrail - Outputs the page trail, based on Bill Wilson's script
PoweredBy - A little link to Etomite
RelatedInfo - Output a related chunk into the document
SearchForm - All-in-one snippet to search the site
SearchPrompt - Search prompt snippet for use with SearchResults
SearchResults - Displays results of SearchPrompt snippet
SiteUpdate - Returns date of most recent document update

PLEASE NOTE: There are already updated versions for many of these snippets in the Snippet Library and/or the Snippet Announcements Forum.

Best Regards, Lloyd Borrett.

Edited by lloyd_borrett, 31 May 2006 - 09:59 AM.


#2 lloyd_borrett

    Loves Etomite Forums!

  • Member
  • PipPipPipPip
  • 605 posts
  • Gender:Male

Posted 31 May 2006 - 08:45 AM

A02Menu - [TEMPLATE] Menu for Andreas02

$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='activenavitab'";
	} 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>";	
	} else {
		$menu .= "<a class='navitab' href='[~".$children[$x]['id']."~]'>$indentString".$children[$x]['pagetitle']."</a>";
	}
}

$menu .= "";
return $menu."";


#3 lloyd_borrett

    Loves Etomite Forums!

  • Member
  • PipPipPipPip
  • 605 posts
  • Gender:Male

Posted 31 May 2006 - 08:48 AM

A03Menu - [TEMPLATE] Menu for Andreas03

$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='sidelink'";
	} else {
		$active="";
	}
	if($children[$x]['id']==$etomite->documentIdentifier || $children[$x]['id']==$etomite->documentObject['parent']) {
		$menu .= "<a class='sidelink' href='[~".$children[$x]['id']."~]'>$indentString".$children[$x]['pagetitle']."</a><span class='hide'> | </span>";	
	} else {
		$menu .= "<a class='sidelink' href='[~".$children[$x]['id']."~]'>$indentString".$children[$x]['pagetitle']."</a><span class='hide'> | </span>";
	}
}

$menu .= "";
return $menu."";


#4 lloyd_borrett

    Loves Etomite Forums!

  • Member
  • PipPipPipPip
  • 605 posts
  • Gender:Male

Posted 31 May 2006 - 08:49 AM

A05Menu - [TEMPLATE] Menu for Andreas05

$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='menu'";
	} 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>";	
	} else {
		$menu .= "<a class='menu' href='[~".$children[$x]['id']."~]'>$indentString".$children[$x]['pagetitle']."</a>";
	}
}

$menu .= "";
return $menu."";


#5 lloyd_borrett

    Loves Etomite Forums!

  • Member
  • PipPipPipPip
  • 605 posts
  • Gender:Male

Posted 31 May 2006 - 08:54 AM

A06A08A09Hori - [TEMPLATE] Menu for Andreas06,08,09

$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 = "<ul id='nav'>";
$childrenCount = count($children);
$active="";

if($children==false) {
	return false;
}
for($x=0; $x<$childrenCount; $x++) {
	if($children[$x]['id']==$etomite->documentIdentifier) {
		$active="class='current'";
	} else {
		$active="class='current'";
	}
	if($children[$x]['id']==$etomite->documentIdentifier || $children[$x]['id']==$etomite->documentObject['parent']) {
		$menu .= "<li id='current' class='current'><a ".$active." href='[~".$children[$x]['id']."~]'>$indentString".$children[$x]['pagetitle']."</a></li>";	
	} else {
		$menu .= "<li><a href='[~".$children[$x]['id']."~]'>$indentString".$children[$x]['pagetitle']."</a></li>";
	}
}

$menu .= "</ul>";
return $menu."";


#6 lloyd_borrett

    Loves Etomite Forums!

  • Member
  • PipPipPipPip
  • 605 posts
  • Gender:Male

Posted 31 May 2006 - 08:56 AM

A07Menu - [TEMPLATE] Menu for Andreas07

$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='active'";
	} 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>";	
	} else {
		$menu .= "<a href='[~".$children[$x]['id']."~]'>$indentString".$children[$x]['pagetitle']."</a>";
	}
}

$menu .= "";
return $menu."";


#7 lloyd_borrett

    Loves Etomite Forums!

  • Member
  • PipPipPipPip
  • 605 posts
  • Gender:Male

Posted 31 May 2006 - 08:58 AM

autumnmenu - [TEMPLATE] Menu for Autumn

$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 = "<ul id='nav'>";
$childrenCount = count($children);
$active="";

if($children==false) {
	return false;
}
for($x=0; $x<$childrenCount; $x++) {
	if($children[$x]['id']==$etomite->documentIdentifier) {
		$active="";
	} else {
		$active="";
	}
	if($children[$x]['id']==$etomite->documentIdentifier || $children[$x]['id']==$etomite->documentObject['parent']) {
		$menu .= "<li><a href='[~".$children[$x]['id']."~]'>$indentString".$children[$x]['pagetitle']."</a></li>";	
	} else {
		$menu .= "<li><a href='[~".$children[$x]['id']."~]'>$indentString".$children[$x]['pagetitle']."</a></li>";
	}
}

$menu .= "</ul>";
return $menu."";


#8 lloyd_borrett

    Loves Etomite Forums!

  • Member
  • PipPipPipPip
  • 605 posts
  • Gender:Male

Posted 31 May 2006 - 08:59 AM

BGMenu - [TEMPLATE] Menu for BorrowedGoods

$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 = "<ul id='nav'>";
$childrenCount = count($children);
$active="";

if($children==false) {
	return false;
}
for($x=0; $x<$childrenCount; $x++) {
	if($children[$x]['id']==$etomite->documentIdentifier) {
		$active="class='selected'";
	} else {
		$active="";
	}
	if($children[$x]['id']==$etomite->documentIdentifier || $children[$x]['id']==$etomite->documentObject['parent']) {
		$menu .= "<li><a ".$active." href='[~".$children[$x]['id']."~]'>$indentString".$children[$x]['pagetitle']."</a></li>";	
	} else {
		$menu .= "<li><a href='[~".$children[$x]['id']."~]'>$indentString".$children[$x]['pagetitle']."</a></li>";
	}
}

$menu .= "</ul>";
return $menu."";


#9 lloyd_borrett

    Loves Etomite Forums!

  • Member
  • PipPipPipPip
  • 605 posts
  • Gender:Male

Posted 31 May 2006 - 09:01 AM

Copyright - Returns a copyright statement

/*
Snippet name: Copyright
Snippet description: Returns a copyright statement
Revision: 1.1 ships with Etomite 0.6.1-Final

Description:
  Returns a copyright statement of the form:
	'Copyright (c) 2006 by Lloyd Borrett. All rights reserved.'
	'Copyright (c) 2005-2006 by Lloyd Borrett. All rights reserved.'
	'Copyright (c) 2005-2006. All rights reserved.'

  (Note: the (c) is replaced with the actual copyright symbol character.
		 the '-' is replaced with an en dash.)

  The year range being from either a site start year (if provided) 
  to the current year, or from the year the document was created 
  to the current year. All year values are based on local time 
  using the Etomite server offset time configuration setting.
  The copyright holder can be the one entity for the 
  whole web site (if provided), or the author of the current
  document (if provided).

Snippet Author:
  Lloyd Borrett (lloyd@borrett.id.au)
  
Snippet Category:
  Miscellaneous

See in use at:
  www.raydon.com.au		   

Usage:
  Insert [[Copyright]] anywhere in the appropriate section
  of your template. (Usually the footer.)
*/

// *** Configuration Settings ***

// Start Year of the web site.
// To use the document creation date, set this to ''
$site_start_year = '';

// Copyright holder for the whole web site.
// To use the document author details of each document, set this to ''
$site_copyholder = $etomite->config['site_name'];

// *** Start

// Get the document details.

$docInfo = $etomite->getDocument($etomite->documentIdentifier);

// *** AUTHOR ***
if ($site_copyholder == '') {
   $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
   $copyholder = str_replace('"', '"', trim($authorname));
} else {
   $copyholder = $site_copyholder;
}

// *** 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 ($copyholder == '') {
   $copyname = $copyholder;
} else {
   $copyname = " by ".$copyholder;
}

// *** BUILD COPYRIGHT STATEMENT & RETURN RESULTS ***

$Copyright = "Copyright © ";
$Copyright .= $copydate.$copyname.". All rights reserved.";

return $Copyright;


#10 lloyd_borrett

    Loves Etomite Forums!

  • Member
  • PipPipPipPip
  • 605 posts
  • Gender:Male

Posted 31 May 2006 - 09:03 AM

DateTime - Makes a date and time... thingy.

// Snippet name: DateTime
// Snippet description: Makes a date and time... thingy.
// Revision: 1.1 ships with Etomite 0.6.1-Final
// Author: Alex -- 2004-09-12

/* For such a small piece of code, this is an exceedingly 
   powerful and handy snippet. The snippet accepts one 
   parameter, 'timestamp'. If this isn't set, the snippet 
   will display the current date and time. If you pass a 
   timestamp (UNIX-style), it will convert that instead. 
   Probably the most useful way of using this snippet is 
   by writing something like the following in your template 
   or document:

   Last edited on: [[DateTime?timestamp=[*editedon*]]

   This will display the date and time at which the document 
   was last altered on your page!
*/

// Changes:
//   v1.1 by Lloyd Borrett -- 2005-02-07
//   Return local time based on Etomite server offset 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;
}

if(!isset($timestamp)) {
	$timestamp=time();
}

return strftime("%d-%m-%Y %H:%M:%S", $timestamp + $server_offset_time);


#11 lloyd_borrett

    Loves Etomite Forums!

  • Member
  • PipPipPipPip
  • 605 posts
  • Gender:Male

Posted 31 May 2006 - 09:04 AM

DateTimePlus - Adjusts and formats document or current Date/Time

// Snippet name: DateTimePlus
// Snippet description: Adjusts and formats document or current Date/Time 
// Revision: 1.1 ships with Etomite 0.6.1-Final

// Author: Ralph A. Dahlgren -- rad14701 -- 2005-04-14 based on Bill Wilson's script
// Usage: [!DateTimePlus?timestamp=[*editedon*]&diff=2&format=d-m-Y H:i:s!]

// Changes:
//   v1.1 by Lloyd Borrett -- 2005-02-07
//   Use Etomite server offset time as the default time offset

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

// Default time offset (+/-) to use if not sent in snippet call
$defaultDiff = $server_offset_time;

// Default Date/Time format to use if not sent in snippet call based on date()
$defaultFormat = "( l, F jS, Y g:i a )";  #  ( Thursday, April 14th, 2005 8:00 pm )

// If timestamp such as [*editedon*] or [*createdon*] sent, use it, 
// otherwise use time()
if($timestamp == "editedon") $timestamp = $etomite->documentObject['editedon'];
elseif($timestamp == "createdon") $timestamp = $etomite->documentObject['createdon'];
elseif($timestamp == "pub_date") $timestamp = $etomite->documentObject['pub_date'];
elseif($timestamp == "unpub_date") $timestamp = $etomite->documentObject['unpub_date'];
$timestamp = isset($timestamp) ? $timestamp : time();

// Hours difference between server time and local time
$diff = isset($diff) ? $diff : $defaultDiff;

// Your desired Date/Time format based on date()
$format = isset($format) ? $format : $defaultFormat;

// Adjust time if required, format, and return
$timeadjust = ($diff * 60 * 60);
$output = date($format, $timestamp + $timeadjust);
return $output;


#12 lloyd_borrett

    Loves Etomite Forums!

  • Member
  • PipPipPipPip
  • 605 posts
  • Gender:Male

Posted 31 May 2006 - 09:05 AM

DontLogPageHit - Stops the parser from logging the page hit

$this->config['track_visitors']=0;
return "";


#13 lloyd_borrett

    Loves Etomite Forums!

  • Member
  • PipPipPipPip
  • 605 posts
  • Gender:Male

Posted 31 May 2006 - 09:06 AM

FirstHit - Fetches the first ever recorded page impression from the database.

// Snippet name: FirstHit
// Snippet description: Fetches the first ever recorded page impression from the database.
// Revision: 1.1 ships with Etomite 0.6.1-Final

// Changes:
//   v1.1 by Lloyd Borrett -- 2005-04-07
//   Return local time based on Etomite server offset 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;
}

$sql = "SELECT MIN(timestamp) AS first FROM ".$etomite->dbConfig['dbase'].".".$etomite->dbConfig['table_prefix']."log_access";
$rs = $etomite->dbQuery($sql);
$tmp = $etomite->fetchRow($rs);

return strftime("%d-%m-%Y %H:%M:%S", $tmp['first'] + $server_offset_time);


#14 lloyd_borrett

    Loves Etomite Forums!

  • Member
  • PipPipPipPip
  • 605 posts
  • Gender:Male

Posted 31 May 2006 - 09:07 AM

FormHandler - Saves form data to an internal or external database table (Advanced)

#  FormHandler -- Etomite 0.6.1+ Snippet -- 2005-03-11
#  Created By: Ralph A. Dahlgren -- rad14701@yahoo.com
#  Extracts data from an Etomite form and saves to either an internal or external MySQL database table.
#  WARNING: This is an advanced snippet which requires an understanding of HTML forms, PHP, and MySQL.
#		   This snippet assumes that the target database and table already exist.
#  Usage:
#  1. Place the snippet call [!FormHandler!] at the top of a document containing an HTML form
#  2. Insert hidden fields within the form to
#	Internal database tables
#	  $prefix = field perfix prepended onto form data elements only
#	  $into = name of the table which will receive the form data
#	External database tables
#	  $host = MySQL server hostname ('localhost','www.your_server.com')
#	  $user = username
#	  $pass = password
#	  $dbase = database name
#	  $into = name of the table which will receive the form data
#	  $prefix = field perfix prepended onto form data elements only
#  Note: The control elements (host,user,pass,dbase,fields,into,prefix,submit,reset) do not require a prefix.
#  Additional fields can be added to the form which will be replaced by calculated data. These fields must be prefixed.
#	timestamp = Unix timestamp using time() function
#	datetime = formatted date and/or time based on the string variable $datetime
#	additonal calculated fields can be added to the appropriate code section

$fields=array();  #  Define the $fields variable as an array
$datetime = "%Y-%m-%d %T";  #  Assign desired formatting for datetime data fields

# Has the form been submitted
if(isset($_POST['submit'])){
  # Was a prefix assigned as a hidden form field
  if(isset($_POST['prefix'])) $prefix = $_POST['prefix'];
  else return "Database Field Prefix Required...";

  # Extract the form data fields using getFormVars
  $fields = $etomite->getFormVars($method="POST",$prefix,$trim=true,$REQUEST_METHOD);
  if(isset($_POST['into'])) $into = $_POST['into'];
  else return "Database Name Parameter Missing...";

  #  Check for calculated field assignments based on returned value
  foreach($fields as $key=>$value){
	if($fields[$key] == "timestamp") $fields[$key] = time();
	if($fields[$key] == "datetime") $fields[$key] = strftime($datetime,time());
  }

  #  Was external database information supplied
  if(isset($_POST['host'])){
	$host = $_POST['host'];
	$user = $_POST['user'];
	$pass = $_POST['pass'];
	$dbase = $_POST['dbase'];
	#  External database so save using putExtTableRow
	$rs = $etomite->putExtTableRow($host, $user, $pass, $dbase, $fields, $into);
  } else {
	#  Internal database so save using putIntTableRow
	$rs = $etomite->putIntTableRow($fields,$into);
  }
}

# END of snippet code


#15 lloyd_borrett

    Loves Etomite Forums!

  • Member
  • PipPipPipPip
  • 605 posts
  • Gender:Male

Posted 31 May 2006 - 09:09 AM

GetAuthorData - Returns author information based on sent parameters

// Snippet name: GetAuthorData
// Snippet description: Returns author information based on sent parameters 
// Revision: 1.1 ships with Etomite 0.6.1-Final
// Created By: Ralph A. Dahlgren - rad14701@yahoo.com - Modified 2005-04-17

// Usage: [[GetAuthorData?internalKey=[*createdby*]&field=fullname]]
// internalKey=[*editedby*] will return data about the user who last edited a document
// field can be any column in the user_attributes database table
// field subset: (fullname,email,phone,mobilephone)

if(($internalKey == "") || ($field == "")){
 return "";
} else {
  $sql = "SELECT * FROM ".$etomite->db."user_attributes WHERE internalKey=".$internalKey.";";
  $rs = $etomite->dbQuery($sql);
  $limit = $etomite->recordCount($rs);
  if($limit > 0){
	$author = $etomite->fetchRow($rs);
	$output = $author[$field];
  } else {
	$output = "";
  }
}

return $output;


#16 lloyd_borrett

    Loves Etomite Forums!

  • Member
  • PipPipPipPip
  • 605 posts
  • Gender:Male

Posted 31 May 2006 - 09:10 AM

GetDocContent - Example of extracting document content using API

#  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 "";


#17 lloyd_borrett

    Loves Etomite Forums!

  • Member
  • PipPipPipPip
  • 605 posts
  • Gender:Male

Posted 31 May 2006 - 09:11 AM

GetKeywords - Fetches the keywords attached to the document.

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

    Loves Etomite Forums!

  • Member
  • PipPipPipPip
  • 605 posts
  • Gender:Male

Posted 31 May 2006 - 09:12 AM

GetStats - Fetches the visitor statistics totals from the database

// 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%\">&nbsp;</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 lloyd_borrett

    Loves Etomite Forums!

  • Member
  • PipPipPipPip
  • 605 posts
  • Gender:Male

Posted 31 May 2006 - 09:13 AM

GoogleSiteMap_XML - Output a Google XML site map

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

    Loves Etomite Forums!

  • Member
  • PipPipPipPip
  • 605 posts
  • Gender:Male

Posted 31 May 2006 - 09:14 AM

ListDocuments - Displays document listings based on provided criteria

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

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






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users