/** Set up an individual's details * @access public * @return void */ public function rulerAction() { if ($this->getParam('id', false)) { $id = (int) $this->getParam('id'); $this->view->id = $id; $this->view->rulers = $this->_rulers->getIronAgeRuler($id); $regions = new Geography(); $this->view->regions = $regions->getIronAgeRegionToRuler($id); } else { throw new Pas_Exception_Param($this->_missingParameter, 500); } }
/** An individual denomination's entry details * @access public * @return void * @throws Pas_Exception_Param */ public function denominationAction() { if ($this->getParam('id', false)) { $id = $this->getParam('id'); $this->view->id = $id; $this->view->denoms = $this->_denominations->getDenom($id, $this->_period); $regions = new Geography(); $this->view->regions = $regions->getIronAgeDenomGeog($id); } else { throw new Pas_Exception_Param($this->_missingParameter, 500); } }
/** Individual region's details * @access public * @throws Pas_Exception_Param * */ public function regionAction() { if ($this->getParam('id', false)) { $this->view->regions = $this->_geography->getIronAgeRegion($this->getParam('id')); $id = $this->getParam('id'); $denominations = new Denominations(); $this->view->denominations = $denominations->getDenByPeriod($this->_period); $rulers = new Rulers(); $this->view->rulers = $rulers->getIronAgeRulerToRegion($id); } else { throw new Pas_Exception_Param($this->_missingParameter, 500); } }
public function optionsAddClone($broadperiod, $coinDataFlat) { Zend_Controller_Action_HelperBroker::getStaticHelper('FlashMessenger')->addMessage('Your last record data has been cloned'); switch ($broadperiod) { case 'IRON AGE': if (isset($coinDataFlat['denomination'])) { $geographies = new Geography(); $geography_options = $geographies->getIronAgeGeographyMenu($coinDataFlat['denomination']); $this->_view->form->geographyID->addMultiOptions(array(NULL => 'Choose geographic region', 'Available regions' => $geography_options)); } break; case 'ROMAN': if (isset($coinDataFlat['ruler'])) { $reverses = new Revtypes(); $reverse_options = $reverses->getRevTypesForm($coinDataFlat['ruler']); if ($reverse_options) { $this->_view->form->revtypeID->addMultiOptions(array(NULL => 'Choose reverse type', 'Available reverses' => $reverse_options)); } else { $this->_view->form->revtypeID->addMultiOptions(array(NULL => 'No options available')); } } else { $this->_view->form->revtypeID->addMultiOptions(array(NULL => 'No options available')); } if (isset($coinDataFlat['ruler']) && $coinDataFlat['ruler'] == 242) { $moneyers = new Moneyers(); $moneyer_options = $moneyers->getRepublicMoneyers(); $this->_view->form->moneyer->addMultiOptions(array(NULL => NULL, 'Choose reverse type' => $moneyer_options)); } else { $this->_view->form->moneyer->addMultiOptions(array(NULL => 'No options available')); //$this->_view->form->moneyer->disabled=true; } break; case 'EARLY MEDIEVAL': $types = new MedievalTypes(); $type_options = $types->getMedievalTypeToRulerMenu($coinDataFlat['ruler']); $this->_view->form->typeID->addMultiOptions(array(NULL => 'Choose Early Medieval type', 'Available types' => $type_options)); break; case 'MEDIEVAL': $types = new MedievalTypes(); $type_options = $types->getMedievalTypeToRulerMenu($coinDataFlat['ruler']); $this->_view->form->typeID->addMultiOptions(array(NULL => 'Choose Medieval type', 'Available types' => $type_options)); break; case 'POST MEDIEVAL': $types = new MedievalTypes(); $type_options = $types->getMedievalTypeToRulerMenu($coinDataFlat['ruler']); $this->_view->form->typeID->addMultiOptions(array(NULL => 'Choose Post Medieval type', 'Available types' => $type_options)); break; } }
/** * Обновление географического кеша * @return void */ public function action_geo_cache_updater() { if (Arr::get($_GET, 'start') != 'geo_cache') { return; } if (Geography::update_geography_params()) { echo "Географический кэш успешно обновлен в " . Date::formatted_time() . " \n"; } else { echo "Ошибка обновления географического кэша \n"; } }
/** add and clone last record * @access public * @param array $coinDataFlat * @return void */ public function optionsAddClone($coinData) { if (array_key_exists('ruler_id', $coinData)) { $rulers = new Rulers(); $this->_view->form->ruler_id->addMultiOptions(array(NULL => 'Please choose a ruler', 'Available rulers' => $rulers->getLastRulersPairs($coinData['broadperiod']))); } if (array_key_exists('denomination', $coinData)) { $denominations = new Denominations(); $this->_view->form->denomination->addMultiOptions(array(NULL => 'Please choose a denomination', 'Available choices' => $denominations->getDenominationByBroadPeriodPairs($coinData['broadperiod']))); } if (array_key_exists('mint_id', $coinData)) { $mints = new Mints(); $this->_view->form->mint_id->addMultiOptions(array(NULL => 'Please choose a mint', 'Available choices' => $mints->getMintbyBroadperiodPairs($coinData['broadperiod']))); } if (array_key_exists('broadperiod', $coinData)) { if ($coinData['broadperiod'] == 'IRON AGE') { $geography = new Geography(); $this->_view->form->geographyID->addMultiOptions(array(NULL => 'Please choose a geography if applicable', 'Available choices' => $geography->getIronAgeGeographyDD())); } } }
function before() { parent::before(); $this->response->headers('Pragma', 'no-cache'); $this->settings = Kohana::$config->load('settings'); $this->site_name = $this->settings['site_name']; // Стили $this->add_css('assets/css/reset.css'); $this->add_css('assets/js/multiselect/jquery.multiselect.css'); $this->add_css('assets/js/gallery/css/jquery.lightbox-0.5.css'); $this->add_css('assets/css/rmsform.css'); $this->add_css('assets/js/css/flick/jquery-ui-1.8.16.custom.css'); $this->add_css('assets/css/bootstrap_frontend.css'); $this->add_css('assets/css/main_min.css?version=781'); // Скрипты $this->add_js('assets/js/jquery-1.7.1.js'); $this->add_js('assets/js/jquery-ui-1.8.17.custom.min.js'); $this->add_js('assets/js/jquery.columnizer.min.js'); $this->add_js('assets/js/jquery.scrollTo-min.js'); $this->add_js('assets/js/jquery.showpassword.js'); $this->add_js('assets/js/ckeditor/ckeditor.js'); $this->add_js('assets/js/multiselect/jquery.multiselect.js'); $this->add_js('assets/js/multiselect/jquery.multiselect.filter.js'); $this->add_js('assets/js/gallery/jquery.lightbox-0.5.js'); $this->add_js('assets/js/jquery.qtip-1.0.0-rc3.js'); $this->add_js('assets/js/main.js?version=780'); $this->add_js('http://userapi.com/js/api/openapi.js?48', 'before'); // Count of notices if ($this->user) { $this->template->notice_count = ORM::factory('notice')->get_notices_count($this->user); } $this->template->css_class = ''; $this->template->bc['/'] = 'Главная'; //$current_city = $this->session->get('current_city', 'moscow'); $items = array('cars' => array('name' => 'cars', 'ids' => NULL), 'works' => array('name' => 'works', 'ids' => NULL)); $this->_geo_params = Geography::get_geography_params(); $this->_selected_city_ids = Geography::set_selected_city_id($this->_geo_params['cities'], Cookie::get('filter_city')); // Cities select on header $this->template->cities = $this->_geo_params['cities']['total']; uasort($this->template->cities, array('Model_City', 'cmp')); $this->template->selected_city_ids = array('total' => $this->_selected_city_ids['total'], 'has_cars' => $this->_selected_city_ids['has_cars']); $this->template->assoc_news = ORM::factory('newsportal'); }
/** Clone the options * @access public * @param string $broadperiod * @param array $coinDataFlat * @throw Exeption */ public function optionsAddClone($broadperiod, array $coinDataFlat) { switch ($broadperiod) { case 'IRON AGE': if (isset($coinDataFlat['denomination'])) { $geographies = new Geography(); $geography_options = $geographies->getIronAgeGeographyMenu($coinDataFlat['denomination']); $form->geographyID->addMultiOptions(array(null => 'Choose geographic region', 'Available regions' => $geography_options)); $form->geographyID->addValidator('InArray', false, array(array_keys($geography_options))); } break; case 'ROMAN': if (isset($coinDataFlat['ruler'])) { $reverses = new RevTypes(); $reverse_options = $reverses->getRevTypesForm($coinDataFlat['ruler']); if ($reverse_options) { $form->revtypeID->addMultiOptions(array(null => 'Choose reverse type', 'Available reverses' => $reverse_options)); } else { $form->revtypeID->addMultiOptions(array(null => 'No options available')); } } else { $form->revtypeID->addMultiOptions(array(null => 'No options available')); } if (isset($coinDataFlat['ruler']) && $coinDataFlat['ruler'] == 242) { $moneyers = new Moneyers(); $moneyer_options = $moneyers->getRepublicMoneyers(); $form->moneyer->addMultiOptions(array(null => 'Choose moneyer', 'Available moneyers' => $moneyer_options)); } else { $form->moneyer->addMultiOptions(array(null => 'No options available')); } break; case 'EARLY MEDIEVAL': $types = new MedievalTypes(); $type_options = $types->getMedievalTypeToRulerMenu($coinDataFlat['ruler']); $form->typeID->addMultiOptions(array(null => 'Choose Early Medieval type', 'Available types' => $type_options)); break; case 'MEDIEVAL': $types = new MedievalTypes(); $type_options = $types->getMedievalTypeToRulerMenu($coinDataFlat['ruler']); $form->typeID->addMultiOptions(array(null => 'Choose Medieval type', 'Available types' => $type_options)); break; case 'POST MEDIEVAL': $types = new MedievalTypes(); $type_options = $types->getMedievalTypeToRulerMenu($coinDataFlat['ruler']); $form->typeID->addMultiOptions(array(null => 'Choose Post Medieval type', 'Available types' => $type_options)); break; default: throw new Exception('No period supplied', 500); } }
/** * Для обновления пощиций маркеров на карте */ public function action_ajax_map_update() { if ($this->request->is_ajax()) { $this->auto_render = FALSE; $metro_stations = Arr::get($_POST, 'metro_stations'); if (!$metro_stations) { $result['error'] = 'Ошибка обновления карты'; echo json_encode($result); return; } $updated_count = 0; foreach ($metro_stations as $metro) { $pairs = array(); foreach ($metro as $field => $value) { $pairs[$field] = $value; } unset($pairs['id']); $query = DB::update('metro')->set($pairs)->where('id', '=', $metro['id'])->execute(); if ($query) { $updated_count++; } } Geography::update_geography_params(); $result['msg'] = 'updated metro stations: ' . $updated_count; echo json_encode($result); } }
/** * Поиск по услуге services/search/work_:id * @return void */ public function action_search_by_work() { $work_id = $this->request->param('work'); $city_id = $this->request->param('city'); $district_id = $this->request->query('district'); $metro_id = $this->request->query('metro'); $this->_selected_city_ids = Geography::set_selected_city_id($this->_geo_params['cities'], $city_id); if (!array_key_exists($city_id, $this->_geo_params['cities']['total'])) { $this->request->redirect('filter/auto/city_' . $this->_selected_city_ids['has_works']); } $params['city'] = array('field' => 'city_id', 'op' => '=', 'value' => $city_id); $current_district = Arr::get($this->_geo_params['districts'], $district_id); $current_metro_station = Arr::get($this->_geo_params['metro_stations'], $metro_id); if ($current_district and $current_district['city_id'] == $city_id and !empty($current_district['works']) and in_array($work_id, $current_district['works'])) { $params['district'] = array('field' => 'district_id', 'op' => '=', 'value' => $district_id); } else { $district_id = 0; } if ($current_metro_station and $current_metro_station['city_id'] == $city_id or $current_district and $current_metro_station['district_id'] == $district_id and !empty($current_metro_station['works']) and in_array($work_id, $current_metro_station['works'])) { $params['metro'] = array('field' => 'metro_id', 'op' => '=', 'value' => $metro_id); } else { $metro_id = 0; } $url = 'services/search/work_' . $work_id . '/city_' . $city_id; $items['works'] = array('name' => 'works', 'ids' => array($work_id)); $district = ORM::factory('district')->set_has_items($items)->get_districts($this->_geo_params, $city_id); $metro = ORM::factory('metro')->set_has_items($items)->get_metro($this->_geo_params, $city_id, $district_id); $discount = ORM::factory('discount')->set_params($params)->get_discounts(); $car_brand = ORM::factory('car_brand')->set_params($params)->get_cars(NULL, $items['works']['ids']); $work = ORM::factory('work')->set_params($params)->get_works(TRUE); $service = ORM::factory('service')->set_params($params)->set_has_items($items)->get_services_2(); $service->reset(FALSE); $services_count = count($service->find_all()); if ($services_count == 0) { Message::set(Message::ERROR, 'Неправильные параметры поиска, сервисы не найдены.'); $this->request->redirect('filter/work/' . $this->_selected_city_ids['has_works']); } $current_work = ORM::factory('work')->extract_current_work_from_categories($work, $work_id); $content = $current_work['current_object']->content; $i18n_params = array(':work_name' => $current_work['name'], ':dativus_city_name' => $this->_geo_params['cities']['total'][$city_id]->dativus_name); $this->template->meta_keywords = __('search_work_keywords', $i18n_params); $this->template->meta_description = __('search_work_description', $i18n_params); $h1_title = __('search_work_h1', $i18n_params); $this->template->title = __('search_work_title', $i18n_params); $this->template->bc['filter/work/' . $this->_selected_city_ids['has_works']] = 'Подбор автосервиса по предоставляемым услугам'; $this->template->bc['#'] = Text::limit_chars($h1_title, 75); /* Default text */ if ($params['city']['value'] != 1 or !trim(strip_tags($content->text))) { $content->text = __(Kohana::$config->load('default_search_content.search_by_work'), array(':name' => $current_work['name'])); } $this->view = View::factory('frontend/services/search')->set('city', $this->_geo_params['cities']['total'][$city_id])->set('metro_stations', $metro)->set('districts', $district)->set('discounts', $discount)->set('cars', $car_brand)->set('works', $work)->set('services', $service)->set('type', 'work')->set('work_id', $work_id)->set('car_id', NULL)->set('city_id', $city_id)->set('metro_id', $metro_id)->set('district_id', $district_id)->set('url', $url)->set('services_count', $services_count)->set('content', $content)->set('h1_title', $h1_title); $this->template->content = $this->view; }
/** * Теги округов * @return void */ function action_district() { if ($this->request->param('city')) { $this->_selected_city_ids = Geography::set_selected_city_id($this->_geo_params['cities'], $this->request->param('city')); $this->template->selected_city_ids = array_intersect_key($this->_selected_city_ids, $this->template->selected_city_ids); Cookie::set('filter_city', $this->_selected_city_ids['total']); } else { $this->request->redirect('filter/district/city_' . $this->_selected_city_ids['has_district']); } $params = array('city' => array('field' => 'city_id', 'op' => '=', 'value' => $this->_selected_city_ids['has_district'])); $district = ORM::factory('district')->get_districts($this->_geo_params, $params['city']['value']); if (empty($district)) { Message::set(Message::ERROR, 'Не найдены округи'); $this->request->redirect('filter/district/city_' . $this->_selected_city_ids['has_district']); } $current_city = $this->_geo_params['cities']['total'][$this->_selected_city_ids['has_district']]; $content = $current_city->contents->where('type', '=', 'district')->find(); if (!trim(strip_tags($content->text))) { $content->text = __('filter_district_default_content', array(':name' => $content->city->name)); } if ($this->request->query('selected_city') and $this->request->query('selected_city') != $this->_selected_city_ids['has_district']) { Message::set(Message::NOTICE, __('filter_district_city_not_found', array(':city_name' => $current_city->name))); } $this->view = View::factory('frontend/filter/districts')->set('cities', array_intersect_key($this->_geo_params['cities']['total'], $this->_geo_params['cities']['has_district']))->set('selected_city_ids', $this->_selected_city_ids)->set('districts', $district)->set('content', $content); $this->template->title = 'Подбор автосервиса по округу'; $this->template->bc['#'] = $this->template->title; $this->template->content = $this->view; }
function getLocalTerm($term, $locale = null, $translate = true, $returnDef = false) { $_this =& Geography::getInstance(); if (!empty($_this->localeTerms[$term])) { $res = $_this->localeTerms[$term]; if (!empty($locale)) { if (!is_array($locale)) { $locale = array($locale); } foreach ($locale as $elem) { if (!empty($res[$elem])) { $res = $res[$elem]; } } } if (!empty($res) && !is_array($res)) { if ($translate) { $res = __d('spark_form', $res, true); } return $res; } } if ($returnDef) { return $term; } return null; }
function action_index() { $this->auto_render = FALSE; $sitemap = new Sitemap(); $base_url = 'http://www.as-avtoservice.ru/'; // Basic urls $base_urls = Kohana::$config->load('settings.sitemap_urls'); foreach ($base_urls as $u) { $url = new Sitemap_URL(); $url->set_loc($base_url . $u); $sitemap->add($url); } // Standart contents $content = ORM::factory('content_site'); foreach ($content->where('active', '!=', 0)->find_all() as $c) { $url = new Sitemap_URL(); $url->set_loc($base_url . $c->url); //$unix_time = strtotime($c->date); //$url->set_last_mod($unix_time); $sitemap->add($url); } // Shops page $shop = ORM::factory('service')->where('type', '=', 2); foreach ($shop->find_all() as $s) { $url = new Sitemap_URL(); $url->set_loc($base_url . 'shops/' . $s->id); //$unix_time = (int) strtotime($s->date_create); //$url->set_last_mod($unix_time); $sitemap->add($url); } // Services page $service = ORM::factory('service')->where('type', '=', 1); foreach ($service->find_all() as $s) { $url = new Sitemap_URL(); $url->set_loc($base_url . 'services/' . $s->id); $sitemap->add($url); } unset($s); // Service news $service_all_news_urls = array(); $news_service = ORM::factory('newsservice')->where('active', '=', 1); foreach ($news_service->find_all() as $news) { $url = new Sitemap_URL(); $url->set_loc($base_url . 'services/' . $news->service->id . '/news/' . $news->id); $sitemap->add($url); if (!array_key_exists($news->service->id, $service_all_news_urls)) { $service_all_news_urls[$news->service->id] = 'services/' . $news->service->id . '/news'; } } unset($news); foreach ($service_all_news_urls as $all_news_url) { $url = new Sitemap_URL(); $url->set_loc($base_url . $all_news_url); $sitemap->add($url); } // Site news $news_portal = ORM::factory('newsportal')->where('active', '!=', 0); foreach ($news_portal->find_all() as $news) { $url = new Sitemap_URL(); $url->set_loc($base_url . 'news/association/' . $news->id); $sitemap->add($url); } unset($news); // World news $news_world = ORM::factory('newsworld')->where('active', '!=', 0)->find_all(); if (count($news_world) > 0) { $url = new Sitemap_URL(); $url->set_loc($base_url . 'news/world'); $sitemap->add($url); foreach ($news_world as $news) { $url = new Sitemap_URL(); $url->set_loc($base_url . 'news/world/' . $news->id); $sitemap->add($url); } } // Articles $article = ORM::factory('content_article')->where('active', '!=', 0)->find_all(); if (count($article) > 0) { $url = new Sitemap_URL(); $url->set_loc($base_url . 'articles'); $sitemap->add($url); foreach ($article as $a) { $url = new Sitemap_URL(); $url->set_loc($base_url . 'articles/' . $a->id); $sitemap->add($url); } } // Reviews $service_all_reviews_urls = array(); $review = ORM::factory('review')->where('active', '!=', 0)->find_all(); if (count($review) > 0) { $url = new Sitemap_URL(); $url->set_loc($base_url . 'reviews'); $sitemap->add($url); foreach ($review as $r) { $url = new Sitemap_URL(); $url->set_loc($base_url . 'services/' . $r->service->id . '/reviews/' . $r->id); $sitemap->add($url); if (!array_key_exists($r->service->id, $service_all_reviews_urls)) { $service_all_reviews_urls[$r->service->id] = 'services/' . $r->service->id . '/reviews'; } } } foreach ($service_all_reviews_urls as $all_reviews_url) { $url = new Sitemap_URL(); $url->set_loc($base_url . $all_reviews_url); $sitemap->add($url); } // Services stocks (акции) $service_all_stocks_urls = array(); $stock = ORM::factory('stock')->where('active', '!=', 0)->find_all(); if (count($stock) > 0) { $url = new Sitemap_URL(); $url->set_loc($base_url . 'stocks'); $sitemap->add($url); foreach ($stock as $s) { $url = new Sitemap_URL(); $url->set_loc($base_url . 'services/' . $s->service->id . '/stocks/' . $s->id); $sitemap->add($url); if (!array_key_exists($s->service->id, $service_all_stocks_urls)) { $service_all_stocks_urls[$s->service->id] = 'services/' . $s->service->id . '/stocks'; } } } foreach ($service_all_stocks_urls as $all_stocks_url) { $url = new Sitemap_URL(); $url->set_loc($base_url . $all_stocks_url); $sitemap->add($url); } // Services Vacancies (вакансии) $service_all_vacancies_urls = array(); foreach (ORM::factory('vacancy')->get_vacancies() as $v) { $url = new Sitemap_URL(); $url->set_loc($base_url . 'services/' . $v->service->id . '/vacancies/' . $v->id); $sitemap->add($url); if (!array_key_exists($v->service->id, $service_all_vacancies_urls)) { $service_all_vacancies_urls[$v->service->id] = 'services/' . $v->service->id . '/vacancies'; } } foreach ($service_all_vacancies_urls as $all_vacancies_url) { $url = new Sitemap_URL(); $url->set_loc($base_url . $all_vacancies_url); $sitemap->add($url); } // Q&A (запросы пользователей) $question = ORM::factory('question')->where('active', '!=', 0)->find_all(); if (count($question) > 0) { $url = new Sitemap_URL(); $url->set_loc($base_url . 'messages'); $sitemap->add($url); foreach ($question as $q) { $url = new Sitemap_URL(); $url->set_loc($base_url . 'messages/' . $q->id); $sitemap->add($url); } } $geo_params = Geography::get_geography_params(); // Tags pages // Auto tags and search pages foreach ($geo_params['cities']['has_cars'] as $city) { $url = new Sitemap_URL(); $url->set_loc($base_url . 'filter/auto/city_' . $city['city_id']); $sitemap->add($url); foreach ($city['cars'] as $car_id) { $url = new Sitemap_URL(); $url->set_loc($base_url . 'services/search/car_' . $car_id . '/city_' . $city['city_id']); $sitemap->add($url); } } unset($city); // Works tags and search pages foreach ($geo_params['cities']['has_works'] as $city) { $url = new Sitemap_URL(); $url->set_loc($base_url . 'filter/work/city_' . $city['city_id']); $sitemap->add($url); foreach ($city['works'] as $work_id) { $url = new Sitemap_URL(); $url->set_loc($base_url . 'services/search/work_' . $work_id . '/city_' . $city['city_id']); $sitemap->add($url); } } unset($city); // Districts tags and search pages foreach ($geo_params['cities']['has_district'] as $city) { $url = new Sitemap_URL(); $url->set_loc($base_url . 'filter/district/city_' . $city['city_id']); $sitemap->add($url); } unset($city); foreach ($geo_params['districts'] as $id => $value) { if (!empty($value['cars']) or !empty($value['works'])) { $url = new Sitemap_URL(); $url->set_loc($base_url . 'services/search/district_' . $id); $sitemap->add($url); } } // Metro stations tags and search pages foreach ($geo_params['cities']['has_metro'] as $city) { $url = new Sitemap_URL(); $url->set_loc($base_url . 'filter/metro/city_' . $city['city_id']); $sitemap->add($url); } foreach ($geo_params['metro_stations'] as $id => $value) { if (!empty($value['cars']) or !empty($value['works'])) { $url = new Sitemap_URL(); $url->set_loc($base_url . 'services/search/metro_' . $id); $sitemap->add($url); } } $this->response->headers('Content-type', 'text/xml'); $this->response->body($sitemap); }
/** add and clone last record * @access public * @param string $broadperiod * @param array $coinDataFlat * @return void */ public function optionsAddClone($broadperiod, array $coinDataFlat) { $coinDataFlat = $coinDataFlat[0]; switch ($broadperiod) { case 'IRON AGE': if (array_key_exists('denomination', $coinDataFlat)) { $geographies = new Geography(); $geography_options = $geographies->getIronAgeGeographyMenu($coinDataFlat['denomination']); $this->_view->form->geographyID->addMultiOptions(array(null => 'Choose geographic region', 'Available regions' => $geography_options)); $this->_view->form->geographyID->addValidator('InArray', false, array(array_keys($geography_options))); } break; case 'ROMAN': if (array_key_exists('ruler_id', $coinDataFlat)) { if (!is_null($coinDataFlat['ruler_id'])) { $rulers = new Rulers(); $identifier = $rulers->fetchRow($rulers->select()->where('id = ?', $coinDataFlat['ruler_id'])); if ($identifier) { $nomisma = $identifier->nomismaID; $rrcTypes = new Nomisma(); $this->_view->form->ricID->addMultiOptions(array(null => 'Choose RIC type', 'Available RIC types' => $rrcTypes->getRICDropdownsFlat($nomisma))); } } $reverses = new RevTypes(); $reverse_options = $reverses->getRevTypesForm($coinDataFlat['ruler_id']); if ($reverse_options) { $this->_view->form->revtypeID->addMultiOptions(array(null => 'Choose reverse type', 'Available reverses' => $reverse_options)); $this->_view->form->revtypeID->setRegisterInArrayValidator(false); } else { $this->_view->form->revtypeID->addMultiOptions(array(null => 'No options available')); $this->_view->form->revtypeID->setRegisterInArrayValidator(false); } } else { $this->_view->form->revtypeID->addMultiOptions(array(null => 'No options available')); $this->_view->form->revtypeID->setRegisterInArrayValidator(false); } if (array_key_exists('ruler_id', $coinDataFlat) && $coinDataFlat['ruler_id'] == '242') { $moneyers = new Moneyers(); $moneyer_options = $moneyers->getRepublicMoneyers(); $this->_view->form->moneyer->addMultiOptions(array(null => 'Choose moneyer', 'Available moneyers' => $moneyer_options)); if (array_key_exists('moneyer', $coinDataFlat)) { if (!is_null($coinDataFlat['moneyer'])) { $identifier = $moneyers->fetchRow($moneyers->select()->where('id = ?', $coinDataFlat['moneyer'])); if ($identifier) { $nomisma = $identifier->nomismaID; $rrcTypes = new Nomisma(); $this->_view->form->rrcID->addMultiOptions(array(null => 'Choose RRC type', 'Available RRC types' => $rrcTypes->getRRCDropdownsFlat($nomisma))); } } } } else { $this->_view->form->moneyer->addMultiOptions(array(null => 'No options available')); } break; case 'EARLY MEDIEVAL': if (array_key_exists('ruler_id', $coinDataFlat)) { $types = new MedievalTypes(); $type_options = $types->getMedievalTypeToRulerMenu($coinDataFlat['ruler_id']); $this->_view->form->typeID->addMultiOptions(array(null => 'Choose Early Medieval type', 'Available types' => $type_options)); } break; case 'MEDIEVAL': if (array_key_exists('ruler_id', $coinDataFlat)) { $types = new MedievalTypes(); $type_options = $types->getMedievalTypeToRulerMenu($coinDataFlat['ruler_id']); $this->_view->form->typeID->addMultiOptions(array(null => 'Choose Medieval type', 'Available types' => $type_options)); } break; case 'POST MEDIEVAL': if (array_key_exists('ruler_id', $coinDataFlat)) { $types = new MedievalTypes(); $type_options = $types->getMedievalTypeToRulerMenu((int) $coinDataFlat['ruler_id']); $this->_view->form->typeID->addMultiOptions(array(null => 'Choose Post Medieval type', 'Available types' => $type_options)); } break; default: return false; } }
public function optionsAddClone($broadperiod, $coinDataFlat) { switch ($broadperiod) { case 'IRON AGE': if (isset($coinDataFlat['denomination'])) { $geographies = new Geography(); $geography_options = $geographies->getIronAgeGeographyMenu($coinDataFlat['denomination']); $form->geographyID->addMultiOptions(array(NULL => 'Choose geographic region', 'Available regions' => $geography_options)); } break; case 'ROMAN': if (isset($coinDataFlat['ruler'])) { $reverses = new Revtypes(); $reverse_options = $reverses->getRevTypesForm($coinDataFlat['ruler']); if ($reverse_options) { $form->revtypeID->addMultiOptions(array(NULL => 'Choose reverse type', 'Available reverses' => $reverse_options)); } else { $form->revtypeID->addMultiOptions(array(NULL => 'No options available')); } } else { $form->revtypeID->addMultiOptions(array(NULL => 'No options available')); } if (isset($coinDataFlat['ruler']) && $coinDataFlat['ruler'] == 242) { $moneyers = new Moneyers(); $moneyer_options = $moneyers->getRepublicMoneyers(); $form->moneyer->addMultiOptions(array(NULL => NULL, 'Choose reverse type' => $moneyer_options)); } else { $form->moneyer->addMultiOptions(array(NULL => 'No options available')); //$form->moneyer->disabled=true; } break; case 'EARLY MEDIEVAL': $types = new MedievalTypes(); $type_options = $types->getMedievalTypeToRulerMenu($coinDataFlat['ruler']); $form->typeID->addMultiOptions(array(NULL => 'Choose Early Medieval type', 'Available types' => $type_options)); break; case 'MEDIEVAL': $types = new MedievalTypes(); $type_options = $types->getMedievalTypeToRulerMenu($coinDataFlat['ruler']); $form->typeID->addMultiOptions(array(NULL => 'Choose Medieval type', 'Available types' => $type_options)); break; case 'POST MEDIEVAL': $types = new MedievalTypes(); $type_options = $types->getMedievalTypeToRulerMenu($coinDataFlat['ruler']); $form->typeID->addMultiOptions(array(NULL => 'Choose Post Medieval type', 'Available types' => $type_options)); break; } }
/** * Возвращаем гео параметры автосервисов * @static * @return mixed|void */ public static function get_geography_params() { $cache = Cache::instance(); if (!$cache->get('geo_params')) { return Geography::update_geography_params(); } else { return $cache->get('geo_params'); } }
public function getgeographyAction() { $geography = new Geography(); $this->view->json = $geography->getIronAgeGeographyAll(); }
function byCountry($options, $supplementItem, $order, $supplement_choice, $calcul) { $defOpt = array('keyPath' => array('order.ShopOrder.shipping_country', 'settings.defaultCountry'), 'subMethod' => null, 'modifProp' => 'total', 'list' => array()); if (!count(array_intersect_key($options, $defOpt))) { $options = array('list' => $options); } $opt = array_merge($defOpt, $options); App::import('Lib', 'Shop.ShopConfig'); $settings = ShopConfig::load(); $dataSource = array('settings' => $settings, 'order' => $order, 'calcul' => $calcul); App::import('Lib', 'Shop.SetMulti'); $country = SetMulti::extractHierarchic($opt['keyPath'], $dataSource); $val = null; if (array_key_exists($country, $opt['list'])) { $val = $opt['list'][$country]; } else { App::import('Lib', 'O2form.Geography'); $continent = Geography::getContinent($country); if (array_key_exists($continent, $opt['list'])) { $val = $opt['list'][$continent]; } elseif (array_key_exists('default', $opt['list'])) { $val = $opt['list']['default']; } } if (!is_null($val)) { if (!empty($opt['subMethod'])) { return $this->calculFunct($opt['subMethod'], $val, $supplementItem, $order, $supplement_choice, $calcul); } $supplementItem[$opt['modifProp']] = $val; } return $supplementItem; }
/** * Фильтр услуг и прочего * @return mixed */ public function action_fast_filter() { $geo_params = Geography::get_geography_params(); // Типы быстрого поиска на главной $types = array('has_cars', 'has_works', 'has_metro', 'has_district'); if ($this->request->query('type') and in_array($this->request->query('type'), $types)) { Cookie::set('fast_filter_type', $this->request->query('type')); $filter_type = $this->request->query('type'); } else { $filter_type = Cookie::get('fast_filter_type', 'has_cars'); if (!in_array($filter_type, $types)) { $filter_type = 'has_cars'; } } if ($this->request->query('city') and array_key_exists($this->request->query('city'), $geo_params['cities']['total'])) { Cookie::set('filter_city', $this->request->query('city')); $city_id = $this->request->query('city'); } else { $city_id = Cookie::get('filter_city'); } $selected_city_ids = Geography::set_selected_city_id($geo_params['cities'], $city_id); $params = array('city' => array('field' => 'city_id', 'op' => '=', 'value' => $selected_city_ids[$filter_type])); $header_cities_view = View::factory('frontend/navigation/header_cities')->set('cities', $geo_params['cities']['total'])->set('current_city', $selected_city_ids['total'])->render(); if ($this->request->query('mode') == 'without_filter') { $result = array('header_cities' => $header_cities_view, 'auto_filter_city_id' => $selected_city_ids['has_cars']); echo json_encode($result); return; } $config = Kohana::$config->load('settings'); $current_city = array('name' => $geo_params['cities']['total'][$selected_city_ids[$filter_type]]->name, 'genitive_name' => $geo_params['cities']['total'][$selected_city_ids[$filter_type]]->genitive_name); $primary_cities = array_intersect_key($geo_params['cities']['total'], $geo_params['cities'][$filter_type]); $other_cities = NULL; // Получение городов, основных и "других" if (count($primary_cities) > $config['max_fast_filter_cities']) { $primary_cities = array_intersect_key($primary_cities, array_flip($config['fast_filter_cities'])); if (!array_key_exists($selected_city_ids[$filter_type], $primary_cities)) { array_pop($primary_cities); $primary_cities = array($selected_city_ids[$filter_type] => $geo_params['cities']['total'][$selected_city_ids[$filter_type]]) + $primary_cities; } $other_cities = array_diff_key(array_intersect_key($geo_params['cities']['total'], $geo_params['cities'][$filter_type]), $primary_cities); } $filter_type_view = View::factory('frontend/navigation/fast_filter_types')->set('types', $types)->set('current_type', $filter_type)->render(); $cities_view = View::factory('frontend/navigation/fast_filter_cities')->set('cities', $primary_cities)->set('other_cities', $other_cities)->set('city_id', $selected_city_ids[$filter_type])->render(); switch ($filter_type) { case 'has_cars': $car_brand = ORM::factory('car_brand')->set_params($params)->get_cars(); if (count($car_brand) > $config['max_fast_filter_models']) { $primary_cars = array_intersect_key($car_brand, array_flip($config['fast_filter_models'])); if (count($primary_cars) < $config['max_fast_filter_models']) { $primary_cars = $primary_cars + array_slice(array_diff_key($car_brand, $primary_cars), 0, $config['max_fast_filter_models'] - count($primary_cars), TRUE); } $car_brand = $primary_cars; } $items_view = View::factory('frontend/fast_filter/car_brands')->set('city_id', $params['city']['value'])->set('car_brands', $car_brand)->render(); break; case 'has_works': $work = ORM::factory('work')->set_params($params)->get_works(); if (count($work) > $config['max_fast_filter_works']) { $primary_works = array_intersect_key($work, array_flip($config['fast_filter_works'])); if (count($primary_works) < $config['max_fast_filter_works']) { $primary_works = $primary_works + array_slice(array_diff_key($work, $primary_works), 0, $config['max_fast_filter_works'] - count($primary_works), TRUE); } $work = $primary_works; } $items_view = View::factory('frontend/fast_filter/works')->set('works', $work)->set('city_id', $params['city']['value'])->render(); break; case 'has_metro': $metro = ORM::factory('metro')->get_metro($geo_params, $params['city']['value']); if (count($metro) > $config['max_fast_filter_metro']) { $metro = array_slice($metro, 0, $config['max_fast_filter_metro'], TRUE); } $items_view = View::factory('frontend/fast_filter/metro')->set('metro_stations', $metro)->set('city_id', $params['city']['value'])->render(); break; case 'has_district': $district = ORM::factory('district')->get_districts($geo_params, $params['city']['value']); if (count($district) > $config['max_fast_filter_districts']) { $district = array_slice($district, 0, $config['max_fast_filter_districts'], TRUE); } $items_view = View::factory('frontend/fast_filter/districts')->set('districts', $district)->set('city_id', $params['city']['value'])->render(); break; } $result = array('filter_type' => $filter_type_view, 'cities' => $cities_view, 'items' => $items_view, 'header_cities' => $header_cities_view, 'current_city' => $current_city, 'auto_filter_url' => URL::site('filter/auto/city_' . $selected_city_ids['has_cars'])); if ($this->request->is_ajax()) { echo json_encode($result); } else { $this->response->body($result['filter_type'] . $result['cities'] . $result['items']); } }
function region($fieldName, $options = array()) { $defOpt = array('countrySelect' => null, 'options' => true, 'other' => array('label' => __('Other', true), 'optLabel' => true, 'div' => array('class' => 'input otherInput text')), 'div' => array('class' => array('input', 'extendedSelect'))); if (!empty($options['countrySelect'])) { $defOpt = array_merge($defOpt, array('empty' => array('div' => array('class' => array('input', 'extendedSelectCase', 'extendedSelectEmpty', 'select')), 'other' => true), 'cases' => array('div' => array('class' => array('input', 'extendedSelectCase', 'select'), 'style' => 'display:none'), 'disabled' => 'disabled'), 'more' => array('div' => array('class' => 'input extendedSelectCase extendedSelectMore text', 'style' => 'display:none'), 'disabled' => 'disabled'))); } else { $defOpt = array_merge($defOpt, array('div' => array('class' => 'input extendedSelect select'))); } $opt = $this->mergeOpt($defOpt, $options); $loadScript = false; $out = null; App::import('Lib', 'SparkForm.Geography'); $regions = array(); $needMore = false; if ($opt['options'] === true) { $selected = Geography::getCountries(array_keys($regions)); } else { $selected = Set::normalize($opt['options']); } $opt['options'] = array(); foreach ($selected as $key => $country) { if (!empty($country) && is_string($country)) { $label = $country; } elseif (is_array($country) && !empty($country['label'])) { $label = $country['label']; } else { $label = Geography::getCountry($key); } $cregions = Geography::getRegions($key); if (is_array($country) && !empty($country['regions']) && !is_array($country['regions'])) { $selected = Set::normalize($country['regions']); $cregions = array_intersect_key($cregions, $selected); } if (!empty($cregions)) { $regions[] = array('label' => array('text' => Geography::getLocalTerm('region', $key)), 'rel' => $key, 'options' => $cregions); $opt['options'][$label] = $cregions; } else { $needMore = true; } } if (!$needMore) { $opt['more'] = false; } $allOpt = $opt['options']; if ($opt['other']) { $loadScript = true; if ($opt['other'] === true) { $opt['other'] = array(); } elseif (!is_array($opt['other'])) { $opt['other'] = array('label' => $opt['other']); } $opt['other'] = array_merge($defOpt['other'], $opt['other']); if ($opt['other']['optLabel'] === true) { $opt['other']['optLabel'] = $opt['other']['label']; } $allOpt['other'] = $opt['other']['optLabel']; unset($opt['other']['optLabel']); } $localOpt = array('countrySelect', 'options', 'other', 'empty', 'cases', 'more', 'type'); $fowardOpt = array_diff_key($options, array_flip($localOpt)); if (empty($opt['countrySelect'])) { $opt['options'] = $allOpt; $opt['type'] = null; if ($opt['other']) { $opt['after'] = $this->input($fieldName . '_other', $opt['other']); } $out = $this->input($fieldName, $opt); } else { if (preg_match('/[_a-z0-9]/i', $opt['countrySelect'])) { $opt['countrySelect'] = '#' . $this->domId($opt['countrySelect']); $this->setEntity($fieldName); } $loadScript = true; $out = ''; if ($opt['empty']) { $opt['empty'] = $this->mergeOpt($defOpt['empty'], (array) $opt['empty'], $fowardOpt); $opt['empty']['options'] = $allOpt; if ($opt['empty']['other']) { $opt['empty']['after'] = $this->input($fieldName . '_other', $opt['other']); } $out .= $this->input($fieldName, $opt['empty']); } foreach ($regions as $region) { $caseOpt = $this->mergeOpt($opt['cases'], $region, $fowardOpt); $caseOpt['div']['rel'] = $region['rel']; unset($caseOpt['rel']); $out .= $this->input($fieldName, $caseOpt); } if ($opt['more']) { $opt['more'] = array_merge($defOpt['more'], (array) $opt['more']); $out .= $this->input($fieldName, $opt['more']); } if ($opt['div']) { $opt['div']['linked'] = $opt['countrySelect']; $out = '<div' . $this->_parseAttributes($opt['div']) . '>' . $out . '</div>'; } } if ($loadScript) { $this->Html->script('/spark_form/js/region_select', array('inline' => false)); } return $out; }
public function iageographyAction() { if ($this->_getParam('term', false)) { $geographies = new Geography(); $response = $geographies->getIronAgeGeography($this->_getParam('term')); } else { $response = array(array('id' => NULL, 'term' => 'No ruler specified')); } echo Zend_Json::encode($response); }
public function __construct($options = null) { //Get data to form select menu for primary and secondary material $primaries = new Materials(); $primary_options = $primaries->getPrimaries(); //Get data to form select menu for periods //Get Rally data $rallies = new Rallies(); $rally_options = $rallies->getRallies(); //Get Hoard data $hoards = new Hoards(); $hoard_options = $hoards->getHoards(); $counties = new Counties(); $county_options = $counties->getCountyName2(); $denominations = new Denominations(); $denom_options = $denominations->getOptionsIronAge(); $rulers = new Rulers(); $ruler_options = $rulers->getIronAgeRulers(); $mints = new Mints(); $mint_options = $mints->getIronAgeMints(); $axis = new Dieaxes(); $axis_options = $axis->getAxes(); $geog = new Geography(); $geog_options = $geog->getIronAgeGeographyDD(); $regions = new Regions(); $region_options = $regions->getRegionName(); $tribes = new Tribes(); $tribe_options = $tribes->getTribes(); $institutions = new Institutions(); $inst_options = $institutions->getInsts(); parent::__construct($options); $decorators = array(array('ViewHelper'), array('Description', array('placement' => 'append', 'class' => 'info')), array('Errors', array('placement' => 'append', 'class' => 'error', 'tag' => 'li')), array('Label'), array('HtmlTag', array('tag' => 'li'))); $this->setName('Advanced'); $old_findID = new Zend_Form_Element_Text('old_findID'); $old_findID->setLabel('Find number: ')->setRequired(false)->addFilters(array('StripTags', 'StringTrim'))->addErrorMessage('Please enter a valid number!')->setDecorators($decorators); $description = new Zend_Form_Element_Text('description'); $description->setLabel('Object description contains: ')->setRequired(false)->addFilters(array('StripTags', 'StringTrim'))->addErrorMessage('Please enter a valid term')->setDecorators($decorators); $workflow = new Zend_Form_Element_Select('workflow'); $workflow->setLabel('Workflow stage: ')->setRequired(false)->addFilters(array('StripTags', 'StringTrim'))->setDecorators($decorators); if (in_array($this->getRole(), $this->_higherlevel)) { $workflow->addMultiOptions(array(NULL => 'Choose a workflow stage', 'Available workflow stages' => array('1' => 'Quarantine', '2' => 'On review', '4' => 'Awaiting validation', '3' => 'Published'))); } if (in_array($this->getRole(), $this->_restricted)) { $workflow->addMultiOptions(array(NULL => 'Choose a workflow stage', 'Available workflow stages' => array('4' => 'Awaiting validation', '3' => 'Published'))); } //Rally details $rally = new Zend_Form_Element_Checkbox('rally'); $rally->setLabel('Rally find: ')->setRequired(false)->addFilters(array('StripTags', 'StringTrim'))->setUncheckedValue(NULL)->setDecorators($decorators); $geographyID = new Zend_Form_Element_Select('geographyID'); $geographyID->setLabel('Geographic area: ')->setDecorators($decorators)->addFilters(array('StripTags', 'StringTrim'))->addMultiOptions(array(NULL => 'Choose a geography', 'Available geographies' => $geog_options))->addValidator('inArray', false, array(array_keys($geog_options)))->addValidator('Int'); $rallyID = new Zend_Form_Element_Select('rallyID'); $rallyID->setLabel('Found at this rally: ')->setRequired(false)->addFilters(array('StripTags', 'StringTrim'))->addMultiOptions(array(NULL => 'Choose a rally', 'Available rallies' => $rally_options))->setDecorators($decorators)->addValidator('inArray', false, array(array_keys($rally_options)))->addValidator('Int'); $hoard = new Zend_Form_Element_Checkbox('hoard'); $hoard->setLabel('Hoard find: ')->setRequired(false)->addFilters(array('StripTags', 'StringTrim'))->setUncheckedValue(NULL)->setDecorators($decorators); $hoardID = new Zend_Form_Element_Select('hID'); $hoardID->setLabel('Part of this hoard: ')->setRequired(false)->addFilters(array('StripTags', 'StringTrim'))->addMultiOptions(array(NULL => 'Choose a hoard', 'Available hoards' => $hoard_options))->setDecorators($decorators)->addValidator('inArray', false, array(array_keys($hoard_options)))->addValidator('Int'); $county = new Zend_Form_Element_Select('county'); $county->setLabel('County: ')->addFilters(array('StripTags', 'StringTrim'))->addMultiOptions(array(NULL => 'Choose a county', 'Available counties' => $county_options))->addValidator('inArray', false, array(array_keys($county_options)))->setDecorators($decorators); $district = new Zend_Form_Element_Select('district'); $district->setLabel('District: ')->addFilters(array('StripTags', 'StringTrim'))->addMultiOptions(array(NULL => 'Choose district after county'))->setDecorators($decorators)->disabled = true; $parish = new Zend_Form_Element_Select('parish'); $parish->setLabel('Parish: ')->addFilters(array('StripTags', 'StringTrim'))->addMultiOptions(array(NULL => 'Choose parish after county'))->setDecorators($decorators)->disabled = true; $regionID = new Zend_Form_Element_Select('regionID'); $regionID->setLabel('European region: ')->setDecorators($decorators)->addMultiOptions(array(NULL => 'Choose a region for a wide result', 'Available regions' => $region_options))->addValidator('Int'); $gridref = new Zend_Form_Element_Text('gridref'); $gridref->setLabel('Grid reference: ')->setDecorators($decorators)->addValidator('ValidGridRef')->addFilters(array('StripTags', 'StringTrim'))->addValidator('Alnum'); $fourFigure = new Zend_Form_Element_Text('fourFigure'); $fourFigure->setLabel('Four figure grid reference: ')->setDecorators($decorators)->addFilters(array('StripTags', 'StringTrim'))->addValidator('ValidGridRef')->addValidator('Alnum'); ### ##Numismatic data ### // Denomination $denomination = new Zend_Form_Element_Select('denomination'); $denomination->setLabel('Denomination: ')->setRegisterInArrayValidator(false)->setRequired(false)->addFilters(array('StripTags', 'StringTrim'))->addMultiOptions(array(NULL => 'Choose denomination type', 'Available denominations' => $denom_options))->addValidator('inArray', false, array(array_keys($denom_options)))->setDecorators($decorators); //Primary ruler $ruler = new Zend_Form_Element_Select('ruler'); $ruler->setLabel('Ruler / issuer: ')->setRequired(false)->addFilters(array('StripTags', 'StringTrim'))->addMultiOptions(array(NULL => 'Choose primary ruler', 'Available rulers' => $ruler_options))->addValidator('inArray', false, array(array_keys($denom_options)))->setDecorators($decorators); //Mint $mint = new Zend_Form_Element_Select('mint'); $mint->setLabel('Issuing mint: ')->setRequired(false)->addFilters(array('StripTags', 'StringTrim'))->addMultiOptions(array(NULL => 'Choose issuing mint', 'Available mints' => $mint_options))->addValidator('inArray', false, array(array_keys($mint_options)))->setDecorators($decorators); //Secondary ruler $ruler2 = new Zend_Form_Element_Select('ruler2'); $ruler2->setLabel('Secondary ruler / issuer: ')->setRequired(false)->addFilters(array('StripTags', 'StringTrim'))->addMultiOptions(array(NULL => 'Choose secondary ruler', 'Available rulers' => $ruler_options))->addValidator('inArray', false, array(array_keys($ruler_options)))->setDecorators($decorators); //Obverse inscription $obverseinsc = new Zend_Form_Element_Text('obverseLegend'); $obverseinsc->setLabel('Obverse inscription contains: ')->setRequired(false)->addFilters(array('StripTags', 'StringTrim'))->addErrorMessage('Please enter a valid term')->setDecorators($decorators); //Obverse description $obversedesc = new Zend_Form_Element_Text('obverseDescription'); $obversedesc->setLabel('Obverse description contains: ')->setRequired(false)->addFilters(array('StripTags', 'StringTrim'))->addErrorMessage('Please enter a valid term')->setDecorators($decorators); //reverse inscription $reverseinsc = new Zend_Form_Element_Text('reverseLegend'); $reverseinsc->setLabel('Reverse inscription contains: ')->setRequired(false)->addFilters(array('StripTags', 'StringTrim'))->addErrorMessage('Please enter a valid term')->setDecorators($decorators); //reverse description $reversedesc = new Zend_Form_Element_Text('reverseDescription'); $reversedesc->setLabel('Reverse description contains: ')->setRequired(false)->addFilters(array('StripTags', 'StringTrim'))->addErrorMessage('Please enter a valid term')->setDecorators($decorators); //Die axis $axis = new Zend_Form_Element_Select('axis'); $axis->setLabel('Die axis measurement: ')->setRequired(false)->addFilters(array('StripTags', 'StringTrim'))->addMultiOptions(array(NULL => 'Choose measurement', 'Available die axes' => $axis_options))->addValidator('inArray', false, array(array_keys($axis_options)))->addErrorMessage('That option is not a valid choice')->addValidator('Int')->setDecorators($decorators); //Tribe $tribe = new Zend_Form_Element_Select('tribe'); $tribe->setLabel('Iron Age tribe: ')->setRequired(false)->addFilters(array('StripTags', 'StringTrim'))->addMultiOptions(array(NULL => 'Choose a tribe', 'Available tribes' => $tribe_options))->addValidator('inArray', false, array(array_keys($tribe_options)))->addErrorMessage('That option is not a valid choice')->addValidator('Int')->setDecorators($decorators); $objecttype = new Zend_Form_Element_Hidden('objecttype'); $objecttype->setValue('COIN')->setAttrib('class', 'none')->addFilters(array('StripTags', 'StringTrim'))->addValidator('Alpha', false, array('allowWhiteSpace' => true))->removeDecorator('DtDdWrapper')->removeDecorator('HtmlTag')->removeDecorator('Label'); $broadperiod = new Zend_Form_Element_Hidden('broadperiod'); $broadperiod->setValue('IRON AGE')->addValidator('Alnum', false, array('allowWhiteSpace' => true))->setAttrib('class', 'none')->addFilters(array('StripTags', 'StringTrim'))->removeDecorator('DtDdWrapper')->removeDecorator('HtmlTag')->removeDecorator('Label'); $mack_type = new Zend_Form_Element_Text('mackType'); $mack_type->setLabel('Mack Type: ')->setDecorators($decorators)->addFilters(array('StripTags', 'StringTrim'))->addValidator('Alnum', false, array('allowWhiteSpace' => true)); $bmc_type = new Zend_Form_Element_Text('bmc'); $bmc_type->setLabel('British Museum catalogue number: ')->setDecorators($decorators)->addFilters(array('StripTags', 'StringTrim'))->addValidator('Alnum', false, array('allowWhiteSpace' => true)); $allen_type = new Zend_Form_Element_Text('allenType'); $allen_type->setLabel('Allen Type: ')->setDecorators($decorators)->addFilters(array('StripTags', 'StringTrim'))->addValidator('Alnum', false, array('allowWhiteSpace' => true)); $va_type = new Zend_Form_Element_Text('vaType'); $va_type->setLabel('Van Arsdell Number: ')->setDecorators($decorators)->addFilters(array('StripTags', 'StringTrim'))->addValidator('Alnum', false, array('allowWhiteSpace' => true)); $rudd_type = new Zend_Form_Element_Text('ruddType'); $rudd_type->setLabel('Ancient British Coinage number: ')->setDecorators($decorators)->addFilters(array('StripTags', 'StringTrim'))->addValidator('Alnum', false, array('allowWhiteSpace' => true)); $phase_date_1 = new Zend_Form_Element_Text('phase_date_1'); $phase_date_1->setLabel('Phase date 1: ')->setDecorators($decorators)->addFilters(array('StripTags', 'StringTrim'))->addValidator('Alnum', false, array('allowWhiteSpace' => true)); $phase_date_2 = new Zend_Form_Element_Text('phase_date_2'); $phase_date_2->setLabel('Phase date 2: ')->setDecorators($decorators)->addFilters(array('StripTags', 'StringTrim'))->addValidator('Alnum', false, array('allowWhiteSpace' => true)); $context = new Zend_Form_Element_Text('context'); $context->setLabel('Context of coins: ')->setDecorators($decorators)->addFilters(array('StripTags', 'StringTrim'))->addValidator('Alnum', false, array('allowWhiteSpace' => true)); $depositionDate = new Zend_Form_Element_Text('depositionDate'); $depositionDate->setLabel('Date of deposition: ')->setDecorators($decorators)->addFilters(array('StripTags', 'StringTrim'))->addValidator('Alnum', false, array('allowWhiteSpace' => true)); $numChiab = new Zend_Form_Element_Text('numChiab'); $numChiab->setLabel('Coin hoards of Iron Age Britain number: ')->setDecorators($decorators)->addFilters(array('StripTags', 'StringTrim'))->addValidator('Alnum', false, array('allowWhiteSpace' => true)); //Submit button $submit = new Zend_Form_Element_Submit('submit'); $submit->setAttrib('id', 'submit')->setAttrib('class', 'large')->setLabel('Submit your search...'); $institution = new Zend_Form_Element_Select('institution'); $institution->setLabel('Recording institution: ')->setRequired(false)->addFilters(array('StringTrim', 'StripTags'))->addMultiOptions(array(NULL => NULL, 'Choose institution' => $inst_options))->setDecorators($decorators); $hash = new Zend_Form_Element_Hash('csrf'); $hash->setValue($this->_config->form->salt)->removeDecorator('DtDdWrapper')->removeDecorator('HtmlTag')->removeDecorator('label')->setTimeout(4800); $this->addElement($hash); $this->addElements(array($old_findID, $description, $workflow, $rally, $rallyID, $hoard, $hoardID, $county, $regionID, $district, $parish, $fourFigure, $gridref, $denomination, $ruler, $mint, $axis, $obverseinsc, $obversedesc, $reverseinsc, $reversedesc, $ruler2, $tribe, $objecttype, $broadperiod, $geographyID, $bmc_type, $mack_type, $allen_type, $va_type, $rudd_type, $numChiab, $context, $depositionDate, $phase_date_1, $phase_date_2, $submit, $institution)); $this->addDisplayGroup(array('denomination', 'geographyID', 'ruler', 'ruler2', 'tribe', 'mint', 'axis', 'obverseLegend', 'obverseDescription', 'reverseLegend', 'reverseDescription', 'bmc', 'vaType', 'allenType', 'ruddType', 'mackType', 'numChiab', 'context', 'phase_date_1', 'phase_date_2', 'depositionDate'), 'numismatics')->removeDecorator('HtmlTag'); $this->numismatics->addDecorators(array('FormElements', array('HtmlTag', array('tag' => 'ul')))); $this->numismatics->removeDecorator('DtDdWrapper'); $this->numismatics->setLegend('Numismatic details: '); $this->addDisplayGroup(array('old_findID', 'description', 'rally', 'rallyID', 'hoard', 'hID', 'workflow'), 'details')->removeDecorator('HtmlTag'); $this->details->addDecorators(array('FormElements', array('HtmlTag', array('tag' => 'ul')))); $this->details->removeDecorator('DtDdWrapper'); $this->details->setLegend('Object details: '); $this->addDisplayGroup(array('county', 'regionID', 'district', 'parish', 'gridref', 'fourFigure', 'institution'), 'spatial')->removeDecorator('HtmlTag'); $this->spatial->addDecorators(array('FormElements', array('HtmlTag', array('tag' => 'ul')))); $this->spatial->removeDecorator('DtDdWrapper'); $this->spatial->setLegend('Spatial details: '); $this->addDisplayGroup(array('submit'), 'submit'); $this->submit->removeDecorator('DtDdWrapper'); $this->submit->removeDecorator('HtmlTag'); }
/** The constructor * @access public * @param array $options * @return void */ public function __construct(array $options = null) { // Construct the select menu data $denominations = new Denominations(); $denomination_options = $denominations->getOptionsIronAge(); $statuses = new Statuses(); $status_options = $statuses->getCoinStatus(); $dies = new Dieaxes(); $die_options = $dies->getAxes(); $wears = new WearTypes(); $wear_options = $wears->getWears(); $rulers = new Rulers(); $ro = $rulers->getIronAgeRulers(); $mints = new Mints(); $mint_options = $mints->getIronAgeMints(); $tribes = new Tribes(); $to = $tribes->getTribes(); $atypes = new AllenTypes(); $atypelist = $atypes->getATypes(); $vatypes = new VanArsdellTypes(); $vatypelist = $vatypes->getVATypesDD(); $macktypes = new MackTypes(); $macktypelist = $macktypes->getMackTypesDD(); $abc = new AbcNumbers(); $abclist = $abc->getTerms(); $regions = new Geography(); $ia_geog = $regions->getIronAgeGeographyDD(); parent::__construct($options); $this->setName('ironagecoin'); $denomination = new Zend_Form_Element_Select('denomination'); $denomination->setLabel('Denomination: ')->setAttrib('class', 'input-xxlarge selectpicker show-menu-arrow')->setRequired(true)->addFilters(array('StripTags', 'StringTrim'))->addMultiOptions(array(null => 'Choose denomination', 'Available options' => $denomination_options))->addValidator('InArray', false, array(array_keys($denomination_options)))->addValidator('Int'); $denomination_qualifier = new Zend_Form_Element_Radio('denomination_qualifier'); $denomination_qualifier->setLabel('Denomination qualifier: ')->addMultiOptions(array('1' => 'Certain', '2' => 'Probably', '3' => 'Possibly'))->setValue(1)->addFilters(array('StripTags', 'StringTrim'))->addValidator('Digits')->setOptions(array('separator' => '')); $geographyID = new Zend_Form_Element_Select('geographyID'); $geographyID->setLabel('Geographic area: ')->setAttrib('class', 'input-xxlarge selectpicker show-menu-arrow')->addMultiOptions(array(null => 'Choose geography', 'Available options' => $ia_geog))->addValidator('InArray', false, array(array_keys($ia_geog)))->addFilters(array('StripTags', 'StringTrim'))->addValidator('Digits'); $geography_qualifier = new Zend_Form_Element_Radio('geography_qualifier'); $geography_qualifier->setLabel('Geographic qualifier: ')->addMultiOptions(array('1' => 'Certain', '2' => 'Probably', '3' => 'Possibly'))->addFilters(array('StripTags', 'StringTrim'))->addValidator('Digits')->setOptions(array('separator' => '')); $ruler_id = new Zend_Form_Element_Select('ruler_id'); $ruler_id->setLabel('Ruler: ')->setAttrib('class', 'input-xxlarge selectpicker show-menu-arrow')->addFilters(array('StripTags', 'StringTrim'))->addValidator('Digits')->addMultiOptions(array(null => 'Choose primary ruler', 'Available rulers' => $ro)); $ruler_qualifier = new Zend_Form_Element_Radio('ruler_qualifier'); $ruler_qualifier->setLabel('Issuer qualifier: ')->addMultiOptions(array('1' => 'Certain', '2' => 'Probably', '3' => 'Possibly'))->addFilters(array('StripTags', 'StringTrim'))->addValidator('Int')->setOptions(array('separator' => '')); $ruler2_id = new Zend_Form_Element_Select('ruler2_id'); $ruler2_id->setLabel('Secondary ruler: ')->setAttrib('class', 'input-xxlarge selectpicker show-menu-arrow')->addFilters(array('StripTags', 'StringTrim'))->addValidator('Int')->addMultiOptions(array(null => 'Choose issuing secondary ruler', 'Available rulers' => $ro))->addValidator('InArray', false, array(array_keys($ro))); $ruler2_qualifier = new Zend_Form_Element_Radio('ruler2_qualifier'); $ruler2_qualifier->setLabel('Secondary issuer qualifier: ')->addMultiOptions(array('1' => 'Certain', '2' => 'Probably', '3' => 'Possibly'))->addFilters(array('StripTags', 'StringTrim'))->addValidator('Int')->setOptions(array('separator' => '')); $mint_id = new Zend_Form_Element_Select('mint_id'); $mint_id->setLabel('Issuing mint: ')->setAttrib('class', 'input-xxlarge selectpicker show-menu-arrow')->setRegisterInArrayValidator(false)->addFilters(array('StripTags', 'StringTrim'))->addValidator('Int')->addMultiOptions(array(null => 'Choose issuing mint', 'Available options' => $mint_options))->addValidator('InArray', false, array(array_keys($mint_options))); $tribe = new Zend_Form_Element_Select('tribe'); $tribe->setLabel('Tribe: ')->setAttrib('class', 'input-xxlarge selectpicker show-menu-arrow')->addFilters(array('StripTags', 'StringTrim'))->addValidator('Int')->setRegisterInArrayValidator(false)->addMultiOptions(array(null => 'Choose tribe', 'Available options' => $to))->addValidator('InArray', false, array(array_keys($to))); $tribe_qualifier = new Zend_Form_Element_Radio('tribe_qualifier'); $tribe_qualifier->setLabel('Tribe qualifier: ')->addMultiOptions(array('1' => 'Certain', '2' => 'Probably', '3' => 'Possibly'))->addFilters(array('StripTags', 'StringTrim'))->addValidator('Int')->setOptions(array('separator' => '')); $status = new Zend_Form_Element_Select('status'); $status->setLabel('Status: ')->addFilters(array('StripTags', 'StringTrim'))->setAttrib('class', 'input-xxlarge selectpicker show-menu-arrow')->addValidator('Int')->setValue(1)->addMultiOptions(array(null => 'Choose coin status', 'Available options' => $status_options))->addValidator('InArray', false, array(array_keys($status_options))); $status_qualifier = new Zend_Form_Element_Radio('status_qualifier'); $status_qualifier->setLabel('Status qualifier: ')->addMultiOptions(array('1' => 'Certain', '2' => 'Probably', '3' => 'Possibly'))->setValue(1)->addFilters(array('StripTags', 'StringTrim'))->addValidator('Digits')->setOptions(array('separator' => '')); $degree_of_wear = new Zend_Form_Element_Select('degree_of_wear'); $degree_of_wear->setLabel('Degree of wear: ')->setAttrib('class', 'input-xxlarge selectpicker show-menu-arrow')->addFilters(array('StripTags', 'StringTrim'))->addValidator('Digits')->addMultiOptions(array(null => 'Choose wear status', 'Available options' => $wear_options))->addValidator('InArray', false, array(array_keys($wear_options))); $obverse_inscription = new Zend_Form_Element_Text('obverse_inscription'); $obverse_inscription->setLabel('Obverse inscription: ')->addFilters(array('StripTags', 'StringTrim'))->setAttribs(array('rows' => 8, 'cols' => 80, 'class' => 'span6')); $reverse_inscription = new Zend_Form_Element_Text('reverse_inscription'); $reverse_inscription->setLabel('Reverse inscription: ')->addFilters(array('StripTags', 'StringTrim'))->setAttribs(array('rows' => 8, 'cols' => 80, 'class' => 'span6')); $obverse_description = new Zend_Form_Element_Textarea('obverse_description'); $obverse_description->setLabel('Obverse description: ')->setAttribs(array('rows' => 8, 'cols' => 80, 'class' => 'span6'))->addFilters(array('StripTags', 'StringTrim', 'BasicHtml', 'EmptyParagraph')); $reverse_description = new Zend_Form_Element_Textarea('reverse_description'); $reverse_description->setLabel('Reverse description: ')->setAttribs(array('rows' => 8, 'cols' => 80, 'class' => 'span6'))->addFilters(array('StripTags', 'StringTrim', 'BasicHtml', 'EmptyParagraph')); $die_axis_measurement = new Zend_Form_Element_Select('die_axis_measurement'); $die_axis_measurement->setLabel('Die axis measurement: ')->setAttrib('class', 'input-xxlarge selectpicker show-menu-arrow')->addMultiOptions(array(null => 'Choose die axis', 'Available options' => $die_options))->addValidator('InArray', false, array(array_keys($die_options))); $die_axis_certainty = new Zend_Form_Element_Radio('die_axis_certainty'); $die_axis_certainty->setLabel('Die axis certainty: ')->addMultiOptions(array('1' => 'Certain', '2' => 'Probably', '3' => 'Possibly'))->addFilters(array('StripTags', 'StringTrim'))->addValidator('Int')->setOptions(array('separator' => '')); $mack_type = new Zend_Form_Element_Select('mack_type'); $mack_type->setLabel('Mack Type: ')->addFilters(array('StripTags', 'StringTrim'))->setAttrib('class', 'input-xxlarge selectpicker show-menu-arrow')->addMultiOptions(array(null => 'Choose a Mack type', 'Valid types' => $macktypelist))->addValidator('InArray', false, array(array_keys($macktypelist))); $bmc_type = new Zend_Form_Element_Text('bmc_type'); $bmc_type->setLabel('British Museum catalogue number: ')->addFilters(array('StripTags', 'StringTrim', 'Purifier')); $allen_type = new Zend_Form_Element_Select('allen_type'); $allen_type->setLabel('Allen Type: ')->addFilters(array('StripTags', 'StringTrim'))->setAttrib('class', 'input-xxlarge selectpicker show-menu-arrow')->addMultiOptions(array(null => 'Choose an Allen type', 'Valid types' => $atypelist))->addValidator('InArray', false, array(array_keys($atypelist))); $va_type = new Zend_Form_Element_Select('va_type'); $va_type->setLabel('Van Arsdell Number: ')->addFilters(array('StripTags', 'StringTrim'))->setAttrib('class', 'input-xxlarge selectpicker show-menu-arrow')->addMultiOptions(array(null => 'Choose Van Arsdell type', 'Valid types' => $vatypelist))->addValidator('InArray', false, array(array_keys($vatypelist))); $cciNumber = new Zend_Form_Element_Text('cciNumber'); $cciNumber->setLabel('Celtic Coin Index Number: ')->setAttrib('size', 12)->addFilters(array('StripTags', 'StringTrim'))->setDescription('This is the coin\'s unique CCI number, not a ' . 'comparison field. Numbers are issued by the CCI.'); $rudd_type = new Zend_Form_Element_Select('rudd_type'); $rudd_type->setLabel('Ancient British Coinage number: ')->setAttrib('class', 'input-xxlarge selectpicker show-menu-arrow')->addFilters(array('StripTags', 'StringTrim', 'Purifier'))->addMultiOptions(array(null => 'Choose ABC number', 'Valid types' => $abclist))->addValidator('InArray', false, array(array_keys($abclist))); $phase_date_1 = new Zend_Form_Element_Text('phase_date_1'); $phase_date_1->setLabel('Phase date 1: ')->addFilters(array('StripTags', 'StringTrim', 'Purifier')); $phase_date_2 = new Zend_Form_Element_Text('phase_date_2'); $phase_date_2->setLabel('Phase date 2: ')->addFilters(array('StripTags', 'StringTrim', 'Purifier')); $context = new Zend_Form_Element_Text('context'); $context->setLabel('Context of coins: ')->addFilters(array('StripTags', 'StringTrim', 'Purifier')); $depositionDate = new Zend_Form_Element_Text('depositionDate'); $depositionDate->setLabel('Date of deposition: ')->addFilters(array('StripTags', 'StringTrim', 'Purifier')); $numChiab = new Zend_Form_Element_Text('numChiab'); $numChiab->setLabel('Coin hoards of Iron Age Britain number: ')->addFilters(array('StripTags', 'StringTrim', 'Purifier')); $submit = new Zend_Form_Element_Submit('submit'); $this->addElements(array($ruler_id, $ruler_qualifier, $denomination, $denomination_qualifier, $mint_id, $ruler2_id, $ruler2_qualifier, $geographyID, $geography_qualifier, $status, $status_qualifier, $degree_of_wear, $obverse_description, $obverse_inscription, $reverse_description, $reverse_inscription, $die_axis_measurement, $die_axis_certainty, $tribe, $tribe_qualifier, $bmc_type, $mack_type, $allen_type, $va_type, $rudd_type, $cciNumber, $numChiab, $context, $depositionDate, $phase_date_1, $phase_date_2, $submit)); $this->addDisplayGroup(array('denomination', 'denomination_qualifier', 'geographyID', 'geography_qualifier', 'tribe', 'tribe_qualifier', 'ruler_id', 'ruler_qualifier', 'ruler2_id', 'ruler2_qualifier', 'mint_id', 'status', 'status_qualifier', 'degree_of_wear', 'obverse_description', 'obverse_inscription', 'reverse_description', 'reverse_inscription', 'die_axis_measurement', 'die_axis_certainty', 'bmc_type', 'va_type', 'allen_type', 'rudd_type', 'mack_type', 'cciNumber', 'numChiab', 'context', 'phase_date_1', 'phase_date_2', 'depositionDate'), 'details'); $this->addDisplayGroup(array('submit'), 'buttons'); parent::init(); }