Added is_object()

This commit is contained in:
abraar
2010-12-06 15:12:37 +00:00
parent 4509ef59f1
commit cec620ff6b
12 changed files with 32 additions and 32 deletions

View File

@@ -290,7 +290,7 @@ class database extends database_base {
* @param $aKeys array of keys * @param $aKeys array of keys
* @return sql sentence * @return sql sentence
*/ */
public
public function generateAddKeysSQL($sTable, $indexName, $aKeys) { public function generateAddKeysSQL($sTable, $indexName, $aKeys) {
try { try {
$indexType = 'INDEX'; $indexType = 'INDEX';

View File

@@ -59,7 +59,7 @@ class Form extends XmlForm
function setDefaultValues( ) function setDefaultValues( )
{ {
foreach($this->fields as $name => $content) { foreach($this->fields as $name => $content) {
if (get_class($content) != '__PHP_Incomplete_Class') { if (is_object($content) && get_class($content) != '__PHP_Incomplete_Class') {
if (isset($content->defaultValue)) if (isset($content->defaultValue))
$this->values[$name] = $content->defaultValue; $this->values[$name] = $content->defaultValue;
else else
@@ -233,7 +233,7 @@ class Form extends XmlForm
} }
} }
foreach($this->fields as $k => $v){ foreach($this->fields as $k => $v){
if(get_class($this->fields[$k])!='__PHP_Incomplete_Class'){ if(is_object($this) && get_class($this->fields[$k])!='__PHP_Incomplete_Class'){
$this->fields[$k]->owner =& $this; $this->fields[$k]->owner =& $this;
} }
} }
@@ -493,7 +493,7 @@ class Form extends XmlForm
$rFields = Array(); $rFields = Array();
$missingFields = Array(); $missingFields = Array();
foreach ($this->fields as $o) { foreach ($this->fields as $o) {
if(property_exists(get_class($o), 'required')) { if (is_object($o) && property_exists(get_class($o), 'required')) {
if( $o->required == 1) { if( $o->required == 1) {
if (!in_array($o->name, $aNoRequiredByJS)) { if (!in_array($o->name, $aNoRequiredByJS)) {
array_push($rFields, $o->name); array_push($rFields, $o->name);

View File

@@ -2987,37 +2987,37 @@ class G
switch($format){ switch($format){
case '@firstName @lastName': case '@firstName @lastName':
$infoUser = ereg_replace('@firstName', $aUserInfo['USR_FIRSTNAME'], $format); $infoUser = str_replace('@firstName', $aUserInfo['USR_FIRSTNAME'], $format);
$infoUser = ereg_replace('@lastName', $aUserInfo['USR_LASTNAME'], $infoUser); $infoUser = str_replace('@lastName', $aUserInfo['USR_LASTNAME'], $infoUser);
break; break;
case '@firstName @lastName (@userName)': case '@firstName @lastName (@userName)':
$infoUser = ereg_replace('@firstName', $aUserInfo['USR_FIRSTNAME'], $format); $infoUser = str_replace('@firstName', $aUserInfo['USR_FIRSTNAME'], $format);
$infoUser = ereg_replace('@lastName', $aUserInfo['USR_LASTNAME'], $infoUser); $infoUser = str_replace('@lastName', $aUserInfo['USR_LASTNAME'], $infoUser);
$infoUser = ereg_replace('@userName', $aUserInfo['USR_USERNAME'], $infoUser); $infoUser = str_replace('@userName', $aUserInfo['USR_USERNAME'], $infoUser);
break; break;
case '@userName': case '@userName':
$infoUser = ereg_replace('@userName', $aUserInfo['USR_USERNAME'], $format); $infoUser = str_replace('@userName', $aUserInfo['USR_USERNAME'], $format);
break; break;
case '@userName (@firstName @lastName)': case '@userName (@firstName @lastName)':
$infoUser = ereg_replace('@userName', $aUserInfo['USR_USERNAME'], $format); $infoUser = str_replace('@userName', $aUserInfo['USR_USERNAME'], $format);
$infoUser = ereg_replace('@firstName', $aUserInfo['USR_FIRSTNAME'], $infoUser); $infoUser = str_replace('@firstName', $aUserInfo['USR_FIRSTNAME'], $infoUser);
$infoUser = ereg_replace('@lastName', $aUserInfo['USR_LASTNAME'], $infoUser); $infoUser = str_replace('@lastName', $aUserInfo['USR_LASTNAME'], $infoUser);
break; break;
case '@lastName @firstName': case '@lastName @firstName':
$infoUser = ereg_replace('@lastName', $aUserInfo['USR_LASTNAME'], $format); $infoUser = str_replace('@lastName', $aUserInfo['USR_LASTNAME'], $format);
$infoUser = ereg_replace('@firstName', $aUserInfo['USR_FIRSTNAME'], $infoUser); $infoUser = str_replace('@firstName', $aUserInfo['USR_FIRSTNAME'], $infoUser);
break; break;
case '@lastName, @firstName': case '@lastName, @firstName':
$infoUser = ereg_replace('@lastName', $aUserInfo['USR_LASTNAME'], $format); $infoUser = str_replace('@lastName', $aUserInfo['USR_LASTNAME'], $format);
$infoUser = ereg_replace('@firstName', $aUserInfo['USR_FIRSTNAME'], $infoUser); $infoUser = str_replace('@firstName', $aUserInfo['USR_FIRSTNAME'], $infoUser);
break; break;
case '@lastName, @firstName (@userName)': case '@lastName, @firstName (@userName)':
$infoUser = ereg_replace('@lastName', $aUserInfo['USR_LASTNAME'], $format); $infoUser = str_replace('@lastName', $aUserInfo['USR_LASTNAME'], $format);
$infoUser = ereg_replace('@firstName', $aUserInfo['USR_FIRSTNAME'], $infoUser); $infoUser = str_replace('@firstName', $aUserInfo['USR_FIRSTNAME'], $infoUser);
$infoUser = ereg_replace('@userName', $aUserInfo['USR_USERNAME'], $infoUser); $infoUser = str_replace('@userName', $aUserInfo['USR_USERNAME'], $infoUser);
break; break;
default : default :
$infoUser = ereg_replace('@userName', $aUserInfo['USR_USERNAME'], '@userName'); $infoUser = str_replace('@userName', $aUserInfo['USR_USERNAME'], '@userName');
break; break;
} }
return $infoUser; return $infoUser;

View File

@@ -318,7 +318,7 @@ class pagedTable
else else
trigger_Error('Warning: sql query is empty',E_USER_WARNING); trigger_Error('Warning: sql query is empty',E_USER_WARNING);
// Config attributes from XMLFORM file // Config attributes from XMLFORM file
$myAttributes=get_class_vars(get_class($this)); $myAttributes=get_class_vars(is_object($this) && get_class($this));
foreach ($this->xmlForm->xmlform->tree->attribute as $atrib => $value) foreach ($this->xmlForm->xmlform->tree->attribute as $atrib => $value)
if (array_key_exists( $atrib, $myAttributes)){ if (array_key_exists( $atrib, $myAttributes)){
eval('settype($value,gettype($this->'.$atrib.'));'); eval('settype($value,gettype($this->'.$atrib.'));');
@@ -637,8 +637,8 @@ class pagedTable
$this->xmlForm->setDefaultValues(); $this->xmlForm->setDefaultValues();
$this->xmlForm->setValues( $result ); $this->xmlForm->setValues( $result );
$this->xmlForm->fields[ $this->fields[$r]['Name'] ]->mode = 'view'; $this->xmlForm->fields[ $this->fields[$r]['Name'] ]->mode = 'view';
if ((array_search( 'rendergrid', get_class_methods( get_class($this->xmlForm->fields[ $this->fields[$r]['Name'] ])) )!==FALSE) if ((array_search( 'rendergrid', get_class_methods(is_object($this) && get_class($this->xmlForm->fields[ $this->fields[$r]['Name'] ])) )!==FALSE)
||(array_search( 'renderGrid', get_class_methods( get_class($this->xmlForm->fields[ $this->fields[$r]['Name'] ])) )!==FALSE)) { ||(array_search( 'renderGrid', get_class_methods(is_object($this) && get_class($this->xmlForm->fields[ $this->fields[$r]['Name'] ])) )!==FALSE)) {
$htmlField = $this->xmlForm->fields[ $this->fields[$r]['Name'] ]->renderGrid( array($value) , $this->xmlForm ); $htmlField = $this->xmlForm->fields[ $this->fields[$r]['Name'] ]->renderGrid( array($value) , $this->xmlForm );
$this->tpl->assign( "value" , $htmlField[0] ); $this->tpl->assign( "value" , $htmlField[0] );
} else { } else {

View File

@@ -75,7 +75,7 @@ class Xml_Node
*/ */
function addChildNode( $childNode ) function addChildNode( $childNode )
{ {
if (strcasecmp( get_class($childNode), 'Xml_Node' ) == 0 ) { if (is_object($childNode) && strcasecmp( get_class($childNode), 'Xml_Node' ) == 0 ) {
$this->type = 'open'; $this->type = 'open';
$childNode->parent = &$this; $childNode->parent = &$this;
$this->children[] = &$childNode; $this->children[] = &$childNode;

View File

@@ -194,7 +194,7 @@ class ymlTestCases
{ {
$results=array(); $results=array();
//$this->addToPlan( $count, $start ); //$this->addToPlan( $count, $start );
$functions=get_class_methods( get_class($testerObject) ); $functions=get_class_methods(is_object($testerObject) && get_class($testerObject) );
foreach($functions as $id=>$fn) foreach($functions as $id=>$fn)
$functions[$id]=strtolower($fn); $functions[$id]=strtolower($fn);
foreach($this->testCases as $index => $testCase){ foreach($this->testCases as $index => $testCase){

View File

@@ -1,7 +1,7 @@
<?php <?php
class LayoutEngine { class LayoutEngine {
function process(&$tree, &$media) { function process(&$tree, &$media) {
die("Oops. Inoverridden 'process' method called in ".get_class($this)); die("Oops. Inoverridden 'process' method called in ".is_object($this) && get_class($this));
} }
} }
?> ?>

View File

@@ -427,7 +427,7 @@ class Table extends XMLElement implements IDMethod {
$children = $this->inheritanceColumn->getChildren(); $children = $this->inheritanceColumn->getChildren();
$names = array(); $names = array();
for ($i = 0, $size=count($children); $i < $size; $i++) { for ($i = 0, $size=count($children); $i < $size; $i++) {
$names[] = get_class($children[$i]); $names[] = is_object($children[$i]) && get_class($children[$i]);
} }
return $names; return $names;
} }

View File

@@ -64,7 +64,7 @@ class DefaultPlatform implements Platform {
*/ */
public function getDatabaseType() public function getDatabaseType()
{ {
$clazz = get_class($this); $clazz = is_object($this) && get_class($this);
$pos = strpos($clazz, 'Platform'); $pos = strpos($clazz, 'Platform');
return strtolower(substr($clazz,0,$pos)); return strtolower(substr($clazz,0,$pos));
} }

View File

@@ -84,7 +84,7 @@ class PropelOMTask extends AbstractPropelDataModelTask {
$_f = new PhingFile($this->getOutputDirectory(), $path); $_f = new PhingFile($this->getOutputDirectory(), $path);
if ($overwrite || !$_f->exists()) { if ($overwrite || !$_f->exists()) {
$this->log("\t\t-> " . $builder->getClassname() . " [builder: " . get_class($builder) . "]"); $this->log("\t\t-> " . $builder->getClassname() . " [builder: " .is_object($builder) && get_class($builder) . "]");
$script = $builder->build(); $script = $builder->build();
file_put_contents($_f->getAbsolutePath(), $script); file_put_contents($_f->getAbsolutePath(), $script);
foreach($builder->getWarnings() as $warning) { foreach($builder->getWarnings() as $warning) {

View File

@@ -175,7 +175,7 @@ class PropelSQLTask extends AbstractPropelDataModelTask {
if (!$table->isSkipSql()) { if (!$table->isSkipSql()) {
$builder = DataModelBuilder::builderFactory($table, 'ddl'); $builder = DataModelBuilder::builderFactory($table, 'ddl');
$this->log("\t+ " . $table->getName() . " [builder: " . get_class($builder) . "]"); $this->log("\t+ " . $table->getName() . " [builder: " . is_object($builder) && get_class($builder) . "]");
$ddl .= $builder->build(); $ddl .= $builder->build();
foreach($builder->getWarnings() as $warning) { foreach($builder->getWarnings() as $warning) {
$this->log($warning, PROJECT_MSG_WARN); $this->log($warning, PROJECT_MSG_WARN);

View File

@@ -181,7 +181,7 @@ abstract class BaseObject {
*/ */
protected function log($msg, $priority = Propel::LOG_INFO) protected function log($msg, $priority = Propel::LOG_INFO)
{ {
return Propel::log(get_class($this) . ': ' . $msg, $priority); return Propel::log(is_object($this) && get_class($this) . ': ' . $msg, $priority);
} }
} }