public function language_switch_show($widget = array())
 {
     if ($widget['settings'] == FALSE) {
         $settings = $this->defaults;
     } else {
         $settings = $widget['settings'];
     }
     $current_address = '';
     $current_address .= $this->uri->uri_string();
     if ($this->input->server('QUERY_STRING')) {
         $current_address .= '?' . $this->input->server('QUERY_STRING');
     }
     if ($this->uri->segment(1)) {
         if (array_key_exists($this->uri->segment(1), $this->core->langs)) {
             $current_address = substr_replace($current_address, '', 0, strlen($this->uri->segment(1)));
         } else {
             $current_address = '/' . $current_address;
         }
     }
     $languages = $this->db->get('languages')->result_array();
     foreach ($languages as $key => $lang) {
         if ($lang['identif'] == MY_Controller::getCurrentLocale()) {
             $languages[$key]['current'] = 1;
         } else {
             $languages[$key]['current'] = 0;
         }
     }
     return $this->template->fetch('widgets/' . $widget['name'], array('languages' => $languages, 'current_address' => $current_address));
 }
Exemple #2
0
 /**
  * Run widget
  *
  * @param string $name - widget name
  * @param integer $cache - cache ttl in minutes
  */
 function widget($name = FALSE, $cache = FALSE)
 {
     $ci =& get_instance();
     $query = $ci->db->limit(1)->get_where('widgets', array('name' => $name));
     if ($query->num_rows() == 1) {
         $widget = $query->row_array();
     } else {
         log_message('error', 'Can\'t run widget <b>' . $name . '</b>');
     }
     if (($data = $ci->cache->fetch('widget' . $name, 'widgets')) != FALSE and $cache != FALSE) {
         return $data;
     } else {
         $widget['settings'] = unserialize($widget['settings']);
         switch ($widget['type']) {
             case 'module':
                 $subpath = isset($widget['settings']['subpath']) ? $widget['settings']['subpath'] . '/' : '';
                 $result = $ci->load->module($widget['data'] . '/' . $subpath . $widget['data'] . '_widgets')->{$widget}['method']($widget);
                 break;
             case 'html':
                 $locale = MY_Controller::getCurrentLocale();
                 $id = $widget['id'];
                 $sql = "select * from widget_i18n where locale = '{$locale}' and id = '{$id}'";
                 $w_i18 = $ci->db->query($sql)->row_array();
                 $result = $w_i18['data'];
                 break;
         }
         if ($cache != FALSE and is_integer($cache)) {
             $ci->cache->store('widget' . $name, $result, $cache * 60, 'widgets');
         }
         return $result;
     }
 }
 /**
  * get all activ discount
  * @return array discount
  */
 public function getDiscount()
 {
     $locale = \MY_Controller::getCurrentLocale();
     $time = time();
     $sql = "select *, mod_shop_discounts.id as ids, mod_shop_discounts.id as id\n                from mod_shop_discounts\n                left join mod_shop_discounts_i18n on mod_shop_discounts_i18n.id = mod_shop_discounts.id and mod_shop_discounts_i18n.locale = '{$locale}'\n                where (max_apply > count_apply \n                        or max_apply is null \n                        or (max_apply is null and count_apply is null)\n                        or (count_apply is null and max_apply > 0))\n                      and \n                      (date_begin < '{$time}' and date_end > '{$time}' \n                          or date_begin < '{$time}' and date_end is Null \n                           or date_begin is Null and date_end is Null\n                           or date_begin < '{$time}' and date_end = '0'\n                           or date_begin is null and date_end = '0')\n                      and \n                       active = 1";
     return $this->db->query($sql)->result_array();
 }
 function getMoFileName($domain)
 {
     if ($domain) {
         if (isset($GLOBALS['MO_FILE_NAMES'][$domain])) {
             return $GLOBALS['MO_FILE_NAMES'][$domain];
         }
         if (!defined('CUR_LOCALE')) {
             $CI =& get_instance();
             if (strstr($_SERVER['REQUEST_URI'], 'install')) {
                 $lang = $CI->config->item('language');
                 $locale = $lang ? $lang : 'ru_RU';
             } else {
                 if (strstr(uri_string(), 'admin')) {
                     $locale = $CI->config->item('language');
                 } else {
                     $currentLocale = MY_Controller::getCurrentLocale();
                     $language = $CI->db->where('identif', $currentLocale)->get('languages')->row_array();
                     $locale = $language['locale'];
                 }
             }
             define('CUR_LOCALE', $locale);
         } else {
             $locale = CUR_LOCALE;
         }
         $name = NULL;
         switch ($domain) {
             case 'main':
                 $searched = glob(correctUrl('./application/language/main/' . $locale) . '/' . $locale . '/LC_MESSAGES/main*.mo');
                 if (!empty($searched)) {
                     $name = str_replace('.mo', '', basename(array_pop($searched)));
                 }
                 break;
             default:
                 if (strstr($domain, 'admin') && MAINSITE) {
                     $begin = MAINSITE;
                 } else {
                     $begin = '.';
                 }
                 //$locale = 'de_DE';
                 $module_path = correctUrl('./application/modules/' . $domain . '/language/' . $locale);
                 if (is_dir($module_path)) {
                     $searched = glob($module_path . '/' . $locale . '/LC_MESSAGES/' . $domain . '*.mo');
                     if (!empty($searched)) {
                         $name = str_replace('.mo', '', basename(array_pop($searched)));
                     }
                 } elseif (file_exists(TEMPLATES_PATH . $domain)) {
                     $searched = glob(TEMPLATES_PATH . $domain . '/language/' . $domain . '/' . $locale . '/LC_MESSAGES/' . $domain . '*.mo');
                     if (!empty($searched)) {
                         $name = str_replace('.mo', '', basename(array_pop($searched)));
                     }
                 }
                 break;
         }
         $GLOBALS['MO_FILE_NAMES'] = $GLOBALS['MO_FILE_NAMES'] ? $GLOBALS['MO_FILE_NAMES'] : array();
         $GLOBALS['MO_FILE_NAMES'][$domain] = $name;
         return $name;
     }
     return FALSE;
 }
 /**
  * Autoload method.
  * 
  * @return void 
  */
 public function autoload()
 {
     $url = ltrim(str_replace('/' . MY_Controller::getCurrentLocale() . '/', '', $this->input->server('REQUEST_URI')), '/');
     //locale fix
     $row = $this->db->where('trash_url', $url)->or_where('trash_url', $this->uri->uri_string())->get('trash')->row();
     if ($row != null) {
         $row->trash_redirect_type != '404' or $this->core->error_404();
         redirect($row->trash_redirect, 'location', $row->trash_type);
     }
 }
