Permalink
Browse files

fix is_a for 4.3.7+ due to php-core stupidity

  • Loading branch information...
roojs committed Aug 26, 2011
1 parent 79bf094 commit 56369a9796c46921fe7894b6d6a0458ace94292c
View
@@ -37,7 +37,7 @@
function HTML_Template_Flexy_is_a($obj, $class) // which f***wit depreciated is_a....
{
if (version_compare(phpversion(),"5","<")) {
- return is_a($obj, $class);
+ return is_object($obj) && is_a($obj, $class);
}
$test=false;
@@ -73,7 +73,7 @@ function factory($options)
function is_a($obj, $class) // which f***wit depreciated is_a....
{
if (version_compare(phpversion(),"5","<")) {
- return is_a($obj, $class);
+ return is_object($obj) && is_a($obj, $class);
}
$test=false;
@@ -116,7 +116,7 @@ function compile(&$flexy, $string=false)
require_once 'HTML/Template/Flexy/Token.php';
$res = HTML_Template_Flexy_Token::buildTokens($tokenizer);
- if (is_a($res, 'PEAR_Error')) {
+ if ($this->is_a($res, 'PEAR_Error')) {
return $res;
}
$_HTML_TEMPLATE_FLEXY_COMPILER['cache'][md5($data)] = $res;
@@ -125,15 +125,15 @@ function compile(&$flexy, $string=false)
// technically we shouldnt get here as we dont cache errors..
- if (is_a($res, 'PEAR_Error')) {
+ if ($this->is_a($res, 'PEAR_Error')) {
return $res;
}
// turn tokens into Template..
$data = $res->compile($this);
- if (is_a($data, 'PEAR_Error')) {
+ if ($this->is_a($data, 'PEAR_Error')) {
return $data;
}
@@ -244,7 +244,7 @@ function initializeTranslator() {
);
}
- if (is_a($this->options['Translation2'], 'Translation2')) {
+ if ($this->is_a($this->options['Translation2'], 'Translation2')) {
$this->options['Translation2']->setLang($this->options['locale']);
if(empty($this->_options['Translation2']['CommonPageID'])) {
@@ -357,14 +357,14 @@ function toString($element)
$ret = $element->value;
$add = $element->compileChildren($this);
- if (is_a($add, 'PEAR_Error')) {
+ if ($this->is_a($add, 'PEAR_Error')) {
return $add;
}
$ret .= $add;
if ($element->close) {
$add = $element->close->compile($this);
- if (is_a($add, 'PEAR_Error')) {
+ if ($this->is_a($add, 'PEAR_Error')) {
return $add;
}
$ret .= $add;
@@ -455,7 +455,7 @@ function toStringForeach($element)
{
$loopon = $element->toVar($element->loopOn);
- if (is_a($loopon, 'PEAR_Error')) {
+ if ($this->is_a($loopon, 'PEAR_Error')) {
return $loopon;
}
@@ -490,7 +490,7 @@ function toStringIf($element)
{
$var = $element->toVar($element->condition);
- if (is_a($var, 'PEAR_Error')) {
+ if ($this->is_a($var, 'PEAR_Error')) {
return $var;
}
@@ -577,7 +577,7 @@ function toStringVar($element)
// ignore modifier at present!!
$var = $element->toVar($element->value);
- if (is_a($var, 'PEAR_Error')) {
+ if ($this->is_a($var, 'PEAR_Error')) {
return $var;
}
list($prefix, $suffix) = $this->getModifierWrapper($element);
@@ -618,7 +618,7 @@ function toStringMethod($element)
$object = implode('.', $bits);
$var = $element->toVar($object);
- if (is_a($var, 'PEAR_Error')) {
+ if ($this->is_a($var, 'PEAR_Error')) {
return $var;
}
@@ -633,7 +633,7 @@ function toStringMethod($element)
}
- if (is_a($var, 'PEAR_Error')) {
+ if ($this->is_a($var, 'PEAR_Error')) {
return $var;
}
@@ -659,7 +659,7 @@ function toStringMethod($element)
}
$var = $element->toVar($a);
- if (is_a($var, 'PEAR_Error')) {
+ if ($this->is_a($var, 'PEAR_Error')) {
return $var;
}
$ret .= $var;
@@ -839,7 +839,7 @@ function translateString($string)
return $string;
}
- if (is_a($this->options['Translation2'], 'Translation2')) {
+ if ($this->is_a($this->options['Translation2'], 'Translation2')) {
$result = $this->options['Translation2']->get($string);
if (!empty($result)) {
return $result;
@@ -106,7 +106,7 @@ function toJavascriptToString($element)
$v = substr($v,1,-1);
$ret .= $this->compiler->appendPhp(
'$__tmp = HTML_Javascript_Convert::convertVar('.$element->toVar($v) .',\''.$prefix . $k.'\',true);'.
- 'echo (is_a($__tmp,"PEAR_Error")) ? ("<pre>".print_r($__tmp,true)."</pre>") : $__tmp;');
+ 'echo (is_object($__tmp) && is_a($__tmp,"PEAR_Error")) ? ("<pre>".print_r($__tmp,true)."</pre>") : $__tmp;');
$ret .= $this->compiler->appendHTML("\n");
}
$ret .= $this->compiler->appendHTML("</script>");
@@ -202,9 +202,9 @@ function includeToString($element)
}
} else {
//it's a variable
- if (is_a($item, 'HTML_Template_Flexy_Token_Var')) {
+ if (is_object($item) && is_a($item, 'HTML_Template_Flexy_Token_Var')) {
$value = $item->toVar($item->value);
- if (is_a($value, 'PEAR_Error')) {
+ if (is_object($value) && is_a($value, 'PEAR_Error')) {
return $value;
}
$string .= "{{$value}}";
@@ -302,7 +302,7 @@ function functionToString($element)
// that the {xxx} element is item 1 in the list...
$e=$element->ucAttributes['CALL'][1];
$add = $e->toVar($e->value);
- if (is_a($add,'PEAR_Error')) {
+ if (is_object($add) && is_a($add,'PEAR_Error')) {
return $add;
}
return $this->compiler->appendPHP(
@@ -186,7 +186,7 @@ function toString($element)
$add = $this->toStringOpenTag($element,$ret);
- if (is_a($add,'PEAR_Error')) {
+ if (is_object($add) && is_a($add,'PEAR_Error')) {
return $add;
}
@@ -199,15 +199,15 @@ function toString($element)
if ($element->postfix) {
foreach ($element->postfix as $e) {
$add = $e->compile($this->compiler);
- if (is_a($add,'PEAR_Error')) {
+ if (is_object($add) && is_a($add,'PEAR_Error')) {
return $add;
}
$ret .= $add;
}
} else if ($this->element->postfix) { // if postfixed by self..
foreach ($this->element->postfix as $e) {
$add = $e->compile($this->compiler);
- if (is_a($add,'PEAR_Error')) {
+ if (is_object($add) && is_a($add,'PEAR_Error')) {
return $add;
}
@@ -217,11 +217,11 @@ function toString($element)
$tmp = $this->toStringChildren($element,$ret);
- if (is_a($tmp,'PEAR_Error')) {
+ if (is_object($tmp) && is_a($tmp,'PEAR_Error')) {
return $tmp;
}
$tmp = $this->toStringCloseTag($element,$ret);
- if (is_a($tmp,'PEAR_Error')) {
+ if (is_object($tmp) && is_a($tmp,'PEAR_Error')) {
return $tmp;
}
@@ -285,7 +285,7 @@ function toStringOpenTag(&$element,&$ret)
null, HTML_TEMPLATE_FLEXY_ERROR_DIE);
}
$add = $v[1]->compile($this->compiler);
- if (is_a($add,'PEAR_Error')) {
+ if (is_object($add) && is_a($add,'PEAR_Error')) {
return $add;
}
$ret .= ' ' . $add;
@@ -316,7 +316,7 @@ function toStringOpenTag(&$element,&$ret)
if (is_object($v)) {
$add = $v->compile($this->compiler);
- if (is_a($add,'PEAR_Error')) {
+ if (is_object($add) && is_a($add,'PEAR_Error')) {
return $add;
}
@@ -337,7 +337,7 @@ function toStringOpenTag(&$element,&$ret)
continue;
}
$add = $item->compile($this->compiler);
- if (is_a($add,'PEAR_Error')) {
+ if (is_object($add) && is_a($add,'PEAR_Error')) {
return $add;
}
$ret .= $add;
@@ -374,7 +374,7 @@ function toStringChildren(&$element,&$ret)
return;
}
$add = $element->compileChildren($this->compiler);
- if (is_a($add,'PEAR_Error')) {
+ if (is_object($add) && is_a($add,'PEAR_Error')) {
return $add;
}
$ret .= $add;
@@ -398,7 +398,7 @@ function toStringCloseTag(&$element,&$ret)
if ((! empty($element->tag)) && (! empty($element->oTag)))
{
$add = $element->close->compile($this->compiler);
- if (is_a($add,'PEAR_Error')) {
+ if (is_object($add) && is_a($add,'PEAR_Error')) {
return $add;
}
$ret .= $add;
@@ -411,7 +411,7 @@ function toStringCloseTag(&$element,&$ret)
if ($element->close->postfix) {
foreach ($element->close->postfix as $e) {
$add = $e->compile($this->compiler);
- if (is_a($add,'PEAR_Error')) {
+ if (is_object($add) && is_a($add,'PEAR_Error')) {
return $add;
}
$ret .= $add;
@@ -421,7 +421,7 @@ function toStringCloseTag(&$element,&$ret)
if ($this->element->close->postfix) { // if postfixed by self..
foreach ($this->element->close->postfix as $e) {
$add = $e->compile($this->compiler);
- if (is_a($add,'PEAR_Error')) {
+ if (is_object($add) && is_a($add,'PEAR_Error')) {
return $add;
}
@@ -765,7 +765,7 @@ function getElementPhp($id,$mergeWithName=false,$varsOnly = false) {
for($i =1; $i < count($ar) -1; $i++) {
switch(true) {
- case is_a($ar[$i], 'HTML_Template_Flexy_Token_Var'):
+ case (is_object($ar[$i) && is_a($ar[$i], 'HTML_Template_Flexy_Token_Var')):
$str .= '. ' . $ar[$i]->toVar($ar[$i]->value). ' ';
break;
case is_string($ar[$i]):
@@ -824,7 +824,7 @@ function getElementPhp($id,$mergeWithName=false,$varsOnly = false) {
}
$var = $item->toVar($item->value);
- if (is_a($var, 'PEAR_Error')) {
+ if (is_object($var) && is_a($var, 'PEAR_Error')) {
return $var;
}
list($prefix,$suffix) = $this->compiler->getModifierWrapper($item);
@@ -1092,7 +1092,7 @@ function parseTagLabel()
$for = $this->element->getAttribute('FOR');
$ret = '';
$tmp = $this->toStringChildren($this->element, $ret);
- if (is_a($tmp,'PEAR_Error')) {
+ if (is_object($tmp) && is_a($tmp,'PEAR_Error')) {
return $tmp;
}
@@ -1272,6 +1272,9 @@ function parseXulTag()
function elementUsesDynamic($e)
{
+ if (!is_object($e)) {
+ return false;
+ }
if (is_a($e,'HTML_Template_Flexy_Token_Var')) {
return true;
}
Oops, something went wrong.

0 comments on commit 56369a9

Please sign in to comment.