@@ -55,26 +55,29 @@ |
||
| 55 | 55 | for($i=$this->_startStep;$i<$count;$i++){ |
| 56 | 56 | $step=$this->content[$i]; |
| 57 | 57 | $step->removeStatus(); |
| 58 | - if($i<$activestep) |
|
| 59 | - $step->setCompleted(); |
|
| 60 | - elseif ($i===$activestep) |
|
| 61 | - $step->setActive(); |
|
| 62 | - else |
|
| 63 | - $step->setDisabled(); |
|
| 58 | + if($i<$activestep) { |
|
| 59 | + $step->setCompleted(); |
|
| 60 | + } elseif ($i===$activestep) { |
|
| 61 | + $step->setActive(); |
|
| 62 | + } else { |
|
| 63 | + $step->setDisabled(); |
|
| 64 | + } |
|
| 64 | 65 | } |
| 65 | - }else{ |
|
| 66 | + } else{ |
|
| 66 | 67 | foreach ($this->content as $step){ |
| 67 | 68 | $step->removeStatus(); |
| 68 | 69 | } |
| 69 | - if($activestep<$count) |
|
| 70 | - $this->content[$activestep]->setActive(); |
|
| 70 | + if($activestep<$count) { |
|
| 71 | + $this->content[$activestep]->setActive(); |
|
| 72 | + } |
|
| 71 | 73 | } |
| 72 | 74 | return $this; |
| 73 | 75 | } |
| 74 | 76 | |
| 75 | 77 | public function compile(JsUtils $js=NULL, &$view=NULL) { |
| 76 | - if(isset($this->_activeStep) && \is_numeric($this->_activeStep)) |
|
| 77 | - $this->defineActiveStep(); |
|
| 78 | + if(isset($this->_activeStep) && \is_numeric($this->_activeStep)) { |
|
| 79 | + $this->defineActiveStep(); |
|
| 80 | + } |
|
| 78 | 81 | return parent::compile($js,$view); |
| 79 | 82 | } |
| 80 | 83 | |
@@ -9,12 +9,12 @@ discard block |
||
| 9 | 9 | use Ajax\common\html\HtmlDoubleElement; |
| 10 | 10 | use Ajax\semantic\html\base\constants\Side; |
| 11 | 11 | |
| 12 | -class HtmlStep extends HtmlSemCollection{ |
|
| 12 | +class HtmlStep extends HtmlSemCollection { |
|
| 13 | 13 | protected $_activeStep; |
| 14 | 14 | protected $_startStep; |
| 15 | 15 | |
| 16 | - public function __construct( $identifier,$steps=array()){ |
|
| 17 | - parent::__construct( $identifier,"div", "ui steps"); |
|
| 16 | + public function __construct($identifier, $steps=array()) { |
|
| 17 | + parent::__construct($identifier, "div", "ui steps"); |
|
| 18 | 18 | $this->addItems($steps); |
| 19 | 19 | } |
| 20 | 20 | |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | * @see \Ajax\common\html\html5\HtmlCollection::createItem() |
| 25 | 25 | */ |
| 26 | 26 | protected function createItem($value) { |
| 27 | - $itemO=new HtmlStepItem("item-".\sizeof($this->content),$value); |
|
| 27 | + $itemO=new HtmlStepItem("item-".\sizeof($this->content), $value); |
|
| 28 | 28 | return $itemO; |
| 29 | 29 | } |
| 30 | 30 | |
@@ -32,50 +32,50 @@ discard block |
||
| 32 | 32 | * @param string|array $step |
| 33 | 33 | * @return HtmlStepItem |
| 34 | 34 | */ |
| 35 | - public function addStep($step){ |
|
| 35 | + public function addStep($step) { |
|
| 36 | 36 | return $this->addItem($step); |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | - public function setOrdered(){ |
|
| 39 | + public function setOrdered() { |
|
| 40 | 40 | return $this->addToProperty("class", "ordered"); |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | - public function isOrdered(){ |
|
| 43 | + public function isOrdered() { |
|
| 44 | 44 | return $this->propertyContains("class", "ordered"); |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - public function setVertical(){ |
|
| 47 | + public function setVertical() { |
|
| 48 | 48 | return $this->addToProperty("class", "vertical"); |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | - protected function defineActiveStep(){ |
|
| 51 | + protected function defineActiveStep() { |
|
| 52 | 52 | $activestep=$this->_activeStep; |
| 53 | 53 | $count=$this->count(); |
| 54 | - if(!$this->isOrdered()){ |
|
| 55 | - for($i=$this->_startStep;$i<$count;$i++){ |
|
| 54 | + if (!$this->isOrdered()) { |
|
| 55 | + for ($i=$this->_startStep; $i<$count; $i++) { |
|
| 56 | 56 | $step=$this->content[$i]; |
| 57 | 57 | $step->removeStatus(); |
| 58 | - if($i<$activestep) |
|
| 58 | + if ($i<$activestep) |
|
| 59 | 59 | $step->setCompleted(); |
| 60 | 60 | elseif ($i===$activestep) |
| 61 | 61 | $step->setActive(); |
| 62 | 62 | else |
| 63 | 63 | $step->setDisabled(); |
| 64 | 64 | } |
| 65 | - }else{ |
|
| 66 | - foreach ($this->content as $step){ |
|
| 65 | + } else { |
|
| 66 | + foreach ($this->content as $step) { |
|
| 67 | 67 | $step->removeStatus(); |
| 68 | 68 | } |
| 69 | - if($activestep<$count) |
|
| 69 | + if ($activestep<$count) |
|
| 70 | 70 | $this->content[$activestep]->setActive(); |
| 71 | 71 | } |
| 72 | 72 | return $this; |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | public function compile(JsUtils $js=NULL, &$view=NULL) { |
| 76 | - if(isset($this->_activeStep) && \is_numeric($this->_activeStep)) |
|
| 76 | + if (isset($this->_activeStep) && \is_numeric($this->_activeStep)) |
|
| 77 | 77 | $this->defineActiveStep(); |
| 78 | - return parent::compile($js,$view); |
|
| 78 | + return parent::compile($js, $view); |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | public function setActiveStep($_activeStep) { |
@@ -83,11 +83,11 @@ discard block |
||
| 83 | 83 | return $this; |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | - public function setAttached($side="",HtmlDoubleElement $toElement=NULL){ |
|
| 87 | - if(isset($toElement)){ |
|
| 88 | - $toElement->addToPropertyCtrl("class", "attached",array("attached")); |
|
| 86 | + public function setAttached($side="", HtmlDoubleElement $toElement=NULL) { |
|
| 87 | + if (isset($toElement)) { |
|
| 88 | + $toElement->addToPropertyCtrl("class", "attached", array("attached")); |
|
| 89 | 89 | } |
| 90 | - return $this->addToPropertyCtrl("class", $side." attached",Side::getConstantValues("attached")); |
|
| 90 | + return $this->addToPropertyCtrl("class", $side." attached", Side::getConstantValues("attached")); |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | public function setStartStep($_startStep) { |
@@ -9,15 +9,15 @@ discard block |
||
| 9 | 9 | protected $image; |
| 10 | 10 | |
| 11 | 11 | public function __construct($identifier, $content=NULL) { |
| 12 | - parent::__construct($identifier,"item",$content); |
|
| 12 | + parent::__construct($identifier, "item", $content); |
|
| 13 | 13 | } |
| 14 | - protected function initContent($content){ |
|
| 15 | - if(\is_array($content)){ |
|
| 16 | - if(JArray::isAssociative($content)===false){ |
|
| 14 | + protected function initContent($content) { |
|
| 15 | + if (\is_array($content)) { |
|
| 16 | + if (JArray::isAssociative($content)===false) { |
|
| 17 | 17 | $icon=@$content[0]; |
| 18 | 18 | $title=@$content[1]; |
| 19 | 19 | $desc=@$content[2]; |
| 20 | - }else{ |
|
| 20 | + } else { |
|
| 21 | 21 | $icon=@$content["icon"]; |
| 22 | 22 | $image=@$content["image"]; |
| 23 | 23 | $title=@$content["title"]; |
@@ -25,38 +25,38 @@ discard block |
||
| 25 | 25 | $desc=@$content["description"]; |
| 26 | 26 | $items=@$content["items"]; |
| 27 | 27 | } |
| 28 | - if(isset($icon)){ |
|
| 28 | + if (isset($icon)) { |
|
| 29 | 29 | $this->setIcon($icon); |
| 30 | 30 | } |
| 31 | - if(isset($image)){ |
|
| 31 | + if (isset($image)) { |
|
| 32 | 32 | $this->setImage($image); |
| 33 | 33 | } |
| 34 | - if(isset($title)){ |
|
| 35 | - $this->setTitle($title,$desc); |
|
| 36 | - }elseif (isset($header)){ |
|
| 37 | - $this->setTitle($header,$desc,"header"); |
|
| 34 | + if (isset($title)) { |
|
| 35 | + $this->setTitle($title, $desc); |
|
| 36 | + }elseif (isset($header)) { |
|
| 37 | + $this->setTitle($header, $desc, "header"); |
|
| 38 | 38 | } |
| 39 | - if(isset($items)){ |
|
| 39 | + if (isset($items)) { |
|
| 40 | 40 | $this->addList($items); |
| 41 | 41 | } |
| 42 | - }else{ |
|
| 42 | + } else { |
|
| 43 | 43 | $this->setContent($content); |
| 44 | 44 | } |
| 45 | 45 | } |
| 46 | - public function addList($items=array(),$ordered=false) { |
|
| 46 | + public function addList($items=array(), $ordered=false) { |
|
| 47 | 47 | $list=new HtmlList("", $items); |
| 48 | - if($ordered) |
|
| 48 | + if ($ordered) |
|
| 49 | 49 | $list->setOrdered(); |
| 50 | 50 | $list->setClass("list"); |
| 51 | 51 | $this->content["list"]=$list; |
| 52 | 52 | return $list; |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - public function getList(){ |
|
| 55 | + public function getList() { |
|
| 56 | 56 | return $this->content["list"]; |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | - public function getItem($index){ |
|
| 59 | + public function getItem($index) { |
|
| 60 | 60 | return $this->getList()->getItem($index); |
| 61 | 61 | } |
| 62 | 62 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | $icon=@$content[0]; |
| 18 | 18 | $title=@$content[1]; |
| 19 | 19 | $desc=@$content[2]; |
| 20 | - }else{ |
|
| 20 | + } else{ |
|
| 21 | 21 | $icon=@$content["icon"]; |
| 22 | 22 | $image=@$content["image"]; |
| 23 | 23 | $title=@$content["title"]; |
@@ -33,20 +33,21 @@ discard block |
||
| 33 | 33 | } |
| 34 | 34 | if(isset($title)){ |
| 35 | 35 | $this->setTitle($title,$desc); |
| 36 | - }elseif (isset($header)){ |
|
| 36 | + } elseif (isset($header)){ |
|
| 37 | 37 | $this->setTitle($header,$desc,"header"); |
| 38 | 38 | } |
| 39 | 39 | if(isset($items)){ |
| 40 | 40 | $this->addList($items); |
| 41 | 41 | } |
| 42 | - }else{ |
|
| 42 | + } else{ |
|
| 43 | 43 | $this->setContent($content); |
| 44 | 44 | } |
| 45 | 45 | } |
| 46 | 46 | public function addList($items=array(),$ordered=false) { |
| 47 | 47 | $list=new HtmlList("", $items); |
| 48 | - if($ordered) |
|
| 49 | - $list->setOrdered(); |
|
| 48 | + if($ordered) { |
|
| 49 | + $list->setOrdered(); |
|
| 50 | + } |
|
| 50 | 51 | $list->setClass("list"); |
| 51 | 52 | $this->content["list"]=$list; |
| 52 | 53 | return $list; |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | |
| 12 | 12 | class HtmlPopup extends HtmlSemDoubleElement { |
| 13 | 13 | private $_container; |
| 14 | - public function __construct(BaseHtml $container,$identifier, $content="") { |
|
| 14 | + public function __construct(BaseHtml $container, $identifier, $content="") { |
|
| 15 | 15 | parent::__construct($identifier, "div"); |
| 16 | 16 | $this->_container=$container; |
| 17 | 17 | $this->setClass("ui popup"); |
@@ -23,9 +23,9 @@ discard block |
||
| 23 | 23 | * {@inheritDoc} |
| 24 | 24 | * @see \Ajax\semantic\html\base\HtmlSemDoubleElement::addList() |
| 25 | 25 | */ |
| 26 | - public function addList($items=array(),$header=NULL){ |
|
| 27 | - if(!$this->content instanceof HtmlGrid){ |
|
| 28 | - $this->content=new HtmlGrid("Grid-".$this->identifier,0); |
|
| 26 | + public function addList($items=array(), $header=NULL) { |
|
| 27 | + if (!$this->content instanceof HtmlGrid) { |
|
| 28 | + $this->content=new HtmlGrid("Grid-".$this->identifier, 0); |
|
| 29 | 29 | } |
| 30 | 30 | $grid=$this->content; |
| 31 | 31 | |
@@ -33,12 +33,12 @@ discard block |
||
| 33 | 33 | $colCount++; |
| 34 | 34 | $grid->setColsCount($colCount); |
| 35 | 35 | |
| 36 | - $list=new HtmlList("",$items); |
|
| 36 | + $list=new HtmlList("", $items); |
|
| 37 | 37 | $list->asLink(); |
| 38 | - if(isset($header)){ |
|
| 39 | - $list->addHeader(4,$header); |
|
| 38 | + if (isset($header)) { |
|
| 39 | + $list->addHeader(4, $header); |
|
| 40 | 40 | } |
| 41 | - $grid->getCell(0,$colCount-1)->setContent($list); |
|
| 41 | + $grid->getCell(0, $colCount-1)->setContent($list); |
|
| 42 | 42 | $grid->setDivided()->setRelaxed(true); |
| 43 | 43 | return $list; |
| 44 | 44 | } |
@@ -46,14 +46,14 @@ discard block |
||
| 46 | 46 | /** |
| 47 | 47 | * A popup can have no maximum width and continue to flow to fit its content |
| 48 | 48 | */ |
| 49 | - public function setFlowing(){ |
|
| 49 | + public function setFlowing() { |
|
| 50 | 50 | return $this->addToProperty("class", "flowing"); |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | /** |
| 54 | 54 | * A popup can provide more basic formatting |
| 55 | 55 | */ |
| 56 | - public function setBasic(){ |
|
| 56 | + public function setBasic() { |
|
| 57 | 57 | return $this->addToProperty("class", "basic"); |
| 58 | 58 | } |
| 59 | 59 | |
@@ -61,23 +61,23 @@ discard block |
||
| 61 | 61 | * {@inheritDoc} |
| 62 | 62 | * @see \Ajax\semantic\html\base\HtmlSemDoubleElement::run() |
| 63 | 63 | */ |
| 64 | - public function run(JsUtils $js){ |
|
| 64 | + public function run(JsUtils $js) { |
|
| 65 | 65 | parent::run($js); |
| 66 | 66 | $this->_params["popup"]="#".$this->identifier; |
| 67 | - $js->semantic()->popup("#".$this->_container->getIdentifier(),$this->_params); |
|
| 67 | + $js->semantic()->popup("#".$this->_container->getIdentifier(), $this->_params); |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | - public function setOn($event="click"){ |
|
| 70 | + public function setOn($event="click") { |
|
| 71 | 71 | $this->_params["on"]=$event; |
| 72 | 72 | return $this; |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | - public function setInline($value=true){ |
|
| 75 | + public function setInline($value=true) { |
|
| 76 | 76 | $this->_params["inline"]=$value; |
| 77 | 77 | return $this; |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | - public function setPosition($position){ |
|
| 80 | + public function setPosition($position) { |
|
| 81 | 81 | $this->_params["position"]=$position; |
| 82 | 82 | return $this; |
| 83 | 83 | } |
@@ -50,8 +50,9 @@ discard block |
||
| 50 | 50 | |
| 51 | 51 | protected function getItemToAdd($item){ |
| 52 | 52 | $itemO=parent::getItemToAdd($item); |
| 53 | - if($itemO instanceof AbstractCheckbox) |
|
| 54 | - $itemO->addClass("item"); |
|
| 53 | + if($itemO instanceof AbstractCheckbox) { |
|
| 54 | + $itemO->addClass("item"); |
|
| 55 | + } |
|
| 55 | 56 | return $itemO; |
| 56 | 57 | } |
| 57 | 58 | |
@@ -106,14 +107,15 @@ discard block |
||
| 106 | 107 | if (isset($masterItem)) { |
| 107 | 108 | if(\is_array($masterItem)){ |
| 108 | 109 | $masterO=new HtmlFormCheckbox("master-" . $identifier, @$masterItem[0],@$masterItem[1]); |
| 109 | - if(isset($name)) |
|
| 110 | - $masterO->setName($name); |
|
| 110 | + if(isset($name)) { |
|
| 111 | + $masterO->setName($name); |
|
| 112 | + } |
|
| 111 | 113 | if(isset($masterItem[1])){ |
| 112 | 114 | if(\array_search($masterItem[1], $values)!==false){ |
| 113 | 115 | $masterO->getDataField()->setProperty("checked", ""); |
| 114 | 116 | } |
| 115 | 117 | } |
| 116 | - }else{ |
|
| 118 | + } else{ |
|
| 117 | 119 | $masterO=new HtmlFormCheckbox("master-" . $identifier, $masterItem); |
| 118 | 120 | } |
| 119 | 121 | if($notAllChecked){ |
@@ -130,8 +132,9 @@ discard block |
||
| 130 | 132 | if (\array_search($val, $values) !== false) { |
| 131 | 133 | $itemO->getDataField()->setProperty("checked", ""); |
| 132 | 134 | } |
| 133 | - if(isset($name)) |
|
| 134 | - $itemO->setName($name); |
|
| 135 | + if(isset($name)) { |
|
| 136 | + $itemO->setName($name); |
|
| 137 | + } |
|
| 135 | 138 | $itemO->setClass("item"); |
| 136 | 139 | $fields[]=$itemO; |
| 137 | 140 | } |
@@ -21,17 +21,17 @@ discard block |
||
| 21 | 21 | |
| 22 | 22 | protected function createItem($value) { |
| 23 | 23 | $count=$this->count(); |
| 24 | - $item=new HtmlListItem("item-" . $this->identifier . "-" . $count, $value); |
|
| 24 | + $item=new HtmlListItem("item-".$this->identifier."-".$count, $value); |
|
| 25 | 25 | return $item; |
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | public function addHeader($niveau, $content) { |
| 29 | - $header=new HtmlHeader("header-" . $this->identifier, $niveau, $content, "page"); |
|
| 29 | + $header=new HtmlHeader("header-".$this->identifier, $niveau, $content, "page"); |
|
| 30 | 30 | $this->wrap($header); |
| 31 | 31 | return $header; |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | - public function getItemPart($index,$partName="header"){ |
|
| 34 | + public function getItemPart($index, $partName="header") { |
|
| 35 | 35 | return $this->getItem($index)->getPart($partName); |
| 36 | 36 | } |
| 37 | 37 | |
@@ -39,9 +39,9 @@ discard block |
||
| 39 | 39 | return $this->contentAs($tagName); |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | - public function asLinks($hrefs=[],$target=NUll) { |
|
| 43 | - $this->addToPropertyCtrl("class", "link", array ("link" )); |
|
| 44 | - return parent::asLinks($hrefs,$target); |
|
| 42 | + public function asLinks($hrefs=[], $target=NUll) { |
|
| 43 | + $this->addToPropertyCtrl("class", "link", array("link")); |
|
| 44 | + return parent::asLinks($hrefs, $target); |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | public function addList($items=array()) { |
@@ -50,9 +50,9 @@ discard block |
||
| 50 | 50 | return $this->addItem($list); |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | - protected function getItemToAdd($item){ |
|
| 53 | + protected function getItemToAdd($item) { |
|
| 54 | 54 | $itemO=parent::getItemToAdd($item); |
| 55 | - if($itemO instanceof AbstractCheckbox) |
|
| 55 | + if ($itemO instanceof AbstractCheckbox) |
|
| 56 | 56 | $itemO->addClass("item"); |
| 57 | 57 | return $itemO; |
| 58 | 58 | } |
@@ -70,9 +70,9 @@ discard block |
||
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | public function run(JsUtils $js) { |
| 73 | - if ($this->_hasCheckedList === true) { |
|
| 74 | - $jsCode=include dirname(__FILE__) . '/../../components/jsTemplates/tplCheckedList.php'; |
|
| 75 | - $jsCode=\str_replace("%identifier%", "#" . $this->identifier, $jsCode); |
|
| 73 | + if ($this->_hasCheckedList===true) { |
|
| 74 | + $jsCode=include dirname(__FILE__).'/../../components/jsTemplates/tplCheckedList.php'; |
|
| 75 | + $jsCode=\str_replace("%identifier%", "#".$this->identifier, $jsCode); |
|
| 76 | 76 | $jsCode=\str_replace("%fireOnInit%", $this->_fireOnInit, $jsCode); |
| 77 | 77 | $jsCode=\str_replace("%onChange%", $this->_ckItemChange, $jsCode); |
| 78 | 78 | $this->executeOnRun($jsCode); |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | return parent::run($js); |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | - public function onCkItemChange($jsCode){ |
|
| 83 | + public function onCkItemChange($jsCode) { |
|
| 84 | 84 | $this->_ckItemChange=$jsCode; |
| 85 | 85 | } |
| 86 | 86 | |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | * @param boolean $fireOnInit |
| 89 | 89 | */ |
| 90 | 90 | public function setFireOnInit($fireOnInit) { |
| 91 | - $this->_fireOnInit = $fireOnInit; |
|
| 91 | + $this->_fireOnInit=$fireOnInit; |
|
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | public function setRelaxed() { |
@@ -115,42 +115,42 @@ discard block |
||
| 115 | 115 | * @param string $notAllChecked |
| 116 | 116 | * @return HtmlList |
| 117 | 117 | */ |
| 118 | - public function addCheckedList($items=array(), $masterItem=NULL, $values=array(),$notAllChecked=false,$name=null) { |
|
| 118 | + public function addCheckedList($items=array(), $masterItem=NULL, $values=array(), $notAllChecked=false, $name=null) { |
|
| 119 | 119 | $count=$this->count(); |
| 120 | - $identifier=$this->identifier . "-" . $count; |
|
| 120 | + $identifier=$this->identifier."-".$count; |
|
| 121 | 121 | if (isset($masterItem)) { |
| 122 | - if(\is_array($masterItem)){ |
|
| 123 | - $masterO=new HtmlFormCheckbox("master-" . $identifier, @$masterItem[0],@$masterItem[1]); |
|
| 124 | - if(isset($name)) |
|
| 122 | + if (\is_array($masterItem)) { |
|
| 123 | + $masterO=new HtmlFormCheckbox("master-".$identifier, @$masterItem[0], @$masterItem[1]); |
|
| 124 | + if (isset($name)) |
|
| 125 | 125 | $masterO->setName($name); |
| 126 | - if(isset($masterItem[1])){ |
|
| 127 | - if(\array_search($masterItem[1], $values)!==false){ |
|
| 126 | + if (isset($masterItem[1])) { |
|
| 127 | + if (\array_search($masterItem[1], $values)!==false) { |
|
| 128 | 128 | $masterO->getDataField()->setProperty("checked", ""); |
| 129 | 129 | } |
| 130 | 130 | } |
| 131 | - }else{ |
|
| 132 | - $masterO=new HtmlFormCheckbox("master-" . $identifier, $masterItem); |
|
| 131 | + } else { |
|
| 132 | + $masterO=new HtmlFormCheckbox("master-".$identifier, $masterItem); |
|
| 133 | 133 | } |
| 134 | - if($notAllChecked){ |
|
| 134 | + if ($notAllChecked) { |
|
| 135 | 135 | $masterO->getDataField()->addClass("_notAllChecked"); |
| 136 | 136 | } |
| 137 | 137 | $masterO->getHtmlCk()->addToProperty("class", "master"); |
| 138 | 138 | $masterO->setClass("item"); |
| 139 | 139 | $this->addItem($masterO); |
| 140 | 140 | } |
| 141 | - $fields=array (); |
|
| 141 | + $fields=array(); |
|
| 142 | 142 | $i=0; |
| 143 | - foreach ( $items as $val => $caption ) { |
|
| 144 | - $itemO=new HtmlFormCheckbox($identifier . "-" . $i++, $caption, $val, "child"); |
|
| 145 | - if (\array_search($val, $values) !== false) { |
|
| 143 | + foreach ($items as $val => $caption) { |
|
| 144 | + $itemO=new HtmlFormCheckbox($identifier."-".$i++, $caption, $val, "child"); |
|
| 145 | + if (\array_search($val, $values)!==false) { |
|
| 146 | 146 | $itemO->getDataField()->setProperty("checked", ""); |
| 147 | 147 | } |
| 148 | - if(isset($name)) |
|
| 148 | + if (isset($name)) |
|
| 149 | 149 | $itemO->setName($name); |
| 150 | 150 | $itemO->setClass("item"); |
| 151 | 151 | $fields[]=$itemO; |
| 152 | 152 | } |
| 153 | - if (isset($masterO) === true) { |
|
| 153 | + if (isset($masterO)===true) { |
|
| 154 | 154 | $list=new HtmlList("", $fields); |
| 155 | 155 | $list->setClass("list"); |
| 156 | 156 | $masterO->addContent($list); |
@@ -161,12 +161,12 @@ discard block |
||
| 161 | 161 | return $this; |
| 162 | 162 | } |
| 163 | 163 | |
| 164 | - public function setIcons($icons){ |
|
| 165 | - if(!\is_array($icons)){ |
|
| 164 | + public function setIcons($icons) { |
|
| 165 | + if (!\is_array($icons)) { |
|
| 166 | 166 | $icons=\array_fill(0, \sizeof($this->content), $icons); |
| 167 | 167 | } |
| 168 | - $max=\min(\sizeof($icons),\sizeof($this->content)); |
|
| 169 | - for($i=0;$i<$max;$i++){ |
|
| 168 | + $max=\min(\sizeof($icons), \sizeof($this->content)); |
|
| 169 | + for ($i=0; $i<$max; $i++) { |
|
| 170 | 170 | $this->content[$i]->addIcon($icons[$i]); |
| 171 | 171 | } |
| 172 | 172 | return $this; |
@@ -14,19 +14,19 @@ discard block |
||
| 14 | 14 | * @property boolean $_visibleHover |
| 15 | 15 | * @property InstanceViewer $_instanceViewer |
| 16 | 16 | */ |
| 17 | -trait DataTableFieldAsTrait{ |
|
| 17 | +trait DataTableFieldAsTrait { |
|
| 18 | 18 | abstract public function addField($field); |
| 19 | - abstract public function insertField($index,$field); |
|
| 20 | - abstract public function insertInField($index,$field); |
|
| 21 | - abstract public function fieldAs($index,$type,$attributes=NULL); |
|
| 19 | + abstract public function insertField($index, $field); |
|
| 20 | + abstract public function insertInField($index, $field); |
|
| 21 | + abstract public function fieldAs($index, $type, $attributes=NULL); |
|
| 22 | 22 | /** |
| 23 | 23 | * @param string $caption |
| 24 | 24 | * @param callable $callback |
| 25 | 25 | * @param boolean $visibleHover |
| 26 | 26 | * @return callable |
| 27 | 27 | */ |
| 28 | - private function getFieldButtonCallable($caption,$visibleHover=true,$callback=null){ |
|
| 29 | - return $this->getCallable("getFieldButton",[$caption,$visibleHover],$callback); |
|
| 28 | + private function getFieldButtonCallable($caption, $visibleHover=true, $callback=null) { |
|
| 29 | + return $this->getCallable("getFieldButton", [$caption, $visibleHover], $callback); |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | /** |
@@ -35,20 +35,20 @@ discard block |
||
| 35 | 35 | * @param callable $callback |
| 36 | 36 | * @return callable |
| 37 | 37 | */ |
| 38 | - private function getCallable($thisCallback,$parameters,$callback=null){ |
|
| 39 | - $result=function($instance) use($thisCallback,$parameters,$callback){ |
|
| 40 | - $object=call_user_func_array(array($this,$thisCallback), $parameters); |
|
| 41 | - if(isset($callback)){ |
|
| 42 | - if(\is_callable($callback)){ |
|
| 43 | - $callback($object,$instance,$this->_instanceViewer->count()+1); |
|
| 38 | + private function getCallable($thisCallback, $parameters, $callback=null) { |
|
| 39 | + $result=function($instance) use($thisCallback, $parameters, $callback){ |
|
| 40 | + $object=call_user_func_array(array($this, $thisCallback), $parameters); |
|
| 41 | + if (isset($callback)) { |
|
| 42 | + if (\is_callable($callback)) { |
|
| 43 | + $callback($object, $instance, $this->_instanceViewer->count()+1); |
|
| 44 | 44 | } |
| 45 | 45 | } |
| 46 | - if($object instanceof HtmlSemDoubleElement){ |
|
| 46 | + if ($object instanceof HtmlSemDoubleElement) { |
|
| 47 | 47 | $id=$this->_instanceViewer->getIdentifier(); |
| 48 | - $object->setProperty("data-ajax",$id); |
|
| 49 | - if($object->propertyContains("class","visibleover")){ |
|
| 48 | + $object->setProperty("data-ajax", $id); |
|
| 49 | + if ($object->propertyContains("class", "visibleover")) { |
|
| 50 | 50 | $this->_visibleHover=true; |
| 51 | - $object->setProperty("style","visibility:hidden;"); |
|
| 51 | + $object->setProperty("style", "visibility:hidden;"); |
|
| 52 | 52 | } |
| 53 | 53 | } |
| 54 | 54 | return $object; |
@@ -60,16 +60,16 @@ discard block |
||
| 60 | 60 | * @param string $caption |
| 61 | 61 | * @return HtmlButton |
| 62 | 62 | */ |
| 63 | - private function getFieldButton($caption,$visibleHover=true){ |
|
| 64 | - $bt= new HtmlButton($this->cleanIdentifier($caption),$caption); |
|
| 65 | - if($visibleHover) |
|
| 63 | + private function getFieldButton($caption, $visibleHover=true) { |
|
| 64 | + $bt=new HtmlButton($this->cleanIdentifier($caption), $caption); |
|
| 65 | + if ($visibleHover) |
|
| 66 | 66 | $this->_visibleOver($bt); |
| 67 | 67 | return $bt; |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | - private function getFieldButtons($buttons,$visibleHover=true){ |
|
| 71 | - $bts=new HtmlButtonGroups("",$buttons); |
|
| 72 | - if($visibleHover) |
|
| 70 | + private function getFieldButtons($buttons, $visibleHover=true) { |
|
| 71 | + $bts=new HtmlButtonGroups("", $buttons); |
|
| 72 | + if ($visibleHover) |
|
| 73 | 73 | $this->_visibleOver($bts); |
| 74 | 74 | return $bts; |
| 75 | 75 | } |
@@ -83,19 +83,19 @@ discard block |
||
| 83 | 83 | * @param array $attributes associative array (<b>ajax</b> key is for ajax post) |
| 84 | 84 | * @return DataTable |
| 85 | 85 | */ |
| 86 | - public function fieldAsSubmit($index,$cssStyle=NULL,$url=NULL,$responseElement=NULL,$attributes=NULL){ |
|
| 87 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($url,$responseElement,$cssStyle,$index,$attributes){ |
|
| 88 | - $button=new HtmlButton($id,$value,$cssStyle); |
|
| 89 | - $button->postOnClick($url,"$(event.target).closest('tr').find(':input').serialize()",$responseElement,$attributes["ajax"]); |
|
| 90 | - if(!isset($attributes["visibleHover"]) || $attributes["visibleHover"]) |
|
| 86 | + public function fieldAsSubmit($index, $cssStyle=NULL, $url=NULL, $responseElement=NULL, $attributes=NULL) { |
|
| 87 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($url, $responseElement, $cssStyle, $index, $attributes){ |
|
| 88 | + $button=new HtmlButton($id, $value, $cssStyle); |
|
| 89 | + $button->postOnClick($url, "$(event.target).closest('tr').find(':input').serialize()", $responseElement, $attributes["ajax"]); |
|
| 90 | + if (!isset($attributes["visibleHover"]) || $attributes["visibleHover"]) |
|
| 91 | 91 | $this->_visibleOver($button); |
| 92 | 92 | return $button; |
| 93 | - }, $index,$attributes); |
|
| 93 | + }, $index, $attributes); |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | - protected function _visibleOver(BaseHtml $element){ |
|
| 96 | + protected function _visibleOver(BaseHtml $element) { |
|
| 97 | 97 | $this->_visibleHover=true; |
| 98 | - return $element->addToProperty("class", "visibleover")->setProperty("style","visibility:hidden;"); |
|
| 98 | + return $element->addToProperty("class", "visibleover")->setProperty("style", "visibility:hidden;"); |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | /** |
@@ -105,8 +105,8 @@ discard block |
||
| 105 | 105 | * @param boolean $visibleHover |
| 106 | 106 | * @return DataTable |
| 107 | 107 | */ |
| 108 | - public function addFieldButton($caption,$visibleHover=true,$callback=null){ |
|
| 109 | - $this->addField($this->getCallable("getFieldButton",[$caption,$visibleHover],$callback)); |
|
| 108 | + public function addFieldButton($caption, $visibleHover=true, $callback=null) { |
|
| 109 | + $this->addField($this->getCallable("getFieldButton", [$caption, $visibleHover], $callback)); |
|
| 110 | 110 | return $this; |
| 111 | 111 | } |
| 112 | 112 | |
@@ -117,8 +117,8 @@ discard block |
||
| 117 | 117 | * @param boolean $visibleHover |
| 118 | 118 | * @return DataTable |
| 119 | 119 | */ |
| 120 | - public function addFieldButtons($buttons,$visibleHover=true,$callback=null){ |
|
| 121 | - $this->addField($this->getCallable("getFieldButtons",[$buttons,$visibleHover],$callback)); |
|
| 120 | + public function addFieldButtons($buttons, $visibleHover=true, $callback=null) { |
|
| 121 | + $this->addField($this->getCallable("getFieldButtons", [$buttons, $visibleHover], $callback)); |
|
| 122 | 122 | return $this; |
| 123 | 123 | } |
| 124 | 124 | |
@@ -129,8 +129,8 @@ discard block |
||
| 129 | 129 | * @param callable $callback |
| 130 | 130 | * @return DataTable |
| 131 | 131 | */ |
| 132 | - public function insertFieldButton($index,$caption,$visibleHover=true,$callback=null){ |
|
| 133 | - $this->insertField($index, $this->getFieldButtonCallable($caption,$visibleHover,$callback)); |
|
| 132 | + public function insertFieldButton($index, $caption, $visibleHover=true, $callback=null) { |
|
| 133 | + $this->insertField($index, $this->getFieldButtonCallable($caption, $visibleHover, $callback)); |
|
| 134 | 134 | return $this; |
| 135 | 135 | } |
| 136 | 136 | |
@@ -141,25 +141,25 @@ discard block |
||
| 141 | 141 | * @param callable $callback |
| 142 | 142 | * @return DataTable |
| 143 | 143 | */ |
| 144 | - public function insertInFieldButton($index,$caption,$visibleHover=true,$callback=null){ |
|
| 145 | - $this->insertInField($index, $this->getFieldButtonCallable($caption,$visibleHover,$callback)); |
|
| 144 | + public function insertInFieldButton($index, $caption, $visibleHover=true, $callback=null) { |
|
| 145 | + $this->insertInField($index, $this->getFieldButtonCallable($caption, $visibleHover, $callback)); |
|
| 146 | 146 | return $this; |
| 147 | 147 | } |
| 148 | 148 | |
| 149 | - private function addDefaultButton($icon,$class=null,$visibleHover=true,$callback=null){ |
|
| 150 | - $this->addField($this->getCallable("getDefaultButton",[$icon,$class,$visibleHover],$callback)); |
|
| 149 | + private function addDefaultButton($icon, $class=null, $visibleHover=true, $callback=null) { |
|
| 150 | + $this->addField($this->getCallable("getDefaultButton", [$icon, $class, $visibleHover], $callback)); |
|
| 151 | 151 | return $this; |
| 152 | 152 | } |
| 153 | 153 | |
| 154 | - private function insertDefaultButtonIn($index,$icon,$class=null,$visibleHover=true,$callback=null){ |
|
| 155 | - $this->insertInField($index,$this->getCallable("getDefaultButton",[$icon,$class,$visibleHover],$callback)); |
|
| 154 | + private function insertDefaultButtonIn($index, $icon, $class=null, $visibleHover=true, $callback=null) { |
|
| 155 | + $this->insertInField($index, $this->getCallable("getDefaultButton", [$icon, $class, $visibleHover], $callback)); |
|
| 156 | 156 | return $this; |
| 157 | 157 | } |
| 158 | 158 | |
| 159 | - private function getDefaultButton($icon,$class=null,$visibleHover=true){ |
|
| 160 | - $bt=$this->getFieldButton("",$visibleHover); |
|
| 159 | + private function getDefaultButton($icon, $class=null, $visibleHover=true) { |
|
| 160 | + $bt=$this->getFieldButton("", $visibleHover); |
|
| 161 | 161 | $bt->asIcon($icon); |
| 162 | - if(isset($class)) |
|
| 162 | + if (isset($class)) |
|
| 163 | 163 | $bt->addClass($class); |
| 164 | 164 | return $bt; |
| 165 | 165 | } |
@@ -171,9 +171,9 @@ discard block |
||
| 171 | 171 | * @param callable $callback this function takes the following arguments : $object=>the delete button, $instance : the active instance of the object |
| 172 | 172 | * @return DataTable |
| 173 | 173 | */ |
| 174 | - public function addDeleteButton($visibleHover=true,$deleteBehavior=[],$callback=null){ |
|
| 174 | + public function addDeleteButton($visibleHover=true, $deleteBehavior=[], $callback=null) { |
|
| 175 | 175 | $this->_deleteBehavior=$deleteBehavior; |
| 176 | - return $this->addDefaultButton("remove","_delete red basic",$visibleHover,$callback); |
|
| 176 | + return $this->addDefaultButton("remove", "_delete red basic", $visibleHover, $callback); |
|
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 179 | /** |
@@ -183,9 +183,9 @@ discard block |
||
| 183 | 183 | * @param callable $callback this function takes the following arguments : $object=>the delete button, $instance : the active instance of the object |
| 184 | 184 | * @return DataTable |
| 185 | 185 | */ |
| 186 | - public function addEditButton($visibleHover=true,$editBehavior=[],$callback=null){ |
|
| 186 | + public function addEditButton($visibleHover=true, $editBehavior=[], $callback=null) { |
|
| 187 | 187 | $this->_editBehavior=$editBehavior; |
| 188 | - return $this->addDefaultButton("edit","_edit basic",$visibleHover,$callback); |
|
| 188 | + return $this->addDefaultButton("edit", "_edit basic", $visibleHover, $callback); |
|
| 189 | 189 | } |
| 190 | 190 | |
| 191 | 191 | /** |
@@ -196,20 +196,20 @@ discard block |
||
| 196 | 196 | * @param callable $callbackDelete this function takes the following arguments : $object=>the delete button, $instance : the active instance of the object |
| 197 | 197 | * @return DataTable |
| 198 | 198 | */ |
| 199 | - public function addEditDeleteButtons($visibleHover=true,$behavior=[],$callbackEdit=null,$callbackDelete=null){ |
|
| 200 | - $this->addEditButton($visibleHover,$behavior,$callbackEdit); |
|
| 199 | + public function addEditDeleteButtons($visibleHover=true, $behavior=[], $callbackEdit=null, $callbackDelete=null) { |
|
| 200 | + $this->addEditButton($visibleHover, $behavior, $callbackEdit); |
|
| 201 | 201 | $index=$this->_instanceViewer->visiblePropertiesCount()-1; |
| 202 | - $this->insertDeleteButtonIn($index,$visibleHover,$behavior,$callbackDelete); |
|
| 202 | + $this->insertDeleteButtonIn($index, $visibleHover, $behavior, $callbackDelete); |
|
| 203 | 203 | return $this; |
| 204 | 204 | } |
| 205 | 205 | |
| 206 | - public function insertDeleteButtonIn($index,$visibleHover=true,$deleteBehavior=[],$callback=null){ |
|
| 206 | + public function insertDeleteButtonIn($index, $visibleHover=true, $deleteBehavior=[], $callback=null) { |
|
| 207 | 207 | $this->_deleteBehavior=$deleteBehavior; |
| 208 | - return $this->insertDefaultButtonIn($index,"remove","_delete red basic",$visibleHover,$callback); |
|
| 208 | + return $this->insertDefaultButtonIn($index, "remove", "_delete red basic", $visibleHover, $callback); |
|
| 209 | 209 | } |
| 210 | 210 | |
| 211 | - public function insertEditButtonIn($index,$visibleHover=true,$editBehavior=[],$callback=null){ |
|
| 211 | + public function insertEditButtonIn($index, $visibleHover=true, $editBehavior=[], $callback=null) { |
|
| 212 | 212 | $this->_editBehavior=$editBehavior; |
| 213 | - return $this->insertDefaultButtonIn($index,"edit","_edit basic",$visibleHover,$callback); |
|
| 213 | + return $this->insertDefaultButtonIn($index, "edit", "_edit basic", $visibleHover, $callback); |
|
| 214 | 214 | } |
| 215 | 215 | } |
@@ -62,15 +62,17 @@ discard block |
||
| 62 | 62 | */ |
| 63 | 63 | private function getFieldButton($caption,$visibleHover=true){ |
| 64 | 64 | $bt= new HtmlButton($this->cleanIdentifier($caption),$caption); |
| 65 | - if($visibleHover) |
|
| 66 | - $this->_visibleOver($bt); |
|
| 65 | + if($visibleHover) { |
|
| 66 | + $this->_visibleOver($bt); |
|
| 67 | + } |
|
| 67 | 68 | return $bt; |
| 68 | 69 | } |
| 69 | 70 | |
| 70 | 71 | private function getFieldButtons($buttons,$visibleHover=true){ |
| 71 | 72 | $bts=new HtmlButtonGroups("",$buttons); |
| 72 | - if($visibleHover) |
|
| 73 | - $this->_visibleOver($bts); |
|
| 73 | + if($visibleHover) { |
|
| 74 | + $this->_visibleOver($bts); |
|
| 75 | + } |
|
| 74 | 76 | return $bts; |
| 75 | 77 | } |
| 76 | 78 | |
@@ -87,8 +89,9 @@ discard block |
||
| 87 | 89 | return $this->_fieldAs(function($id,$name,$value,$caption) use ($url,$responseElement,$cssStyle,$index,$attributes){ |
| 88 | 90 | $button=new HtmlButton($id,$value,$cssStyle); |
| 89 | 91 | $button->postOnClick($url,"$(event.target).closest('tr').find(':input').serialize()",$responseElement,$attributes["ajax"]); |
| 90 | - if(!isset($attributes["visibleHover"]) || $attributes["visibleHover"]) |
|
| 91 | - $this->_visibleOver($button); |
|
| 92 | + if(!isset($attributes["visibleHover"]) || $attributes["visibleHover"]) { |
|
| 93 | + $this->_visibleOver($button); |
|
| 94 | + } |
|
| 92 | 95 | return $button; |
| 93 | 96 | }, $index,$attributes); |
| 94 | 97 | } |
@@ -159,8 +162,9 @@ discard block |
||
| 159 | 162 | private function getDefaultButton($icon,$class=null,$visibleHover=true){ |
| 160 | 163 | $bt=$this->getFieldButton("",$visibleHover); |
| 161 | 164 | $bt->asIcon($icon); |
| 162 | - if(isset($class)) |
|
| 163 | - $bt->addClass($class); |
|
| 165 | + if(isset($class)) { |
|
| 166 | + $bt->addClass($class); |
|
| 167 | + } |
|
| 164 | 168 | return $bt; |
| 165 | 169 | } |
| 166 | 170 | |
@@ -58,10 +58,12 @@ discard block |
||
| 58 | 58 | $js->execOn("mouseover", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'visible');",["preventDefault"=>false,"stopPropagation"=>true]); |
| 59 | 59 | $js->execOn("mouseout", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'hidden');",["preventDefault"=>false,"stopPropagation"=>true]); |
| 60 | 60 | } |
| 61 | - if(\is_array($this->_deleteBehavior)) |
|
| 62 | - $this->_generateBehavior("delete",$this->_deleteBehavior, $js); |
|
| 63 | - if(\is_array($this->_editBehavior)) |
|
| 64 | - $this->_generateBehavior("edit",$this->_editBehavior,$js); |
|
| 61 | + if(\is_array($this->_deleteBehavior)) { |
|
| 62 | + $this->_generateBehavior("delete",$this->_deleteBehavior, $js); |
|
| 63 | + } |
|
| 64 | + if(\is_array($this->_editBehavior)) { |
|
| 65 | + $this->_generateBehavior("edit",$this->_editBehavior,$js); |
|
| 66 | + } |
|
| 65 | 67 | return parent::run($js); |
| 66 | 68 | } |
| 67 | 69 | |
@@ -94,8 +96,9 @@ discard block |
||
| 94 | 96 | $table->setRowCount(0, \sizeof($captions)); |
| 95 | 97 | $this->_generateHeader($table,$captions); |
| 96 | 98 | |
| 97 | - if(isset($this->_compileParts)) |
|
| 98 | - $table->setCompileParts($this->_compileParts); |
|
| 99 | + if(isset($this->_compileParts)) { |
|
| 100 | + $table->setCompileParts($this->_compileParts); |
|
| 101 | + } |
|
| 99 | 102 | |
| 100 | 103 | $this->_generateContent($table); |
| 101 | 104 | |
@@ -126,8 +129,9 @@ discard block |
||
| 126 | 129 | } |
| 127 | 130 | |
| 128 | 131 | protected function _applyStyleAttributes($table){ |
| 129 | - if(isset($this->_hiddenColumns)) |
|
| 130 | - $this->_hideColumns(); |
|
| 132 | + if(isset($this->_hiddenColumns)) { |
|
| 133 | + $this->_hideColumns(); |
|
| 134 | + } |
|
| 131 | 135 | if(isset($this->_colWidths)){ |
| 132 | 136 | foreach ($this->_colWidths as $colIndex=>$width){ |
| 133 | 137 | $table->setColWidth($colIndex,$width); |
@@ -180,8 +184,9 @@ discard block |
||
| 180 | 184 | $field=$ck->getField(); |
| 181 | 185 | $field->setProperty("value",$dataAjax); |
| 182 | 186 | $field->setProperty("name", "selection[]"); |
| 183 | - if(isset($checkedClass)) |
|
| 184 | - $field->setClass($checkedClass); |
|
| 187 | + if(isset($checkedClass)) { |
|
| 188 | + $field->setClass($checkedClass); |
|
| 189 | + } |
|
| 185 | 190 | \array_unshift($values, $ck); |
| 186 | 191 | } |
| 187 | 192 | $result=$table->newRow(); |
@@ -194,8 +199,9 @@ discard block |
||
| 194 | 199 | |
| 195 | 200 | protected function _generatePagination($table,$js=NULL){ |
| 196 | 201 | if(isset($this->_toolbar)){ |
| 197 | - if($this->_toolbarPosition==PositionInTable::FOOTER) |
|
| 198 | - $this->_toolbar->setFloated("left"); |
|
| 202 | + if($this->_toolbarPosition==PositionInTable::FOOTER) { |
|
| 203 | + $this->_toolbar->setFloated("left"); |
|
| 204 | + } |
|
| 199 | 205 | } |
| 200 | 206 | $footer=$table->getFooter(); |
| 201 | 207 | $footer->mergeCol(); |
@@ -214,8 +220,9 @@ discard block |
||
| 214 | 220 | |
| 215 | 221 | protected function _getFieldName($index){ |
| 216 | 222 | $fieldName=parent::_getFieldName($index); |
| 217 | - if(\is_object($fieldName)) |
|
| 218 | - $fieldName="field-".$index; |
|
| 223 | + if(\is_object($fieldName)) { |
|
| 224 | + $fieldName="field-".$index; |
|
| 225 | + } |
|
| 219 | 226 | return $fieldName."[]"; |
| 220 | 227 | } |
| 221 | 228 | |
@@ -255,7 +262,7 @@ discard block |
||
| 255 | 262 | $hasPart=$table->hasPart($part); |
| 256 | 263 | if($hasPart){ |
| 257 | 264 | $row=$table->getPart($part)->addRow(\sizeof($captions)); |
| 258 | - }else{ |
|
| 265 | + } else{ |
|
| 259 | 266 | $row=$table->getPart($part)->getRow(0); |
| 260 | 267 | } |
| 261 | 268 | $row->mergeCol(); |
@@ -286,7 +293,7 @@ discard block |
||
| 286 | 293 | $this->_urls["refresh"]=JArray::getValue($urls, "refresh",0); |
| 287 | 294 | $this->_urls["edit"]=JArray::getValue($urls, "edit",1); |
| 288 | 295 | $this->_urls["delete"]=JArray::getValue($urls, "delete",2); |
| 289 | - }else{ |
|
| 296 | + } else{ |
|
| 290 | 297 | $this->_urls=["refresh"=>$urls,"edit"=>$urls,"delete"=>$urls]; |
| 291 | 298 | } |
| 292 | 299 | return $this; |
@@ -369,8 +376,9 @@ discard block |
||
| 369 | 376 | |
| 370 | 377 | protected function getTargetSelector($op) { |
| 371 | 378 | $result=$this->_targetSelector; |
| 372 | - if(!isset($result[$op])) |
|
| 373 | - $result="#".$this->identifier; |
|
| 379 | + if(!isset($result[$op])) { |
|
| 380 | + $result="#".$this->identifier; |
|
| 381 | + } |
|
| 374 | 382 | return $result[$op]; |
| 375 | 383 | } |
| 376 | 384 | |
@@ -388,8 +396,9 @@ discard block |
||
| 388 | 396 | } |
| 389 | 397 | |
| 390 | 398 | public function getRefreshSelector() { |
| 391 | - if(isset($this->_refreshSelector)) |
|
| 392 | - return $this->_refreshSelector; |
|
| 399 | + if(isset($this->_refreshSelector)) { |
|
| 400 | + return $this->_refreshSelector; |
|
| 401 | + } |
|
| 393 | 402 | return "#".$this->identifier." tbody"; |
| 394 | 403 | } |
| 395 | 404 | |
@@ -408,8 +417,9 @@ discard block |
||
| 408 | 417 | */ |
| 409 | 418 | public function show($modelInstance){ |
| 410 | 419 | if(\is_array($modelInstance)){ |
| 411 | - if(isset($modelInstance[0]) && \is_array(array_values($modelInstance)[0])) |
|
| 412 | - $modelInstance=\json_decode(\json_encode($modelInstance), FALSE); |
|
| 420 | + if(isset($modelInstance[0]) && \is_array(array_values($modelInstance)[0])) { |
|
| 421 | + $modelInstance=\json_decode(\json_encode($modelInstance), FALSE); |
|
| 422 | + } |
|
| 413 | 423 | } |
| 414 | 424 | $this->_modelInstance=$modelInstance; |
| 415 | 425 | } |
@@ -449,8 +459,9 @@ discard block |
||
| 449 | 459 | } |
| 450 | 460 | |
| 451 | 461 | public function hideColumn($colIndex){ |
| 452 | - if(!\is_array($this->_hiddenColumns)) |
|
| 453 | - $this->_hiddenColumns=[]; |
|
| 462 | + if(!\is_array($this->_hiddenColumns)) { |
|
| 463 | + $this->_hiddenColumns=[]; |
|
| 464 | + } |
|
| 454 | 465 | $this->_hiddenColumns[]=$colIndex; |
| 455 | 466 | return $this; |
| 456 | 467 | } |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | * |
| 25 | 25 | */ |
| 26 | 26 | class DataTable extends Widget { |
| 27 | - use TableTrait,DataTableFieldAsTrait,HasCheckboxesTrait,BaseTrait; |
|
| 27 | + use TableTrait, DataTableFieldAsTrait, HasCheckboxesTrait, BaseTrait; |
|
| 28 | 28 | protected $_searchField; |
| 29 | 29 | protected $_urls; |
| 30 | 30 | protected $_pagination; |
@@ -42,35 +42,35 @@ discard block |
||
| 42 | 42 | protected $_colWidths; |
| 43 | 43 | |
| 44 | 44 | |
| 45 | - public function __construct($identifier,$model,$modelInstance=NULL) { |
|
| 46 | - parent::__construct($identifier, $model,$modelInstance); |
|
| 47 | - $this->_init(new InstanceViewer($identifier), "table", new HtmlTable($identifier, 0,0), false); |
|
| 45 | + public function __construct($identifier, $model, $modelInstance=NULL) { |
|
| 46 | + parent::__construct($identifier, $model, $modelInstance); |
|
| 47 | + $this->_init(new InstanceViewer($identifier), "table", new HtmlTable($identifier, 0, 0), false); |
|
| 48 | 48 | $this->_urls=[]; |
| 49 | - $this->_emptyMessage=new HtmlMessage("","nothing to display"); |
|
| 49 | + $this->_emptyMessage=new HtmlMessage("", "nothing to display"); |
|
| 50 | 50 | $this->_emptyMessage->setIcon("info circle"); |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | - public function run(JsUtils $js){ |
|
| 54 | - if($this->_hasCheckboxes && isset($js)){ |
|
| 53 | + public function run(JsUtils $js) { |
|
| 54 | + if ($this->_hasCheckboxes && isset($js)) { |
|
| 55 | 55 | $this->_runCheckboxes($js); |
| 56 | 56 | } |
| 57 | - if($this->_visibleHover){ |
|
| 58 | - $js->execOn("mouseover", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'visible');",["preventDefault"=>false,"stopPropagation"=>true]); |
|
| 59 | - $js->execOn("mouseout", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'hidden');",["preventDefault"=>false,"stopPropagation"=>true]); |
|
| 57 | + if ($this->_visibleHover) { |
|
| 58 | + $js->execOn("mouseover", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'visible');", ["preventDefault"=>false, "stopPropagation"=>true]); |
|
| 59 | + $js->execOn("mouseout", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'hidden');", ["preventDefault"=>false, "stopPropagation"=>true]); |
|
| 60 | 60 | } |
| 61 | - if(\is_array($this->_deleteBehavior)) |
|
| 62 | - $this->_generateBehavior("delete",$this->_deleteBehavior, $js); |
|
| 63 | - if(\is_array($this->_editBehavior)) |
|
| 64 | - $this->_generateBehavior("edit",$this->_editBehavior,$js); |
|
| 61 | + if (\is_array($this->_deleteBehavior)) |
|
| 62 | + $this->_generateBehavior("delete", $this->_deleteBehavior, $js); |
|
| 63 | + if (\is_array($this->_editBehavior)) |
|
| 64 | + $this->_generateBehavior("edit", $this->_editBehavior, $js); |
|
| 65 | 65 | return parent::run($js); |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | |
| 69 | 69 | |
| 70 | - protected function _generateBehavior($op,$params,JsUtils $js){ |
|
| 71 | - if(isset($this->_urls[$op])){ |
|
| 72 | - $params=\array_merge($params,["attr"=>"data-ajax"]); |
|
| 73 | - $js->ajaxOnClick("#".$this->identifier." ._".$op, $this->_urls[$op],$this->getTargetSelector($op),$params); |
|
| 70 | + protected function _generateBehavior($op, $params, JsUtils $js) { |
|
| 71 | + if (isset($this->_urls[$op])) { |
|
| 72 | + $params=\array_merge($params, ["attr"=>"data-ajax"]); |
|
| 73 | + $js->ajaxOnClick("#".$this->identifier." ._".$op, $this->_urls[$op], $this->getTargetSelector($op), $params); |
|
| 74 | 74 | } |
| 75 | 75 | } |
| 76 | 76 | |
@@ -83,164 +83,164 @@ discard block |
||
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | |
| 86 | - public function compile(JsUtils $js=NULL,&$view=NULL){ |
|
| 87 | - if(!$this->_generated){ |
|
| 86 | + public function compile(JsUtils $js=NULL, &$view=NULL) { |
|
| 87 | + if (!$this->_generated) { |
|
| 88 | 88 | $this->_instanceViewer->setInstance($this->_model); |
| 89 | 89 | $captions=$this->_instanceViewer->getCaptions(); |
| 90 | 90 | $table=$this->content["table"]; |
| 91 | - if($this->_hasCheckboxes){ |
|
| 91 | + if ($this->_hasCheckboxes) { |
|
| 92 | 92 | $this->_generateMainCheckbox($captions); |
| 93 | 93 | } |
| 94 | 94 | $table->setRowCount(0, \sizeof($captions)); |
| 95 | - $this->_generateHeader($table,$captions); |
|
| 95 | + $this->_generateHeader($table, $captions); |
|
| 96 | 96 | |
| 97 | - if(isset($this->_compileParts)) |
|
| 97 | + if (isset($this->_compileParts)) |
|
| 98 | 98 | $table->setCompileParts($this->_compileParts); |
| 99 | 99 | |
| 100 | 100 | $this->_generateContent($table); |
| 101 | 101 | |
| 102 | - $this->compileExtraElements($table, $captions,$js); |
|
| 102 | + $this->compileExtraElements($table, $captions, $js); |
|
| 103 | 103 | |
| 104 | - $this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE,"table",PositionInTable::AFTERTABLE]); |
|
| 104 | + $this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE, "table", PositionInTable::AFTERTABLE]); |
|
| 105 | 105 | $this->_compileForm(); |
| 106 | 106 | $this->_applyStyleAttributes($table); |
| 107 | 107 | $this->_generated=true; |
| 108 | 108 | } |
| 109 | - return parent::compile($js,$view); |
|
| 109 | + return parent::compile($js, $view); |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | - protected function compileExtraElements($table,$captions,JsUtils $js=NULL){ |
|
| 113 | - if(isset($this->_searchField) && isset($js) && isset($this->_urls["refresh"])){ |
|
| 114 | - $this->_searchField->postOn("change", $this->_urls["refresh"],"{'s':$(this).val()}","#".$this->identifier." tbody",["preventDefault"=>false,"jqueryDone"=>"replaceWith"]); |
|
| 112 | + protected function compileExtraElements($table, $captions, JsUtils $js=NULL) { |
|
| 113 | + if (isset($this->_searchField) && isset($js) && isset($this->_urls["refresh"])) { |
|
| 114 | + $this->_searchField->postOn("change", $this->_urls["refresh"], "{'s':$(this).val()}", "#".$this->identifier." tbody", ["preventDefault"=>false, "jqueryDone"=>"replaceWith"]); |
|
| 115 | 115 | } |
| 116 | - if($this->_hasCheckboxes && $table->hasPart("thead")){ |
|
| 116 | + if ($this->_hasCheckboxes && $table->hasPart("thead")) { |
|
| 117 | 117 | $table->getHeader()->getCell(0, 0)->addClass("no-sort"); |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | - if(isset($this->_toolbar)){ |
|
| 120 | + if (isset($this->_toolbar)) { |
|
| 121 | 121 | $this->_setToolbarPosition($table, $captions); |
| 122 | 122 | } |
| 123 | - if(isset($this->_pagination) && $this->_pagination->getVisible()){ |
|
| 124 | - $this->_generatePagination($table,$js); |
|
| 123 | + if (isset($this->_pagination) && $this->_pagination->getVisible()) { |
|
| 124 | + $this->_generatePagination($table, $js); |
|
| 125 | 125 | } |
| 126 | 126 | } |
| 127 | 127 | |
| 128 | - protected function _applyStyleAttributes($table){ |
|
| 129 | - if(isset($this->_hiddenColumns)) |
|
| 128 | + protected function _applyStyleAttributes($table) { |
|
| 129 | + if (isset($this->_hiddenColumns)) |
|
| 130 | 130 | $this->_hideColumns(); |
| 131 | - if(isset($this->_colWidths)){ |
|
| 132 | - foreach ($this->_colWidths as $colIndex=>$width){ |
|
| 133 | - $table->setColWidth($colIndex,$width); |
|
| 131 | + if (isset($this->_colWidths)) { |
|
| 132 | + foreach ($this->_colWidths as $colIndex=>$width) { |
|
| 133 | + $table->setColWidth($colIndex, $width); |
|
| 134 | 134 | } |
| 135 | 135 | } |
| 136 | 136 | } |
| 137 | 137 | |
| 138 | - protected function _hideColumns(){ |
|
| 139 | - foreach ($this->_hiddenColumns as $colIndex){ |
|
| 138 | + protected function _hideColumns() { |
|
| 139 | + foreach ($this->_hiddenColumns as $colIndex) { |
|
| 140 | 140 | $this->_self->hideColumn($colIndex); |
| 141 | 141 | } |
| 142 | 142 | return $this; |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | - protected function _generateHeader(HtmlTable $table,$captions){ |
|
| 145 | + protected function _generateHeader(HtmlTable $table, $captions) { |
|
| 146 | 146 | $table->setHeaderValues($captions); |
| 147 | - if(isset($this->_sortable)){ |
|
| 147 | + if (isset($this->_sortable)) { |
|
| 148 | 148 | $table->setSortable($this->_sortable); |
| 149 | 149 | } |
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | |
| 153 | 153 | |
| 154 | - protected function _generateContent($table){ |
|
| 154 | + protected function _generateContent($table) { |
|
| 155 | 155 | $objects=$this->_modelInstance; |
| 156 | - if(isset($this->_pagination)){ |
|
| 156 | + if (isset($this->_pagination)) { |
|
| 157 | 157 | $objects=$this->_pagination->getObjects($this->_modelInstance); |
| 158 | 158 | } |
| 159 | 159 | InstanceViewer::setIndex(0); |
| 160 | 160 | $table->fromDatabaseObjects($objects, function($instance) use($table){ |
| 161 | 161 | return $this->_generateRow($instance, $table); |
| 162 | 162 | }); |
| 163 | - if($table->getRowCount()==0){ |
|
| 163 | + if ($table->getRowCount()==0) { |
|
| 164 | 164 | $result=$table->addRow(); |
| 165 | 165 | $result->mergeRow(); |
| 166 | 166 | $result->setValues([$this->_emptyMessage]); |
| 167 | 167 | } |
| 168 | 168 | } |
| 169 | 169 | |
| 170 | - protected function _generateRow($instance,&$table,$checkedClass=null){ |
|
| 170 | + protected function _generateRow($instance, &$table, $checkedClass=null) { |
|
| 171 | 171 | $this->_instanceViewer->setInstance($instance); |
| 172 | 172 | InstanceViewer::$index++; |
| 173 | - $values= $this->_instanceViewer->getValues(); |
|
| 173 | + $values=$this->_instanceViewer->getValues(); |
|
| 174 | 174 | $id=$this->_instanceViewer->getIdentifier(); |
| 175 | 175 | $dataAjax=$id; |
| 176 | 176 | $id=$this->cleanIdentifier($id); |
| 177 | - if($this->_hasCheckboxes){ |
|
| 178 | - $ck=new HtmlCheckbox("ck-".$this->identifier."-".$id,""); |
|
| 177 | + if ($this->_hasCheckboxes) { |
|
| 178 | + $ck=new HtmlCheckbox("ck-".$this->identifier."-".$id, ""); |
|
| 179 | 179 | $checked=false; |
| 180 | - if(isset($this->_checkedCallback)){ |
|
| 180 | + if (isset($this->_checkedCallback)) { |
|
| 181 | 181 | $func=$this->_checkedCallback; |
| 182 | 182 | $checked=$func($instance); |
| 183 | 183 | } |
| 184 | 184 | $ck->setChecked($checked); |
| 185 | 185 | $ck->setOnChange("event.stopPropagation();"); |
| 186 | 186 | $field=$ck->getField(); |
| 187 | - $field->setProperty("value",$dataAjax); |
|
| 187 | + $field->setProperty("value", $dataAjax); |
|
| 188 | 188 | $field->setProperty("name", "selection[]"); |
| 189 | - if(isset($checkedClass)) |
|
| 189 | + if (isset($checkedClass)) |
|
| 190 | 190 | $field->setClass($checkedClass); |
| 191 | 191 | \array_unshift($values, $ck); |
| 192 | 192 | } |
| 193 | 193 | $result=$table->newRow(); |
| 194 | 194 | $result->setIdentifier($this->identifier."-tr-".$id); |
| 195 | - $result->setProperty("data-ajax",$dataAjax); |
|
| 195 | + $result->setProperty("data-ajax", $dataAjax); |
|
| 196 | 196 | $result->setValues($values); |
| 197 | - $result->addToProperty("class",$this->_rowClass); |
|
| 197 | + $result->addToProperty("class", $this->_rowClass); |
|
| 198 | 198 | return $result; |
| 199 | 199 | } |
| 200 | 200 | |
| 201 | - protected function _generatePagination($table,$js=NULL){ |
|
| 202 | - if(isset($this->_toolbar)){ |
|
| 203 | - if($this->_toolbarPosition==PositionInTable::FOOTER) |
|
| 201 | + protected function _generatePagination($table, $js=NULL) { |
|
| 202 | + if (isset($this->_toolbar)) { |
|
| 203 | + if ($this->_toolbarPosition==PositionInTable::FOOTER) |
|
| 204 | 204 | $this->_toolbar->setFloated("left"); |
| 205 | 205 | } |
| 206 | 206 | $footer=$table->getFooter(); |
| 207 | 207 | $footer->mergeCol(); |
| 208 | - $menu=new HtmlPaginationMenu("pagination-".$this->identifier,$this->_pagination->getPagesNumbers()); |
|
| 208 | + $menu=new HtmlPaginationMenu("pagination-".$this->identifier, $this->_pagination->getPagesNumbers()); |
|
| 209 | 209 | $menu->floatRight(); |
| 210 | 210 | $menu->setActiveItem($this->_pagination->getPage()-1); |
| 211 | 211 | $footer->addValues($menu); |
| 212 | - $this->_associatePaginationBehavior($menu,$js); |
|
| 212 | + $this->_associatePaginationBehavior($menu, $js); |
|
| 213 | 213 | } |
| 214 | 214 | |
| 215 | - protected function _associatePaginationBehavior(HtmlMenu $menu,JsUtils $js=NULL){ |
|
| 216 | - if(isset($this->_urls["refresh"])){ |
|
| 217 | - $menu->postOnClick($this->_urls["refresh"],"{'p':$(this).attr('data-page')}",$this->getRefreshSelector(),["preventDefault"=>false,"jqueryDone"=>"replaceWith","hasLoader"=>false]); |
|
| 215 | + protected function _associatePaginationBehavior(HtmlMenu $menu, JsUtils $js=NULL) { |
|
| 216 | + if (isset($this->_urls["refresh"])) { |
|
| 217 | + $menu->postOnClick($this->_urls["refresh"], "{'p':$(this).attr('data-page')}", $this->getRefreshSelector(), ["preventDefault"=>false, "jqueryDone"=>"replaceWith", "hasLoader"=>false]); |
|
| 218 | 218 | } |
| 219 | 219 | } |
| 220 | 220 | |
| 221 | - protected function _getFieldName($index){ |
|
| 221 | + protected function _getFieldName($index) { |
|
| 222 | 222 | $fieldName=parent::_getFieldName($index); |
| 223 | - if(\is_object($fieldName)) |
|
| 223 | + if (\is_object($fieldName)) |
|
| 224 | 224 | $fieldName="field-".$index; |
| 225 | 225 | return $fieldName."[]"; |
| 226 | 226 | } |
| 227 | 227 | |
| 228 | - protected function _getFieldCaption($index){ |
|
| 228 | + protected function _getFieldCaption($index) { |
|
| 229 | 229 | return null; |
| 230 | 230 | } |
| 231 | 231 | |
| 232 | - protected function _setToolbarPosition($table,$captions=NULL){ |
|
| 233 | - switch ($this->_toolbarPosition){ |
|
| 232 | + protected function _setToolbarPosition($table, $captions=NULL) { |
|
| 233 | + switch ($this->_toolbarPosition) { |
|
| 234 | 234 | case PositionInTable::BEFORETABLE: |
| 235 | 235 | case PositionInTable::AFTERTABLE: |
| 236 | - if(isset($this->_compileParts)===false){ |
|
| 236 | + if (isset($this->_compileParts)===false) { |
|
| 237 | 237 | $this->content[$this->_toolbarPosition]=$this->_toolbar; |
| 238 | 238 | } |
| 239 | 239 | break; |
| 240 | 240 | case PositionInTable::HEADER: |
| 241 | 241 | case PositionInTable::FOOTER: |
| 242 | 242 | case PositionInTable::BODY: |
| 243 | - $this->addToolbarRow($this->_toolbarPosition,$table, $captions); |
|
| 243 | + $this->addToolbarRow($this->_toolbarPosition, $table, $captions); |
|
| 244 | 244 | break; |
| 245 | 245 | } |
| 246 | 246 | } |
@@ -252,16 +252,16 @@ discard block |
||
| 252 | 252 | * @param callable $callback function called after the field compilation |
| 253 | 253 | * @return DataTable |
| 254 | 254 | */ |
| 255 | - public function afterCompile($index,$callback){ |
|
| 256 | - $this->_instanceViewer->afterCompile($index,$callback); |
|
| 255 | + public function afterCompile($index, $callback) { |
|
| 256 | + $this->_instanceViewer->afterCompile($index, $callback); |
|
| 257 | 257 | return $this; |
| 258 | 258 | } |
| 259 | 259 | |
| 260 | - private function addToolbarRow($part,$table,$captions){ |
|
| 260 | + private function addToolbarRow($part, $table, $captions) { |
|
| 261 | 261 | $hasPart=$table->hasPart($part); |
| 262 | - if($hasPart){ |
|
| 262 | + if ($hasPart) { |
|
| 263 | 263 | $row=$table->getPart($part)->addRow(\sizeof($captions)); |
| 264 | - }else{ |
|
| 264 | + } else { |
|
| 265 | 265 | $row=$table->getPart($part)->getRow(0); |
| 266 | 266 | } |
| 267 | 267 | $row->mergeCol(); |
@@ -273,7 +273,7 @@ discard block |
||
| 273 | 273 | * @see Widget::getHtmlComponent() |
| 274 | 274 | * @return HtmlTable |
| 275 | 275 | */ |
| 276 | - public function getHtmlComponent(){ |
|
| 276 | + public function getHtmlComponent() { |
|
| 277 | 277 | return $this->content["table"]; |
| 278 | 278 | } |
| 279 | 279 | |
@@ -288,12 +288,12 @@ discard block |
||
| 288 | 288 | * @return DataTable |
| 289 | 289 | */ |
| 290 | 290 | public function setUrls($urls) { |
| 291 | - if(\is_array($urls)){ |
|
| 292 | - $this->_urls["refresh"]=JArray::getValue($urls, "refresh",0); |
|
| 293 | - $this->_urls["edit"]=JArray::getValue($urls, "edit",1); |
|
| 294 | - $this->_urls["delete"]=JArray::getValue($urls, "delete",2); |
|
| 295 | - }else{ |
|
| 296 | - $this->_urls=["refresh"=>$urls,"edit"=>$urls,"delete"=>$urls]; |
|
| 291 | + if (\is_array($urls)) { |
|
| 292 | + $this->_urls["refresh"]=JArray::getValue($urls, "refresh", 0); |
|
| 293 | + $this->_urls["edit"]=JArray::getValue($urls, "edit", 1); |
|
| 294 | + $this->_urls["delete"]=JArray::getValue($urls, "delete", 2); |
|
| 295 | + } else { |
|
| 296 | + $this->_urls=["refresh"=>$urls, "edit"=>$urls, "delete"=>$urls]; |
|
| 297 | 297 | } |
| 298 | 298 | return $this; |
| 299 | 299 | } |
@@ -306,8 +306,8 @@ discard block |
||
| 306 | 306 | * @param number $pages_visibles The number of visible pages in the Pagination component |
| 307 | 307 | * @return DataTable |
| 308 | 308 | */ |
| 309 | - public function paginate($page,$total_rowcount,$items_per_page=10,$pages_visibles=null){ |
|
| 310 | - $this->_pagination=new Pagination($items_per_page,$pages_visibles,$page,$total_rowcount); |
|
| 309 | + public function paginate($page, $total_rowcount, $items_per_page=10, $pages_visibles=null) { |
|
| 310 | + $this->_pagination=new Pagination($items_per_page, $pages_visibles, $page, $total_rowcount); |
|
| 311 | 311 | return $this; |
| 312 | 312 | } |
| 313 | 313 | |
@@ -318,8 +318,8 @@ discard block |
||
| 318 | 318 | * @param number $pages_visibles The number of visible pages in the Pagination component |
| 319 | 319 | * @return DataTable |
| 320 | 320 | */ |
| 321 | - public function autoPaginate($page=1,$items_per_page=10,$pages_visibles=4){ |
|
| 322 | - $this->_pagination=new Pagination($items_per_page,$pages_visibles,$page); |
|
| 321 | + public function autoPaginate($page=1, $items_per_page=10, $pages_visibles=4) { |
|
| 322 | + $this->_pagination=new Pagination($items_per_page, $pages_visibles, $page); |
|
| 323 | 323 | return $this; |
| 324 | 324 | } |
| 325 | 325 | |
@@ -329,7 +329,7 @@ discard block |
||
| 329 | 329 | * @param array $compileParts |
| 330 | 330 | * @return DataTable |
| 331 | 331 | */ |
| 332 | - public function refresh($compileParts=["tbody"]){ |
|
| 332 | + public function refresh($compileParts=["tbody"]) { |
|
| 333 | 333 | $this->_compileParts=$compileParts; |
| 334 | 334 | return $this; |
| 335 | 335 | } |
@@ -340,14 +340,14 @@ discard block |
||
| 340 | 340 | * @param string $position |
| 341 | 341 | * @return \Ajax\common\html\HtmlDoubleElement |
| 342 | 342 | */ |
| 343 | - public function addSearchInToolbar($position=Direction::RIGHT){ |
|
| 343 | + public function addSearchInToolbar($position=Direction::RIGHT) { |
|
| 344 | 344 | return $this->addInToolbar($this->getSearchField())->setPosition($position); |
| 345 | 345 | } |
| 346 | 346 | |
| 347 | - public function getSearchField(){ |
|
| 348 | - if(isset($this->_searchField)===false){ |
|
| 349 | - $this->_searchField=new HtmlInput("search-".$this->identifier,"search","","Search..."); |
|
| 350 | - $this->_searchField->addIcon("search",Direction::RIGHT); |
|
| 347 | + public function getSearchField() { |
|
| 348 | + if (isset($this->_searchField)===false) { |
|
| 349 | + $this->_searchField=new HtmlInput("search-".$this->identifier, "search", "", "Search..."); |
|
| 350 | + $this->_searchField->addIcon("search", Direction::RIGHT); |
|
| 351 | 351 | } |
| 352 | 352 | return $this->_searchField; |
| 353 | 353 | } |
@@ -367,7 +367,7 @@ discard block |
||
| 367 | 367 | * Returns a form corresponding to the Datatable |
| 368 | 368 | * @return \Ajax\semantic\html\collections\form\HtmlForm |
| 369 | 369 | */ |
| 370 | - public function asForm(){ |
|
| 370 | + public function asForm() { |
|
| 371 | 371 | return $this->getForm(); |
| 372 | 372 | } |
| 373 | 373 | |
@@ -375,7 +375,7 @@ discard block |
||
| 375 | 375 | |
| 376 | 376 | protected function getTargetSelector($op) { |
| 377 | 377 | $result=$this->_targetSelector; |
| 378 | - if(!isset($result[$op])) |
|
| 378 | + if (!isset($result[$op])) |
|
| 379 | 379 | $result="#".$this->identifier; |
| 380 | 380 | return $result[$op]; |
| 381 | 381 | } |
@@ -386,15 +386,15 @@ discard block |
||
| 386 | 386 | * @return DataTable |
| 387 | 387 | */ |
| 388 | 388 | public function setTargetSelector($_targetSelector) { |
| 389 | - if(!\is_array($_targetSelector)){ |
|
| 390 | - $_targetSelector=["edit"=>$_targetSelector,"delete"=>$_targetSelector]; |
|
| 389 | + if (!\is_array($_targetSelector)) { |
|
| 390 | + $_targetSelector=["edit"=>$_targetSelector, "delete"=>$_targetSelector]; |
|
| 391 | 391 | } |
| 392 | 392 | $this->_targetSelector=$_targetSelector; |
| 393 | 393 | return $this; |
| 394 | 394 | } |
| 395 | 395 | |
| 396 | 396 | public function getRefreshSelector() { |
| 397 | - if(isset($this->_refreshSelector)) |
|
| 397 | + if (isset($this->_refreshSelector)) |
|
| 398 | 398 | return $this->_refreshSelector; |
| 399 | 399 | return "#".$this->identifier." tbody"; |
| 400 | 400 | } |
@@ -412,9 +412,9 @@ discard block |
||
| 412 | 412 | * {@inheritDoc} |
| 413 | 413 | * @see \Ajax\common\Widget::show() |
| 414 | 414 | */ |
| 415 | - public function show($modelInstance){ |
|
| 416 | - if(\is_array($modelInstance)){ |
|
| 417 | - if(isset($modelInstance[0]) && \is_array(array_values($modelInstance)[0])) |
|
| 415 | + public function show($modelInstance) { |
|
| 416 | + if (\is_array($modelInstance)) { |
|
| 417 | + if (isset($modelInstance[0]) && \is_array(array_values($modelInstance)[0])) |
|
| 418 | 418 | $modelInstance=\json_decode(\json_encode($modelInstance), FALSE); |
| 419 | 419 | } |
| 420 | 420 | $this->_modelInstance=$modelInstance; |
@@ -449,29 +449,29 @@ discard block |
||
| 449 | 449 | return $this; |
| 450 | 450 | } |
| 451 | 451 | |
| 452 | - public function setActiveRowSelector($class="active",$event="click",$multiple=false){ |
|
| 453 | - $this->_self->setActiveRowSelector($class,$event,$multiple); |
|
| 452 | + public function setActiveRowSelector($class="active", $event="click", $multiple=false) { |
|
| 453 | + $this->_self->setActiveRowSelector($class, $event, $multiple); |
|
| 454 | 454 | return $this; |
| 455 | 455 | } |
| 456 | 456 | |
| 457 | - public function hideColumn($colIndex){ |
|
| 458 | - if(!\is_array($this->_hiddenColumns)) |
|
| 457 | + public function hideColumn($colIndex) { |
|
| 458 | + if (!\is_array($this->_hiddenColumns)) |
|
| 459 | 459 | $this->_hiddenColumns=[]; |
| 460 | 460 | $this->_hiddenColumns[]=$colIndex; |
| 461 | 461 | return $this; |
| 462 | 462 | } |
| 463 | 463 | |
| 464 | - public function setColWidth($colIndex,$width){ |
|
| 464 | + public function setColWidth($colIndex, $width) { |
|
| 465 | 465 | $this->_colWidths[$colIndex]=$width; |
| 466 | 466 | return $this; |
| 467 | 467 | } |
| 468 | 468 | public function setColWidths($_colWidths) { |
| 469 | - $this->_colWidths = $_colWidths; |
|
| 469 | + $this->_colWidths=$_colWidths; |
|
| 470 | 470 | return $this; |
| 471 | 471 | } |
| 472 | 472 | |
| 473 | - public function setColAlignment($colIndex,$alignment){ |
|
| 474 | - $this->content["table"]->setColAlignment($colIndex,$alignment); |
|
| 473 | + public function setColAlignment($colIndex, $alignment) { |
|
| 474 | + $this->content["table"]->setColAlignment($colIndex, $alignment); |
|
| 475 | 475 | return $this; |
| 476 | 476 | } |
| 477 | 477 | } |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | $icon=JArray::getValue($value, "icon", 0); |
| 28 | 28 | $size=JArray::getValue($value, "size", 1); |
| 29 | 29 | } |
| 30 | - $iconO=new HtmlIcon("icon-" . $this->identifier, $icon); |
|
| 30 | + $iconO=new HtmlIcon("icon-".$this->identifier, $icon); |
|
| 31 | 31 | if (isset($size)) { |
| 32 | 32 | $iconO->setSize($size); |
| 33 | 33 | } |
@@ -35,15 +35,15 @@ discard block |
||
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | protected function createCondition($value) { |
| 38 | - return ($value instanceof HtmlIcon) === false; |
|
| 38 | + return ($value instanceof HtmlIcon)===false; |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | public function getIcon($index) { |
| 42 | 42 | return $this->content[$index]; |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | - public function run(JsUtils $js){ |
|
| 46 | - $result= parent::run($js); |
|
| 45 | + public function run(JsUtils $js) { |
|
| 46 | + $result=parent::run($js); |
|
| 47 | 47 | return $result->setItemSelector("i"); |
| 48 | 48 | } |
| 49 | 49 | |
@@ -52,8 +52,8 @@ discard block |
||
| 52 | 52 | return $this; |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - public static function corner($mainIcon,$cornerIcon,$size="huge"){ |
|
| 56 | - $icons=new HtmlIconGroups("icons",[$mainIcon,$cornerIcon],$size); |
|
| 55 | + public static function corner($mainIcon, $cornerIcon, $size="huge") { |
|
| 56 | + $icons=new HtmlIconGroups("icons", [$mainIcon, $cornerIcon], $size); |
|
| 57 | 57 | return $icons->toCorner(1); |
| 58 | 58 | } |
| 59 | 59 | } |
@@ -7,29 +7,29 @@ discard block |
||
| 7 | 7 | |
| 8 | 8 | class HtmlFormDropdown extends HtmlFormField { |
| 9 | 9 | |
| 10 | - public function __construct($identifier,$items=array(), $label=NULL,$value="",$multiple=false,$associative=true) { |
|
| 11 | - parent::__construct("field-".$identifier, (new HtmlDropdown("dropdown-".$identifier,$value,$items,$associative))->asSelect($identifier,$multiple), $label); |
|
| 10 | + public function __construct($identifier, $items=array(), $label=NULL, $value="", $multiple=false, $associative=true) { |
|
| 11 | + parent::__construct("field-".$identifier, (new HtmlDropdown("dropdown-".$identifier, $value, $items, $associative))->asSelect($identifier, $multiple), $label); |
|
| 12 | 12 | $this->_identifier=$identifier; |
| 13 | 13 | } |
| 14 | 14 | |
| 15 | - public function setItems($items){ |
|
| 15 | + public function setItems($items) { |
|
| 16 | 16 | return $this->getField()->setItems($items); |
| 17 | 17 | } |
| 18 | - public function addItem($item,$value=NULL,$image=NULL){ |
|
| 19 | - return $this->getField()->addItem($item,$value,$image); |
|
| 18 | + public function addItem($item, $value=NULL, $image=NULL) { |
|
| 19 | + return $this->getField()->addItem($item, $value, $image); |
|
| 20 | 20 | } |
| 21 | - public static function multipleDropdown($identifier,$items=array(), $label=NULL,$value="",$associative=true){ |
|
| 22 | - return new HtmlFormDropdown($identifier,$items,$label,$value,true,$associative); |
|
| 21 | + public static function multipleDropdown($identifier, $items=array(), $label=NULL, $value="", $associative=true) { |
|
| 22 | + return new HtmlFormDropdown($identifier, $items, $label, $value, true, $associative); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | /** |
| 26 | 26 | * @return HtmlDropdown |
| 27 | 27 | */ |
| 28 | - public function getDataField(){ |
|
| 28 | + public function getDataField() { |
|
| 29 | 29 | return $this->getField()->getInput(); |
| 30 | 30 | } |
| 31 | - public function asSelect($name=NULL,$multiple=false,$selection=true){ |
|
| 32 | - $this->getField()->asSelect($name,$multiple,$selection); |
|
| 31 | + public function asSelect($name=NULL, $multiple=false, $selection=true) { |
|
| 32 | + $this->getField()->asSelect($name, $multiple, $selection); |
|
| 33 | 33 | return $this; |
| 34 | 34 | } |
| 35 | 35 | |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | * @param boolean $floating |
| 38 | 38 | * @return HtmlDropdown |
| 39 | 39 | */ |
| 40 | - public function asButton($floating=false){ |
|
| 40 | + public function asButton($floating=false) { |
|
| 41 | 41 | $field=$this->content["field"]; |
| 42 | 42 | $label=$this->content["label"]; |
| 43 | 43 | $field->addContent($label); |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | * @version 1.001 |
| 16 | 16 | */ |
| 17 | 17 | class HtmlMessage extends HtmlSemDoubleElement { |
| 18 | - use AttachedTrait,HasTimeoutTrait; |
|
| 18 | + use AttachedTrait, HasTimeoutTrait; |
|
| 19 | 19 | protected $icon; |
| 20 | 20 | protected $close; |
| 21 | 21 | |
@@ -32,39 +32,39 @@ discard block |
||
| 32 | 32 | * @param string|HtmlSemDoubleElement $header |
| 33 | 33 | * @return \Ajax\semantic\html\collections\HtmlMessage |
| 34 | 34 | */ |
| 35 | - public function addHeader($header){ |
|
| 35 | + public function addHeader($header) { |
|
| 36 | 36 | $headerO=$header; |
| 37 | - if(\is_string($header)){ |
|
| 38 | - $headerO=new HtmlSemDoubleElement("header-".$this->identifier,"div"); |
|
| 37 | + if (\is_string($header)) { |
|
| 38 | + $headerO=new HtmlSemDoubleElement("header-".$this->identifier, "div"); |
|
| 39 | 39 | $headerO->setClass("header"); |
| 40 | 40 | $headerO->setContent($header); |
| 41 | 41 | } |
| 42 | - return $this->addContent($headerO,true); |
|
| 42 | + return $this->addContent($headerO, true); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | - public function setHeader($header){ |
|
| 45 | + public function setHeader($header) { |
|
| 46 | 46 | return $this->addHeader($header); |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | - public function setIcon($icon){ |
|
| 49 | + public function setIcon($icon) { |
|
| 50 | 50 | $this->addToProperty("class", "icon"); |
| 51 | - $this->wrapContent("<div class='content'>","</div>"); |
|
| 52 | - if(\is_string($icon)){ |
|
| 51 | + $this->wrapContent("<div class='content'>", "</div>"); |
|
| 52 | + if (\is_string($icon)) { |
|
| 53 | 53 | $this->icon=new HtmlIcon("icon-".$this->identifier, $icon); |
| 54 | - }else{ |
|
| 54 | + } else { |
|
| 55 | 55 | $this->icon=$icon; |
| 56 | 56 | } |
| 57 | 57 | return $this; |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - public function addLoader($loaderIcon="notched circle"){ |
|
| 60 | + public function addLoader($loaderIcon="notched circle") { |
|
| 61 | 61 | $this->setIcon($loaderIcon); |
| 62 | 62 | $this->icon->addToIcon("loading"); |
| 63 | 63 | return $this; |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | - public function setDismissable($dismiss=true){ |
|
| 67 | - if($dismiss===true) |
|
| 66 | + public function setDismissable($dismiss=true) { |
|
| 67 | + if ($dismiss===true) |
|
| 68 | 68 | $this->close=new HtmlIcon("close-".$this->identifier, "close"); |
| 69 | 69 | else |
| 70 | 70 | $this->close=NULL; |
@@ -75,43 +75,43 @@ discard block |
||
| 75 | 75 | * {@inheritDoc} |
| 76 | 76 | * @see \Ajax\semantic\html\base\HtmlSemDoubleElement::run() |
| 77 | 77 | */ |
| 78 | - public function run(JsUtils $js){ |
|
| 79 | - if(!isset($this->_bsComponent)){ |
|
| 80 | - if(isset($this->close)){ |
|
| 78 | + public function run(JsUtils $js) { |
|
| 79 | + if (!isset($this->_bsComponent)) { |
|
| 80 | + if (isset($this->close)) { |
|
| 81 | 81 | $js->execOn("click", "#".$this->identifier." .close", "$(this).closest('.message').transition({$this->_closeTransition})"); |
| 82 | 82 | } |
| 83 | - if(isset($this->_timeout)){ |
|
| 84 | - $js->exec("setTimeout(function() { $('#{$this->identifier}').transition({$this->_closeTransition}); }, {$this->_timeout});",true); |
|
| 83 | + if (isset($this->_timeout)) { |
|
| 84 | + $js->exec("setTimeout(function() { $('#{$this->identifier}').transition({$this->_closeTransition}); }, {$this->_timeout});", true); |
|
| 85 | 85 | } |
| 86 | 86 | } |
| 87 | 87 | return parent::run($js); |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | - public function setState($visible=true){ |
|
| 91 | - $visible=($visible===true)?"visible":"hidden"; |
|
| 92 | - return $this->addToPropertyCtrl("class", $visible, array("visible","hidden")); |
|
| 90 | + public function setState($visible=true) { |
|
| 91 | + $visible=($visible===true) ? "visible" : "hidden"; |
|
| 92 | + return $this->addToPropertyCtrl("class", $visible, array("visible", "hidden")); |
|
| 93 | 93 | } |
| 94 | 94 | |
| 95 | - public function setVariation($value="floating"){ |
|
| 96 | - return $this->addToPropertyCtrl("class", $value, array("floating","compact")); |
|
| 95 | + public function setVariation($value="floating") { |
|
| 96 | + return $this->addToPropertyCtrl("class", $value, array("floating", "compact")); |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | - public function setStyle($style){ |
|
| 99 | + public function setStyle($style) { |
|
| 100 | 100 | return $this->addToPropertyCtrl("class", $style, Style::getConstants()); |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | - public function setError(){ |
|
| 103 | + public function setError() { |
|
| 104 | 104 | return $this->setStyle("error"); |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | - public function setWarning(){ |
|
| 107 | + public function setWarning() { |
|
| 108 | 108 | return $this->setStyle("warning"); |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | - public function setMessage($message){ |
|
| 112 | - if(\is_array($this->content)){ |
|
| 111 | + public function setMessage($message) { |
|
| 112 | + if (\is_array($this->content)) { |
|
| 113 | 113 | $this->content[\sizeof($this->content)-1]=$message; |
| 114 | - }else |
|
| 114 | + } else |
|
| 115 | 115 | $this->setContent($message); |
| 116 | 116 | } |
| 117 | 117 | |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | $this->wrapContent("<div class='content'>","</div>"); |
| 52 | 52 | if(\is_string($icon)){ |
| 53 | 53 | $this->icon=new HtmlIcon("icon-".$this->identifier, $icon); |
| 54 | - }else{ |
|
| 54 | + } else{ |
|
| 55 | 55 | $this->icon=$icon; |
| 56 | 56 | } |
| 57 | 57 | return $this; |
@@ -64,10 +64,11 @@ discard block |
||
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | public function setDismissable($dismiss=true){ |
| 67 | - if($dismiss===true) |
|
| 68 | - $this->close=new HtmlIcon("close-".$this->identifier, "close"); |
|
| 69 | - else |
|
| 70 | - $this->close=NULL; |
|
| 67 | + if($dismiss===true) { |
|
| 68 | + $this->close=new HtmlIcon("close-".$this->identifier, "close"); |
|
| 69 | + } else { |
|
| 70 | + $this->close=NULL; |
|
| 71 | + } |
|
| 71 | 72 | return $this; |
| 72 | 73 | } |
| 73 | 74 | |
@@ -111,8 +112,9 @@ discard block |
||
| 111 | 112 | public function setMessage($message){ |
| 112 | 113 | if(\is_array($this->content)){ |
| 113 | 114 | $this->content[\sizeof($this->content)-1]=$message; |
| 114 | - }else |
|
| 115 | - $this->setContent($message); |
|
| 115 | + } else { |
|
| 116 | + $this->setContent($message); |
|
| 117 | + } |
|
| 116 | 118 | } |
| 117 | 119 | |
| 118 | 120 | } |