Exemple #6
0
 public function getPaternSettings($patern_name)
 {
     $locale = \MY_Controller::getCurrentLocale();
     $query = $this->db->select('*, mod_email_paterns.id as id')->join('mod_email_paterns_i18n', "mod_email_paterns_i18n.id = mod_email_paterns.id and mod_email_paterns_i18n.locale = '{$locale}'", 'left')->where('mod_email_paterns.name', $patern_name)->get('mod_email_paterns');
     if ($query) {
         return $query->row_array();
     } else {
         return '';
     }
 }
Exemple #7
0
 /**
  * Print Product
  * @param int $id
  * @param int $var
  */
 public function print_product($id, $var)
 {
     if (!$this->no_install) {
         return false;
     }
     $product = SProductsQuery::create()->joinWithI18n(MY_Controller::getCurrentLocale())->findPk($id);
     $variant = SProductVariantsQuery::create()->joinWithI18n(MY_Controller::getCurrentLocale())->findPk($var);
     \CMSFactory\assetManager::create()->registerStyleWithoutTemplate('style');
     \CMSFactory\assetManager::create()->setData(array('product' => $product, 'variant' => $variant))->render('print_product', TRUE);
 }
Exemple #8
0
 public function get_one_banner($id, $locale)
 {
     if (!$locale) {
         $locale = MY_Controller::getCurrentLocale();
     }
     $banner = $this->db->query("select * from mod_banner inner join mod_banner_i18n on mod_banner.id = mod_banner_i18n.id where locale = '{$locale}' and mod_banner.id = '{$id}'")->result_array();
     if (count($banner) == 0) {
         return FALSE;
     }
     return $banner[0];
 }
 function getWidgetTitle($name)
 {
     $ci =& get_instance();
     $locale = MY_Controller::getCurrentLocale();
     $query = $ci->db->join('widget_i18n', 'widget_i18n.id=widgets.id AND locale="' . $locale . '"', 'left')->get_where('widgets', array('name' => $name));
     if ($query->num_rows() == 1) {
         $widget = $query->row_array();
         return $widget['title'];
     } else {
         log_message('error', 'Can\'t run widget <b>' . $name . '</b>');
     }
     return '';
 }
Exemple #10
0
 public function getSettings()
 {
     $settings = getSettings();
     if (strstr($_SERVER['HTTP_REFERER'], 'admin')) {
         $langs = $this->config->item('languages');
         $language = $this->config->item('language');
         $locale = $langs[$language][0];
     } else {
         $locale = MY_Controller::getCurrentLocale();
     }
     $settings['curLocale'] = $locale;
     return json_encode($settings);
 }
Exemple #11
0
 function set_tpl_roles()
 {
     // roles
     //$query = $this->db->get('shop_rbac_roles');
     $locale = MY_Controller::getCurrentLocale();
     $this->db->select("shop_rbac_roles.*", FALSE);
     $this->db->select("shop_rbac_roles_i18n.alt_name", FALSE);
     $this->db->where('locale', $locale);
     $this->db->join("shop_rbac_roles_i18n", "shop_rbac_roles_i18n.id = shop_rbac_roles.id");
     $role = $this->db->get('shop_rbac_roles')->result_array();
     //$this->template->assign('roles', $query->result_array());
     $this->template->assign('roles', $role);
     // roles
 }
Exemple #12
0
 /**
  * Setting class variables
  * @param string $locale locale to intiate class with
  */
 public function __construct($locale = NULL)
 {
     if ($this->useLocales == TRUE) {
         $this->locale = !is_null($locale) ? $locale : MY_Controller::getCurrentLocale();
     }
     $locales_ = CI::$APP->db->select('identif,id')->get('languages')->result_array();
     foreach ($locales_ as $row) {
         $this->locales[$row['id']] = $row['identif'];
     }
     // getting data from DB
     $result = CI::$APP->db->select('siteinfo')->get('settings')->row_array();
     $siteinfo = @unserialize($result['siteinfo']);
     if (is_array($siteinfo)) {
         $this->siteinfo = $siteinfo;
     } else {
         // throw new Exception();
     }
 }
 function media_url($url = '')
 {
     $CI =& get_instance();
     /* @var $config CI_Config */
     $config = $CI->config;
     if (is_array($url)) {
         $url = implode('/', $url);
     }
     $index_page = $config->slash_item('index_page');
     if ($index_page === '/') {
         $index_page = '';
     }
     if ($CI->uri->segment(1) == MY_Controller::getCurrentLocale()) {
         $return = rtrim($config->slash_item('base_url'), MY_Controller::getCurrentLocale() . '/') . '/' . $index_page . preg_replace("|^/*(.+?)/*\$|", "\\1", $url);
     } else {
         $return = $config->slash_item('base_url') . $index_page . preg_replace("|^/*(.+?)/*\$|", "\\1", $url);
     }
     return $return;
 }
