protected function build_form()
 {
     $this->add_field('include_categories', 'Generate individual category pages', 'full', db_varchar)->tab('Categories')->renderAs(frm_checkbox);
     $this->add_field('include_hidden_categories', 'Include hidden categories', 'full', db_varchar)->tab('Categories')->renderAs(frm_checkbox);
     $this->add_field('categories_path', 'Category Root Path', 'full', db_varchar)->tab('Categories');
     $this->add_field('categories_changefreq', 'Category changefreq', 'full', db_varchar)->tab('Categories')->renderAs(frm_dropdown);
     $this->add_field('categories_priority', 'Category priority', 'full', db_varchar)->tab('Categories')->validation('The category priority field should contain a number between 0 and 1')->method('priority_validation');
     $this->add_field('include_products', 'Generate individual product pages', 'full', db_varchar)->tab('Products')->renderAs(frm_checkbox);
     $this->add_field('include_products_not_visible_search', 'Include products not visible in search results?', 'full', db_varchar)->tab('Products')->renderAs(frm_checkbox);
     $this->add_field('include_products_not_visible_catalog', 'Include products not visible in the catalog?', 'full', db_varchar)->tab('Products')->renderAs(frm_checkbox);
     $this->add_field('products_path', 'Product Root Path', 'full', db_varchar)->tab('Products');
     $this->add_field('products_changefreq', 'Product changefreq', 'full', db_varchar)->tab('Products')->renderAs(frm_dropdown);
     $this->add_field('products_priority', 'Product priority', 'full', db_varchar)->tab('Products')->validation('The products priority field should contain a number between 0 and 1')->method('priority_validation');
     $this->add_field('include_blogposts', 'Generate individual blog post pages', 'full', db_varchar)->tab('Blog Posts')->renderAs(frm_checkbox);
     $this->add_field('blogposts_path', 'Blog posts Root Path', 'full', db_varchar)->tab('Blog Posts');
     $this->add_field('blogposts_changefreq', 'Blog posts changefreq', 'full', db_varchar)->tab('Blog Posts')->renderAs(frm_dropdown);
     $this->add_field('blogposts_priority', 'Blog posts priority', 'full', db_varchar)->tab('Blog Posts')->validation('The blog posts priority field should contain a number between 0 and 1')->method('priority_validation');
     $wiki_installed = Core_ModuleManager::findById('wiki');
     if ($wiki_installed) {
         $this->add_field('include_wiki', 'Generate individual wiki pages', 'full', db_varchar)->tab('Wiki Pages')->renderAs(frm_checkbox);
         $this->add_field('wiki_path', 'Wiki pages Root Path', 'full', db_varchar)->tab('Wiki Pages');
         $this->add_field('wiki_changefreq', 'Wiki pages changefreq', 'full', db_varchar)->tab('Wiki Pages')->renderAs(frm_dropdown);
         $this->add_field('wiki_priority', 'Blog posts priority', 'full', db_varchar)->tab('Wiki Pages')->validation('The wiki pages priority field should contain a number between 0 and 1')->method('priority_validation');
     }
     if (Cms_Theme::is_theming_enabled()) {
         $this->add_form_section('Please note that the generated sitemap will include only the CMS pages belonging to the active theme.')->tab('CMS Pages');
     }
     $this->add_field('include_navigation_hidden', 'Include pages not visible in navigation ', 'full', db_varchar)->tab('CMS Pages')->comment('Select to include pages that are not included in automatically generated navigation menus.')->renderAs(frm_checkbox);
     $this->add_form_custom_area('pages')->tab('CMS Pages');
     Backend::$events->fireEvent('sitemap:onExtendSitemapParamsModel', $this);
 }
 public function index()
 {
     try {
         $params = new Sitemap_Params();
         $this->viewData['form_model'] = $params->load();
         $this->viewData['pages'] = Cms_Page::create()->order('theme_id asc')->order('navigation_sort_order asc')->find_all();
         $this->viewData['theming_enabled'] = Cms_Theme::is_theming_enabled();
     } catch (exception $ex) {
         $this->_controller->handlePageError($ex);
     }
 }
 public function get_product_url($product_id, $default = null)
 {
     if (Cms_Theme::is_theming_enabled() && ($active_theme = Cms_Theme::get_active_theme())) {
         $page = Db_DbHelper::scalar("select url from pages inner join cms_page_references cpr on (pages.id = cpr.page_id)\n\t\t\t\t\twhere cpr.object_id=:product_id\n\t\t\t\t\tand object_class_name = 'Shop_Product'\n\t\t\t\t\tand reference_name = 'page_id'\n\t\t\t\t\tand page_id in (select id from pages where theme_id = :theme_id)", array('product_id' => $product_id, 'theme_id' => $active_theme->id));
         return $page;
     } else {
         return $default;
     }
 }