Esempio n. 1
0
 protected static function recurseQueryValueBeforeComposingQs($value, $currDepth)
 {
     if ($currDepth == self::$ms_maxRecursionDepth) {
         return $value;
     }
     $currDepth++;
     if (!is_collection($value)) {
         if (!is_cstring($value)) {
             if (is_bool($value)) {
                 $value = CString::fromBool10($value);
             } else {
                 if (is_int($value)) {
                     $value = CString::fromInt($value);
                 } else {
                     if (is_float($value)) {
                         $value = CString::fromFloat($value);
                     } else {
                         assert('false', vs(isset($this), get_defined_vars()));
                     }
                 }
             }
         }
         return $value;
     }
     if (is_carray($value)) {
         $value = splarray($value)->toArray();
     } else {
         $value = parray($value);
     }
     foreach ($value as &$mapValue) {
         $mapValue = self::recurseQueryValueBeforeComposingQs($mapValue, $currDepth);
     }
     unset($mapValue);
     return $value;
 }
Esempio n. 2
0
 protected static function recurseCollectionFiltering($inputCollection, $filterOrFilterCollection, &$success, $currDepth)
 {
     assert('is_a($filterOrFilterCollection, get_called_class()) || is_collection($filterOrFilterCollection)', vs(isset($this), get_defined_vars()));
     if ($currDepth == self::$ms_maxRecursionDepth) {
         $success = false;
         return;
     }
     $currDepth++;
     if (is_carray($inputCollection)) {
         if (!is_carray($filterOrFilterCollection)) {
             $success = false;
             return;
         }
         $len = CArray::length($inputCollection);
         if ($len != CArray::length($filterOrFilterCollection)) {
             $success = false;
             return;
         }
         for ($i = 0; $i < $len; $i++) {
             $inputValue = $inputCollection[$i];
             $filterElement = $filterOrFilterCollection[$i];
             if (!is_collection($inputValue)) {
                 $strInputValue = self::collectionElementToString($inputValue, $success);
                 if (!$success) {
                     return;
                 }
                 if (!is_a($filterElement, get_called_class())) {
                     $success = false;
                     return;
                 }
                 $inputValue = $filterElement->filter($strInputValue, $success);
                 if (!$success) {
                     return;
                 }
             } else {
                 $inputValue = self::recurseCollectionFiltering($inputValue, $filterElement, $success, $currDepth);
                 if (!$success) {
                     return;
                 }
             }
             $inputCollection[$i] = $inputValue;
         }
     } else {
         if (!is_cmap($filterOrFilterCollection)) {
             $success = false;
             return;
         }
         foreach ($inputCollection as $inputKey => &$inputValue) {
             if (!CMap::hasKey($filterOrFilterCollection, $inputKey)) {
                 $success = false;
                 return;
             }
             $filterElement = $filterOrFilterCollection[$inputKey];
             if (!is_collection($inputValue)) {
                 $strInputValue = self::collectionElementToString($inputValue, $success);
                 if (!$success) {
                     return;
                 }
                 if (!is_a($filterElement, get_called_class())) {
                     $success = false;
                     return;
                 }
                 $inputValue = $filterElement->filter($strInputValue, $success);
                 if (!$success) {
                     return;
                 }
             } else {
                 $inputValue = self::recurseCollectionFiltering($inputValue, $filterElement, $success, $currDepth);
                 if (!$success) {
                     return;
                 }
             }
         }
         unset($inputValue);
     }
     return $inputCollection;
 }