Example #1
0
 public function stringComp($arg = null)
 {
     if ($this->crit === 'LIKE') {
         return $this->val === $arg;
     }
     if ($this->crit === '%LIKE') {
         return removeEndStr($arg, $this->val);
     }
     if ($this->crit === 'LIKE%') {
         return removeStartStr($arg, $this->val);
     }
     if ($this->crit === '%LIKE%') {
         return strpos($arg, $this->val) !== false;
     }
     throw new \Exception("Unknown [{$this->crit}] for comptype: {$this->comptype}");
 }
Example #2
0
 /** Returns just the controller name, without ending in 'Controller'.
  * @param boolean - $lc - Return the name in lower case? Default true
  * @return string - the base controller name
  */
 public static function getControllerName($lc = true)
 {
     $shortname = (new \ReflectionClass($this))->getShortName();
     $controllerName = removeEndStr($shortname, 'Controller');
     if ($lc) {
         return to_lower($controllerName);
     }
     return $controllerName;
 }
 /**
  * Clear the search parameters (also in the saved query) if $submit == 'clear'
  * @param array|string $extrafields - clear these fields also
  */
 public function checkClearPost($extrafields = []) {
   if (is_string($extrafields)) $extrafields = [$extrafields];
   $method = Request::method();
   //if (($method == 'POST') && array_key_exists('submit',$_POST) && ($_POST['submit'] == 'clear')) {
   if (($method == 'POST') && (Request::input('submit') == 'clear')) {
     $data = Request::all();
     //pkdebug("Trying to clear: Data before:", $data);
     $mergearr = [];
     $keys = array_keys($data);
     foreach ($keys as $key) {
       if (removeEndStr($key, '_crit') !== false) $mergearr[$key] = '';
       if (removeEndStr($key, '_val') !== false) $mergearr[$key] = '';
     }
     foreach ($extrafields as $extrafield) {
       $mergearr[$extrafield] = '';
     }
     //pkdebug("MergeArr:", $mergearr);
     Request::merge($mergearr);
   }
 }
 public static function fieldNameToBase($fieldname) {
    return removeEndStr($fieldname, '_ref');
 }
Example #5
0
/** Does what perhaps the above function "removeEndStr" should do - that is,
 * returns the original string if it doesn't end with '$test' str.
 */
function removeEndStrIf($str, $test) {
  $res = removeEndStr($str, $test);
  if ($res === false) return $str;
  return $res;
}
Example #6
0
 public function __call($method, $args = [])
 {
     $name = removeEndStr($method, static::$displayValueSuffix);
     if (ne_string($name) && in_array($name, static::getDisplayValueFields(), 1)) {
         return $this->displayValueMethod($name, $args);
     }
     if (in_array($method, static::getMethodsAsAttributeNames(), true)) {
         return call_user_func_array([$this, $method], $args);
     }
     return parent::__call($method, $args);
 }
 public function __call($method, $args = [])
 {
     $name = removeEndStr($method, 'Tfrm');
     if (!$name) {
         $this->result = call_user_func_array([$this->item, $method], $args);
         return $this->executeActionSet();
     }
     $actionarr = keyval($name, $this->transforms, $this->donothingaction);
     $actionarr['args'] = $args;
     $actionarr['name'] = $name;
     $this->actionset[] = $actionarr;
     return $this;
 }