Ejemplo n.º 1
0
 /**
  * Provides the object of the question this response is for.
  * 
  * @return \Wannabe\Question
  */
 public function getQuestion()
 {
     if ($this->getQuestionID() < 1) {
         return null;
     }
     return Manager::getInstance()->getQuestionByID($this->getQuestionID());
 }
Ejemplo n.º 2
0
 /**
  * Provides the object of the crew.
  *
  * @return \Wannabe\Crew
  */
 public function getCrew()
 {
     if ($this->getCrewID() < 1) {
         return null;
     }
     return Manager::getInstance()->getCrewByID($this->getCrewID());
 }
Ejemplo n.º 3
0
 public function handlerRequest($data = NULL)
 {
     try {
         $this->context = new MContext($this->request);
         Manager::getInstance()->baseURL = $this->request->getBaseURL(false);
         $app = $this->context->app;
         Manager::getInstance()->app = $app;
         $appPath = $this->context->isCore ? Manager::getInstance()->coreAppsPath : Manager::getInstance()->appsPath;
         Manager::getInstance()->appPath = $appPath . '/' . $app;
         $this->removeInputSlashes();
         $this->setData($data ?: $_REQUEST);
         mtrace('DTO Data:');
         mtrace($this->getData());
         $this->loadExtensions();
         $this->init();
         do {
             $this->prepare();
             $this->handler();
         } while ($this->forward != '');
         $this->terminate();
     } catch (ENotFoundException $e) {
         $this->result = new MNotFound($e->getMessage());
     } catch (ESecurityException $e) {
         $this->result = new MInternalError($e);
     } catch (ETimeOutException $e) {
         $this->result = new MInternalError($e);
     } catch (ERuntimeException $e) {
         $this->result = new MRunTimeError($e);
     } catch (EMException $e) {
         $this->result = new MInternalError($e);
     } catch (Exception $e) {
         $this->result = new MInternalError($e);
     }
 }
Ejemplo n.º 4
0
 /**
  * Install: module install action
  *
  * @return boolean
  */
 public function install()
 {
     $module = Core::app()->getModuleById($this->sModuleAlias);
     if (!$module) {
         // 1. add row to the modules table
         $moduleDir = RX_PATH . '/ruxon/modules/' . $this->sModuleAlias;
         $info = Loader::loadConfigFile($moduleDir, 'module');
         $module = array('Name' => $info['Name'], 'Description' => $info['Description'], 'Version' => $info['Version'], 'DbRevision' => '-1');
         Core::app()->updateModuleById($this->sModuleAlias, $module);
         $sClassName = $this->sModuleAlias . 'Module';
         $classNameWithNamespaces = '\\ruxon\\modules\\' . $this->sModuleAlias . '\\classes\\' . $sClassName;
         Manager::getInstance()->setModule($this->sModuleAlias, class_exists($classNameWithNamespaces) ? new $classNameWithNamespaces() : new $sClassName());
         // 2. create table structure
         $migrator = new MysqlDbMigrator($this->sModuleAlias);
         $migrator->migrateTo('last');
         // 3. copy default config to config folder
         $file1 = RX_PATH . '/ruxon/modules/' . $this->sModuleAlias . '/config/module.inc.php';
         $file2 = RX_PATH . '/ruxon/config/modules/' . $this->sModuleAlias . '.inc.php';
         if (file_exists($file1) && !file_exists($file2)) {
             copy($file1, $file2);
         }
         return true;
     }
     return false;
 }
Ejemplo n.º 5
0
 public function __construct($name = NULL)
 {
     $this->property = new stdClass();
     $this->property->className = strtolower(get_class($this));
     $this->property->name = $name;
     $this->manager = Manager::getInstance();
 }
 public function get(Object $oObject, $aParams = array())
 {
     if (isset($this->aParams['ToModuleAlias'])) {
         Core::import('Modules.' . $this->aParams['ToModuleAlias']);
     }
     $oMapper = Manager::getInstance()->getMapper($this->aParams['ToMapperAlias']);
     $nLimit = 0;
     $nOffset = 0;
     $aLocCriteria = array($this->aParams['Field'] => $oObject->getId());
     $aLocOrder = array('Pos' => 'ASC');
     if (count($aParams) > 0) {
         if (isset($aParams['Criteria'])) {
             foreach ($aParams['Criteria'] as $key => $val) {
                 $aLocCriteria[$key] = $val;
             }
         }
         if (isset($aParams['Order'])) {
             $aLocOrder = $aParams['Order'];
         }
         if (isset($aParams['Limit'])) {
             $nLimit = intval($aParams['Limit']);
         }
         if (isset($aParams['Offset'])) {
             $nOffset = intval($aParams['Offset']);
         }
     }
     $aDefaultParams = isset($this->aParams['Params']) ? $this->aParams['Params'] : array();
     return $oMapper->find(ArrayHelper::merge($aDefaultParams, array('Order' => $aLocOrder, 'Criteria' => $aLocCriteria, 'Limit' => $nLimit, 'Offset' => $nOffset)));
 }
