File: D:/HostingSpaces/SBogers10/tops.komma.pro/wwwroot/app/models/m_basic_page.class.php
<?php
/**
* m_basic_page.class.php
* Created by Komma Mediadesign.
* Author: mike
* Date: 13/02/14
*/
class Basic_Page_Model extends Model
{
/*
* Translator Object
*/
private $_Translator;
public function __construct()
{
parent::__construct();
// Translator
$this->_Translator = new Translator(URL_LANG);
}
/*
* Get page title
*/
public function getPageTitle()
{
// Url to convert
$stringUrl = substr($_SERVER['REQUEST_URI'],1);
$urls = explode('/', $stringUrl);
$arr = '';
// Loop through url and translate
foreach($urls as $key => $url)
{
if( ! empty($url) && $key != 0)
{
// Get key
$urlKey = $this->_Translator->getPageKey($url);
if(isset($this->lang[$urlKey]))
{
// In language array?
$arr[] = ucwords($this->lang[$urlKey]);
}
else
{
// Default: capitalize url-part
$title = str_replace('-',' ',$url);
$arr[] = ucwords($title);
}
}
}
// Reverse array for page title
$arr = array_reverse($arr);
// Generate title
$title = '';
foreach($arr as $word)
{
$title .= $word . ' | ';
}
$title .= SITE_NAME;
return $title;
}
/*
* Get breadcrump
*/
public function getBreadcrumb()
{
// Url to convert
$stringUrl = substr($_SERVER['REQUEST_URI'],1);
$urls = explode('/', $stringUrl);
$Breadcrumb = new Breadcrumb();
$bcUrl = LANG_ROOT;
// Loop through url and translate
foreach($urls as $key => $url)
{
if( ! empty($url) && $key != 0)
{
// Get key
$urlKey = $this->_Translator->getPageKey($url);
if($key > 1) $bcUrl .= '/';
$bcUrl .= $url;
if(isset($this->lang[$urlKey]))
{
// In language array?
$bcTitle = ucwords($this->lang[$urlKey]) . ' ';
}
else
{
// Default: capitalize url-part
$bcTitle = str_replace('-',' ',$url);
$bcTitle = ucwords($bcTitle) . ' ';
}
$Breadcrumb->add($bcUrl, $bcTitle);
}
}
return $Breadcrumb->get();
}
}