示例#1
0
/**
 * A recursive function to build a html list
 *
 * @param array $matches
 * @param string $list
 * @param int $i
 * @param int $depth
 * @return string
 */
function lesson_importppt_build_list(array &$matches, $list, &$i, $depth) {
    while($i < count($matches[1])) {

        $class = lesson_importppt_isolate_class($matches[1][$i]);

        if (strstr($class, 'B')) {  // make sure we are still working with bullet classes
            if ($class == 'B') {
                $this_depth = 0;  // calling class B depth 0
            } else {
                // set the depth number.  So B1 is depth 1 and B2 is depth 2 and so on
                $this_depth = substr($class, 1);
                if (!is_numeric($this_depth)) {
                    print_error('invalidnum');
                }
            }
            if ($this_depth < $depth) {
                // we are moving back a level in the nesting
                break;
            }
            if ($this_depth > $depth) {
                // we are moving in a lvl in nesting
                $list .= '<ul>';
                $list = lesson_importppt_build_list($matches, $list, $i, $this_depth);
                // once we return back, should go to the start of the while
                continue;
            }
            // no depth changes, so add the match to our list
            if ($cleanstring = lesson_importppt_clean_text($matches[3][$i])) {
                $list .= '<li>'.lesson_importppt_clean_text($matches[3][$i]).'</li>';
            }
            $i++;
        } else {
            // not a B class, so get out of here...
            break;
        }
    }
    // end the list and return it
    $list .= '</ul>';
    return $list;

}
示例#2
0
            $countmatches = count($matches[1]);
            for($i = 0; $i < $countmatches; $i++) { // go through all of our div matches

                $class = lesson_importppt_isolate_class($matches[1][$i]); // first step in isolating the class

                // check for any static classes
                switch ($class) {
                    case 'T':  // class T is used for Titles
                        $page->title = $matches[3][$i];
                        break;
                    case 'B':  // I would guess that all bullet lists would start with B then go to B1, B2, etc
                    case 'B1': // B1-B4 are just insurance, should just hit B and all be taken care of
                    case 'B2':
                    case 'B3':
                    case 'B4':
                        $page->contents[] = lesson_importppt_build_list($matches, '<ul>', $i, 0);  // this is a recursive function that will grab all the bullets and rebuild the list in html
                        break;
                    default:
                        if ($matches[3][$i] != '&#13;') {  // odd crap generated... sigh
                            if (substr($matches[3][$i], 0, 1) == ':') {  // check for leading :    ... hate MS ...
                                $page->contents[] = substr($matches[3][$i], 1);  // get rid of :
                            } else {
                                $page->contents[] = $matches[3][$i];
                            }
                        }
                        break;
                }
            }
            $pages[] = $page;
        }
 // check for any static classes
 switch ($class) {
     case 'T':
         // class T is used for Titles
         $page->title = $matches[3][$i];
         break;
     case 'B':
         // I would guess that all bullet lists would start with B then go to B1, B2, etc
     // I would guess that all bullet lists would start with B then go to B1, B2, etc
     case 'B1':
         // B1-B4 are just insurance, should just hit B and all be taken care of
     // B1-B4 are just insurance, should just hit B and all be taken care of
     case 'B2':
     case 'B3':
     case 'B4':
         $page->contents[] = lesson_importppt_build_list($matches, '<ul>', $i, 0);
         // this is a recursive function that will grab all the bullets and rebuild the list in html
         break;
     default:
         if ($matches[3][$i] != '&#13;') {
             // odd crap generated... sigh
             if (substr($matches[3][$i], 0, 1) == ':') {
                 // check for leading :    ... hate MS ...
                 $page->contents[] = substr($matches[3][$i], 1);
                 // get rid of :
             } else {
                 $page->contents[] = $matches[3][$i];
             }
         }
         break;
 }