当前位置: 首页>>代码示例>>PHP>>正文


PHP QApplication::SetErrorHandler方法代码示例

本文整理汇总了PHP中QApplication::SetErrorHandler方法的典型用法代码示例。如果您正苦于以下问题:PHP QApplication::SetErrorHandler方法的具体用法?PHP QApplication::SetErrorHandler怎么用?PHP QApplication::SetErrorHandler使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QApplication的用法示例。


在下文中一共展示了QApplication::SetErrorHandler方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: MakeDirectory

 /**
  * Same as mkdir but correctly implements directory recursion.
  * At its core, it will use the php MKDIR function.
  * This method does no special error handling.  If you want to use special error handlers,
  * be sure to set that up BEFORE calling MakeDirectory.
  *
  * @param         string  $strPath actual path of the directoy you want created
  * @param         integer $intMode optional mode
  *
  * @return         boolean        the return flag from mkdir
  */
 public static function MakeDirectory($strPath, $intMode = null)
 {
     if (is_dir($strPath)) {
         // Directory Already Exists
         return true;
     }
     // Check to make sure the parent(s) exist, or create if not
     if (!self::MakeDirectory(dirname($strPath), $intMode)) {
         return false;
     }
     if (PHP_OS != "Linux") {
         // Create the current node/directory, and return its result
         $blnReturn = mkdir($strPath);
         if ($blnReturn && !is_null($intMode)) {
             // Manually CHMOD to $intMode (if applicable)
             // mkdir doesn't do it for mac, and this will error on windows
             // Therefore, ignore any errors that creep up
             QApplication::SetErrorHandler(null);
             chmod($strPath, $intMode);
             QApplication::RestoreErrorHandler();
         }
     } else {
         $blnReturn = mkdir($strPath, $intMode);
     }
     return $blnReturn;
 }
开发者ID:vaibhav-kaushal,项目名称:qc-framework,代码行数:37,代码来源:QFolder.class.php

示例2: __construct

 public function __construct($mixValue = null, DateTimeZone $objTimeZone = null)
 {
     // Cloning from another QDateTime object
     if ($mixValue instanceof QDateTime) {
         if ($objTimeZone) {
             throw new QCallerException('QDateTime cloning cannot take in a DateTimeZone parameter');
         }
         parent::__construct($mixValue->format(DateTime::ISO8601));
         $this->blnDateNull = $mixValue->IsDateNull();
         $this->blnTimeNull = $mixValue->IsTimeNull();
         // Subclassing from a PHP DateTime object
     } else {
         if ($mixValue instanceof DateTime) {
             if ($objTimeZone) {
                 throw new QCallerException('QDateTime subclassing of a DateTime object cannot take in a DateTimeZone parameter');
             }
             parent::__construct($mixValue->format(DateTime::ISO8601));
             // By definition, a DateTime object doesn't have anything nulled
             $this->blnDateNull = false;
             $this->blnTimeNull = false;
             // Using "Now" constant
         } else {
             if (strtolower($mixValue) == QDateTime::Now) {
                 if ($objTimeZone) {
                     parent::__construct('now', $objTimeZone);
                 } else {
                     parent::__construct('now');
                 }
                 $this->blnDateNull = false;
                 $this->blnTimeNull = false;
                 // Null or No Value
             } else {
                 if (!$mixValue) {
                     // Set to "null date"
                     // And Do Nothing Else -- Default Values are already set to Nulled out
                     if ($objTimeZone) {
                         parent::__construct('2000-01-01 00:00:00', $objTimeZone);
                     } else {
                         parent::__construct('2000-01-01 00:00:00');
                     }
                     // Parse the Value string
                 } else {
                     $intTimestamp = null;
                     $blnValid = false;
                     QApplication::SetErrorHandler('QDateTimeErrorHandler');
                     try {
                         if ($objTimeZone) {
                             $blnValid = parent::__construct($mixValue, $objTimeZone);
                         } else {
                             $blnValid = parent::__construct($mixValue);
                         }
                     } catch (Exception $objExc) {
                     }
                     if ($blnValid !== false) {
                         $intTimestamp = parent::format('U');
                     }
                     QApplication::RestoreErrorHandler();
                     // Valid Value String
                     if ($intTimestamp) {
                         // To deal with "Tues" and date skipping bug in PHP 5.2
                         parent::__construct(date('Y-m-d H:i:s', parent::format('U')));
                         // We MUST assume that Date isn't null
                         $this->blnDateNull = false;
                         // Update Time Null Value if Time was Specified
                         if (strpos($mixValue, ':') !== false) {
                             $this->blnTimeNull = false;
                         }
                         // Timestamp-based Value string
                     } else {
                         if (is_numeric($mixValue)) {
                             if ($objTimeZone) {
                                 parent::__construct(date('Y-m-d H:i:s', $mixValue), $objTimeZone);
                             } else {
                                 parent::__construct(date('Y-m-d H:i:s', $mixValue));
                             }
                             $this->blnTimeNull = false;
                             $this->blnDateNull = false;
                             // Null Date
                         } else {
                             // Set to "null date"
                             // And Do Nothing Else -- Default Values are already set to Nulled out
                             if ($objTimeZone) {
                                 parent::__construct('2000-01-01 00:00:00', $objTimeZone);
                             } else {
                                 parent::__construct('2000-01-01 00:00:00');
                             }
                         }
                     }
                 }
             }
         }
     }
 }
