public function getProperties($empty = null) { if ($empty == null) { $categoryId = $this->input->post('category'); $categoryId = (int) $categoryId[0]; $categoryModel = SCategoryQuery::create()->findPk((int) $categoryId); $properties = SPropertiesQuery::create()->joinWithI18n('ru')->filterByPropertyCategory($categoryModel)->orderByPosition()->find(); $this->db->select('property_id, value'); $this->db->where('category_id', $categoryId); $this->db->order_by('property_order', 'asc'); $query = $this->db->get('mod_hotline_properties'); $arr = $query->result_array(); if (count($properties) == 0) { echo "<p style='margin-left:20px;'>" . lang('no properties', 'hotline') . "</p>"; exit; } if (count($arr) > 0) { $properties1 = ''; foreach ($arr as $key => $value1) { $properties1 .= "<div class='over' style='padding-bottom:10px; overflow:hidden; clear:both'><div style='float:left;width:180px;'><input name='name_properties' value='" . $value1['value'] . "' type='text' class='form-control'></div>"; $properties1 .= "<div style='float:right; width:280px;'>"; $properties1 .= "<select style='width:200px; margin-right:10px;' name='displayedProperties'>"; $selected = ''; foreach ($properties as $key => $value) { if ($value1['property_id'] == $value->getId()) { $selected = 'selected'; } $properties1 .= "<option " . $selected . " value=" . $value->getId() . ">" . $value->getName() . "</option>"; $selected = ''; } $properties1 .= "</select><button type='button' class='btn btn-small btn-danger del_item'><i class='icon-trash icon-white'></i></button></div></div>"; } $properties1 .= "<div class='but_clear' style='clear:both; height:10px;'></div><button type='button' class='btn btn-small btn-success empty'><i class='icon-plus-sign icon-white'></i> " . lang('Add property', 'hotline') . "</button><br /><button style='margin-top:5px;' data-form='#settings_form_properties' type='button' class='btn btn-small btn-primary save_btn'><i class='icon-ok'></i> Сохранить</button>"; return $properties1; } else { $properties1 = "<div class='over' style='padding-bottom:10px; overflow:hidden; clear:both'><div style='float:left;width:180px;'><input name='name_properties' value='' type='text' class='form-control'></div>"; $properties1 .= "<div style='float:right; width:280px;'>"; $properties1 .= "<select style='width:200px; margin-right:10px;' name='displayedProperties'>"; foreach ($properties as $key => $value) { $properties1 .= "<option value=" . $value->getId() . ">" . $value->getName() . "</option>"; } $properties1 .= "</select><button type='button' class='btn btn-small btn-danger del_item'><i class='icon-trash icon-white'></i></button></div></div>"; $properties1 .= "<div class='but_clear' style='clear:both; height:10px;'></div><button type='button' class='btn btn-small btn-success empty'><i class='icon-plus-sign icon-white'></i> " . lang('Add property', 'hotline') . "</button><br /><button style='margin-top:5px;' data-form='#settings_form_properties' type='button' class='btn btn-small btn-primary save_btn'><i class='icon-ok'></i> Сохранить</button>"; return $properties1; } } else { $categoryId = $this->input->post('category'); $categoryModel = SCategoryQuery::create()->findPk((int) $categoryId); $properties = SPropertiesQuery::create()->joinWithI18n('ru')->filterByPropertyCategory($categoryModel)->orderByPosition()->find(); if (count($properties) > 0) { $properties1 = "<div class='over' style='padding-bottom:10px; overflow:hidden; clear:both'><div style='float:left;width:180px;'><input value='' name='name_properties' type='text' class='form-control'></div>"; $properties1 .= "<div style='float:right; width:280px;'>"; $properties1 .= "<select style='width:200px; margin-right:10px;' name='displayedProperties'>"; foreach ($properties as $key => $value) { $properties1 .= "<option value=" . $value->getId() . ">" . $value->getName() . "</option>"; } $properties1 .= "</select><button type='button' class='btn btn-small btn-danger del_item'><i class='icon-trash icon-white'></i></button></div></div>"; return $properties1; } else { echo "<p style='margin-left:20px;'>" . lang('is empty!', 'hotline') . "</p"; } } }
/** * Data Autocomplete * @access public * @author L.Andriy <*****@*****.**> * @copyright (c) 2013, ImageCMS */ public function autosearch() { switch ($this->input->post('queryString')) { case 'product': $entity = SProductsQuery::create()->joinWithI18n($this->def_locale)->filterByActive(true)->withColumn('SProductsI18n.Name', 'Name')->select(array('Id', 'Name'))->find()->toArray(); break; case 'shop_category': $entity = SCategoryQuery::create()->joinWithI18n($this->def_locale)->withColumn('SCategoryI18n.Name', 'Name')->select(array('Id', 'Name'))->find()->toArray(); break; case 'brand': $entity = SBrandsQuery::create()->joinWithI18n($this->def_locale)->withColumn('SBrandsI18n.Name', 'Name')->select(array('Id', 'Name'))->find()->toArray(); break; case 'category': $entity = $this->db->select('id as Id')->select('name as Name')->get('category')->result_array(); break; case 'page': $entity = $this->db->select('id as Id')->select('title as Name')->get('content')->result_array(); break; case 'main': $entity = array(array('Id' => 0, 'Name' => lang('Main', 'banners'))); break; default: break; } /** Show template with data */ \CMSFactory\assetManager::create()->setData('entity', $entity)->render($this->input->post('tpl'), TRUE); }
function get_entity_mod($w) { $ci =& get_instance(); switch ($w) { case $w == 'product_0': return 'product - all'; break; case $w == 'shop_category_0': return 'shop_category - all'; break; case $w == 'brand_0': return 'brand - all'; break; case $w == 'category_0': return 'category - all'; break; case $w == 'page_0': return 'page - all'; break; case strstr($w, 'product'): $id = (int) str_replace('product_', '', $w); $prod = SProductsQuery::create()->findPk($id); if ($prod) { return 'product - ' . $prod->getName(); } break; case strstr($w, 'shop_category'): $id = (int) str_replace('shop_category_', '', $w); $cat = SCategoryQuery::create()->findPk($id); if ($cat) { return 'shop_category - ' . $cat->getName(); } break; case strstr($w, 'brand'): $id = (int) str_replace('brand_', '', $w); $br = SBrandsQuery::create()->findPk($id); if ($br) { return 'brand - ' . $br->getName(); } break; case strstr($w, 'page'): $id = (int) str_replace('page_', '', $w); $page = $ci->db->where('id', $id)->get('content')->result_array(); if (count($page) > 0) { return 'page - ' . $page[0]['title']; } break; case strstr($w, 'category'): $id = (int) str_replace('category_', '', $w); $page = $ci->db->where('id', $id)->get('category')->result_array(); if (count($page) > 0) { return 'category - ' . $page[0]['name']; } break; case strstr($w, 'main'): return 'main - ' . lang('Main', 'banners'); break; default: break; } }