Exemple #1
0
 /**
  * Checking if identified route is valid.
  *
  * @static
  * @access   private
  * @param    Route $oRoute
  * @return   boolean
  * @since    1.0.0-alpha
  * @version  1.0.0-alpha
  */
 private static function checkRoute(Route $oRoute)
 {
     $aRouteDefaults = $oRoute->getDefaults();
     // relocation
     if (Helper\Arrays::path($aRouteDefaults, 'relocate', FALSE) !== FALSE) {
         static::relocate($aRouteDefaults['relocate']);
     }
     // check controller
     static::checkControllerExistance($oRoute->getController(), Helper\Arrays::path($aRouteDefaults, 'package', NULL));
     // check action
     static::checkActionExistance($oRoute->getAction());
     return TRUE;
 }
Exemple #2
0
 /**
  * Check data of particular validator object.
  *
  * @access   public
  * @since    1.0.0-alpha
  * @version  1.0.0-alpha
  */
 public function check()
 {
     foreach ($this->aRules as $sField => $aRules) {
         if (!isset($this->aFields[$sField]) || in_array($sField, $this->aBlockRulesFor)) {
             continue;
         }
         foreach ($aRules as $mRule) {
             foreach ($this->getValue($sField) as $sLang => $aAllValues) {
                 if (in_array($sField . '_' . $sLang, $this->aBlockRulesFor)) {
                     continue;
                 }
                 foreach ($aAllValues as $iValueNumber => $mSingleValue) {
                     if (in_array($sField . '_' . $sLang . '_' . $iValueNumber, $this->aBlockRulesFor)) {
                         continue;
                     }
                     $mErrorKey = $sField . static::FIELD_NAME_SEPARATOR . $sLang . static::FIELD_NAME_SEPARATOR . $iValueNumber;
                     // if rule is simple method usage
                     if (!is_array($mRule)) {
                         if ($mRule($mSingleValue) === FALSE) {
                             $this->addError($mErrorKey, static::getSystemFunctionError($mRule));
                         }
                     }
                     $aRule = $mRule;
                     $sFunc = $aRule[0];
                     $aArgs = Helper\Arrays::get($aRule, 1, [':value']);
                     // change aliases for particular values
                     foreach ($aArgs as $i => $sVal) {
                         if ($sVal == ':value') {
                             $aArgs[$i] = $mSingleValue;
                         }
                         if (!is_array($sVal) && strpos($sVal, ':valuefrom:') === 0) {
                             $sOtherFieldName = str_replace(':valuefrom:', '', $sVal);
                             $aOtherFieldValues = $this->getValue($sOtherFieldName);
                             $aOtherFieldLang = isset($aOtherFieldValues[$sLang]) ? $aOtherFieldValues[$sLang] : $aOtherFieldValues['und'];
                             $aOtherFieldSingle = isset($aOtherFieldLang[$iValueNumber]) ? $aOtherFieldLang[$iValueNumber] : $aOtherFieldLang[0];
                             $aArgs[$i] = $aOtherFieldSingle;
                         }
                     }
                     // if rule is simple method usage with more than one arguments
                     if (strpos($sFunc, '::') == 0) {
                         if (call_user_func_array($sFunc, $aArgs) === FALSE) {
                             $this->addError($mErrorKey, static::getSystemFunctionError($sFunc, $aArgs));
                         }
                     } elseif (($sError = call_user_func_array($sFunc, $aArgs)) !== TRUE) {
                         $this->addError($mErrorKey, $sError);
                     }
                 }
             }
         }
     }
     $this->bChecked = TRUE;
 }
Exemple #3
0
 /**
  * Return URL of current route
  *
  * @access   public
  * @param    array $args
  * @return   string
  * @sicne    1.0.0-alpha
  * @version  1.0.0-alpha
  */
 public function url(array $args = [])
 {
     $aTemp = [];
     $sRawURL = $this->rawURL;
     preg_match_all('/\\{[a-zA-Z0-9_]*\\}/', $sRawURL, $aTemp);
     $GET_variables = $aTemp[0];
     unset($aTemp);
     if (count($GET_variables) > 0) {
         foreach ($GET_variables as $mValue) {
             $sVaName = str_replace(["{", "}"], "", $mValue);
             if (isset($args[$sVaName])) {
                 $sReplaceTo = $args[$sVaName];
                 unset($args[$sVaName]);
             } else {
                 $sReplaceTo = NULL;
             }
             $sRawURL = str_replace($mValue, $sReplaceTo, $sRawURL);
         }
     }
     $sReplacedURL = str_replace(['(', ')'], ['', ''], $sRawURL);
     $sURL = rtrim($sReplacedURL, '/');
     if (!empty($args)) {
         foreach ($args as $sKey => $sValue) {
             if (!empty($sValue)) {
                 Router::addAttrToURL($sURL, $sKey, $sValue);
             }
         }
     }
     $sDefaultLang = Router::getLang();
     $sLang = Helper\Arrays::get($args, 'lang', $sDefaultLang);
     $aLangs = Config::get('base.languages');
     $sFirstLang = array_shift($aLangs);
     if ($sLang == $sFirstLang) {
         return Router::getBase() . $sURL;
     } else {
         return Router::getBase() . '/' . $sLang . $sURL;
     }
 }
Exemple #4
0
 /**
  * Get current theme path name.
  *
  * @static
  * @param    string $sThemeName
  * @return   string
  * @since    1.0.0-alpha
  * @version  1.0.0-alpha
  */
 public static function getThemePath($sThemeName = NULL)
 {
     if ($sThemeName === NULL) {
         $sThemeName = static::$theme;
     }
     return Helper\Arrays::get(static::$themesList, $sThemeName);
 }