function display($tpl = null) { $mainframe = MFactory::getApplication(); $option = MRequest::getCmd('option'); $document = MFactory::getDocument(); $document->addStyleSheet(MURL_MIWOSQL . '/admin/assets/css/miwosql.css'); MToolBarHelper::title(MText::_('MiwoSQL') . ' - ' . MText::_('COM_MIWOSQL_SAVED_QUERIES'), 'miwosql'); MToolBarHelper::editList(); MToolBarHelper::deleteList(); // ACL if (version_compare(MVERSION, '1.6.0', 'ge') && MFactory::getUser()->authorise('core.admin', 'com_miwosql')) { MToolBarHelper::divider(); MToolBarHelper::preferences('com_miwosql', '550'); } $this->mainframe = MFactory::getApplication(); $this->option = MRequest::getWord('option'); $filter_order = $mainframe->getUserStateFromRequest($option . '.queries.filter_order', 'filter_order', 'title', 'string'); $filter_order_Dir = $mainframe->getUserStateFromRequest($option . '.queries.filter_order_Dir', 'filter_order_Dir', '', 'word'); $search = $mainframe->getUserStateFromRequest($option . '.queries.search', 'search', '', 'string'); // table ordering $lists['order_Dir'] = $filter_order_Dir; $lists['order'] = $filter_order; // search filter $lists['search'] = $search; $this->lists = $lists; $this->items = $this->get('Data'); $this->pagination = $this->get('Pagination'); parent::display($tpl); }
public function apply() { // Check for request forgeries MRequest::checkToken() or mexit('Invalid Token'); if ($this->_model->save($this->_table, $this->_query)) { $msg = MText::_('COM_MIWOSQL_SAVE_TRUE'); } else { $msg = MText::_('COM_MIWOSQL_SAVE_FALSE'); } $id = MRequest::getInt('id', MRequest::getInt('id', null, 'post'), 'get'); $key = MRequest::getCmd('key', MRequest::getCmd('key', null, 'post'), 'get'); $vars = '&ja_tbl_g=' . base64_encode($this->_table) . '&ja_qry_g=' . base64_encode($this->_query) . '&key=' . $key . '&id=' . $id; $this->setRedirect('index.php?option=com_miwosql&task=edit' . $vars, $msg); }
public function delete($table) { $sql = MiwosqlHelper::getVar('qry'); $key = MRequest::getString('key', null, 'get'); if (!is_null($sql) && !is_null($key)) { $id = MRequest::getCmd('id', null, 'get'); $this->_db->setQuery("DELETE FROM {$table} WHERE {$key} = '{$id}'"); $this->_db->query(); if (!empty($this->_db->_errorMsg)) { echo '<small style="color:red;">' . $this->_db->_errorMsg . '</small><br/>'; return false; } else { return true; } } }
public function display($tpl = null) { $db = MFactory::getDbo(); $task = MRequest::getCmd('task'); $table = MiwosqlHelper::getVar('tbl'); $query = MiwosqlHelper::getVar('qry'); $id = MRequest::getInt('id', MRequest::getInt('id', null, 'post'), 'get'); $key = MRequest::getCmd('key', MRequest::getCmd('key', null, 'post'), 'get'); $document = MFactory::getDocument(); $document->addStyleSheet(MURL_MIWOSQL . '/admin/assets/css/miwosql.css'); // Toolbar MToolBarHelper::title(MText::_('MiwoSQL') . ': <small><small> ' . $table . ' [ ' . $key . ' = ' . $id . ' ]' . ' </small></small>', 'miwosql'); MToolBarHelper::apply(); MToolBarHelper::save(); MToolBarHelper::divider(); MToolBarHelper::cancel(); if ($task == 'edit') { $fld_value = '$value = $this->rows[$this->id][$field];'; } else { $fld_value = '$value = "";'; } list($rows, $last_key_vol) = $this->get('Data'); $this->task = $task; $this->id = $id; $this->key = $key; $this->table = $table; $this->query = $query; $this->fld_value = $fld_value; $this->last_key_vol = $last_key_vol; $this->rows = $rows; $fields = $this->get('Fields'); if (!MiwosqlHelper::is30()) { $fields = $fields[$this->table]; } $this->fields = $fields; parent::display($tpl); }
public function metadata() { $option = MRequest::getCmd('option'); if ($option != 'com_' . $this->context) { return; } if (defined('MIWI_IS_ITEM')) { return; } $document = MFactory::getDocument(); $metadata = array(); if ($meta_desc = $document->getMetadata('description')) { $metadata[] = '<meta name="description" content="' . $meta_desc . '" />'; } if ($meta_keywords = $document->getMetadata('keywords')) { $metadata[] = '<meta name="keywords" content="' . $meta_keywords . '" />'; } if ($meta_author = $document->getMetadata('author')) { $metadata[] = '<meta name="author" content="' . $meta_author . '" />'; } $base = MFactory::getUri()->base(); $metadata[] = '<base href="' . $base . '" />'; echo implode("\n", $metadata); }
public function getParams($option = null) { static $params = array(); $hash = '__default'; if (!empty($option)) { $hash = $option; } if (!isset($params[$hash])) { // Get component parameters if (!$option) { $option = MRequest::getCmd('option'); } // Get new instance of component global parameters $params[$hash] = clone MComponentHelper::getParams($option); } return $params[$hash]; }
public function save($table, $query) { $key = MRequest::getCmd('key', null, 'post'); $fields = MRequest::getVar('fields', array(), 'post', 'array'); if (!is_null($table) && !is_null($query) && !empty($fields)) { $sql_save = "UPDATE {$table} SET "; $i = 0; $comma = ', '; $cnt = count($fields); foreach ($fields as $name => $val) { $i++; if ($cnt <= $i) { $comma = ''; } $sql_save .= "`{$name}`='" . htmlspecialchars($val, ENT_QUOTES) . "'" . $comma; } $sql_save .= " WHERE `{$key}`='" . $fields[$key] . "'"; } $this->_db->setQuery($sql_save); $this->_db->loadAssocList(); if (!empty($this->_db->_errorMsg)) { echo '<small style="color:red;">' . $this->_db->_errorMsg . '</small><br/>'; return false; } else { return true; } }
protected function cleanCache($group = null, $client_id = 0) { // Initialise variables; $conf = MFactory::getConfig(); $dispatcher = MDispatcher::getInstance(); $options = array('defaultgroup' => $group ? $group : (isset($this->option) ? $this->option : MRequest::getCmd('option')), 'cachebase' => MPATH_CACHE); $cache = MCache::getInstance('callback', $options); $cache->clean(); // Trigger the onContentCleanCache event. $dispatcher->trigger($this->event_clean_cache, $options); }
protected function getInput() { $assetField = $this->element['asset_field'] ? (string) $this->element['asset_field'] : 'asset_id'; $authorField = $this->element['created_by_field'] ? (string) $this->element['created_by_field'] : 'created_by'; $asset = $this->form->getValue($assetField) ? $this->form->getValue($assetField) : (string) $this->element['asset_id']; if ($asset == '') { $asset = MRequest::getCmd('option'); } $link = (string) $this->element['link']; if (!self::$initialised) { // Load the modal behavior script. MHtml::_('behavior.modal'); // Build the script. $script = array(); $script[] = ' function jInsertFieldValue(value, id) {'; $script[] = ' var old_value = document.id(id).value;'; $script[] = ' if (old_value != value) {'; $script[] = ' var elem = document.id(id);'; $script[] = ' elem.value = value;'; $script[] = ' elem.fireEvent("change");'; $script[] = ' if (typeof(elem.onchange) === "function") {'; $script[] = ' elem.onchange();'; $script[] = ' }'; $script[] = ' jMediaRefreshPreview(id);'; $script[] = ' }'; $script[] = ' }'; $script[] = ' function jMediaRefreshPreview(id) {'; $script[] = ' var value = document.id(id).value;'; $script[] = ' var img = document.id(id + "_preview");'; $script[] = ' if (img) {'; $script[] = ' if (value) {'; $script[] = ' img.src = "' . MURI::root() . '" + value;'; $script[] = ' document.id(id + "_preview_empty").setStyle("display", "none");'; $script[] = ' document.id(id + "_preview_img").setStyle("display", "");'; $script[] = ' } else { '; $script[] = ' img.src = ""'; $script[] = ' document.id(id + "_preview_empty").setStyle("display", "");'; $script[] = ' document.id(id + "_preview_img").setStyle("display", "none");'; $script[] = ' } '; $script[] = ' } '; $script[] = ' }'; $script[] = ' function jMediaRefreshPreviewTip(tip)'; $script[] = ' {'; $script[] = ' tip.setStyle("display", "block");'; $script[] = ' var img = tip.getElement("img.media-preview");'; $script[] = ' var id = img.getProperty("id");'; $script[] = ' id = id.substring(0, id.length - "_preview".length);'; $script[] = ' jMediaRefreshPreview(id);'; $script[] = ' }'; // Add the script to the document head. MFactory::getDocument()->addScriptDeclaration(implode("\n", $script)); self::$initialised = true; } // Initialize variables. $html = array(); $attr = ''; // Initialize some field attributes. $attr .= $this->element['class'] ? ' class="' . (string) $this->element['class'] . '"' : ''; $attr .= $this->element['size'] ? ' size="' . (int) $this->element['size'] . '"' : ''; // Initialize JavaScript field attributes. $attr .= $this->element['onchange'] ? ' onchange="' . (string) $this->element['onchange'] . '"' : ''; // The text field. $html[] = '<div class="fltlft">'; $html[] = ' <input type="text" name="' . $this->name . '" id="' . $this->id . '"' . ' value="' . htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8') . '"' . ' readonly="readonly"' . $attr . ' />'; $html[] = '</div>'; $directory = (string) $this->element['directory']; if ($this->value && file_exists(MPATH_ROOT . '/' . $this->value)) { $folder = explode('/', $this->value); array_shift($folder); array_pop($folder); $folder = implode('/', $folder); } elseif (file_exists(MPATH_ROOT . '/' . MComponentHelper::getParams('com_media')->get('image_path', 'images') . '/' . $directory)) { $folder = $directory; } else { $folder = ''; } // The button. $html[] = '<div class="button2-left">'; $html[] = ' <div class="blank">'; $html[] = ' <a class="modal" title="' . MText::_('MLIB_FORM_BUTTON_SELECT') . '"' . ' href="' . ($this->element['readonly'] ? '' : ($link ? $link : 'index.php?option=com_media&view=images&tmpl=component&asset=' . $asset . '&author=' . $this->form->getValue($authorField)) . '&fieldid=' . $this->id . '&folder=' . $folder) . '"' . ' rel="{handler: \'iframe\', size: {x: 800, y: 500}}">'; $html[] = MText::_('MLIB_FORM_BUTTON_SELECT') . '</a>'; $html[] = ' </div>'; $html[] = '</div>'; $html[] = '<div class="button2-left">'; $html[] = ' <div class="blank">'; $html[] = ' <a title="' . MText::_('MLIB_FORM_BUTTON_CLEAR') . '"' . ' href="#" onclick="'; $html[] = 'jInsertFieldValue(\'\', \'' . $this->id . '\');'; $html[] = 'return false;'; $html[] = '">'; $html[] = MText::_('MLIB_FORM_BUTTON_CLEAR') . '</a>'; $html[] = ' </div>'; $html[] = '</div>'; // The Preview. $preview = (string) $this->element['preview']; $showPreview = true; $showAsTooltip = false; switch ($preview) { case 'false': case 'none': $showPreview = false; break; case 'true': case 'show': break; case 'tooltip': default: $showAsTooltip = true; $options = array('onShow' => 'jMediaRefreshPreviewTip'); MHtml::_('behavior.tooltip', '.hasTipPreview', $options); break; } if ($showPreview) { if ($this->value && file_exists(MPATH_ROOT . '/' . $this->value)) { $src = MURI::root() . $this->value; } else { $src = ''; } $attr = array('id' => $this->id . '_preview', 'class' => 'media-preview', 'style' => 'max-width:160px; max-height:100px;'); $img = MHtml::image($src, MText::_('MLIB_FORM_MEDIA_PREVIEW_ALT'), $attr); $previewImg = '<div id="' . $this->id . '_preview_img"' . ($src ? '' : ' style="display:none"') . '>' . $img . '</div>'; $previewImgEmpty = '<div id="' . $this->id . '_preview_empty"' . ($src ? ' style="display:none"' : '') . '>' . MText::_('MLIB_FORM_MEDIA_PREVIEW_EMPTY') . '</div>'; $html[] = '<div class="media-preview fltlft">'; if ($showAsTooltip) { $tooltip = $previewImgEmpty . $previewImg; $options = array('title' => MText::_('MLIB_FORM_MEDIA_PREVIEW_SELECTED_IMAGE'), 'text' => MText::_('MLIB_FORM_MEDIA_PREVIEW_TIP_TITLE'), 'class' => 'hasTipPreview'); $html[] = MHtml::tooltip($tooltip, $options); } else { $html[] = ' ' . $previewImgEmpty; $html[] = ' ' . $previewImg; } $html[] = '</div>'; } return implode("\n", $html); }
/** * @package MiwoSQL * @copyright 2009-2012 Mijosoft LLC, www.mijosoft.com * @license GNU/GPL http://www.gnu.org/copyleft/gpl.html */ // no direct access defined('MIWI') or die('Restricted access'); if (version_compare(MVERSION, '1.6.0', 'ge')) { if (!MFactory::getUser()->authorise('core.manage', 'com_miwosql')) { return MError::raiseWarning(404, MText::_('MERROR_ALERTNOAUTHOR')); } } require_once MPATH_COMPONENT . '/mvc/model.php'; require_once MPATH_COMPONENT . '/mvc/view.php'; require_once MPATH_COMPONENT . '/mvc/controller.php'; require_once MPATH_COMPONENT . '/toolbar.php'; require_once MPATH_COMPONENT . '/helpers/helper.php'; MTable::addIncludePath(MPATH_COMPONENT . '/tables'); if ($controller = MRequest::getWord('controller')) { $path = MPATH_COMPONENT . '/controllers/' . $controller . '.php'; if (file_exists($path)) { require_once $path; } else { $controller = ''; } } $classname = 'MiwosqlController' . ucfirst($controller); $controller = new $classname(); $controller->execute(MRequest::getCmd('task')); $controller->redirect(); echo '<div style="margin: 10px; text-align: center;"><a href="http://miwisoft.com/wordpress-plugins/miwosql" target="_blank">MiwoSQL | Copyright © 2009-2014 Miwisoft LLC</a></div>';
public function display($cachable = false, $urlparams = false) { $document = MFactory::getDocument(); $viewType = $document->getType(); $viewName = MRequest::getCmd('view', $this->default_view); $viewLayout = MRequest::getCmd('layout', 'default'); $view = $this->getView($viewName, $viewType, '', array('base_path' => $this->basePath, 'layout' => $viewLayout)); // Get/Create the model if ($model = $this->getModel($viewName)) { // Push the model into the view (as default) $view->setModel($model, true); } $view->document = $document; $conf = MFactory::getConfig(); // Display the view if ($cachable && $viewType != 'feed' && $conf->get('caching') >= 1) { $option = MRequest::getCmd('option'); $cache = MFactory::getCache($option, 'view'); if (is_array($urlparams)) { $app = MFactory::getApplication(); if (!empty($app->registeredurlparams)) { $registeredurlparams = $app->registeredurlparams; } else { $registeredurlparams = new stdClass(); } foreach ($urlparams as $key => $value) { // Add your safe url parameters with variable type as value {@see MFilterInput::clean()}. $registeredurlparams->{$key} = $value; } $app->registeredurlparams = $registeredurlparams; } $cache->get($view, 'display'); } else { $view->display(); } return $this; }
public static function getPath($varname, $user_option = null) { // Check needed for handling of custom/new module XML file loading $check = $varname == 'mod0_xml' || $varname == 'mod1_xml'; if (!$user_option && !$check) { $user_option = MRequest::getCmd('option'); } else { $user_option = MFilterInput::getInstance()->clean($user_option, 'path'); } $result = null; $name = substr($user_option, 4); switch ($varname) { case 'front': $result = self::_checkPath('/components/' . $user_option . '/' . $name . '.php', 0); break; case 'html': case 'front_html': if (!($result = self::_checkPath('/templates/' . MApplication::getTemplate() . '/components/' . $name . '.html.php', 0))) { $result = self::_checkPath('/components/' . $user_option . '/' . $name . '.html.php', 0); } break; case 'toolbar': $result = self::_checkPath('/components/' . $user_option . '/toolbar.' . $name . '.php', -1); break; case 'toolbar_html': $result = self::_checkPath('/components/' . $user_option . '/toolbar.' . $name . '.html.php', -1); break; case 'toolbar_default': case 'toolbar_front': $result = self::_checkPath('/includes/HTML_toolbar.php', 0); break; case 'admin': $path = '/components/' . $user_option . '/admin.' . $name . '.php'; $result = self::_checkPath($path, -1); if ($result == null) { $path = '/components/' . $user_option . '/' . $name . '.php'; $result = self::_checkPath($path, -1); } break; case 'admin_html': $path = '/components/' . $user_option . '/admin.' . $name . '.html.php'; $result = self::_checkPath($path, -1); break; case 'admin_functions': $path = '/components/' . $user_option . '/' . $name . '.functions.php'; $result = self::_checkPath($path, -1); break; case 'class': if (!($result = self::_checkPath('/components/' . $user_option . '/' . $name . '.class.php'))) { $result = self::_checkPath('/includes/' . $name . '.php'); } break; case 'helper': $path = '/components/' . $user_option . '/' . $name . '.helper.php'; $result = self::_checkPath($path); break; case 'com_xml': $path = '/components/' . $user_option . '/' . $name . '.xml'; $result = self::_checkPath($path, 1); break; case 'mod0_xml': $path = '/modules/' . $user_option . '/' . $user_option . '.xml'; $result = self::_checkPath($path); break; case 'mod1_xml': // Admin modules $path = '/modules/' . $user_option . '/' . $user_option . '.xml'; $result = self::_checkPath($path, -1); break; case 'plg_xml': // Site plugins $j15path = '/plugins/' . $user_option . '.xml'; $parts = explode(DIRECTORY_SEPARATOR, $user_option); $j16path = '/plugins/' . $user_option . '/' . $parts[1] . '.xml'; $j15 = self::_checkPath($j15path, 0); $j16 = self::_checkPath($j16path, 0); // Return 1.6 if working otherwise default to whatever 1.5 gives us $result = $j16 ? $j16 : $j15; break; case 'menu_xml': $path = '/components/com_menus/' . $user_option . '/' . $user_option . '.xml'; $result = self::_checkPath($path, -1); break; } return $result; }
public static function isActiveSubMenu($src) { $state = false; $controller = MRequest::getCmd('controller'); switch ($src) { case 'query': if (empty($controller) || $controller == 'miwosql') { $state = true; } break; case 'queries': if ($controller == 'queries') { $state = true; } break; } return $state; }
protected function _parseSefRoute(&$uri) { $route = $uri->getPath(); // Get the variables from the uri $vars = $uri->getQuery(true); // Handle an empty URL (special case) if (empty($route)) { // If route is empty AND option is set in the query, assume it's non-sef url, and parse apropriately if (isset($vars['option'])) { return $this->_parseRawRoute($uri); } return $vars; } $segments = explode('/', $route); if (!empty($segments[0])) { $page = get_page_by_path($segments[0]); if (is_object($page)) { $vars['page_id'] = $page->ID; $vars['option'] = MRequest::getCmd('option'); array_shift($segments); } } // Set the variables $this->setVars($vars); if (!empty($route) and isset($this->_vars['option'])) { //$segments = explode('/', $route); if (empty($segments[0])) { array_shift($segments); } // Handle component route $component = preg_replace('/[^A-Z0-9_\\.-]/i', '', $this->_vars['option']); // Use the component routing handler if it exists $path = MPATH_WP_PLG . '/' . str_replace('com_', '', $component) . '/site/router.php'; if (file_exists($path) && count($segments)) { //decode the route segments $segments = $this->_decodeSegments($segments); require_once $path; $function = str_replace('com_', '', $component) . 'ParseRoute'; $function = str_replace(array("-", "."), "", $function); $vars = $function($segments); $this->setVars($vars); } } return $vars; }