cvs: pear /Services_Trackback/Services Trackback.php
| From: | Tobias Schlitt | Date: | Mon, 23 May 2005 11:44:14 +0000 |
| Subject: | cvs: pear /Services_Trackback/Services Trackback.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-32050@lists.php.net to get a copy of this message | ||
toby Mon May 23 07:44:14 2005 EDT
Modified files:
/pear/Services_Trackback/Services Trackback.php
Log:
* Unified PEAR_Error documentation.
* Modified API: addSpamCheck() now returns a reference to the added spam check or PEAR_Error.
* Added createSpamCheck().
http://cvs.php.net/diff.php/pear/Services_Trackback/Services/Trackback.php?r1=1.6&r2=1.7&ty=u
Index: pear/Services_Trackback/Services/Trackback.php
diff -u pear/Services_Trackback/Services/Trackback.php:1.6
pear/Services_Trackback/Services/Trackback.php:1.7
--- pear/Services_Trackback/Services/Trackback.php:1.6 Sun May 8 12:29:58 2005
+++ pear/Services_Trackback/Services/Trackback.php Mon May 23 07:44:14 2005
@@ -21,7 +21,7 @@
* @author Tobias Schlitt <toby@php.net>
* @copyright 1997-2005 The PHP Group
* @license http://www.php.net/license/3_0.txt
PHP License 3.0
- * @version CVS: $Id: Trackback.php,v 1.6 2005/05/08 16:29:58 toby Exp $
+ * @version CVS: $Id: Trackback.php,v 1.7 2005/05/23 11:44:14 toby Exp $
* @link http://pear.php.net/package/Services_Trackback
* @since File available since Release 0.0.1
*/
@@ -212,7 +212,7 @@
* @see Services_Trackback::create()
* @see Services_Trackback::getOptions()
* @param array $options Pairs of 'option' => 'value' as described at
@see Services_Trackback::create().
- * @return mixed Bool true on success, otherwise PEAR::Error().
+ * @return mixed Bool true on success, otherwise PEAR_Error.
*/
function setOptions($options) {
foreach($options as $option => $value) {
@@ -268,7 +268,7 @@
*
* @since 0.2.0
* @access public
- * @return bool True on success, otherwise PEAR::Error.
+ * @return bool True on success, otherwise PEAR_Error.
*/
function autodiscover()
{
@@ -341,7 +341,7 @@
* @since 0.3.0
* @access public
* @param string $data Additional data to complete the trackback.
- * @return mixed True on success, otherwise PEAR::Error.
+ * @return mixed True on success, otherwise PEAR_Error.
*/
function send($data = null)
{
@@ -538,15 +538,54 @@
* @param object(Services_Trackback_SpamCheck) $spamCheck The spam check module to add.
* @param int $priority A priority value for the spam check. Lower priority indices are
processed earlier.
* If no priority level is set, 0 is assumed.
- * @return bool True on success, otherwise PEAR::Error().
+ * @return mixed Added SpamCheck module instance on success, otherwise PEAR_Error.
*/
- function addSpamCheck(&$spamCheck, $priority = 0)
+ function &addSpamCheck(&$spamCheck, $priority = 0)
{
if (!is_object($spamCheck) || !is_subclass_of($spamCheck,
'Services_Trackback_SpamCheck')) {
return PEAR::raiseError('Invalid spam check module.', -1);
}
$this->_spamChecks[$priority][] =& $spamCheck;
- return true;
+ return $spamCheck;
+ }
+
+ // }}}
+ // {{{ createSpamCheck()
+
+ /**
+ * createSpamCheck
+ * Create and add a spam check module to the trackback.
+ *
+ * @since 0.5.0
+ * @access public
+ * @see Services_Trackback::addSpamCheck()
+ * @see Services_Trackback::removeSpamCheck()
+ * @see Services_Trackback::checkSpam()
+ * @param string $spamCheckType Name of the spamcheck module to create and add.
+ * @param array $options Options for the spamcheckmodule.
+ * @param int $priority A priority value for the spam check. Lower priority indices are
processed earlier.
+ * If no priority level is set, 0 is assumed.
+ * @return mixed Instance of the created SpamCheck module or PEAR_Error.
+ */
+ function &createSpamCheck($spamCheckType, $options = array(), $priority = 0)
+ {
+ $filename = 'Services/Trackback/SpamCheck.php';
+ $createfunc = array('Services_Trackback_SpamCheck', 'create');
+
+ // SpamCheck class already included?
+ if (!class_exists($createfunc[0])) {
+ include_once $filename;
+ }
+
+ // SpamCheck class successfully included?
+ if (!class_exists($createfunc[0])) {
+ return PEAR::raiseError('SpamCheck subclass not found. Broken
installation!');
+ }
+
+ $spamCheck =& call_user_func($createfunc, $spamCheckType, $options);
+ $res =& $this->addSpamCheck($spamCheck);
+
+ return $res;
}
// }}}
@@ -561,7 +600,7 @@
* @see Services_Trackback::addSpamCheck()
* @see Services_Trackback::checkSpam()
* @param object(Services_Trackback_SpamCheck) The spam check module to remove.
- * @return bool True on success, otherwise PEAR::Error().
+ * @return bool True on success, otherwise PEAR_Error.
*/
function removeSpamCheck(&$spamCheck)
{
@@ -617,12 +656,12 @@
/**
* get
* Get data from the trackback. Returns the value of a given
- * key or PEAR::Error.
+ * key or PEAR_Error.
*
* @since 0.2.0
* @access public
* @param string $key The key to fetch a value for.
- * @return mixed A string value or a PEAR::Error on failure.
+ * @return mixed A string value or a PEAR_Error on failure.
*/
function get($key)
{
@@ -635,13 +674,13 @@
/**
* set
* Set data of the trackback. Saves the value of a given
- * key , returning true on success, PEAR::Error on faulure.
+ * key , returning true on success, PEAR_Error on faulure.
*
* @since 0.2.0
* @access public
* @param string $key The key to set a value for.
* @param string $val The value for the key.
- * @return mixed Boolean true on success or a PEAR::Error on failure.
+ * @return mixed Boolean true on success or a PEAR_Error on failure.
*/
function set($key, $val)
{
@@ -658,7 +697,7 @@
* @since 0.2.0
* @access protected
* @param array $data The data array (@see Services_Trackback::create()).
- * @return mixed True on success, otherwise PEAR::Error.
+ * @return mixed True on success, otherwise PEAR_Error.
*/
function _fromArray($data) {
$res = $this->_checkData(array('id'), $data);
@@ -791,7 +830,7 @@
* @param string $url1 The first URL.
* @param string $url2 The second URL.
* @param constant $strictness How strict to check URLs. Use one of
SERVICES_TRACKBACK_STRICTNESS_* constants.
- * @return mixed True on success, otherwise PEAR::Error.
+ * @return mixed True on success, otherwise PEAR_Error.
*/
function _checkURLs($url1, $url2, $strictness)
{
@@ -836,7 +875,7 @@
* @see Services_Trackback::send()
* @since 0.3.0
* @access protected
- * @return void Mixed true on success, otherwise PEAR::Error.
+ * @return void Mixed true on success, otherwise PEAR_Error.
*/
function _interpretTrackbackResponse($response)
{