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


PHP Hooks::runHook方法代码示例

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


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

示例1: load

 /**
  * Converts an XML url or string to a PHP array format
  *
  * @static
  * @access public
  * @param string $data Either an url to an xml file, or a raw XML string. Peachy will autodetect which is which.
  * @return array Parsed XML
  * @throws BadEntryError
  * @throws DependencyError
  * @throws HookError
  * @throws XMLError
  */
 public static function load($data)
 {
     $http = HTTP::getDefaultInstance();
     if (!function_exists('simplexml_load_string')) {
         throw new DependencyError("SimpleXML", "http://us.php.net/manual/en/book.simplexml.php");
     }
     libxml_use_internal_errors(true);
     if (in_string("<?xml", $data)) {
         $xmlout = $data;
     } else {
         $xmlout = $http->get($data);
     }
     Hooks::runHook('PreSimpleXMLLoad', array(&$xmlout));
     $xml = simplexml_load_string($xmlout);
     Hooks::runHook('PostSimpleXMLLoad', array(&$xml));
     if (!$xml) {
         foreach (libxml_get_errors() as $error) {
             throw new XMLError($error);
         }
     }
     $outArr = array();
     $namespaces = $xml->getNamespaces(true);
     $namespaces['default'] = '';
     self::recurse($xml, $outArr, $namespaces);
     libxml_clear_errors();
     return $outArr;
 }
开发者ID:emijrp,项目名称:Peachy,代码行数:39,代码来源:XMLParse.php

示例2: autoload

 /**
  * Takes a class name and attempt to load it
  *
  * @param $class_name String: name of class we're looking for.
  * @return boolean|null Returning false is important on failure as
  * 		it allows Zend to try and look in other registered autoloaders
  * 		as well.
  */
 public static function autoload($class_name)
 {
     global $pgIP, $pgAutoloader;
     if (isset($pgAutoloader[$class_name]) && is_file($pgIP . $pgAutoloader[$class_name])) {
         require_once $pgIP . $pgAutoloader[$class_name];
         return true;
     }
     if (is_file($pgIP . 'Plugins/' . $class_name . '.php')) {
         Hooks::runHook('LoadPlugin', array(&$class_name));
         require_once $pgIP . 'Plugins/' . $class_name . '.php';
         return true;
     }
 }
开发者ID:emijrp,项目名称:Peachy,代码行数:21,代码来源:Autoloader.php

示例3: newWiki

 /**
  * Initializes Peachy, logs in with a either configuration file or a given username and password
  *
  * @static
  * @access public
  *
  * @param string $config_name Name of the config file stored in the Configs directory, minus the .cfg extension. Default null
  * @param string $pgUsername Username to log in if no config file specified. Default null
  * @param string $password Password to log in with if no config file specified. Default null
  * @param string $base_url URL to api.php if no config file specified. Defaults to English Wikipedia's API.
  * @param string $classname
  *
  * @throws LoginError
  * @return Wiki Instance of the Wiki class, where most functions are stored
  */
 public static function newWiki($config_name = null, $pgUsername = null, $password = null, $base_url = 'http://en.wikipedia.org/w/api.php', $classname = 'Wiki')
 {
     pecho("Loading Peachy (version " . PEACHYVERSION . ")...\n\n", PECHO_NORMAL);
     /*$updater = new AutoUpdate();
     		$Uptodate = $updater->Checkforupdate();
     		if( !$Uptodate ) $updater->updatePeachy();*/
     if (!is_null($config_name)) {
         $config_params = self::parse_config($config_name);
     } else {
         $config_params = array('username' => $pgUsername, 'password' => $password, 'baseurl' => $base_url);
     }
     if (is_null($config_params['baseurl']) || !isset($config_params['baseurl'])) {
         throw new LoginError(array("MissingParam", "The baseurl parameter was not set."));
     }
     if (!isset($config_params['username']) || !isset($config_params['password'])) {
         $config_params['nologin'] = true;
     }
     list($version, $extensions) = self::wikiChecks($config_params['baseurl']);
     Hooks::runHook('StartLogin', array(&$config_params, &$extensions));
     $w = new $classname($config_params, $extensions, false, null);
     $w->mwversion = $version;
     return $w;
 }
开发者ID:emijrp,项目名称:Peachy,代码行数:38,代码来源:Peachy.php

示例4: update

 public function update($rev)
 {
     Hooks::runHook('StartCodeReviewUpdate', array(&$rev));
     $apiRes = $this->wiki->apiQuery(array('action' => 'codeupdate', 'repo' => $this->repo, 'rev' => $rev), true);
     print_r($apiRes);
 }
开发者ID:emijrp,项目名称:Peachy,代码行数:6,代码来源:CodeReview.php