Ejemplo n.º 7
0
 public function run(FilterChain $oFilterChain)
 {
     $aDb = Core::app()->config()->getCache();
     foreach ($aDb as $k => $val) {
         Manager::getInstance()->getCache()->add(Cache::factory($val['Driver'], $val['Params']), $k);
     }
     $oFilterChain->next();
 }
Ejemplo n.º 8
0
 public static function getInstance($configLoader = 'PHP')
 {
     if (self::$instance == NULL) {
         $manager = self::$instance = new PersistentManager();
         self::$container = Manager::getInstance();
         $manager->setConfigLoader($configLoader);
     }
     return self::$instance;
 }
Ejemplo n.º 9
0
 public function get(Object $oObject, $aParams = array())
 {
     if (isset($this->aParams['ToModuleAlias'])) {
         Core::import('Modules.' . $this->aParams['ToModuleAlias']);
     }
     $oMapper = Manager::getInstance()->getMapper($this->aParams['ToMapperAlias']);
     $aParams['Criteria'][$this->aParams['Field']] = $oObject->getId();
     return $oMapper->findFirst($aParams);
 }
Ejemplo n.º 10
0
 public function run(FilterChain $oFilterChain)
 {
     $aDb = Core::app()->config()->getDb();
     foreach ($aDb as $k => $val) {
         $oDb = new Db($val['ConnectionString'], $val['Username'], $val['Password'], $val['Params']);
         $oDb->open();
         Manager::getInstance()->getDb()->add($oDb, $k);
     }
     $oFilterChain->next();
 }
Ejemplo n.º 11
0
 public function init()
 {
     parent::init();
     $sms = Manager::getInstance()->getMapper('SmsProviderMapper')->findFirst(array('Criteria' => array('IsActive' => true, 'Handler' => 'Sms')));
     if ($sms->getId()) {
         $this->login = $sms->getLogin();
         $this->password = $sms->getPassword();
         $this->secretkey = $sms->getSecretkey();
     }
 }
