redirectToProperUrl (); $page = new Theme_Page (); $page->setMacrophage (new Theme_Macrophage ()); $systempage = ORM::factory ('page')->getSystemPage (Page_Model::SYSTEM_PAGE_INDEX)->find (); $page->setRecord ($systempage); $this->view_name = $systempage->getTemplate ('index'); $this->view->global_vars [View_Template::G_HOME] = true; $this->view->page = $page; } function humanReadableUrl () { $id = $this->input->get ('id'); if ($id) { $template = ORM::factory ('template', $id); if ($template->exists ()) { $theme_template = new Theme_Template (); $theme_template->setMacrophage(new Theme_Macrophage()); $theme_template->setRecord ($template); url::newurl ($theme_template->getUrl (), 301); } } url::newurl (url::href ('//')); } function userpage ($alias) { $this->currentLocationIs ('userpage'); $user_page = ORM::factory ('page') ->getUserPages ($alias) ->find () ; if ($user_page->isExist ()) { if (! $user_page->isDisabled ()) { $macrophage = new Theme_Macrophage (); if ($user_page->hasRedirect ()) { $url = $user_page->redirect_to; $url = $macrophage->run ($url); url::newurl ($url, url::HTTP_MOVED_PERMANENTLY); } else { $this->redirectToProperUrl (sprintf ('/%s/', $user_page->url_name)); } $this->view_name = $user_page->getTemplate ('user_page'); $page = new Theme_Page (); $page->setMacrophage ($macrophage); $page->setRecord ($user_page); $this->view->page = $page; $this->view->current_page = $page->getId (); return; } } throw new Exception_NotFound (); } function preview ($id = null, $subsection = null) { $template = ORM::factory ('template', $id); if ($template->isVisible ()) { $macrophage = new Theme_Macrophage (); $theme_template = new Theme_Template (); $theme_template->setMacrophage ($macrophage); $theme_template->setRecord ($template); $theme_template->selectSubsection ($subsection); if (request::is_ajax ()) { $subpage = new View_Frontend ('ajax-subpage'); $subpage->template = $theme_template; $subpage->page_name = ''; echo $subpage->render (); exit; } if (preg_replace ('/[\?#].*/', '', url::href ('//') . Router::$complete_uri) != $theme_template->getUrl ()) { throw new Exception_NotFound (); } $this->redirectToProperUrl (); $preview_page = ORM::factory ('page')->getSystemPage (Page_Model::SYSTEM_PAGE_PREVIEW)->find (); $this->view_name = $preview_page->getTemplate ('preview'); $page = new Theme_Page (); $page->setMacrophage ($macrophage); $page->setRecord ($preview_page); $this->view->page = $page; $this->view->template = $theme_template; if (Setting_Model::get (Setting_Model::S_SCREENSHOT_LOCAL)) { if ($theme_template->getScreenshotDownloadStatus () != Theme_Template::SCREENSHOT_STATUS_FULLY_DOWNLOADED) { $this->downloadTemplateScreenshots ($template->id); } } $this->view->page_name = $theme_template->getSelectedSubsection ()->getVisibleName (); return; } else { $new_url = sprintf ('/search/page1.html?keyword=%u', $id); url::redirect ($new_url, 301); } } private function downloadTemplateScreenshots ($template_id) { $template = ORM::factory ('template', $template_id); $template->screenshot_download_status = Theme_Template::SCREENSHOT_STATUS_QUEUED_FOR_FULL_DOWNLOAD; $template->save (); } function catalog ($cluster_type, $cluster_name, $page = 1) { $page = intval ($page); $matrix = array ( 'categories' => array ('templatecategory', 'Theme_Link_Catalog_Category', Page_Model::SYSTEM_PAGE_CATEGORY, SearchCriterion_Category::PARAM_CATEGORY), 'types' => array ('templatetype', 'Theme_Link_Catalog_Type', Page_Model::SYSTEM_PAGE_TYPE, SearchCriterion_Type::PARAM_TYPE), 'packages' => array ('templatepackage', 'Theme_Link_Catalog_Package', Page_Model::SYSTEM_PAGE_PACKAGE, ''), ); if (in_array ($cluster_type, array_keys ($matrix))) { list ($cluster_table, $cluster_class, $cluster_page_name, $search_param) = $matrix[$cluster_type]; $cluster_page = ORM::factory ('systempage')->getSystemPage ($cluster_page_name)->find (); $cluster = ORM::factory ($cluster_table)->where ('url_name', $cluster_name)->find (); if ($cluster->isExist ()) { if ($cluster->visibility == Cluster_Model::STATE_DISABLED) { throw new Exception_NotFound (); } } $template = $cluster->getTemplate ('catalog'); if ($template == 'catalog') { $template = $cluster_page->getTemplate ('catalog'); } $this->view_name = $template; $request = new Sql_Template (); $cluster->compileTemplateRequest ($request); $templates_count = $cluster->prefetchRecordCount ($request); $limit = COLS * ROWS; $request->setLimit ($limit); $request->setOffset (($page - 1) * $limit); $max_page = ceil ($templates_count/$limit); if ($page > 0) { if ($page <= $max_page) { $this->redirectToProperUrl (); $this->view->global_vars [$cluster_type . '.current.alias'] = $cluster_name; $this->view->global_vars [$cluster_type . '.current.id'] = $cluster->id; $this->view->global_vars [$search_param] = $cluster->id; $macrophage = new Theme_Macrophage (); $templates = $cluster->getTemplatesByRequest ($request); $this->view->templates = $templates ['templates']; $this->view->max_page = $max_page; $this->view->num_page = $page; $theme_catalog = new $cluster_class (); $theme_catalog->setMacrophage ($macrophage); $theme_catalog->setRecord ($cluster); $this->view->catalog = $theme_catalog; $theme_page = new Theme_Page (); $theme_page->setMacrophage ($macrophage); $theme_page->setRecord ($cluster); if ($cluster_type == 'types') { $this->view->curr_type = $cluster_name; $theme_page->setTextTableId (Text_content_Model::TABLE_TYPE); } elseif($cluster_type == 'categories') { $this->view->curr_cat = $cluster_name; $theme_page->setTextTableId (Text_content_Model::TABLE_CATEGORY); } else { $this->view->curr_cat = $cluster_name; $theme_page->setTextTableId (Text_content_Model::TABLE_PACKAGE); } $theme_page->setHtmlTitle ($cluster_page->html_name); $theme_page->getMacrophage ()->addMacro ('TYPE', $theme_catalog->getHtmlTitle ()); $theme_page->getMacrophage ()->addMacro ('CATEGORY', $theme_catalog->getHtmlTitle ()); $theme_page->getMacrophage ()->addMacro ('PACKAGE', $theme_catalog->getHtmlTitle ()); $prototype = new Theme_Page (); $prototype->setMacrophage ($macrophage); $prototype->setRecord ($cluster_page); $theme_page->setPrototype ($prototype); $this->view->page = $theme_page; return; } } } return $this->userpage ($cluster_name); } function search ($page = 1) { $this->currentLocationIs ('search'); $search_id = $this->input->get ('id'); $search_system_page = ORM::factory ('page')->getSystemPage (Page_Model::SYSTEM_PAGE_SEARCH)->find (); $view = new View_Frontend ($search_system_page->getTemplate ('search')); $macrophage = new Theme_Macrophage (); $search = new Search_Interactive_Seo (); $search->setView ($view); $search->setMacrophage ($macrophage); $search->run ($page); $this->view_class_name = 'View_Frontend'; $this->view_name = 'layout'; $theme_page = new Theme_Page (); $theme_page->setMacrophage ($macrophage); $theme_page->setRecord ($search_system_page); $view->theme_page = $theme_page; $this->view->page = $theme_page; $data = array ( 'view' => $view ); Event::run ('frontend.search.view', $data); $this->view->content = $view->render (); } function contacts () { $theme_page = new Theme_Page (); $theme_page->setMacrophage (new Theme_Macrophage ()); $page = ORM::factory ('conventionalpage') ->where ('visibility >', 0) ->where ('name', 'contacts') ->find (); $theme_page->setRecord ($page); $this->view->page = $theme_page; $this->view->current_page = $theme_page->getId (); $required_fields = array ( 'First name' => 'first_name', 'Last name' => 'last_name', 'E-mail address' => 'email', 'Subject' => 'subject', 'Message' => 'message', ); foreach ($required_fields as $required_field => $field) { $this->view->$field = ''; } foreach (array ('website') as $variable) { $this->view->$variable = ''; } $errors = array (); if ($_POST) { $post = $this->input->post (); foreach ($required_fields as $required_field => $field) { unset ($valid_value); if (isset ($post [$field])) { $valid_value = trim ((string) $post [$field]); $this->view->$field = $valid_value; } if (empty ($valid_value)) { $errors [] = $required_field . ' is required.'; } } foreach (array ('website') as $variable) { if (isset ($post [$variable])) { $this->view->$variable = $post [$variable]; } } if (! empty ($post ['email'])) { if (! valid::email ($post ['email'])) { $errors [] = 'You have entered an invalid e-mail'; } } if (! empty ($post ['website'])) { if (! valid::url ($post ['website'])) { $errors [] = 'You have entered an invalid website URL'; } } if (! $errors) { if ('London' == $this->input->post ('city')) { if ('' == $this->input->post ('address')) { $this->send_contact_us_form (); } } url::newurl ('?sent=1'); } } elseif (isset ($_GET ['sent'])) { $this->view->mail_sent = 1; } $this->view->errors = ''; if ($errors) { $this->view->errors = '
There were errors in your submission
'; $logger = new Zend_Log (); $logger->addWriter(new Zend_Log_Writer_Stream ('php://output')); $setup = new Setup_Update(); $setup->logger ($logger); $setup->patchDatabase(); echo ''; } private function send_contact_us_form () { $fields = array ( 'first_name', 'last_name', 'email', 'subject', 'message', 'website', ); foreach ($fields as $field) { $$field = $this->input->post ($field, ''); } $site = url::getSiteRootUrl (); $message = <<
FirstName: {$first_name}
LastName: {$last_name}
Email: {$email}
WebSite: {$website}
Subject: {$subject}
Message: {$message}
message;
$subject = "Form submission form $site : $subject"; $headers = <<