Browse Source

fix for language argument and add language class.

stekkel 23 years ago
parent
commit
db5747eb3f
1 changed files with 25 additions and 5 deletions
  1. 25 5
      class/mime.class

+ 25 - 5
class/mime.class

@@ -332,6 +332,7 @@ class message {
 	            $i++;
 		    $arg_a[] = $msg->parseDisposition($read,&$i);
 		 } else {
+		    $i++;
 		    $arg_a[] = $msg->parseLanguage($read,&$i);
 		 }
 		 $arg_no++;    
@@ -339,8 +340,10 @@ class message {
 	       case 10:
 	         if ($arg_a[0] == 'text' ||
 		       ($arg_a[0] == 'message' && $arg_a[1] == 'rfc822')) {
+		    $i++;		       
  	    	    $arg_a[] = $msg->parseLanguage($read,&$i);
 		 }  else {
+		    $msg->parseParenthesis($read,&$i);
 		    $arg_a[] = ''; /* not yet desribed in rfc2060 */
 		 }
 	       	 $arg_no++;
@@ -689,24 +692,34 @@ class message {
     
     function parseLanguage($read,&$i) {
         /* no idea how to process this one without examples */
-        $arg = '';
+        $arg_a = array();
         while ($read{$i} != ')') {
 	   switch ($read{$i}) {
 	     case '"':
-	       $arg = $this->parseQuote($read,&$i);
+	       $arg_a[] = $this->parseQuote($read,&$i);
 	       break;
 	     case '{': 
-	       $arg = $this->parseLiteral($read,&$i);
+	       $arg_a[] = $this->parseLiteral($read,&$i);
 	       break;
 	     case '(':
-	       $arg = $this->parseProperties($read,&$i);
+	       $arg_a[] = $this->parseProperties($read,&$i);
 	       break;
 	     default:
 	       break;
 	   }
 	   $i++;
         }
-        return $arg;;
+	if (isset($arg_a[0])) {
+	   $lang = new language($arg_a[0]);
+	   if (isset($arg_a[1])) {
+	      $lang->properties = $arg_a[1];
+	   }
+	}
+	if (is_object($lang)) { 
+	   return $lang;
+	} else {
+	   return '';
+        }
     }
     
     function parseParenthesis($read,&$i) {
@@ -856,4 +869,11 @@ class disposition {
   }
 }
 
+class language {
+  function language($name) {
+     $this->name = $name;
+     $this->properties = array();
+  }
+}
+
 ?>