Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit cbfe118

Browse files
committed
add renderComponent + applyInverted for Ubiquity
1 parent 2aef246 commit cbfe118

File tree

2 files changed

+22
-22
lines changed

2 files changed

+22
-22
lines changed

‎Ajax/Semantic.php

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,10 @@ class Semantic extends BaseGui {
1616

1717
private $language;
1818

19-
private $inverted;
20-
2119
public function __construct($autoCompile=true) {
2220
parent::__construct($autoCompile);
2321
}
2422

25-
2623
public function setLanguage($language){
2724
if($language!==$this->language){
2825
$file=\realpath(dirname(__FILE__)."/semantic/components/validation/languages/".$language.".js");
@@ -33,23 +30,4 @@ public function setLanguage($language){
3330
}
3431
}
3532
}
36-
37-
public function compileHtml(JsUtils $js = NULL, &$view = NULL) {
38-
if($this->inverted==null){
39-
parent::compileHtml($js,$view);
40-
}else {
41-
foreach ($this->htmlComponents as $htmlComponent) {
42-
$htmlComponent->setInverted(true);
43-
$htmlComponent->compile($js, $view);
44-
}
45-
}
46-
}
47-
48-
public function setInverted($inverted='inverted'){
49-
$this->inverted=$inverted;
50-
}
51-
52-
public function getInverted(){
53-
return $this->inverted;
54-
}
5533
}

‎Ajax/php/ubiquity/JsUtils.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
22
namespace Ajax\php\ubiquity;
33

4+
use Ajax\common\html\BaseHtml;
45
use Ajax\semantic\components\validation\Rule;
56
use Ubiquity\controllers\Startup;
67
use Ubiquity\utils\http\URequest;
@@ -81,6 +82,19 @@ public function renderView($viewName, $parameters = [], $asString = false) {
8182
throw new \Exception(get_class() . " instance is not properly instancied : you omitted the second parameter \$controller!");
8283
}
8384

85+
/**
86+
* Compile and render a component.
87+
*
88+
* @param BaseHtml $component
89+
* @param bool $asString
90+
* @return mixed
91+
* @throws \Exception
92+
*/
93+
public function renderComponent(BaseHtml $component, bool $asString = false) {
94+
$component->setLibraryId('_compo_');
95+
return $this->renderView('@framework/main/component.html',[],$asString);
96+
}
97+
8498
/**
8599
* Performs jQuery compilation and displays the default view
86100
*
@@ -175,4 +189,12 @@ public function checkValidationRule($callback): void {
175189
echo \json_encode($result);
176190
}
177191
}
192+
193+
public function applyInverted(){
194+
$this->setParam('beforeCompileHtml', function ($elm) {
195+
if (\method_exists($elm, 'setInverted')) {
196+
$elm->setInverted(false);
197+
}
198+
});
199+
}
178200
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /