title; } private $htmlTitle = null; protected function setTitle( string $title) { $this->title = $title; $this->htmlTitle->clear(); $this->htmlTitle->add( $this->getTitle() ); } private $htmlMetaViewPort = null; public function getHtmlMetaViewPort() : HtmlMeta { return $this->htmlMetaViewPort; } private $htmlMetaHttoEquiv = null; private $htmlMetaCharset = null; protected $globalMeta = array( 'robots' => 'index, follow' ,'geo.region' => "FR" // ,'geo.placename' => "Le Controis-en-Sologne, Loir-et-Cher" // ,'geo.position' => "47.420083230613315;1.429889413492917" // ,'ICBM' => "47.420083230613315, 1.429889413492917" ); protected $dwApplicationShortcut = null; protected $pageRootFolder = "file://bakuba/content"; public function __construct( string $title = "Page" ) { $myClassName = $this->getClassName(); $sectionName = \darkphp\source\DwSource::classNameToSectionName( $myClassName ); $topSection = \darkphp\source\DwSource::classNameToTopName( $sectionName ); if ( $topSection == "page" ) $sectionName = \darkphp\source\DwSource::classNameToSectionName( $sectionName ); $this->pageRootFolder="file://".\darkphp\source\DwSource::classNameToFolder( $sectionName ); parent::__construct( "html" ); $this->domHead = new Html( "head" ); $this->htmlMetaHttoEquiv = new HtmlMeta ( array( "http-equiv" => "x-ua-compatible" ,"content" => "IE=edge" ) ); $this->htmlMetaCharset = new HtmlMeta ( array( "charset" => $this->charset ) ); $this->htmlMetaViewPort = $this->setHeadMeta( "viewport" ,"width=device-width, initial-scale=1" ); $this->htmlTitle = new Html( 'title' ); $this->htmlTitle->noIndent(); $this->setTitle( $title ); $this->domBody = new Html( "body" ); //$this->domBody->noIndent(); foreach( $this->globalMeta as $metaName => $metaContent ) $this->setHeadMeta( $metaName ,$metaContent ); } protected static $defaultStaticPagesData = array( array( "uri" => "/mentions-legales" ,"content" => "mentions-legales/contrat.html" ,"title" => "Mentions Légales" ) ,array( "uri" => "/charte" ,"content" => "charte/contrat.html" ,"title" => "Charte RGPD" ) // ,array( "uri" => "/contact" ,"content" => "contact/contrat.html" ,"title" => "Contact" ) ); protected $staticPagesData = null; protected function loadStaticPagesData() { $this->staticPagesData = self::$defaultStaticPagesData; } public function errorPage( string $dataError ) : void { $this->addLog( __METHOD__ ); $this->littleClear(); $this->setTitle( "Error Page" );//d1rKM3b.fr $this->add( "
{$dataError}
" ); } public function loadPage( array $staticPageData ) : void { $this->addLog( __METHOD__ ); if ( isset( $staticPageData[ "meta" ] ) ) { foreach( $staticPageData[ "meta" ] as $metaName => $metaContent ) $this->setHeadMeta( $metaName ,$metaContent ); } $this->littleClear(); $this->setTitle( $staticPageData["title"] );//d1rKM3b.fr $this->add( $this->getFile( $staticPageData["content"] ) ); } public function littleClear() : void { $this->domBody->clear(); } public function clear( ) : void { parent::clear(); $this->setParam( "lang" ,"fr-FR" ); $this->initHeader(); $this->initBody(); } public function initHeader() : void { $this->domHead->clear(); parent::add( $this->domHead ); $this->addToHead( $this->htmlMetaCharset ); $this->addToHead( $this->htmlMetaHttoEquiv ); $this->addToHead( $this->htmlTitle ); foreach( $this->headMeta as $name => $htmlMeta ) $this->addToHead( $htmlMeta ); } private $headMeta = array(); protected function setHeadMeta( string $name, string $content ) : HtmlMeta { if ( isset( $this->headMeta[ $name ] ) ) $this->headMeta[ $name ]->setParam( 'content' ,$content ); else $this->headMeta[ $name ] = new HtmlMeta( array( 'name' => $name, 'content' => $content ) ); return $this->headMeta[ $name ]; } public function addToHead( $html ) : void { $this->domHead->add( $html ); } public function initBody() : void { $this->domBody->clear(); parent::add( $this->domBody ); } public function paramsBody( array $paramsBody ) : void { $this->domBody->setParams( $paramsBody ); } public function addToBody( $html ) : void { $this->domBody->add( $html ); } public function add( $content ) : void { $this->addToBody( $content ); } private $docType = ""; public function setDocType( string $docType ) : void { $this->docType = $docType; } public function __toString() : string { return $this->docType."\r\n".parent::toString(); } // $page->parse( $tmplFile, $keys, $values ); /* public function parse( string $filePath ,array $keys = null ,array $values = null ) : ?string { return \darkphp\template\Template::parse( $this->getFile( $filePath ) ,$keys ,$values ); } */ private function autoLoadGetFile( string $filePath ) : ?string { //echo $this->getClassName()."::getFile( {$this->pageRootFolder}/{$filePath} )".\PHP_EOL; return \darkphp\autoload\DwAutoLoad::getFile( "{$this->pageRootFolder}/{$filePath}" ); } public function getFile( string $filePath ) : ?string { return $this->autoLoadGetFile( "content/{$filePath}" ); } public function getClassName( bool $fqcn=null ) : string { return self::getStaticClassName( $fqcn ); } public static function getStaticClassName( bool $fqcn=null ) : string { return $fqcn ? parent::getStaticClassName( $fqcn ).self::CLASS_SEPARATOR.__CLASS__ : __CLASS__; } } ?>