/** ConvertList
  * 
  * This function generates a html-list from a plain text which starts list-points with:
  *  #(ordered) or *(unsorted).
  * There are no restrictions with the deepnes of a "list-tree".
  *   
  * @return string
  * @param bool ordered
  * @param string textpart
  */
 function ConvertList($ordered, $textpart)
 {
     // initialize the settings for an ordered or an unsorted list
     $codesequence = '# ';
     $htmlcode = 'ol';
     if (!$ordered) {
         $codesequence = '* ';
         $htmlcode = 'ul';
     }
     $output_text = "\n<{$htmlcode}>";
     // sepeerate the text into single lines
     $lines = explode("\n", $textpart);
     $nodes = '';
     $first = true;
     // go through each line
     foreach ($lines as $line) {
         // get the 'real' content of the line
         $line = substr($line, strpos($line, $codesequence) + strlen($codesequence));
         // check if it's real text or a line which initializes a sublist
         if (TextActions::StartsWith($codesequence, $line)) {
             $nodes .= $line . "\n";
         } else {
             // if it is a 'text'-line make sure if there is a sublist to add before
             if ($nodes != '') {
                 if ($first) {
                     $fist = false;
                     $output_text .= "\n\t<li>";
                 }
                 // add the text of a sublist
                 $output_text .= TextActions::ConvertList($ordered, $nodes) . "\n";
                 $nodes = '';
             }
             // if the line isn't empty add it to the oter code
             if ($line != "") {
                 if (!$first) {
                     $output_text .= "</li>\n\t<li>{$line}";
                 } else {
                     $first = false;
                     $output_text .= "\n\t<li>{$line}";
                 }
             }
         }
     }
     $output_text .= "</li>\n</{$htmlcode}>";
     return $output_text;
 }