Exemple #14
0
 public function index()
 {
     $success = FALSE;
     $this->load->library('Form_validation');
     $this->form_validation->set_error_delimiters(FALSE, FALSE);
     $model = new SCallbacks();
     if ($this->input->post()) {
         $this->form_validation->set_message('required', $model->validationMessage('required'));
         $this->form_validation->set_rules($model->rules());
         if ($this->form_validation->run($this) !== FALSE) {
             $theme = SCallbackThemesQuery::create()->orderByPosition()->findOne();
             if ($theme) {
                 $model->setThemeId($theme->getId());
             } else {
                 $model->setThemeId(0);
             }
             $model->fromArray($this->input->post());
             $model->setDate(time());
             $model->setStatusId(SCallbackStatusesQuery::create()->filterByIsDefault(TRUE)->findOne()->getId());
             $model->save();
             $info = array();
             $info['userName'] = $model->getName();
             $info['userPhone'] = $model->getPhone();
             $info['dateCreated'] = $model->getDate();
             $info['callbackStatus'] = $model->getSCallbackStatuses()->getText();
             if ($theme) {
                 $info['callbackTheme'] = $model->getSCallbackThemes()->getText();
             }
             $info['userComment'] = $model->getComment();
             $this->composeAndSendEmail($info);
             $locale = \MY_Controller::getCurrentLocale();
             $notif = $this->db->where('locale', $locale)->where('name', 'callback')->get('answer_notifications')->row();
             $success = $notif->message;
             /** Register event 'category:load' */
             CMSFactory\Events::create()->raiseEvent(['model' => $model], 'Shop:callback');
             echo json_encode(array('msg' => $success, 'status' => true, 'close' => true, 'refresh' => $this->input->post('refresh') ? $this->input->post('refresh') : FALSE, 'redirect' => $this->input->post('redirect') ? $this->input->post('redirect') : FALSE));
         } else {
             echo json_encode(array('msg' => validation_errors(), 'status' => false, 'validations' => array('Name' => form_error('Name'), 'Phone' => form_error('Phone'), 'Comment' => form_error('Comment'))));
         }
     } else {
         echo json_encode(array('msg' => "Ошибка, не достаточно данных", 'status' => false));
     }
 }
Exemple #15
0
 function get_all($offset = 0, $row_count = 0)
 {
     $users_table = $this->_table;
     $roles_table = $this->_roles_table;
     if ($offset >= 0 and $row_count > 0) {
         $locale = MY_Controller::getCurrentLocale();
         $this->db->select("{$users_table}.*", FALSE);
         $this->db->select("{$roles_table}.name AS role_name", FALSE);
         $this->db->select("shop_rbac_roles_i18n.alt_name AS role_alt_name", FALSE);
         $this->db->join($roles_table, "{$roles_table}.id = {$users_table}.role_id", "left");
         $this->db->join("shop_rbac_roles_i18n", "shop_rbac_roles_i18n.id = shop_rbac_roles.id AND shop_rbac_roles_i18n.locale ='{$locale}'", "left");
         //$this->db->where('shop_rbac_roles_i18n.locale', MY_Controller::getCurrentLocale());
         $this->db->order_by("{$users_table}.id", "ASC");
         $query = $this->db->get($this->_table, $row_count, $offset);
     } else {
         $query = $this->db->get($this->_table);
     }
     return $query;
 }
