@@ -4,64 +4,64 @@ |
||
| 4 | 4 | class JString { |
| 5 | 5 | |
| 6 | 6 | public static function contains($hay, $needle) { |
| 7 | - return strpos($hay, "$needle") !== false; |
|
| 7 | + return strpos($hay, "$needle")!==false; |
|
| 8 | 8 | } |
| 9 | 9 | |
| 10 | 10 | public static function startswith($hay, $needle) { |
| 11 | - return substr($hay, 0, strlen($needle)) === $needle; |
|
| 11 | + return substr($hay, 0, strlen($needle))===$needle; |
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | public static function endswith($hay, $needle) { |
| 15 | - return substr($hay, - strlen($needle)) === $needle; |
|
| 15 | + return substr($hay, - strlen($needle))===$needle; |
|
| 16 | 16 | } |
| 17 | 17 | |
| 18 | 18 | public static function isNull($s) { |
| 19 | - return (! isset($s) || NULL === $s || "" === $s); |
|
| 19 | + return (!isset($s) || NULL===$s || ""===$s); |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | public static function isNotNull($s) { |
| 23 | - return (isset($s) && NULL !== $s && "" !== $s); |
|
| 23 | + return (isset($s) && NULL!==$s && ""!==$s); |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | public static function isBoolean($value) { |
| 27 | - return \is_bool($value) || $value == 1 || $value == 0; |
|
| 27 | + return \is_bool($value) || $value==1 || $value==0; |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | public static function isBooleanTrue($value) { |
| 31 | - return $value == 1 || $value; |
|
| 31 | + return $value==1 || $value; |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | public static function isBooleanFalse($value) { |
| 35 | - return $value == 0 || ! $value; |
|
| 35 | + return $value==0 || !$value; |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | - public static function camelCaseToSeparated($input, $separator = " ") { |
|
| 39 | - return strtolower(preg_replace('/(?<!^)[A-Z]/', $separator . '$0', $input)); |
|
| 38 | + public static function camelCaseToSeparated($input, $separator=" ") { |
|
| 39 | + return strtolower(preg_replace('/(?<!^)[A-Z]/', $separator.'$0', $input)); |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | public static function replaceAtFirst($subject, $from, $to) { |
| 43 | - $from = '/\A' . preg_quote($from, '/') . '/'; |
|
| 43 | + $from='/\A'.preg_quote($from, '/').'/'; |
|
| 44 | 44 | return \preg_replace($from, $to, $subject, 1); |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | public static function replaceAtLast($subject, $from, $to) { |
| 48 | - $from = '/' . preg_quote($from, '/') . '\z/'; |
|
| 48 | + $from='/'.preg_quote($from, '/').'\z/'; |
|
| 49 | 49 | return \preg_replace($from, $to, $subject, 1); |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | public static function replaceAtFirstAndLast($subject, $fromFirst, $toFirst, $fromLast, $toLast) { |
| 53 | - $s = self::replaceAtFirst($subject, $fromFirst, $toFirst); |
|
| 53 | + $s=self::replaceAtFirst($subject, $fromFirst, $toFirst); |
|
| 54 | 54 | return self::replaceAtLast($s, $fromLast, $toLast); |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - public static function getValueBetween(&$str, $before = "{{", $after = "}}") { |
|
| 58 | - $matches = []; |
|
| 59 | - $result = null; |
|
| 60 | - $_before = \preg_quote($before); |
|
| 61 | - $_after = \preg_quote($after); |
|
| 62 | - if (\preg_match('/' . $_before . '(.*?)' . $_after . '/s', $str, $matches) === 1) { |
|
| 63 | - $result = $matches[1]; |
|
| 64 | - $str = \str_replace($before . $result . $after, "", $str); |
|
| 57 | + public static function getValueBetween(&$str, $before="{{", $after="}}") { |
|
| 58 | + $matches=[]; |
|
| 59 | + $result=null; |
|
| 60 | + $_before=\preg_quote($before); |
|
| 61 | + $_after=\preg_quote($after); |
|
| 62 | + if (\preg_match('/'.$_before.'(.*?)'.$_after.'/s', $str, $matches)===1) { |
|
| 63 | + $result=$matches[1]; |
|
| 64 | + $str=\str_replace($before.$result.$after, "", $str); |
|
| 65 | 65 | } |
| 66 | 66 | return $result; |
| 67 | 67 | } |
@@ -67,8 +67,9 @@ |
||
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | public static function doubleBackSlashes($value) { |
| 70 | - if (\is_string($value)) |
|
| 71 | - return \str_replace("\\", "\\\\", $value); |
|
| 70 | + if (\is_string($value)) { |
|
| 71 | + return \str_replace("\\", "\\\\", $value); |
|
| 72 | + } |
|
| 72 | 73 | return $value; |
| 73 | 74 | } |
| 74 | 75 | |
@@ -13,21 +13,21 @@ discard block |
||
| 13 | 13 | use Ajax\semantic\html\elements\html5\HtmlDatalist; |
| 14 | 14 | |
| 15 | 15 | class HtmlInput extends HtmlSemDoubleElement { |
| 16 | - use IconTrait,TextFieldsTrait,FieldTrait; |
|
| 16 | + use IconTrait, TextFieldsTrait, FieldTrait; |
|
| 17 | 17 | |
| 18 | - public function __construct($identifier, $type = "text", $value = "", $placeholder = "") { |
|
| 19 | - parent::__construct("div-" . $identifier, "div", "ui input"); |
|
| 20 | - $this->_identifier = $identifier; |
|
| 21 | - $this->_libraryId = $identifier; |
|
| 22 | - $this->content = [ |
|
| 18 | + public function __construct($identifier, $type="text", $value="", $placeholder="") { |
|
| 19 | + parent::__construct("div-".$identifier, "div", "ui input"); |
|
| 20 | + $this->_identifier=$identifier; |
|
| 21 | + $this->_libraryId=$identifier; |
|
| 22 | + $this->content=[ |
|
| 23 | 23 | "field" => new HtmlInput5($identifier, $type, $value, $placeholder) |
| 24 | 24 | ]; |
| 25 | - $this->_states = [ |
|
| 25 | + $this->_states=[ |
|
| 26 | 26 | State::DISABLED, |
| 27 | 27 | State::FOCUS, |
| 28 | 28 | State::ERROR |
| 29 | 29 | ]; |
| 30 | - $this->_variations = [ |
|
| 30 | + $this->_variations=[ |
|
| 31 | 31 | Variation::TRANSPARENT |
| 32 | 32 | ]; |
| 33 | 33 | } |
@@ -40,16 +40,16 @@ discard block |
||
| 40 | 40 | return $this->content["field"]; |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | - public static function outline($identifier, $icon, $value = "", $placeholder = "") { |
|
| 44 | - $result = new HtmlInput($identifier, "text", $value, $placeholder); |
|
| 43 | + public static function outline($identifier, $icon, $value="", $placeholder="") { |
|
| 44 | + $result=new HtmlInput($identifier, "text", $value, $placeholder); |
|
| 45 | 45 | $result->addToProperty("class", "transparent"); |
| 46 | 46 | $result->addIcon($icon)->setOutline(); |
| 47 | 47 | return $result; |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | public function run(JsUtils $js) { |
| 51 | - $result = parent::run($js); |
|
| 52 | - $result->attach("#" . $this->getDataField() |
|
| 51 | + $result=parent::run($js); |
|
| 52 | + $result->attach("#".$this->getDataField() |
|
| 53 | 53 | ->getIdentifier()); |
| 54 | 54 | return $result; |
| 55 | 55 | } |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | return $this->addToProperty("class", "transparent"); |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | - public function compile_once(\Ajax\JsUtils $js = NULL, &$view = NULL) { |
|
| 61 | + public function compile_once(\Ajax\JsUtils $js=NULL, &$view=NULL) { |
|
| 62 | 62 | parent::compile_once($js, $view); |
| 63 | 63 | if (isset($this->content['file'])) { |
| 64 | 64 | $this->onCreate(Javascript::fileUploadBehavior($this->identifier)); |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | public function addDataList($items) { |
| 69 | - $dl = new HtmlDatalist('list-' . $this->identifier); |
|
| 69 | + $dl=new HtmlDatalist('list-'.$this->identifier); |
|
| 70 | 70 | $dl->addItems($items); |
| 71 | 71 | $this->getDataField()->setProperty('list', $dl->getIdentifier()); |
| 72 | 72 | $this->getDataField()->wrap($dl); |