Ejemplo n.º 12
0
 public static function Login()
 {
     if (@$_COOKIE[MODLOGIN_LOGIN] != '' || @$_POST[MODLOGIN_LOGIN] != '') {
         $new_connection = true;
         @($login = $_POST[MODLOGIN_LOGIN]);
         @($pass = Site::crypt_pwd($_POST[MODLOGIN_PASSWORD]));
         @($keep = $_POST['keep']);
         if (@$_COOKIE[MODLOGIN_LOGIN] != '') {
             $new_connection = false;
             $login = $_COOKIE[MODLOGIN_LOGIN];
             $pass = $_COOKIE[MODLOGIN_PASSWORD];
         }
         $login = DB::ProtectData($login);
         $class = MODLOGIN_OBJECT;
         $pref = $class::getStaticPref();
         //Récupération du mot de passe de la bdd lié au compte $login
         $pass_crypt = DB::SqlOne("select " . $pref . MODLOGIN_PASSWORD . " from " . DBPRE . MODLOGIN_OBJECT . " where " . $pref . MODLOGIN_LOGIN . "='{$login}'");
         //vérification des conditions de connexion (compte existant et mot de passe valide)
         if ($pass_crypt != '' && $pass == $pass_crypt) {
             if ($new_connection) {
                 if ($keep == 1) {
                     setcookie(MODLOGIN_LOGIN, $login, time() + 31536000, '/');
                     setcookie(MODLOGIN_PASSWORD, $pass, time() + 31536000, '/');
                 } else {
                     setcookie(MODLOGIN_LOGIN, $login, 0, '/');
                     setcookie(MODLOGIN_PASSWORD, $pass, 0, '/');
                 }
                 //Link du compte Facebook
                 /*if($_SESSION['fb_action']=='link')
                   {
                     user::LinkFacebook($login);
                   }*/
                 //Redirection vers la page qui nous amenait à nous connecter, ou sur l'accueil
                 if (Site::isNextUrl()) {
                     Site::goToNextUrl();
                 } else {
                     Site::redirect(WEBDIR);
                 }
                 exit;
             } else {
                 Session::setMe(Manager::getInstance()->selectAll(MODLOGIN_OBJECT)->where($pref . MODLOGIN_LOGIN . "='{$login}'")->query()[0][MODLOGIN_OBJECT]);
             }
         } else {
             if ($new_connection) {
                 Site::message_info("Les informations de connexion sont fausses. Vérifiez votre nom d'utilisateur et votre mot de passe. Avez vous bien créé un compte sur ce site ?", 'ERROR');
             } else {
                 setcookie(MODLOGIN_LOGIN, '', 0, '/');
                 setcookie(MODLOGIN_PASSWORD, '', 0, '/');
                 Site::message_info("Session expirée, vous avez été déconnecté.", 'WARNING');
                 Site::redirect(WEBDIR);
                 exit;
             }
         }
     }
 }
 public function getDynamicText()
 {
     if ($this->edition_prefixe != false) {
         Manager::getInstance()->selectAllFrom("content")->where("cont_name LIKE '" . $this->edition_prefixe . "%'")->query();
         $this->content = Manager::getInstance()->getObjects("content");
         foreach ($this->content as $c) {
             $this->content[$c->getAttr('name')] = $c;
         }
     } else {
         Site::addDevError("Il faut remplir le préfixe édition du controller avant d'appeler getDynamicText()");
     }
 }
 public function eagerFetching(DbFetcher $oQuery, ObjectMapper $oParentMapper, $sPrefix, $aParams = array(), $aLocalParams = array())
 {
     if (isset($this->aParams['ToModuleAlias'])) {
         Core::import('Modules.' . $this->aParams['ToModuleAlias']);
     }
     $oMapper = Manager::getInstance()->getMapper($this->aParams['ToMapperAlias']);
     //echo '<pre>', print_r($oMapper, true), '</pre>'; die();
     $aContainer = $oMapper->getContainer();
     if ($oMapper) {
         $oParentFields = $oParentMapper->getFields();
         $oQuery->addJoinTable($aContainer['TableName'], $sPrefix . '_' . $this->getAlias(), DbFetcher::JOIN_LEFT, $sPrefix . '.' . $oParentFields->get($this->getField())->getField() . ' = ' . $sPrefix . '_' . $this->getAlias() . '.id');
         $oFields = $oMapper->getFields();
         foreach ($oFields as $alias => $field) {
             if ($field->getType() != 'Object' && $field->getField()) {
                 $oQuery->addSelectField($sPrefix . '_' . $this->getAlias() . '.' . $field->getField(), $sPrefix . '_' . $this->getAlias() . '_' . $field->getField());
             }
         }
         // Условия выборки
         if (isset($aLocalParams['Criteria']) && is_object($aLocalParams['Criteria'])) {
             $oQuery->addCriteria(call_user_func(array($aLocalParams['Criteria'], 'renderWhere')));
         }
         if (isset($aLocalParams['Criteria']) && is_array($aLocalParams['Criteria']) && count($aLocalParams['Criteria']) > 0) {
             $oCriteria = new CriteriaGroup(Criteria::TYPE_AND);
             foreach ($aLocalParams['Criteria'] as $k => $itm) {
                 if (is_object($itm)) {
                     $oCriteria->addElement($itm);
                 } else {
                     if (is_array($itm)) {
                         $oCriteria->addElement(new CriteriaElement($k, $itm['Type'], $itm['Value']));
                     } else {
                         $oCriteria->addElement(new CriteriaElement($k, '=', $itm));
                     }
                 }
             }
             $oQuery->addCriteria($oMapper->parseFindCriteria($oCriteria->renderWhere(), $sPrefix . '_' . $this->getAlias()));
         }
         if (isset($aLocalParams['Criteria']) && is_string($aLocalParams['Criteria'])) {
             $oQuery->addCriteria($oMapper->parseFindCriteria($aLocalParams['Criteria'], $sPrefix . '_' . $this->getAlias()));
         }
         // Сортировка
         if (isset($aLocalParams['Order']) && is_array($aLocalParams['Order']) && count($aLocalParams['Order']) > 0) {
             foreach ($aLocalParams['Order'] as $k => $itm) {
                 $oQuery->addOrder($oMapper->parseFindField($k, $sPrefix . '_' . $this->getAlias()), $itm);
             }
         }
         if (isset($aLocalParams['With']) && is_array($aLocalParams['With']) && count($aLocalParams['With'])) {
             // TODO: Вложенные JOINы
         }
     }
     return $oQuery;
 }