Exemple #16
0
 public static function get_html($file)
 {
     self::$path = PUBPATH . 'system/cache/templates_c/HTML/';
     if (!\CI_Controller::get_instance()->config->item('tpl_force_compile')) {
         $file = $file . MY_Controller::getCurrentLocale();
         $file = self::$path . md5($file) . '.html';
         if (file_exists($file)) {
             if (time() - filemtime($file) > \CI_Controller::get_instance()->config->item('tpl_compiled_ttl')) {
                 @unlink($file);
                 return false;
             } else {
                 return file_get_contents($file);
             }
         } else {
             return false;
         }
     } else {
         return false;
     }
 }
 function create_trash()
 {
     $this->form_validation->set_rules('url', 'Url', 'required');
     $this->db->where('name', 'shop')->get('components');
     if (count($this->db->where('name', 'shop')->get('components')->row()) > 0) {
         $query = $this->db->where('locale', MY_Controller::getCurrentLocale())->order_by('name', 'asc')->get('shop_products_i18n');
         $this->template->add_array(array('products' => $query->result()));
         $this->db->order_by("name", "asc");
         $query = $this->db->where('locale', MY_Controller::getCurrentLocale())->get('shop_category_i18n');
         $this->template->add_array(array('category' => $query->result()));
     }
     //$this->db->order_by("name", "asc");
     //$query = $this->db->get('category');
     $lang_identif = $this->db->where('identif', MY_Controller::getCurrentLocale())->get('languages')->row();
     $query = $this->db->where('lang', (int) $lang_identif->id)->join('category_translate', 'category_translate.alias = category.id')->get('category');
     $this->template->add_array(array('category_base' => $query->result()));
     $this->ajaxRequest or $this->display_tpl('create_trash');
     if ($_POST) {
         if ($this->form_validation->run($this) == FALSE) {
             showMessage(validation_errors(), '', 'r');
         } else {
             switch ($this->input->post('redirect_type')) {
                 case "url":
                     $array = array('trash_url' => ltrim($this->input->post('url'), '/'), 'trash_redirect_type' => $this->input->post('redirect_type'), 'trash_type' => $this->input->post('type'), 'trash_redirect' => 'http://' . ltrim($this->input->post('redirect_url'), 'http://'));
                     break;
                 case "product":
                     $query = $this->db->get_where('shop_products', array('id' => $this->input->post('products')));
                     $url = $query->row();
                     $array = array('trash_id' => $this->input->post('products'), 'trash_url' => ltrim($this->input->post('url'), '/'), 'trash_redirect_type' => $this->input->post('redirect_type'), 'trash_type' => $this->input->post('type'), 'trash_redirect' => site_url() . 'shop/product/' . $url->url);
                     break;
                 case "category":
                     $query = $this->db->get_where('shop_category', array('id' => $this->input->post('category')));
                     $url = $query->row();
                     $array = array('trash_id' => $this->input->post('category'), 'trash_url' => ltrim($this->input->post('url'), '/'), 'trash_redirect_type' => $this->input->post('redirect_type'), 'trash_type' => $this->input->post('type'), 'trash_redirect' => site_url() . 'shop/category/' . $url->full_path);
                     break;
                 case "basecategory":
                     $query = $this->db->get_where('category', array('id' => $this->input->post('category_base')));
                     $url = $query->row();
                     $array = array('trash_id' => $this->input->post('category_base'), 'trash_url' => ltrim($this->input->post('url'), '/'), 'trash_redirect_type' => $this->input->post('redirect_type'), 'trash_type' => $this->input->post('type'), 'trash_redirect' => site_url($this->cms_base->get_category_full_path($url->id)));
                     break;
                 case "404":
                     $array = array('trash_url' => ltrim($this->input->post('url'), '/'), 'trash_redirect_type' => '404');
                     break;
                 default:
                     $array = array('trash_url' => ltrim($this->input->post('url'), '/'), 'trash_redirect_type' => '404');
                     break;
             }
             $this->db->set($array);
             $this->db->insert('trash');
             $lastId = $this->db->insert_id();
             showMessage(lang('Trash was created', 'trash'));
             $this->lib_admin->log(lang("Trash was created", "trash") . '. Url: ' . $array['trash_url']);
             if ($this->input->post('action') == 'create') {
                 pjax('/admin/components/init_window/trash/edit_trash/' . $lastId);
             }
             if ($this->input->post('action') == 'exit') {
                 pjax('/admin/components/init_window/trash');
             }
         }
     }
 }
 /**
  * display a list of RBAC privileges
  *
  * @access public
  * @return	void
  */
 public function privilegeList()
 {
     $sql = 'SELECT SRG.id, SRG.name, SRGI.description
         FROM shop_rbac_group SRG
         INNER JOIN shop_rbac_group_i18n SRGI ON SRGI.id = SRG.id WHERE SRGI.locale = "' . MY_Controller::getCurrentLocale() . '"';
     $queryGroups = $this->db->query($sql)->result();
     foreach ($queryGroups as $key => $value) {
         $sqlPriv = 'SELECT SRP.id, SRP.name, SRP.group_id, SRPI.title, SRPI.description
         FROM shop_rbac_privileges SRP
         INNER JOIN  shop_rbac_privileges_i18n SRPI ON SRPI.id = SRP.id WHERE SRPI.locale = "' . MY_Controller::getCurrentLocale() . '" AND SRP.group_id = ' . $value->id;
         $queryGroupsPrivilege = $this->db->query($sqlPriv)->result();
         $queryGroups[$key]->privileges = $queryGroupsPrivilege;
     }
     $queryRBACGroup = $this->db->select(array('id', 'name'))->get('shop_rbac_privileges')->result();
     $this->template->add_array(array('model' => $queryRBACGroup, 'groups' => $queryGroups));
     $this->template->show('privilegeList', FALSE);
 }
 function getPoFileAttributes($domain)
 {
     if ($domain) {
         $CI =& get_instance();
         if (strstr($_SERVER['HTTP_REFERER'], 'admin')) {
             $langs = $CI->config->item('languages');
             $language = $CI->config->item('language');
             $locale = $language;
         } else {
             $currentLocale = MY_Controller::getCurrentLocale();
             $language = $CI->db->where('identif', $currentLocale)->get('languages');
             $language = $language->row_array();
             $locale = $language['locale'];
         }
         if ($locale) {
             $attributes = array();
             switch ($domain) {
                 case 'main':
                     $attributes = array('name' => 'main', 'type' => 'main', 'lang' => $locale);
                     break;
                 default:
                     if (file_exists('./application/modules/' . $domain)) {
                         $attributes = array('name' => $domain, 'type' => 'modules', 'lang' => $locale);
                     } elseif (file_exists('./templates/' . $domain)) {
                         $attributes = array('name' => $domain, 'type' => 'templates', 'lang' => $locale);
                     }
                     break;
             }
             return $attributes;
         }
     }
     return FALSE;
 }
 public function getByGroup($group)
 {
     $banners = $this->banner_model->get_all_banner(MY_Controller::getCurrentLocale(), $group);
     return $banners;
 }
