<?php
/*
	Stempora Web Framework
	Copyright (c) 2002-2014 Stempora. 
	All rights reserved.
		web:  www.stempora.com
		mail: support@stempora.com		
*/

// dependencies

/**
* description
*
* @library	
* @author	
* @since	
*/
class CSeo extends CPlugin{
	
	var $tplvars; 

	function CSeo() {
		//$this->CPlugin($db, $tables , $templates);
	}

	function DoEvents(){
		global $base, $_CONF, $_TSM , $_VARS , $_USER , $_BASE , $_SESS;

		parent::DoEvents();
	}



	/**
	* description
	*
	* @param
	*
	* @return
	*
	* @access
	*/
	function PageMeta($item , $remove_key = "" , $force = false) {
		global $_TSM;

		if ($remove_key) {

			foreach ($item as $key => $val) {
				if (stristr($key , $remove_key)) {
					$_item[str_replace($remove_key , "" , $key)] = $val;
				}				
			}
			
			$item = $_item;
		}

		if ( ($item["seo_title"] && !$_TSM["PUB:SEO_TITLE"]) || $force);
			$_TSM["PUB:SEO_TITLE"] = $item["seo_title"];

		if (($item["seo_desc"] && !$_TSM["PUB:SEO_DESC"])  || $force);
			$_TSM["PUB:SEO_DESC"] = $item["seo_desc"];
		
		if ($item["seo_conv_head"] && !$_TSM["PUB:SEO_CONV_HEAD"])
			$_TSM["PUB:SEO_CONV_HEAD"] .= $item["seo_conv_head"];
	

		if ($item["seo_meta"] && !$_TSM["PUB:SEO_META"]) {
			$_TSM["PUB:SEO_CONV_HEAD"] .= "<meta name=\"robots\" content=\"{$item[seo_meta]}\">";
		}


		if ($item["seo_conv_body"])
			$_TSM["PUB:SEO_CONV_BODY"] .= $item["seo_conv_body"];


		if ($item["canonical"]) {
			$this->Canonical($item["canonical"]);
		}
		
		if ($item["next_page"]) {
			$this->NextPage($item["next_page"]);
		}

		if ($item["prev_page"]) {
			$this->NextPage($item["prev_page"]);
		}

	}

	/**
	* description
	*
	* @param
	*
	* @return
	*
	* @access
	*/
	function AppedToHead($info) {
		$this->AppendToHead($info);
	}
	
	/**
	* description
	*
	* @param
	*
	* @return
	*
	* @access
	*/
	function AppendToHead($info) {
		global $_TSM;

		$_TSM["PUB:SEO_CONV_HEAD"] .= $info;

	}
	
	/**
	* description
	*
	* @param
	*
	* @return
	*
	* @access
	*/
	function AppedToBody($info) {
		$this->AppendToBody($info);
	}

	function PrependToBody($info) {
		global $_TSM;

		$_TSM["PUB:SEO_CONV_BODYHEAD"] .= $info;

	}
	
	function AppendToBody($info) {
		global $_TSM;

		$_TSM["PUB:SEO_CONV_BODY"] .= $info;

	}
	
	/**
	* description
	*
	* @param
	*
	* @return
	*
	* @access
	*/
	function NextPage($link) {
		global $_TSM;
		$_TSM["PUB:SEO_CONV_HEAD"] .= '<link rel="next" href="' . $link . '" />';
	}
	
	/**
	* description
	*
	* @param
	*
	* @return
	*
	* @access
	*/
	function PrevPage($link) {
		global $_TSM;
		$_TSM["PUB:SEO_CONV_HEAD"] .= '<link rel="prev" href="' . $link . '" />';
	}

	/**
	* description
	*
	* @param
	*
	* @return
	*
	* @access
	*/
	function Canonical($link) {
		global $_TSM;
		$_TSM["PUB:SEO_CONV_HEAD"] .= '<link rel="canonical" href="' . $link . '" />';
	}
		
}

?>