Skip to content

Commit ab06fe6

Browse files
committed
ajaxTrait complete refactoring
1 parent a91c54f commit ab06fe6

File tree

16 files changed

+184
-162
lines changed

16 files changed

+184
-162
lines changed

Ajax/common/Widget.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,12 @@ public function insertInField($index,$field){
194194
return $this;
195195
}
196196

197+
/**
198+
* Defines the function which displays the field value
199+
* @param $index index or name of the field to display
200+
* @param callable $callback function parameters are : $value : the field value ,$index : the field index, $instance : the active instance of model
201+
* @return Widget
202+
*/
197203
public function setValueFunction($index,$callback){
198204
$index=$this->_getIndex($index);
199205
$this->_instanceViewer->setValueFunction($index, $callback);

Ajax/common/html/BaseHtml.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ protected function compile_once(JsUtils $js=NULL, &$view=NULL) {
202202
$pc=$this->_preCompile;
203203
$pc($this);
204204
}
205+
unset($this->properties["jsCallback"]);
205206
$this->_compiled=true;
206207
}
207208
}
@@ -214,7 +215,10 @@ public function compile(JsUtils $js=NULL, &$view=NULL) {
214215
if (\is_array($value)) {
215216
$v=PropertyWrapper::wrap($value, $js);
216217
} else {
217-
$v=$value;
218+
if($value instanceof \stdClass)
219+
$v=\print_r($value,true);
220+
else
221+
$v=$value;
218222
}
219223
$result=str_ireplace("%" . $key . "%", $v, $result);
220224
}

Ajax/common/html/BaseWidget.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace Ajax\common\html;
44

5+
use Ajax\service\JString;
6+
57
/**
68
* BaseWidget for Twitter Bootstrap, jQuery UI or Semantic rich components
79
* @author jc
@@ -23,11 +25,11 @@ public function getIdentifier() {
2325
}
2426

2527
public function setIdentifier($identifier) {
26-
$this->identifier=$identifier;
28+
$this->identifier=$this->cleanIdentifier($identifier);
2729
return $this;
2830
}
2931

3032
protected function cleanIdentifier($id) {
31-
return preg_replace('/[^a-zA-Z0-9\-.]/s', '', $id);
33+
return JString::cleanIdentifier($id);
3234
}
3335
}

Ajax/common/traits/JsUtilsAjaxTrait.php

Lines changed: 134 additions & 130 deletions
Large diffs are not rendered by default.

Ajax/semantic/html/base/HtmlSemDoubleElement.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,8 @@ public function run(JsUtils $js) {
167167
return $this->_bsComponent;
168168
}
169169

170-
public function addList($elements,$ordered=false){
171-
$list=new HtmlList("list-".$this->identifier,$elements);
170+
public function addList($items,$ordered=false){
171+
$list=new HtmlList("list-".$this->identifier,$items);
172172
$list->setOrdered($ordered);
173173
$list->setClass("ui list");
174174
$this->addContent($list);

Ajax/semantic/html/base/constants/icons/webContent.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44

55
use Ajax\common\BaseEnum;
66

7-
abstract class WebContent extends BaseEnum {
7+
abstract class webContent extends BaseEnum {
88
const ALARM="alarm", ALARM_SLASH="alarm slash", ALARM_OUTLINE="alarm outline", ALARM_SLASH_OUTLINE="alarm slash outline", AT="at", BROWSER="browser", BUG="bug", CALENDAR_OUTLINE="calendar outline", CALENDAR="calendar", CLOUD="cloud", CODE="code", COMMENT="comment", COMMENTS="comments", COMMENT_OUTLINE="comment outline", COMMENTS_OUTLINE="comments outline", COPYRIGHT="copyright", DASHBOARD="dashboard", DROPDOWN="dropdown", EXTERNAL_SQUARE="external square", EXTERNAL="external", EYEDROPPER="eyedropper", FEED="feed", FIND="find", HEARTBEAT="heartbeat", HISTORY="history", HOME="home", IDEA="idea", INBOX="inbox", LAB="lab", MAIL="mail", MAIL_OUTLINE="mail outline", MAIL_SQUARE="mail square", MAP="map", OPTIONS="options", PAINT_BRUSH="paint brush", PAYMENT="payment", PHONE="phone", PHONE_SQUARE="phone square", PRIVACY="privacy", PROTECT="protect", SEARCH="search", SETTING="setting", SETTINGS="settings", SHOP="shop", SIDEBAR="sidebar", SIGNAL="signal", SITEMAP="sitemap", TAG="tag", TAGS="tags", TASKS="tasks", TERMINAL="terminal", TEXT_TELEPHONE="text telephone", TICKET="ticket", TROPHY="trophy", WIFI="wifi";
99
}

Ajax/semantic/html/collections/form/HtmlFormFields.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,10 @@ public static function checkeds($name, $items=array(), $label=NULL, $values=arra
124124
}
125125
$fields[]=$itemO;
126126
}
127-
$checkeds=new HtmlFormFields("fields-".$name, $fields);
127+
$radios=new HtmlFormFields("fields-".$name, $fields);
128128
if (isset($label))
129-
$checkeds->setLabel($label)->setProperty("for", $name);
130-
return $checkeds;
129+
$radios->setLabel($label)->setProperty("for", $name);
130+
return $radios;
131131
}
132132

133133
public function setEqualWidth($_equalWidth) {

Ajax/semantic/html/elements/HtmlButtonGroups.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,6 @@ protected function createItem($value){
2626
return new HtmlButton("", $value);
2727
}
2828

29-
/**
30-
* @param array $items
31-
* @param boolean $asCombo
32-
* @return HtmlDropdown
33-
*/
3429
public function addDropdown($items,$asCombo=false){
3530
$dd= new HtmlDropdown("dd-".$this->identifier,null,$items);
3631
$dd->asButton();

Ajax/semantic/html/modules/HtmlModal.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public function setActions($actions) {
5757
public function addAction($action){
5858
if(!$action instanceof BaseHtml){
5959
$class="";
60-
if(\array_search($action, ["Okay","Yes"])!==false){
60+
if(\array_search($action, ["Okay","Yes","Validate"])!==false){
6161
$class="approve";
6262
}
6363
if(\array_search($action, ["Close","Cancel","No"])!==false){

Ajax/semantic/widgets/base/FieldAsTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ protected function _applyAttributes(BaseHtml $element,&$attributes,$index){
4646
$callback=$attributes["jsCallback"];
4747
if(\is_callable($callback)){
4848
$callback($element,$this->_modelInstance,$index);
49-
unset($attributes["jsCallback"]);
49+
//unset($attributes["jsCallback"]);
5050
}
5151
}
5252
unset($attributes["rules"]);

0 commit comments

Comments
 (0)