allowMethod ( 'getMainPreviewWidth', 'getMainPreviewHeight', 'getSmallPreviewWidth', 'getSmallPreviewHeight', 'getMainPreview', 'getUrl', 'getSmallPreview', 'getBuyUrl', 'getDownloadsCount', 'getRegularPrice', 'getOriginalPrice', 'getExclusivePrice', 'getCurrencySymbol', 'getCustomizeUrl', 'getDescription', 'getShortDescription', 'getSourcesString', 'getSoftwaresString', 'getKeywords', 'getScreenshots', 'getSelectedSubsection', 'getPages', 'getType', 'getPackage', 'getCategories', 'getAuthor' ); } function onAssignRecord () { $record = $this->getRecord (); $this->setId ($record->id); $this->setOriginalPrice ($record->price); if ($record->discounted_price <= 0) { $this->setRegularPrice ($record->price); } else { $this->setRegularPrice ($record->discounted_price); } $this->setExclusivePrice ($record->exc_price); $this->setDownloadsCount ($record->download_count); $this->setScreenshotDownloadStatus ($record->screenshot_download_status); if ($record->large_preview_id) { $large_preview = $this->getScreenshots ($record->large_preview_id); if (isset ($large_preview)) { $this->setMainPreview ($this->getGarantiedScreenshotLocation () . $record->getMainPreview ()); $this->setMainPreviewHeight ($large_preview->getHeight ()); $this->setMainPreviewWidth ($large_preview->getWidth ()); } } if ($record->small_preview_id) { $small_preview = $this->getScreenshots ($record->small_preview_id); if (isset ($small_preview)) { $this->setSmallPreviewHeight ($small_preview->getHeight ()); $this->setSmallPreviewWidth ($small_preview->getWidth ()); } } $macrophage = $this->getMacrophage (); { $params = array ( 'act' => 'add', 'templ' => $record->id, 'pr_code' => Setting_Model::get (Setting_Model::S_AFF_CODE), ); if (Zend_Registry::isRegistered ('affiliate-program')) { $affiliate_program = Zend_Registry::get ('affiliate-program'); if ($affiliate_program->getActive ()) { $params ['referal'] = $affiliate_program->getAffiliateId (); } } $buy_url = 'http://www.templatehelp.com/preset/cart.php?' . http_build_query ($params); $this->setBuyUrl ($buy_url); } $type = new Theme_Link_Catalog_Type (); $type->setMacrophage ($macrophage); $type->setUrlPattern (Setting_Model::get (Setting_Model::S_ROUTE_TYPE_FIRST)); $type->setRecord ($record->templatetype); $this->setType ($type); $categories = $record->templatecategories; if ($categories->count ()) { $category = new Theme_Link_Catalog_Category (); $category->setMacrophage ($macrophage); $category->setUrlPattern (Setting_Model::get (Setting_Model::S_ROUTE_CATEGORY_FIRST)); $category->setRecord ($categories[0]); $this->setCategory ($category); } $package = new Theme_Link_Catalog_Package(); $package->setMacrophage ($macrophage); $package->setUrlPattern (Setting_Model::get (Setting_Model::S_ROUTE_PACKAGE_FIRST)); $package->setRecord ($record->templatepackage); $this->setPackage ($package); $author = new Theme_Property_Author (); $author->setMacrophage ($macrophage); $author->setRecord ($record->templateauthor); $this->setAuthor ($author); $this->setSmallPreview ($this->getGarantiedScreenshotLocation () . $record->getSmallPreview ()); $macrophage ->addMacro ('TEMPLATE-ID', $this->getId ()) ->addMacro ('AUTHOR', $record->templateauthor->name) ->addMacro ('PRICE', $this->getRegularPrice ()) ->addMacro ('ORIGINAL-PRICE', $this->getOriginalPrice ()) ->addMacro ('TYPE', $type->getAlias ()) ->addMacro ('TYPE-NAME', $type->getVisibleName ()) ; if (isset ($category)) { $macrophage->addMacro ('CATEGORY', $category->getVisibleName ()); } } function setMainPreviewWidth ($main_preview_width) { $this->main_preview_width = $main_preview_width; } function getMainPreviewWidth () { return $this->main_preview_width; } function setSmallPreviewWidth ($_small_preview_width) { $this->_small_preview_width = $_small_preview_width; } function getSmallPreviewWidth () { return $this->_small_preview_width; } function setSmallPreviewHeight ($_small_preview_height) { $this->_small_preview_height = $_small_preview_height; } function getSmallPreviewHeight () { return $this->_small_preview_height; } function setMainPreviewHeight ($main_preview_height) { $this->main_preview_height = $main_preview_height; } function getMainPreviewHeight () { return $this->main_preview_height; } function setSmallPreview ($small_preview) { $this->small_preview = $small_preview; } function getSmallPreview () { return $this->small_preview; } function setBuyUrl ($buy_url) { $this->buy_url = $buy_url; } function getBuyUrl () { return $this->buy_url; } function setDownloadsCount ($download_count) { $this->download_count = $download_count; } function getDownloadsCount () { return $this->download_count; } function setRegularPrice ($regular_price) { $this->regular_price = $regular_price; } function getRegularPrice () { return $this->regular_price; } function setOriginalPrice ($original_price) { $this->original_price = $original_price; } function getOriginalPrice () { return $this->original_price; } function setExclusivePrice ($exclusive_price) { $this->exclusive_price = $exclusive_price; } function getExclusivePrice () { return $this->exclusive_price; } function getCurrencySymbol () { return Zend_Registry::get ('Environment')->getCurrencySymbol (); } function setType ($type) { $this->type = $type; } function getType () { return $this->type; } function setPackage ($package) { $this->package = $package; } function getPackage () { return $this->package; } function setAuthor ($author) { $this->author = $author; } function getAuthor () { return $this->author; } function getCustomizeUrl () { $result = sprintf ('http://www.template-help.com/tuning/tuning.php?t_number=%s&aff=%s&pr_code=%s', $this->getId (), Setting_Model::get (Setting_Model::S_AFF_LOGIN), Setting_Model::get (Setting_Model::S_AFF_CODE) ); return $result; } function getDescription () { return $this->getPackage ()->getText('PACKAGE_DESCRIPTION')->getContent();; } function getShortDescription () { return $this->getPackage ()->getText('PACKAGE_SHORT_DESCRIPTION')->getContent();; } function getSourcesString () { return join (', ', $this->getSources ()); } function getSoftwaresString () { return join (', ', $this->getSoftwares ()); } function getPages () { if (!isset ($this->pages)) { $this->pages = new ArrayObject (); foreach ($this->getRecord ()->getSubsections () as $subsection) { $theme_subsection = new Theme_Subsection (); $theme_subsection->setScreenshotLocation ($this->getGarantiedScreenshotLocation ()); $theme_subsection->setRecord ($subsection); $theme_subsection->setMacrophage ($this->getMacrophage ()); $theme_subsection->setTemplateId ($this->getId ()); if ($this->pages->count ()) { $url = Setting_Model::get ('ROUTE_PREVIEW_OTHER'); } else { $url = Setting_Model::get ('ROUTE_PREVIEW_FIRST'); } $url = Setting_Model::get ('ROUTE_PREVIEW_OTHER'); $theme_subsection->setUrl ('/' . $url); $this->pages->append ($theme_subsection); } } return $this->pages; } function getGarantiedScreenshotLocation () { if (Setting_Model::get (Setting_Model::S_SCREENSHOT_LOCAL)) { if (($this->getScreenshotDownloadStatus () == Theme_Template::SCREENSHOT_STATUS_FULLY_DOWNLOADED)) { return Setting_Model::screenshotLocation (Setting_Model::SCREENSHOT_LOCATION_LOCAL); } } $screenshot_remote_url = Setting_Model::get (Setting_Model::S_SCREENSHOT_REMOTE_URL); if ($screenshot_remote_url) { return $screenshot_remote_url; } return Template_Model::SCREENSHOT_DISTRIBUTION; } function getCategories () { $result = array (); foreach ($this->getRecord ()->templatecategories as $category) { if ($category->visibility != TemplateCategory_Model::STATE_DISABLED) { $item = new Theme_Link_Catalog_Category (); $item->setMacrophage (new Theme_Macrophage ()); $item->setUrlPattern (Setting_Model::get (Setting_Model::S_ROUTE_CATEGORY_FIRST)); $item->setRecord ($category); $result [] = $item; } } return $result; } function getKeywords () { return join (' ', $this->getRecord ()->getKeywords ()); } function getSoftwares () { if (!isset ($this->softwares)) { $this->softwares = array (); foreach ($this->getRecord ()->templatesoftwares as $software) { $this->softwares[] = $software->name; } } return $this->softwares; } function getSources () { if (!isset ($this->sources)) { $this->sources = array (); foreach ($this->getRecord ()->templatesources as $source) { $this->sources[] = $source->name; } } return $this->sources; } function getScreenshots ($screenshot_id = null) { if (isset ($screenshot_id)) { $screenshot = ORM::factory ('screenshot', $screenshot_id); if ($screenshot->isExist ()) { $result = new Theme_Preview (); $result->setBaseUrl ($this->getGarantiedScreenshotLocation ()); $result->setMacrophage (new Theme_Macrophage ()); $result->setRecord ($screenshot); return $result; } } else { $result = array (); foreach ($this->getRecord ()->screenshots as $record) { $item = new Theme_Preview (); $result->setBaseUrl ($this->getGarantiedScreenshotLocation ()); $item->setMacrophage (new Theme_Macrophage ()); $item->setRecord ($record); $result [] = $item; } return $result; } } function getUrl () { $url = Setting_Model::get (Setting_Model::S_ROUTE_PREVIEW_FIRST); $url = '//' . $this->getMacrophage ()->run ($url); return url::href ($url); } function setMainPreview ($main_preview) { $this->main_preview = $main_preview; } function getMainPreview () { return $this->main_preview; } function selectSubsection ($subsection_name) { $subsections = $this->getPages (); if ($subsections->count () == 0) { throw new Exception_NotFound (); } foreach ($subsections as $subsection) { if ($subsection->getSeoName () == $subsection_name) { $this->selected_subsection = $subsection; return; } } $this->selected_subsection = $subsections->offsetGet (0); } function getSelectedSubsection () { return $this->selected_subsection; } function setCategory ($category) { $this->category = $category; } function getCategory () { return $this->category; } function setScreenshotDownloadStatus ($screenshot_download_status) { $this->screenshot_download_status = $screenshot_download_status; } function getScreenshotDownloadStatus () { return $this->screenshot_download_status; } }