开发者ID:heshuai64,项目名称:einv2,代码行数:93,代码来源:QDateTime.class.php

示例3: GenerateFile

 /**
  * Enter description here...
  *
  * @param string $strModuleName
  * @param string $strFilename
  * @param boolean $blnOverrideFlag whether we are using the _core template, or using a custom one
  * @param mixed[] $mixArgumentArray
  * @param boolean $blnSave wheather or not to actually perform the save
  * @return mixed returns the evaluated template or boolean save success.
  */
 public function GenerateFile($strModuleName, $strFilename, $blnOverrideFlag, $mixArgumentArray, $blnSave = true)
 {
     // Figure out the actual TemplateFilePath
     if ($blnOverrideFlag) {
         $strTemplateFilePath = __QCODO__ . QCodeGen::TemplatesPathCustom . $strModuleName . '/' . $strFilename;
     } else {
         $strTemplateFilePath = __QCODO_CORE__ . QCodeGen::TemplatesPath . $strModuleName . '/' . $strFilename;
     }
     // Setup Debug/Exception Message
     if (QCodeGen::DebugMode) {
         _p("Evaluating {$strTemplateFilePath}<br/>", false);
     }
     $strError = 'Template\'s first line must be <template OverwriteFlag="boolean" DocrootFlag="boolean" TargetDirectory="string" DirectorySuffix="string" TargetFileName="string"/>: ' . $strTemplateFilePath;
     // Check to see if the template file exists, and if it does, Load It
     if (!file_exists($strTemplateFilePath)) {
         throw new QCallerException('Template File Not Found: ' . $strTemplateFilePath);
     }
     $strTemplate = file_get_contents($strTemplateFilePath);
     // Evaluate the Template
     $strTemplate = $this->EvaluateTemplate($strTemplate, $strModuleName, $mixArgumentArray);
     // Parse out the first line (which contains path and overwriting information)
     $intPosition = strpos($strTemplate, "\n");
     if ($intPosition === false) {
         throw new Exception($strError);
     }
     $strFirstLine = trim(substr($strTemplate, 0, $intPosition));
     $strTemplate = substr($strTemplate, $intPosition + 1);
     $objTemplateXml = null;
     // Attempt to Parse the First Line as XML
     try {
         @($objTemplateXml = new SimpleXMLElement($strFirstLine));
     } catch (Exception $objExc) {
     }
     if (is_null($objTemplateXml) || !$objTemplateXml instanceof SimpleXMLElement) {
         throw new Exception($strError);
     }
     $blnOverwriteFlag = QType::Cast($objTemplateXml['OverwriteFlag'], QType::Boolean);
     $blnDocrootFlag = QType::Cast($objTemplateXml['DocrootFlag'], QType::Boolean);
     $strTargetDirectory = QType::Cast($objTemplateXml['TargetDirectory'], QType::String);
     $strDirectorySuffix = QType::Cast($objTemplateXml['DirectorySuffix'], QType::String);
     $strTargetFileName = QType::Cast($objTemplateXml['TargetFileName'], QType::String);
     if (is_null($blnOverwriteFlag) || is_null($strTargetFileName) || is_null($strTargetDirectory) || is_null($strDirectorySuffix) || is_null($blnDocrootFlag)) {
         throw new Exception($strError);
     }
     if ($blnSave && $strTargetDirectory) {
         // Figure out the REAL target directory
         if ($blnDocrootFlag) {
             $strTargetDirectory = __DOCROOT__ . $strTargetDirectory . $strDirectorySuffix;
         } else {
             $strTargetDirectory = $strTargetDirectory . $strDirectorySuffix;
         }
         // Create Directory (if needed)
         if (!is_dir($strTargetDirectory)) {
             if (!QApplication::MakeDirectory($strTargetDirectory, 0777)) {
                 throw new Exception('Unable to mkdir ' . $strTargetDirectory);
             }
         }
         // Save to Disk
         $strFilePath = sprintf('%s/%s', $strTargetDirectory, $strTargetFileName);
         if ($blnOverwriteFlag || !file_exists($strFilePath)) {
             $intBytesSaved = file_put_contents($strFilePath, $strTemplate);
             // CHMOD to full read/write permissions (applicable only to nonwindows)
             // Need to ignore error handling for this call just in case
             QApplication::SetErrorHandler(null);
             chmod($strFilePath, 0666);
             QApplication::RestoreErrorHandler();
             return $intBytesSaved == strlen($strTemplate);
         } else {
             // Becuase we are not supposed to overwrite, we should return "true" by default
             return true;
         }
     }
     // Why Did We Not Save?
     if ($blnSave) {
         // We WANT to Save, but Qcodo Configuration says that this functionality/feature should no longer be generated
         // By definition, we should return "true"
         return true;
     } else {
         // Running GenerateFile() specifically asking it not to save -- so return the evaluated template instead
         return $strTemplate;
     }
 }
