Skip to content

Commit 3dd4a0b

Browse files
committed
JReflextion + href target bug fixed
1 parent f58e0b8 commit 3dd4a0b

File tree

7 files changed

+114
-19
lines changed

7 files changed

+114
-19
lines changed

Ajax/semantic/html/base/HtmlSemDoubleElement.php

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,23 +34,49 @@ public function __construct($identifier, $tagName="p", $baseClass="ui", $content
3434
}
3535
}
3636

37+
/**
38+
* Defines the popup attributes
39+
* @param string $variation
40+
* @param string $popupEvent
41+
*/
3742
public function setPopupAttributes($variation=NULL, $popupEvent=NULL) {
3843
if (isset($this->_popup))
3944
$this->_popup->setAttributes($variation, $popupEvent);
4045
}
4146

47+
/**
48+
* Adds a popup to the element
49+
* @param string $title
50+
* @param string $content
51+
* @param string $variation
52+
* @param array $params
53+
* @return HtmlSemDoubleElement
54+
*/
4255
public function addPopup($title="", $content="", $variation=NULL, $params=array()) {
4356
$this->_popup=new InternalPopup($this, $title, $content, $variation, $params);
4457
return $this;
4558
}
4659

60+
/**
61+
* Adds an html popup to the element
62+
* @param string $html
63+
* @param string $variation
64+
* @param array $params
65+
* @return HtmlSemDoubleElement
66+
*/
4767
public function addPopupHtml($html="", $variation=NULL, $params=array()) {
4868
$this->_popup=new InternalPopup($this);
4969
$this->_popup->setHtml($html);
5070
$this->_popup->setAttributes($variation, $params);
5171
return $this;
5272
}
5373

