jcheron /
phalcon-jquery
This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | |||
| 3 | namespace Ajax\semantic\html\elements; |
||
| 4 | |||
| 5 | use Ajax\semantic\html\base\HtmlSemDoubleElement; |
||
| 6 | use Ajax\semantic\html\base\traits\LabeledIconTrait; |
||
| 7 | use Ajax\semantic\html\base\constants\Emphasis; |
||
| 8 | use Ajax\semantic\html\base\constants\Social; |
||
| 9 | use Ajax\semantic\html\elements\html5\HtmlLink; |
||
| 10 | |||
| 11 | /** |
||
| 12 | * Semantic Button component |
||
| 13 | * @see http://semantic-ui.com/elements/button.html |
||
| 14 | * @author jc |
||
| 15 | * @version 1.001 |
||
| 16 | */ |
||
| 17 | class HtmlButton extends HtmlSemDoubleElement { |
||
| 18 | use LabeledIconTrait; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * Constructs an HTML Semantic button |
||
| 22 | * @param string $identifier HTML id |
||
| 23 | * @param string $value value of the Button |
||
| 24 | * @param string $cssStyle btn-default, btn-primary... |
||
| 25 | * @param string $onClick JS Code for click event |
||
| 26 | */ |
||
| 27 | View Code Duplication | public function __construct($identifier, $value="", $cssStyle=null, $onClick=null) { |
|
|
0 ignored issues
–
show
|
|||
| 28 | parent::__construct($identifier, "button", "ui button"); |
||
| 29 | $this->content=$value; |
||
| 30 | if (isset($cssStyle)) { |
||
| 31 | $this->setStyle($cssStyle); |
||
| 32 | } |
||
| 33 | if (isset($onClick)) { |
||
| 34 | $this->onClick($onClick); |
||
| 35 | } |
||
| 36 | } |
||
| 37 | |||
| 38 | /** |
||
| 39 | * Set the button value |
||
| 40 | * @param string $value |
||
| 41 | * @return \Ajax\semantic\html\HtmlButton |
||
| 42 | */ |
||
| 43 | public function setValue($value) { |
||
| 44 | $this->content=$value; |
||
| 45 | return $this; |
||
| 46 | } |
||
| 47 | |||
| 48 | /** |
||
| 49 | * define the button style |
||
| 50 | * @param string|int $cssStyle |
||
| 51 | * @return \Ajax\semantic\html\HtmlButton default : "" |
||
| 52 | */ |
||
| 53 | public function setStyle($cssStyle) { |
||
| 54 | return $this->addToProperty("class", $cssStyle); |
||
| 55 | } |
||
| 56 | |||
| 57 | public function setFocusable($value=true) { |
||
| 58 | if ($value === true) |
||
| 59 | $this->setProperty("tabindex", "0"); |
||
| 60 | else { |
||
| 61 | $this->removeProperty("tabindex"); |
||
| 62 | } |
||
| 63 | return $this; |
||
| 64 | } |
||
| 65 | |||
| 66 | public function setAnimated($content, $animation="") { |
||
| 67 | $this->setTagName("div"); |
||
| 68 | $this->addToProperty("class", "animated " . $animation); |
||
| 69 | $visible=new HtmlSemDoubleElement("visible-" . $this->identifier, "div"); |
||
| 70 | $visible->setClass("visible content"); |
||
| 71 | $visible->setContent($this->content); |
||
| 72 | $hidden=new HtmlSemDoubleElement("hidden-" . $this->identifier, "div"); |
||
| 73 | $hidden->setClass("hidden content"); |
||
| 74 | $hidden->setContent($content); |
||
| 75 | $this->content=array ($visible,$hidden ); |
||
| 76 | return $hidden; |
||
| 77 | } |
||
| 78 | |||
| 79 | /** |
||
| 80 | * |
||
| 81 | * @param string|HtmlIcon $icon |
||
| 82 | * @return \Ajax\semantic\html\elements\HtmlButton |
||
| 83 | */ |
||
| 84 | public function asIcon($icon) { |
||
| 85 | $iconO=$icon; |
||
| 86 | if (\is_string($icon)) { |
||
| 87 | $iconO=new HtmlIcon("icon-" . $this->identifier, $icon); |
||
| 88 | } |
||
| 89 | $this->addToProperty("class", "icon"); |
||
| 90 | $this->content=$iconO; |
||
| 91 | return $this; |
||
| 92 | } |
||
| 93 | |||
| 94 | public function asSubmit() { |
||
| 95 | $this->setProperty("type", "submit"); |
||
| 96 | return $this->setTagName("button"); |
||
| 97 | } |
||
| 98 | |||
| 99 | /** |
||
| 100 | * Add and return a button label |
||
| 101 | * @param string $caption |
||
|
0 ignored issues
–
show
There is no parameter named
$caption. Was it maybe removed?
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. Consider the following example. The parameter /**
* @param array $germany
* @param array $island
* @param array $italy
*/
function finale($germany, $island) {
return "2:1";
}
The most likely cause is that the parameter was removed, but the annotation was not. Loading history...
|
|||
| 102 | * @param string $before |
||
| 103 | * @param string $icon |
||
| 104 | * @return \Ajax\semantic\html\elements\HtmlLabel |
||
| 105 | */ |
||
| 106 | View Code Duplication | public function addLabel($label, $before=false, $icon=NULL) { |
|
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. Loading history...
|
|||
| 107 | $this->tagName="div"; |
||
| 108 | $this->addToProperty("class", "labeled"); |
||
| 109 | $this->content=new HtmlButton("button-" . $this->identifier, $this->content); |
||
| 110 | $this->content->setTagName("div"); |
||
| 111 | $label=new HtmlLabel("label-" . $this->identifier, $label, "a"); |
||
| 112 | if(isset($icon)) |
||
| 113 | $label->addIcon($icon); |
||
| 114 | $label->setBasic(); |
||
| 115 | $this->addContent($label, $before); |
||
|
0 ignored issues
–
show
It seems like
$before defined by parameter $before on line 106 can also be of type string; however, Ajax\common\html\HtmlDoubleElement::addContent() does only seem to accept boolean, maybe add an additional type check?
This check looks at variables that have been passed in as parameters and are passed out again to other methods. If the outgoing method call has stricter type requirements than the method itself, an issue is raised. An additional type check may prevent trouble. Loading history...
|
|||
| 116 | return $label; |
||
| 117 | } |
||
| 118 | |||
| 119 | /* |
||
| 120 | * (non-PHPdoc) |
||
| 121 | * @see \Ajax\common\html\BaseHtml::fromArray() |
||
| 122 | */ |
||
| 123 | public function fromArray($array) { |
||
| 124 | $array=parent::fromArray($array); |
||
| 125 | foreach ( $array as $key => $value ) { |
||
| 126 | $this->setProperty($key, $value); |
||
| 127 | } |
||
| 128 | return $array; |
||
| 129 | } |
||
| 130 | |||
| 131 | /** |
||
| 132 | * show it is currently the active user selection |
||
| 133 | * @return \Ajax\semantic\html\elements\HtmlButton |
||
| 134 | */ |
||
| 135 | public function setActive() { |
||
| 136 | return $this->addToProperty("class", "active"); |
||
| 137 | } |
||
| 138 | |||
| 139 | /** |
||
| 140 | * hint towards a positive consequence |
||
| 141 | * @return \Ajax\semantic\html\elements\HtmlButton |
||
| 142 | */ |
||
| 143 | public function setPositive() { |
||
| 144 | return $this->addToProperty("class", "positive"); |
||
| 145 | } |
||
| 146 | |||
| 147 | /** |
||
| 148 | * hint towards a negative consequence |
||
| 149 | * @return \Ajax\semantic\html\elements\HtmlButton |
||
| 150 | */ |
||
| 151 | public function setNegative() { |
||
| 152 | return $this->addToProperty("class", "negative"); |
||
| 153 | } |
||
| 154 | |||
| 155 | /** |
||
| 156 | * formatted to toggle on/off |
||
| 157 | * @return \Ajax\semantic\html\elements\HtmlButton |
||
| 158 | */ |
||
| 159 | public function setToggle() { |
||
| 160 | return $this->addToProperty("class", "toggle"); |
||
| 161 | } |
||
| 162 | |||
| 163 | /** |
||
| 164 | * |
||
| 165 | * @return \Ajax\semantic\html\elements\HtmlButton |
||
| 166 | */ |
||
| 167 | public function setCircular() { |
||
| 168 | return $this->addToProperty("class", "circular"); |
||
| 169 | } |
||
| 170 | |||
| 171 | /** |
||
| 172 | * button is less pronounced |
||
| 173 | * @return \Ajax\semantic\html\elements\HtmlButton |
||
| 174 | */ |
||
| 175 | public function setBasic() { |
||
| 176 | return $this->addToProperty("class", "basic"); |
||
| 177 | } |
||
| 178 | |||
| 179 | public function setEmphasis($value) { |
||
| 180 | return $this->addToPropertyCtrl("class", $value, Emphasis::getConstants()); |
||
| 181 | } |
||
| 182 | |||
| 183 | public function setLoading() { |
||
| 184 | return $this->addToProperty("class", "loading"); |
||
| 185 | } |
||
| 186 | |||
| 187 | public static function social($identifier, $social, $value=NULL) { |
||
| 188 | if ($value === NULL) |
||
| 189 | $value=\ucfirst($social); |
||
| 190 | $return=new HtmlButton($identifier, $value); |
||
| 191 | $return->addIcon($social); |
||
| 192 | return $return->addToPropertyCtrl("class", $social, Social::getConstants()); |
||
| 193 | } |
||
| 194 | |||
| 195 | public static function labeled($identifier, $value, $icon, $before=true) { |
||
| 196 | $result=new HtmlButton($identifier, $value); |
||
| 197 | $result->addIcon($icon, $before, true); |
||
| 198 | return $result; |
||
| 199 | } |
||
| 200 | |||
| 201 | public static function icon($identifier, $icon) { |
||
| 202 | $result=new HtmlButton($identifier); |
||
| 203 | $result->asIcon($icon); |
||
| 204 | return $result; |
||
| 205 | } |
||
| 206 | |||
| 207 | public function asLink($href=NULL) { |
||
| 208 | $lnk=new HtmlLink("lnk-".$this->identifier,$href,$this->content); |
||
| 209 | $this->content=$lnk; |
||
| 210 | return $this; |
||
| 211 | } |
||
| 212 | } |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.