Example #1
0
 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);
 }
Example #2
0
 public static function getInstance($prefix, $config = array())
 {
     if (is_object(self::$instance)) {
         return self::$instance;
     }
     // Get the environment configuration.
     $basePath = array_key_exists('base_path', $config) ? $config['base_path'] : MPATH_COMPONENT;
     $format = MRequest::getWord('format');
     $command = MRequest::getVar('task', 'display');
     // Check for array format.
     $filter = MFilterInput::getInstance();
     if (is_array($command)) {
         $command = $filter->clean(array_pop(array_keys($command)), 'cmd');
     } else {
         $command = $filter->clean($command, 'cmd');
     }
     // Check for a controller.task command.
     if (strpos($command, '.') !== false) {
         // Explode the controller.task command.
         list($type, $task) = explode('.', $command);
         // Define the controller filename and path.
         $file = self::createFileName('controller', array('name' => $type, 'format' => $format));
         $path = $basePath . '/controllers/' . $file;
         // Reset the task without the controller context.
         MRequest::setVar('task', $task);
     } else {
         // Base controller.
         $type = null;
         $task = $command;
         // Define the controller filename and path.
         $file = self::createFileName('controller', array('name' => 'controller', 'format' => $format));
         $path = $basePath . '/' . $file;
         $backupfile = self::createFileName('controller', array('name' => 'controller'));
         $backuppath = $basePath . '/' . $backupfile;
     }
     // Get the controller class name.
     $class = ucfirst($prefix) . 'Controller' . ucfirst($type);
     // Include the class if not present.
     if (!class_exists($class)) {
         // If the controller file path exists, include it.
         if (file_exists($path)) {
             require_once $path;
         } elseif (isset($backuppath) && file_exists($backuppath)) {
             require_once $backuppath;
         } else {
             throw new InvalidArgumentException(MText::sprintf('MLIB_APPLICATION_ERROR_INVALID_CONTROLLER', $type, $format));
         }
     }
     // Instantiate the class.
     if (class_exists($class)) {
         self::$instance = new $class($config);
     } else {
         throw new InvalidArgumentException(MText::sprintf('MLIB_APPLICATION_ERROR_INVALID_CONTROLLER_CLASS', $class));
     }
     return self::$instance;
 }
Example #3
0
 public function __construct($context, $menu_id = 33, $has_config = true, $title = '')
 {
     $this->context = $context;
     $this->menu_id = $menu_id;
     $this->has_config = $has_config;
     $this->title = $title;
     $this->constants();
     $this->initialise();
     if (!defined('MIWI')) {
         return;
     }
     add_action('init', array($this, 'initialise'));
     //add_action('widgets_init', array($this, 'widgets'));
     $this->widgets();
     if ($this->app->isAdmin()) {
         add_action('admin_menu', array($this, 'menu'));
         add_action('admin_init', array($this, 'preDisplayAdmin'));
         $pack = strtoupper($this->context) . '_PACK';
         if (MRequest::getWord('option') != 'com_' . $this->context and constant($pack) == 'pro') {
             add_filter('media_buttons_context', array($this, 'shortcodeButton'));
             add_action('admin_footer', array($this, 'shortcodePopup'));
         }
         add_action('admin_enqueue_scripts', array($this, 'safelyAddScript'), 999);
         add_action('admin_enqueue_scripts', array($this, 'safelyAddStylesheet'), 999);
     } else {
         add_filter('rewrite_rules_array', array($this, 'miwiFrontendRewrite'));
         add_action('wp_loaded', array($this, 'miwiFlushRewriteRules'));
         add_action('parse_query', array($this, 'parse'));
         add_action('wp_head', array($this, 'metadata'));
         add_action('template_redirect', array($this, 'preDisplay'));
         add_action('template_redirect', array($this, 'modulePreDisplay'));
         add_action('wp_enqueue_scripts', array($this, 'safelyAddScript'), 999);
         add_action('wp_enqueue_scripts', array($this, 'safelyAddStylesheet'), 999);
     }
     # ajax hooks
     add_action('wp_head', array($this, 'ajaxurl'), 999);
     add_action('wp_ajax_' . $this->context, array($this, 'ajax'));
     add_action('wp_ajax_nopriv_' . $this->context, array($this, 'ajax'));
     #search hooks
     add_filter('the_posts', array($this, 'search'), 10, 2);
     add_filter('post_link', array($this, 'fixSearchLink'), 10, 2);
     add_filter('get_edit_post_link', array($this, 'fixEditPostLink'), 10, 2);
     #shortcode hooks
     add_shortcode($this->context, array($this, 'shortcode'));
     add_shortcode($this->context . '_item', array($this, 'shortcode'));
     add_filter('plugin_row_meta', array($this, 'links'), 10, 2);
     # upgrade hooks
     add_filter('upgrader_source_selection', array($this, 'miwiPreUpgrade'), 10, 2);
     add_filter('upgrader_post_install', array($this, 'miwiPostUpgrade'), 10, 3);
 }
