/** * Метод относится к стандартным методам ImageCMS. * Будет вызван каждый раз при обращении к сайту. * Запускается при условии включении "Автозагрузка модуля-> Да" в панели * уплавнеия модулями. */ public function autoload() { if ('TRUE' == $this->useEmailNotification) { // \CMSFactory\Events::create()->setListener('handler', 'Sample_Module:__construct'); \CMSFactory\Events::create()->setListener('handler', 'Commentsapi:newPost'); } }
/** * AdminAutoload method. * * @return void */ public static function adminAutoload() { parent::adminAutoload(); \CMSFactory\Events::create()->onShopProductDelete()->setListener('addProductWhenDelete'); \CMSFactory\Events::create()->onShopProductCreate()->setListener('delProductWhenCreate'); \CMSFactory\Events::create()->onShopProductAjaxChangeActive()->setListener('addProductWhenAjaxChangeActive'); \CMSFactory\Events::create()->onShopCategoryDelete()->setListener('addProductsWhenCatDelete'); }
public function __construct() { parent::__construct(); $lang = new \MY_Lang(); $lang->load('template_manager'); $this->templateName = $this->db->get('settings')->row()->site_template; $this->templateModel = TemplateManager::getInstance()->getCurentTemplate(); \CMSFactory\Events::create()->setListener([new DemodataMigrationsControl(), 'run'], TemplateManager::EVENT_DEMODATA_INSTALLED); }
public function __construct() { parent::__construct(); $this->currentTemplate = TemplateManager::getInstance()->getCurentTemplate(); $this->templatesUploadPath = PUBPATH . 'uploads/templates'; $this->loadLangs(); $this->cache->delete_all(); \CMSFactory\Events::create()->setListener([new DemodataMigrationsControl(), 'run'], TemplateManager::EVENT_DEMODATA_INSTALLED); }
function modules_table() { $not_installed = array(); $fs_modules = $this->find_components(); $db_modules = $this->db->order_by('position', 'asc')->not_like('identif', 'payment_method_')->get('components')->result_array(); // Find not installed modules $count = count($fs_modules); for ($i = 0; $i < $count; $i++) { if ($this->is_installed($fs_modules[$i]['com_name']) == 0) { $info = $this->get_module_info($fs_modules[$i]['com_name']); $fs_modules[$i]['name'] = $info['menu_name']; $fs_modules[$i]['version'] = $info['version']; $fs_modules[$i]['description'] = $info['description']; $fs_modules[$i]['icon_class'] = $info['icon_class']; array_push($not_installed, $fs_modules[$i]); } } // process modules info $count = count($db_modules); for ($i = 0; $i < $count; $i++) { $module_name = $db_modules[$i]['name']; if ($this->module_exists($module_name)) { $info = $this->get_module_info($module_name); $db_modules[$i]['menu_name'] = $info['menu_name']; $db_modules[$i]['version'] = $info['version']; $db_modules[$i]['description'] = $info['description']; $db_modules[$i]['icon_class'] = $info['icon_class']; $db_modules[$i]['identif'] = $db_modules[$i]['identif']; $modulePath = getModulePath($module_name); if (file_exists($modulePath . 'admin.php')) { $db_modules[$i]['admin_file'] = 1; } else { $db_modules[$i]['admin_file'] = 0; } } else { unset($db_modules[$i]); } } if (MAINSITE != '') { list($db_modules, $not_installed) = $this->isPermitedModules($db_modules, $not_installed); } \CMSFactory\Events::create()->registerEvent(array('installed' => $db_modules, 'not_installed' => $not_installed), 'Components:modules_table')->runFactory(); $this->template->assign('installed', $db_modules); $this->template->assign('not_installed', $not_installed); $this->template->show('module_table', FALSE); }
public function newPost() { $this->load->model('base'); $this->init_settings(); ($hook = get_hook('comments_on_add')) ? eval($hook) : NULL; $this->load->library('user_agent'); $this->load->library('form_validation'); $this->load->model('base'); $item_id = $this->parsUrl($_SERVER['HTTP_REFERER']); if ($this->period > 0) { if ($this->check_comment_period() == FALSE) { echo json_encode(array('answer' => 'error', 'validation_errors' => lang('The following comment can be left through', 'comments') . ' ' . $this->period . ' ' . lang('minutes', 'comments'))); return; } } // Validate email and nickname from unregistered users. if ($this->dx_auth->is_logged_in() == FALSE) { ($hook = get_hook('comments_set_val_rules')) ? eval($hook) : NULL; $this->form_validation->set_rules('comment_email', lang('Email', 'comments'), 'trim|required|xss_clean|valid_email'); $this->form_validation->set_rules('comment_author', lang('Your name', 'comments'), 'trim|required|xss_clean|max_length[50]'); $this->form_validation->set_rules('comment_site', lang('Site', 'comments'), 'trim|xss_clean|max_length[250]'); } // Check captcha code if captcha_check enabled and user in not admin. if ($this->use_captcha == TRUE and $this->dx_auth->is_admin() == FALSE) { ($hook = get_hook('comments_set_captcha')) ? eval($hook) : NULL; $this->form_validation->set_message('callback_captcha_check', lang('Wrong code protection', 'comments')); if ($this->dx_auth->use_recaptcha) { $this->form_validation->set_rules('recaptcha_response_field', lang("Code protection", 'comments'), 'trim|required|xss_clean|callback_captcha_check'); } else { $this->form_validation->set_rules('captcha', lang("Code protection", 'comments'), 'trim|required|xss_clean|callback_captcha_check'); } } if ($this->max_comment_length != 0) { $this->form_validation->set_rules('comment_text', lang('Comment', 'comments'), 'trim|required|xss_clean|max_length[' . $this->max_comment_length . ']'); } else { $this->form_validation->set_rules('comment_text', lang('Comment', 'comments'), 'trim|required|xss_clean'); } if ($this->form_validation->run($this) == FALSE) { ($hook = get_hook('comments_validation_failed')) ? eval($hook) : NULL; //$this->core->error( validation_errors() ); // $this->template->assign('comment_errors', validation_errors()); } else { if ($this->dx_auth->is_logged_in() == FALSE) { ($hook = get_hook('comments_author_not_logged')) ? eval($hook) : NULL; $comment_author = trim(htmlspecialchars($this->input->post('comment_author'))); $comment_email = trim(htmlspecialchars($this->input->post('comment_email'))); // Write on cookie nickname and email $this->_write_cookie($comment_author, $comment_email, $this->input->post('comment_site')); } else { ($hook = get_hook('comments_author_logged')) ? eval($hook) : NULL; $user = $this->db->get_where('users', array('id' => $this->dx_auth->get_user_id()))->row_array(); $comment_author = $user['username']; $comment_email = $user['email']; } $comment_text = trim(htmlspecialchars($this->input->post('comment_text'))); $comment_text = str_replace("\n", '<br/>', $comment_text); $comment_text_plus = trim(htmlspecialchars($this->input->post('comment_text_plus'))); $comment_text_plus = str_replace("\n", '<br/>', $comment_text_plus); $comment_text_minus = trim(htmlspecialchars($this->input->post('comment_text_minus'))); $comment_text_minus = str_replace("\n", '<br/>', $comment_text_minus); $rate = $this->input->post('ratec'); if ($this->input->post('ratec')) { if (class_exists('SProductsQuery')) { if (SProductsQuery::create()->findPk($item_id) !== null) { $model = SProductsRatingQuery::create()->findPk($item_id); if ($model === null) { $model = new SProductsRating(); $model->setProductId($item_id); } $model->setVotes($model->getVotes() + 1); $model->setRating($model->getRating() + $rate); $model->save(); } } } } if ($this->input->post('action') == 'newPost') { $email = $this->db->select('email')->get_where('users', array('id' => $this->dx_auth->get_user_id()), 1)->row(); if (!validation_errors()) { $comment_data = array('module' => $this->module, 'user_id' => $this->dx_auth->get_user_id(), 'user_name' => $this->dx_auth->is_logged_in() ? $this->dx_auth->get_username() : trim(htmlspecialchars($this->input->post('comment_author'))), 'user_mail' => $this->dx_auth->is_logged_in() ? $email->email : trim(htmlspecialchars($this->input->post('comment_email'))), 'user_site' => htmlspecialchars($this->input->post(comment_site)), 'text' => $comment_text, 'text_plus' => $comment_text_plus, 'text_minus' => $comment_text_minus, 'item_id' => $item_id, 'status' => $this->_comment_status(), 'agent' => $this->agent->agent_string(), 'user_ip' => $this->input->ip_address(), 'date' => time(), 'rate' => $this->input->post('ratec'), 'parent' => $this->input->post('comment_parent')); $this->db->insert('comments', $comment_data); $this->_recount_comments($item_id, $comment_data['module']); \CMSFactory\Events::create()->registerEvent(array('commentId' => $this->db->insert_id())); $this->validation_errors = ''; //return sucesfull JSON answer echo json_encode(array('answer' => 'sucesfull')); } else { if ($this->dx_auth->use_recaptcha) { $field_name = 'recaptcha_response_field'; } else { $field_name = 'captcha'; } // if ($this->form_validation->error($field_name)) { $this->dx_auth->captcha(); $cap_image = $this->dx_auth->get_captcha_image(); // } // if ($this->use_captcha == TRUE && !$this->dx_auth->is_admin()) { // $this->dx_auth->captcha(); // $data['cap_image'] = $this->dx_auth->get_captcha_image(); // } echo json_encode(array('answer' => 'error', 'validation_errors' => validation_errors(), 'cap_image' => $cap_image)); } } }
/** * Display category */ function _display_category($category = array()) { /** Register event 'Core:_displayCategory' */ \CMSFactory\Events::create()->registerEvent($this->cat_content, 'Core:_displayCategory')->runFactory(); ($hook = get_hook('core_disp_category')) ? eval($hook) : NULL; $category['fetch_pages'] = unserialize($category['fetch_pages']); $content = ''; preg_match('/^\\d+$/', $this->uri->segment($this->uri->total_segments()), $matches); if (!empty($matches)) { $offset = $this->uri->segment($this->uri->total_segments()); $segment = $this->uri->total_segments(); } else { $offset = 0; $segment = $this->uri->total_segments() + 1; } $offset == FALSE ? $offset = 0 : TRUE; $row_count = $category['per_page']; $pages = $this->_get_category_pages($category, $row_count, $offset); // Count total pages for pagination $category['total_pages'] = $this->_get_category_pages($category, 0, 0, TRUE); if ($category['total_pages'] > $category['per_page']) { $this->load->library('Pagination'); if (array_key_exists($this->uri->segment(1), $this->langs)) { $config['base_url'] = '/' . $this->uri->segment(1) . "/" . $category['path_url']; } else { $config['base_url'] = '/' . $category['path_url']; } $config['total_rows'] = $category['total_pages']; $config['per_page'] = $category['per_page']; $config['uri_segment'] = $segment; $config['first_link'] = lang("The first", "core"); $config['last_link'] = lang("Last", "core"); $this->pagination->num_links = 5; ($hook = get_hook('core_dispcat_set_pagination')) ? eval($hook) : NULL; $this->pagination->initialize($config); $this->template->assign('pagination', $this->pagination->create_links()); } // End pagination ($hook = get_hook('core_dispcat_set_category_data')) ? eval($hook) : NULL; $this->template->assign('category', $category); $cnt = count($pages); if ($category['tpl'] == '') { $cat_tpl = 'category'; } else { $cat_tpl = $category['tpl']; } if ($cnt > 0) { // Locate category tpl file if (!file_exists($this->template->template_dir . $cat_tpl . '.tpl')) { ($hook = get_hook('core_dispcat_tpl_error')) ? eval($hook) : NULL; show_error(lang("Can't locate category template file.")); } ($hook = get_hook('core_dispcat_read_ptpl')) ? eval($hook) : NULL; $content = $this->template->read($cat_tpl, array('pages' => $pages)); } else { ($hook = get_hook('core_dispcat_no_pages')) ? eval($hook) : NULL; $content = $this->template->read($cat_tpl, array('no_pages' => lang("In the category has no pages.", "core"))); } $category['title'] == NULL ? $category['title'] = $category['name'] : TRUE; ($hook = get_hook('core_dispcat_set_meta')) ? eval($hook) : NULL; // Generate auto meta-tags if ($this->settings['create_description'] == 'auto' && !$category['description']) { $category['description'] = $this->lib_seo->get_description($category['short_desc']); } if ($this->settings['create_keywords'] == 'auto' && !$category['keywords']) { $keywords = $this->lib_seo->get_keywords($category['short_desc'], TRUE); $i = FALSE; foreach ($keywords as $key => $value) { if (!$i) { $category['keywords'] .= $key; $i = TRUE; } else { $category['keywords'] .= ', ' . $key; } } } // adding page number for pages with pagination (from second page) $curPage = $this->pagination->cur_page; if ($curPage > 1) { $title = $category['title'] . ' - ' . $curPage; $description = $category['description'] . ' - ' . $curPage; $this->set_meta_tags($title, $category['keywords'], $description); } else { $this->set_meta_tags($category['title'], $category['keywords'], $category['description']); } ($hook = get_hook('core_dispcat_set_content')) ? eval($hook) : NULL; $this->template->assign('content', $content); ($hook = get_hook('core_dispcat_show_content')) ? eval($hook) : NULL; if (!$category['main_tpl']) { $this->core->core_data['id'] = $category['id']; $this->template->show(); } else { $this->core->core_data['id'] = $category['id']; $this->template->display($category['main_tpl']); } }
/** * 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; } }
public function installDemoArchive($template_name) { try { /** * Install uploads folder */ $demodata_atchive = realpath('templates/' . $template_name . '/demodata/uploads.zip'); if ($demodata_atchive) { $uploads_folder = realpath('uploads'); if ($uploads_folder) { chmod($uploads_folder, 0777); rename($uploads_folder, $uploads_folder . '_backup_' . time()); } $zip = new \ZipArchive(); $zip->open($demodata_atchive); if (strstr($zip->getNameIndex(0), 'uploads')) { $zip->extractTo('.'); } else { mkdir('./uploads'); chmod('./uploads', 0777); $zip->extractTo(realpath('uploads')); } $zip->close(); $changedDir = array(); $uploads_folder = realpath('uploads'); foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($uploads_folder)) as $entity) { $directory = dirname($entity->getPathname()); if (!in_array($directory, $changedDir)) { chmod($directory, 0777); $changedDir[] = dirname($entity->getPathname()); } chmod($entity->getPathname(), 0777); } chmod($uploads_folder, 0777); } /** * Make database backup */ $this->db_backup(); /** * Install database demodata */ $demodata_db = realpath('templates/' . $template_name . '/demodata/database.sql'); if ($demodata_db) { $db_file_content = file_get_contents($demodata_db); $this->query_from_file($db_file_content); } \CMSFactory\Events::create()->raiseEvent(['templateName' => $template_name], self::EVENT_DEMODATA_INSTALLED); return TRUE; } catch (\Exception $exc) { $this->messages = $exc->getMessage(); return FALSE; } }
public static function adminAutoload() { parent::adminAutoload(); // Set listeners on page pre update to set url \CMSFactory\Events::create()->setListener('setUpdatedUrl', 'ShopAdminProducts:preEdit'); \CMSFactory\Events::create()->onAdminPagePreEdit()->setListener('setUpdatedUrl'); \CMSFactory\Events::create()->onAdminCategoryPreUpdate()->setListener('setUpdatedUrl'); \CMSFactory\Events::create()->onShopCategoryPreEdit()->setListener('setUpdatedUrl'); \CMSFactory\Events::create()->onShopBrandPreEdit()->setListener('setUpdatedUrl'); \CMSFactory\Events::create()->onShopProductCreate()->setListener('ping_google'); \CMSFactory\Events::create()->onShopProductUpdate()->setListener('ping_google'); \CMSFactory\Events::create()->onShopProductDelete()->setListener('ping_google'); \CMSFactory\Events::create()->onShopCategoryCreate()->setListener('ping_google'); \CMSFactory\Events::create()->onShopCategoryEdit()->setListener('ping_google'); \CMSFactory\Events::create()->onShopCategoryDelete()->setListener('ping_google'); \CMSFactory\Events::create()->onShopBrandCreate()->setListener('ping_google'); \CMSFactory\Events::create()->onShopBrandEdit()->setListener('ping_google'); \CMSFactory\Events::create()->onShopBrandDelete()->setListener('ping_google'); \CMSFactory\Events::create()->onAdminPageCreate()->setListener('ping_google'); \CMSFactory\Events::create()->onAdminPageUpdate()->setListener('ping_google'); \CMSFactory\Events::create()->onAdminPageDelete()->setListener('ping_google'); \CMSFactory\Events::create()->onAdminCategoryCreate()->setListener('ping_google'); \CMSFactory\Events::create()->onAdminCategoryUpdate()->setListener('ping_google'); }
public static function adminAutoload() { \CMSFactory\Events::create()->on('ShopAdminProducts:preEdit')->setListener('_extendProductAdmin'); }
public function index() { // get latest pages $this->db->limit(5); $this->db->order_by('created', 'DESC'); $this->db->where('lang_alias', 0); $latest = $this->db->get('content')->result_array(); // get recenly updated pages $this->db->limit(5); $this->db->order_by('updated', 'DESC'); $this->db->where('updated >', 0); $this->db->where('lang_alias', 0); $updated = $this->db->get('content')->result_array(); // get comments if ($this->db->get_where('components', array('name' => 'comments'))->row()) { $comments = $this->db->where('status', '0')->or_where('status', '1')->order_by('date', 'DESC')->get('comments')->result_array(); $total_comments = count($comments); $comments = array_slice($comments, 0, 5); } else { $total_comments = 0; } // total pages $this->db->where('post_status', 'publish'); $this->db->from('content'); $total_pages = $this->db->count_all_results(); // total categories $this->db->from('category'); $total_cats = $this->db->count_all_results(); $this->template->add_array(array('latest' => $latest, 'updated' => $updated, 'comments' => $comments, 'total_cats' => $total_cats, 'total_pages' => $total_pages, 'total_comments' => $total_comments)); // If we are online - load system news. $s_ip = substr($_SERVER['SERVER_ADDR'], 0, strrpos($_SERVER['SERVER_ADDR'], '.')); switch ($s_ip) { case '127.0.0': case '127.0.1': case '10.0.0': case '172.16.0': case '192.168.0': $on_local = TRUE; break; } if (($api_news = $this->cache->fetch('api_news_cache')) !== FALSE) { $this->template->assign('api_news', $api_news); } else { if ($on_local !== TRUE) { $this->config->load('api'); $api_news = $this->_curl_post($this->config->item('imagecms_latest_news'), array('for' => IMAGECMS_NUMBER)); if (count(unserialize($api_news['result'])) > 1 and $api_news['code'] == '200') { $this->template->assign('api_news', unserialize($api_news['result'])); $this->cache->store('api_news_cache', unserialize($api_news['result'])); } else { $this->cache->store('api_news_cache', 'false'); } } } // Get system upgrade info // $this->load->module('admin/sys_upgrade'); // $status = $this->sys_upgrade->_check_status(); // Get next version number $next_v = explode('_', $status['upgrade_file']); if (isset($next_v[2])) { $this->template->assign('next_v', str_replace('.zip', '', $next_v[2])); } $this->template->add_array(array('cms_number' => IMAGECMS_NUMBER, 'sys_status' => $status)); \CMSFactory\Events::create()->registerEvent('', 'Dashboard:show'); \CMSFactory\Events::runFactory(); $this->template->show('dashboard', FALSE); }
public function create_cat() { $this->load->library('lib_admin'); $this->form_validation->set_rules('name', lang("Name", "documentation"), 'trim|min_length[1]|max_length[256]|required|xss_clean'); $this->form_validation->set_rules('url', lang("URL", "documentation"), 'xss_clean|max_length[256]'); $this->form_validation->run(); if (!$this->form_validation->error_string()) { if ($this->input->post('url') == FALSE) { $url = translit_url($this->input->post('name')); } else { $url = translit_url($this->input->post('url')); } $data = array('name' => $this->input->post('name'), 'url' => $url, 'title' => $this->input->post('meta_title'), 'keywords' => $this->input->post('keywords'), 'description' => $this->input->post('description'), 'parent_id' => $this->input->post('category'), 'order_by' => 'publish_date', 'sort_order' => 'desc', 'tpl' => 'category'); $parent = $this->lib_category->get_category($data['parent_id']); if ($parent != 'NULL') { $full_path = $parent['path_url'] . $data['url'] . '/'; } else { $full_path = $data['url'] . '/'; } if ($this->category_exists($full_path) == TRUE and $data['url'] != 'core') { $data['url'] .= time(); } $id = $this->cms_admin->create_category($data); $responseArray = array(); /** Return true if category created success and return errors* */ if ($id != null) { $responseArray['success'] = 'true'; $responseArray['errors'] = 'false'; $this->cache->delete_all(); echo json_encode($responseArray); } else { $responseArray['success'] = 'false'; $responseArray['errors'] = lang("Ошибка при создании категории", "documentation"); echo json_encode($responseArray); } /** Init Event. Create new Category */ \CMSFactory\Events::create()->registerEvent(array_merge($data, array('userId' => $this->dx_auth->get_user_id()))); } else { $responseArray['success'] = 'false'; $responseArray['errors'] = $this->form_validation->error_string(); echo json_encode($responseArray); } }
public function edit_module_widget($id, $update_info = FALSE, $locale = NULL) { //cp_check_perm('widget_access_settings'); $locale = $locale ? $locale : MY_Controller::defaultLocale(); if ($_POST) { $this->update_widget($id, $update_info, $locale); $this->cache->delete_all(); $this->lib_admin->log(lang("Widget edited", "admin")); } else { $widget = $this->db->where('widgets.id', $id)->join('widget_i18n', 'widget_i18n.id=widgets.id AND locale="' . $locale . '"', 'left')->get('widgets'); /** Init Event. Pre Create Category */ \CMSFactory\Events::create()->registerEvent(array('widgetId' => $id), 'WidgetModule:preUpdate'); \CMSFactory\Events::runFactory(); $this->template->add_array(array('widget_id' => $id, 'widget' => $widget->row_array(), 'locale' => $locale, 'languages' => $this->db->get('languages')->result_array())); $this->template->show('widget_edit_module', FALSE); } }
/** * Update existing page by ID * * @access public */ function update($page_id) { //cp_check_perm('page_edit'); $data = $this->db->get_where('content', array('id' => $page_id)); if ($data->num_rows() > 0) { $data = $data->row_array(); } else { $data = FALSE; } /** Init Event. Pre Edit Page */ \CMSFactory\Events::create()->registerEvent(array('pageId' => $page_id, 'url' => $data['url']), 'BaseAdminPage:preUpdate'); \CMSFactory\Events::runFactory(); $this->form_validation->set_rules('page_title', lang("Title", "admin"), 'trim|required|min_length[1]|max_length[500]'); $this->form_validation->set_rules('page_url', lang("URL", "admin"), 'alpha_dash'); $this->form_validation->set_rules('page_keywords', lang("Keywords", "admin"), 'trim'); $this->form_validation->set_rules('prev_text', lang("Preliminary contents", "admin"), 'trim|required'); $this->form_validation->set_rules('page_description', lang("Description ", "admin"), 'trim'); $this->form_validation->set_rules('full_tpl', lang("Page template", "admin"), 'trim|max_length[50]|min_length[2]|callback_tpl_validation'); $this->form_validation->set_rules('main_tpl', lang("Main page template ", "admin"), 'trim|max_length[50]|min_length[2]|callback_tpl_validation'); $this->form_validation->set_rules('create_date', lang("Creation date", "admin"), 'required|valid_date'); $this->form_validation->set_rules('create_time', lang("Creation time", "admin"), 'required|valid_time'); $this->form_validation->set_rules('publish_date', lang("Publication date", "admin"), 'required|valid_date'); $this->form_validation->set_rules('publish_time', lang("Publication time", "admin"), 'required|valid_time'); ($hook = get_hook('admin_page_update_set_rules')) ? eval($hook) : NULL; $page_category = $this->cms_admin->get_category($data['category']); if ($page_category['field_group'] != -1 && $page_category) { $groupId = $page_category['field_group']; ($hook = get_hook('cfcm_set_rules')) ? eval($hook) : NULL; } if ($this->form_validation->run($this) == FALSE) { ($hook = get_hook('admin_page_update_val_failed')) ? eval($hook) : NULL; showMessage(validation_errors(), false, 'r'); } else { // load site settings $settings = $this->cms_admin->get_settings(); if ($this->input->post('page_url') == '' or $this->input->post('page_url') == NULL) { $this->load->helper('translit'); $url = translit_url($this->input->post('page_title')); } else { $url = $this->input->post('page_url'); } // check if we have existing module with entered URL $this->db->where('name', $url); $query = $this->db->get('components'); if ($query->num_rows() > 0) { showMessage(lang("Reserved the same name module", "admin"), false, 'r'); exit; } // end module check // check if we have existing category with entered URL $this->db->where('url', $url); $query = $this->db->get('category', 1); if ($query->num_rows() > 0) { showMessage(lang("Reserved of the same name category", "admin"), false, 'r'); exit; } // end check // check if we have existing page with entered URL $b_page = $this->cms_admin->get_page($page_id); $this->db->where('url', $url); $this->db->where('category', $this->input->post('category')); $this->db->where('category !=', $b_page['category']); $this->db->where('lang', $b_page['lang']); $query = $this->db->get('content', 1); if ($query->num_rows() > 0) { showMessage(lang("Page with URL", "admin") . '<b>' . $url . '</b>' . lang("in ID category", "admin") . $this->input->post('category') . lang(" already exists. Specify or select another URL"), false, 'r'); exit; } // end check $full_url = $this->lib_category->GetValue($this->input->post('category'), 'path_url'); if ($full_url == FALSE) { $full_url = ''; } $keywords = $this->lib_admin->db_post('page_keywords'); $description = $this->lib_admin->db_post('page_description'); // create keywords // if ($keywords == '' AND $settings['create_keywords'] == 'auto') { // $keywords = $this->lib_seo->get_keywords($this->input->post('prev_text') . ' ' . $this->input->post('full_text')); // } // create description // if ($description == '' AND $settings['create_description'] == 'auto') { // $description = $this->lib_seo->get_description($this->input->post('prev_text') . ' ' . $this->input->post('full_text')); // } // mb_substr($keywords, -1) == ',' ? $keywords = mb_substr($keywords, 0, -1) : TRUE; $publish_date = $this->input->post('publish_date') . ' ' . $this->input->post('publish_time'); $create_date = $this->input->post('create_date') . ' ' . $this->input->post('create_time'); $data = array('title' => trim($this->input->post('page_title')), 'meta_title' => trim($this->input->post('meta_title')), 'url' => str_replace('.', '', trim($url)), 'cat_url' => $full_url, 'keywords' => $keywords, 'description' => $description, 'full_text' => trim($this->input->post('full_text')), 'prev_text' => trim($this->lib_admin->db_post('prev_text')), 'category' => $this->input->post('category'), 'full_tpl' => $_POST['full_tpl'], 'main_tpl' => $_POST['main_tpl'], 'comments_status' => $this->input->post('comments_status'), 'post_status' => $this->input->post('post_status'), 'author' => $this->dx_auth->get_username(), 'publish_date' => strtotime($publish_date), 'created' => strtotime($create_date), 'updated' => time()); $data['id'] = $page_id; if ($b_page['lang_alias'] != 0) { $data['url'] = $b_page['url']; } $this->on_page_update($data); $this->load->module('cfcm')->save_item_data($page_id, 'page'); $this->cache->delete_all(); //($hook = get_hook('admin_page_update')) ? eval($hook) : NULL; if ($this->cms_admin->update_page($page_id, $data) >= 1) { $this->lib_admin->log(lang("Changed the page", "admin") . " " . '<a href="' . site_url('admin/pages/edit/' . $page_id) . '">' . $data['title'] . '</a>'); $action = $this->input->post('action'); $path = '/admin/pages/GetPagesByCategory'; if ($action == 'edit') { $path = '/admin/pages/edit/' . $page_id; } showMessage(lang("Page contents have been updated", "admin")); pjax($path); } else { showMessage('', false, 'r'); } } }
function runFactory() { \CMSFactory\Events::runFactory(); }
public function updateDiscountsApplies() { \mod_discount\classes\BaseDiscount::prepareOption(array('reBuild' => 1)); $baseDiscount = \mod_discount\classes\BaseDiscount::create(); if (\mod_discount\classes\BaseDiscount::checkModuleInstall()) { if ($baseDiscount->discountProductVal > $baseDiscount->discountNoProductVal) { $discount['result_sum_discount'] = $baseDiscount->discountProductVal; $discount['type'] = 'product'; } else { $discount['result_sum_discount'] = $baseDiscount->discountNoProductVal; $discount['type'] = 'user'; } if ($discount['result_sum_discount'] > 0) { if ($discount['type'] != 'product') { $baseDiscount->updateDiskApply($baseDiscount->discountMax['key']); } else { $cartItems = \Cart\BaseCart::getInstance()->getItems(); $diff = 0; foreach ($cartItems['data'] as $item) { if (is_null($item->discountKey)) { continue; } $appliesLeft = \mod_discount\classes\BaseDiscount::create()->getAppliesLeft($item->discountKey); if ($appliesLeft === null) { continue; } for ($i = 0; $i < $item->quantity; $i++) { if ($appliesLeft-- > 0) { \mod_discount\classes\BaseDiscount::create()->updateDiskApply($item->discountKey); } } if ($appliesLeft < 0) { $appliesLeft = abs($appliesLeft); $diff += ($item->originPrice - $item->price) * $appliesLeft; } } if ($diff > 0) { \CMSFactory\Events::create()->setListener(function (\SOrders $order, $price) use($diff) { if (Mod_discount::$orderPassOverloadControl == false) { $price = $order->getTotalPrice() + $diff; $discount = $order->getDiscount() - $diff; $order->setTotalPrice($price)->save(); Mod_discount::$orderPassOverloadControl = true; } }, 'Cart:MakeOrder'); } } } } }
/** * Show edit category window * * @access public */ function edit($id) { //cp_check_perm('category_edit'); $cat = $this->cms_admin->get_category($id); /** Init Event. Pre Create Category */ \CMSFactory\Events::create()->registerEvent(array('pageId' => $id, 'url' => $cat['url']), 'Categories:preUpdate'); \CMSFactory\Events::runFactory(); ($hook = get_hook('admin_edit_category')) ? eval($hook) : NULL; if ($cat !== FALSE) { // Get langs $langs = $this->cms_base->get_langs(); $this->template->assign('langs', $langs); $settings = unserialize($cat['settings']); $cat['fetch_pages'] = unserialize($cat['fetch_pages']); $this->template->add_array($cat); $this->template->assign('tree', $this->lib_category->build()); $this->template->assign('include_cats', $this->sub_cats($this->lib_category->build())); $this->template->assign('settings', $settings); ($hook = get_hook('admin_show_category_edit')) ? eval($hook) : NULL; $this->template->show('category_edit', FALSE); } else { return FALSE; } }
public static function adminAutoload() { \CMSFactory\Events::create()->onAdminPagePreEdit()->setListener('_extendPageAdmin'); }
public static function adminAutoload() { parent::adminAutoload(); \CMSFactory\Events::create()->onShopProductUpdate()->setListener('priceUpdate'); \CMSFactory\Events::create()->onShopProductDelete()->setListener('priceDelete'); }
public function autoload() { \CMSFactory\Events::create()->on('MakeOrder')->setListener('_setHour'); \CMSFactory\Events::create()->on('MakeOrder')->setListener('_setPartnerId'); }
public function edit_module_widget($id) { //cp_check_perm('widget_access_settings'); $widget = $this->get($id); /** Init Event. Pre Create Category */ \CMSFactory\Events::create()->registerEvent(array('widgetId' => $id), 'WidgetModule:preUpdate'); \CMSFactory\Events::runFactory(); $this->template->add_array(array('widget' => $widget->row_array())); $this->template->show('widget_edit_module', FALSE); }