Ejemplo n.º 15
0
 public function beforeDelete()
 {
     if ($this->getOwner()->getGalleryId()) {
         $mapper = Manager::getInstance()->getMapper($this->mapper_alias);
         $aContainer = $mapper->getContainer();
         $categoryId = $this->getOwner()->getGalleryId();
         // Удаляем все записи о фотках из базы
         $oQuery = new DbUpdater(DbUpdater::TYPE_DELETE, $aContainer['TableName'], $aContainer['Object'], $this->getDbConnectionAlias());
         $oCriteria = new CriteriaElement('category_id', Criteria::EQUAL, $categoryId);
         $oQuery->addCriteria($mapper->parseUpdateCriteria($oCriteria->renderWhere()));
         $oQuery->delete();
         $this->getOwner()->getGallery()->delete();
     }
     return true;
 }
Ejemplo n.º 16
0
 public function init()
 {
     if (!$this->merchant_login) {
         $this->merchant_login = Manager::getInstance()->getModule('Shop')->config('RobokassaMerchantLogin');
     }
     if (!$this->password1) {
         $this->password1 = Manager::getInstance()->getModule('Shop')->config('RobokassaPassword1');
     }
     if (!$this->password2) {
         $this->password2 = Manager::getInstance()->getModule('Shop')->config('RobokassaPassword2');
     }
     if ($this->test_mode === null) {
         $this->test_mode = Manager::getInstance()->getModule('Shop')->config('RobokassaTestMode');
     }
 }
Ejemplo n.º 17
0
 public function raise($alias, $recipients, $params = array())
 {
     $event = Manager::getInstance()->getMapper('SmsTemplateMapper')->findFirst(array('Criteria' => array('IsActive' => true, 'Alias' => $alias)));
     if ($event->getId()) {
         $sms = Manager::getInstance()->getMapper('SmsProviderMapper')->findFirst(array('Criteria' => array('IsActive' => true)));
         if ($sms->getId()) {
             $classname = 'Sms' . $sms->getHandler();
             $handler = new $classname();
             $handler->init();
             $smsTemplate = new SmsView($params);
             $content = $smsTemplate->fetch($event->getAlias());
             return $handler->send($recipients, $content, Manager::getInstance()->getModule('Main')->config('AdminPhoneSender'));
         }
     }
     return false;
 }
Ejemplo n.º 18
0
 public function get(Object $oObject, $aParams = array())
 {
     if (isset($this->aParams['ToModuleAlias'])) {
         Core::import('Modules.' . $this->aParams['ToModuleAlias']);
     }
     $oMapper = Manager::getInstance()->getMapper($this->aParams['ToMapperAlias']);
     $aLocCriteria = array($this->aParams['Field'] => $oObject->getId());
     if (!empty($aParams)) {
         if (isset($aParams['Criteria'])) {
             foreach ($aParams['Criteria'] as $key => $val) {
                 $aLocCriteria[$key] = $val;
             }
         }
     }
     $nRelation = $oMapper->findStat('count', 'c', isset($this->aParams['FunctionParams']) ? $this->aParams['FunctionParams'] : '*', array('Criteria' => $aLocCriteria));
     return $nRelation;
 }