Exemple #21
0
 /**
  * Load a language file
  *
  * @access	public
  * @param	mixed	the name of the language file to be loaded. Can be an array
  * @param	string	the language (english, etc.)
  * @return	mixed
  */
 public function load($module = 'main')
 {
     $this->_init();
     if (strstr(uri_string(), 'admin')) {
         $lang = $this->getAdminLocale();
         if (!$module) {
             $module = 'admin';
         }
     } else {
         if (strstr($_SERVER['REQUEST_URI'], 'install')) {
             $lang = $this->ci->session->userdata('language');
         } else {
             $languageFront = $this->getFrontLangCode(MY_Controller::getCurrentLocale());
             $lang = $languageFront[1];
         }
     }
     //        var_dumps_exit($lang);
     //        $lang = 'de_DE';
     //        $module = 'translator';
     if ($module == 'main') {
         $this->addDomain(correctUrl('./application/language/main/' . $lang), getMoFileName('main'), $lang);
         $template_name = \CI_Controller::get_instance()->config->item('template');
         $this->addDomain('templates/' . $template_name . '/language/' . $template_name . '/', getMoFileName($template_name), $lang);
     } else {
         if ($module == 'admin') {
             $this->addDomain(correctUrl('./application/language/main/' . $lang), getMoFileName('main'), $lang);
         }
         //            if (MAINSITE && $module == 'admin') {
         //                $this->addDomain(MAINSITE . '/application/modules/' . $module . '/language', getMoFileName($module), $lang);
         //            } else {
         //            var_dumps_exit(getMoFileName($module));
         //            var_dumps_exit(correctUrl('./application/modules/' . $module . '/language/' . $lang));
         $this->addDomain(correctUrl('./application/modules/' . $module . '/language/' . $lang), getMoFileName($module), $lang);
         //            }
     }
 }