Example #4
0
 function __construct()
 {
     parent::__construct();
     $this->mainframe = MFactory::getApplication();
     $this->option = MRequest::getWord('option');
     // Get the pagination request variables
     $limit = $this->mainframe->getUserStateFromRequest($this->option . '.queries.limit', 'limit', $this->mainframe->getCfg('list_limit'), 'int');
     $limitstart = $this->mainframe->getUserStateFromRequest($this->option . '.queries.limitstart', 'limitstart', 0, 'int');
     // In case limit has been changed, adjust limitstart accordingly
     $limitstart = $limit != 0 ? floor($limitstart / $limit) * $limit : 0;
     $this->setState($this->option . '.queries.limit', $limit);
     $this->setState($this->option . '.queries.limitstart', $limitstart);
     $this->_buildViewQuery();
 }
Example #5
0
 protected static function createDocument()
 {
     $lang = self::getLanguage();
     // @deprecated 12.1 This will be removed in the next version
     $raw = MRequest::getBool('no_html');
     $type = MRequest::getWord('format', $raw ? 'raw' : 'html');
     $attributes = array('charset' => 'utf-8', 'lineend' => 'unix', 'tab' => '  ', 'language' => $lang->getTag(), 'direction' => $lang->isRTL() ? 'rtl' : 'ltr');
     return MDocument::getInstance($type, $attributes);
 }
Example #6
0
 public function display($cachable = false, $urlparams = false)
 {
     $controller = MRequest::getWord('controller', 'miwosql');
     MRequest::setVar('view', $controller);
     parent::display($cachable, $urlparams);
 }
Example #7
0
/**
* @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 &copy; 2009-2014 Miwisoft LLC</a></div>';
Example #8
0
 protected function _buildSefRoute(&$uri)
 {
     // Get the route
     $route = $uri->getPath();
     $route = str_replace('index.php', '', $route);
     // Get the query data
     $query = $uri->getQuery(true);
     if (!isset($query['option'])) {
         return;
     }
     /*
      * Build the component route
      */
     $component = preg_replace('/[^A-Z0-9_\\.-]/i', '', $query['option']);
     $tmp = '';
     // Use the component routing handler if it exists
     $path = MPATH_WP_PLG . '/' . str_replace('com_', '', $component) . '/site/router.php';
     // Use the custom routing handler if it exists
     if (file_exists($path) && !empty($query)) {
         require_once $path;
         $function = str_replace('com_', '', $component) . 'BuildRoute';
         $function = str_replace(array("-", "."), "", $function);
         $parts = $function($query);
         // encode the route segments
         $parts = $this->_encodeSegments($parts);
         $result = implode('/', $parts);
         $tmp = $result != "" ? $result : '';
     }
     /*
      * Build the application route
      */
     if ($tmp) {
         $route .= '/' . $tmp;
     } elseif ($route == 'index.php') {
         $route = '';
     }
     $option_get = str_replace('com_', '', MRequest::getWord('option', ''));
     if (str_replace('com_', '', $component) == $option_get) {
         $page_id = MRequest::getInt('page_id');
     } else {
         $page_id = null;
     }
     if (empty($page_id)) {
         $page_id = MFactory::getWOption(str_replace('com_', '', $query['option']) . '_page_id');
     }
     if (!empty($page_id)) {
         $post = MFactory::getWPost($page_id);
         if (is_object($post)) {
             $route = $post->post_name . '/' . ltrim($route, '/');
         }
         $route = MUri::base(true) . '/' . ltrim($route, '/');
     }
     // Unset unneeded query information
     unset($query['option']);
     //Set query again in the URI
     $uri->setQuery($query);
     $uri->setPath($route);
 }