/** * @see EventListener::execute() */ public function execute($eventObj, $className, $eventName) { // create needed variables $knownHostIDs = $knownPageIDs = array(); // read known page and host IDs $sql = "SELECT\n\t\t\t\t\t*\n\t\t\t\tFROM\n\t\t\t\t\tcms" . CMS_N . "_statistic_known\n\t\t\t\tWHERE\n\t\t\t\t\tsessionID = '" . escapeString(WCF::getSession()->sessionID) . "'"; $result = WCF::getDB()->sendQuery($sql); while ($row = WCF::getDB()->fetchArray($result)) { if (intval($row['pageID'])) { $knownPageIDs[] = intval($row['pageID']); } if (intval($row['hostID'])) { $knownHostIDs[] = intval($row['hostID']); } } // handle hosts if (!in_array(CMSCore::getActiveHost()->getHostID(), $knownHostIDs)) { // update count for host if this user isn't known $sql = "UPDATE\n\t\t\t\t\t\tcms" . CMS_N . "_statistic_host\n\t\t\t\t\tSET\n\t\t\t\t\t\trequestCount = requestCount + 1\n\t\t\t\t\tWHERE\n\t\t\t\t\t\thostID = " . CMSCore::getActiveHost()->getHostID(); WCF::getDB()->sendQuery($sql); // add to known hosts $sql = "INSERT INTO\n\t\t\t\t\t\tcms" . CMS_N . "_statistic_known (sessionID, hostID, timestamp)\n\t\t\t\t\tVALUES\n\t\t\t\t\t\t('" . escapeString(WCF::getSession()->sessionID) . "', " . CMSCore::getActiveHost()->getHostID() . ", " . TIME_NOW . ")"; WCF::getDB()->sendQuery($sql); } // handle pages if (!in_array($eventObj->pageID, $knownPageIDs)) { // update count for page if this user isn't known $sql = "UPDATE\n\t\t\t\t\t\tcms" . CMS_N . "_statistic_page\n\t\t\t\t\tSET\n\t\t\t\t\t\trequestCount = requestCount + 1\n\t\t\t\t\tWHERE\n\t\t\t\t\t\tpageID = " . $eventObj->pageID; WCF::getDB()->sendQuery($sql); // add to known pages $sql = "INSERT INTO\n\t\t\t\t\t\tcms" . CMS_N . "_statistic_known (sessionID, pageID, timestamp)\n\t\t\t\t\tVALUES\n\t\t\t\t\t\t('" . escapeString(WCF::getSession()->sessionID) . "', " . $eventObj->pageID . ", " . TIME_NOW . ")"; WCF::getDB()->sendQuery($sql); } if (isset($_SERVER['HTTP_REFERER']) and !strpos($_SERVER['HTTP_REFERER'], $_SERVER['SERVER_NAME'], 0) and !empty($_SERVER['HTTP_REFERER'])) { $url = parse_url($_SERVER['HTTP_REFERER']); $sql = "SELECT\n\t\t\t\t\t\t*\n\t\t\t\t\tFROM\n\t\t\t\t\t\tcms" . CMS_N . "_statistic_referer_host\n\t\t\t\t\tWHERE\n\t\t\t\t\t\thostname = '" . escapeString($url['host']) . "'"; $row = WCF::getDB()->getFirstRow($sql); if (WCF::getDB()->countRows()) { $hostID = $row['hostID']; $sql = "UPDATE\n\t\t\t\t\t\t\tcms" . CMS_N . "_statistic_referer_host\n\t\t\t\t\t\tSET\n\t\t\t\t\t\t\tcount = count + 1\n\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\thostname = '" . escapeString($url['host']) . "'"; WCF::getDB()->sendQuery($sql); } else { $sql = "INSERT INTO\n\t\t\t\t\t\t\tcms" . CMS_N . "_statistic_referer_host (hostname, count)\n\t\t\t\t\t\tVALUES\n\t\t\t\t\t\t\t('" . escapeString($url['host']) . "', 1)"; WCF::getDB()->sendQuery($sql); $hostID = WCF::getDB()->getInsertID(); } $sql = "SELECT\n\t\t\t\t\t\t*\n\t\t\t\t\tFROM\n\t\t\t\t\t\tcms" . CMS_N . "_statistic_referer\n\t\t\t\t\tWHERE\n\t\t\t\t\t\turl = '" . escapeString($_SERVER['HTTP_REFERER']) . "'"; $row = WCF::getDB()->getFirstRow($sql); if (WCF::getDB()->countRows()) { $sql = "UPDATE\n\t\t\t\t\t\t\tcms" . CMS_N . "_statistic_referer\n\t\t\t\t\t\tSET\n\t\t\t\t\t\t\tcount = count + 1\n\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\turl = '" . escapeString($_SERVER['HTTP_REFERER']) . "'"; WCF::getDB()->sendQuery($sql); } else { $sql = "INSERT INTO\n\t\t\t\t\t\t\tcms" . CMS_N . "_statistic_referer (url, count, hostID)\n\t\t\t\t\t\tVALUES\n\t\t\t\t\t\t\t('" . escapeString($_SERVER['HTTP_REFERER']) . "', 1, " . $hostID . ")"; WCF::getDB()->sendQuery($sql); } } }
/** * @see EventListener::execute() */ public function execute($eventObj, $className, $eventName) { if (CMSCore::getActiveHost() !== null) { foreach ($eventObj->menuItems as $key => $item) { // remove menu items from other hosts if (!in_array($item['menuItemID'], CMSCore::getActiveHost()->getMenuItemIDs())) { unset($eventObj->menuItems[$key]); } } } }
public function getContent() { $this->postProcess(); $path = _MODULE_DIR_ . 'lgconsultas/views/js/jquery-ui.js'; $this->context->controller->addJS($path); $this->context->controller->addJqueryPlugin('ui.tooltip', null, true); $this->context->controller->addCSS(_MODULE_DIR_ . 'lgconsultas/views/css/back.css'); $this->fields_form = array(); $this->fields_form[0]['form']['input'] = array(array('type' => 'free', 'name' => 'LG_CONSULTAS_INFO', 'desc' => '<a href="index.php?controller=AdminLGConsultas&token=' . Tools::getAdminTokenLite('AdminLGConsultas') . '" target="_blank"> ' . $this->l('Click here to manage your questions and answer them') . '</a>'), array('type' => 'text', 'label' => $this->l('Email address:'), 'name' => 'LG_CONSULTAS_EMAIL', 'required' => true, 'desc' => $this->l('Set the email address to which the notifications will be sent every time a question is received.')), array('type' => 'select', 'name' => 'LG_CONSULTAS_TAB_CONTENT', 'label' => $this->l('Display module:'), 'options' => array('query' => array(array('id' => 1, 'name' => $this->l('In a new block (PS 1.6)')), array('id' => 2, 'name' => $this->l('In a new tab (PS 1.5)'))), 'id' => 'id', 'name' => 'name'), 'desc' => $this->l('Choose how you want to display the module on the product sheets according to your template (in a block or in a tab).')), array('type' => 'radio', 'name' => 'LG_CONSULTAS_EXTRA_RIGHT', 'label' => $this->l('Display shortcut:'), 'values' => array(array('id' => 'LG_CONSULTAS_EXTRA_RIGHT_on', 'value' => 1, 'label' => $this->l('Yes')), array('id' => 'LG_CONSULTAS_EXTRA_RIGHT_off', 'value' => 0, 'label' => $this->l('No'))), 'desc' => $this->l('Choose to display or hide the question shortcut in the superior part of the product sheets.')), array('type' => 'radio', 'name' => 'LG_CONSULTAS_ICON_DISPLAY', 'label' => $this->l('Display icons:'), 'values' => array(array('id' => 'LG_CONSULTAS_ICON_DISPLAY_on', 'value' => 1, 'label' => $this->l('Yes')), array('id' => 'LG_CONSULTAS_ICON_DISPLAY_off', 'value' => 0, 'label' => $this->l('No'))), 'desc' => $this->l('Choose to display or hide the question icons.')), array('type' => 'select', 'name' => 'LG_CONSULTAS_ICON_COLOR', 'label' => $this->l('Icon color:'), 'options' => array('query' => array(array('id' => 1, 'name' => $this->l('Yellow')), array('id' => 2, 'name' => $this->l('Orange')), array('id' => 3, 'name' => $this->l('Red')), array('id' => 4, 'name' => $this->l('Pink')), array('id' => 5, 'name' => $this->l('Purple')), array('id' => 6, 'name' => $this->l('Green')), array('id' => 7, 'name' => $this->l('Blue light')), array('id' => 8, 'name' => $this->l('Blue dark')), array('id' => 9, 'name' => $this->l('Grey')), array('id' => 10, 'name' => $this->l('Black'))), 'id' => 'id', 'name' => 'name'), 'desc' => $this->l('Choose the color of the icon displayed on the product sheets.')), array('type' => 'text', 'label' => $this->l('Number of questions:'), 'name' => 'LG_CONSULTAS_DEFAULT', 'required' => true, 'desc' => $this->l('Set the number of questions you want to display by default on the product sheets.')), array('type' => 'text', 'label' => $this->l('Display more:'), 'name' => 'LG_CONSULTAS_EXTRA', 'required' => true, 'desc' => $this->l('Set the number of extra product reviews to display when clicking on the button "Display more".')), array('type' => 'select', 'label' => $this->l('Form link:'), 'name' => 'LG_CONSULTAS_CMS', 'tab' => 'buttons', 'required' => false, 'desc' => $this->l('Choose the CMS page for the link in the question form.'), 'options' => array('query' => CMSCore::getCMSPages($this->context->language->id), 'id' => 'id_cms', 'name' => 'meta_title'))); $this->fields_form[0]['form']['submit'] = array('title' => $this->l('Save'), 'name' => 'submitForm'); $form = new HelperForm($this); $form->show_toolbar = true; $form->fields_value = $this->getConfigFormValues(); $form->name_controller = 'lgconsultas'; $form->token = Tools::getAdminTokenLite('AdminModules'); $form->currentIndex = AdminController::$currentIndex . '&configure=' . $this->name; $form->default_form_language = $this->context->language->id; $form->allow_employee_form_lang = $this->context->language->id; $form->toolbar_scroll = true; $form->title = $this->displayName; $form->submit_action = 'submitForm'; $form->toolbar_btn = array('back' => array('href' => AdminController::$currentIndex . '&configure=' . $this->name . '&token=' . Tools::getAdminTokenLite('AdminModules'), 'desc' => $this->l('Back to the list'))); return $this->getP() . $form->generateForm($this->fields_form); }
/** * Creates a new instance of DynamicHostManager */ protected function initHostManager() { require_once WCF_DIR . 'lib/page/util/DynamicHostManager.class.php'; self::$hostManagerObj = new DynamicHostManager(); self::$activeHost = self::$hostManagerObj->getHost(); self::$activeHostID = self::$activeHost->hostID; }
public function __construct($id = null, $id_lang = null, $id_shop = null) { require_once _PS_MODULE_DIR_ . "ag_viewhelper/ag_viewhelper.php"; parent::__construct($id, $id_lang, $id_shop); $this->content = ag_viewhelper::getHtmlCode($this->content); }