/** * Show star_rating * @param SProducts $item */ public function show_star_rating($item = null, $registerScript = true) { $get_settings = $this->rating_model->get_settings(); //prepare array with pages which can display "Star rating" $this->list_for_show = json_decode($get_settings['settings'], true); if ($this->list_for_show == null) { $this->list_for_show = array(); } $id = $this->core->core_data['id']; $type = $this->core->core_data['data_type']; // product rating if ($item != null && $item instanceof SProducts) { if ($item->getRating() != null) { $rating_s = (int) $item->getRating() * 20; } else { $rating_s = 0; } $data = array('id_type' => $item->getId(), 'type' => 'product', 'votes' => $item->getVotes(), 'rating' => $rating_s); $template = 'product_star_rating'; } else { if (in_array($type, array_keys($this->list_for_show))) { $rating = $this->rating_model->get_rating($id, $type); if ($rating->votes != 0) { $rating_s = $rating->rating / $rating->votes * 20; //rating in percent } else { $rating_s = 0; } $data = array('id' => $rating->id, 'type' => $rating->type, 'votes' => $rating->votes, 'rating' => $rating_s); $template = 'star_rating'; } else { $template = null; return false; } } //Show template with prepared parametrs if ($template !== null) { $renderTemplate = CMSFactory\assetManager::create(); } $renderTemplate->setData($data)->registerStyle('style'); // if ($template != 'product_star_rating')$registerScript if ($registerScript) { $renderTemplate->registerScript('scripts'); } $renderTemplate->render($template, true); return $this; }
/** * Get shop news for shop category or product * @param int $limit */ public function getShopNews($limit = 20) { $this->load->model('shop_news_model'); //Prepare category id if ($this->core->core_data['data_type'] == 'shop_category') { $categoryId = $this->core->core_data['id']; } elseif ($this->core->core_data['data_type'] == 'product') { $productId = $this->core->core_data['id']; $categoryId = $this->shop_news_model->getProductCategory($productId); } // Get content ids by category $contentIds = $this->shop_news_model->getContentIds($categoryId); // Prepare array with content ids $ids = array(); foreach ($contentIds as $contentId) { $ids[] .= $contentId['content_id']; } $content = $this->shop_news_model->getContent($ids, $limit); CMSFactory\assetManager::create()->setData(array('contentShopNews' => $content))->registerStyle('style')->registerScript('scripts')->render('content', true); }
private function _send_message() { $config['charset'] = 'UTF-8'; $config['wordwrap'] = FALSE; $this->load->library('email'); $this->email->initialize($config); $this->email->from($this->input->post('email'), $this->input->post('name')); $this->email->to($this->admin_mail); $this->email->subject($this->input->post('theme')); $this->email->message($this->message); $this->email->send(); CMSFactory\assetManager::create()->appendData('message_sent', TRUE); }
/** * Edit Banner by Id Banner * @access public * @param int $id * @param string $locale * @author L.Andriy <*****@*****.**> * @copyright (c) 2013, ImageCMS */ public function edit($id, $locale = null) { /** Locale value is necessary */ $locale != null or $locale = $this->def_locale; if ($_POST) { $this->load->library('Form_validation'); $this->form_validation->set_rules('name', lang('Banner name', 'banners'), 'required|xss_clean|max_length[45]'); $this->form_validation->set_rules('photo', lang('Photo', 'banners'), 'required|xss_clean'); if ($this->form_validation->run($this) != FALSE) { /** Set Update data */ $data = array('name' => $_POST['name'], 'active' => (int) $this->input->post('active'), 'description' => $this->input->post('description'), 'active_to' => $this->input->post('active_to_permanent') == 'on' ? -1 : (int) strtotime($this->input->post('active_to')), 'where_show' => count($_POST['data']) ? serialize(array_unique($this->input->post('data'))) : serialize(array()), 'photo' => $this->input->post('photo'), 'url' => $this->input->post('url'), 'locale' => $locale, 'group' => serialize($this->input->post('group')), 'id' => (int) $id); /** Update banner from data-array */ $this->banner_model->edit_banner($data); /** Show successful message and redirect */ $this->lib_admin->log(lang("Banner was edited", "banners") . '. Id: ' . $id); showMessage(lang('Data is saved', 'banners')); if ($this->input->post('action') == 'tomain') { pjax('/admin/components/init_window/banners'); } } else { /** Show validation error message */ showMessage(validation_errors(), false, 'r'); } } else { $banner = $this->banner_model->get_one_banner($id, $locale); $groups = $this->banner_model->getGroups(); if (!isset($banner['id']) or empty($banner)) { $banner['id'] = $id; } /** Show Banner edit template */ CMSFactory\assetManager::create()->registerScript('main', TRUE)->registerStyle('style', TRUE)->setData(array('is_shop' => $this->is_shop, 'banner' => $banner, 'locale' => $locale, 'languages' => $this->db->get('languages')->result_array(), 'groups' => $groups))->renderAdmin('edit'); } }
/** * Get menu by menu name * @param string $menu_name - menu name * @return string */ private function getMenu($menu_name) { $menu_name = self::$DEV_MODE ? self::$MENU_NAME : $menu_name; $menu = AdminMenuBuilder::getMenu($menu_name, self::$MENU_TYPE); $modules = self::$DEV_MODE ? array() : $this->getModules(); if ($menu) { $tpl = self::$DEV_MODE ? 'dev_menu' : 'menu'; return CMSFactory\assetManager::create()->setData(array('menu' => $menu, 'modules' => $modules, 'SAAS' => self::$SAAS))->registerScript('admin_menu')->fetchAdminTemplate($tpl); } }