'Name', 'url_name' => 'URL Alias', 'html_name' => 'HTML Title', 'visibility' => 'Visibility', 'layout' => 'Layout', 'description' => 'Description', 'position' => 'Position', 'is_blocked' => 'Blocked', ); protected $journal_name = 'Package'; function getTableId() { return Text_content_Model::TABLE_PACKAGE; } function renew ($initial = false) { if ($initial) { $this->visibility = self::STATE_VISIBLE_EVERYWHERE; } else { if (! $this->isExist () ) { $visibility_by_default = Setting_Model::get (Setting_Model::S_INCOMING_PACKAGE_VISIBILITY); if (! is_numeric ($visibility_by_default)) { $visibility_by_default = self::STATE_VISIBLE_EVERYWHERE; } $this->visibility = $visibility_by_default; } } parent::renew (); } public function getSampleTemplatesFromPackage () { $result = array (); $records = ORM::factory ('template') ->where ('templatepackage_id', $this->getId ()) ->orderby ('inserted_date', 'desc') ->limit (9) ->find_all () ; foreach ($records as $record) { $template = new Theme_Template (); $template->setMacrophage (new Theme_Macrophage ()); $template->setRecord ($record); $template->setSmallPreview ($template->getGarantiedScreenshotLocation () . $record->getSmallPreview ()); $item = new stdClass (); $item->id = $template->getId (); $item->preview = $template->getSmallPreview (); $item->type = $template->getType ()->getHtmlTitle ();; $categories = array (); foreach ($record->templatecategories as $category) { $categories[] = $category->name; } $item->category = join ("\n", $categories); $result [] = $item; } return $result; } function compileTemplateRequest ($request) { $request->addWhere ("templatepackage_id = '$this->id'"); $request->addWhere ("disabled = 0"); } function getFirstRecord() { foreach($this->orderby('position')->find_all() as $package) { return $package; } } function getMainTabForm() { return new Form_Admin_TemplatePackage(); } function markAsEdited($id) { $package = $this->where('id', $id)->find(); if ($package->isExist()) { $package->is_edited = 1; $package->save(); } } function setNaturalOrder($sort_by = 'name') { parent::setNaturalOrder($sort_by); } }