/** Check params. * @var array $params */ function _checkParams(&$params) { foreach ($this->__args as $name => $val) { // Deal with unfilled parameters if (!isset($params[$name]) || empty($params[$name])) { // Set default val if available if (!empty($this->__args[$name]['DEFAULT'])) { $params[$name] = $this->__args[$name]['DEFAULT']; } else { $errstack =& PEAR_ErrorStack::singleton($this->__module); $errstack->push(MB_MISSING_ACTION_ARG, 'error', array('name' => $name)); return null; } } else { if (isset($this->__args[$name]['REGEX'])) { if (!preg_match($this->__args[$name]['REGEX'], $params[$name])) { $errstack =& PEAR_ErrorStack::singleton($this->__module); $errstack->push(MB_INVALID_ACTION_ARG, 'error', array('module' => $this->__module, 'action' => $this->__name, 'name' => $name, 'val' => $params[$name], 'regex' => $this->__args[$name]['REGEX'], 'default' => $this->__args[$name]['DEFAULT'])); return null; } } } } return true; }
/** Renvoie le chemin vers le module. * @param string $module_name */ function _getModuleClassPath($module_name) { $path = MB_CONF_PREFIX . "/phplib/modules/{$module_name}/{$module_name}.php"; if (!file_exists($path)) { $errstack =& PEAR_ErrorStack::singleton('MicroBuilder'); $errstack->push(MB_NONEXISTENT_MODULE, 'error', array('module' => $module_name)); return null; } return $path; }
/** Renvoie le chemin vers l'action. */ function _getActionClassPath($module_name, $action_name) { $path = MB_CONF_PREFIX . "/phplib/modules/{$module_name}/actions/{$action_name}.php"; if (!file_exists($path)) { $errstack =& PEAR_ErrorStack::singleton($module_name); $errstack->push(MB_NONEXISTENT_ACTION, 'error', array('module' => $module_name, 'action' => $action_name, 'file' => $path)); return null; } return $path; }
/** Returns theme class path * @param string $theme_name */ function _getThemeClassPath($theme_name) { $path = MB_CONF_PREFIX . "/phplib/themes/{$theme_name}/{$theme_name}.php"; if (!file_exists($path)) { $errstack =& PEAR_ErrorStack::singleton('MicroBuilder'); $errstack->push(MB_NONEXISTENT_THEME, 'fatal', array('theme' => $theme_name, 'path' => $path)); return null; } return $path; }
/** ErrorCallback */ function errorCallback($err) { switch ($err['level']) { case 'error': break; case 'fatal': $mbstack =& PEAR_ErrorStack::singleton('MicroBuilder'); $mbstack->push(5, 'error', array(), "Fatal error during module execution"); break; } }
/** * PHP5 type constructor */ function __construct() { global $wpdb; //get the PhotoQ error stack for easy access $this->_errStack =& PEAR_ErrorStack::singleton('PhotoQ'); PhotoQHelper::debug('-----------start plugin-------------'); // load text domain for localization load_plugin_textdomain('PhotoQ', '', 'photoq-photoblog-plugin/lang'); // set names of database tables used and created by photoq $this->QUEUEMETA_TABLE = $wpdb->prefix . "photoqmeta"; $this->QUEUE_TABLE = $wpdb->prefix . "photoq"; $this->QFIELDS_TABLE = $wpdb->prefix . "photoqfields"; $this->QCAT_TABLE = $wpdb->prefix . "photoq2cat"; $this->POSTS_TABLE = $wpdb->prefix . "posts"; // setting up database $this->_db =& PhotoQSingleton::getInstance('PhotoQDB'); // setting up options $this->_oc =& PhotoQSingleton::getInstance('PhotoQOptionController'); $this->_autoUpgrade(); //creating queue $this->_queue =& PhotoQSingleton::getInstance('PhotoQQueue'); // actions and filters are next // Insert the _actionAddAdminPages() sink into the plugin hook list for 'admin_menu' add_action('admin_menu', array(&$this, '_actionAddAdminPages')); // function executed when a post is deleted add_action('delete_post', array(&$this, '_actionCleanUp')); // Hook into the 'wp_dashboard_setup' action to setup the photoq dashboard widget add_action('wp_dashboard_setup', array(&$this, '_actionAddDashboardWidget')); add_action('admin_print_styles-index.php', array(&$this, '_actionEnqueueDashboardStyles'), 1); // the next two hooks are used to show a thumb in the manage post section add_filter('manage_posts_columns', array(&$this, '_filterAddThumbToListOfPosts')); add_action('manage_posts_custom_column', array(&$this, '_actionInsertThumbIntoListOfPosts'), 10, 2); // filter to show change photo form in post editing add_filter('edit_form_advanced', array(&$this, '_filterShowChangePostedPhotoBox')); // Only show description in content field when editing add_filter('edit_post_content', array(&$this, '_filterPrepareEditorContent'), 100, 2); // Get description back add_filter('wp_insert_post_data', array(&$this, '_filterPostProcessEditedPost'), 100, 2); register_activation_hook(PHOTOQ_PATH . 'whoismanu-photoq.php', array(&$this, 'activatePlugin')); register_deactivation_hook(PHOTOQ_PATH . 'whoismanu-photoq.php', array(&$this, 'deactivatePlugin')); add_filter('favorite_actions', array(&$this, '_filterAddFavoriteActions')); add_filter('contextual_help', array(&$this, '_filterAddContextualHelp'), 100, 2); /*foreach( $_POST as $key => $value){ PhotoQHelper::debug("POST $key: ".print_r($value,true)." <br />"); } foreach( $_GET as $key => $value){ PhotoQHelper::debug("GET $key: ".print_r($value,true)." <br />"); } */ PhotoQHelper::debug('leave __construct()'); }
/** * PHP5 type constructor * * @access public */ function __construct() { parent::__construct("wimpq_options", new PhotoQRenderOptionVisitor()); //get the PhotoQ error stack for easy access and set it up properly $this->_errStack =& PEAR_ErrorStack::singleton('PhotoQ'); //get alternative original identifier if available $originalID = get_option("wimpq_originalFolder"); if ($originalID) { $this->ORIGINAL_IDENTIFIER = $originalID; } //establish default options $this->_defineAndRegisterOptions(); //localize strings in js scripts etc. of option controller $this->localizeStrings(array("switchLinkLabel" => __('Switch Sides', 'PhotoQ'))); }
/** * PHP5 type constructor * * @access public */ function __construct() { global $wpdb; //get the PhotoQ error stack for easy access $this->_errStack =& PEAR_ErrorStack::singleton('PhotoQ'); // set wordpress database $this->_wpdb =& $wpdb; // some methods need access to options so instantiate an OptionController $this->_oc =& PhotoQSingleton::getInstance('PhotoQOptionController'); // set names of database tables used and created by photoq $this->QUEUEMETA_TABLE = $wpdb->prefix . "photoqmeta"; $this->QUEUE_TABLE = $wpdb->prefix . "photoq"; $this->QFIELDS_TABLE = $wpdb->prefix . "photoqfields"; $this->QCAT_TABLE = $wpdb->prefix . "photoq2cat"; $this->QBATCH_TABLE = $wpdb->prefix . "photoqbatch"; // set names of wordpress database tables used by photoq $this->POSTS_TABLE = $wpdb->prefix . "posts"; $this->POSTMETA_TABLE = $wpdb->prefix . "postmeta"; }
/** * PHP5 type constructor */ function __construct($id, $title, $descr, $exif, $path, $imgname, $tags = '', $slug = '', $edited = false) { //get the PhotoQ error stack for easy access $this->_errStack =& PEAR_ErrorStack::singleton('PhotoQ'); //get the other singletons $this->_oc =& PhotoQSingleton::getInstance('PhotoQOptionController'); $this->_db =& PhotoQSingleton::getInstance('PhotoQDB'); $this->id = $id; $this->imgname = $imgname; $this->_tags = $tags; $this->title = $title; $this->descr = $descr; $this->exif = maybe_unserialize($exif); if (empty($path)) { $this->_path = $this->_oc->getQDir() . $this->imgname; } else { $this->_path = $path; } //mute this one because it can issue warnings if the original does not exist. @$this->initImageSizes(); }
function __construct(&$context, $id = NULL) { //get the PhotoQ error stack for easy access $this->_errStack =& PEAR_ErrorStack::singleton('PhotoQ'); $this->_db =& PhotoQSingleton::getInstance('PhotoQDB'); if (is_null($id)) { //create a new empty BatchProcessor //PhotoQHelper::debug('creating empty BatchProcessor'); $this->_batchSets = array(); $this->_totalSets = 0; $this->_id = $id; //no id yet } else { //load it from the database //PhotoQHelper::debug('creating BatchProcessor no:' . $id); $this->_context =& $context; $this->load($id); //PhotoQHelper::debug('sets from db: ' . print_r($this->_batchSets,true)); } //at the end of script execution we need to make the batch persistent //such that execution can go on in the next request register_shutdown_function(array(&$this, '_makeBatchPersistent')); }
/** * Initialize an object wrapper for a Subversion subcommand. * * @return mixed object on success, false on failure * @access public */ function init($command, $options) { // Check for shortcuts for commands $shortcuts = VersionControl_SVN::fetchShortcuts(); if (isset($options['shortcuts']) && is_array($options['shortcuts'])) { foreach ($options['shortcuts'] as $key => $val) { $shortcuts[strtolower($key)] = $val; } } $cmd = isset($shortcuts[strtolower($command)]) ? $shortcuts[strtolower($command)] : $command; $lowercmd = strtolower($cmd); $cmd = ucfirst($lowercmd); $class = 'VersionControl_SVN_' . $cmd; if (include_once realpath(dirname(__FILE__)) . "/SVN/{$cmd}.php") { if (class_exists($class)) { $obj =& new $class(); $obj->options = $options; $obj->_svn_cmd = $lowercmd; $obj->_stack =& PEAR_ErrorStack::singleton('VersionControl_SVN'); $obj->_stack->setErrorMessageTemplate(VersionControl_SVN::declareErrorMessages()); $obj->setOptions($options); return $obj; } } PEAR_ErrorStack::staticPush('VersionControl_SVN', VERSIONCONTROL_SVN_ERROR_UNKNOWN_CMD, 'error', array('command' => $command, 'options' => $options)); return false; }
/** * Returns the error-stack * * @static * @access public * @return object PEAR_ErrorStack error-stack */ function &getErrorStack() { return PEAR_ErrorStack::singleton('Date_Holidays', false, false, true); }
/** * * @param bool|log boolean value to denote if the debug mode should be enabled, or instance of a PEAR_ErrorStack compatible Log object * @return LiveUser_Admin * * @access public * @see init */ function LiveUser_Admin(&$debug) { $this->stack =& PEAR_ErrorStack::singleton('LiveUser_Admin'); if ($debug) { $log =& LiveUser::PEARLogFactory($debug); if ($log) { $this->log =& $log; $this->stack->setLogger($this->log); } } $this->stack->setErrorMessageTemplate($this->_errorMessages); }
/** * Constructor * * @access protected * @param mixed configuration array * @return void */ function LiveUser_Perm_Storage() { $this->_stack =& PEAR_ErrorStack::singleton('LiveUser'); }
/** * Constructeur DocInfos */ function DocInfos(&$db) { $this->db =& $db; $this->errors =& PEAR_ErrorStack::singleton('OpenWeb::Backend::DocInfos'); }
/** * Constructor. Use the factory or singleton methods. * * @param bool|object $debug Boolean that indicates if a log instance * should be created or an instance of a class * that implements the PEAR:Log interface. * @return void * @access protected * @see LiveUser::factory * @see LiveUser::singleton */ function LiveUser(&$debug) { $this->stack =& PEAR_ErrorStack::singleton('LiveUser'); if ($debug) { $log =& LiveUser::PEARLogFactory($debug); if ($log) { $this->log =& $log; $this->stack->setLogger($this->log); } } $this->stack->setErrorMessageTemplate($this->_errorMessages); $this->dispatcher =& Event_Dispatcher::getInstance(); }
function DocumentType($typeid = null) { $this->db =& $GLOBALS['db']; $this->id = null; $this->libelle = ''; $this->repertoire = ''; $this->isintro = false; $this->accroche = false; $this->max = array(); $this->min = array(); $this->total_max = -1; $this->total_min = 0; $this->errors =& PEAR_ErrorStack::singleton('OpenWeb_Backend_DocumentType'); if ($typeid) { $this->load($typeid); } }
/** * Constructor * * @param mixed $db SQLiteDatabase のインスタンス or データベースのパス * @param array $options キャッシュ設定オプション (optional) * @throws Cache_SQLiteException * @access public */ public function __construct($db = ':memory:', $options = array()) { // エラー管理オブジェクトを用意 $this->_stack = PEAR_ErrorStack::singleton('Cache_SQLite'); // オプションを設定 $constOptions = array('debug', 'strict', 'autoCreateTable', 'autoVacuum'); foreach ($this->_defaults as $key => $value) { $propName = '_' . $key; $this->{$propName} = $value; if (isset($options[$key])) { if ($key == 'table') { $this->{$propName} = (string) $options[$key]; } elseif (in_array($key, $constOptions)) { $this->{$propName} = (bool) $options[$key]; } else { $this->setOption($key, $options[$key]); } } } $this->_tableQuoted = self::_quoteIdentifier($this->_table); $this->_validFromat = self::SERIALIZE_PHP | self::ENCODE_BASE64 | self::ENCODE_ZLIB_BINARY; // データベースをオープン $errmsg = ''; if ($db instanceof SQLiteDatabase) { $this->_db = $db; } else { if ($db == ':memory:' || File_Util::isAbsolute($db)) { $path = $db; } else { $path = File_Util::realPath($db); } $this->_db = new SQLiteDatabase($path, CACHE_SQLITE_FILE_MODE, $errmsg); } if ($errmsg == '') { $this->_inTransaction = false; if ($this->_autoCreateTable) { $this->_checkTable(); } } else { $params = array('message' => $errmsg); $msg = 'sqlite_open() failed: %message%'; $this->_stack->push(self::ERR_CRITICAL, 'error', $params, $msg); throw new Cache_SQLiteException('Cache_SQLite sqlite_open() failed: {$errmsg}', self::ERR_CRITICAL); } }
/** * Get an instance of PEAR_ErrorStack. * * @return object PEAR_ErrorStack * @access public * @static */ public static function getStack() { if (!self::$_stack) { self::$_stack =& PEAR_ErrorStack::singleton('Services_HyperEstraier'); } return self::$_stack; }
/** * Get an instance of PEAR_ErrorStack. * * @return object PEAR_ErrorStack * @access public * @static */ function &getStack() { static $stack = null; if (!$stack) { $stack =& PEAR_ErrorStack::singleton('EstraierPure'); } return $stack; }
/** * Constructor * * @return void * * @access protected */ function LiveUser_Admin_Perm_Simple() { // Create the error stack, retrieve the errors using LiveUser_Admin->getErrors(). $this->stack =& PEAR_ErrorStack::singleton('LiveUser_Admin'); }
/** * Constructor * * @access protected * @return void */ function LiveUser_Admin_Storage() { $this->stack =& PEAR_ErrorStack::singleton('LiveUser_Admin'); }
} /** * Terminate execution abnormally. */ protected static function abend($code) { // do a hard rollback of any pending transactions // if we've come here, its because of some unexpected PEAR errors CRM_Core_Transaction::forceRollbackIfEnabled(); CRM_Utils_System::civiExit($code); } /** * @param array $error * @param int $type * * @return bool */ public static function isAPIError($error, $type = CRM_Core_Error::FATAL_ERROR) { if (is_array($error) && !empty($error['is_error'])) { $code = $error['error_message']['code']; if ($code == $type) { return TRUE; } } return FALSE; } } $e = new PEAR_ErrorStack('CRM'); $e->singleton('CRM', FALSE, NULL, 'CRM_Core_Error');
/** * Class constructor. Feel free to override in backend subclasses. * * @access protected */ function LiveUser_Admin_Auth_Common() { $this->stack =& PEAR_ErrorStack::singleton('LiveUser_Admin'); }
/** * Executes the constructed VersionControl_SVN instance * * @param array Additional arguments to pass to SVN. * @param array Switches to pass to SVN. * @return string Output generated by SVN. */ protected function run($args = array(), $switches = array()) { $svnstack = PEAR_ErrorStack::singleton('VersionControl_SVN'); $tempArgs = $this->svnArgs; $tempArgs = array_merge($tempArgs, $args); $tempSwitches = $this->svnSwitches; $tempSwitches = array_merge($tempSwitches, $switches); if ($output = $this->svn->run($tempArgs, $tempSwitches)) { return $output; } else { if (count($errs = $svnstack->getErrors())) { $err = current($errs); throw new BuildException("Failed to run the 'svn " . $this->mode . "' command: " . $err['params']['errstr']); } } }
/** * Clears the error stack for the package. * * @see PEAR_ErrorStack::getErrors() */ function clearErrors() { $stack =& PEAR_ErrorStack::singleton('Piece_Unity'); $stack->getErrors(true); }
/** * Get an instance of PEAR_ErrorStack. * * @return object PEAR_ErrorStack * @access public * @static */ function &errorstack() { $stack =& PEAR_ErrorStack::singleton('EstraierPure'); return $stack; }
/** * Initialize Error Stack engine * * @param array $prefs hash of params for PEAR::Log object list * * @return void * @since 0.3.3 * @access private */ function _initErrorStack($prefs = array()) { $this->_package = 'HTML_CSS'; $stack = PEAR_ErrorStack::singleton($this->_package); if (isset($prefs['pushCallback']) && is_callable($prefs['pushCallback'])) { $cb = $prefs['pushCallback']; } else { $cb = array('HTML_CSS', '_handleError'); } $stack->pushCallback($cb); if (isset($prefs['msgCallback'])) { $cb = $prefs['msgCallback']; } else { $cb = array('HTML_CSS', '_msgCallback'); } $stack->setMessageCallback($cb); if (isset($prefs['contextCallback'])) { $stack->setContextCallback($prefs['contextCallback']); } $messages = $this->_getErrorMessage(); $stack->setErrorMessageTemplate($messages); $composite =& Log::singleton('composite'); $stack->setLogger($composite); $drivers = isset($prefs['handler']) ? $prefs['handler'] : array(); $display_errors = isset($prefs['display_errors']) ? strtolower($prefs['display_errors']) : 'on'; $log_errors = isset($prefs['log_errors']) ? strtolower($prefs['log_errors']) : 'on'; foreach ($drivers as $handler => $params) { if (strtolower($handler) == 'display' && $display_errors == 'off') { continue; } if (strtolower($handler) != 'display' && $log_errors == 'off') { continue; } $name = isset($params['name']) ? $params['name'] : ''; $ident = isset($params['ident']) ? $params['ident'] : ''; $conf = isset($params['conf']) ? $params['conf'] : array(); $level = isset($params['level']) ? $params['level'] : PEAR_LOG_DEBUG; $logger =& Log::singleton(strtolower($handler), $name, $ident, $conf, $level); $composite->addChild($logger); } // Add at least the Log::display driver to output errors on browser screen if (!array_key_exists('display', $drivers)) { if ($display_errors == 'on') { $logger =& Log::singleton('display'); $composite->addChild($logger); } } }
/** * Static version of {@link push()} * * @param string $package Package name this error belongs to * @param int $code Package-specific error code * @param string $level Error level. This is NOT spell-checked * @param array $params associative array of error parameters * @param string $msg Error message, or a portion of it if the message * is to be generated * @param array $repackage If this error re-packages an error pushed by * another package, place the array returned from * {@link pop()} in this parameter * @param array $backtrace Protected parameter: use this to pass in the * {@link debug_backtrace()} that should be used * to find error context * @return PEAR_Error|array if compatibility mode is on, a PEAR_Error is also * thrown. see docs for {@link push()} * @static */ function staticPush($package, $code, $level = 'error', $params = array(), $msg = false, $repackage = false, $backtrace = false) { $s =& PEAR_ErrorStack::singleton($package); if ($s->_contextCallback) { if (!$backtrace) { if (function_exists('debug_backtrace')) { $backtrace = debug_backtrace(); } } } return $s->push($code, $level, $params, $msg, $repackage, $backtrace); }
/** * Constructor * * @param mixed $dsn PDO のインスタンス or DSN or DSN, username, password 等の配列 * @param array $options キャッシュ設定オプション (optional) * @throws PDOException, Cache_PDOException * @access public */ public function __construct($dsn, $options = array()) { // データベースに接続 if ($dsn instanceof PDO) { $this->_db = $dsn; } elseif (is_string($dsn)) { $this->_db = new PDO($dsn); } elseif (is_array($dsn) && isset($dsn['dsn'])) { $username = isset($dsn['username']) ? $dsn['username'] : ''; $password = isset($dsn['password']) ? $dsn['password'] : ''; $driver_options = isset($dsn['driver_options']) ? $dsn['driver_options'] : array(); $this->_db = new PDO($dsn['dsn'], $username, $password, $driver_options); } else { throw new Cache_PDOException('Cache_PDO: invalid DSN given.', self::ERR_ERROR); } $this->_db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); //$this->_db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, false); // 互換モジュールを読み込む $driver = $this->_getDriver(); $class = 'Cache_PDO_Driver_' . $driver; if (!@(require_once 'Cache/PDO/Driver/' . $driver . '.php')) { throw new Cache_PDOException(sprintf('Cache_PDO: %s driver not supported.', $driver), self::ERR_ERROR); } $this->_driver = new $class($this->_db); $this->_validFromat = self::SERIALIZE_PHP | self::ENCODE_BASE64 | self::ENCODE_ZLIB_BINARY; // エラー管理オブジェクトを用意 $this->_stack = PEAR_ErrorStack::singleton('Cache_PDO'); // オプションを設定 $constOptions = array('debug', 'strict', 'autoCreateTable', 'autoVacuum'); foreach ($this->_defaults as $key => $value) { $propName = '_' . $key; $this->{$propName} = $value; if (isset($options[$key])) { if ($key == 'table') { $this->{$propName} = (string) $options[$key]; } elseif (in_array($key, $constOptions)) { $this->{$propName} = (bool) $options[$key]; } else { $this->setOption($key, $options[$key]); } } } // テーブルを作成 $this->_qTable = $this->_driver->quoteIdentifier($this->_table); $this->_inTransaction = false; if ($this->_autoCreateTable) { $this->_checkTable(); } }