public function listing() { hikaserial::setTitle(JText::_(self::name), self::icon, self::ctrl); $buttons = array(array('name' => JText::_('ADD_NEW_SERIAL'), 'url' => hikaserial::completeLink('serial&task=edit'), 'icon' => 'icon-48-add-serials'), array('name' => JText::_('HIKA_SERIALS'), 'url' => hikaserial::completeLink('serial'), 'icon' => 'icon-48-serials'), array('name' => JText::_('HIKA_PACKS'), 'url' => hikaserial::completeLink('pack'), 'icon' => 'icon-48-pack'), array('name' => JText::_('PLUGINS'), 'url' => hikaserial::completeLink('plugins'), 'icon' => 'icon-48-plugin'), array('name' => JText::_('HIKA_CONFIGURATION'), 'url' => hikaserial::completeLink('config'), 'icon' => 'icon-48-config'), array('name' => JText::_('IMPORT'), 'url' => hikaserial::completeLink('import'), 'icon' => 'icon-48-import'), array('name' => JText::_('UPDATE_ABOUT'), 'url' => hikaserial::completeLink('update'), 'icon' => 'icon-48-install'), array('name' => JText::_('HIKA_HELP'), 'url' => hikaserial::completeLink('documentation'), 'icon' => 'icon-48-help_header')); $this->assignRef('buttons', $buttons); if (HIKASHOP_J16 && JFactory::getUser()->authorise('core.admin', 'com_hikamarket')) { $this->toolbar[] = array('name' => 'preferences', 'component' => 'com_hikaserial'); } $this->toolbar[] = array('name' => 'pophelp', 'target' => 'welcome'); $toggleClass = hikaserial::get('helper.toggle'); $this->assignRef('toggleClass', $toggleClass); }
public function update() { $config = hikaserial::config(); if ($config->get('website') != HIKASHOP_LIVE) { $updateHelper = hikaserial::get('helper.update'); $updateHelper->addUpdateSite(); } hikaserial::setTitle(JText::_('UPDATE_ABOUT'), 'install', 'update'); $bar = JToolBar::getInstance('toolbar'); $bar->appendButton('Link', HIKASERIAL_LNAME, JText::_('HIKASHOP_CPANEL'), hikaserial::completeLink('dashboard')); $this->showIframe(HIKASERIAL_UPDATEURL . 'update'); return false; }
public function sql($tpl = null) { hikaserial::setTitle(JText::_('HIKA_CONFIGURATION_SQL'), self::icon, self::ctrl); $config = hikaserial::config(); $this->assignRef('config', $config); $toolbar = JToolBar::getInstance('toolbar'); $sql_data = JRequest::getVar('sql_data', '', '', 'string', JREQUEST_ALLOWRAW); $this->assignRef('sql_data', $sql_data); $user = JFactory::getUser(); $iAmSuperAdmin = false; if (!HIKASHOP_J16) { $iAmSuperAdmin = $user->get('gid') == 25; } else { $iAmSuperAdmin = $user->authorise('core.admin'); } $query_result = ''; if (!empty($sql_data) && $iAmSuperAdmin) { $p = strpos($sql_data, ' '); if ($p) { $db = JFactory::getDBO(); $word = strtolower(substr($sql_data, 0, $p)); if (in_array($word, array('insert', 'update', 'delete'))) { $db->setQuery($sql_data); $db->query(); $query_result = JText::_('HIKA_X_ROWS_AFFECTED', $db->getAffectedRows()); } else { if ($word == 'select') { $db->setQuery($sql_data); $query_result = $db->loadObjectList(); } else { if (in_array($word, array('create', 'drop', 'alter'))) { $db->setQuery($sql_data); if ($db->query()) { $query_result = JText::_('HIKA_QUERY_SUCCESS'); } else { $query_result = JText::_('HIKA_QUERY_FAILURE'); } } } } } } $this->assignRef('query_result', $query_result); $this->toolbar = array('|', array('name' => 'custom', 'icon' => 'apply', 'alt' => JText::_('APPLY'), 'task' => 'sql', 'check' => false), 'hikacancel', '|', array('name' => 'pophelp', 'target' => 'config'), 'dashboard'); }
function listing() { hikaserial::setTitle(JText::_(self::name), self::icon, self::ctrl); $bar = JToolBar::getInstance('toolbar'); $bar->appendButton('Link', HIKASERIAL_LNAME, JText::_('HIKASHOP_CPANEL'), hikaserial::completeLink('dashboard')); $config = hikaserial::config(); $level = $config->get('level'); $url = HIKASERIAL_HELPURL . 'documentation&level=' . $level; $shopConfig = hikaserial::config(false); $menu_style = $shopConfig->get('menu_style', 'title_bottom'); if (HIKASHOP_J30) { $menu_style = 'content_top'; } if ($menu_style == 'content_top') { echo hikaserial::getMenu(); } echo '<div id="hikaserial_div"><iframe allowtransparency="true" scrolling="auto" height="450px" frameborder="0" width="100%" name="hikaserial_frame" id="hikaserial_frame" src="' . $url . '"></iframe></div>'; }
public function import($tpl = null) { hikaserial::setTitle(JText::_(self::name), self::icon, self::ctrl); $this->toolbar = array('|', array('name' => 'custom', 'icon' => 'upload', 'alt' => JText::_('IMPORT'), 'task' => 'import', 'check' => false), '|', array('name' => 'pophelp', 'target' => self::ctrl), 'dashboard'); }
public function select() { $app = JFactory::getApplication(); $db = JFactory::getDBO(); hikaserial::setTitle(JText::_(self::name), self::icon, self::ctrl); $config = hikaserial::config(); $this->assignRef('config', $config); $shopConfig = hikaserial::config(false); $this->assignRef('shopConfig', $shopConfig); $serialStatusType = hikaserial::get('type.serial_status'); $this->assignRef('serialStatusType', $serialStatusType); $packType = hikaserial::get('type.pack'); $this->assignRef('packType', $packType); $filterType = $app->getUserStateFromRequest($this->paramBase . ".filter_type", 'filter_type', 0, 'int'); $singleSelection = JRequest::getVar('single', false); $this->assignRef('singleSelection', $singleSelection); $confirm = JRequest::getVar('confirm', true); $this->assignRef('confirm', $confirm); $elemStruct = array('serial_data', 'serial_id', 'serial_pack_id', 'serial_status', 'pack_name'); $this->assignRef('elemStruct', $elemStruct); $cfg = array('table' => 'serial', 'main_key' => 'serial_id', 'order_sql_value' => 'a.serial_id'); $manage = true; // TODO $this->assignRef('manage', $manage); $manage_shop_order = hikaserial::isAllowed($shopConfig->get('acl_order_manage', 'all')); $this->assignRef('manage_shop_order', $manage_shop_order); $manage_shop_user = hikaserial::isAllowed($shopConfig->get('acl_user_manage', 'all')); $this->assignRef('manage_shop_user', $manage_shop_user); $pageInfo = new stdClass(); $filters = array(); $pageInfo->filter = new stdClass(); $pageInfo->filter->serial_status = $app->getUserStateFromRequest($this->paramBase . ".filter_status", 'filter_status', '', 'string'); $pageInfo->filter->pack = $app->getUserStateFromRequest($this->paramBase . ".filter_pack", 'filter_pack', '', 'string'); $pageInfo->filter->order = new stdClass(); $pageInfo->filter->order->value = $app->getUserStateFromRequest($this->paramBase . ".filter_order", 'filter_order', $cfg['order_sql_value'], 'cmd'); $pageInfo->filter->order->dir = $app->getUserStateFromRequest($this->paramBase . ".filter_order_Dir", 'filter_order_Dir', 'asc', 'word'); $pageInfo->limit = new stdClass(); $pageInfo->limit->value = $app->getUserStateFromRequest($this->paramBase . '.list_limit', 'limit', $app->getCfg('list_limit'), 'int'); if (empty($pageInfo->limit->value)) { $pageInfo->limit->value = 500; } if (JRequest::getVar('search') != $app->getUserState($this->paramBase . ".search")) { $app->setUserState($this->paramBase . '.limitstart', 0); $pageInfo->limit->start = 0; } else { $pageInfo->limit->start = $app->getUserStateFromRequest($this->paramBase . '.limitstart', 'limitstart', 0, 'int'); } $pageInfo->search = JString::strtolower($app->getUserStateFromRequest($this->paramBase . ".search", 'search', '', 'string')); $this->assignRef('pageInfo', $pageInfo); $filters = array(); $searchMap = array('a.serial_id', 'a.serial_data', 'a.serial_status', 'b.pack_name', 'd.username'); if (!empty($pageInfo->search)) { $searchVal = '\'%' . $db->getEscaped(JString::strtolower($pageInfo->search), true) . '%\''; $filters[] = '(' . implode(' LIKE ' . $searchVal . ' OR ', $searchMap) . ' LIKE ' . $searchVal . ')'; } if (!empty($pageInfo->filter->serial_status)) { $filters[] = ' a.serial_status = ' . $db->quote($pageInfo->filter->serial_status); } if (!empty($pageInfo->filter->pack)) { if ((int) $pageInfo->filter->pack > 0) { $filters[] = ' b.pack_id = ' . (int) $pageInfo->filter->pack; } else { $filters[] = ' b.pack_name = ' . $db->quote($pageInfo->filter->pack); } } if (!empty($filters)) { $filters = ' WHERE ' . implode(' AND ', $filters); } else { $filters = ''; } $order = ''; if (!empty($pageInfo->filter->order->value)) { $order = ' ORDER BY ' . $pageInfo->filter->order->value . ' ' . $pageInfo->filter->order->dir; } $query = 'FROM ' . hikaserial::table($cfg['table']) . ' AS a INNER JOIN ' . hikaserial::table('pack') . ' AS b ON a.serial_pack_id = b.pack_id LEFT JOIN ' . hikaserial::table('shop.user') . ' AS c ON a.serial_user_id = c.user_id LEFT JOIN ' . hikaserial::table('users', false) . ' AS d ON c.user_cms_id = d.id LEFT JOIN ' . hikaserial::table('shop.order') . ' AS e ON a.serial_order_id = e.order_id ' . $filters . $order; $db->setQuery('SELECT * ' . $query, (int) $pageInfo->limit->start, (int) $pageInfo->limit->value); $rows = $db->loadObjectList(); if (!empty($pageInfo->search)) { $rows = hikaserial::search($pageInfo->search, $rows, $cfg['main_key']); } $this->assignRef('rows', $rows); JPluginHelper::importPlugin('hikaserial'); $dispatcher = JDispatcher::getInstance(); $dispatcher->trigger('onDisplaySerials', array(&$rows, 'back-serial-listing')); $db->setQuery('SELECT COUNT(*) ' . $query); $pageInfo->elements = new stdClass(); $pageInfo->elements->total = $db->loadResult(); $pageInfo->elements->page = count($rows); jimport('joomla.html.pagination'); if ($pageInfo->limit->value == 500) { $pageInfo->limit->value = 100; } $pagination = new JPagination($pageInfo->elements->total, $pageInfo->limit->start, $pageInfo->limit->value); $this->assignRef('pagination', $pagination); $doOrdering = !$filterType; $this->assignRef('doOrdering', $doOrdering); if ($doOrdering) { $ordering = new stdClass(); $ordering->ordering = false; $ordering->orderUp = 'orderup'; $ordering->orderDown = 'orderdown'; $ordering->reverse = false; if ($pageInfo->filter->order->value == 'a.ordering') { $ordering->ordering = true; if ($pageInfo->filter->order->dir == 'desc') { $ordering->orderUp = 'orderdown'; $ordering->orderDown = 'orderup'; $ordering->reverse = true; } } $this->assignRef('ordering', $ordering); } }
public function generate($tpl = null) { $app = JFactory::getApplication(); $db = JFactory::getDBO(); JHTML::_('behavior.modal'); $ctrl = ''; $pack_id = hikaserial::getCID(); if (empty($pack_id)) { $app->redirect(hikaserial::completeLink('pack&task=list')); } $packClass = hikaserial::get('class.pack'); $pack = $packClass->get($pack_id); $task = 'generate'; $cid = '&cid[]=' . $pack_id; $ctrl .= '&task=' . $task . $cid; $this->assignRef('task', $task); $this->assignRef('pack', $pack); $generator = null; if (substr($pack->pack_generator, 0, 4) == 'plg.') { $pluginName = substr($pack->pack_generator, 4); if (strpos($pluginName, '-') !== false) { list($pluginName, $pluginId) = explode('-', $pluginName, 2); $pack->{$pluginName} = $pluginId; } $generator = hikaserial::import('hikaserial', $pluginName); } if (!empty($generator) && (!method_exists($generator, 'canPopulate') || $generator->canPopulate() != true)) { $app->enqueueMessage(JText::_('PLUGIN_GENERATOR_CAN_NOT_POPULATE')); $app->redirect(hikaserial::completeLink('pack&task=edit&cid[]=' . $pack_id, false, true)); } $populateFormData = ''; if (!empty($generator) && method_exists($generator, 'populateForm')) { $populateFormData = $generator->populateForm($pack); } $this->assignRef('populateFormData', $populateFormData); $packGeneratorType = hikaserial::get('type.pack_generator'); $this->assignRef('packGeneratorType', $packGeneratorType); $serialStatusType = hikaserial::get('type.serial_status'); $this->assignRef('serialStatusType', $serialStatusType); hikaserial::setTitle(JText::_(self::name), self::icon, self::ctrl . $ctrl); $this->toolbar = array(array('name' => 'custom', 'icon' => 'upload', 'task' => 'generate', 'alt' => JText::_('GENERATE'), 'check' => false), array('name' => 'hikacancel', 'url' => hikaserial::completeLink('pack&task=edit&cid[]=' . $pack_id)), '|', array('name' => 'pophelp', 'target' => self::ctrl . '-form')); }
public function form() { JHTML::_('behavior.modal'); $app = JFactory::getApplication(); $db = JFactory::getDBO(); $config = hikaserial::config(); $task = JRequest::getVar('task'); $this->content = ''; $this->plugin_name = JRequest::getCmd('name', ''); if (empty($this->plugin_name)) { return false; } $plugin = hikaserial::import('hikaserial', $this->plugin_name); if (!$plugin || !method_exists($plugin, 'type')) { $app->enqueueMessage('Fail to load the plugin or the plugin is not an HikaSerial one', 'error'); return false; } $this->plugin_type = $plugin->type(); $query = ''; if (in_array($this->plugin_type, array('generator', 'consumer', 'plugin'))) { $query = 'SELECT * FROM ' . hikaserial::table($this->plugin_type) . ' WHERE ' . $this->plugin_type . '_type = ' . $db->Quote($this->plugin_name); $query .= ' ORDER BY ' . $this->plugin_type . '_ordering ASC'; } if (empty($query)) { return false; } $db->setQuery($query); $elements = $db->loadObjectList($this->plugin_type . '_id'); if (!empty($elements)) { $params_name = $this->plugin_type . '_params'; foreach ($elements as $k => $el) { if (!empty($el->{$params_name})) { $elements[$k]->{$params_name} = unserialize($el->{$params_name}); } } } $multiple_plugin = false; if (method_exists($plugin, 'isMultiple')) { $multiple_plugin = $plugin->isMultiple(); } $function = 'onPluginConfiguration'; $ctrl = '&plugin_type=' . $this->plugin_type . '&task=edit&name=' . $this->plugin_name; if ($multiple_plugin === true) { $subtask = JRequest::getCmd('subtask', ''); $ctrl .= '&subtask=' . $subtask; if (empty($subtask)) { $function = 'onPluginMultipleConfiguration'; } $cid = hikaserial::getCID($this->plugin_type . '_id'); if (isset($elements[$cid])) { $this->assignRef('element', $elements[$cid]); $ctrl .= '&' . $this->plugin_type . '_id=' . $cid; } } else { if (!empty($elements)) { $this->assignRef('element', reset($elements)); } } $this->assignRef('elements', $elements); $setTitle = true; if (method_exists($plugin, $function)) { if (empty($plugin->title)) { $plugin->title = JText::_('HIKAS_PLUGIN') . ' ' . $this->plugin_name; } $plugin->ctrl_url = self::ctrl . $ctrl; ob_start(); $plugin->{$function}($elements); $this->content = ob_get_clean(); $this->data = $plugin->getProperties(); $setTitle = false; } $this->assignRef('name', $this->plugin_name); $this->assignRef('plugin', $plugin); $this->assignRef('multiple_plugin', $multiple_plugin); $this->assignRef('content', $this->content); $this->assignRef('plugin_type', $this->plugin_type); if (empty($plugin->pluginView)) { $this->content .= $this->loadPluginTemplate(@$plugin->view, $this->plugin_type); } if ($setTitle) { hikaserial::setTitle(JText::_('HIKAS_PLUGIN') . ' ' . $this->name, self::icon, self::ctrl . $ctrl); } return true; }
public function form() { $app = JFactory::getApplication(); $db = JFactory::getDBO(); JHTML::_('behavior.modal'); $ctrl = ''; $cid = ''; $cancelUrl = urlencode(base64_encode(hikaserial::completeLink('serial'))); $this->assignRef('cancelUrl', $cancelUrl); $config = hikaserial::config(); $this->assignRef('config', $config); $shopConfig = hikaserial::config(false); $this->assignRef('shopConfig', $shopConfig); $popup = hikaserial::get('shop.helper.popup'); $this->assignRef('popup', $popup); $manage = true; // TODO $this->assignRef('manage', $manage); $manage_shop_order = hikaserial::isAllowed($shopConfig->get('acl_order_manage', 'all')); $this->assignRef('manage_shop_order', $manage_shop_order); $manage_shop_user = hikaserial::isAllowed($shopConfig->get('acl_user_manage', 'all')); $this->assignRef('manage_shop_user', $manage_shop_user); $serial = null; $serial_id = hikaserial::getCID(); if (!empty($serial_id)) { $serialClass = hikaserial::get('class.serial'); $serial = $serialClass->get($serial_id, true); $task = 'edit'; $cid = '&cid[]=' . $serial_id; $cancelUrl = urlencode(base64_encode(hikaserial::completeLink('serial&task=edit&cid[]=' . $serial_id))); } else { $task = 'add'; } $ctrl .= '&task=' . $task . $cid; $this->assignRef('task', $task); $this->assignRef('serial', $serial); JPluginHelper::importPlugin('hikaserial'); $dispatcher = JDispatcher::getInstance(); $serials = array(&$serial); $dispatcher->trigger('onDisplaySerials', array(&$serials, 'back-serial-form')); $packType = hikaserial::get('type.pack'); $this->assignRef('packType', $packType); $serialStatusType = hikaserial::get('type.serial_status'); $this->assignRef('serialStatusType', $serialStatusType); hikaserial::setTitle(JText::_(self::name), self::icon, self::ctrl . $ctrl); $this->toolbar = array('|', 'save', 'apply', 'hikacancel', '|', array('name' => 'pophelp', 'target' => self::ctrl . '-form')); }