/**
  * 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);
 }
Exemplo n.º 2
0
 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;
     }
 }