Ejemplo n.º 19
0
 public function __construct($path = '')
 {
     parent::__construct();
     $this->path = $path;
     if (function_exists('mb_internal_charset')) {
         mb_internal_charset('UTF-8');
     }
     define('SMARTY_RESOURCE_CHAR_SET', 'UTF-8');
     $this->engine = new Smarty();
     $this->engine->setTemplateDir($path ? $path : Manager::getPublicPath() . '/templates');
     $this->engine->setCompileDir(Manager::getFrameworkPath() . '/var/templates');
     $this->engine->setCacheDir(Manager::getFrameworkPath() . '/var/cache');
     $this->engine->setConfigDir(Manager::getClassPath() . '/ui/smarty/configs');
     $this->engine->left_delimiter = '{{';
     $this->engine->right_delimiter = '}}';
     $this->context = array();
     $this->context('manager', Manager::getInstance());
 }
Ejemplo n.º 20
0
 public function arrayValue($array)
 {
     $first = true;
     $flatValue = '';
     foreach ($array as $value) {
         if (!$first) {
             $flatValue .= ',';
         } else {
             $first = false;
         }
         if (is_numeric($value)) {
             $flatValue .= $value;
         } else {
             $flatValue .= $this->quoteSign . Manager::getInstance()->escapeString($value) . $this->quoteSign;
         }
     }
     return $flatValue;
 }
Ejemplo n.º 21
0
 public function raise($alias, $recipients, $params = array())
 {
     Loader::import('Modules.Main');
     if (!is_array($recipients)) {
         $recipients = array($recipients);
     }
     $event = Manager::getInstance()->getMapper('EmailObjectMapper')->findFirst(array('Criteria' => array('IsActive' => true, 'Alias' => $alias)));
     if ($event->getId()) {
         Toolkit::getInstance()->mail->ClearAddresses();
         Toolkit::getInstance()->mail->From = Manager::getInstance()->getModule('Main')->config('FromEmail');
         Toolkit::getInstance()->mail->FromName = Manager::getInstance()->getModule('Main')->config('FromName');
         foreach ($recipients as $email) {
             Toolkit::getInstance()->mail->AddAddress($email);
         }
         Toolkit::getInstance()->mail->Subject = $event->getSubject();
         $emailTemplate = new MailTemplate($params);
         Toolkit::getInstance()->mail->SetHtmlBody($emailTemplate->fetch($event->getAlias()));
         return Toolkit::getInstance()->mail->Send();
     }
     return false;
 }
 public function eagerFetching(DbFetcher $oQuery, ObjectMapper $oParentMapper, $sPrefix, $aParams = array(), $aLocalParams = array())
 {
     $oMapper = Manager::getInstance()->getMapper($this->aParams['ToMapperAlias']);
     if ($oMapper) {
         $oQuery->addJoinTable($this->aParams['TableName'], $this->getAlias(), DbFetcher::JOIN_LEFT, $sPrefix . '.id' . ' = ' . $this->getAlias() . '.' . $this->aParams['Field2']);
         // Условия выборки
         if (isset($aLocalParams['Criteria']) && is_object($aLocalParams['Criteria'])) {
             $oQuery->addCriteria(call_user_func(array($aLocalParams['Criteria'], 'renderWhere')));
         }
         if (isset($aLocalParams['Criteria']) && is_array($aLocalParams['Criteria']) && count($aLocalParams['Criteria']) > 0) {
             $oCriteria = new CriteriaGroup(Criteria::TYPE_AND);
             foreach ($aLocalParams['Criteria'] as $k => $itm) {
                 if (is_object($itm)) {
                     $oCriteria->addElement($itm);
                 } else {
                     if (is_array($itm)) {
                         $oCriteria->addElement(new CriteriaElement($k, $itm['Type'], $itm['Value']));
                     } else {
                         $oCriteria->addElement(new CriteriaElement($k, '=', $itm));
                     }
                 }
             }
             $oQuery->addCriteria($oMapper->parseFindCriteria($oCriteria->renderWhere(), $sPrefix . '_' . $this->getAlias()));
         }
         if (isset($aLocalParams['Criteria']) && is_string($aLocalParams['Criteria'])) {
             $oQuery->addCriteria($oMapper->parseFindCriteria($aLocalParams['Criteria'], $sPrefix . '_' . $this->getAlias()));
         }
         // Сортировка
         if (isset($aLocalParams['Order']) && is_array($aLocalParams['Order']) && count($aLocalParams['Order']) > 0) {
             foreach ($aLocalParams['Order'] as $k => $itm) {
                 $oQuery->addOrder($oMapper->parseFindField($k, $sPrefix . '_' . $this->getAlias()), $itm);
             }
         }
         if (isset($aLocalParams['With']) && is_array($aLocalParams['With']) && count($aLocalParams['With'])) {
             // TODO: Вложенные JOINы
         }
     }
     return $oQuery;
 }