Exemple #22
0
 public function index()
 {
     $locale = MY_Controller::getCurrentLocale();
     $models = $this->sample_mail_model->getList($locale);
     $this->render('list', array('models' => $models, 'locale' => $locale));
 }
 function widget_navigation($widget = array())
 {
     $this->load->module('core');
     if ($widget['settings'] == FALSE) {
         $settings = $this->defaults;
     } else {
         $settings = $widget['settings'];
     }
     if ($this->core->core_data['data_type'] == '404') {
         $data_type = $this->uri->segment(2);
     } else {
         $data_type = $this->core->core_data['data_type'];
     }
     switch ($data_type) {
         case 'category':
             $cur_category = $this->core->cat_content;
             $i = 0;
             $path_count = count($cur_category['path']);
             $path_categories = $this->lib_category->get_category(array_keys($cur_category['path']));
             $tpl_data = array('navi_cats' => $path_categories);
             return $this->template->fetch('widgets/' . $widget['name'], $tpl_data);
             break;
         case 'page':
             $cur_category = $this->core->cat_content;
             $path_categories = $this->lib_category->get_category(array_keys($cur_category['path']));
             // Insert Page data
             $path_categories[] = array('path_url' => $this->core->page_content['cat_url'] . $this->core->page_content['url'], 'name' => $this->core->page_content['title']);
             $tpl_data = array('navi_cats' => $path_categories);
             return $this->template->fetch('widgets/' . $widget['name'], $tpl_data);
             break;
         case 'brand':
             if ($this->core->core_data['id'] != null) {
                 $ci =& get_instance();
                 $brand = $ci->db->select(array('url', 'name'))->where(array('shop_brands.id' => $this->core->core_data['id'], 'shop_brands_i18n.locale' => MY_Controller::getCurrentLocale()))->join('shop_brands_i18n', 'shop_brands_i18n.id=shop_brands.id')->limit(1)->get('shop_brands')->row_array();
                 $navi_cats[] = array('path_url' => 'shop/brand/', 'name' => lang('Brands', 'navigation'));
                 $navi_cats[] = array('path_url' => $brand['url'], 'name' => $brand['name']);
                 $tpl_data = array('navi_cats' => $navi_cats);
                 return $this->template->fetch('widgets/' . $widget['name'], $tpl_data);
             } else {
                 if ($data_type == 'brand') {
                     $navi_cats[] = array('path_url' => 'shop/brand/', 'name' => lang('Brands', 'navigation'));
                     $tpl_data = array('navi_cats' => $navi_cats);
                     return $this->template->fetch('widgets/' . $widget['name'], $tpl_data);
                 }
             }
             break;
         case 'compare':
             $navi_cats[] = array('path_url' => 'shop/compare/', 'name' => lang('Compare', 'navigation'));
             $tpl_data = array('navi_cats' => $navi_cats);
             return $this->template->fetch('widgets/' . $widget['name'], $tpl_data);
             break;
         case 'wish_list':
             $navi_cats[] = array('path_url' => 'shop/wish_list/', 'name' => lang('Wish list', 'navigation'));
             $tpl_data = array('navi_cats' => $navi_cats);
             return $this->template->fetch('widgets/' . $widget['name'], $tpl_data);
             break;
         case 'profile':
             $navi_cats[] = array('path_url' => 'shop/profile/', 'name' => lang('Profile', 'navigation'));
             $tpl_data = array('navi_cats' => $navi_cats);
             return $this->template->fetch('widgets/' . $widget['name'], $tpl_data);
             break;
         case 'search':
             $navi_cats[] = array('path_url' => 'shop/search/', 'name' => lang('Search', 'navigation'));
             $tpl_data = array('navi_cats' => $navi_cats);
             return $this->template->fetch('widgets/' . $widget['name'], $tpl_data);
             break;
         case 'cart':
             $navi_cats[] = array('path_url' => 'shop/cart/', 'name' => lang('Cart', 'navigation'));
             $tpl_data = array('navi_cats' => $navi_cats);
             return $this->template->fetch('widgets/' . $widget['name'], $tpl_data);
             break;
         case 'shop_category':
             if ($this->core->core_data['id'] != null && $this->core->core_data > 0) {
                 //get category object
                 $ci =& get_instance();
                 $shop_category = $ci->db->select(array('full_path_ids', 'url', 'name'))->where(array('shop_category.id' => $this->core->core_data['id'], 'shop_category_i18n.locale' => MY_Controller::getCurrentLocale()))->join('shop_category_i18n', 'shop_category_i18n.id=shop_category.id')->limit(1)->get('shop_category');
                 if ($shop_category) {
                     $shop_category = $shop_category->result();
                     $full_path_ids = $shop_category[0]->full_path_ids;
                     $full_path_ids = unserialize($full_path_ids);
                     $result = array();
                     if (is_array($full_path_ids) && !empty($full_path_ids)) {
                         $result = $ci->db->select('*')->where('locale', MY_Controller::getCurrentLocale())->where_in('shop_category.id', $full_path_ids)->order_by('full_path_ids')->join('shop_category_i18n', 'shop_category_i18n.id=shop_category.id')->get('shop_category');
                         if ($result) {
                             $result = $result->result_array();
                             foreach ($result as $key => $value) {
                                 $result[$key]['path_url'] = 'shop/category/' . $result[$key]['full_path'];
                                 unset($result[$key]['url']);
                             }
                             $result[] = array('path_url' => $shop_category[0]->url, 'name' => $shop_category[0]->name);
                         }
                     } else {
                         //current category is first level category
                         $result[] = array('path_url' => $shop_category[0]->url, 'name' => $shop_category[0]->name);
                     }
                     $tpl_data = array('navi_cats' => $result);
                     return $this->template->fetch('widgets/' . $widget['name'], $tpl_data);
                 } else {
                     throw new Exception("Category not found");
                 }
             }
             break;
         case 'product':
             if ($this->core->core_data['id'] != null && $this->core->core_data['id'] > 0) {
                 $ci =& get_instance();
                 //get product model
                 $product = $ci->db->select(array('name', 'category_id'))->where(array('shop_products.id' => $this->core->core_data['id'], 'locale' => MY_Controller::getCurrentLocale()))->join('shop_products_i18n', 'shop_products_i18n.id=shop_products.id')->get('shop_products');
                 if ($product) {
                     $product = $product->result_array();
                     $product = $product[0];
                     if ($product['category_id'] == null && $product['category_id'] == 0) {
                         throw new Exception("Category not found");
                     }
                     // getting categories
                     $ci->db->cache_on();
                     $result = $ci->db->select(array('shop_category.id', 'parent_id', 'full_path', 'name'))->where(array('shop_category_i18n.locale' => MY_Controller::getCurrentLocale()))->join('shop_category_i18n', 'shop_category_i18n.id=shop_category.id')->get('shop_category');
                     $ci->db->cache_off();
                     if (!$result) {
                         return;
                     }
                     $categories = array();
                     foreach ($result->result_array() as $row) {
                         $categories[$row['id']] = $row;
                     }
                     // building path
                     $neededCid = $product['category_id'];
                     $path = array(array('path_url' => '', 'name' => $product['name']));
                     while ($neededCid != 0) {
                         $path[] = array('path_url' => 'shop/category/' . $categories[$neededCid]['full_path'], 'name' => $categories[$neededCid]['name']);
                         $neededCid = $categories[$neededCid]['parent_id'];
                     }
                     // path is using from back, so...
                     $fromBack = array_reverse($path);
                     $tpl_data = array('navi_cats' => $fromBack);
                     return $this->template->fetch('widgets/' . $widget['name'], $tpl_data);
                 } else {
                     throw new Exception("Product not found");
                 }
             }
             break;
     }
 }
 /**
  * send email
  *
  * @param string $send_to - recepient email
  * @param string $patern_name - email patern  name
  * @param array $variables - variables to raplase in message:
  *   $variables = array('$user$' => 'UserName')
  * @return bool
  */
 public function sendEmail($send_to, $patern_name, $variables, $attachment = FALSE)
 {
     //loading CodeIgniter Email library
     $this->load->library('email');
     $locale = \MY_Controller::getCurrentLocale();
     //Getting settings
     $patern_settings = $this->cmsemail_model->getPaternSettings($patern_name);
     $default_settings = $this->cmsemail_model->getSettings($locale);
     //Prepare settings into correct array for initialize library
     if ($patern_settings) {
         foreach ($patern_settings as $key => $value) {
             if (!$value) {
                 if ($default_settings[$key]) {
                     $patern_settings[$key] = $default_settings[$key];
                 }
             }
         }
     }
     $default_settings['type'] = strtolower($patern_settings['type']);
     $patern_settings['protocol'] = $default_settings['protocol'];
     if (strtolower($default_settings['protocol']) == strtolower("SMTP")) {
         $patern_settings['smtp_port'] = $default_settings['port'];
         $patern_settings['smtp_host'] = $default_settings['smtp_host'];
         $patern_settings['smtp_user'] = $default_settings['smtp_user'];
         $patern_settings['smtp_pass'] = $default_settings['smtp_pass'];
         $patern_settings['smtp_crypto'] = $default_settings['encryption'];
         $this->email->set_newline("\r\n");
     }
     //Initializing library settings
     $this->_set_config($patern_settings);
     //Sending user email if active in options
     if ($patern_settings['user_message_active']) {
         $this->from_email = $patern_settings['from_email'];
         $this->from = $patern_settings['from'];
         $this->send_to = $send_to;
         $this->theme = $patern_settings['theme'];
         $this->message = $this->replaceVariables($patern_settings['user_message'], $variables);
         if (!$this->_sendEmail()) {
             $this->errors[] = lang('User message doesnt send', 'cmsemail');
         } else {
             //Registering event is success
             \CMSFactory\Events::create()->registerEvent(array('from' => $this->from, 'from_email' => $this->from_email, 'send_to' => $this->send_to, 'theme' => $this->theme, 'message' => $this->message), 'ParentEmail:userSend');
             \CMSFactory\Events::runFactory();
         }
     }
     //Sending administrator email if active in options
     if ($patern_settings['admin_message_active']) {
         $this->from_email = $patern_settings['from_email'];
         $this->from = $patern_settings['from'];
         if ($patern_settings['admin_email']) {
             $this->send_to = $patern_settings['admin_email'];
         } else {
             $this->send_to = $default_settings['admin_email'];
         }
         $this->theme = $patern_settings['theme'];
         $this->message = $this->replaceVariables($patern_settings['admin_message'], $variables);
         $this->attachment = $attachment;
         if (!$this->_sendEmail()) {
             $this->errors[] = lang('User message doesnt send', 'cmsemail');
         } else {
             //Registering event is success
             \CMSFactory\Events::create()->registerEvent(array('from' => $this->from, 'from_email' => $this->from_email, 'send_to' => $this->send_to, 'theme' => $this->theme, 'message' => $this->message), 'ParentEmail:adminSend');
             \CMSFactory\Events::runFactory();
         }
     }
     //Returning status
     if ($this->errors) {
         return FALSE;
     } else {
         return TRUE;
     }
 }
 /**
  * Get product name by id
  * @param int $id
  * @return string|boolean
  */
 public function getProductById($id)
 {
     $locale = MY_Controller::getCurrentLocale();
     $query = $this->db->select('name')->from('shop_products_i18n')->where('id', $id)->where('locale', $locale)->get()->row_array();
     if ($query) {
         return $query['name'];
     }
     return false;
 }
 /**
  * create discount
  * @access public
  * @author DevImageCms
  * @param array $postArray input params:
  * @return array $data params:
  * - (boolean) success: result of create
  * - (string) errors: message of error
  * @copyright (c) 2013, ImageCMS
  */
 public function create($postArray)
 {
     $this->validation($postArray);
     if (count($this->error) > 0) {
         return array('success' => false, 'error' => $this->error);
     }
     if (!$postArray['key']) {
         $postArray['key'] = $this->generateDiscountKey();
     }
     $typeDiscount = $postArray['type_discount'];
     $typeDiscountTableName = 'mod_discount_' . $typeDiscount;
     // Check range for cumulative discount
     if ($typeDiscount == "comulativ" and $this->discount_model_admin->checkRangeForCumulativeDiscount($postArray[$typeDiscount])) {
         return array('success' => false, 'error' => array(lang('Has been already created with the cumulative discount value', 'mod_discount')));
     }
     $data = array('key' => $postArray['key'], 'max_apply' => $postArray['max_apply'], 'type_value' => $postArray['type_value'], 'value' => $postArray['value'], 'type_discount' => $typeDiscount, 'date_begin' => strtotime($postArray['date_begin']), 'date_end' => strtotime($postArray['date_end']), 'active' => '1');
     // gift correction (just in case)
     if (isset($postArray['all_order']['is_gift'])) {
         $data['max_apply'] = 1;
     }
     $discountId = $this->discount_model_admin->insertDataToDB('mod_shop_discounts', $data);
     $data_locale = array('id' => $discountId, 'locale' => \MY_Controller::getCurrentLocale(), 'name' => $postArray['name']);
     $typeDiscountData = $postArray[$typeDiscount];
     $this->discount_model_admin->insertDataToDB('mod_shop_discounts_i18n', $data_locale);
     if ($discountId != false) {
         $typeDiscountData['discount_id'] = $discountId;
         $result = $this->discount_model_admin->insertDataToDB($typeDiscountTableName, $typeDiscountData);
     }
     if ($result && $discountId) {
         return array('success' => true, 'id' => $discountId);
     } else {
         return array('success' => false, 'error' => array(lang('Error creating discount', 'mod_discount')));
     }
 }
