Example #1
0
 public static function getApplication($id = null, $config = array(), $prefix = 'M')
 {
     if (!self::$application) {
         if (!$id) {
             //MError::raiseError(500, 'Application Instantiation Error');
         }
         self::$application = MApplication::getInstance($id, $config, $prefix);
     }
     return self::$application;
 }
Example #2
0
 public static function getHash($seed)
 {
     // Deprecation warning.
     MLog::add('MUtility::getHash() is deprecated. Use MApplication::getHash() instead.', MLog::WARNING, 'deprecated');
     return MApplication::getHash($seed);
 }
Example #3
0
 public static function getFormToken($forceNew = false)
 {
     $user = MFactory::getUser();
     $session = MFactory::getSession();
     $hash = MApplication::getHash($user->get('id', 0) . $session->getToken($forceNew));
     return $hash;
 }
Example #4
0
/*
 * Copyright (c) 2011 Movinpixel Ltd. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. Neither the name of the company nor the names of its contributors
 *    may be used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY MOVINPIXEL AND ITS CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL MOVINPIXEL OR ITS CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 */
require 'libraries.php';
$application = new MApplication();
$application->run();
 /**
  * Creates a new MApplication instance with the specified delegate class
  * If no delegate class is specified the system looks for the 'manifest.xml'
  * file inside the 'resources' folder and parses it
  *
  * @param MString $delegateClass A string containing the fully qualified class
  * name for this application's delegate, or null.
  *
  * @return MApplication The MApplication instance which has just been created
  */
 public function __construct(MString $delegateClass = null)
 {
     parent::__construct();
     $this->_delegate = null;
     $this->_errorViewControllerClass = null;
     $this->_defaultNamespace = null;
     $this->_rootViewController = null;
     $this->_commandName = null;
     $this->_commandLineArguments = null;
     if (!$this->isRoutingEnabled()) {
         $this->enableRouting();
         $redirect = new MHTTPResponse(MHTTPResponse::RESPONSE_FOUND);
         $redirect->addHeader(S("Location"), MHTTPRequest()->url());
         MDie($redirect);
     }
     if ($delegateClass) {
         $this->_delegate = MObject::newInstanceOfClass($delegateClass);
     } else {
         if (MFile::fileExists("resources/manifest.xml")) {
             $xmlManifest = simplexml_load_file("resources/manifest.xml");
             $this->_delegate = MObject::newInstanceOfClassWithParameters(S($xmlManifest['delegate']), A($this));
             $this->_errorViewControllerClass = S($xmlManifest['errorClass']);
             try {
                 $this->_defaultNamespace = MApplicationNamespace::parseFromXMLElement($xmlManifest, S("application"));
             } catch (Exception $e) {
                 throw new MParseErrorException(S("resources/manifest.xml"), null, null, $e);
             }
         } else {
             $this->_delegate = new MApplicationDelegate($this);
         }
     }
     MApplication::$_application = $this;
 }
Example #6
0
/**
 * Returns the current MApplication instance
 *
 * This function returns the MApplication instance that represents the
 * currently running application
 *
 * @see MApplication
 *
 * @return MApplication The current MApplication instance
 */
function MApp()
{
    return MApplication::sharedApplication();
}
Example #7
0
 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;
 }