Ejemplo n.º 23
0
 public function actionConfig($aParams = array())
 {
     $aConfig = $this->config('Config');
     $mResult = false;
     if ($aConfig) {
         if (!isset($aConfig['View']) || isset($aConfig['View']) && $aConfig['View'] != false) {
             $mResult = $this->view(array(), $aConfig['View']);
         } else {
             if (isset($aConfig['Component'])) {
                 $sComponentModule = $aConfig['Component']['Component'][0];
                 $sComponentAlias = $aConfig['Component']['Component'][1];
                 $aComponentParams = isset($aConfig['Component']['Params']) ? $aConfig['Component']['Params'] : array();
                 // Проверка доступа
                 $this->checkActionAccess('Config');
                 // load config
                 $aComponentParams['Data'] = Manager::getInstance()->getModule($this->sModuleAlias)->config();
                 if (!empty($_POST)) {
                     //echo print_r($_POST, true);die();
                     $aResult = array();
                     if (Manager::getInstance()->getModule($this->sModuleAlias)->saveConfig($_POST)) {
                         $aResult['success'] = true;
                     } else {
                         $aResult['success'] = false;
                     }
                     header("Content-type: application/json");
                     echo json_encode($aResult);
                     Core::app()->hardEnd();
                 } else {
                     $mResult = $this->component($sComponentModule, $sComponentAlias, $aComponentParams);
                 }
             } else {
                 $mResult = false;
             }
         }
     }
     return $mResult;
 }
Ejemplo n.º 24
0
 public function init()
 {
     if (!$this->merchant_id) {
         $this->merchant_id = Manager::getInstance()->getModule('Shop')->config('PlatronMerchantId');
     }
     if (!$this->secret_key) {
         $this->secret_key = Manager::getInstance()->getModule('Shop')->config('PlatronSecretKey');
     }
     if ($this->test_mode === null) {
         $this->test_mode = Manager::getInstance()->getModule('Shop')->config('PlatronTestMode');
     }
     if (!$this->site_url) {
         $this->site_url = 'http://' . Toolkit::getInstance()->request->getServerName();
     }
     if (!$this->result_url) {
         $this->result_url = 'http://' . Toolkit::getInstance()->request->getServerName() . '/shop/payment/result';
     }
     if (!$this->success_url) {
         $this->success_url = 'http://' . Toolkit::getInstance()->request->getServerName() . '/shop/payment/success';
     }
     if (!$this->failure_url) {
         $this->failure_url = 'http://' . Toolkit::getInstance()->request->getServerName() . '/shop/payment/failed';
     }
 }
Ejemplo n.º 25
0
 public function renderPackages()
 {
     if (Core::app()->checkInstalledModule($this->assetsModule)) {
         Core::import("Modules." . $this->assetsModule);
         $assetsUrl = Manager::getInstance()->getModule($this->assetsModule)->publishAssets();
         $assetsPath = Manager::getInstance()->getModule($this->assetsModule)->pathAssets();
         $sResult = '';
         if (count($this->aPackages)) {
             foreach ($this->aPackages as $package) {
                 $aPackage = Loader::loadConfigFile($assetsPath . '/' . $package, 'package');
                 if (isset($aPackage['Includes']) && count($aPackage['Includes'])) {
                     foreach ($aPackage['Includes'] as $file) {
                         $sExt = mb_substr($file, mb_strrpos($file, ".") + 1);
                         $file_path = str_replace("~/", $assetsPath . '/' . $package . '/', $file);
                         $file = str_replace("~/", $assetsUrl . '/' . $package . '/', $file);
                         switch ($sExt) {
                             case 'js':
                                 $sResult .= '<script type="text/javascript" src="' . $file . '"></script>';
                                 $sResult .= "\n\t";
                                 break;
                             case 'css':
                                 $sResult .= '<link href="' . $file . '" type="text/css" rel="stylesheet" />';
                                 $sResult .= "\n\t";
                                 break;
                             case 'tpl':
                                 $sResult .= file_get_contents($file_path);
                                 $sResult .= "\n\t";
                                 break;
                         }
                     }
                 }
             }
         }
         return $sResult;
     }
 }