74+
/**
75+
* Adds a Dimmer to the element
76+
* @param array $params
77+
* @param mixed $content
78+
* @return HtmlDimmer
79+
*/
5480
public function addDimmer($params=array(), $content=NULL) {
5581
$dimmer=new HtmlDimmer("dimmer-" . $this->identifier, $content);
5682
$dimmer->setParams($params);
@@ -59,6 +85,13 @@ public function addDimmer($params=array(), $content=NULL) {
5985
return $dimmer;
6086
}
6187

88+
/**
89+
* Adds a label to the element
90+
* @param mixed $label
91+
* @param boolean $before
92+
* @param string $icon
93+
* @return mixed|HtmlLabel
94+
*/
6295
public function addLabel($label, $before=false, $icon=NULL) {
6396
$labelO=$label;
6497
if (\is_object($label) === false) {
@@ -72,15 +105,23 @@ public function addLabel($label, $before=false, $icon=NULL) {
72105
return $labelO;
73106
}
74107

108+
/**
109+
* Adds an attached label to the element
110+
* @param mixed $label
111+
* @param string $side
112+
* @param string $direction
113+
* @param string $icon
114+
* @return HtmlSemDoubleElement
115+
*/
75116
public function attachLabel($label,$side=Side::TOP,$direction=Direction::NONE,$icon=NULL){
76117
$label=$this->addLabel($label,true,$icon);
77118
$label->setAttached($side,$direction);
78119
return $this;
79120
}
80121

81122
/**
82-
*
83-
* @return \Ajax\semantic\html\base\HtmlSemDoubleElement
123+
* Transforms the element into a link
124+
* @return HtmlSemDoubleElement
84125
*/
85126
public function asLink($href=NULL,$target=NULL) {
86127
if (isset($href))
@@ -90,19 +131,32 @@ public function asLink($href=NULL,$target=NULL) {
90131
return $this->setTagName("a");
91132
}
92133

134+
/**
135+
* Returns the script displaying the dimmer
136+
* @param boolean $show
137+
* @return string
138+
*/
93139
public function jsShowDimmer($show=true) {
94140
$status="hide";
95141
if ($show === true)
96142
$status="show";
97143
return '$("#.' . $this->identifier . ').dimmer("' . $status . '");';
98144
}
99145

146+
/**
147+
* {@inheritDoc}
148+
* @see BaseHtml::compile()
149+
*/
100150
public function compile(JsUtils $js=NULL, &$view=NULL) {
101151
if (isset($this->_popup))
102152
$this->_popup->compile($js);
103153
return parent::compile($js, $view);
104154
}
105155

156+
/**
157+
* {@inheritDoc}
158+
* @see HtmlDoubleElement::run()
159+
*/
106160
public function run(JsUtils $js) {
107161
$this->_bsComponent=$js->semantic()->generic("#" . $this->identifier);
108162
parent::run($js);

Ajax/semantic/html/elements/HtmlButton.php

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
/**
1212
* Semantic Button component
1313
* @see http://phpmv-ui.kobject.net/index/direct/main/31
14-
* @see http://semantic-ui.com/elements/button.html * @author jc
14+
* @see http://semantic-ui.com/elements/button.html
15+
* @author jc
1516
* @version 1.001
1617
*/
1718
class HtmlButton extends HtmlSemDoubleElement {
@@ -38,7 +39,7 @@ public function __construct($identifier, $value="", $cssStyle=null, $onClick=nul
3839
/**
3940
* Set the button value
4041
* @param string $value
41-
* @return \Ajax\semantic\html\HtmlButton
42+
* @return HtmlButton
4243
*/
4344
public function setValue($value) {
4445
$this->content=$value;
@@ -48,7 +49,7 @@ public function setValue($value) {
4849
/**
4950
* define the button style
5051
* @param string|int $cssStyle
51-
* @return \Ajax\semantic\html\HtmlButton default : ""
52+
* @return HtmlButton default : ""
5253
*/
5354
public function setStyle($cssStyle) {
5455
return $this->addToProperty("class", $cssStyle);
@@ -79,7 +80,7 @@ public function setAnimated($content, $animation="") {
7980
/**
8081
*
8182
* @param string|HtmlIcon $icon
82-
* @return \Ajax\semantic\html\elements\HtmlButton
83+
* @return HtmlButton
8384
*/
8485
public function asIcon($icon) {
8586
$iconO=$icon;
@@ -101,7 +102,7 @@ public function asSubmit() {
101102
* @param string $label
102103
* @param boolean $before
103104
* @param string $icon
104-
* @return \Ajax\semantic\html\elements\HtmlLabel
105+
* @return HtmlLabel
105106
*/
106107
public function addLabel($label, $before=false, $icon=NULL) {
107108
$this->tagName="div";
@@ -128,23 +129,23 @@ public function fromArray($array) {
128129

129130
/**
130131
* hint towards a positive consequence
131-
* @return \Ajax\semantic\html\elements\HtmlButton
132+
* @return HtmlButton
132133
*/
133134
public function setPositive() {
134135
return $this->addToProperty("class", "positive");
135136
}
136137

137138
/**
138139
* hint towards a negative consequence
139-
* @return \Ajax\semantic\html\elements\HtmlButton
140+
* @return HtmlButton
140141
*/
141142
public function setNegative() {
142143
return $this->addToProperty("class", "negative");
143144
}
144145

145146
/**
146147
* formatted to toggle on/off
147-
* @return \Ajax\semantic\html\elements\HtmlButton
148+
* @return HtmlButton
148149
*/
149150
public function setToggle() {
150151
$this->onCreate("$('#".$this->identifier."').state();");
@@ -153,15 +154,15 @@ public function setToggle() {
153154

154155
/**
155156
*
156-
* @return \Ajax\semantic\html\elements\HtmlButton
157+
* @return HtmlButton
157158
*/
158159
public function setCircular() {
159160
return $this->addToProperty("class", "circular");
160161
}
161162

162163
/**
163164
* button is less pronounced
164-
* @return \Ajax\semantic\html\elements\HtmlButton
165+
* @return HtmlButton
165166
*/
166167
public function setBasic() {
167168
return $this->addToProperty("class", "basic");
@@ -175,6 +176,13 @@ public function setLoading() {
175176
return $this->addToProperty("class", "loading");
176177
}
177178

179+
/**
180+
* Returns a new social Button
181+
* @param string $identifier
182+
* @param string $social
183+
* @param string $value
184+
* @return HtmlButton
185+
*/
178186
public static function social($identifier, $social, $value=NULL) {
179187
if ($value === NULL)
180188
$value=\ucfirst($social);
@@ -183,18 +191,36 @@ public static function social($identifier, $social, $value=NULL) {
183191
return $return->addToPropertyCtrl("class", $social, Social::getConstants());
184192
}
185193

194+
/**
195+
* Returns a new labeled Button
196+
* @param string $identifier
197+
* @param string $value
198+
* @param string $icon
199+
* @param boolean $before
200+
* @return \Ajax\semantic\html\elements\HtmlButton
201+
*/
186202
public static function labeled($identifier, $value, $icon, $before=true) {
187203
$result=new HtmlButton($identifier, $value);
188204
$result->addIcon($icon, $before, true);
189205
return $result;
190206
}
191207

208+
/**
209+
* Returns a new icon Button
210+
* @param string $identifier
211+
* @param string $icon
212+
* @return HtmlButton
213+
*/
192214
public static function icon($identifier, $icon) {
193215
$result=new HtmlButton($identifier);
194216
$result->asIcon($icon);
195217
return $result;
196218
}
197219

220+
/**
221+
* {@inheritDoc}
222+
* @see HtmlSemDoubleElement::asLink()
223+
*/
198224
public function asLink($href=NULL,$target=NULL) {
199225
$lnk=new HtmlLink("lnk-".$this->identifier,$href,$this->content,$target);
200226
$this->content=$lnk;

Ajax/semantic/html/elements/HtmlIcon.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,16 @@ public function setRotated($sens="clockwise") {
8282

8383
/**
8484
* icon formatted as a link
85-
* @return \Ajax\semantic\html\HtmlIcon
85+
* @param string $href
86+
* @param string target
87+
* @return HtmlIcon
8688
*/
87-
public function asLink($href=NULL) {
89+
public function asLink($href=NULL,$target=NULL) {
8890
if (isset($href)) {
89-
$this->wrap("<a href='" . $href . "'>", "</a>");
91+
$_target="";
92+
if(isset($target))
93+
$_target="target='{$target}'";
94+
$this->wrap("<a href='" . $href . "' {$_target}>", "</a>");
9095
}
9196
return $this->addToProperty("class", "link");
9297
}

Ajax/semantic/html/views/HtmlCard.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,17 +129,19 @@ public function getCardHeader() {
129129
*
130130
* {@inheritDoc}
131131
*
132-
* @see \Ajax\semantic\html\base\HtmlSemDoubleElement::compile()
132+
* @see HtmlSemDoubleElement::compile()
133133
*/
134134
public function compile(JsUtils $js=NULL, &$view=NULL) {
135135
$this->content=JArray::sortAssociative($this->content, [ "header","image","content","extra-content" ]);
136136
return parent::compile($js, $view);
137137
}
138138

139-
public function asLink($href="") {
139+
public function asLink($href="",$target=NULL) {
140140
$this->addToProperty("class", "link");
141141
if ($href !== "") {
142142
$this->setProperty("href", $href);
143+
if (isset($target))
144+
$this->setProperty("target", $target);
143145
}
144146
return $this;
145147
}

Ajax/semantic/widgets/base/FieldAsTrait.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use Ajax\semantic\html\elements\HtmlButton;
1818
use Ajax\service\JArray;
1919
use Ajax\semantic\html\elements\html5\HtmlLink;
20+
use Ajax\semantic\html\elements\HtmlFlag;
2021

2122
/**
2223
* trait used in Widget
@@ -138,6 +139,14 @@ public function fieldAsImage($index,$size=Size::MINI,$circular=false){
138139
return $this;
139140
}
140141

142+
public function fieldAsFlag($index){
143+
$this->setValueFunction($index,function($flag){
144+
$flag=new HtmlFlag($this->_getFieldIdentifier("flag"),$flag);
145+
return $flag;
146+
});
147+
return $this;
148+
}
149+
141150
public function fieldAsAvatar($index,$attributes=NULL){
142151
return $this->_fieldAs(function($id,$name,$value){
143152
$img=new HtmlImage($id,$value);

Ajax/semantic/widgets/dataform/DataForm.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ protected function _generateFields($form,$values,$headers,$sepFirst,$sepLast,$wr
7575
if(isset($wrappers[$sepFirst+1])){
7676
$wrapper=$wrappers[$sepFirst+1];
7777
}
78-
//TODO check why $fields is empty
7978
if(\sizeof($fields)===1){
8079
$added=$form->addField($fields[0]);
8180
}elseif(\sizeof($fields)>1){

Ajax/service/JReflection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public static function jsonObject($classname){
1515
foreach ($methods as $method){
1616
$name=$method->getName();
1717
if(JString::startswith($name, "set")){
18-
$property=\strtolower(JString::replaceAtFirst($name, "set", ""));
18+
$property=\lcfirst(JString::replaceAtFirst($name, "set", ""));
1919
$value="__".$property."__";
2020
try{
2121
if($class->getProperty($property)!==null){

0 commit comments

Comments
 (0)