HEX
Server: Apache
System: Linux v38079.2is.nl 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64
User: democfellows (10015)
PHP: 8.1.34
Disabled: opcache_get_status
Upload Files
File: /var/www/vhosts/creativefellows.nl/recht.creativefellows.nl/src/Domain/Page/Data/PageData.php
<?php

namespace App\Domain\Page\Data;

use App\Domain\Data;


final class PageData extends Data
{	
	//private $entryData;	
	private $fields = [];	
	protected $base_url = "/";
	protected $active = false;
	protected $default_grid = "default.twig";
	protected $view_folder = "/../../../../templates/";
	protected $form;
	
	function __construct($data =null)
	{
		foreach((array) $data as $key => $val)
		{
			$this->$key = $val;
		}
		
		$this->url_original = $this->url;
	}
	
	public function setBaseUrl($base_url)
	{
		$this->base_url = $base_url;
	}
	
	public function baseUrl()
	{
		return $this->base_url;
	}
	
	public function templateId()
	{
		return $this->template_id;
	}
	
	public function entryId()
	{
		return $this->entry_id;
	}
	
	public function uniqueId()
	{
		return $this->unique_id;
	}
	
	public function getHtml()
	{
		return $this->tekst;
	}
	
	public function getValue($parameter)
	{
		return $this->$parameter;
	}
	
	public function getUrl()
	{
		return $this->url;
	}
	
	public function setEntry($entryData)
	{
		$this->entryData = $entryData;
	}
	
	public function setField($field)
	{
		$this->fields[ $field->name() ] = $field;
	}
	
	public function getProperty(string $property,$html_tag=null,$element_class=null)
	{	
		return $this->fields[$property]->value($html_tag,$element_class);
	}
	
	public function propertyEmpty(string $property)
	{			
		return isset($this->fields[$property]) && $this->fields[$property]->value() ? false : true;
	}
	
	public function hasData()
	{
		return !empty($this->fields) ? true : false;
	}
	
	public function fields()
	{
		return $this->fields;
	}
	
	
	public function setMetaTitle($title)
	{
		$this->meta_title = $title;
	}
	
	public function setMetaDescription($description)
	{
		$this->meta_description = $description;	
	}
	
	
	public function metaTitle()
	{
		return $this->meta_title;// != "" ? $this->meta_title : $this->name ." | #RECHT advocaten";		
	}
		
	public function metaDescription()
	{
		return $this->meta_description;
	}

	public function setRedirect($page_redirect)
	{
		$this->page_redirect = $page_redirect;	
	}	
	
	public function redirect()
	{
		return $this->page_redirect;
	}
	
	
	public function sectionPageClass($prefix=null)
	{
		return $prefix."".$this->cssid;
	}
	
	public function getTemplateName()
	{
		return $this->section_view;
	}
	
	public function setUrl($url)
	{
		$this->url = $url;
	}
	
	public function setName($name)
	{
		$this->name = $name;
	}
	
	public function name()
	{
		return $this->name;
	}
	
	public function title()
	{	
		$property = array_key_first($this->fields);
		return $this->fields[$property]->value();
	}

	public function nameAsUrl()
	{
		return strtolower(preg_replace("/ /","-",$this->name));
	}
	
	public function url()
	{
		return $this->url;	
	}
	
	public function setGrid(string $name)
	{
		$this->section_view = file_exists(__DIR__ . $this->view_folder . $name .".twig") ? $name .".twig" : $this->default_grid;
	}
	
	public function getGrid()
	{
		return $this->stramien;
	}
	
	public function sectionUrl()
	{
		return $this->section_url;
	}
	
	public function urlWithHash()
	{	
		
		return $this->url()."?id=".$this->uniqueId()."&hash=". $this->getHash();//.(!$this->url."&ty");
	}
	
	public function setHashKey($key)
	{
		$this->hash_key = $key;
	}
	
	private function getHash()
	{
		return hash_hmac('sha256', $this->uniqueId(), $this->hashKey());

	}
	
	public function hashKey()
	{
		return $this->hash_key;
	}
	
	public function lastModified()
	{
		return gmdate('D, d M Y H:i:s ', strtotime($this->last_update) ) . 'GMT';
	}
	
	public function dateCreated($format="%e %m %Y")
	{
		return strftime($format,strtotime($this->date_created));
	}
	
	public function urlOriginal()
	{
		return $this->url_original == "" ? $this->titleAsLink() : $this->url_original;
	}
	
	private function titleAsLink(){
		return preg_replace("/ /","-",strtolower($this->title()));
	}
	
	public function setActive(){
		$this->active = true;
	}
	
	public function isActive(){
		return $this->active;
	}
	
	
	public function setForm($form)
	{
		$this->form = $form;
	}
	
	public function form()
	{
		return $this->form;
	}
	
	public function twigData(){
		
		$data = [];
		$data["page_id"] = $this->uniqueId();	
		$data["meta_title"] = $this->metaTitle();
		$data["meta_description"] = $this->metaDescription();
		$data["form"] = $this->form();	
		$data["url"] = $this->url();
		
		foreach($this->fields() as $property => $field)
		{
			$data[$property] = $field->value();
		}
				
		return $data;
		
	}
	
}