setTextTableId (Text_content_Model::TABLE_USERPAGE); } function revealMethods () { parent::revealMethods (); $this->allowMethod( 'getText', 'getVisibleName', 'getHtmlTitle', 'getAlias', 'getIdentityName', 'getMetas', 'getUrl', 'getGlobalText'); } function onAssignRecord () { parent::onAssignRecord(); $record = $this->getRecord(); $this->setVisibleName ($record->list_name); $this->setHtmlTitle ($record->html_name); $this->setAlias ($record->url_name); $this->setIdentityName ($record->name); } function setVisibleName($visible_name) { $this->visible_name = $visible_name; } function getVisibleName() { return $this->visible_name; } function setHtmlTitle($html_title) { $this->html_title = $html_title; } function getHtmlTitle() { $macro = $this->getMacrophage (); $result = $macro->run($this->html_title); return $result; return $this->html_title; } function setAlias($alias) { $this->alias = $alias; } function getAlias() { return $this->alias; } function setIdentityName ($_identity_name) { $this->_identity_name = $_identity_name; } function getIdentityName () { return $this->_identity_name; } function getText ($name) { $text = ORM::factory('text')->byName($name); if ($text->isExist()) { $text_content = ORM::factory('text_content') ->where('table', $this->getTextTableId ()) ->where('table_id', $this->getId()) ->where('text_id', $text->id) ->find(); if ($text_content->isExist() && $text_content->title) { return $this->createText ($text_content); } elseif ($this->hasPrototype ()) { return $this->getPrototype ()->getText ($name); } } return new Theme_Dumb($name); } function getMetas() { $metas = ORM::factory('text_content') ->with('text') ->where('text.type', Text_Model::TYPE_META) ->where('text_contents.content!=', '') ->where('table', $this->getTextTableId ()) ->where('table_id', $this->getId ()) ->find_all() ; $result = array (); $found = array (); foreach ($metas as $meta) { $found [] = $meta->text->name; $metatag = new Theme_Meta (); $metatag->setName ($meta->text->name); $metatag->setContent ($this->getMacrophage ()->run ($meta->content)); $result [] = $metatag->restrict (); } if ($this->hasPrototype ()) { foreach ($this->getPrototype ()->getMetas () as $metatag) { if (! in_array ($metatag->getName (), $found)) { $result [] = $metatag; } } } return $result; } function getGlobalText($name) { $text = ORM::factory('text')->byName($name); if ($text->isExist()) { $text_content = ORM::factory('text_content') ->where('table', Text_content_Model::TABLE_GLOBAL) ->where('text_id', $text->id) ->find(); if ($text_content->isExist ()) { return $this->createText ($text_content); } } return new Theme_Dumb(); } function setUrl($url) { $this->url = $url; } public function getUrl() { if (isset($this->url)) { return $this->url; } elseif (isset($this->alias)) { return url::href('//' . $this->alias); } } function setTextTableId ($_text_table_id) { $this->_text_table_id = $_text_table_id; } function getTextTableId () { return $this->_text_table_id; } private function createText ($text_content) { $text = new Theme_Text (); $text->setTitle ($this->getMacrophage ()->run ($text_content->title)); $text->setContent ($this->getMacrophage ()->run ($text_content->content)); return $text->restrict(); } function setPrototype (Theme_Page $_prototype) { $this->_prototype = $_prototype; } function getPrototype () { return $this->_prototype; } function hasPrototype () { return isset($this->_prototype); } }