public static function tableFieldName() { $baseModel = getBaseName(static::class); $base = removeStartStr($baseModel, 'Ref'); if (!$base) { return false; } $lcbase = strtolower($base); return $lcbase . '_ref'; }
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}"); }
public function __call($method, $args) { $method = trim($method); $raw = false; if ($tag = removeStartStr($method, 'raw')) { $method = $tag; $raw = true; } #TODO: Do something with $raw array_unshift($args, $method); if (in_array($method, static::$selfclosing_tags)) { return call_user_func_array([$this, 'nocontent'], $args); } else { if (!$raw && in_array($method, static::$content_tags)) { return call_user_func_array([$this, 'tagged'], $args); } else { if ($raw && in_array($method, static::$content_tags)) { return call_user_func_array([$this, 'rawtagged'], $args); } else { if (in_array($method, static::$input_types)) { //$args = array_unshift($args,$method,$args); return call_user_func_array([$this, 'input'], $args); } } } } throw new \Exception("Unknown Method: [{$method}]"); }
public function __call($method, $args) { $method = trim($method); $raw = false; if ($tag = removeStartStr($method, 'raw')) { $method = $tag; $raw = true; } if (!$this->isHandled($method)) { throw new \Exception("Unhandled __call type: [{$method}]"); } if (!$this->canHaveChildren()) { throw new \Exception("Can't create a child node for this nodetype: [{$this->getPkTag()}]"); } $child = $this->spawn(); if ($this->customTag($method)) { $custommethod = 'custom' . $method; return call_user_func_array([$child, $custommethod], $args); } array_unshift($args, $method); if ($this->contentTag($method)) { return call_user_func_array([$child, 'tagged'], $args); } if ($this->selfClosingTag($method)) { return call_user_func_array([$child, 'nocontent'], $args); } if (in_array($method, static::$input_types)) { return call_user_func_array([$child, 'custominput'], $args); ## It's a content/dom element -create a child } throw new \Exception("Unknown Method: [{$method}]"); }
/** Wraps content to be appropriate for a jQuery/pklib.js Pop Up Dialog */ public function wrapDlg($content, $args = []) { if (!$args) { $args = []; } if (ne_string($args)) { $args = ['class' => $args]; } $atts = []; foreach ($args as $key => $value) { if (removeStartStr($key, 'data-') || in_array($key, static::$dialogAtts)) { $atts[$key] = $value; } } $extraClass = keyVal('extra_class', $args); $atts = merge_attributes($atts, $extraClass); return PkRenderer::div($content, $atts); }
/** Returns $str with prepended $test string removed if str starts w. test; * else returns just the original $str. * @param string $str - the string to examine and remove leading string from * @param string $test - the string to remove from the given string, if it starts * with it. * @ return string - the initial argument $str string, with $test removed if it exists */ function removeStartStrIf($str, $test = '') { $res = removeStartStr($str, $test); if ($res !== false) return $res; return $str; }