packages: phorum/wordwrap.patch (NEW) - add phorum_wordwrap wrapper which i...

glen glen at pld-linux.org
Thu Jan 27 12:14:47 CET 2011


Author: glen                         Date: Thu Jan 27 11:14:47 2011 GMT
Module: packages                      Tag: HEAD
---- Log message:
- add phorum_wordwrap wrapper which is utf8 safe, patch from raul raat

---- Files affected:
packages/phorum:
   wordwrap.patch (NONE -> 1.1)  (NEW)

---- Diffs:

================================================================
Index: packages/phorum/wordwrap.patch
diff -u /dev/null packages/phorum/wordwrap.patch:1.1
--- /dev/null	Thu Jan 27 12:14:47 2011
+++ packages/phorum/wordwrap.patch	Thu Jan 27 12:14:42 2011
@@ -0,0 +1,210 @@
+--- ./common.php	2010-11-04 18:05:47.000000000 +0200
++++ ./common.php	2011-01-19 13:59:55.000000000 +0200
+@@ -1715,6 +1715,33 @@
+     return $ret_string;
+ }
+ 
++function phorum_wordwrap($str = '', $width = 75, $break = "\n", $cut = false)
++{
++    global $PHORUM;
++
++    if (empty($PHORUM["DATA"]["HCHARSET"]) or !$cut) {
++        // if unable to get charset or word cut not enabled use wordwrap
++        return wordwrap($st, $width, $break, $cut);
++    }
++
++    $l = mb_strlen($str, $PHORUM["DATA"]["HCHARSET"]);
++    if($l == 0) {
++        return '';
++    }
++
++    $pl = 1;
++    $return = '';
++    for ($i = 0; $i < $l ; $i++) {
++        if ($pl > $width) {
++            $return .= $break;
++            $pl = 1;
++        }
++        $return .= mb_substr($str, $i, 1, $PHORUM["DATA"]["HCHARSET"]);
++        $pl++;
++    }
++    return $return;
++}
++
+ // removes slashes from all array-entries
+ function phorum_recursive_stripslashes( $array )
+ {
+--- ./htdocs/login.php	2010-11-04 18:05:47.000000000 +0200
++++ ./htdocs/login.php	2011-01-19 14:01:55.000000000 +0200
+@@ -174,9 +174,9 @@
+                 $maildata["login_url"] = phorum_get_url(PHORUM_LOGIN_URL);
+                 $maildata["mailsubject"] = $PHORUM["DATA"]["LANG"]["VerifyRegEmailSubject"];
+                 $maildata["mailmessage"] =
+-                   wordwrap($PHORUM["DATA"]["LANG"]["VerifyRegEmailBody1"],72).
++                   phorum_wordwrap($PHORUM["DATA"]["LANG"]["VerifyRegEmailBody1"],72).
+                    "\n\n$verify_url\n\n".
+-                   wordwrap($PHORUM["DATA"]["LANG"]["VerifyRegEmailBody2"],72);
++                   phorum_wordwrap($PHORUM["DATA"]["LANG"]["VerifyRegEmailBody2"],72);
+                 phorum_email_user(array($user["email"]), $maildata);
+ 
+                 $okmsg = $PHORUM["DATA"]["LANG"]["RegVerifyEmail"];
+@@ -205,12 +205,12 @@
+                 $maildata["phorum_title"] = $PHORUM['title'];
+                 $maildata["login_url"] = phorum_get_url(PHORUM_LOGIN_URL);
+                 $maildata['mailmessage'] =
+-                   wordwrap($PHORUM["DATA"]["LANG"]["LostPassEmailBody1"],72).
++                   phorum_wordwrap($PHORUM["DATA"]["LANG"]["LostPassEmailBody1"],72).
+                    "\n\n".
+                    $PHORUM["DATA"]["LANG"]["Username"] .": $user[username]\n".
+                    $PHORUM["DATA"]["LANG"]["Password"] .": $newpass".
+                    "\n\n".
+-                   wordwrap($PHORUM["DATA"]["LANG"]["LostPassEmailBody2"],72);
++                   phorum_wordwrap($PHORUM["DATA"]["LANG"]["LostPassEmailBody2"],72);
+                 $maildata['mailsubject'] = $PHORUM["DATA"]["LANG"]["LostPassEmailSubject"];
+                 phorum_email_user(array( 0 => $user['email'] ), $maildata);
+ 
+--- ./htdocs/pm.php	2010-11-04 18:05:47.000000000 +0200
++++ ./htdocs/pm.php	2011-01-19 14:01:55.000000000 +0200
+@@ -1444,7 +1444,7 @@
+         // Build a quoted version of the message body.
+         $quote = phorum_strip_body($message["message"]);
+         $quote = str_replace("\n", "\n> ", $quote);
+-        $quote = wordwrap(trim($quote), 50, "\n> ", true);
++        $quote = phorum_wordwrap(trim($quote), 50, "\n> ", true);
+         $quote = "$author {$PHORUM['DATA']['LANG']['Wrote']}:\n" .
+                  str_repeat("-", 55)."\n> {$quote}\n\n\n";
+     }
+--- ./htdocs/register.php	2010-11-04 18:05:47.000000000 +0200
++++ ./htdocs/register.php	2011-01-19 14:01:55.000000000 +0200
+@@ -256,9 +256,9 @@
+                     $maildata["login_url"] = phorum_get_url(PHORUM_LOGIN_URL);
+                     $maildata["mailsubject"] = $PHORUM["DATA"]["LANG"]["VerifyRegEmailSubject"];
+                     $maildata["mailmessage"] =
+-                       wordwrap($PHORUM["DATA"]["LANG"]["VerifyRegEmailBody1"],72).
++                       phorum_wordwrap($PHORUM["DATA"]["LANG"]["VerifyRegEmailBody1"],72).
+                        "\n\n$verify_url\n\n".
+-                       wordwrap($PHORUM["DATA"]["LANG"]["VerifyRegEmailBody2"],72);
++                       phorum_wordwrap($PHORUM["DATA"]["LANG"]["VerifyRegEmailBody2"],72);
+                     phorum_email_user(array($userdata["email"]), $maildata);
+                 }
+ 
+--- ./htdocs/report.php	2010-11-04 18:05:47.000000000 +0200
++++ ./htdocs/report.php	2011-01-19 14:01:55.000000000 +0200
+@@ -62,11 +62,11 @@
+                 "reportedby"  => $PHORUM["user"]["display_name"],
+                 "author"      => $message["author"],
+                 "subject"     => $message["subject"],
+-                "body"        => wordwrap($message["body"], 72),
++                "body"        => phorum_wordwrap($message["body"], 72),
+                 "ip"          => $message["ip"],
+                 "raw_date"    => $message["datestamp"],
+                 "date"        => phorum_date($PHORUM["short_date_time"], $message["datestamp"]),
+-                "explanation" => wordwrap($_POST["explanation"], 72),
++                "explanation" => phorum_wordwrap($_POST["explanation"], 72),
+                 "url"         => phorum_get_url_no_uri_auth(PHORUM_READ_URL, $message["thread"], $message_id),
+                 "delete_url"  => phorum_get_url_no_uri_auth(PHORUM_MODERATION_URL, PHORUM_DELETE_MESSAGE, $message_id),
+                 "hide_url"    => phorum_get_url_no_uri_auth(PHORUM_MODERATION_URL, PHORUM_HIDE_POST, $message_id),
+--- ./include/admin/mods.php	2010-11-04 18:05:47.000000000 +0200
++++ ./include/admin/mods.php	2011-01-19 14:01:55.000000000 +0200
+@@ -96,7 +96,7 @@
+         $text.=" (version ".$info["version"].")";
+     }
+     if(isset($info["desc"])){
+-        $text.="<div class=\"small\">".wordwrap($info["desc"], 90, "<br />")."</div>";
++        $text.="<div class=\"small\">".phorum_wordwrap($info["desc"], 90, "<br />")."</div>";
+     }
+     if(isset($info["author"])){
+         $text.="<div class=\"small\">Created by ".$info["author"]."</div>";
+--- ./include/cache/file.php	2010-11-04 18:05:46.000000000 +0200
++++ ./include/cache/file.php	2011-01-19 14:01:55.000000000 +0200
+@@ -42,7 +42,7 @@
+     if(is_array($key)) {
+         $ret=array();
+         foreach($key as $realkey) {
+-            $path=$partpath."/".wordwrap(md5($realkey), PHORUM_CACHE_SPLIT, "/", true)."/data.php";
++            $path=$partpath."/".phorum_wordwrap(md5($realkey), PHORUM_CACHE_SPLIT, "/", true)."/data.php";
+             if(file_exists($path)) {
+                 // the data is: array($ttl_time,$data,$version)
+                 // $version might not be set.
+@@ -66,7 +66,7 @@
+         if(count($ret) == 0) $ret = NULL;
+ 
+     } else {
+-        $path=$partpath."/".wordwrap(md5($key), PHORUM_CACHE_SPLIT, "/", true)."/data.php";
++        $path=$partpath."/".phorum_wordwrap(md5($key), PHORUM_CACHE_SPLIT, "/", true)."/data.php";
+         if(!file_exists($path)){
+             $ret=NULL;
+         } else {
+@@ -101,7 +101,7 @@
+  */
+ function phorum_cache_put($type,$key,$data,$ttl=PHORUM_CACHE_DEFAULT_TTL,$version = NULL) {
+ 
+-    $path=$GLOBALS['PHORUM']['real_cache']."/$type/".wordwrap(md5($key), PHORUM_CACHE_SPLIT, "/", true);
++    $path=$GLOBALS['PHORUM']['real_cache']."/$type/".phorum_wordwrap(md5($key), PHORUM_CACHE_SPLIT, "/", true);
+     if(!file_exists($path)){
+         phorum_cache_mkdir($path);
+     }
+@@ -120,7 +120,7 @@
+ function phorum_cache_remove($type,$key) {
+ 
+     $ret  =true;
+-    $path=$GLOBALS['PHORUM']['real_cache']."/$type/".wordwrap(md5($key), PHORUM_CACHE_SPLIT, "/", true)."/data.php";
++    $path=$GLOBALS['PHORUM']['real_cache']."/$type/".phorum_wordwrap(md5($key), PHORUM_CACHE_SPLIT, "/", true)."/data.php";
+     if(file_exists($path)) {
+         $ret=@unlink($path);
+     }
+--- ./include/controlcenter/email.php	2010-11-04 18:05:47.000000000 +0200
++++ ./include/controlcenter/email.php	2011-01-19 14:01:55.000000000 +0200
+@@ -65,7 +65,7 @@
+             $_POST['email_temp']=$_POST['email']."|".$conf_code;
+             // ... send email ... //
+             $maildata=array(
+-                'mailmessage'   => wordwrap($PHORUM['DATA']['LANG']['EmailVerifyBody'], 72),
++                'mailmessage'   => phorum_wordwrap($PHORUM['DATA']['LANG']['EmailVerifyBody'], 72),
+                 'mailsubject'   => $PHORUM['DATA']['LANG']['EmailVerifySubject'],
+                 'phorum_title'  => $PHORUM['title'],
+                 'uname'         => $PHORUM['DATA']['PROFILE']['username'],
+--- ./include/controlcenter/users.php	2010-11-04 18:05:47.000000000 +0200
++++ ./include/controlcenter/users.php	2011-01-19 14:01:55.000000000 +0200
+@@ -50,7 +50,7 @@
+                 $userdata["active"]=PHORUM_USER_ACTIVE;
+                 // send reg approved message
+                 $maildata["mailsubject"]=$PHORUM["DATA"]["LANG"]["RegApprovedSubject"];
+-                $maildata["mailmessage"]=wordwrap($PHORUM["DATA"]["LANG"]["RegApprovedEmailBody"], 72);
++                $maildata["mailmessage"]=phorum_wordwrap($PHORUM["DATA"]["LANG"]["RegApprovedEmailBody"], 72);
+                 $maildata["phorum_title"]=$PHORUM['title'];
+                 phorum_email_user(array($user["email"]), $maildata);
+                 
+--- ./include/email_functions.php	2010-11-04 18:05:47.000000000 +0200
++++ ./include/email_functions.php	2011-01-19 14:01:55.000000000 +0200
+@@ -278,7 +278,7 @@
+         "author"         => phorum_api_user_get_display_name($message["user_id"], $message["from_username"], PHORUM_FLAG_PLAINTEXT),
+         "subject"        => $message["subject"],
+         "full_body"      => $message["message"],
+-        "plain_body"     => wordwrap(phorum_strip_body($message["message"]),72),
++        "plain_body"     => phorum_wordwrap(phorum_strip_body($message["message"]),72),
+         "read_url"       => phorum_get_url_no_uri_auth(PHORUM_PM_URL, "page=read", "pm_id=" . $message["pm_message_id"]),
+         "phorum_title"   => $PHORUM['title'],
+ 
+--- ./include/posting/request_first.php	2010-11-04 18:05:46.000000000 +0200
++++ ./include/posting/request_first.php	2011-01-19 14:01:55.000000000 +0200
+@@ -83,7 +83,7 @@
+         {
+             $quoted = phorum_strip_body($dbmessage["body"]);
+             $quoted = str_replace("\n", "\n> ", $quoted);
+-            $quoted = wordwrap(trim($quoted), 50, "\n> ", true);
++            $quoted = phorum_wordwrap(trim($quoted), 50, "\n> ", true);
+             $quoted = "$author " .
+                       "{$PHORUM["DATA"]["LANG"]["Wrote"]}:\n" .
+                       str_repeat("-", 55) . "\n> $quoted\n\n\n";
+--- ./include/thread_sort.php	2010-11-04 18:05:46.000000000 +0200
++++ ./include/thread_sort.php	2011-01-19 14:01:55.000000000 +0200
+@@ -101,7 +101,7 @@
+                 $cut_len = $cut_max - $indent*$cut_indentfactor;
+                 if ($cut_len < $cut_min) $cut_len = $cut_min;
+                 $order[$curr_id]["subject"] =
+-                    wordwrap($order[$curr_id]["subject"], $cut_len, " ", TRUE);
++                    phorum_wordwrap($order[$curr_id]["subject"], $cut_len, " ", TRUE);
+             }
+         }
+         array_push($stack, $curr_id);
================================================================


More information about the pld-cvs-commit mailing list