Пример #1
0
 public function edit()
 {
     MRequest::setVar('hidemainmenu', 1);
     $view = $this->getView(ucfirst('Queries'), 'edit');
     $view->setModel($this->_model, true);
     $view->display('edit');
 }
Пример #2
0
 public function edit()
 {
     MRequest::setVar('hidemainmenu', 1);
     MRequest::setVar('view', 'edit');
     MRequest::setVar('edit', true);
     parent::display();
 }
Пример #3
0
 public function run()
 {
     // Check for request forgeries
     //MRequest::checkToken() or mexit('Invalid Token');
     MRequest::setVar('view', 'miwosql');
     parent::display();
 }
Пример #4
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;
 }
Пример #5
0
 public static function getComponentName($default = null)
 {
     static $option;
     if ($option) {
         return $option;
     }
     $option = strtolower(MRequest::getCmd('option'));
     if (empty($option)) {
         $option = $default;
     }
     MRequest::setVar('option', $option);
     return $option;
 }
Пример #6
0
 public function parse($query)
 {
     $post = null;
     if ($this->app->getCfg('sef', 0) == 0) {
         $id = $query->get('page_id');
         if (empty($id)) {
             $id = $query->get('p');
         }
         $post = MFactory::getWPost($id);
     } else {
         $segments = explode('/', $query->get('pagename'));
         if (empty($segments[0])) {
             return;
         }
         $post = get_page_by_path($segments[0]);
     }
     if (!is_object($post)) {
         $page_id = MFactory::getWOption($this->context . '_page_id');
         $post = MFactory::getWPost($page_id);
         $option = MRequest::getCmd('option', '');
         if (!is_object($post) or $option != 'com_' . $this->context) {
             return;
         }
         $query->set('page_id', $page_id);
         $query->set('post_type', 'page');
     }
     if ($this->_hasShortcode($post->post_content, $this->context) or $this->_hasShortcode($post->post_content, $this->context . '_item')) {
         MRequest::setVar('option', 'com_' . $this->context);
         $vars = $this->app->parse();
         //MRequest::set($vars, 'POST');
         //MRequest::set($vars, 'GET');
         $query->query_vars = array_merge($query->query_vars, $vars);
     }
 }
Пример #7
0
 public function parse($component = null)
 {
     if ($this->get('parsed') == true) {
         $result = $this->get('parsed_vars');
     } else {
         if (!empty($component)) {
             MRequest::setVar('option', $component);
         }
         $uri = clone MUri::getInstance();
         $router = $this->getRouter();
         $result = $router->parse($uri);
         $this->set('parsed_vars', $result);
         $this->set('parsed', true);
     }
     if (!is_array($result)) {
         $result = array();
     }
     return $result;
 }