Clean code
This commit is contained in:
parent
77dfc19389
commit
01962cbc67
@ -2452,6 +2452,13 @@ class lessc_parser {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse a string
|
||||||
|
*
|
||||||
|
* @param string $buffer String to parse
|
||||||
|
* @throws exception
|
||||||
|
* @return NULL|stdclass
|
||||||
|
*/
|
||||||
public function parse($buffer) {
|
public function parse($buffer) {
|
||||||
$this->count = 0;
|
$this->count = 0;
|
||||||
$this->line = 1;
|
$this->line = 1;
|
||||||
@ -2473,11 +2480,15 @@ class lessc_parser {
|
|||||||
while (false !== $this->parseChunk());
|
while (false !== $this->parseChunk());
|
||||||
|
|
||||||
if ($this->count != strlen($this->buffer))
|
if ($this->count != strlen($this->buffer))
|
||||||
$this->throwError();
|
{
|
||||||
|
$this->throwError('parse error count '.$this->count.' != len buffer '.strlen($this->buffer));
|
||||||
|
}
|
||||||
|
|
||||||
// TODO report where the block was opened
|
// TODO report where the block was opened
|
||||||
if ( !property_exists($this->env, 'parent') || !is_null($this->env->parent) )
|
if (!property_exists($this->env, 'parent') || !is_null($this->env->parent))
|
||||||
|
{
|
||||||
throw new exception('parse error: unclosed block');
|
throw new exception('parse error: unclosed block');
|
||||||
|
}
|
||||||
|
|
||||||
return $this->env;
|
return $this->env;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5663,23 +5663,28 @@ function dol_htmlentities($string, $flags = null, $encoding = 'UTF-8', $double_e
|
|||||||
* Example, if string contains euro symbol that has ascii code 128
|
* Example, if string contains euro symbol that has ascii code 128
|
||||||
*
|
*
|
||||||
* @param string $s String to check
|
* @param string $s String to check
|
||||||
* @return int 0 if bad iso, 1 if good iso
|
* @param string $clean Clean if it is not an ISO. Warning, if file is utf8, you will get a bad formated file.
|
||||||
|
* @return int|string 0 if bad iso, 1 if good iso, Or the clean string if $clean is 1
|
||||||
*/
|
*/
|
||||||
function dol_string_is_good_iso($s)
|
function dol_string_is_good_iso($s, $clean = 0)
|
||||||
{
|
{
|
||||||
$len=dol_strlen($s);
|
$len=dol_strlen($s);
|
||||||
|
$out= '';
|
||||||
$ok=1;
|
$ok=1;
|
||||||
for($scursor=0;$scursor<$len;$scursor++)
|
for($scursor = 0; $scursor < $len; $scursor++)
|
||||||
{
|
{
|
||||||
$ordchar=ord($s[$scursor]);
|
$ordchar=ord($s[$scursor]);
|
||||||
//print $scursor.'-'.$ordchar.'<br>';
|
//print $scursor.'-'.$ordchar.'<br>';
|
||||||
if ($ordchar < 32 && $ordchar != 13 && $ordchar != 10) { $ok=0; break; }
|
if ($ordchar < 32 && $ordchar != 13 && $ordchar != 10) { $ok=0; break; }
|
||||||
if ($ordchar > 126 && $ordchar < 160) { $ok=0; break; }
|
elseif ($ordchar > 126 && $ordchar < 160) { $ok=0; break; }
|
||||||
|
elseif ($clean) {
|
||||||
|
$out.= $s[$scursor];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if ($clean) return $out;
|
||||||
return $ok;
|
return $ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return nb of lines of a clear text
|
* Return nb of lines of a clear text
|
||||||
*
|
*
|
||||||
|
|||||||
@ -667,6 +667,13 @@ if ($action == 'addcontainer')
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Clean some comment
|
// Clean some comment
|
||||||
|
//$tmpgeturl['content'] = dol_string_is_good_iso($tmpgeturl['content'], 1);
|
||||||
|
//$tmpgeturl['content'] = utf8_encode(utf8_decode($tmpgeturl['content']));
|
||||||
|
//$tmpgeturl['content'] = mb_convert_encoding($tmpgeturl['content'], 'UTF-8', 'UTF-8');
|
||||||
|
//$tmpgeturl['content'] = remove_bs($tmpgeturl['content']);
|
||||||
|
//$tmpgeturl['content'] = str_replace('$screen-md-max', 'auto', $tmpgeturl['content']);
|
||||||
|
|
||||||
|
//var_dump($tmpgeturl['content']);exit;
|
||||||
$tmpgeturl['content'] = preg_replace('/\/\*\s+CSS content[a-z\s]*\s+\*\//', '', $tmpgeturl['content']);
|
$tmpgeturl['content'] = preg_replace('/\/\*\s+CSS content[a-z\s]*\s+\*\//', '', $tmpgeturl['content']);
|
||||||
|
|
||||||
//dol_mkdir(dirname($filetosave));
|
//dol_mkdir(dirname($filetosave));
|
||||||
@ -694,7 +701,7 @@ if ($action == 'addcontainer')
|
|||||||
//$pagecsscontent.=$tmpgeturl['content']."\n";
|
//$pagecsscontent.=$tmpgeturl['content']."\n";
|
||||||
} catch (exception $e) {
|
} catch (exception $e) {
|
||||||
//echo "failed to compile lessc";
|
//echo "failed to compile lessc";
|
||||||
dol_syslog("Failed to compile the CSS ".$urltograbbis." that we caught, with lessc: ".$e->getMessage(), LOG_WARNING);
|
dol_syslog("Failed to compile the CSS from URL ".$urltograbbis." with lessc: ".$e->getMessage(), LOG_WARNING);
|
||||||
$pagecsscontent.=$tmpgeturl['content']."\n";
|
$pagecsscontent.=$tmpgeturl['content']."\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user