44 parsable char default 'N',
45 rules text default '{}'
47 create sequence SEQ_ID_STYLE start 10000;
57 if (!empty($this->rules)) {
58 $this->_expanded_rules = json_decode($this->rules,
true);
74 $this->rules = json_encode($this->_expanded_rules);
86 $socStyle = $this->parent->Getparam(
"CORE_SOCSTYLE");
88 if (($socStyle !=
"") && file_exists($root .
"/STYLE/" . $socStyle .
"/Images/" . $img)) {
89 return (
"STYLE/" . $socStyle .
"/Images/" . $img);
92 if (file_exists($root .
"/STYLE/" . $this->
name .
"/Images/" . $img)) {
93 return (
"STYLE/" . $this->
name .
"/Images/" . $img);
103 $socStyle = $this->parent->Getparam(
"CORE_SOCSTYLE");
105 if ($socStyle !=
"") {
106 $file = $root .
"/STYLE/" . $socStyle .
"/Layout/" . $layname;
110 $file = $root .
"/STYLE/" . $this->
name .
"/Layout/" . $layname;
118 $this->_expanded_rules = $filesDefinition;
123 $this->_expanded_rules[$fileType][
$file] = $definition;
134 if (!isset($this->_expanded_rules[$fileType])) {
138 if (!isset($this->_expanded_rules[$fileType][
$file])) {
141 return $this->_expanded_rules[$fileType][
$file];
158 const STY0003 =
'style registration error: %s';
162 const STY0004 =
'source file not readable for sty target: %s';
170 const STY0006 =
'parser does not implements required interfaces: %s';
179 const STY0008 =
'cannot create target directory: %s';
184 const STY0009 =
'origin "%s" is not a directory';
189 const STY0010 =
'cannot copy from origin "%s" to "%s"';
200 private function _bo()
213 public function __construct($srcFiles, Array $options, Array $styleConfig);
219 public function gen($destFile = null);
235 public function __construct($srcFiles, Array $options, Array $styleConfig)
237 if (is_array($srcFiles)) {
238 $this->_srcFiles = $srcFiles;
240 $this->_srcFiles = array(
250 public function gen($destFile = null)
254 $fullTargetPath = $pubDir . DIRECTORY_SEPARATOR . $destFile;
255 $fullTargetDirname = dirname($fullTargetPath);
256 if (!is_dir($fullTargetDirname) && (
false === mkdir($fullTargetDirname, 0777,
true))) {
257 throw new Exception(
"STY0005",
"$fullTargetDirname dir could not be created for file $destFile");
260 $targetHandler = fopen($fullTargetPath,
'w');
261 if (
false === $targetHandler) {
262 throw new Exception(
"STY0005",
"$destFile dir could not be created");
265 foreach ($this->_srcFiles as $srcPath) {
266 $srcFullPath = $pubDir . DIRECTORY_SEPARATOR . $srcPath;
267 if (!is_readable($srcFullPath)) {
268 if (!file_exists($srcFullPath)) {
269 $msg =
"source file $srcFullPath does not exists for file $destFile";
271 $msg =
"source file $srcFullPath is not readable for file $destFile";
275 if (
false === fwrite($targetHandler, file_get_contents($srcFullPath))) {
276 throw new Exception(
"STY0005",
"data from $srcFullPath could not be written to file $fullTargetPath");
279 if (
false === fclose($targetHandler)) {
280 throw new Exception(
"STY0005",
"$fullTargetPath could not be closed");
295 public function __construct($srcFiles, Array $options, Array $styleConfig)
297 if (is_array($srcFiles)) {
298 $this->_srcFiles = $srcFiles;
300 $this->_srcFiles = array(
304 $this->_styleConfig = $styleConfig;
311 public function gen($destFile = null)
316 foreach ($this->_srcFiles as $srcPath) {
317 $srcFullPath = $pubDir . DIRECTORY_SEPARATOR . $srcPath;
318 if (!is_readable($srcFullPath)) {
319 if (!file_exists($srcFullPath)) {
320 $msg =
"source file $srcFullPath does not exists for file $destFile";
322 $msg =
"source file $srcFullPath is not readable for file $destFile";
326 $template.= file_get_contents($srcFullPath);
329 $fullTargetPath = $pubDir . DIRECTORY_SEPARATOR . $destFile;
330 $fullTargetDirname = dirname($fullTargetPath);
331 if (!is_dir($fullTargetDirname) && (
false === mkdir($fullTargetDirname, 0777,
true))) {
332 throw new Exception(
"STY0005",
"$fullTargetDirname dir could not be created for file $destFile");
335 foreach ($explorerP as $ep) {
336 $action->parent->SetVolatileParam($ep, null);
338 $lay = new \Layout(
"", $action, $template);
339 $template = $lay->gen();
340 $keyForStyle = preg_replace(
"/css\//",
"", $destFile);
341 if (!isset($this->_styleConfig[
"sty_rules"][
"css"][$keyForStyle][
"flags"]) || $this->_styleConfig[
"sty_rules"][
"css"][$keyForStyle][
"flags"] !== \
Style::RULE_FLAG_PARSE_ON_RUNTIME) {
342 $subRepositoryLevel = substr_count($destFile,
"/");
344 for ($i = 0; $i < $subRepositoryLevel; $i++) {
347 $template = preg_replace(
'/(url\()\s*([\'"]?)\s*(.*?)\s*(\2\s*\))/',
"$1$2" . $levelToGo .
"$3$4", $template);
349 if (
false === file_put_contents($fullTargetPath, $template)) {
350 throw new Exception(
"STY0005",
"$fullTargetPath could not be written for file $destFile");
364 public function __construct($srcFiles, Array $options, Array $styleConfig)
366 if (is_array($srcFiles)) {
367 $this->_srcFiles = $srcFiles;
369 $this->_srcFiles = array(
379 public function gen($destFile = null)
384 foreach ($this->_srcFiles as $srcPath) {
385 $srcFullPath = $pubDir . DIRECTORY_SEPARATOR . $srcPath;
386 if (!is_dir($srcFullPath)) {
388 throw new Exception(
"STY0009", $srcFullPath);
390 if (!is_dir($pubDir . DIRECTORY_SEPARATOR . $destFile)) {
391 $r = mkdir($pubDir . DIRECTORY_SEPARATOR . $destFile);
393 throw new Exception(
"STY0008", $pubDir . DIRECTORY_SEPARATOR . $destFile);
396 $cpCmd = sprintf(
"cp -r %s/* %s", escapeshellarg($srcFullPath) , escapeshellarg($pubDir . DIRECTORY_SEPARATOR . $destFile));
397 $r = shell_exec(
"$cpCmd 2>&1 && echo 1");
399 throw new Exception(
"STY0010", $srcFullPath, $pubDir . DIRECTORY_SEPARATOR . $destFile);
getRule($fileType, $file)
setRule($fileType, $file, $definition)
__construct($srcFiles, Array $options, Array $styleConfig)
getImageUrl($img, $default)
print< H1 > Check Database< i > $dbaccess</i ></H1 > $a
print $fam getTitle() $fam name
Exception class use exceptionCode to identifiy correctly exception.
__construct($srcFiles, Array $options, Array $styleConfig)
getLayoutFile($layname, $default="")
__construct($dbaccess= '', $id= '', $res= '', $dbid=0)
setRules(Array $filesDefinition)
const RULE_FLAG_PARSE_ON_RUNTIME
__construct($srcFiles, Array $options, Array $styleConfig)
getExplorerParamtersName()
__construct($srcFiles, Array $options, Array $styleConfig)