|
Server : Apache/2.4.62 System : FreeBSD fbsdweb2.web.rcn.net 14.1-RELEASE FreeBSD 14.1-RELEASE releng/14.1-n267679-10e31f0946d8 GENERIC amd64 User : www ( 80) PHP Version : 8.3.8 Disable Function : NONE Directory : /domains/highlandlabs/cqi-bin/ALFA_DATA/alfasymlink/root/domains/insite/ |
Upload File : |
<?php
/**
* Drum automatically generates tags TITLE, KEYWORDS and DESCRIPTION for each
* page. This should be used with header3 . php or a similar script of your making.
*
* @version 3
* @author Mark Valentine
* @author Kekoa Vincent
*/
class Drum {
/**
* The title of the page
*
* @var string
*/
private static $title;
/**
* The name of the company
*
* @var string
*/
private static $companyName;
/**
* The location of the company
*
* @var string
*/
private static $location;
/**
* The industry of the company
*
* @var string
*/
private static $industry;
/**
* The services provided by the company
*
* @var string
*/
private static $services;
/**
* The default title that will appear if no title is set. Useful for a site-
* wide default.
*
* @var string
*/
private static $defaultTitle;
/**
* Text that will appear at the beginning of the title
*
* @var string
*/
private static $titleTail;
/**
* Text that will appear at the end of the title
*
* @var string
*/
private static $titleHead;
/**
* Sets an attribute for drum to a value
*
* @param string $attrName The name of the attribute
* @param string $attrValue The new value of the attribute
*/
public static function SetAttribute($attrName, $attrValue) {
// echo "$attrName set";
self::${$attrName} = $attrValue;
}
/**
* Sets the default title to be used if no title is set.
*
* @param string $defaultTitle
*/
public static function SetDefaultTitle($defaultTitle) {
self::SetAttribute('defaultTitle', $defaultTitle);
}
/**
* Sets the title
*
* @param string $title
*/
public static function SetTitle($title) {
self::SetAttribute('title', $title);
}
/**
* Sets the title head which will appear at the beginning of the generated
* title.
*
* @param string $title
*/
public static function SetTitleHead($titleHead) {
self::SetAttribute('titleHead', $titleHead);
}
/**
* Sets the title tail which will appear at the end of the generated title
*
* @param string $title
*/
public static function SetTitleTail($titleTail) {
self::SetAttribute('titleTail', $titleTail);
}
/**
* Sets the location using an array or a comma-separated list
*
* @param array|string $location
*/
public static function SetLocation($location) {
self::SetAttribute('location', self::MakeArray($location));
}
/**
* Sets the indstry
*
* @param string $industry
*/
public static function SetIndustry($industry) {
self::SetAttribute('industry', $industry);
}
/**
* Sets the name of the company
*
* @param string $companyName
*/
public static function SetCompanyName($companyName) {
self::SetAttribute('companyName', $companyName);
}
/**
* Sets the services
*
* @param array $services
*/
public static function SetServices($services) {
self::SetAttribute('services', self::MakeArray($services));
}
/**
* If the input is an array, it is passed through, if not, an array is created
* assuming the input is a comma-separated list of values.
*
* @param mixed $inputValue
* @return array
*/
private static function MakeArray($inputValue) {
if(is_array($inputValue)) {
$newValue =& $inputValue;
} else {
$newValue = explode(",", $inputValue);
foreach($newValue as $key => $value) {
$newValue[$key] = trim($value);
}
}
return $newValue;
}
/**
* Turns the input into a string... mainly converts array to string format,
* separated by commas
*
* @param mixed $inputValue
* @return string
*/
private static function MakeString($inputValue) {
if(is_string($inputValue)) {
$newValue =& $inputValue;
} else if(is_array($inputValue)) {
$newValue = implode(", ", $inputValue);
}
return $newValue;
}
/**
* Generates and outputs the title
*
*/
public static function PrintTitle()
{
echo self::GetTitle();
}
/**
* Generates the title. If the title is specifically set, it will display
* that title, otherwise it will use the default, or if none is set, it will
* output the name:industry
*
* @return string
*/
public static function GetTitle() {
if(self::$title != "") {
$output = self::$title;
} else if(self::$defaultTitle != "") {
$output = self::$defaultTitle;
} else {
$output = self::$companyName . ": " . self::MakeString(self::$industry);
}
return self::$titleHead . $output . self::$titleTail;
}
/**
* Generates and outputs the meta keywords
*
*/
function PrintKeywords() {
echo self::GetKeywords();
}
/**
* Generates the keywords based on variables given
*
* @return string
*/
public static function GetKeywords() {
$keywords = "";
for($locItr=0; $locItr<count(self::$location); $locItr++)
{
for($servItr=0; $servItr<count(self::$services); $servItr++)
{
$keywords .= self::$location[$locItr] . " " . self::$services[$servItr] . ", ";
}
}
$keywords .= self::$industry;
return $keywords;
}
/**
* Generates and outputs meta description
*
*/
public static function PrintDescription()
{
echo self::GetDescription();
}
/**
* Generates the meta description from variables given
*
* @return string
*/
public static function GetDescription() {
$description = self::$companyName . ": ";
$description .= self::$industry . " ";
$description .= "providing ";
$servItr=0;
for($servItr; $servItr<count(self::$services)-1; $servItr++)
{
$description .= self::$services[$servItr] . ", ";
}
$description .= "and " . self::$services[$servItr];
$description .= " to ";
$locItr = 0;
for($locItr; $locItr<count(self::$location)-1; $locItr++)
{
$description .= self::$location[$locItr] . ", ";
}
$description .= "and " . self::$location[$locItr];
return $description;
}
}
?>