示例5: __construct

 function __construct($server, $pgPort = 6667, $user, $pass, $nick, $channel, $callback = null)
 {
     global $pgIRCTrigger, $pgHooks;
     if (func_num_args() > 6) {
         $this->server = $server;
         $this->port = $pgPort;
         $this->user = $user;
         $this->pass = $pass;
         $this->nick = $nick;
         $this->channel = $channel;
         $this->callback = $callback;
     } else {
         $this->server = $server;
         $this->port = 6667;
         $this->user = $pgPort;
         $this->pass = $user;
         $this->nick = $pass;
         $this->channel = $nick;
         $this->callback = $channel;
     }
     $pgHooks['SimpleIRCPrivMSG'][] = $callback;
     $irc = new IRC($this->user, $this->nick, $this->pass, $this->server, $this->port, "Peachy IRC Bot Version " . PEACHYVERSION, $this->channel);
     while (!feof($irc->f)) {
         $parsed = IRC::parseLine(fgets($irc->f, 1024), $pgIRCTrigger, true);
         if (@$parsed['n!u@h'] == 'PING') {
             $irc->sendPong($parsed['payload']);
         }
         if (@$parsed['type'] == '376' || @$parser['type'] == '422') {
             $feed->joinChan();
             sleep(5);
         }
         if (@$parsed['type'] == 'PRIVMSG') {
             Hooks::runHook('SimpleIRCPrivMSG', array(&$parsed, &$irc, &$this));
         }
     }
 }
开发者ID:emijrp,项目名称:Peachy,代码行数:36,代码来源:IRC.php

示例6: stabilize

 /**
  * @param $title
  * @param string $level
  * @param null $reason
  * @param bool|false $autoreview
  * @param bool|false $watch
  * @return bool
  * @throws AssertFailure
  * @throws BadEntryError
  * @throws HookError
  * @throws LoggedOut
  * @throws MWAPIError
  */
 public function stabilize($title, $level = 'none', $reason = null, $autoreview = false, $watch = false)
 {
     if (!in_array('stablesettings', $this->wiki->get_userrights())) {
         pecho("User is not allowed to change the stabilization settings", PECHO_FATAL);
         return false;
     }
     $tokens = $this->wiki->get_tokens();
     if ($tokens['edit'] == '+\\') {
         pecho("User has logged out.\n\n", PECHO_FATAL);
         return false;
     }
     if (mb_strlen($reason, '8bit') > 255) {
         pecho("Comment is over 255 bytes, the maximum allowed.\n\n", PECHO_FATAL);
         return false;
     }
     pecho("Stabilizing title...\n\n", PECHO_NOTICE);
     $editarray = array('action' => 'review', 'title' => $title, 'token' => $tokens['edit'], 'protectlevel' => $level);
     if ($watch) {
         $editArray['watch'] = 'yes';
     }
     if (!empty($reason)) {
         $editArray['reason'] = $reason;
     }
     if ($this->wiki->get_maxlag()) {
         $editarray['maxlag'] = $this->wiki->get_maxlag();
     }
     Hooks::runHook('StartStabilize', array(&$editarray));
     $result = $this->wiki->apiQuery($editarray, true);
     if (isset($result['stabilize'])) {
         if (isset($result['stabilize']['title'])) {
             return true;
         } else {
             pecho("Stabilization error...\n\n" . print_r($result['stabilize'], true) . "\n\n", PECHO_FATAL);
             return false;
         }
     } else {
         pecho("Stabilization error...\n\n" . print_r($result, true), PECHO_FATAL);
         return false;
     }
 }
开发者ID:emijrp,项目名称:Peachy,代码行数:53,代码来源:FlaggedRevs.php

示例7: download

 /**
  * Downloads an image to the local disk
  *
  * @param string $localname Filename to store image as. Default null.
  * @param int $width Width of image to download. Default -1.
  * @param int $height Height of image to download. Default -1.
  * @return void
  */
 public function download($localname = null, $width = -1, $height = -1)
 {
     global $pgIP;
     if (!$this->get_exists()) {
         pecho("Attempted to download a non-existant file.", PECHO_NOTICE);
     }
     $ii = $this->imageinfo(1, $width, $height);
     if (is_array($ii)) {
         $ii = $ii[0];
         if ($width != -1) {
             $url = $ii['thumburl'];
         } else {
             $url = $ii['url'];
         }
         if (is_null($localname)) {
             $localname = $pgIP . 'Images/' . $this->localname;
         }
         Hooks::runHook('DownloadImage', array(&$url, &$localname));
         pecho("Downloading {$this->title} to {$localname}..\n\n", PECHO_NOTICE);
         $this->wiki->get_http()->download($url, $localname);
     } else {
         pecho("Error in getting image URL.\n\n" . print_r($ii) . "\n\n", PECHO_FATAL);
     }
 }
开发者ID:emijrp,项目名称:Peachy,代码行数:32,代码来源:Image.php

