'Name', ); const TYPE_META = 1; const TYPE_LOCAL = 2; const TYPE_GLOBAL = 3; function byName ($name) { return $this->where ('name', $name)->find (); } function getMetaTags () { return $this->getByType (self::TYPE_META); } function getLocalTexts () { return $this->getByType (self::TYPE_LOCAL); } function getGlobalTexts () { return $this->getByType (self::TYPE_GLOBAL); } function getByType ($type) { return $this->where ('type', $type)->orderby ('name')->find_all (); } function getFormName () { return 'text_' . $this->id; } function delete ($id = NULL) { $this->deleteHasMany (); parent::delete ($id); } function getGlobalContent () { $global = ORM::factory ('text_content') ->where ('table', Text_content_Model::TABLE_GLOBAL) ->where ('text_id', $this->id) ->find () ; return $global; } function getJournalName () { $result = parent::getJournalName (); switch ($this->type) { case self::TYPE_META: $result = 'Meta ' . $result; break; case self::TYPE_LOCAL: $result = 'Local ' . $result; break; case self::TYPE_GLOBAL: $result = 'Global ' . $result; break; } return $result; } }