getMain(); } public function getUrl() { return '/'. $this->getSlug(); } public function getLink($html_options = array()) { sfLoader::loadHelpers('Url'); return link_to($this->getName(), $this->getUrl(), $html_options); } public function getName() { return $this->_get('name'); } public function isParent() { return is_null($this->getParentId()); } public function isChildSlug($slug) { $result = $this->getTable() ->createQuery() ->where('parent_id = ?', $this->getId()) ->andWhere('slug = ?', $slug) ->fetchOne(); return !($result == false); } public function hasPosterity() { return count($this->getPosterity()) > 0; } public function getPosterity() { return $this->getTable() ->createQuery() ->where('parent_id = ?', $this->getId()) ->addOrderBy('priority DESC') ->execute(); } public function getTitle() { return $this->getName(); } public function getPermission() { return $this->_get('permission'); } public function getProductParameters() { //switch($this->getSlug()) switch($this->getId()) { case 3: //'vibracni-pechy': return array('gear', 'balance', 'code', 'stock', 'price'); case 2: //'vibracni-desky': return array('gear', 'balance', 'code', 'stock', 'price'); case 4: //'rezace-spar': return array('gear', 'diameter_disc', 'code', 'stock', 'price'); case 5: //'diamantove-kotouce': return array('application', 'cooling', 'type_note', 'diameter_disc', 'code', 'stock', 'price'); case 6: //'korunky': return array('application', 'diameter_disc', 'code', 'stock', 'price'); case 15: //'o-krouzky': return array('material', 'diameter_in', 'balance', 'code', 'stock', 'price'); case 16: //'manzety': return array('material', 'type_note', 'application', 'diameter_in', 'diameter_out', 'line_width', 'code', 'stock', 'price'); case 17: //'stiraci-krouzky': return array('material', 'type_note', 'application', 'diameter_in', 'diameter_out', 'line_width', 'code', 'stock', 'price'); case 18: //'gufera': return array('material', 'type_note', 'application', 'diameter_in', 'diameter_out', 'line_width', 'code', 'stock', 'price'); case 19: //'vodici-krouzky': return array('code', 'stock', 'price'); case 20: //'tesnici-krouzky': return array('code', 'stock', 'price'); case 11: //'manometry': return array('diameter', 'type_note', 'whorl', 'extensity', 'code', 'stock', 'price'); case 13: //'klinove-remeny': return array('profile', 'width', 'length', 'code', 'stock', 'price'); case 12: //'hydraulicke-naradi-a-zvedaky': case 68: case 69: case 70: return array('type_note', 'tonnage_str', 'min_height', 'max_height', 'code', 'stock', 'price'); case 9: //'hadice': return array('gap', 'compression', 'medium', 'code', 'stock', 'price'); case 10: //'hydraulicka-sroubeni': return array('gap', 'compression', 'whorl', 'code', 'stock', 'price'); case 21: //'vysokozdvizne-voziky-celni': return array('producer', 'tonnage', 'uplift_str', 'gear', 'code', 'stock', 'price'); case 72: case 73: case 64: //'vysokozdvizne-voziky-terenni': return array('producer', 'tonnage', 'uplift_str', 'gear', 'code', 'stock', 'price'); case 22: //'vysokozdvizne-voziky-bocni': return array('producer', 'tonnage', 'uplift_str', 'gear', 'code', 'stock', 'price'); case 23: //'vysokozdvizne-voziky-ctyrcestne': return array('producer', 'tonnage', 'uplift_str', 'gear', 'code', 'stock', 'price'); case 25: //'specialni-manipulacni-technika': return array('producer', 'type_note', 'tonnage', 'uplift_str', 'gear', 'code', 'stock', 'price'); case 26: //'hlinikove-najezdy': return array('tonnage_couple', 'length', 'width', 'code', 'stock', 'price'); case 28: //'prodlouzene-vidle': return array('tonnage_car', 'width_prong_car', 'weight_prong_car', 'length_prong_car', 'length_extended_prong_car', 'code', 'stock', 'price'); case 29: //'jerabove-zavesy': return array('tonnage_car', 'width_prong_car', 'weight_prong_car', 'code', 'stock', 'price'); case 30: //'bocni-posuvy': return array('producer', 'tonnage_car', 'drift_width', 'desk_iso', 'code', 'stock', 'price'); case 31: //'pily-stolni': return array('board', 'diameter_disc', 'code', 'stock', 'price'); case 32: //'vrtacky-jadrove': return array('diameter_str', 'type_note', 'code', 'stock', 'price'); case 33: //'freza-povrchu': return array('gear', 'width_mesh', 'type_note', 'code', 'stock', 'price'); case 34: //'vibrator': return array('gear', 'diameter_str', 'code', 'stock', 'price'); case 35: //'hladicka-betonu': return array('diameter', 'type_note', 'code', 'stock', 'price'); case 36: //'lista-vibracni': return array('gear', 'length', 'code', 'stock', 'price'); case 37: //'lamacka-dlazby': return array('length_fracture', 'code', 'stock', 'price'); case 38: //'michacka-betonu': return array('size', 'code', 'stock', 'price'); case 39: //'diamantove-brusne-kotouce': return array('type_note', 'diameter_disc', 'code', 'stock', 'price'); case 40: //'diamantove-hvezdice': return array('type_note', 'code', 'stock', 'price'); case 41: //'bruska-betonu': return array('type_note', 'code', 'stock', 'price'); case 71: case 46: //'bazar-vysokozdvizne-voziky': return array('tonnage', 'uplift', 'gear', 'producer', 'year', 'moto_hours', 'code', 'stock', 'price'); case 47: //'rucni-technika': return array('tonnage', 'uplift', 'gear', 'year', 'code', 'stock', 'price'); case 45: //'samohybne-pracovni-plosiny': return array('type_note', 'gear', 'operative_height', 'tonnage', 'length', 'width', 'height', 'weight', 'code', 'stock', 'price'); case 50: //'samohybne-pracovni-plosiny-2': return array('type_note', 'uplift', 'gear', 'code', 'stock', 'price'); case 48: //'skladova-technika': case 49: //'skladova-technika-1': return array(); case 52: //'nizkozdvizne-voziky-rucne-vedene': case 53: //'vysokozdvizne-voziky-rucne-vedene': case 54: //'retraky': case 55: //'vychystavaci-voziky': case 56: //'ostatni-skladova-technika': return array('producer', 'type_note', 'tonnage', 'uplift_str', 'gear', 'price'); case 57: //'paletove-voziky': return array('producer', 'type_note', 'tonnage', 'length', 'price'); case 58: //'rucni-vysokozdvizne-voziky': return array('producer', 'type_note', 'tonnage', 'uplift', 'price'); case 59: //'rudly': return array('producer', 'type_note', 'tonnage', 'dipper_size', 'wheel_diameter', 'price'); case 60: //'stoly': return array('producer', 'type_note', 'tonnage', 'desk_size', 'price'); case 61: //'plosinove-voziky': return array('producer', 'type_note', 'tonnage', 'loading_area', 'price'); case 62: //'transportni-podvozky': return array('type_note', 'tonnage', 'price'); case 63: //'ostatni-rucni-technika': return array('producer', 'tonnage', 'uplift_str', 'code', 'stock', 'price'); case 66: //'bazar-pouzite-rolby': return array('gear', 'modifications', 'weight', 'snow_capacity', 'water_capacity', 'code', 'stock', 'price'); case 67: //'bazar-pouzite-orezavace': return array('gear', 'cut_depth', 'code', 'stock', 'price'); default: return array(); } } /* * Lucene vyhledavani */ public function save(Doctrine_Connection $conn = null) { // ... $ret = parent::save($conn); $this->updateLuceneIndex(); return $ret; } public function updateLuceneIndex() { $index = $this->getTable()->getLuceneIndex(); // remove existing entries foreach ($index->find('pk:'.$this->getId()) as $hit) { $index->delete($hit->id); } $doc = new Zend_Search_Lucene_Document(); // store job primary key to identify it in the search results $doc->addField(Zend_Search_Lucene_Field::Keyword('pk', $this->getId())); // index job fields $doc->addField(Zend_Search_Lucene_Field::UnStored('name', $this->name, 'UTF-8')); $doc->addField(Zend_Search_Lucene_Field::UnStored('description', $this->description, 'UTF-8')); // add job to the index $index->addDocument($doc); $index->commit(); } public function getFulltextFields() { return array($this->description); } public function getMetaDescription() { return !empty($this->meta_desc) ? $this->meta_desc : $this->getName().', '.substr(trim(strip_tags($this->getDescription())), 0, 100); } public function getMetaKeywords() { if (!empty($this->meta_kw)) { return $this->meta_kw; } else { if(!is_null($this->getParentId())) { if($Parent = Doctrine::getTable('Equipment')->findOneById($this->getParentId())) { return $this->getName().', '.$Parent->getName(); } } else { return $this->getName(); } } } public function hasPrice() { $arr = $this->getProductParameters(); return in_array('price', $arr); } public function isInBazaar() { return $this->getParentId() == 44; } public function getPermissionObject() { return Doctrine::getTable('sfGuardPermission')->createQuery() ->addWhere('name =?', $this->getPermission()) ->fetchOne(); } public function __get($name) { if($name == 'request_emails' && strlen(parent::__get($name)) == 0) { return sfConfig::get('app_request_emails'); } if($name == 'indent_emails' && strlen(parent::__get($name)) == 0) { return sfConfig::get('app_indent_emails'); } return parent::__get($name); } /* * Vrací defaultni zobrazeni seznamu produktů pro kategorii - table/mini */ public function getListView() { // $mini = array(21,64,23,52,53,54,55,56,57,58,59,60,46,47,3,2,31,32,33,34,35,37,38,5,12); // // if(in_array($this->getId(), $mini)) // { // return 'mini'; // } return 'mini'; } public function getProducts() { return Doctrine::getTable('Product')->findByEquipmentId($this->getId()); } public function getSort() { if(in_array('tonnage', $this->getProductParameters())) { return array('tonnage', 'desc'); } return array('name', 'asc'); } }