Пример #1
0
Файл: Str.php Проект: no22/gongo
 static function getInstance()
 {
     if (is_null(self::$singleton)) {
         self::$singleton = Gongo_Locator::get('Gongo_Str_Base');
     }
     return self::$singleton;
 }
Пример #2
0
 function setSearchCondition($q)
 {
     $words = $this->searchWords();
     $columns = Gongo_Str::split($this->options->searchColumns);
     foreach ($words as $i => $word) {
         $q = $this->freeWordCondition($q, $word, $i, $columns);
     }
     return $q;
 }
Пример #3
0
 public function notBlank($value, $params)
 {
     $text = Gongo_Str::trim($value);
     return $text != '';
 }
Пример #4
0
 function _requestUrl()
 {
     return Gongo_Str::startsWith($this->requestPath, '/') ? $this->requestPath : '/' . $this->requestPath;
 }
Пример #5
0
 public function executeController($app, $controller, $e = array())
 {
     $eAction = isset($e['action']) ? $e['action'] : $app->args->__action__;
     $eMethod = strtolower(isset($e['method']) ? $e['method'] : $app->server->REQUEST_METHOD);
     $request = array();
     if ($eMethod === 'get') {
         $request = $app->get->_();
     } else {
         if ($eMethod === 'post') {
             $request = $app->post->_();
         }
     }
     $eRequest = isset($e['submit']) ? array_merge($request, array($e['submit'] => '')) : $request;
     $eSecure = isset($e['https']) ? $e['https'] : $app->env()->path->https;
     $this->currentAction = $eAction;
     $methodName = $this->makeControllerMethodName($eAction, $eMethod, $eRequest);
     if ($this->buttonName) {
         if ($eMethod === 'get') {
             unset($app->get->{$this->buttonName});
         } else {
             if ($eMethod === 'post') {
                 unset($app->post->{$this->buttonName});
             }
         }
     }
     $methodName .= $eSecure ? $this->options->secureMethod : '';
     if (!method_exists($controller, $methodName)) {
         return $app->error('404');
     }
     $this->controller = $controller;
     $this->methodName = $methodName;
     $argStr = $app->args->__args__;
     if ($this->options->useExtension && preg_match('/^(\\.(?:' . $this->options->extension . '))/', $argStr, $m)) {
         $argStr = substr($argStr, strlen($m[1]));
         $app->args->__args__ = $argStr;
         $this->currentExtension = $m[1];
     }
     $this->currentArgs = $argStr;
     $sep = $this->options->argSeparator;
     $refl = new ReflectionMethod($controller, $methodName);
     $numOfRequiredParams = $refl->getNumberOfRequiredParameters();
     if ($argStr == '') {
         if ($numOfRequiredParams != 1) {
             return $app->error('404');
         }
         return call_user_func(array($controller, $methodName), $app);
     }
     if (!Gongo_Str::startsWith($argStr, $sep)) {
         return $app->error('404');
     }
     $argArr = array_map('urldecode', explode($sep, substr($argStr, 1)));
     $args = array_merge(array($app), $argArr);
     if (count($args) < $numOfRequiredParams) {
         return $app->error('404');
     }
     foreach ($refl->getParameters() as $p) {
         $pos = $p->getPosition();
         if ($pos !== 0) {
             $name = $p->getName();
             $app->args->{$name} = isset($args[$pos]) ? $args[$pos] : null;
             $this->currentArgMaps[$pos] = ':' . $name;
         }
     }
     ksort($this->currentArgMaps);
     return call_user_func_array(array($controller, $methodName), $args);
 }
Пример #6
0
 public function space($value)
 {
     return Gongo_Str::replaceSpaces($value);
 }