@@ -8,16 +8,16 @@ discard block |
||
| 8 | 8 | |
| 9 | 9 | trait MenuItemTrait { |
| 10 | 10 | |
| 11 | - public function setContent($content){ |
|
| 12 | - if($content==="-"){ |
|
| 11 | + public function setContent($content) { |
|
| 12 | + if ($content==="-") { |
|
| 13 | 13 | $this->asDivider(); |
| 14 | - }elseif($content==="-search-"){ |
|
| 15 | - $values=\explode(",",$content,-1); |
|
| 16 | - $this->asSearchInput(JArray::getDefaultValue($values, 0, "Search..."),JArray::getDefaultValue($values, 1, "search")); |
|
| 17 | - }elseif(JString::startswith($content, "-")){ |
|
| 18 | - $content=\ltrim($content,"-"); |
|
| 14 | + }elseif ($content==="-search-") { |
|
| 15 | + $values=\explode(",", $content, -1); |
|
| 16 | + $this->asSearchInput(JArray::getDefaultValue($values, 0, "Search..."), JArray::getDefaultValue($values, 1, "search")); |
|
| 17 | + }elseif (JString::startswith($content, "-")) { |
|
| 18 | + $content=\ltrim($content, "-"); |
|
| 19 | 19 | $this->asHeader($content); |
| 20 | - }else |
|
| 20 | + } else |
|
| 21 | 21 | parent::setContent($content); |
| 22 | 22 | return $this; |
| 23 | 23 | } |
@@ -27,13 +27,13 @@ discard block |
||
| 27 | 27 | * @param string $icon |
| 28 | 28 | * @return \Ajax\semantic\html\content\HtmlDropdownItem|\Ajax\semantic\html\content\HtmlMenuItem |
| 29 | 29 | */ |
| 30 | - public function asSearchInput($placeholder=NULL,$icon=NULL){ |
|
| 30 | + public function asSearchInput($placeholder=NULL, $icon=NULL) { |
|
| 31 | 31 | $this->setClass("ui icon search input"); |
| 32 | 32 | $input=new HtmlInput("search-".$this->identifier); |
| 33 | - if(isset($placeholder)) |
|
| 33 | + if (isset($placeholder)) |
|
| 34 | 34 | $input->setProperty("placeholder", $placeholder); |
| 35 | 35 | $this->content=$input; |
| 36 | - if(isset($icon)) |
|
| 36 | + if (isset($icon)) |
|
| 37 | 37 | $this->addIcon($icon); |
| 38 | 38 | return $this; |
| 39 | 39 | } |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | /** |
| 42 | 42 | * @return \Ajax\semantic\html\content\HtmlDropdownItem|\Ajax\semantic\html\content\HtmlMenuItem |
| 43 | 43 | */ |
| 44 | - public function asDivider(){ |
|
| 44 | + public function asDivider() { |
|
| 45 | 45 | $this->content=NULL; |
| 46 | 46 | $this->tagName="div"; |
| 47 | 47 | $this->setClass("divider"); |
@@ -53,16 +53,16 @@ discard block |
||
| 53 | 53 | * @param string $icon |
| 54 | 54 | * @return \Ajax\semantic\html\content\HtmlDropdownItem|\Ajax\semantic\html\content\HtmlMenuItem |
| 55 | 55 | */ |
| 56 | - public function asHeader($caption=NULL,$icon=NULL){ |
|
| 56 | + public function asHeader($caption=NULL, $icon=NULL) { |
|
| 57 | 57 | $this->setClass("header"); |
| 58 | 58 | $this->tagName="div"; |
| 59 | 59 | $this->content=$caption; |
| 60 | - if(isset($icon)) |
|
| 61 | - $this->addIcon($icon,Direction::LEFT); |
|
| 60 | + if (isset($icon)) |
|
| 61 | + $this->addIcon($icon, Direction::LEFT); |
|
| 62 | 62 | return $this; |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - public function setPosition($direction){ |
|
| 66 | - $this->addToProperty("class",$direction); |
|
| 65 | + public function setPosition($direction) { |
|
| 66 | + $this->addToProperty("class", $direction); |
|
| 67 | 67 | } |
| 68 | 68 | } |
| 69 | 69 | \ No newline at end of file |
@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | use Ajax\JsUtils; |
| 8 | 8 | |
| 9 | 9 | abstract class AbstractCheckbox extends HtmlSemDoubleElement { |
| 10 | - protected $_params=array (); |
|
| 10 | + protected $_params=array(); |
|
| 11 | 11 | |
| 12 | 12 | public function __construct($identifier, $name=NULL, $label=NULL, $value=NULL, $inputType="checkbox", $type="checkbox") { |
| 13 | 13 | parent::__construct("ck-".$identifier, "div", "ui ".$type); |
@@ -18,10 +18,10 @@ discard block |
||
| 18 | 18 | $this->setLabel($label); |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | - public function setChecked($value=true){ |
|
| 22 | - if($value===true){ |
|
| 21 | + public function setChecked($value=true) { |
|
| 22 | + if ($value===true) { |
|
| 23 | 23 | $this->getField()->setProperty("checked", "checked"); |
| 24 | - }else{ |
|
| 24 | + } else { |
|
| 25 | 25 | $this->getField()->removeProperty("checked"); |
| 26 | 26 | } |
| 27 | 27 | return $this; |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | * @return \Ajax\semantic\html\collections\form\AbstractHtmlFormRadioCheckbox |
| 84 | 84 | */ |
| 85 | 85 | public function attachEvent($selector, $action=NULL) { |
| 86 | - if (isset($action)!==false||\is_numeric($action)===true) { |
|
| 86 | + if (isset($action)!==false || \is_numeric($action)===true) { |
|
| 87 | 87 | $js='$("#%identifier%").checkbox("attach events", "'.$selector.'", "'.$action.'");'; |
| 88 | 88 | } else { |
| 89 | 89 | $js='$("#%identifier%").checkbox("attach events", "'.$selector.'");'; |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | */ |
| 100 | 100 | public function attachEvents($events=array()) { |
| 101 | 101 | if (\is_array($events)) { |
| 102 | - foreach ( $events as $action => $selector ) { |
|
| 102 | + foreach ($events as $action => $selector) { |
|
| 103 | 103 | $this->attachEvent($selector, $action); |
| 104 | 104 | } |
| 105 | 105 | } |
@@ -110,16 +110,16 @@ discard block |
||
| 110 | 110 | return $this->addToProperty("class", "fitted"); |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | - public function setOnChecked($jsCode){ |
|
| 113 | + public function setOnChecked($jsCode) { |
|
| 114 | 114 | $this->_params["onChecked"]=$jsCode; |
| 115 | 115 | } |
| 116 | 116 | |
| 117 | - public function setOnUnchecked($jsCode){ |
|
| 117 | + public function setOnUnchecked($jsCode) { |
|
| 118 | 118 | $this->_params["onUnchecked"]=$jsCode; |
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | public function run(JsUtils $js) { |
| 122 | - $this->_bsComponent=$js->semantic()->checkbox("#" . $this->identifier, $this->_params); |
|
| 122 | + $this->_bsComponent=$js->semantic()->checkbox("#".$this->identifier, $this->_params); |
|
| 123 | 123 | return parent::run($js); |
| 124 | 124 | } |
| 125 | 125 | } |
| 126 | 126 | \ No newline at end of file |
@@ -2,33 +2,33 @@ |
||
| 2 | 2 | namespace Ajax\service; |
| 3 | 3 | class JString { |
| 4 | 4 | |
| 5 | - public static function contains($hay,$needle){ |
|
| 6 | - return strpos($hay, $needle) !== false; |
|
| 5 | + public static function contains($hay, $needle) { |
|
| 6 | + return strpos($hay, $needle)!==false; |
|
| 7 | 7 | } |
| 8 | 8 | public static function startswith($hay, $needle) { |
| 9 | - return substr($hay, 0, strlen($needle)) === $needle; |
|
| 9 | + return substr($hay, 0, strlen($needle))===$needle; |
|
| 10 | 10 | } |
| 11 | 11 | |
| 12 | 12 | public static function endswith($hay, $needle) { |
| 13 | - return substr($hay, -strlen($needle)) === $needle; |
|
| 13 | + return substr($hay, -strlen($needle))===$needle; |
|
| 14 | 14 | } |
| 15 | 15 | |
| 16 | - public static function isNull($s){ |
|
| 16 | + public static function isNull($s) { |
|
| 17 | 17 | return (!isset($s) || NULL===$s || ""===$s); |
| 18 | 18 | } |
| 19 | - public static function isNotNull($s){ |
|
| 19 | + public static function isNotNull($s) { |
|
| 20 | 20 | return (isset($s) && NULL!==$s && ""!==$s); |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | - public static function isBoolean($value){ |
|
| 23 | + public static function isBoolean($value) { |
|
| 24 | 24 | return \is_bool($value) || $value==1 || $value==0; |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | - public static function isBooleanTrue($value){ |
|
| 27 | + public static function isBooleanTrue($value) { |
|
| 28 | 28 | return $value==1 || $value; |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | - public static function isBooleanFalse($value){ |
|
| 31 | + public static function isBooleanFalse($value) { |
|
| 32 | 32 | return $value==0 || !$value; |
| 33 | 33 | } |
| 34 | 34 | } |
| 35 | 35 | \ No newline at end of file |
@@ -3,5 +3,5 @@ |
||
| 3 | 3 | use Ajax\common\BaseEnum; |
| 4 | 4 | |
| 5 | 5 | abstract class PositionInTable extends BaseEnum { |
| 6 | - const BEFORETABLE="beforeTable",AFTERTABLE="afterTable",HEADER="thead",FOOTER="tfoot",BODY="tbody"; |
|
| 6 | + const BEFORETABLE="beforeTable", AFTERTABLE="afterTable", HEADER="thead", FOOTER="tfoot", BODY="tbody"; |
|
| 7 | 7 | } |
| 8 | 8 | \ No newline at end of file |
@@ -19,35 +19,35 @@ |
||
| 19 | 19 | class DataElement extends Widget { |
| 20 | 20 | |
| 21 | 21 | public function __construct($identifier, $modelInstance=NULL) { |
| 22 | - parent::__construct($identifier, null,$modelInstance); |
|
| 22 | + parent::__construct($identifier, null, $modelInstance); |
|
| 23 | 23 | $this->_instanceViewer=new InstanceViewer(); |
| 24 | - $this->content=["table"=>new HtmlTable($identifier, 0,2)]; |
|
| 24 | + $this->content=["table"=>new HtmlTable($identifier, 0, 2)]; |
|
| 25 | 25 | $this->content["table"]->setDefinition(); |
| 26 | 26 | $this->_toolbarPosition=PositionInTable::BEFORETABLE; |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | - public function compile(JsUtils $js=NULL,&$view=NULL){ |
|
| 29 | + public function compile(JsUtils $js=NULL, &$view=NULL) { |
|
| 30 | 30 | $this->_instanceViewer->setInstance($this->_modelInstance); |
| 31 | 31 | |
| 32 | 32 | $table=$this->content["table"]; |
| 33 | 33 | $this->_generateContent($table); |
| 34 | 34 | |
| 35 | - if(isset($this->_toolbar)){ |
|
| 35 | + if (isset($this->_toolbar)) { |
|
| 36 | 36 | $this->_setToolbarPosition($table); |
| 37 | 37 | } |
| 38 | - $this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE,"table",PositionInTable::AFTERTABLE]); |
|
| 39 | - return parent::compile($js,$view); |
|
| 38 | + $this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE, "table", PositionInTable::AFTERTABLE]); |
|
| 39 | + return parent::compile($js, $view); |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | /** |
| 43 | 43 | * @param HtmlTable $table |
| 44 | 44 | */ |
| 45 | - protected function _generateContent($table){ |
|
| 45 | + protected function _generateContent($table) { |
|
| 46 | 46 | $captions=$this->_instanceViewer->getCaptions(); |
| 47 | - $values= $this->_instanceViewer->getValues(); |
|
| 47 | + $values=$this->_instanceViewer->getValues(); |
|
| 48 | 48 | $count=$this->_instanceViewer->count(); |
| 49 | - for($i=0;$i<$count;$i++){ |
|
| 50 | - $table->addRow([$captions[$i],$values[$i]]); |
|
| 49 | + for ($i=0; $i<$count; $i++) { |
|
| 50 | + $table->addRow([$captions[$i], $values[$i]]); |
|
| 51 | 51 | } |
| 52 | 52 | } |
| 53 | 53 | |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | } |
| 36 | 36 | if (isset($label)) |
| 37 | 37 | $this->setLabel($label); |
| 38 | - foreach ( $fields as $field ) { |
|
| 38 | + foreach ($fields as $field) { |
|
| 39 | 39 | $this->addItem($field); |
| 40 | 40 | } |
| 41 | 41 | return $this; |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | |
| 58 | 58 | public function addItem($item) { |
| 59 | 59 | $item=parent::addItem($item); |
| 60 | - if($item instanceof HtmlFormField) |
|
| 60 | + if ($item instanceof HtmlFormField) |
|
| 61 | 61 | $item->setContainer($this); |
| 62 | 62 | return $item; |
| 63 | 63 | } |
@@ -98,9 +98,9 @@ discard block |
||
| 98 | 98 | |
| 99 | 99 | |
| 100 | 100 | public static function radios($name, $items=array(), $label=NULL, $value=null, $type=NULL) { |
| 101 | - $fields=array (); |
|
| 101 | + $fields=array(); |
|
| 102 | 102 | $i=0; |
| 103 | - foreach ( $items as $val => $caption ) { |
|
| 103 | + foreach ($items as $val => $caption) { |
|
| 104 | 104 | $itemO=new HtmlFormRadio($name."-".$i++, $name, $caption, $val, $type); |
| 105 | 105 | if ($val===$value) { |
| 106 | 106 | $itemO->getField()->setProperty("checked", ""); |
@@ -114,9 +114,9 @@ discard block |
||
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | public static function checkeds($name, $items=array(), $label=NULL, $values=array(), $type=NULL) { |
| 117 | - $fields=array (); |
|
| 117 | + $fields=array(); |
|
| 118 | 118 | $i=0; |
| 119 | - foreach ( $items as $val => $caption ) { |
|
| 119 | + foreach ($items as $val => $caption) { |
|
| 120 | 120 | $itemO=new HtmlFormCheckbox($name."-".$i++, $name, $caption, $val, $type); |
| 121 | 121 | if (\array_search($val, $values)!==false) { |
| 122 | 122 | $itemO->getField()->getField()->setProperty("checked", ""); |
@@ -15,8 +15,8 @@ discard block |
||
| 15 | 15 | * @param array $instances |
| 16 | 16 | * @return DataTable |
| 17 | 17 | */ |
| 18 | - public function dataTable($identifier,$model, $instances){ |
|
| 19 | - return $this->addHtmlComponent(new DataTable($identifier,$model,$instances)); |
|
| 18 | + public function dataTable($identifier, $model, $instances) { |
|
| 19 | + return $this->addHtmlComponent(new DataTable($identifier, $model, $instances)); |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | /** |
@@ -24,8 +24,8 @@ discard block |
||
| 24 | 24 | * @param object $instance |
| 25 | 25 | * @return DataElement |
| 26 | 26 | */ |
| 27 | - public function dataElement($identifier, $instance){ |
|
| 28 | - return $this->addHtmlComponent(new DataElement($identifier,$instance)); |
|
| 27 | + public function dataElement($identifier, $instance) { |
|
| 28 | + return $this->addHtmlComponent(new DataElement($identifier, $instance)); |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | /** |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | * @param object $instance |
| 34 | 34 | * @return DataForm |
| 35 | 35 | */ |
| 36 | - public function dataForm($identifier, $instance){ |
|
| 37 | - return $this->addHtmlComponent(new DataForm($identifier,$instance)); |
|
| 36 | + public function dataForm($identifier, $instance) { |
|
| 37 | + return $this->addHtmlComponent(new DataForm($identifier, $instance)); |
|
| 38 | 38 | } |
| 39 | 39 | } |
| 40 | 40 | \ No newline at end of file |
@@ -8,16 +8,16 @@ |
||
| 8 | 8 | class HtmlFormInput extends HtmlFormField { |
| 9 | 9 | use TextFieldsTrait; |
| 10 | 10 | |
| 11 | - public function __construct($identifier, $label=NULL,$type="text",$value=NULL,$placeholder=NULL) { |
|
| 12 | - if(!isset($placeholder) && $type==="text") |
|
| 11 | + public function __construct($identifier, $label=NULL, $type="text", $value=NULL, $placeholder=NULL) { |
|
| 12 | + if (!isset($placeholder) && $type==="text") |
|
| 13 | 13 | $placeholder=$label; |
| 14 | - parent::__construct("field-".$identifier, new HtmlInput($identifier,$type,$value,$placeholder), $label); |
|
| 14 | + parent::__construct("field-".$identifier, new HtmlInput($identifier, $type, $value, $placeholder), $label); |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | - public function getDataField(){ |
|
| 18 | - $field= $this->getField(); |
|
| 17 | + public function getDataField() { |
|
| 18 | + $field=$this->getField(); |
|
| 19 | 19 | //TODO check getField |
| 20 | - if($field instanceof HtmlInput) |
|
| 20 | + if ($field instanceof HtmlInput) |
|
| 21 | 21 | $field=$field->getDataField(); |
| 22 | 22 | return $field; |
| 23 | 23 | } |
@@ -9,17 +9,17 @@ discard block |
||
| 9 | 9 | class HtmlFormTextarea extends HtmlFormField { |
| 10 | 10 | use TextFieldsTrait; |
| 11 | 11 | |
| 12 | - public function __construct($identifier, $label=NULL,$value=NULL,$placeholder=NULL,$rows=NULL) { |
|
| 13 | - if(!isset($placeholder)) |
|
| 12 | + public function __construct($identifier, $label=NULL, $value=NULL, $placeholder=NULL, $rows=NULL) { |
|
| 13 | + if (!isset($placeholder)) |
|
| 14 | 14 | $placeholder=$label; |
| 15 | - parent::__construct("field-".$identifier, new HtmlTextarea($identifier,$value,$placeholder,$rows), $label); |
|
| 15 | + parent::__construct("field-".$identifier, new HtmlTextarea($identifier, $value, $placeholder, $rows), $label); |
|
| 16 | 16 | } |
| 17 | 17 | |
| 18 | 18 | /** |
| 19 | 19 | * Defines the textarea row count |
| 20 | 20 | * @param int $count |
| 21 | 21 | */ |
| 22 | - public function setRows($count){ |
|
| 22 | + public function setRows($count) { |
|
| 23 | 23 | $this->getField()->setRows($count); |
| 24 | 24 | } |
| 25 | 25 | |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | return $this->content["field"]; |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | - public function setName($name){ |
|
| 31 | - $this->getDataField()->setProperty("name",$name); |
|
| 30 | + public function setName($name) { |
|
| 31 | + $this->getDataField()->setProperty("name", $name); |
|
| 32 | 32 | } |
| 33 | 33 | } |
| 34 | 34 | \ No newline at end of file |