示例8: __destruct

 /**
  * Destructor, deletes cookies and closes cURL class
  *
  * @access public
  * @return void
  */
 public function __destruct()
 {
     Hooks::runHook('HTTPClose', array(&$this));
     curl_close($this->curl_instance);
     //@unlink($this->cookie_jar);
 }
开发者ID:emijrp,项目名称:Peachy,代码行数:12,代码来源:HTTP.php

示例9: deletedcontribs

 /**
  * List all deleted contributions.
  * The logged in user must have the 'deletedhistory' right
  *
  * @access public
  * @param bool $content Whether or not to return content of each contribution. Default false
  * @param string $start Timestamp to start at. Default null.
  * @param string $end Timestamp to end at. Default null.
  * @param string $dir Direction to list. Default 'older'
  * @param array $prop Information to retrieve. Default array( 'revid', 'user', 'parsedcomment', 'minor', 'len', 'content', 'token' )
  * @return array
  */
 public function deletedcontribs($content = false, $start = null, $end = null, $dir = 'older', $prop = array('revid', 'user', 'parsedcomment', 'minor', 'len', 'content', 'token'))
 {
     if (!in_array('deletedhistory', $this->wiki->get_userrights())) {
         pecho("User is not allowed to view deleted revisions", PECHO_FATAL);
         return false;
     }
     if ($content) {
         $prop[] = 'content';
     }
     $drArray = array('_code' => 'dr', 'list' => 'deletedrevs', 'druser' => $this->username, 'drprop' => implode('|', $prop), 'drdir' => $dir);
     if (!is_null($start)) {
         $drArray['drstart'] = $start;
     }
     if (!is_null($end)) {
         $drArray['drend'] = $end;
     }
     Hooks::runHook('StartDelrevs', array(&$drArray));
     pecho("Getting deleted revisions by {$this->username}...\n\n", PECHO_NORMAL);
     return $this->wiki->listHandler($drArray);
 }
开发者ID:emijrp,项目名称:Peachy,代码行数:32,代码来源:User.php

示例10: outputText

/**
 * Outputs text if the given category is in the allowed types
 *
 * @param string $text Text to display
 * @param int $cat Category of text, such as PECHO_WARN, PECHO_NORMAL
 * @param string $func
 * @return void
 */
function outputText($text, $cat = 0, $func = 'echo')
{
    global $pgVerbose;
    Hooks::runHook('OutputText', array(&$text, &$cat, &$func));
    if (in_array($cat, $pgVerbose)) {
        if ($func == 'echo') {
            echo $text;
        } else {
            $func($text);
        }
    }
}
开发者ID:emijrp,项目名称:Peachy,代码行数:20,代码来源:GenFunctions.php

示例11: embeddedin

 /**
  * Returns array of pages that embed (transclude) the page given.
  *
  * @param array $namespace Which namespaces to search (default: null).
  * @param int $limit How many results to retrieve (default: null i.e. all).
  * @return array A list of pages the title is transcluded in.
  */
 public function embeddedin($namespace = null, $limit = null)
 {
     $eiArray = array('list' => 'embeddedin', '_code' => 'ei', 'eititle' => $this->title, '_lhtitle' => 'title', '_limit' => $limit);
     if (!is_null($namespace)) {
         $eiArray['einamespace'] = $namespace;
     }
     Hooks::runHook('PreQueryEmbeddedin', array(&$eiArray));
     pecho("Getting list of pages that include {$this->title}...\n\n", PECHO_NORMAL);
     return $this->wiki->listHandler($eiArray);
 }
开发者ID:emijrp,项目名称:Peachy,代码行数:17,代码来源:Page.php

示例12: get_tokens

 /**
  * Regenerate and return edit tokens
  *
  * @access public
  * @param bool $force Whether to force use of the API, not cache.
  * @return array Edit tokens
  */
 public function get_tokens($force = false)
 {
     Hooks::runHook('GetTokens', array(&$this->tokens));
     if (!$force && !empty($this->tokens)) {
         return $this->tokens;
     }
     $tokens = $this->apiQuery(array('action' => 'tokens', 'type' => 'block|delete|deleteglobalaccount|edit|email|import|move|options|patrol|protect|setglobalaccountstatus|unblock|watch'));
     foreach ($tokens['tokens'] as $y => $z) {
         if (in_string('token', $y)) {
             $this->tokens[str_replace('token', '', $y)] = $z;
         }
     }
     $token = $this->apiQuery(array('action' => 'query', 'list' => 'users', 'ususers' => $this->username, 'ustoken' => 'userrights'));
     if (isset($token['query']['users'][0]['userrightstoken'])) {
         $this->tokens['userrights'] = $token['query']['users'][0]['userrightstoken'];
     } else {
         pecho("Error retrieving userrights token...\n\n", PECHO_FATAL);
         return array();
     }
     return $this->tokens;
 }
开发者ID:emijrp,项目名称:Peachy,代码行数:28,代码来源:Wiki.php


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