File: /var/www/vhosts/creativefellows.nl/dhwd.creativefellows.nl/src/BaseController.php
<?php
class BaseController
{
public $settings;
public function getBaseUrl()
{
return $this->settings["base_url"];
}
public function saveImages()
{
return $this->settings["save_images"];
}
public function getLocale()
{
return $this->settings["locale"];
}
public function getSearchPlaceholder()
{
return $this->settings["search_placeholder"];
}
public function getNoResultsheader($search)
{
return sprintf($this->settings["search_no_result"], $search);
}
public function getLinkBase()
{
return $this->settings["language_base"];
}
public function getCompanyLogo()
{
return $this->settings["logo"];
}
public function getSearchHeader()
{
return $this->settings["search_header"];
}
public function getFooterCopy()
{
return $this->settings["footer_copy"];
}
public function getSiteRegion()
{
return $this->settings["region"];
}
public function is_odd($number)
{
return $number & 1;
}
public function is_last($array,$i)
{
$array_keys = array_keys($array);
$last_key = end($array_keys);
return $last_key == $i ? true : false;
}
/*
* Check languages
function checkLanguage()
{
$language = (isset($_REQUEST["lang"])) ? $_REQUEST["lang"] : "nl";
if(file_exists(ROOT_DIR."languages/config.". $language .".php")) include_once ROOT_DIR."languages/config.". $language .".php";
}*/
/*
* Check directories for thumbs
*/
function checkDirectories()
{
if(file_exists(IMAGE_DIR) == false){
mkdir("content", 0777, true);
chmod("content", 0777);
mkdir("content/th/", 0777, true);
chmod("content/th/", 0777);
}
}
/*
* Wrap a section as a HTML5 wrapper
*/
function wrapAsSection($html,$id=null,$class=null,$style=null)
{
return preg_replace(array("/{section_htmlwrapper}/","/{element-id}/","/{style}/","/{element-class}/"),array($html,$id,$style,$class),$this->settings["group_wrapper"]);
}
/*
* check allow cookies
*/
function getCookieNote()
{
$html = "";
if(!isset($_COOKIE[$this->company_short."_allow_cookies"]))
{
$html .= '<section class="cookies" id="cookies">';
$html .= '<p>'. $this->cookie_text .'<a id="acceptCookie" href="#" class="button primary">Accepteren</a> <a id="moreCookie" href="'. $this->cookie_link .'" class="button secondary">Meer informatie</a></p>';
$html .= '</section>';
}
return $html;
}
/*
* validate link
*/
function vl($url){
return preg_replace("/[-]+/","-",preg_replace("/[^0-9a-zA-Z-#]/",'-', trim($url)));
}
function dp($post)
{
return preg_replace("/-/"," ",strtolower($post));
}
function dp_cap($post)
{
return ucfirst(preg_replace("/-/"," ",strtolower($post)));
}
/*
* Make intro bases on input
*/
function makeIntro($text,$length=null,$addParagraphtags=null,$sign=null){
$text = preg_replace('/<(h1|h2|h3|h4)[^>]*>([\s\S]*?)<\/(h1|h2|h3|h4)[^>]*>/', '', $text);
$sign = ($sign == null) ? " [..]" : $sign;
$textlen = strlen(strip_tags($text));
if($textlen < $length && $length!=null) $return = strip_tags($text);
else{
$cropAfter = ($length != null) ? $length : 115;
$intro = substr(strip_tags($text), 0, $cropAfter);
$ls = strrpos($intro, " ");
$return = substr($intro, 0, $ls).$sign;
}
$return = ($addParagraphtags == null) ? $return : "<p>".$return."</p>";
return $return;
}
/*
* Safe html output for form data etc
*/
function outputSafe($string){
return htmlspecialchars($string, ENT_QUOTES, 'UTF-8');
}
/*
* get inline svg
*/
function getSVG($type){
switch($type){
case "close":
return '<svg version="1.1" id="Laag_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"viewBox="0 0 24 24" style="enable-background:new 0 0 24 24;" xml:space="preserve">
<path d="M14.1,12l6.4-6.4c0.6-0.6,0.6-1.5,0-2.1c-0.6-0.6-1.5-0.6-2.1,0L12,9.9L5.6,3.4C5,2.9,4,2.9,3.4,3.4
C2.9,4,2.9,5,3.4,5.6L9.9,12l-6.4,6.4c-0.6,0.6-0.6,1.5,0,2.1c0.6,0.6,1.5,0.6,2.1,0l6.4-6.4l6.4,6.4c0.6,0.6,1.5,0.6,2.1,0
c0.6-0.6,0.6-1.5,0-2.1L14.1,12z M14.1,12"/>
</svg>';
break;
case "search":
return '<svg version="1.1" id="Laag_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 24 24" style="enable-background:new 0 0 24 24;" xml:space="preserve">
<path d="M10.6,5.8c1.3,0,2.5,0.5,3.4,1.4c0.9,0.9,1.4,2.1,1.4,3.4c0,1.3-0.5,2.5-1.4,3.4c-0.9,0.9-2.1,1.4-3.4,1.4
c-1.3,0-2.5-0.5-3.4-1.4c-0.9-0.9-1.4-2.1-1.4-3.4c0-1.3,0.5-2.5,1.4-3.4C8.1,6.2,9.3,5.8,10.6,5.8 M5.2,16c0.7,0.7,1.5,1.2,2.4,1.6
c0.9,0.4,1.9,0.6,3,0.6c1.6,0,3-0.4,4.3-1.3l3.7,3.7c0.3,0.3,0.6,0.4,1,0.4c0.4,0,0.7-0.1,1-0.4c0.3-0.3,0.4-0.6,0.4-1
c0-0.4-0.1-0.7-0.4-1l-3.7-3.7c0.9-1.3,1.3-2.7,1.3-4.3c0-1-0.2-2-0.6-3c-0.4-0.9-0.9-1.8-1.6-2.4S14.5,4,13.6,3.6
c-0.9-0.4-1.9-0.6-3-0.6c-1,0-2,0.2-3,0.6C6.7,4,5.9,4.5,5.2,5.2S4,6.7,3.6,7.7C3.2,8.6,3,9.6,3,10.6c0,1,0.2,2,0.6,3
C4,14.5,4.5,15.3,5.2,16"/>
</svg>';
break;
case "creativefellows":
return '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 300 25"><defs><style>.cls-1{fill:#fff;}</style></defs><title>Tekengebied 1</title><path class="cls-1" d="M298.6,16.69a6.52,6.52,0,0,0-1.84-5,7.71,7.71,0,0,0-4.44-1.84l-2.71-.43a5.37,5.37,0,0,1-2.17-.87,2,2,0,0,1-.65-1.63C286.79,5.31,288,4,290.37,4a6.43,6.43,0,0,1,4.77,1.63l2.93-2.82A9.85,9.85,0,0,0,290.47.11c-5.09,0-8.13,2.93-8.13,7.15A6.21,6.21,0,0,0,284,11.81a8.17,8.17,0,0,0,4.66,2l2.82.43a3,3,0,0,1,2.06.87,2.61,2.61,0,0,1,.76,2c0,1.84-1.41,2.93-4.12,2.93a7.66,7.66,0,0,1-5.63-2l-2.93,2.93c2.28,2.38,5,3,8.56,3,4.66-.22,8.45-2.71,8.45-7.26M280.51.22h-4.77L272.06,15,267.72.22h-3.47L259.92,15,256.45.22h-4.77L258,23.62h3.79L266.1,9.43l4.33,14.19h3.79Zm-35.21,11.7c0,4.55-.22,5.63-1.19,6.61a3.94,3.94,0,0,1-5.85,0c-.87-1-1.08-2.06-1.08-6.61s.22-5.63,1.08-6.61a3.94,3.94,0,0,1,5.85,0c1,1,1.19,2.06,1.19,6.61m4.66,0c0-4,0-6.93-2.28-9.32A9,9,0,0,0,235,2.6c-2.38,2.38-2.28,5.31-2.28,9.32s-.11,6.93,2.28,9.32a9,9,0,0,0,12.68,0C250,18.85,250,15.93,250,11.92m-19.39,11.7V19.5H219.94V.22h-4.55v23.4Zm-19,0V19.5H201V.22h-4.55v23.4Zm-19.61,0V19.5H181.15V13.76h9.21V9.64h-9.21V4.12H192V.22H176.6v23.4ZM172.49,4.23v-4H157.1v23.4h4.55V14.08h9.21V10h-9.21V4.23ZM145,23.62V19.5H134.13V13.76h9.21V9.64h-9.21V4.12H145V.22H129.58v23.4ZM126.76.22H122l-4.77,15.17L112.57.11H107.8l7.69,23.4H119ZM105,.22h-4.55v23.4H105Zm-8.34,4v-4H79.85V4.33H86V23.73h4.55V4.23ZM73.35,15.6H67.5L70.43,7Zm7.37,8L72.16.22H68.58L60,23.62h4.77L66.2,19.5h8.34L76,23.62Zm-22.64,0V19.5H47.24V13.76h9.21V9.64H47.13V4.12H58V.22H42.69v23.4ZM33.37,7.37a3.12,3.12,0,0,1-3,3.14H25.68V4.33H30a3.13,3.13,0,0,1,3.36,2.82v.22M38.9,23.62,33.7,13.54a6.22,6.22,0,0,0,4.23-6.18c0-3.9-2.82-7.15-7.58-7.15H21.13v23.4h4.55V14.3h3.25l4.55,9.32ZM17.23,16.36H12.57a4,4,0,0,1-3.9,3.36,4.19,4.19,0,0,1-2.93-1.19c-.87-1-1.19-2.06-1.19-6.61s.22-5.63,1.19-6.61A3.43,3.43,0,0,1,8.67,4.12a4,4,0,0,1,3.9,3.36h4.66A8.17,8.17,0,0,0,8.56.11a8.5,8.5,0,0,0-6.28,2.6C-.11,5.09,0,8,0,12S-.11,19,2.28,21.34a8.5,8.5,0,0,0,6.28,2.6,8.5,8.5,0,0,0,8.67-7.58"/></svg>';
break;
}
}
/*
* get column width based on count
*/
function colWidth($count)
{
switch($count){
default:
case 4:
$col_width = "col6";
break;
case 1:
$col_width = "col24";
break;
case 2:
$col_width = "col12";
break;
case 3:
$col_width = "col8";
break;
case 5:
$col_width = "col4-5";
break;
case 6:
$col_width = "col4";
break;
}
return $col_width;
}
/*
* count number of items in array
*/
function countArrayDimension($navigation_array,$dimension,$value=0){
$count = 0;
foreach ($navigation_array as $section){
$section[$dimension] == $value ? $count++ : 0;
}
return $count;
}
}
?>