开发者ID:kmcelhinney,项目名称:qcodo,代码行数:92,代码来源:QCodeGenBase.class.php

示例4: __construct

 public function __construct($mixValue = null, DateTimeZone $objTimeZone = null, $intType = QDateTime::UnknownType)
 {
     switch ($intType) {
         case QDateTime::DateOnlyType:
             if ($objTimeZone) {
                 parent::__construct($mixValue, $objTimeZone);
             } else {
                 parent::__construct($mixValue);
             }
             $this->blnTimeNull = true;
             $this->blnDateNull = false;
             $this->ReinforceNullProperties();
             return;
         case QDateTime::TimeOnlyType:
             if ($objTimeZone) {
                 parent::__construct($mixValue, $objTimeZone);
             } else {
                 parent::__construct($mixValue);
             }
             $this->blnTimeNull = false;
             $this->blnDateNull = true;
             $this->ReinforceNullProperties();
             return;
         case QDateTime::DateAndTimeType:
             if ($objTimeZone) {
                 parent::__construct($mixValue, $objTimeZone);
             } else {
                 parent::__construct($mixValue);
             }
             $this->blnTimeNull = false;
             $this->blnDateNull = false;
             return;
         default:
             break;
     }
     // Cloning from another QDateTime object
     if ($mixValue instanceof QDateTime) {
         if ($objTimeZone) {
             throw new QCallerException('QDateTime cloning cannot take in a DateTimeZone parameter');
         }
         if ($mixValue->GetTimeZone()->GetName() == date_default_timezone_get()) {
             parent::__construct($mixValue->format('Y-m-d H:i:s'));
         } else {
             parent::__construct($mixValue->format(DateTime::ISO8601));
         }
         $this->blnDateNull = $mixValue->IsDateNull();
         $this->blnTimeNull = $mixValue->IsTimeNull();
         // Subclassing from a PHP DateTime object
     } else {
         if ($mixValue instanceof DateTime) {
             if ($objTimeZone) {
                 throw new QCallerException('QDateTime subclassing of a DateTime object cannot take in a DateTimeZone parameter');
             }
             parent::__construct($mixValue->format(DateTime::ISO8601));
             // By definition, a DateTime object doesn't have anything nulled
             $this->blnDateNull = false;
             $this->blnTimeNull = false;
             // Using "Now" constant
         } else {
             if (strtolower($mixValue) == QDateTime::Now) {
                 if ($objTimeZone) {
                     parent::__construct('now', $objTimeZone);
                 } else {
                     parent::__construct('now');
                 }
                 $this->blnDateNull = false;
                 $this->blnTimeNull = false;
                 // Null or No Value
             } else {
                 if (!$mixValue) {
                     // Set to "null date"
                     // And Do Nothing Else -- Default Values are already set to Nulled out
                     if ($objTimeZone) {
                         parent::__construct('2000-01-01 00:00:00', $objTimeZone);
                     } else {
                         parent::__construct('2000-01-01 00:00:00');
                     }
                     // Parse the Value string
                 } else {
                     $strTimeISO8601 = null;
                     $blnValid = false;
                     QApplication::SetErrorHandler('QDateTimeErrorHandler');
                     try {
                         if ($objTimeZone) {
                             $blnValid = parent::__construct($mixValue, $objTimeZone);
                         } else {
                             $blnValid = parent::__construct($mixValue);
                         }
                     } catch (Exception $objExc) {
                     }
                     if ($blnValid !== false) {
                         $strTimeISO8601 = parent::format(DateTime::ISO8601);
                     }
                     QApplication::RestoreErrorHandler();
                     // Valid Value String
                     if ($strTimeISO8601) {
                         // To deal with "Tues" and date skipping bug in PHP 5.2
                         if ($strTimeISO8601 != $mixValue) {
                             parent::__construct($strTimeISO8601);
                         }
//.........这里部分代码省略.........
开发者ID:hiptc,项目名称:dle2wordpress,代码行数:101,代码来源:QDateTime.class.php

示例5: setGeneratedFilePermissions

 /**
  * Sets the file permissions (Linux only) for a file generated by the Code Generator
  * @param string $strFilePath Path of the generated file
  *
  * @throws QCallerException
  */
 protected function setGeneratedFilePermissions($strFilePath)
 {
     // CHMOD to full read/write permissions (applicable only to nonwindows)
     // Need to ignore error handling for this call just in case
     if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') {
         QApplication::SetErrorHandler(null);
         chmod($strFilePath, 0666);
         QApplication::RestoreErrorHandler();
     }
 }
开发者ID:vaibhav-kaushal,项目名称:qc-framework,代码行数:16,代码来源:QCodeGenBase.class.php


注:本文中的QApplication::SetErrorHandler方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。