$this->mods[$module] = $m = PLModule::factory($module);
$hooks = $m->handlers();
foreach ($hooks as $path=>$hook) {
- $this->hooks->addChild(split('/', $path), $hook);
+ $this->hooks->addChild(explode('/', $path), $hook);
}
}
protected function find_hook()
{
- $p = split('/', $this->path);
+ $p = explode('/', $this->path);
list($hook, $matched, $remain, $aliased) = $this->hooks->findChild($p);
if (empty($hook)) {
return null;
public function near_hook()
{
- $p = split('/', $this->path);
+ $p = explode('/', $this->path);
list($hook, $matched, $remain, $aliased) = $this->hooks->findNearestChild($p);
if (empty($hook)) {
return null;
}
}
+interface PlUserInterface
+{
+ public static function _default_user_callback($login, $results);
+
+ /**
+ * Determines if the @p login is an email address, and an email address not
+ * served locally by plat/al.
+ */
+ public static function isForeignEmailAddress($email);
+}
+
/**
* Represents an user of plat/al (without any further assumption), with a
* special focus on always-used properties (identification fields, display name,
* NOTE: each implementation of plat/al-code MUST subclass PlUser, and name it
* 'User'.
*/
-abstract class PlUser
+abstract class PlUser implements PlUserInterface
{
/**
* User data enumerations.
if (strlen(trim($logins)) == 0) {
return null;
}
- $logins = split("[; ,\r\n\|]+", $logins);
+ $logins = preg_split("/[; ,\r\n\|]+/", $logins);
}
if ($logins) {
return;
}
- abstract public static function _default_user_callback($login, $results);
-
- /**
- * Determines if the @p login is an email address, and an email address not
- * served locally by plat/al.
- */
- abstract public static function isForeignEmailAddress($email);
-
private static function stripBadChars($text)
{
return str_replace(array(' ', "'"), array('-', ''),
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
***************************************************************************/
-function quoted_printable_encode($input, $line_max = 76)
-{
- $lines = preg_split("/(?:\r\n|\r|\n)/", $input);
- $eol = "\n";
- $linebreak = "=0D=0A=\n ";
- $escape = "=";
- $output = "";
+// Use native function if it's available (>= PHP5.3)
+if (!function_exists('quoted_printable_encode')) {
+ function quoted_printable_encode($input, $line_max = 76)
+ {
+ $lines = preg_split("/(?:\r\n|\r|\n)/", $input);
+ $eol = "\n";
+ $linebreak = "=0D=0A=\n ";
+ $escape = "=";
+ $output = "";
- foreach ($lines as $j => $line) {
- $linlen = strlen($line);
- $newline = "";
- for($i = 0; $i < $linlen; $i++) {
- $c = $line{$i};
- $dec = ord($c);
- if ( ($dec == 32) && ($i == ($linlen - 1)) ) {
- // convert space at eol only
- $c = "=20";
- } elseif ( ($dec == 61) || ($dec < 32 ) || ($dec > 126) ) {
- // always encode "\t", which is *not* required
- $c = $escape.strtoupper(sprintf("%02x",$dec));
- }
- if ( (strlen($newline) + strlen($c)) >= $line_max ) { // CRLF is not counted
- $output .= $newline.$escape.$eol;
- $newline = " ";
- }
- $newline .= $c;
- } // end of for
- $output .= $newline;
- if ($j<count($lines)-1) $output .= $linebreak;
+ foreach ($lines as $j => $line) {
+ $linlen = strlen($line);
+ $newline = "";
+ for($i = 0; $i < $linlen; $i++) {
+ $c = $line{$i};
+ $dec = ord($c);
+ if ( ($dec == 32) && ($i == ($linlen - 1)) ) {
+ // convert space at eol only
+ $c = "=20";
+ } elseif ( ($dec == 61) || ($dec < 32 ) || ($dec > 126) ) {
+ // always encode "\t", which is *not* required
+ $c = $escape.strtoupper(sprintf("%02x",$dec));
+ }
+ if ( (strlen($newline) + strlen($c)) >= $line_max ) { // CRLF is not counted
+ $output .= $newline.$escape.$eol;
+ $newline = " ";
+ }
+ $newline .= $c;
+ } // end of for
+ $output .= $newline;
+ if ($j<count($lines)-1) $output .= $linebreak;
+ }
+ return trim($output);
}
- return trim($output);
}
/** genere une chaine aleatoire de 22 caracteres ou moins
);
}
- function handler_valid(&$page)
+ function handler_valid($page)
{
readfile($page->compile_dir.'/valid.html');
exit;
}
- function handler_403(&$page)
+ function handler_403($page)
{
global $globals;
header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden');
$page->coreTpl('403.tpl');
}
- function handler_404(&$page)
+ function handler_404($page)
{
global $globals, $platal;
header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found');
$page->trigError('Cette page n\'existe pas !!!');
}
- function handler_login(&$page)
+ function handler_login($page)
{
$allkeys = func_get_args();
unset($allkeys[0]);
pl_redirect($url);
}
- function handler_favicon(&$page)
+ function handler_favicon($page)
{
global $globals;
pl_cached_content_headers("image/x-icon");
exit;
}
- function handler_robotstxt(&$page)
+ function handler_robotstxt($page)
{
global $globals;
return PL_NOT_FOUND;
}
- function handler_purge_cache(&$page)
+ function handler_purge_cache($page)
{
S::assert_xsrf_token();
http_redirect(empty($_SERVER['HTTP_REFERER']) ? './' : $_SERVER['HTTP_REFERER']);
}
- function handler_kill_sessions(&$page)
+ function handler_kill_sessions($page)
{
kill_sessions();
}
- function handler_bug(&$page)
+ function handler_bug($page)
{
global $globals;
}
}
- function handler_wiki_help(&$page, $action = 'title')
+ function handler_wiki_help($page, $action = 'title')
{
$page->coreTpl('wiki.help.tpl', SIMPLE);
$page->assign('wiki_help', MiniWiki::help($action == 'title'));
}
/// Shared handler for wiki syntax result preview
- function handler_wiki_preview(&$page, $action = 'title')
+ function handler_wiki_preview($page, $action = 'title')
{
pl_content_headers("text/html");
$text = Env::v('text');
exit;
}
- function handler_siteerror(&$page) {
+ function handler_siteerror($page) {
global $globals;
$page->coreTpl('site_errors.tpl');
$file = @file_get_contents($globals->spoolroot . '/spool/tmp/site_errors');
$tree->addChild(array('test', 'hook'), new PlStdHook(array('EngineTest', 'barCallback')));
$page = new TestPage();
- $p = split('/', $path);
+ $p = explode('/', $path);
list($hook, $matched, $remain, $aliased) = $tree->findChild($p);
$matched = join('/', $matched);
$this->assertEquals($expmatched, $matched);