cvs: pearweb /include/Damblan Karma.php Log.php Mailer.php Search.php Site.php Trackback.php URL.php /include/Damblan/Log Mail.php Print.php
/include/Damblan/Search Lists.php PEPr.php Packages.php Site.php Users.php

From: Date: Thu, 13 Apr 2006 05:13:01 +0000
Subject: cvs: pearweb /include/Damblan Karma.php Log.php Mailer.php Search.php Site.php Trackback.php URL.php /include/Damblan/Log Mail.php Print.php
/include/Damblan/Search Lists.php PEPr.php Packages.php Site.php Users.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-39580@lists.php.net to get a copy of this message
dufuz Thu Apr 13 05:13:01 2006 UTC Modified files: /pearweb/include/Damblan Karma.php Log.php Mailer.php Search.php Site.php Trackback.php URL.php /pearweb/include/Damblan/Log Mail.php Print.php /pearweb/include/Damblan/Search Lists.php PEPr.php Packages.php Site.php Users.php Log: 101 in rule setting: Follow your own rules. CS cosmetics.

http://cvs.php.net/viewcvs.cgi/pearweb/include/Damblan/Karma.php?r1=1.20&r2=1.21&diff_format=u Index: pearweb/include/Damblan/Karma.php diff -u pearweb/include/Damblan/Karma.php:1.20 pearweb/include/Damblan/Karma.php:1.21 --- pearweb/include/Damblan/Karma.php:1.20 Thu Aug 11 19:29:34 2005 +++ pearweb/include/Damblan/Karma.php Thu Apr 13 05:13:01 2006 @@ -15,7 +15,7 @@ +----------------------------------------------------------------------+ | Author: Martin Jansen <mj@php.net> | +----------------------------------------------------------------------+ - $Id: Karma.php,v 1.20 2005/08/11 19:29:34 toby Exp $ + $Id: Karma.php,v 1.21 2006/04/13 05:13:01 dufuz Exp $ */ /** @@ -26,10 +26,10 @@ * single-sign-on system some time in the future. * * @author Martin Jansen <mj@php.net> - * @version $Revision: 1.20 $ + * @version $Revision: 1.21 $ */ -class Damblan_Karma { - +class Damblan_Karma +{ var $_dbh; /** @@ -38,7 +38,8 @@ * @access public * @param object Instance of PEAR::DB */ - function Damblan_Karma(&$dbh) { + function Damblan_Karma(&$dbh) + { $this->_dbh = $dbh; } @@ -53,44 +54,45 @@ * @param string Level * @return boolean */ - function has($user, $level) { + function has($user, $level) + { $levels = array(); switch ($level) { - case "pear.pepr" : - $levels = array("pear.pepr", "pear.user", "pear.dev", "pear.admin", "pear.group" ); + case 'pear.pepr' : + $levels = array('pear.pepr', 'pear.user', 'pear.dev', 'pear.admin', 'pear.group' ); break; - case "pear.pepr.admin" : - $levels = array("pear.admin", "pear.group", "pear.pepr.admin"); + case 'pear.pepr.admin' : + $levels = array('pear.admin', 'pear.group', 'pear.pepr.admin'); break; - case "pear.user" : - $levels = array("pear.user", "pear.pepr", "pear.dev", "pear.admin", "pear.group"); + case 'pear.user' : + $levels = array('pear.user', 'pear.pepr', 'pear.dev', 'pear.admin', 'pear.group'); break; - case "pear.dev" : - $levels = array("pear.dev", "pear.admin", "pear.group"); + case 'pear.dev' : + $levels = array('pear.dev', 'pear.admin', 'pear.group'); break; - - case "pear.qa" : - $levels = array("pear.qa", "pear.admin", "pear.group"); + + case 'pear.qa' : + $levels = array('pear.qa', 'pear.admin', 'pear.group'); break; - case "pear.admin" : - $levels = array("pear.admin", "pear.group"); + case 'pear.admin' : + $levels = array('pear.admin', 'pear.group'); break; - case "pear.group" : - $levels = array("pear.group"); + case 'pear.group' : + $levels = array('pear.group'); break; - case "global.karma.manager" : - $levels = array("pear.group"); + case 'global.karma.manager' : + $levels = array('pear.group'); break; - case "doc.chm-upload" : - $levels = array("pear.doc.chm-upload", "pear.group"); + case 'doc.chm-upload' : + $levels = array('pear.doc.chm-upload', 'pear.group'); break; default : @@ -113,7 +115,8 @@ * @param string Level * @return boolean */ - function grant($user, $level) { + function grant($user, $level) + { global $auth_user; $this->_requireKarma(); @@ -146,7 +149,8 @@ * @param string Level * @return boolean */ - function remove($user, $level) { + function remove($user, $level) + { global $auth_user; $this->_requireKarma(); @@ -169,7 +173,8 @@ * @param string Name of the user * @return array */ - function get($user) { + function get($user) + { $query = "SELECT * FROM karma WHERE user = ?"; return $this->_dbh->getAll($query, array($user), DB_FETCHMODE_ASSOC); } @@ -181,7 +186,8 @@ * @param string Level * @return array */ - function getUsers($level) { + function getUsers($level) + { $query = "SELECT * FROM karma WHERE level = ?"; return $this->_dbh->getAll($query, array($level), DB_FETCHMODE_ASSOC); } @@ -193,7 +199,8 @@ * @return array Nested array containing the name of each leven and * the number of occurrences of this level. */ - function getLevels() { + function getLevels() + { $query = "SELECT level, COUNT(level) AS sum FROM karma GROUP BY level"; return $this->_dbh->getAll($query, null, DB_FETCHMODE_ASSOC); } @@ -204,7 +211,8 @@ * @access private * @return boolean False on error, true otherwise */ - function _requireKarma() { + function _requireKarma() + { global $auth_user; if ($this->has($auth_user->handle, "global.karma.manager") == false) { @@ -226,9 +234,10 @@ * @param string Describes the type of karma update * @return void */ - function _notify($admin_user, $user, $action) { - require_once "Damblan/Log.php"; - require_once "Damblan/Log/Mail.php"; + function _notify($admin_user, $user, $action) + { + require_once 'Damblan/Log.php'; + require_once 'Damblan/Log/Mail.php'; static $logger, $observer; @@ -244,7 +253,7 @@ $logger->attach($observer); } - $text = $admin_user . " has updated karma for " . $user . ": " . $action; + $text = $admin_user . ' has updated karma for ' . $user . ': ' . $action; $logger->log($text); } } http://cvs.php.net/viewcvs.cgi/pearweb/include/Damblan/Log.php?r1=1.2&r2=1.3&diff_format=u Index: pearweb/include/Damblan/Log.php diff -u pearweb/include/Damblan/Log.php:1.2 pearweb/include/Damblan/Log.php:1.3 --- pearweb/include/Damblan/Log.php:1.2 Wed Jan 26 12:40:05 2005 +++ pearweb/include/Damblan/Log.php Thu Apr 13 05:13:01 2006 @@ -15,27 +15,28 @@ +----------------------------------------------------------------------+ | Author: Martin Jansen <mj@php.net> | +----------------------------------------------------------------------+ - $Id: Log.php,v 1.2 2005/01/26 12:40:05 pajoye Exp $ + $Id: Log.php,v 1.3 2006/04/13 05:13:01 dufuz Exp $ */ -require_once "Log.php"; -require_once "Log/syslog.php"; +require_once 'Log.php'; +require_once 'Log/syslog.php'; /** * Basic class for logging to syslog * * @author Martin Jansen <mj@php.net> * @extends Log_syslog - * @version $Revision: 1.2 $ + * @version $Revision: 1.3 $ * @package Damblan */ -class Damblan_Log extends Log_syslog { - +class Damblan_Log extends Log_syslog +{ var $_name = LOG_SYSLOG; - var $_ident = "pearweb"; + var $_ident = 'pearweb'; var $_mask = null; - function Damblan_Log() { + function Damblan_Log() + { $this->_mask = Log::UPTO(PEAR_LOG_DEBUG); } } http://cvs.php.net/viewcvs.cgi/pearweb/include/Damblan/Mailer.php?r1=1.6&r2=1.7&diff_format=u Index: pearweb/include/Damblan/Mailer.php diff -u pearweb/include/Damblan/Mailer.php:1.6 pearweb/include/Damblan/Mailer.php:1.7 --- pearweb/include/Damblan/Mailer.php:1.6 Wed Feb 23 06:24:18 2005 +++ pearweb/include/Damblan/Mailer.php Thu Apr 13 05:13:01 2006 @@ -6,8 +6,8 @@ */ require_once 'Mail.php'; -class Damblan_Mailer { - +class Damblan_Mailer +{ /** * The template data. * A template consists of an array with several keys. The main key is "Body", @@ -15,11 +15,11 @@ * headers like "To", "From", "Reply-To" or "X-Mailer". Except the body, every * key may contain an array of strings, the body itself may only be a string. * If one of the header keys is an array, the elements of this array will be - * concated using the string ", ". For example templates, see the + * concated using the string ", ". For example templates, see the * include/Damblan/Mail/ directory, where all templates are stored. - * + * * @var array - * @since + * @since */ var $_template = ''; @@ -27,17 +27,17 @@ * The data to replace in the template. * This is an array of keys which represent variables (without the %-sign * used in the template), associated with the data to replace the variables. - * + * * @var array * @since */ - var $_data = array(); + var $_data = array(); /** * Default headers. * These default headers will be used, if one of those is neither set through the * template nor through the additional headers submitted to the send() method. - * + * * @var array * @since */ @@ -46,7 +46,7 @@ 'From' => 'pear-sys@php.net', 'Reply-To' => PEAR_WEBMASTER_EMAIL, 'X-Mailer' => 'PEARWeb - http://pear.php.net' - ); + ); /** * Create a new mail from a template. @@ -54,7 +54,7 @@ * given parameters represent the $_template and $_data variables of this class. * See their documentation for further information. * - * @since + * @since * @access public * * @param array $template The template. This can either be a name of a template or the @@ -88,13 +88,13 @@ $mailer->_data = $data; return $mailer; } - + /** * Send the mail. * This method is used to send a generated email. When calling this method, * the template itself is compiled. Afterwards, the existing headers are merged * with the additional header submited to this method. - * + * * @since * @access public * @param array $headers Additional headers to use when sending an email. Note, that @@ -150,11 +150,11 @@ } /** - * Sanitize headers. + * Sanitize headers. * Sanity checks for the headers of the mail. If a header is missing, it's set to a * default value, provided from Damblan_Mail::$_defaultHeaders. - * - * @since + * + * @since * @access private * @return array $data The sanitized template data. */ @@ -181,8 +181,8 @@ * is added to the array. * - If both (old and new header) are strings, the new header _overwrites_ the * old one!! - * - * @since + * + * @since * @access private * @param array $data The compiled template data. * @param array $headers The new header data to merge. @@ -218,8 +218,8 @@ /** * Compile the data into the template. * The compilation is processed through all data elements (headers and body). - * - * @since + * + * @since * @access private * @return array $data The compiled data. */ http://cvs.php.net/viewcvs.cgi/pearweb/include/Damblan/Search.php?r1=1.4&r2=1.5&diff_format=u Index: pearweb/include/Damblan/Search.php diff -u pearweb/include/Damblan/Search.php:1.4 pearweb/include/Damblan/Search.php:1.5 --- pearweb/include/Damblan/Search.php:1.4 Wed Sep 7 20:46:53 2005 +++ pearweb/include/Damblan/Search.php Thu Apr 13 05:13:01 2006 @@ -15,7 +15,7 @@ +----------------------------------------------------------------------+ | Author: Martin Jansen <mj@php.net> | +----------------------------------------------------------------------+ - $Id: Search.php,v 1.4 2005/09/07 20:46:53 pajoye Exp $ + $Id: Search.php,v 1.5 2006/04/13 05:13:01 dufuz Exp $ */ /** @@ -23,17 +23,18 @@ * * @author Martin Jansen <mj@php.net> * @package Damblan - * @version $Revision: 1.4 $ + * @version $Revision: 1.5 $ */ -class Damblan_Search { - +class Damblan_Search +{ var $_dbh; var $_pager = null; var $_total = 0; var $_results = null; - var $_title = ""; + var $_title = ''; - function Damblan_Search(&$dbh) { + function Damblan_Search(&$dbh) + { $this->_dbh =& $dbh; } @@ -45,42 +46,34 @@ * @param object Instance of PEAR::DB. Will be passed to the subclass * @return object The concrete instance of the search subclass */ - function &factory($searchType, &$dbh) { + function &factory($searchType, &$dbh) + { switch ($searchType) { - - case "users" : - require_once "Damblan/Search/Users.php"; - $s = new Damblan_Search_Users($dbh); - - break; - - case "site" : - require_once "Damblan/Search/Site.php"; - $s = new Damblan_Search_Site; - - break; - - case "pepr" : - require_once "Damblan/Search/PEPr.php"; - $s = new Damblan_Search_PEPr; - - break; - - case "pear-dev": - case "pear-cvs": - case "pear-general": - require_once "Damblan/Search/Lists.php"; - $s = new Damblan_Search_Lists($searchType); - - break; - - case "packages" : - default : - require_once "Damblan/Search/Packages.php"; - $s = new Damblan_Search_Packages($dbh); - - break; + case 'users' : + require_once 'Damblan/Search/Users.php'; + $s = new Damblan_Search_Users($dbh); + break; + case 'site' : + require_once 'Damblan/Search/Site.php'; + $s = new Damblan_Search_Site; + break; + case 'pepr' : + require_once 'Damblan/Search/PEPr.php'; + $s = new Damblan_Search_PEPr; + break; + case 'pear-dev': + case 'pear-cvs': + case 'pear-general': + require_once 'Damblan/Search/Lists.php'; + $s = new Damblan_Search_Lists($searchType); + break; + case 'packages' : + default : + require_once 'Damblan/Search/Packages.php'; + $s = new Damblan_Search_Packages($dbh); + break; } + return $s; } @@ -90,7 +83,8 @@ * @access public * @return array */ - function getResults() { + function getResults() + { return $this->_results; } @@ -100,7 +94,8 @@ * @access public * @return int */ - function getTotal() { + function getTotal() + { return $this->_total; } @@ -110,7 +105,8 @@ * @access public * @return string */ - function getTitle() { + function getTitle() + { return $this->_title; } @@ -120,7 +116,8 @@ * @access public * @return object */ - function &getPager() { + function &getPager() + { return $this->_pager; } } http://cvs.php.net/viewcvs.cgi/pearweb/include/Damblan/Site.php?r1=1.2&r2=1.3&diff_format=u Index: pearweb/include/Damblan/Site.php diff -u pearweb/include/Damblan/Site.php:1.2 pearweb/include/Damblan/Site.php:1.3 --- pearweb/include/Damblan/Site.php:1.2 Wed Jan 26 12:40:05 2005 +++ pearweb/include/Damblan/Site.php Thu Apr 13 05:13:01 2006 @@ -15,7 +15,7 @@ +----------------------------------------------------------------------+ | Author: Martin Jansen <mj@php.net> | +----------------------------------------------------------------------+ - $Id: Site.php,v 1.2 2005/01/26 12:40:05 pajoye Exp $ + $Id: Site.php,v 1.3 2006/04/13 05:13:01 dufuz Exp $ */ /** @@ -24,15 +24,16 @@ * @author Martin Jansen <mj@php.net> * @package Damblan */ -class Damblan_Site { - +class Damblan_Site +{ /** * Factory method * * @access public * @return object Instance of Damblan_Site */ - function &factory() { + function &factory() + { static $_instance; if (!isset($_instance)) { @@ -48,21 +49,23 @@ * @param mixed * @return void */ - function error404($error) { - header("HTTP/1.0 404 Not Found"); - print "<h1>Not Found</h1>\n"; + function error404($error) + { + header('HTTP/1.0 404 Not Found'); + echo "<h1>Not Found</h1>\n"; $this->_errorPrint($error); exit(); } - function _errorPrint($error) { + function _errorPrint($error) + { if (is_object($error)) { - print $error->getMessage(); + echo $error->getMessage(); if (DEVBOX) { - print " " . $error->getDebugInfo(); + echo ' ' . $error->getDebugInfo(); } } else { - print $error; + echo $error; } } } http://cvs.php.net/viewcvs.cgi/pearweb/include/Damblan/Trackback.php?r1=1.14&r2=1.15&diff_format=u Index: pearweb/include/Damblan/Trackback.php diff -u pearweb/include/Damblan/Trackback.php:1.14 pearweb/include/Damblan/Trackback.php:1.15 --- pearweb/include/Damblan/Trackback.php:1.14 Thu Mar 2 09:46:36 2006 +++ pearweb/include/Damblan/Trackback.php Thu Apr 13 05:13:01 2006 @@ -2,8 +2,8 @@ require_once 'Services/Trackback.php'; -class Damblan_Trackback extends Services_Trackback { - +class Damblan_Trackback extends Services_Trackback +{ /** * The time the trackback has been discovered. * @@ -51,6 +51,7 @@ 'url' => 'http://'.PEAR_CHANNELNAME.'/', 'key' => include(TRACKBACK_AKISMET_KEY_FILE), ); + foreach ($data as $key => $val) { if ($key == 'approved') $val = ($val == 'true'); @@ -91,16 +92,18 @@ */ function checkRepost(&$dbh, $count = TRACKBACK_REPOST_COUNT, $timespan = TRACKBACK_REPOST_TIMESPAN) { - $sql = 'SELECT COUNT(timestamp) FROM trackbacks WHERE - ip = '.$dbh->quoteSmart($this->get('host')).' AND + $sql = 'SELECT COUNT(timestamp) FROM trackbacks WHERE + ip = '.$dbh->quoteSmart($this->get('host')).' AND timestamp > '.$dbh->quoteSmart($this->get('timestamp') - $timespan); $res = $dbh->getOne($sql); if (PEAR::isError($res)) { return PEAR::raiseError('Database error, please try again later.'); } + if ($res >= $count) { return true; } + return false; } @@ -118,11 +121,11 @@ $testKey = '_'.$key; if (isset($this->$testKey)) { return $this->$testKey; - } else { - return Services_Trackback::get($key); } + + return Services_Trackback::get($key); } - + /** * set * Overwritten set() to set timestamp, ip and approved state correctly. @@ -138,9 +141,9 @@ if (isset($this->$testKey)) { $this->$testKey = $value; return true; - } else { - return Services_Trackback::set($key, $value); - } + } + + return Services_Trackback::set($key, $value); } /** @@ -161,7 +164,10 @@ $data = $this->_getDecodedData($necessaryData); $approved = ($this->_approved) ? 'true' : 'false'; $extra = $this->get('extra'); - $sql = "INSERT INTO trackbacks (id, title, url, excerpt, blog_name, approved, timestamp, ip, referrer, user_agent) VALUES ( + $sql = "INSERT INTO trackbacks + (id, title, url, excerpt, blog_name, approved, + timestamp, ip, referrer, user_agent) + VALUES ( ".$dbh->quoteSmart($this->get('id')).", ".$dbh->quoteSmart($this->get('title')).", ".$dbh->quoteSmart($this->get('url')).", @@ -177,6 +183,7 @@ if (DB::isError($res)) { return PEAR::raiseError('Unable to save trackback: '.$res->getMessage()); } + return true; } @@ -341,12 +348,12 @@ } return $ret; } - + /** - * recentTrackbacks + * recentTrackbacks * Get a list of trackbacks independent from the package ID. - * - * @since + * + * @since * @access public * @static * @param object(DB) $dbh The database connection object (PEAR::DB). @@ -364,7 +371,7 @@ if (($number < 1) || ($number > 50)) { return PEAR::raiseError('Number out of range. Number must be integer between 1 and 50.'); } - $sql = 'SELECT id, title, excerpt, blog_name, url, timestamp, approved, ip + $sql = 'SELECT id, title, excerpt, blog_name, url, timestamp, approved, ip FROM trackbacks'; if ($approvedOnly) { $sql .= ' WHERE approved = '.$dbh->quoteSmart('true'); @@ -382,7 +389,7 @@ } return $ret; } - + /** * Get maintainers to inform of a trackback (the lead maintainers of a package). * @@ -394,8 +401,11 @@ */ function getMaintainers () { + require_once 'pear-database-maintainer.php'; $maintainers = maintainer::get($this->get('id'), true); $res = array(); + + require_once 'pear-database-user.php'; foreach ($maintainers as $maintainer => $data) { $tmpUser = user::info($maintainer, 'email'); if (empty($tmpUser['email'])) { http://cvs.php.net/viewcvs.cgi/pearweb/include/Damblan/URL.php?r1=1.5&r2=1.6&diff_format=u Index: pearweb/include/Damblan/URL.php diff -u pearweb/include/Damblan/URL.php:1.5 pearweb/include/Damblan/URL.php:1.6 --- pearweb/include/Damblan/URL.php:1.5 Wed Jan 26 12:40:05 2005 +++ pearweb/include/Damblan/URL.php Thu Apr 13 05:13:01 2006 @@ -15,7 +15,7 @@ +----------------------------------------------------------------------+ | Author: Martin Jansen <mj@php.net> | +----------------------------------------------------------------------+ - $Id: URL.php,v 1.5 2005/01/26 12:40:05 pajoye Exp $ + $Id: URL.php,v 1.6 2006/04/13 05:13:01 dufuz Exp $ */ /** @@ -24,24 +24,25 @@ * @author Martin Jansen <mj@php.net> * @package Damblan */ -class Damblan_URL { - +class Damblan_URL +{ var $_parameters = array(); var $_path_elements = array(); /** * Constructor */ - function Damblan_URL() { + function Damblan_URL() + { if (count($_GET) > 0) { $this->_parameters = $_GET; } - $path = preg_replace("=^" . preg_quote($_SERVER['SCRIPT_NAME']) . "=", "", $_SERVER['REQUEST_URI']); + $path = preg_replace("=^" . preg_quote($_SERVER['SCRIPT_NAME']) . '=', '', $_SERVER['REQUEST_URI']); if (!empty($path) && isset($path{0}) && $path{0} == "/") { $path = substr($path, 1); - $elements = explode("/", $path); + $elements = explode('/', $path); foreach ($elements as $e) { $this->_path_elements[] = $e; } @@ -58,17 +59,18 @@ * /scripts.php?bar=hello * * and - * + * * /scripts.php/hello * * will both have the same effect */ - function getElements(&$field) { + function getElements(&$field) + { $i = 0; foreach ($field as $key => $value) { - if (strstr($key, "|")) { - foreach (explode("|", $key) as $k) { + if (strstr($key, '|')) { + foreach (explode('|', $key) as $k) { $res = $this->_find($k); if (!empty($res)) { break; @@ -82,10 +84,11 @@ } } - function _find($name) { + function _find($name) + { static $i = 0; - $retVal = ""; + $retVal = ''; if (!empty($this->_parameters[$name])) { $retVal = $this->_parameters[$name]; } else if (!empty($this->_path_elements[$i])) { http://cvs.php.net/viewcvs.cgi/pearweb/include/Damblan/Log/Mail.php?r1=1.5&r2=1.6&diff_format=u Index: pearweb/include/Damblan/Log/Mail.php diff -u pearweb/include/Damblan/Log/Mail.php:1.5 pearweb/include/Damblan/Log/Mail.php:1.6 --- pearweb/include/Damblan/Log/Mail.php:1.5 Wed Jan 26 12:40:05 2005 +++ pearweb/include/Damblan/Log/Mail.php Thu Apr 13 05:13:01 2006 @@ -15,44 +15,46 @@ +----------------------------------------------------------------------+ | Author: Martin Jansen <mj@php.net> | +----------------------------------------------------------------------+ - $Id: Mail.php,v 1.5 2005/01/26 12:40:05 pajoye Exp $ + $Id: Mail.php,v 1.6 2006/04/13 05:13:01 dufuz Exp $ */ -require_once "Log.php"; -require_once "Log/observer.php"; +require_once 'Log.php'; +require_once 'Log/observer.php'; -require_once "Mail.php"; +require_once 'Mail.php'; /** * Observer class for logging via email * * @author Martin Jansen <mj@php.net> * @extends Log_observer - * @version $Revision: 1.5 $ + * @version $Revision: 1.6 $ * @package Damblan */ -class Damblan_Log_Mail extends Log_observer { - +class Damblan_Log_Mail extends Log_observer +{ var $_mailer = null; var $_headers = array(); var $_recipients = ""; - function Damblan_Log_Mail() { + function Damblan_Log_Mail() + { $this->Log_observer(); - $this->_mailer =& Mail::factory("mail", "-f pear-sys@php.net"); + $this->_mailer =& Mail::factory('mail', '-f pear-sys@php.net'); $this->_headers['From'] = "\"PEAR System Administrators\" <pear-sys@php.net>"; } - + /** * Generate logging email * * @param array Array containing the log information * @return void */ - function notify($event) { + function notify($event) + { if (DEVBOX) { return; } @@ -60,7 +62,7 @@ $ok = $this->_mailer->send($this->_recipients, $this->_headers, $event['message']); if ($ok === false) { - trigger_error("Email notification routine failed.", + trigger_error("Email notification routine failed.", E_USER_WARNING); } } @@ -72,7 +74,8 @@ * @param string Log message * @return boolean */ - function log($text) { + function log($text) + { $event['message'] = $text; return $this->notify($event); } @@ -84,7 +87,8 @@ * @param string Recipients * @return void */ - function setRecipients($r) { + function setRecipients($r) + { $this->_recipients = $r; } @@ -96,7 +100,8 @@ * @param string Value of the header * @return void */ - function setHeader($name, $value) { + function setHeader($name, $value) + { $this->_headers[$name] = $value; } } http://cvs.php.net/viewcvs.cgi/pearweb/include/Damblan/Log/Print.php?r1=1.1&r2=1.2&diff_format=u Index: pearweb/include/Damblan/Log/Print.php diff -u pearweb/include/Damblan/Log/Print.php:1.1 pearweb/include/Damblan/Log/Print.php:1.2 --- pearweb/include/Damblan/Log/Print.php:1.1 Tue Aug 16 18:46:20 2005 +++ pearweb/include/Damblan/Log/Print.php Thu Apr 13 05:13:01 2006 @@ -15,33 +15,35 @@ +----------------------------------------------------------------------+ | Author: Martin Jansen <mj@php.net> | +----------------------------------------------------------------------+ - $Id: Print.php,v 1.1 2005/08/16 18:46:20 mj Exp $ + $Id: Print.php,v 1.2 2006/04/13 05:13:01 dufuz Exp $ */ -require_once "Log/observer.php"; +require_once 'Log/observer.php'; /** * Observer class for logging via email * * @author Martin Jansen <mj@php.net> * @extends Log_observer - * @version $Revision: 1.1 $ + * @version $Revision: 1.2 $ * @package Damblan */ -class Damblan_Log_Print extends Log_observer { - - function Damblan_Log_Print() { +class Damblan_Log_Print extends Log_observer +{ + function Damblan_Log_Print() + { $this->Log_observer(); } - + /** * Generate logging email * * @param array Array containing the log information * @return void */ - function notify($event) { - echo "<li>" . $event['message'] . "</li>\n"; + function notify($event) + { + echo '<li>' . $event['message'] . "</li>\n"; } /** @@ -51,7 +53,8 @@ * @param string Log message * @return boolean */ - function log($text) { + function log($text) + { $event['message'] = $text; return $this->notify($event); } http://cvs.php.net/viewcvs.cgi/pearweb/include/Damblan/Search/Lists.php?r1=1.1&r2=1.2&diff_format=u Index: pearweb/include/Damblan/Search/Lists.php diff -u pearweb/include/Damblan/Search/Lists.php:1.1 pearweb/include/Damblan/Search/Lists.php:1.2 --- pearweb/include/Damblan/Search/Lists.php:1.1 Mon Jul 11 19:40:11 2005 +++ pearweb/include/Damblan/Search/Lists.php Thu Apr 13 05:13:01 2006 @@ -15,28 +15,30 @@ +----------------------------------------------------------------------+ | Author: Martin Jansen <mj@php.net> | +----------------------------------------------------------------------+ - $Id: Lists.php,v 1.1 2005/07/11 19:40:11 mj Exp $ + $Id: Lists.php,v 1.2 2006/04/13 05:13:01 dufuz Exp $ */ -require_once "Damblan/Search.php"; +require_once 'Damblan/Search.php'; /** * Mailing list search class * * @author Martin Jansen <mj@php.net> * @package Damblan - * @version $Revision: 1.1 $ + * @version $Revision: 1.2 $ * @extends Damblan_Search */ -class Damblan_Search_Lists extends Damblan_Search { - +class Damblan_Search_Lists extends Damblan_Search +{ var $_list; - function Damblan_Search_Lists($list) { + function Damblan_Search_Lists($list) + { $this->_list = $list; } - function search($term) { + function search($term) + { header('Location: http://marc.theaimsgroup.com/?' . 'l=' . $this->_list . '&w=2&r=1&q=b&s=' . urlencode($term)); http://cvs.php.net/viewcvs.cgi/pearweb/include/Damblan/Search/PEPr.php?r1=1.1&r2=1.2&diff_format=u Index: pearweb/include/Damblan/Search/PEPr.php diff -u pearweb/include/Damblan/Search/PEPr.php:1.1 pearweb/include/Damblan/Search/PEPr.php:1.2 --- pearweb/include/Damblan/Search/PEPr.php:1.1 Mon Jul 11 19:40:11 2005 +++ pearweb/include/Damblan/Search/PEPr.php Thu Apr 13 05:13:01 2006 @@ -15,26 +15,24 @@ +----------------------------------------------------------------------+ | Author: Martin Jansen <mj@php.net> | +----------------------------------------------------------------------+ - $Id: PEPr.php,v 1.1 2005/07/11 19:40:11 mj Exp $ + $Id: PEPr.php,v 1.2 2006/04/13 05:13:01 dufuz Exp $ */ -require_once "Damblan/Search.php"; +require_once 'Damblan/Search.php'; /** * PEPr search class * * @author Martin Jansen <mj@php.net> * @package Damblan - * @version $Revision: 1.1 $ + * @version $Revision: 1.2 $ * @extends Damblan_Search */ -class Damblan_Search_PEPr extends Damblan_Search { - - function Damblan_Search_PEPr() { - } - - function search($term) { - LocalRedirect("/pepr/pepr-overview.php?search=" +class Damblan_Search_PEPr extends Damblan_Search +{ + function search($term) + { + LocalRedirect('/pepr/pepr-overview.php?search=' . urlencode($term)); exit(); } http://cvs.php.net/viewcvs.cgi/pearweb/include/Damblan/Search/Packages.php?r1=1.7&r2=1.8&diff_format=u Index: pearweb/include/Damblan/Search/Packages.php diff -u pearweb/include/Damblan/Search/Packages.php:1.7 pearweb/include/Damblan/Search/Packages.php:1.8 --- pearweb/include/Damblan/Search/Packages.php:1.7 Mon Jul 18 14:47:29 2005 +++ pearweb/include/Damblan/Search/Packages.php Thu Apr 13 05:13:01 2006 @@ -15,29 +15,30 @@ +----------------------------------------------------------------------+ | Author: Martin Jansen <mj@php.net> | +----------------------------------------------------------------------+ - $Id: Packages.php,v 1.7 2005/07/18 14:47:29 mj Exp $ + $Id: Packages.php,v 1.8 2006/04/13 05:13:01 dufuz Exp $ */ -require_once "Damblan/Search.php"; -require_once "Pager/Pager.php"; +require_once 'Damblan/Search.php'; +require_once 'Pager/Pager.php'; -define("ITEMS_PER_PAGE", 10); +define('ITEMS_PER_PAGE', 10); /** * Package search class * * @author Martin Jansen <mj@php.net> * @package Damblan - * @version $Revision: 1.7 $ + * @version $Revision: 1.8 $ * @extends Damblan_Search */ -class Damblan_Search_Packages extends Damblan_Search { - - var $_placeholders = ""; +class Damblan_Search_Packages extends Damblan_Search +{ + var $_placeholders = ''; var $_where; - var $_title = "Packages"; + var $_title = 'Packages'; - function search($term) { + function search($term) + { if (empty($term)) { return; } @@ -50,47 +51,50 @@ } // Select all results - $query = "SELECT SQL_CALC_FOUND_ROWS name, summary FROM packages WHERE " . $this->_where . " ORDER BY name"; - $query .= " LIMIT " . (($pageID - 1) * ITEMS_PER_PAGE) . ", " . ITEMS_PER_PAGE; + $query = 'SELECT SQL_CALC_FOUND_ROWS name, summary FROM packages WHERE ' . $this->_where . ' ORDER BY name'; + $query .= ' LIMIT ' . (($pageID - 1) * ITEMS_PER_PAGE) . ', ' . ITEMS_PER_PAGE; $this->_results = $this->_dbh->getAll($query, null, DB_FETCHMODE_ASSOC); // Get number of overall results - $query = "SELECT FOUND_ROWS()"; + $query = 'SELECT FOUND_ROWS()'; $this->_total = $this->_dbh->getOne($query); $params = array( - "mode" => "Jumping", - "perPage" => ITEMS_PER_PAGE, - "urlVar" => "p", - "itemData" => range(1, $this->_total), - "extraVars" => array("q" => $term) + 'mode' => 'Jumping', + 'perPage' => ITEMS_PER_PAGE, + 'urlVar' => 'p', + 'itemData' => range(1, $this->_total), + 'extraVars' => array('q' => $term) ); $this->_pager =& Pager::factory($params); } - function getResults() { - array_walk($this->_results, array(__CLASS__, "decorate")); + function getResults() + { + array_walk($this->_results, array(__CLASS__, 'decorate')); return $this->_results; } - function getWhere($term) { + function getWhere($term) + { $elements = preg_split("/\s/", $term, -1, PREG_SPLIT_NO_EMPTY); // we are only interested in the first 3 search words $elements = array_slice($elements, 0, 3); foreach ($elements as $t) { - foreach (array("name", "summary") as $field) { - $ors[] = $field . " LIKE " . $this->_dbh->quote("%" . $t . "%"); + foreach (array('name', 'summary') as $field) { + $ors[] = $field . ' LIKE ' . $this->_dbh->quote('%' . $t . '%'); } - $where[] = "(" . implode(" OR ", $ors) . ")"; + $where[] = '(' . implode(' OR ', $ors) . ')'; $ors = array(); } - return implode(" AND ", $where) . " AND approved = 1 AND package_type = 'pear'"; + return implode(' AND ', $where) . " AND approved = 1 AND package_type = 'pear'"; } - function decorate(&$value, $key) { - $value['html'] = "<strong><a href=\"/package/" . $value['name'] . "\">" . $value['name'] . "</a></strong>: " . $value['summary'] . "\n"; + function decorate(&$value, $key) + { + $value['html'] = '<strong><a href="/package/' . $value['name'] . '">' . $value['name'] . '</a></strong>: ' . $value['summary'] . "\n"; } } http://cvs.php.net/viewcvs.cgi/pearweb/include/Damblan/Search/Site.php?r1=1.1&r2=1.2&diff_format=u Index: pearweb/include/Damblan/Search/Site.php diff -u pearweb/include/Damblan/Search/Site.php:1.1 pearweb/include/Damblan/Search/Site.php:1.2 --- pearweb/include/Damblan/Search/Site.php:1.1 Mon Jul 11 19:40:11 2005 +++ pearweb/include/Damblan/Search/Site.php Thu Apr 13 05:13:01 2006 @@ -15,25 +15,23 @@ +----------------------------------------------------------------------+ | Author: Martin Jansen <mj@php.net> | +----------------------------------------------------------------------+ - $Id: Site.php,v 1.1 2005/07/11 19:40:11 mj Exp $ + $Id: Site.php,v 1.2 2006/04/13 05:13:01 dufuz Exp $ */ -require_once "Damblan/Search.php"; +require_once 'Damblan/Search.php'; /** * Site-wide search class * * @author Martin Jansen <mj@php.net> * @package Damblan - * @version $Revision: 1.1 $ + * @version $Revision: 1.2 $ * @extends Damblan_Search */ -class Damblan_Search_Site extends Damblan_Search { - - function Damblan_Search_Site() { - } - - function search($term) { +class Damblan_Search_Site extends Damblan_Search +{ + function search($term) + { header('Location: http://search.yahoo.com/search?vs=' . PEAR_CHANNELNAME . '&va=' . urlencode($term)); exit(); http://cvs.php.net/viewcvs.cgi/pearweb/include/Damblan/Search/Users.php?r1=1.4&r2=1.5&diff_format=u Index: pearweb/include/Damblan/Search/Users.php diff -u pearweb/include/Damblan/Search/Users.php:1.4 pearweb/include/Damblan/Search/Users.php:1.5 --- pearweb/include/Damblan/Search/Users.php:1.4 Mon Jul 18 14:47:29 2005 +++ pearweb/include/Damblan/Search/Users.php Thu Apr 13 05:13:01 2006 @@ -15,28 +15,30 @@ +----------------------------------------------------------------------+ | Author: Martin Jansen <mj@php.net> | +----------------------------------------------------------------------+ - $Id: Users.php,v 1.4 2005/07/18 14:47:29 mj Exp $ + $Id: Users.php,v 1.5 2006/04/13 05:13:01 dufuz Exp $ */ -require_once "Damblan/Search.php"; -require_once "Pager/Pager.php"; +require_once 'Damblan/Search.php'; +require_once 'Pager/Pager.php'; -define("ITEMS_PER_PAGE", 10); +define('ITEMS_PER_PAGE', 10); /** * User search class * * @author Martin Jansen <mj@php.net> * @package Damblan - * @version $Revision: 1.4 $ + * @version $Revision: 1.5 $ * @extends Damblan_Search */ -class Damblan_Search_Users extends Damblan_Search { +class Damblan_Search_Users extends Damblan_Search +{ var $_where; - var $_title = "Developers"; + var $_title = 'Developers'; - function search($term) { + function search($term) + { if (empty($term)) { return; } @@ -49,47 +51,50 @@ } // Select all results - $query = "SELECT SQL_CALC_FOUND_ROWS handle, name FROM users WHERE " . $this->_where . " ORDER BY name"; - $query .= " LIMIT " . (($pageID - 1) * ITEMS_PER_PAGE) . ", " . ITEMS_PER_PAGE; + $query = 'SELECT SQL_CALC_FOUND_ROWS handle, name FROM users WHERE ' . $this->_where . ' ORDER BY name'; + $query .= ' LIMIT ' . (($pageID - 1) * ITEMS_PER_PAGE) . ', ' . ITEMS_PER_PAGE; $this->_results = $this->_dbh->getAll($query, null, DB_FETCHMODE_ASSOC); // Get number of overall results - $query = "SELECT FOUND_ROWS()"; + $query = 'SELECT FOUND_ROWS()'; $this->_total = $this->_dbh->getOne($query); $params = array( - "mode" => "Jumping", - "perPage" => ITEMS_PER_PAGE, - "urlVar" => "p", - "itemData" => range(1, $this->_total), - "extraVars" => array("q" => $term) + 'mode' => 'Jumping', + 'perPage' => ITEMS_PER_PAGE, + 'urlVar' => 'p', + 'itemData' => range(1, $this->_total), + 'extraVars' => array('q' => $term) ); $this->_pager =& Pager::factory($params); } - function getResults() { - array_walk($this->_results, array(__CLASS__, "decorate")); + function getResults() + { + array_walk($this->_results, array(__CLASS__, 'decorate')); return $this->_results; } - function getWhere($term) { + function getWhere($term) + { $elements = preg_split("/\s/", $term, -1, PREG_SPLIT_NO_EMPTY); // we are only interested in the first 3 search words $elements = array_slice($elements, 0, 3); foreach ($elements as $t) { - foreach (array("handle", "name") as $field) { - $ors[] = $field . " LIKE " . $this->_dbh->quote("%" . $t . "%"); + foreach (array('handle', 'name') as $field) { + $ors[] = $field . ' LIKE ' . $this->_dbh->quoteSmart('%' . $t . '%'); } - $where[] = "(" . implode(" OR ", $ors) . ")"; + $where[] = '(' . implode(' OR ', $ors) . ')'; $ors = array(); } - return implode(" AND ", $where) . " AND registered = 1"; + return implode(' AND ', $where) . ' AND registered = 1'; } - function decorate(&$value, $key) { - $value['html'] = "<strong><a href=\"/user/" . $value['handle'] . "\">" . $value['name'] . "</a></strong> (" . $value['handle'] . ")\n"; + function decorate(&$value, $key) + { + $value['html'] = '<strong><a href="/user/' . $value['handle'] . '">' . $value['name'] . '</a></strong> (' . $value['handle'] . ")\n"; } }
« previous php.pear.cvs (#39580) next »