/colorscheme.css" media="all" />
        <link rel="stylesheet" type="text/css" href="<?php 
if (isset($THEME)) {
    echo $THEME;
}
if (isset($colorScheme)) {
    echo $colorScheme;
}
?>
/color.css" media="all" />

        <?php 
if ($CI->uri->segment(1) == MY_Controller::getCurrentLocale()) {
    ?>
            <?php 
    $lang = '/' . \MY_Controller::getCurrentLocale();
    ?>
        <?php 
} else {
    ?>
            <?php 
    $lang = '';
    ?>
        <?php 
}
?>
        <?php 
if ($CI->uri->segment(2) == 'profile' || $CI->uri->segment(1) == 'wishlist') {
    ?>
            <META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW" />
        <?php 
Exemple #28
0
 /**
  * Get product properties
  * @return array
  */
 public function getProductsProperties()
 {
     $locale = \MY_Controller::getCurrentLocale();
     return \CI::$APP->db->select('shop_product_properties_i18n.id, shop_product_properties_i18n.name')->where('shop_product_properties_i18n.locale', $locale)->order_by('id')->get('shop_product_properties_i18n')->result_array();
 }
Exemple #29
0
 /**
  * get user wish list by id
  *
  * @param $user_id
  * @param $access
  * @return array
  */
 public function getUserWishListsByID($user_id, $access = array('public', 'shared', 'private'))
 {
     $locale = \MY_Controller::getCurrentLocale();
     $queryFirst = $this->db->select('*, shop_product_variants.mainImage AS `image`, mod_wish_list_products.id AS  list_product_id')->where('mod_wish_list.user_id', $user_id)->join('mod_wish_list_products', 'mod_wish_list_products.wish_list_id=mod_wish_list.id', 'left')->where_in('mod_wish_list.access', $access)->where('shop_products_i18n.locale', $locale)->where('shop_product_variants_i18n.locale', $locale)->join('shop_product_variants', 'shop_product_variants.id=mod_wish_list_products.variant_id')->join('shop_product_variants_i18n', 'shop_product_variants_i18n.id=shop_product_variants.id')->join('shop_products', 'shop_products.id=shop_product_variants.product_id')->join('shop_products_i18n', 'shop_products_i18n.id=shop_products.id')->get('mod_wish_list');
     if ($queryFirst) {
         $queryFirst = $queryFirst->result_array();
     }
     $querySecond = $this->db->select('*, mod_wish_list.id AS `wish_list_id`')->where_in('mod_wish_list.access', $access)->where('mod_wish_list_products.wish_list_id', NULL)->where('mod_wish_list.user_id', $user_id)->join('mod_wish_list_products', 'mod_wish_list_products.wish_list_id=mod_wish_list.id', 'left')->get('mod_wish_list');
     if ($querySecond) {
         $querySecond = $querySecond->result_array();
     }
     $arr = array_merge($queryFirst, $querySecond);
     if (count($arr) > 0) {
         return $arr;
     } else {
         return FALSE;
     }
 }
Exemple #30
0
 /**
  * Edit discount 
  * @paran (int) $id
  * @paran (string) $locale
  * @return html  
  */
 public function edit($id, $locale = null)
 {
     if (null === $locale) {
         $locale = \MY_Controller::getCurrentLocale();
     }
     if ($this->input->post()) {
         $postArray = $this->input->post();
         $typeDiscount = $postArray['type_discount'];
         $discauntManager = new \mod_discount\classes\DiscountManager();
         $discauntManager->validation($postArray, $id);
         if (count($discauntManager->error) == 0) {
             // If empty field with discount key, then generate key
             if ($postArray['key'] == null) {
                 $postArray['key'] = $this->generateDiscountKey();
             }
             //Prepare data for insert in table mod_shop_discounts
             $data = array('name' => $postArray['name'], 'key' => $postArray['key'], 'max_apply' => $postArray['max_apply'], 'type_value' => $postArray['type_value'], 'value' => $postArray['value'], 'type_discount' => $typeDiscount, 'date_begin' => strtotime($postArray['date_begin']), 'date_end' => strtotime($postArray['date_end']), 'active' => '1');
             //Prepare data for inserting in the table of selected discount type
             $typeDiscountData = $postArray[$typeDiscount];
             // Check range for cumulative discount
             if ($typeDiscount == "comulativ" and $this->discount_model_admin->checkRangeForCumulativeDiscount($postArray[$typeDiscount], $id)) {
                 showMessage(lang('Has been already created with the cumulative discount value', 'mod_discount'), '', 'r');
                 return;
             }
             // Insert data
             if ($this->discount_model_admin->updateDiscountById($id, $data, $typeDiscountData, $locale)) {
                 showMessage(lang('Changes saved', 'mod_discount'));
             }
             //Return to list of discounts, if user clicked 'save and exit'
             if ($postArray['action'] == 'tomain') {
                 pjax('/admin/components/init_window/mod_discount/index' . $_SESSION['QueryDiscountList']);
             } else {
                 pjax('/admin/components/init_window/mod_discount/edit/' . $id);
             }
         } else {
             showMessage(implode('<br/> ', $discauntManager->error), '', 'r');
         }
     } else {
         //Get list of user roles and info about current discount
         $userGroups = $this->discount_model_admin->getUserGroups(MY_Controller::getCurrentLocale());
         $discountData = $this->discount_model_admin->getDiscountAllDataById($id, $locale);
         //if can't get info about discount from database then 404 error
         if ($discountData == false) {
             $this->error404(lang('Discount not found', 'mod_discount'));
         }
         //If discount type user then get user name and email
         if ($discountData['type_discount'] == 'user') {
             $discountData['user']['userInfo'] = $this->discount_model_admin->getUserNameAndEmailById($discountData['user']['user_id']);
         }
         //If discount type product then get product name
         if ($discountData['type_discount'] == 'product') {
             $discountData['product']['productInfo'] = $this->discount_model_admin->getProductById($discountData['product']['product_id']);
         }
         //Prepare date for rendering
         $data = array('discount' => $discountData, 'userGroups' => $userGroups, 'CS' => $this->discount_model_admin->getMainCurrencySymbol(), 'filterQuery' => $_SESSION['QueryDiscountList'], 'categories' => ShopCore::app()->SCategoryTree->getTree(), 'languages' => $this->db->get('languages')->result_array(), 'locale' => $locale);
         //Render template and set data
         \CMSFactory\assetManager::create()->setData($data)->renderAdmin('edit');
     }
 }