Ejemplo n.º 26
0
 protected function getDbConnection()
 {
     return Manager::getInstance()->getDb($this->sDbConnection);
 }
Ejemplo n.º 27
0
 public function setUp()
 {
     Manager::resetInstance();
     $this->manager = Manager::getInstance();
 }
Ejemplo n.º 28
0
 public function __construct($request)
 {
     $this->isCore = false;
     if (is_string($request)) {
         $path = $request;
         $this->url = $path;
     } else {
         $this->request = $request;
         if ($this->request->querystring != '') {
             parse_str($this->request->querystring, $this->vars);
         }
         $path = $this->request->getPathInfo();
         $this->url = $this->request->path;
     }
     mtrace('Context path: ' . $path);
     $pathParts = explode('/', $path);
     $app = array_shift($pathParts);
     if ($app != '') {
         if ($app == 'core') {
             $this->isCore = true;
             $app = array_shift($pathParts);
         }
         $this->app = $app;
         $part = array_shift($pathParts);
         // check for module
         $namespace = $this->getNamespace($this->app, $part);
         if ($part && Manager::existsNS($namespace)) {
             $this->module = $part;
             $part = array_shift($pathParts);
         } else {
             $this->module = '';
         }
         // check for controller/component/service
         $ctlr = $part;
         $controller = $component = $service = '';
         while ($part && ($controller == '' && $component == '' && $service == '')) {
             $namespace = $this->getNamespace($this->app, $this->module, '', 'controllers');
             $ns = $namespace . $part . 'Controller.php';
             if (Manager::existsNS($ns)) {
                 $controller = $part;
                 $part = array_shift($pathParts);
             } else {
                 $namespace = $this->getNamespace($this->app, $this->module, '', 'services');
                 $ns = $namespace . $part . 'Service.php';
                 if (Manager::existsNS($ns)) {
                     $service = $part;
                     $part = array_shift($pathParts);
                 } else {
                     $namespace = $this->getNamespace($this->app, $this->module, '', 'components');
                     $ns = $namespace . $part . '.php';
                     if (Manager::existsNS($ns)) {
                         $component = $part;
                         $part = array_shift($pathParts);
                     } else {
                         $part = array_shift($pathParts);
                     }
                 }
             }
         }
     } else {
         $this->app = Manager::getOptions('startup');
         $controller = 'main';
     }
     if ($controller) {
         $this->controller = $controller;
     } elseif ($service) {
         $this->service = $service;
     } elseif ($component) {
         $this->component = $component;
     } else {
         throw new ENotFoundException(_M("App: [%s], Module: [%s], Controller: [%s] : Not found!", array($this->app, $this->module, $ctlr)));
     }
     $this->action = $part ?: ($component == '' ? 'main' : '');
     $this->actionTokens[0] = $this->controller;
     $this->actionTokens[1] = $this->action;
     $this->currentToken = 1 + ($this->module ? 1 : 0);
     if ($n = count($pathParts)) {
         for ($i = 0; $i < $n; $i++) {
             $this->actionTokens[$i + 2] = $this->vars[$pathParts[$i]] = $pathParts[$i];
         }
     }
     $this->id = $this->vars['item'] ?: $this->actionTokens[2];
     if ($this->id !== '') {
         $_REQUEST['id'] = $this->id;
     }
     Manager::getInstance()->application = $this->app;
     mtrace('Context app: ' . $this->app);
     mtrace('Context module: ' . $this->module);
     mtrace('Context controller: ' . $this->controller);
     mtrace('Context service: ' . $this->service);
     mtrace('Context component: ' . $this->component);
     mtrace('Context action: ' . $this->action);
     mtrace('Context id: ' . $this->id);
 }
Ejemplo n.º 29
0
 public function mapper()
 {
     return Manager::getInstance()->getMapper($this->getMapper());
 }
Ejemplo n.º 30
0
 public function testGetInstanceSuccess()
 {
     $this->assertInstanceOf('GFG\\Hek\\Manager', Manager::getInstance());
 }