Julio Montoya 11 лет назад
Родитель
Сommit
255c085700
66 измененных файлов с 15312 добавлено и 1882 удалено
  1. 2 1
      composer.json
  2. 1 0
      main/inc/global.inc.php
  3. 20 3
      main/inc/services.php
  4. 43 1528
      main/wiki/index.php
  5. 280 303
      main/wiki/wiki.inc.php
  6. 97 1
      src/ChamiloLMS/Component/DataFilesystem/DataFilesystem.php
  7. 24 9
      src/ChamiloLMS/Component/Editor/Connector.php
  8. 16 2
      src/ChamiloLMS/Component/Editor/Driver/CourseDriver.php
  9. 1 1
      src/ChamiloLMS/Component/Editor/Driver/CourseUserDriver.php
  10. 1 1
      src/ChamiloLMS/Component/Editor/Driver/DropBoxDriver.php
  11. 1 1
      vendor/autoload.php
  12. 0 24
      vendor/composer/autoload_classmap.php
  13. 1 0
      vendor/composer/autoload_namespaces.php
  14. 5 5
      vendor/composer/autoload_real.php
  15. 45 0
      vendor/composer/installed.json
  16. 38 0
      vendor/sunra/php-simple-html-dom-parser/README.md
  17. 20 0
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/HtmlDomParser.php
  18. 891 0
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/app/google.htm
  19. 144 0
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/app/index.php
  20. BIN
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/app/js/images/treeview-default-line.gif
  21. BIN
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/app/js/images/treeview-default.gif
  22. 3363 0
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/app/js/jquery.js
  23. 68 0
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/app/js/jquery.treeview.css
  24. 251 0
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/app/js/jquery.treeview.js
  25. 24 0
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/app/js/screen.css
  26. 109 0
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/change_log.txt
  27. 54 0
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/example/example_advanced_selector.php
  28. 37 0
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/example/example_basic_selector.php
  29. 28 0
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/example/example_callback.php
  30. 5 0
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/example/example_extract_html.php
  31. 18 0
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/example/example_modify_contents.php
  32. 44 0
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/example/scraping/example_scraping_digg.php
  33. 51 0
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/example/scraping/example_scraping_imdb.php
  34. 35 0
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/example/scraping/example_scraping_slashdot.php
  35. 35 0
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/example/simple_html_dom_utility.php
  36. 113 0
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/manual/css/default.css
  37. 116 0
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/manual/css/ui.tabs.css
  38. BIN
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/manual/img/tab.png
  39. 10 0
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/manual/js/jquery-1.2.3.pack.js
  40. 9 0
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/manual/js/ui.tabs.pack.js
  41. 448 0
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/manual/manual.htm
  42. 320 0
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/manual/manual_api.htm
  43. 91 0
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/manual/manual_faq.htm
  44. 1721 0
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/simple_html_dom.php
  45. 24 0
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/testcase/all_test.php
  46. 74 0
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/testcase/callback_testcase.php
  47. 386 0
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/testcase/dom_testcase.php
  48. 247 0
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/testcase/element_testcase.php
  49. 658 0
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/testcase/invalid_testcase.php
  50. 10 0
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/testcase/jquery-1.2.3.pack.js
  51. 68 0
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/testcase/mass_test.php
  52. 121 0
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/testcase/memory_test.php
  53. 60 0
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/testcase/misc_testcase.php
  54. 40 0
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/testcase/performance_test.php
  55. 12 0
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/testcase/reader/all_test.php
  56. 243 0
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/testcase/reader/element_testcase.php
  57. 103 0
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/testcase/reader/memory_test.php
  58. 38 0
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/testcase/reader/performance_test.php
  59. 584 0
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/testcase/reader/selector_testcase.php
  60. 742 0
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/testcase/selector_testcase.php
  61. 27 0
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/testcase/slick_test.php
  62. 2888 0
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/testcase/slickspeed.htm
  63. 243 0
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/testcase/std_testcase.php
  64. 137 0
      vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/testcase/strip_testcase.php
  65. 24 0
      vendor/sunra/php-simple-html-dom-parser/composer.json
  66. 3 3
      web/ChamiloLMS/css/base.css

+ 2 - 1
composer.json

@@ -86,7 +86,8 @@
         "opauth/google": "0.2.2",
         "media-alchemyst/media-alchemyst": "0.3.6",
         "php-ffmpeg/php-ffmpeg": "0.4.4",
-        "php-unoconv/php-unoconv": "0.3.0"
+        "php-unoconv/php-unoconv": "0.3.0",
+        "sunra/php-simple-html-dom-parser": "1.5.0"
     },
     "require-dev": {
         "knplabs/gaufrette": "0.2.*@dev",

+ 1 - 0
main/inc/global.inc.php

@@ -584,6 +584,7 @@ $app->before(
         } else {
             $app['course'] = null;
         }
+        $app['session']->set('course_session', $app['course']);
 
         $studentView = $request->get('isStudentView');
         if (!empty($studentView)) {

+ 20 - 3
main/inc/services.php

@@ -637,7 +637,12 @@ class ChamiloServiceProvider implements ServiceProviderInterface
 
         // Chamilo data filesystem.
         $app['chamilo.filesystem'] = $app->share(function () use ($app) {
-            $filesystem = new ChamiloLMS\Component\DataFilesystem\DataFilesystem($app['paths'], $app['filesystem']);
+            $filesystem = new ChamiloLMS\Component\DataFilesystem\DataFilesystem(
+                $app['paths'],
+                $app['filesystem'],
+                $app['editor_connector'],
+                $app['unoconv']
+            );
             return $filesystem;
         });
 
@@ -857,6 +862,7 @@ $app['html_editor'] = $app->share(function($app) {
 $app['editor_connector'] = $app->share(function ($app) {
     $token = $app['security']->getToken();
     $user = $token->getUser();
+    $course = $app['session']->get('course_session');
 
     return new Connector(
         $app['orm.em'],
@@ -865,15 +871,26 @@ $app['editor_connector'] = $app->share(function ($app) {
         $app['translator'],
         $app['security'],
         $user,
-        $app['course']
+        $course
     );
 });
 
 
+$app->register(new Unoconv\UnoconvServiceProvider(), array(
+    'unoconv.configuration' => array(
+        'unoconv.binaries' => $app['configuration']['unoconv.binaries'],
+        'timeout'          => 42,
+    ),
+    'unoconv.logger'  => $app->share(function () use ($app) {
+        return $app['monolog']; // use Monolog service provider
+    }),
+));
+
+
 /*
 $app->register(
     new ChamiloLMS\Provider\BootstrapSilexProvider(),
     array(
 
     )
-);*/
+);*/

+ 43 - 1528
main/wiki/index.php

@@ -9,20 +9,15 @@
 /**
  * Code
  */
+use \ChamiloSession as Session;
+
 // name of the language file that needs to be included
 $language_file = 'wiki';
-$newtitle = null;
 
 // including the global initialization file
 require_once '../inc/global.inc.php';
 require_once 'wiki.inc.php';
 
-// Database table definition
-$tbl_wiki           = Database::get_course_table(TABLE_WIKI);
-$tbl_wiki_discuss   = Database::get_course_table(TABLE_WIKI_DISCUSS);
-$tbl_wiki_mailcue   = Database::get_course_table(TABLE_WIKI_MAILCUE);
-$tbl_wiki_conf      = Database::get_course_table(TABLE_WIKI_CONF);
-
 global $charset;
 
 $wiki = new Wiki();
@@ -34,6 +29,11 @@ $current_course_tool  = TOOL_WIKI;
 //require_once api_get_path(LIBRARY_PATH).'mail.lib.inc.php';
 
 $course_id = api_get_course_int_id();
+$session_id = api_get_session_id();
+$condition_session = api_get_session_condition($session_id);
+$course_id = api_get_course_int_id();
+$groupId = api_get_group_id();
+
 // additional style information
 $htmlHeadXtra[] ='<link rel="stylesheet" type="text/css" href="'.api_get_path(WEB_CODE_PATH).'wiki/css/default.css"/>';
 
@@ -42,43 +42,31 @@ $htmlHeadXtra[] = '<script>
 function advanced_parameters() {
     if (document.getElementById(\'options\').style.display == \'none\') {
         document.getElementById(\'options\').style.display = \'block\';
-        document.getElementById(\'plus_minus\').innerHTML=\'&nbsp;'.Display::return_icon('div_hide.gif',get_lang('Hide'),array('style'=>'vertical-align:middle')).'&nbsp;'.get_lang('AdvancedParameters').'\';
+        document.getElementById(\'plus_minus\').innerHTML=\'&nbsp;'.Display::return_icon('div_hide.gif', get_lang('Hide'), array('style'=>'vertical-align:middle')).'&nbsp;'.get_lang('AdvancedParameters').'\';
     } else {
         document.getElementById(\'options\').style.display = \'none\';
-        document.getElementById(\'plus_minus\').innerHTML=\'&nbsp;'.Display::return_icon('div_show.gif',get_lang('Show'),array('style'=>'vertical-align:middle')).'&nbsp;'.get_lang('AdvancedParameters').'\';
+        document.getElementById(\'plus_minus\').innerHTML=\'&nbsp;'.Display::return_icon('div_show.gif', get_lang('Show'), array('style'=>'vertical-align:middle')).'&nbsp;'.get_lang('AdvancedParameters').'\';
     }
 }
-function setFocus(){
+function setFocus() {
     $("#search_title").focus();
 }
 
-$(document).ready(function () {
+$(document).ready(function() {
     setFocus();
+    $("#start_date_toggle").click(function() {
+        $("#start_date").toggle();
+    });
+
+    $("#end_date_toggle").click(function() {
+        $("#end_date").toggle();
+    });
 });
 
 </script>';
 
 /* Constants and variables */
 $tool_name = get_lang('ToolWiki');
-$MonthsLong = array(
-    get_lang("JanuaryLong"),
-    get_lang("FebruaryLong"),
-    get_lang("MarchLong"),
-    get_lang("AprilLong"),
-    get_lang("MayLong"),
-    get_lang("JuneLong"),
-    get_lang("JulyLong"),
-    get_lang("AugustLong"),
-    get_lang("SeptemberLong"),
-    get_lang("OctoberLong"),
-    get_lang("NovemberLong"),
-    get_lang("DecemberLong")
-);
-
-//condition for the session
-$session_id = api_get_session_id();
-$condition_session = api_get_session_condition($session_id);
-$course_id = api_get_course_int_id();
 
 /* ACCESS */
 api_protect_course_script();
@@ -87,1531 +75,58 @@ api_block_anonymous_users();
 /* TRACKING */
 event_access_tool(TOOL_WIKI);
 
-/* HEADER & TITLE */
-// If it is a group wiki then the breadcrumbs will be different.
-
-// Setting variable
-$groupId = api_get_group_id();
-
 if ($groupId) {
     $group_properties = GroupManager::get_group_properties($groupId);
-    $interbreadcrumb[] = array("url" => "../group/group.php", "name" => get_lang('Groups'));
-    $interbreadcrumb[] = array("url"=>"../group/group_space.php?gidReq=".$groupId, "name"=> get_lang('GroupSpace').' '.$group_properties['name']);
-
-    $add_group_to_title = ' '.$group_properties['name'];
-    $groupfilter='group_id="'.$groupId.'"';
-
+    $interbreadcrumb[] = array("url" => api_get_path(WEB_CODE_PATH)."group/group.php", "name" => get_lang('Groups'));
+    $interbreadcrumb[] = array(
+        "url" => api_get_path(WEB_CODE_PATH)."group/group_space.php?gidReq=".$groupId,
+        "name" => get_lang('GroupSpace').' '.$group_properties['name']
+    );
     //ensure this tool in groups whe it's private or deactivated
     if ($group_properties['wiki_state'] == 0) {
         api_not_allowed();
     } elseif ($group_properties['wiki_state']==2) {
-        if (!api_is_allowed_to_edit(false,true) and !GroupManager :: is_user_in_group($_user['user_id'], $_SESSION['_gid'])) {
+        if (!api_is_allowed_to_edit(false,true) and !GroupManager :: is_user_in_group(api_get_user_id(), api_get_group_id())) {
             api_not_allowed();
         }
     }
-} else {
-    $groupfilter='group_id=0';
-}
-
-if (isset($_POST['action']) && $_POST['action']=='export_to_pdf' && isset($_POST['wiki_id']) && api_get_setting('students_export2pdf') == 'true') {
-    $wiki->export_to_pdf($_POST['wiki_id'], api_get_course_id());
-    exit;
 }
 
-$action = isset($_GET['action']) ? $_GET['action'] : null;
-Display::display_header($tool_name, 'Wiki');
 $is_allowed_to_edit = api_is_allowed_to_edit(false, true);
-/* INITIALISATION */
 
-//the page we are dealing with
-if (!isset($_GET['title'])) {
-    $page = 'index';
-} else {
-    $page = $_GET['title'];
-}
+// The page we are dealing with
+$page = isset($_GET['title']) ? $_GET['title']: 'index';
+$action = isset($_GET['action']) ? $_GET['action'] : 'showpage';
+$view = isset($_GET['view']) ? $_GET['view'] : null;
 
 $wiki->page = $page;
+$wiki->action = $action;
 
 /* MAIN CODE */
 
-// Tool introduction
-Display::display_introduction_section(TOOL_WIKI);
-
 /* ACTIONS */
 $wiki->blockConcurrentEditions(api_get_user_id(), $action);
 
-// Saving a change
-
-if (isset($_POST['SaveWikiChange']) AND $_POST['title']<>'') {
-    if (empty($_POST['title'])) {
-        Display::display_error_message(get_lang("NoWikiPageTitle"));
-    } elseif (!$wiki->double_post($_POST['wpost_id'])) {
-        //double post
-    } elseif ($_POST['version']!='' && $_SESSION['_version']!=0 && $_POST['version']!=$_SESSION['_version']) {
-        //prevent concurrent users and double version
-        Display::display_error_message(get_lang("EditedByAnotherUser"));
-    } else {
-        $return_message = $wiki->save_wiki();
-        Display::display_confirmation_message($return_message, false);
-    }
-}
-
-// Saving a new wiki entry
-if (isset($_POST['SaveWikiNew'])) {
-    if (empty($_POST['title'])) {
-        Display::display_error_message(get_lang("NoWikiPageTitle"));
-    } elseif (strtotime($wiki->get_date_from_select('startdate_assig')) > strtotime($wiki->get_date_from_select('enddate_assig'))) {
-        Display::display_error_message(get_lang("EndDateCannotBeBeforeTheStartDate"));
-    } elseif (!$wiki->double_post($_POST['wpost_id'])) {
-        //double post
-    } else {
-        $_clean['assignment'] = null;
-        if (isset($_POST['assignment'])) {
-            // for mode assignment
-            $_clean['assignment'] = Database::escape_string($_POST['assignment']);
-        }
-
-        if ($_clean['assignment'] == 1) {
-            $wiki->auto_add_page_users($_clean['assignment']);
-        }
-        $return_message = $wiki->save_new_wiki();
-        if ($return_message == false) {
-            Display::display_error_message(get_lang('NoWikiPageTitle'), false);
-        } else {
-            Display::display_confirmation_message($return_message, false);
-        }
-    }
-}
-
-// check last version
-if (isset($_GET['view']) && $_GET['view']) {
-    $sql = 'SELECT * FROM '.$tbl_wiki.'
-            WHERE
-                c_id = '.$course_id.' AND
-                id="'.Database::escape_string($_GET['view']).'"'; //current view
-    $result=Database::query($sql);
-    $current_row=Database::fetch_array($result);
-
-    $sql = 'SELECT * FROM '.$tbl_wiki.'
-            WHERE c_id = '.$course_id.' AND reflink="'.Database::escape_string($page).'" AND '.$groupfilter.$condition_session.' ORDER BY id DESC'; //last version
-    $result=Database::query($sql);
-    $last_row=Database::fetch_array($result);
-
-    if ($_GET['view'] < $last_row['id']) {
-       $message = '<center>'.get_lang('NoAreSeeingTheLastVersion').'<br /> '.get_lang("Version").' (<a href="index.php?cidReq='.$_course['id'].'&action=showpage&amp;title='.api_htmlentities(urlencode($current_row['reflink'])).'&group_id='.$current_row['group_id'].'&session_id='.$current_row['session_id'].'&view='.api_htmlentities($_GET['view']).'" title="'.get_lang('CurrentVersion').'">'.$current_row['version'].'</a> / <a href="index.php?cidReq='.$_course['id'].'&action=showpage&amp;title='.api_htmlentities(urlencode($last_row['reflink'])).'&group_id='.$last_row['group_id'].'&session_id='.$last_row['session_id'].'" title="'.get_lang('LastVersion').'">'.$last_row['version'].'</a>) <br />'.get_lang("ConvertToLastVersion").': <a href="index.php?cidReq='.$_course['id'].'&action=restorepage&amp;title='.api_htmlentities(urlencode($last_row['reflink'])).'&group_id='.$last_row['group_id'].'&session_id='.$last_row['session_id'].'&view='.api_htmlentities($_GET['view']).'">'.get_lang("Restore").'</a></center>';
-       Display::display_warning_message($message,false);
-    }
-
-    // Restore page.
-
-    if ($action == 'restorepage') {
-        //Only teachers and platform admin can edit the index page. Only teachers and platform admin can edit an assignment teacher
-        if ((
-            $current_row['reflink']=='index' ||
-            $current_row['reflink']=='' ||
-            $current_row['assignment'] == 1
-            ) &&
-            (!api_is_allowed_to_edit(false,true) && intval($_GET['group_id'])==0)
-        ) {
-            Display::display_normal_message(get_lang('OnlyEditPagesCourseManager'));
-        } else {
-            $PassEdit=false;
-
-            //check if is a wiki group
-            if ($current_row['group_id'] != 0) {
-				//Only teacher, platform admin and group members can edit a wiki group
-				if (api_is_allowed_to_edit(false,true) || api_is_platform_admin() || GroupManager :: is_user_in_group($_user['user_id'],intval($_GET['group_id']))) {
-                    $PassEdit = true;
-                } else {
-                    Display::display_normal_message(get_lang('OnlyEditPagesGroupMembers'));
-                }
-            } else {
-                $PassEdit=true;
-            }
-
-            // check if is an assignment
-            $icon_assignment = null;
-            if ($current_row['assignment']==1) {
-                Display::display_normal_message(get_lang('EditAssignmentWarning'));
-                $icon_assignment=Display::return_icon('wiki_assignment.png', get_lang('AssignmentDescExtra'),'',ICON_SIZE_SMALL);
-            } elseif($current_row['assignment']==2) {
-                $icon_assignment=Display::return_icon('wiki_work.png', get_lang('AssignmentWorkExtra'),'',ICON_SIZE_SMALL);
-                if ((api_get_user_id()==$current_row['user_id'])==false) {
-                    if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
-                        $PassEdit=true;
-                    } else {
-                        Display::display_warning_message(get_lang('LockByTeacher'));
-                        $PassEdit=false;
-                    }
-                } else {
-                    $PassEdit=true;
-                }
-            }
-
-            //show editor if edit is allowed
-            if ($PassEdit) {
-                if ($row['editlock']==1 && (api_is_allowed_to_edit(false,true)==false || api_is_platform_admin()==false)) {
-                    Display::display_normal_message(get_lang('PageLockedExtra'));
-                } else {
-                    if ($last_row['is_editing']!=0 && $last_row['is_editing'] != $_user['user_id']) {
-                        //checking for concurrent users
-                        $timestamp_edit = strtotime($last_row['time_edit']);
-                        $time_editing = time()-$timestamp_edit;
-                        $max_edit_time = 1200; // 20 minutes
-                        $rest_time = $max_edit_time - $time_editing;
-                        $userinfo = api_get_user_info($last_row['is_editing']);
-                        $username = api_htmlentities(sprintf(get_lang('LoginX'), $userinfo['username']), ENT_QUOTES);
-                        $is_being_edited = get_lang('ThisPageisBeginEditedBy').' <a href=../user/userInfo.php?uInfo='.$userinfo['user_id'].'>'.
-                            Display::tag('span', api_get_person_name($userinfo['firstname'], $userinfo['lastname'], array('title'=>$username))).
-                            get_lang('ThisPageisBeginEditedTryLater').' '.date( "i",$rest_time).' '.get_lang('MinMinutes');
-                        Display::display_normal_message($is_being_edited, false);
-                    } else {
-                         Display::display_confirmation_message(
-                             $wiki->restore_wikipage(
-                                 $current_row['page_id'],
-                                 $current_row['reflink'],
-                                 api_htmlentities($current_row['title']),
-                                 api_htmlentities($current_row['content']),
-                                 $current_row['group_id'],
-                                 $current_row['assignment'],
-                                 $current_row['progress'],
-                                 $current_row['version'],
-                                 $last_row['version'],
-                                 $current_row['linksto']
-                             ).': <a href="index.php?cidReq='.$_course['id'].'&action=showpage&amp;title='.api_htmlentities(urlencode($last_row['reflink'])).'&session_id='.$last_row['session_id'].'&group_id='.$last_row['group_id'].'">'.api_htmlentities($last_row['title']).'</a>',
-                             false
-                         );
-                    }
-                }
-            }
-        }
-    }
-}
-
-if ($action == 'deletewiki') {
-    if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) {
-        if ($_GET['delete'] == 'yes') {
-            $return_message = $wiki->delete_wiki();
-            Display::display_confirmation_message($return_message);
-        }
-    }
-}
-if ($action =='discuss' && isset($_POST['Submit']) && $_POST['Submit']) {
-    Display::display_confirmation_message(get_lang('CommentAdded'));
-}
-
 /* MAIN WIKI AREA */
 
-/** menuwiki (= actions of the page, not of the wiki tool) **/
-
-echo '<div class="actions">';
-/*        echo '&nbsp;<a href="index.php?cidReq='.$_course['id'].'&action=show&amp;title=index&session_id='.$session_id.'&group_id='.$groupId.'"'.$wiki->is_active_navigation_tab('show').'>'.
-    Display::return_icon('wiki.png',get_lang('HomeWiki'),'',ICON_SIZE_MEDIUM).'</a>&nbsp;';*/
-echo '<ul class="nav" style="margin-bottom:0px">
-    <li class="dropdown">
-    <a class="dropdown-toggle" href="javascript:void(0)">'.Display::return_icon('menu.png', get_lang('Menu'), '', ICON_SIZE_MEDIUM).'</a>';
-// menu home
-echo '<ul class="dropdown-menu">';
-echo '<li><a href="index.php?cidReq='.$_course['id'].'&session_id='.$session_id.'&group_id='.$groupId.'">'.get_lang('Home').'</a></li>';
-if (api_is_allowed_to_session_edit(false,true)) {
-    //menu add page
-    echo '<li><a href="index.php?cidReq='.$_course['id'].'&action=addnew&session_id='.$session_id.'&group_id='.$groupId.'"'.$wiki->is_active_navigation_tab('addnew').'>'.get_lang('AddNew').'</a>';
-}
-$lock_unlock_addnew = null;
-$protect_addnewpage = null;
-
-if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
-    // page action: enable or disable the adding of new pages
-    if ($wiki->check_addnewpagelock()==0) {
-        $protect_addnewpage = Display::return_icon('off.png', get_lang('AddOptionProtected'));
-        $lock_unlock_addnew ='unlockaddnew';
-    } else {
-        $protect_addnewpage = Display::return_icon('on.png', get_lang('AddOptionUnprotected'));
-        $lock_unlock_addnew ='lockaddnew';
-    }
-}
-
-echo '<a href="index.php?action=show&amp;actionpage='.$lock_unlock_addnew.'&amp;title='.api_htmlentities(urlencode($page)).'">'.$protect_addnewpage.'</a></li>';
-// menu find
-echo '<li><a href="index.php?cidReq='.$_course['id'].'&action=searchpages&session_id='.$session_id.'&group_id='.$groupId.'"'.$wiki->is_active_navigation_tab('searchpages').'>'.get_lang('SearchPages').'</a></li>';
-// menu all pages
-echo '<li><a href="index.php?cidReq='.$_course['id'].'&action=allpages&session_id='.$session_id.'&group_id='.$groupId.'"'.$wiki->is_active_navigation_tab('allpages').'>'.get_lang('AllPages').'</a></li>';
-// menu recent changes
-echo '<li><a href="index.php?cidReq='.$_course['id'].'&action=recentchanges&session_id='.$session_id.'&group_id='.$groupId.'"'.$wiki->is_active_navigation_tab('recentchanges').'>'.get_lang('RecentChanges').'</a></li>';
-// menu delete all wiki
-if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
-    echo '<li><a href="index.php?action=deletewiki&amp;title='.api_htmlentities(urlencode($page)).'"'.$wiki->is_active_navigation_tab('deletewiki').'>'.get_lang('DeleteWiki').'</a></li>';
-}
-///menu more
-echo '<li><a href="index.php?action=more&amp;title='.api_htmlentities(urlencode($page)).'"'.$wiki->is_active_navigation_tab('more').'>'.get_lang('Statistics').'</a></li>';
-echo '</ul>';
-echo '</li>';
-
-//menu show page
-echo '<a href="index.php?cidReq='.$_course['id'].'&action=showpage&amp;title='.api_htmlentities(urlencode($page)).'&session_id='.$session_id.'&group_id='.$groupId.'"'.$wiki->is_active_navigation_tab('showpage').'>'.Display::return_icon('page.png',get_lang('ShowThisPage'),'',ICON_SIZE_MEDIUM).'</a>';
-
-if (api_is_allowed_to_session_edit(false,true) ) {
-    //menu edit page
-    echo '<a href="index.php?cidReq='.$_course['id'].'&action=edit&amp;title='.api_htmlentities(urlencode($page)).'&session_id='.$session_id.'&group_id='.$groupId.'"'.$wiki->is_active_navigation_tab('edit').'>'.Display::return_icon('edit.png',get_lang('EditThisPage'),'',ICON_SIZE_MEDIUM).'</a>';
-
-    //menu discuss page
-    echo '<a href="index.php?action=discuss&amp;title='.api_htmlentities(urlencode($page)).'"'.$wiki->is_active_navigation_tab('discuss').'>'.Display::return_icon('discuss.png',get_lang('DiscussThisPage'),'',ICON_SIZE_MEDIUM).'</a>';
- }
-
-//menu history
-echo '<a href="index.php?cidReq='.$_course['id'].'&action=history&amp;title='.api_htmlentities(urlencode($page)).'&session_id='.$session_id.'&group_id='.$groupId.'"'.$wiki->is_active_navigation_tab('history').'>'.Display::return_icon('history.png',get_lang('ShowPageHistory'),'',ICON_SIZE_MEDIUM).'</a>';
-//menu linkspages
-echo '<a href="index.php?action=links&amp;title='.api_htmlentities(urlencode($page)).'&session_id='.$session_id.'&group_id='.$groupId.'"'.$wiki->is_active_navigation_tab('links').'>'.Display::return_icon('what_link_here.png',get_lang('LinksPages'),'',ICON_SIZE_MEDIUM).'</a>';
-
-//menu delete wikipage
-if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
-    echo '<a href="index.php?action=delete&amp;title='.api_htmlentities(urlencode($page)).'"'.$wiki->is_active_navigation_tab('delete').'>'.Display::return_icon('delete.png',get_lang('DeleteThisPage'),'',ICON_SIZE_MEDIUM).'</a>';
-}
-echo '</ul>';
-echo '</div>'; // End actions
-
-
-//In new pages go to new page
-if (isset($_POST['SaveWikiNew'])) {
-    if (isset($_POST['reflink'])) {
-        $wiki->display_wiki_entry($_POST['reflink']);
-    }
-}
-
-//More for export to course document area. See display_wiki_entry
-if (isset($_POST['export2DOC']) && $_POST['export2DOC']) {
-    $doc_id = $_POST['doc_id'];
-    $export2doc = $wiki->export2doc($doc_id);
-    if ($export2doc) {
-        Display::display_confirmation_message(get_lang('ThePageHasBeenExportedToDocArea'));
-    }
-}
-
-if (isset($action) && $action =='more') {
-    echo '<div class="actions">'.get_lang('More').'</div>';
-    echo '<table border="0">';
-    echo '  <tr>';
-    echo '    <td>';
-    echo '      <ul>';
-    //Submenu Most active users
-    echo '        <li><a href="index.php?cidReq='.$_course['id'].'&action=mactiveusers&session_id='.$session_id.'&group_id='.$groupId.'">'.get_lang('MostActiveUsers').'</a></li>';
-    //Submenu Most visited pages
-    echo '        <li><a href="index.php?cidReq='.$_course['id'].'&action=mvisited&session_id='.$session_id.'&group_id='.$groupId.'">'.get_lang('MostVisitedPages').'</a></li>';
-    //Submenu Most changed pages
-    echo '        <li><a href="index.php?cidReq='.$_course['id'].'&action=mostchanged&session_id='.$session_id.'&group_id='.$groupId.'">'.get_lang('MostChangedPages').'</a></li>';
-    echo '      </ul>';
-    echo '    </td>';
-    echo '    <td>';
-    echo '      <ul>';
-    // Submenu Orphaned pages
-    echo '        <li><a href="index.php?cidReq='.$_course['id'].'&action=orphaned&session_id='.$session_id.'&group_id='.$groupId.'">'.get_lang('OrphanedPages').'</a></li>';
-    // Submenu Wanted pages
-    echo '        <li><a href="index.php?cidReq='.$_course['id'].'&action=wanted&session_id='.$session_id.'&group_id='.$groupId.'">'.get_lang('WantedPages').'</a></li>';
-	// Submenu Most linked pages
-    echo '<li><a href="index.php?cidReq='.$_course['id'].'&action=mostlinked&session_id='.$session_id.'&group_id='.$groupId.'">'.get_lang('MostLinkedPages').'</a></li>';
-    echo '</ul>';
-	echo '</td>';
-	echo '<td style="vertical-align:top">';
-    echo '<ul>';
-	// Submenu Statistics
-	if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
-    	echo '<li><a href="index.php?cidReq='.$_course['id'].'&action=statistics&session_id='.$session_id.'&group_id='.$groupId.'">'.get_lang('Statistics').'</a></li>';
-	}
-    echo '      </ul>';
-    echo'    </td>';
-    echo '  </tr>';
-    echo '</table>';
-}
-
-// Statistics Juan Carlos Raña Trabado
-
-if ($action =='statistics' && (api_is_allowed_to_edit(false,true) || api_is_platform_admin())) {
-    $wiki->getStats();
-}
-
-// Most active users Juan Carlos Raña Trabado
-
-if ($action =='mactiveusers') {
-    $wiki->getActiveUsers($action);
-}
-
-// User contributions Juan Carlos Raña Trabado
-
-if ($action =='usercontrib') {
-    $userinfo = api_get_user_info($_GET['user_id']);
-    $username = api_htmlentities(sprintf(get_lang('LoginX'), $userinfo['username']), ENT_QUOTES);
-
-    echo '<div class="actions">'.get_lang('UserContributions').': <a href="../user/userInfo.php?uInfo='.$userinfo['user_id'].'">'.
-            Display::tag('span', api_htmlentities(api_get_person_name($userinfo['firstname'], $userinfo['lastname'])), array('title'=>$username)).
-            '</a><a href="'.api_get_self().'?cidReq='.$_course['id'].'&action=usercontrib&user_id='.urlencode($row['user_id']).
-            '&session_id='.api_htmlentities($_GET['session_id']).'&group_id='.api_htmlentities($_GET['group_id']).'"></a></div>';
-
-    if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
-        //only by professors if page is hidden
-        $sql='SELECT * FROM '.$tbl_wiki.'  WHERE c_id = '.$course_id.' AND '.$groupfilter.$condition_session.' AND user_id="'.Database::escape_string($_GET['user_id']).'"';
-    } else {
-        $sql='SELECT * FROM '.$tbl_wiki.'  WHERE c_id = '.$course_id.' AND '.$groupfilter.$condition_session.' AND user_id="'.Database::escape_string($_GET['user_id']).'" AND visibility=1';
-    }
-
-    $allpages = Database::query($sql);
-
-    //show table
-    if (Database::num_rows($allpages) > 0) {
-        $row = array ();
-        while ($obj = Database::fetch_object($allpages)) {
-            //get author
-            $userinfo = api_get_user_info($obj->user_id);
-
-            //get time
-            $year 	 = substr($obj->dtime, 0, 4);
-            $month	 = substr($obj->dtime, 5, 2);
-            $day 	 = substr($obj->dtime, 8, 2);
-            $hours   = substr($obj->dtime, 11,2);
-            $minutes = substr($obj->dtime, 14,2);
-            $seconds = substr($obj->dtime, 17,2);
-
-            //get type assignment icon
-            if ($obj->assignment==1) {
-                $ShowAssignment=Display::return_icon('wiki_assignment.png', get_lang('AssignmentDescExtra'),'',ICON_SIZE_SMALL);
-            } elseif ($obj->assignment==2) {
-                $ShowAssignment=Display::return_icon('wiki_work.png', get_lang('AssignmentWork'),'',ICON_SIZE_SMALL);
-            } elseif ($obj->assignment==0) {
-                $ShowAssignment='<img src="../img/px_transparent.gif" />';
-            }
-
-            $row = array ();
-            $row[] = $year.'-'.$month.'-'.$day.' '.$hours.":".$minutes.":".$seconds;
-            $row[] =$ShowAssignment;
-            $row[] = '<a href="'.api_get_self().'?cidReq='.$_course['id'].'&action=showpage&title='.api_htmlentities(urlencode($obj->reflink)).'&view='.$obj->id.'&session_id='.api_htmlentities(urlencode($_GET['$session_id'])).'&group_id='.api_htmlentities(urlencode($_GET['group_id'])).'">'.api_htmlentities($obj->title).'</a>';
-            $row[] =Security::remove_XSS($obj->version);
-            $row[] =Security::remove_XSS($obj->comment);
-            $row[] =Security::remove_XSS($obj->progress).' %';
-            $row[] =Security::remove_XSS($obj->score);
-            $rows[] = $row;
-
-        }
-
-        $table = new SortableTableFromArrayConfig($rows,2,10,'UsersContributions_table','','','ASC');
-        $table->set_additional_parameters(
-            array('cidReq' =>Security::remove_XSS($_GET['cidReq']),'action'=>Security::remove_XSS($action ),'user_id'=>Security::remove_XSS($_GET['user_id']),'session_id'=>Security::remove_XSS($_GET['session_id']),'group_id'=>Security::remove_XSS($_GET['group_id']))
-        );
-        $table->set_header(0,get_lang('Date'), true, array ('style' => 'width:200px;'));
-        $table->set_header(1,get_lang('Type'), true, array ('style' => 'width:30px;'));
-        $table->set_header(2,get_lang('Title'), true, array ('style' => 'width:200px;'));
-        $table->set_header(3,get_lang('Version'), true, array ('style' => 'width:30px;'));
-        $table->set_header(4,get_lang('Comment'), true, array ('style' => 'width:200px;'));
-        $table->set_header(5,get_lang('Progress'), true, array ('style' => 'width:30px;'));
-        $table->set_header(6,get_lang('Rating'), true, array ('style' => 'width:30px;'));
-        $table->display();
-    }
-}
-
-/* Most changed pages */
-
-if ($action =='mostchanged') {
-    echo '<div class="actions">'.get_lang('MostChangedPages').'</div>';
-
-    if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) { //only by professors if page is hidden
-        $sql='SELECT *, MAX(version) AS MAX FROM '.$tbl_wiki.'  WHERE c_id = '.$course_id.' AND '.$groupfilter.$condition_session.' GROUP BY reflink';//TODO:check MAX and group by return last version
-    } else {
-        $sql='SELECT *, MAX(version) AS MAX FROM '.$tbl_wiki.'  WHERE c_id = '.$course_id.' AND '.$groupfilter.$condition_session.' AND visibility=1 GROUP BY reflink'; //TODO:check MAX and group by return last version
-    }
-
-    $allpages=Database::query($sql);
-
-    //show table
-    if (Database::num_rows($allpages) > 0) {
-        $row = array ();
-        while ($obj = Database::fetch_object($allpages)) {
-            //get type assignment icon
-            if ($obj->assignment==1) {
-                $ShowAssignment=Display::return_icon('wiki_assignment.png', get_lang('AssignmentDesc'),'',ICON_SIZE_SMALL);
-            } elseif ($obj->assignment==2) {
-                $ShowAssignment=Display::return_icon('wiki_work.png', get_lang('AssignmentWork'),'',ICON_SIZE_SMALL);
-            } elseif ($obj->assignment==0) {
-                $ShowAssignment='<img src="../img/px_transparent.gif" />';
-            }
-
-            $row = array ();
-            $row[] = $ShowAssignment;
-            $row[] = '<a href="'.api_get_self().'?cidReq='.$_course['id'].'&action=showpage&title='.api_htmlentities(urlencode($obj->reflink)).'&session_id='.api_htmlentities($_GET['session_id']).'&group_id='.api_htmlentities($_GET['group_id']).'">'.api_htmlentities($obj->title).'</a>';
-            $row[] = $obj->MAX;
-            $rows[] = $row;
-        }
-
-        $table = new SortableTableFromArrayConfig($rows,2,10,'MostChangedPages_table','','','DESC');
-        $table->set_additional_parameters(array('cidReq' =>Security::remove_XSS($_GET['cidReq']),'action'=>Security::remove_XSS($action ),'session_id'=>Security::remove_XSS($_GET['session_id']),'group_id'=>Security::remove_XSS($_GET['group_id'])));
-        $table->set_header(0,get_lang('Type'), true, array ('style' => 'width:30px;'));
-        $table->set_header(1,get_lang('Title'), true);
-        $table->set_header(2,get_lang('Changes'), true);
-        $table->display();
-    }
-}
-
-/* Most visited pages */
-
-if ($action =='mvisited') {
-    echo '<div class="actions">'.get_lang('MostVisitedPages').'</div>';
-
-    if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) { //only by professors if page is hidden
-        $sql = 'SELECT *, SUM(hits) AS tsum FROM '.$tbl_wiki.'
-                WHERE c_id = '.$course_id.' AND '.$groupfilter.$condition_session.'
-                GROUP BY reflink';
-    } else {
-        $sql = 'SELECT *, SUM(hits) AS tsum FROM '.$tbl_wiki.'
-                WHERE  c_id = '.$course_id.' AND '.$groupfilter.$condition_session.' AND visibility=1
-                GROUP BY reflink';
-    }
-
-    $allpages=Database::query($sql);
-
-    //show table
-    if (Database::num_rows($allpages) > 0) {
-        $row = array ();
-        while ($obj = Database::fetch_object($allpages)) {
-            //get type assignment icon
-            if ($obj->assignment==1) {
-                $ShowAssignment=Display::return_icon('wiki_assignment.png', get_lang('AssignmentDesc'),'',ICON_SIZE_SMALL);
-            } elseif ($obj->assignment==2) {
-                $ShowAssignment=$ShowAssignment=Display::return_icon('wiki_work.png', get_lang('AssignmentWork'),'',ICON_SIZE_SMALL);
-            } elseif ($obj->assignment==0) {
-                $ShowAssignment='<img src="../img/px_transparent.gif" />';
-            }
-
-            $row = array ();
-            $row[] =$ShowAssignment;
-            $row[] = '<a href="'.api_get_self().'?cidReq='.$_course['id'].'&action=showpage&title='.api_htmlentities(urlencode($obj->reflink)).'&session_id='.api_htmlentities($_GET['session_id']).'&group_id='.api_htmlentities($_GET['group_id']).'">'.api_htmlentities($obj->title).'</a>';
-            $row[] = $obj->tsum;
-            $rows[] = $row;
-        }
-
-        $table = new SortableTableFromArrayConfig($rows,2,10,'MostVisitedPages_table','','','DESC');
-        $table->set_additional_parameters(array('cidReq' =>Security::remove_XSS($_GET['cidReq']),'action'=>Security::remove_XSS($action ),'session_id'=>Security::remove_XSS($_GET['session_id']),'group_id'=>Security::remove_XSS($_GET['group_id'])));
-        $table->set_header(0,get_lang('Type'), true, array ('style' => 'width:30px;'));
-        $table->set_header(1,get_lang('Title'), true);
-        $table->set_header(2,get_lang('Visits'), true);
-        $table->display();
-    }
-}
-
-/* Wanted pages */
-
-if ($action =='wanted') {
-    echo '<div class="actions">'.get_lang('WantedPages').'</div>';
-    $pages = array();
-    $refs = array();
-	$wanted = array();
-    //get name pages
-    $sql = 'SELECT * FROM '.$tbl_wiki.'
-            WHERE  c_id = '.$course_id.' AND '.$groupfilter.$condition_session.'
-            GROUP BY reflink ORDER BY reflink ASC';
-    $allpages=Database::query($sql);
-
-    while ($row=Database::fetch_array($allpages)) {
-		if ($row['reflink']=='index'){
-			$row['reflink']=str_replace(' ','_',get_lang('DefaultTitle'));
-		}
-        $pages[] = $row['reflink'];
-    }
-
-    //get name refs in last pages
-    $sql = 'SELECT  *  FROM   '.$tbl_wiki.' s1
-    		WHERE s1.c_id = '.$course_id.' AND id=(
-    		    SELECT MAX(s2.id) FROM '.$tbl_wiki.' s2
-    		    WHERE s2.c_id = '.$course_id.' AND s1.reflink = s2.reflink AND '.$groupfilter.$condition_session.'
-            )';
-
-    $allpages = Database::query($sql);
-
-    while ($row=Database::fetch_array($allpages)) {
-        $refs = explode(" ", trim($row["linksto"]));
-		// Find linksto into reflink. If not found ->page is wanted
-		foreach ($refs as $v) {
-
-			if (!in_array($v, $pages)) {
-				if (trim($v)!="") {
-					$wanted[]=$v;
-				}
-			}
-		}
-	}
-
-	$wanted = array_unique($wanted);//make a unique list
-
-	//show table
-    $rows = array();
-    foreach ($wanted as $wanted_show) {
-        $row = array();
-        $wanted_show=Security::remove_XSS($wanted_show);
-        $row[] = '<a href="'.api_get_path(WEB_PATH).'main/wiki/index.php?cidReq=&action=addnew&title='.str_replace('_',' ',$wanted_show).'&session_id='.api_htmlentities($_GET['session_id']).'&group_id='.api_htmlentities($_GET['group_id']).'" class="new_wiki_link">'.str_replace('_',' ',$wanted_show).'</a>';//meter un remove xss en lugar de htmlentities
-        $rows[] = $row;
-    }
-
-    $table = new SortableTableFromArrayConfig($rows,0,10,'WantedPages_table','','','DESC');
-    $table->set_additional_parameters(array('cidReq' =>Security::remove_XSS($_GET['cidReq']),'action'=>Security::remove_XSS($action ),'session_id'=>Security::remove_XSS($_GET['session_id']),'group_id'=>Security::remove_XSS($_GET['group_id'])));
-    $table->set_header(0,get_lang('Title'), true);
-    $table->display();
-}
-
-/* Orphaned pages */
-
-if ($action =='orphaned') {
-    echo '<div class="actions">'.get_lang('OrphanedPages').'</div>';
-
-    $pages = array();
-    $refs = array();
-	$list_refs = array();
-    $orphaned = array();
-
-    //get name pages
-    $sql = 'SELECT * FROM '.$tbl_wiki.'
-            WHERE c_id = '.$course_id.' AND '.$groupfilter.$condition_session.'
-            GROUP BY reflink
-            ORDER BY reflink ASC';
-    $allpages=Database::query($sql);
-    while ($row=Database::fetch_array($allpages)) {
-        $pages[] = $row['reflink'];
-    }
-
-    //get name refs in last pages and make a unique list
-    $sql = 'SELECT  *  FROM   '.$tbl_wiki.' s1
-    		WHERE s1.c_id = '.$course_id.' AND id=(
-    		SELECT MAX(s2.id) FROM '.$tbl_wiki.' s2 WHERE s2.c_id = '.$course_id.' AND s1.reflink = s2.reflink AND '.$groupfilter.$condition_session.')';
-
-    $allpages=Database::query($sql);
-    while ($row=Database::fetch_array($allpages)) {
-        $row['linksto']= str_replace($row["reflink"], " ", trim($row["linksto"])); //remove self reference
-		$refs = explode(" ", trim($row["linksto"]));
-		foreach ($refs as $ref_linked){
-			if ($ref_linked==str_replace(' ','_',get_lang('DefaultTitle'))) {
-				$ref_linked='index';
-			}
-			$array_refs_linked[]= $ref_linked;
-		}
-    }
-
-	$array_refs_linked = array_unique($array_refs_linked);
-
-    //search each name of list linksto into list reflink
-    foreach ($pages as $v) {
-        if (!in_array($v, $array_refs_linked)) {
-            $orphaned[] = $v;
-        }
-    }
-
-    foreach ($orphaned as $orphaned_show) {
-		// get visibility status and title
-		$sql = 'SELECT  *  FROM   '.$tbl_wiki.'
-		        WHERE c_id = '.$course_id.' AND '.$groupfilter.$condition_session.' AND reflink="'.Database::escape_string($orphaned_show).'" GROUP BY reflink';
-        $allpages=Database::query($sql);
-		while ($row=Database::fetch_array($allpages)) {
-			$orphaned_title=$row['title'];
-			$orphaned_visibility=$row['visibility'];
-			if ($row['assignment']==1) {
-                $ShowAssignment=Display::return_icon('wiki_assignment.png','','',ICON_SIZE_SMALL);
-            } elseif ($row['assignment']==2) {
-                $ShowAssignment=Display::return_icon('wiki_work.png','','',ICON_SIZE_SMALL);
-            } elseif ($row['assignment']==0) {
-                $ShowAssignment='<img src="../img/px_transparent.gif" />';
-            }
-		}
-		if (!api_is_allowed_to_edit(false,true) || !api_is_platform_admin() AND $orphaned_visibility==0){
-			continue;
-		}
-
-		//show table
-        $row = array();
-			$row[] = $ShowAssignment;
-            $row[] = '<a href="'.api_get_self().'?cidReq='.$_course['id'].'&action=showpage&title='.api_htmlentities(urlencode($orphaned_show)).'&session_id='.api_htmlentities($_GET['session_id']).'&group_id='.api_htmlentities($_GET['group_id']).'">'.api_htmlentities($orphaned_title).'</a>';
-            $rows[] = $row;
-        }
-
-        $table = new SortableTableFromArrayConfig($rows,1,10,'OrphanedPages_table','','','DESC');
-        $table->set_additional_parameters(array('cidReq' =>Security::remove_XSS($_GET['cidReq']),'action'=>Security::remove_XSS($action ),'session_id'=>Security::remove_XSS($_GET['session_id']),'group_id'=>Security::remove_XSS($_GET['group_id'])));
-        $table->set_header(0,get_lang('Type'), true, array ('style' => 'width:30px;'));
-        $table->set_header(1,get_lang('Title'), true);
-        $table->display();
-}
-
-/* Most linked pages */
-
-if ($action =='mostlinked') {
-    echo '<div class="actions">'.get_lang('MostLinkedPages').'</div>';
-	$pages = array();
-    $refs = array();
-	$linked = array();
-
-    //get name pages
-    $sql = 'SELECT * FROM '.$tbl_wiki.'
-            WHERE  c_id = '.$course_id.' AND '.$groupfilter.$condition_session.'
-            GROUP BY reflink ORDER BY reflink ASC';
-    $allpages=Database::query($sql);
+ob_start();
+$wiki->handleAction($action);
+$content = ob_get_contents();
+ob_end_clean();
 
-    while ($row=Database::fetch_array($allpages)) {
-		if ($row['reflink']=='index') {
-			$row['reflink']=str_replace(' ','_',get_lang('DefaultTitle'));
-		}
-		$pages[] = $row['reflink'];
-    }
-
-    //get name refs in last pages
-    $sql = 'SELECT  *  FROM   '.$tbl_wiki.' s1 WHERE s1.c_id = '.$course_id.' AND id=(
-            SELECT MAX(s2.id) FROM '.$tbl_wiki.' s2 WHERE s2.c_id = '.$course_id.' AND s1.reflink = s2.reflink AND '.$groupfilter.$condition_session.')';
-
-    $allpages=Database::query($sql);
-
-    while ($row=Database::fetch_array($allpages)) {
-	 	$row['linksto']= str_replace($row["reflink"], " ", trim($row["linksto"])); //remove self reference
-        $refs = explode(" ", trim($row["linksto"]));
-
-		// Find linksto into reflink. If found ->page is linked
-		foreach ($refs as $v) {
-			if (in_array($v, $pages)) {
-				if (trim($v)!="") {
-					$linked[]=$v;
-				}
-			}
-		}
-	}
-
-	$linked = array_unique($linked);
-	//make a unique list. TODO:delete this line and count how many for each page
-    //show table
-    $rows = array();
-    foreach ($linked as $linked_show) {
-        $row = array();
-        $row[] = '<a href="'.api_get_self().'?cidReq='.$_course['id'].'&action=showpage&title='.api_htmlentities(urlencode(str_replace('_',' ',$linked_show))).'&session_id='.api_htmlentities($_GET['session_id']).'&group_id='.api_htmlentities($_GET['group_id']).'">'.str_replace('_',' ',$linked_show).'</a>';
-        $rows[] = $row;
-    }
-
-    $table = new SortableTableFromArrayConfig($rows,0,10,'LinkedPages_table','','','DESC');
-    $table->set_additional_parameters(
-        array(
-            'cidReq' =>Security::remove_XSS($_GET['cidReq']),
-            'action'=>Security::remove_XSS($action ),
-            'session_id'=>Security::remove_XSS($_GET['session_id']),
-            'group_id'=>Security::remove_XSS($_GET['group_id'])
-        )
-    );
-    $table->set_header(0,get_lang('Title'), true);
-    $table->display();
-}
-
-/* Delete current page */
-
-if ($action =='delete') {
-    if (!$_GET['title']) {
-        Display::display_error_message(get_lang('MustSelectPage'));
-        exit;
-    }
-
-    if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
-        echo '<div id="wikititle">'.get_lang('DeletePageHistory').'</div>';
-
-        if ($page == "index") {
-            Display::display_warning_message(get_lang('WarningDeleteMainPage'),false);
-        }
-
-        $message = get_lang('ConfirmDeletePage')."</p>"."<p>"."<a href=\"index.php\">".get_lang("No")."</a>"."&nbsp;&nbsp;|&nbsp;&nbsp;"."<a href=\"".api_get_self()."?action=delete&amp;title=".api_htmlentities(urlencode($page))."&amp;delete=yes\">".get_lang("Yes")."</a>"."</p>";
-
-        if (!isset ($_GET['delete'])) {
-            Display::display_warning_message($message,false);
-        }
-
-        if (isset($_GET['delete']) && $_GET['delete'] == 'yes') {
-            $result = $wiki->deletePage($page, $course_id, $groupfilter, $condition_session);
-            if ($result) {
-                Display::display_confirmation_message(get_lang('WikiPageDeleted'));
-            }
-        }
-    } else {
-        Display::display_normal_message(get_lang("OnlyAdminDeletePageWiki"));
-    }
-}
-
-/* Delete all wiki */
-
-if ($action =='deletewiki') {
-    echo '<div class="actions">'.get_lang('DeleteWiki').'</div>';
-    echo '<div style="overflow:hidden">';
-    if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
-        $message = 	get_lang('ConfirmDeleteWiki');
-        $message .= '<p>
-                        <a href="index.php">'.get_lang('No').'</a>
-                        &nbsp;&nbsp;|&nbsp;&nbsp;
-                        <a href="'.api_get_self().'?action=deletewiki&amp;delete=yes">'.get_lang('Yes').'</a>
-                    </p>';
-
-        if (!isset($_GET['delete'])) {
-            Display::display_warning_message($message,false);
-        }
-    } else {
-        Display::display_normal_message(get_lang("OnlyAdminDeleteWiki"));
-    }
-    echo '</div>';
-}
-
-/* Search wiki pages */
-
-if ($action =='searchpages') {
-    echo '<div class="actions">'.get_lang('SearchPages').'</div>';
-	if (isset($_GET['mode_table'])) {
-		if (!isset($_GET['SearchPages_table_page_nr'])) {
-			$_GET['search_term'] = $_POST['search_term'];
-			$_GET['search_content'] = $_POST['search_content'];
-			$_GET['all_vers'] = $_POST['all_vers'];
-		}
-		$wiki->display_wiki_search_results(
-            api_htmlentities($_GET['search_term']),
-            api_htmlentities($_GET['search_content']),
-            api_htmlentities($_GET['all_vers'])
-        );
-	} else {
-
-		// initiate the object
-		$form = new FormValidator('wiki_search',
-            'post',
-            api_get_self().'?cidReq='.api_htmlentities($_GET['cidReq']).'&action='.api_htmlentities($action).'&session_id='.api_htmlentities($_GET['session_id']).'&group_id='.api_htmlentities($_GET['group_id']).'&mode_table=yes1&search_term='.api_htmlentities($_GET['search_term']).'&search_content='.api_htmlentities($_GET['search_content']).'&all_vers='.api_htmlentities($_GET['all_vers'])
-        );
-
-		// Setting the form elements
-
-		$form->addElement('text', 'search_term', get_lang('SearchTerm'),'class="input_titles" id="search_title"');
-		$form->addElement('checkbox', 'search_content', null, get_lang('AlsoSearchContent'));
-		$form->addElement('checkbox', 'all_vers', null, get_lang('IncludeAllVersions'));
-		$form->addElement('style_submit_button', 'SubmitWikiSearch', get_lang('Search'), 'class="search"');
-
-		// setting the rules
-		$form->addRule('search_term', get_lang('ThisFieldIsRequired'), 'required');
-		$form->addRule('search_term', get_lang('TooShort'),'minlength',3); //TODO: before fixing the pagination rules worked, not now
-		if ($form->validate()) {
-			$form->display();
-			$values = $form->exportValues();
-			$wiki->display_wiki_search_results(
-                $values['search_term'],
-                $values['search_content'],
-                $values['all_vers']
-            );
-		} else {
-			$form->display();
-		}
-	}
-}
-
-/* What links here. Show pages that have linked this page */
-
-if ($action =='links') {
-    if (!$_GET['title']) {
-        Display::display_error_message(get_lang("MustSelectPage"));
-    } else {
-        $sql = 'SELECT * FROM '.$tbl_wiki.'
-                WHERE
-                    c_id = '.$course_id.' AND
-                    reflink="'.Database::escape_string($page).'" AND
-                    '.$groupfilter.$condition_session.'';
-        $result = Database::query($sql);
-        $row = Database::fetch_array($result);
-
-        //get type assignment icon
-
-        if ($row['assignment']==1) {
-            $ShowAssignment=Display::return_icon('wiki_assignment.png', get_lang('AssignmentDesc'),'',ICON_SIZE_SMALL);
-        } elseif ($row['assignment']==2) {
-            $ShowAssignment=Display::return_icon('wiki_work.png', get_lang('AssignmentWork'),'',ICON_SIZE_SMALL);
-        } elseif ($row['assignment']==0) {
-            $ShowAssignment='<img src="../img/px_transparent.gif" />';
-        }
-
-        //fix Title to reflink (link Main Page)
-
-        if ($page==get_lang('DefaultTitle')) {
-            $page='index';
-        }
-
-        echo '<div id="wikititle">';
-        echo get_lang('LinksPagesFrom').': '.$ShowAssignment.' <a href="'.api_get_self().'?cidReq='.$_course['id'].'&action=showpage&title='.api_htmlentities(urlencode($page)).'&session_id='.api_htmlentities($_GET['session_id']).'&group_id='.api_htmlentities($_GET['group_id']).'">'.api_htmlentities($row['title']).'</a>';
-        echo '</div>';
-
-        //fix index to title Main page into linksto
-
-        if ($page=='index') {
-            $page=str_replace(' ','_',get_lang('DefaultTitle'));
-        }
-
-        //table
-        if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) { //only by professors if page is hidden
-			$sql="SELECT * FROM ".$tbl_wiki." s1 WHERE s1.c_id = $course_id AND linksto LIKE '%".Database::escape_string($page)." %' AND id=(SELECT MAX(s2.id) FROM ".$tbl_wiki." s2 WHERE s2.c_id = $course_id AND s1.reflink = s2.reflink AND ".$groupfilter.$condition_session.")";//add blank space after like '%" " %' to identify each word
-        } else {
-            $sql="SELECT * FROM ".$tbl_wiki." s1 WHERE s1.c_id = $course_id AND visibility=1 AND linksto LIKE '%".Database::escape_string($page)." %' AND id=(SELECT MAX(s2.id) FROM ".$tbl_wiki." s2 WHERE s2.c_id = $course_id AND s1.reflink = s2.reflink AND ".$groupfilter.$condition_session.")";//add blank space after like '%" " %' to identify each word
-        }
-
-        $allpages=Database::query($sql);
-
-        //show table
-        if (Database::num_rows($allpages) > 0) {
-            $row = array ();
-            while ($obj = Database::fetch_object($allpages)) {
-                //get author
-                $userinfo = api_get_user_info($obj->user_id);
-                $username = api_htmlentities(sprintf(get_lang('LoginX'), $userinfo['username']), ENT_QUOTES);
-
-                //get time
-                $year 	 = substr($obj->dtime, 0, 4);
-                $month	 = substr($obj->dtime, 5, 2);
-                $day 	 = substr($obj->dtime, 8, 2);
-                $hours   = substr($obj->dtime, 11,2);
-                $minutes = substr($obj->dtime, 14,2);
-                $seconds = substr($obj->dtime, 17,2);
-
-                //get type assignment icon
-                if ($obj->assignment==1) {
-                    $ShowAssignment=Display::return_icon('wiki_assignment.png', get_lang('AssignmentDesc'),'',ICON_SIZE_SMALL);
-                } elseif ($obj->assignment==2) {
-                    $ShowAssignment=Display::return_icon('wiki_work.png', get_lang('AssignmentWork'),'',ICON_SIZE_SMALL);
-                } elseif ($obj->assignment==0) {
-                    $ShowAssignment='<img src="../img/px_transparent.gif" />';
-                }
-
-                $row = array ();
-                $row[] =$ShowAssignment;
-                $row[] = '<a href="'.api_get_self().'?cidReq='.$_course['id'].'&action=showpage&title='.api_htmlentities(urlencode($obj->reflink)).'&session_id='.api_htmlentities($_GET['session_id']).'&group_id='.api_htmlentities($_GET['group_id']).'">'.api_htmlentities($obj->title).'</a>';
-                if ($obj->user_id <>0) {
-                    $row[] = '<a href="../user/userInfo.php?uInfo='.$userinfo['user_id'].'">'.
-                    Display::tag('span', api_htmlentities(api_get_person_name($userinfo['firstname'], $userinfo['lastname'])), array('title'=>$username)).'</a>';
-                }
-                else {
-                    $row[] = get_lang('Anonymous').' ('.$obj->user_ip.')';
-                }
-                $row[] = $year.'-'.$month.'-'.$day.' '.$hours.":".$minutes.":".$seconds;
-                $rows[] = $row;
-            }
-
-            $table = new SortableTableFromArrayConfig($rows,1,10,'AllPages_table','','','ASC');
-            $table->set_additional_parameters(array('cidReq' =>Security::remove_XSS($_GET['cidReq']),'action'=>Security::remove_XSS($action ),'group_id'=>Security::remove_XSS($_GET['group_id'])));
-            $table->set_header(0,get_lang('Type'), true, array ('style' => 'width:30px;'));
-            $table->set_header(1,get_lang('Title'), true);
-            $table->set_header(2,get_lang('Author'), true);
-            $table->set_header(3,get_lang('Date'), true);
-            $table->display();
-        }
-    }
-}
-
-// Adding a new page
-// Display the form for adding a new wiki page
-
-if ($action =='addnew') {
-    if (api_get_session_id()!=0 && api_is_allowed_to_session_edit(false,true)==false) {
-        api_not_allowed();
-    }
-
-    echo '<div class="actions">'.get_lang('AddNew').'</div>';
-	echo '<br/>';
-    //first, check if page index was created. chektitle=false
-    if ($wiki->checktitle('index')) {
-        if (api_is_allowed_to_edit(false,true) || api_is_platform_admin() || GroupManager :: is_user_in_group($_user['user_id'],$_SESSION['_gid'])) {
-            Display::display_normal_message(get_lang('GoAndEditMainPage'));
-        } else {
-            return Display::display_normal_message(get_lang('WikiStandBy'));
-        }
-    } elseif ($wiki->check_addnewpagelock()==0 && (api_is_allowed_to_edit(false,true)==false || api_is_platform_admin()==false)) {
-        Display::display_error_message(get_lang('AddPagesLocked'));
-    } else {
-        if(api_is_allowed_to_edit(false,true) || api_is_platform_admin() || GroupManager :: is_user_in_group($_user['user_id'],$_SESSION['_gid']) || Security::remove_XSS($_GET['group_id'])==0) {
-            $wiki->display_new_wiki_form();
-        } else {
-            Display::display_normal_message(get_lang('OnlyAddPagesGroupMembers'));
-        }
-    }
-}
-
-// Show home page
-if (!$action  OR $action =='show' AND !isset($_POST['SaveWikiNew'])) {
-    $wiki->display_wiki_entry($newtitle);
-}
-
-// Show current page
-if ($action =='showpage' AND !isset($_POST['SaveWikiNew'])) {
-    if ($_GET['title']) {
-        $wiki->display_wiki_entry($newtitle);
-    } else {
-        Display::display_error_message(get_lang('MustSelectPage'));
-    }
-}
-
-// Edit current page
-
-if (isset($action) && $action =='edit') {
-
-    if (api_get_session_id()!=0 && api_is_allowed_to_session_edit(false,true)==false) {
-        api_not_allowed();
-    }
-
-    $sql = 'SELECT * FROM '.$tbl_wiki.', '.$tbl_wiki_conf.'
-    		WHERE
-    		'.$tbl_wiki.'.c_id = '.$course_id.' AND
-    		'.$tbl_wiki_conf.'.c_id = '.$course_id.' AND
-    		'.$tbl_wiki_conf.'.page_id='.$tbl_wiki.'.page_id AND
-    		'.$tbl_wiki.'.reflink="'.Database::escape_string($page).'" AND
-    		'.$tbl_wiki.'.'.$groupfilter.$condition_session.'
-    		ORDER BY id DESC';
-    $result=Database::query($sql);
-    $row=Database::fetch_array($result); // we do not need a while loop since we are always displaying the last version
-
-
-    if ($row['content']=='' AND $row['title']=='' AND $page=='') {
-        Display::display_error_message(get_lang('MustSelectPage'));
-        exit;
-    } elseif ($row['content']=='' AND $row['title']=='' AND $page=='index') {
-        //Table structure for better export to pdf
-        $default_table_for_content_Start='<table align="center" border="0"><tr><td align="center">';
-        $default_table_for_content_End='</td></tr></table>';
-
-        $content=$default_table_for_content_Start.sprintf(get_lang('DefaultContent'),api_get_path(WEB_IMG_PATH)).$default_table_for_content_End;
-        $title=get_lang('DefaultTitle');
-        $page_id=0;
-    } else {
-        $content = api_html_entity_decode($row['content']);
-        $title = api_html_entity_decode($row['title']);
-        $page_id = $row['page_id'];
-    }
-
-    //Only teachers and platform admin can edit the index page. Only teachers and platform admin can edit an assignment teacher. And users in groups
-    if (($row['reflink']=='index' || $row['reflink']=='' || $row['assignment']==1) && (!api_is_allowed_to_edit(false,true) && intval($_GET['group_id'])==0)) {
-        Display::display_error_message(get_lang('OnlyEditPagesCourseManager'));
-    } else {
-        $PassEdit=false;
-
-        //check if is a wiki group
-        if ($groupId!=0) {
-            //Only teacher, platform admin and group members can edit a wiki group
-            if (api_is_allowed_to_edit(false,true) || api_is_platform_admin() || GroupManager :: is_user_in_group($_user['user_id'],intval($_GET['group_id']))) {
-                $PassEdit=true;
-            } else {
-                  Display::display_normal_message(get_lang('OnlyEditPagesGroupMembers'));
-            }
-        } else {
-            $PassEdit=true;
-        }
-        $icon_assignment = null;
-        // check if is a assignment
-        if ($row['assignment']==1) {
-            Display::display_normal_message(get_lang('EditAssignmentWarning'));
-            $icon_assignment=Display::return_icon('wiki_assignment.png', get_lang('AssignmentDescExtra'),'',ICON_SIZE_SMALL);
-        } elseif ($row['assignment']==2) {
-            $icon_assignment=Display::return_icon('wiki_work.png', get_lang('AssignmentWorkExtra'),'',ICON_SIZE_SMALL);
-            if ((api_get_user_id()==$row['user_id'])==false) {
-                if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
-                    $PassEdit=true;
-                } else {
-                    Display::display_warning_message(get_lang('LockByTeacher'));
-                    $PassEdit=false;
-                }
-            } else {
-                $PassEdit=true;
-            }
-        }
-
-         if ($PassEdit) { //show editor if edit is allowed
-             if ($row['editlock']==1 && (api_is_allowed_to_edit(false,true)==false || api_is_platform_admin()==false)) {
-                   Display::display_normal_message(get_lang('PageLockedExtra'));
-            } else {
-                //check tasks
-                if (!empty($row['startdate_assig']) && $row['startdate_assig']!='0000-00-00 00:00:00' && time()<strtotime($row['startdate_assig'])) {
-                    $message=get_lang('TheTaskDoesNotBeginUntil').': '.api_get_local_time($row['startdate_assig'], null, date_default_timezone_get());
-                    Display::display_warning_message($message);
-                    if (!api_is_allowed_to_edit(false,true)) {
-                        exit;
-                    }
-                }
-
-                //
-                if (!empty($row['enddate_assig']) && $row['enddate_assig']!='0000-00-00 00:00:00' && time()>strtotime($row['enddate_assig']) && $row['enddate_assig']!='0000-00-00 00:00:00' && $row['delayedsubmit']==0) {
-                    $message=get_lang('TheDeadlineHasBeenCompleted').': '.api_get_local_time($row['enddate_assig'], null, date_default_timezone_get());
-                    Display::display_warning_message($message);
-                    if (!api_is_allowed_to_edit(false,true)) {
-                        exit;
-                    }
-                }
-
-                if (!empty($row['max_version']) && $row['version']>=$row['max_version']) {
-                    $message=get_lang('HasReachedMaxiNumVersions');
-                    Display::display_warning_message($message);
-                    if (!api_is_allowed_to_edit(false,true)) {
-                        exit;
-                    }
-                }
-
-                if (!empty($row['max_text']) && $row['max_text']<=$wiki->word_count($row['content'])) {
-                    $message=get_lang('HasReachedMaxNumWords');
-                    Display::display_warning_message($message);
-                    if (!api_is_allowed_to_edit(false,true)) {
-                        exit;
-                    }
-                }
-
-                if (!empty($row['task'])) {
-                    //previous change 0 by text
-                    if ($row['startdate_assig']=='0000-00-00 00:00:00') {
-                        $message_task_startdate=get_lang('No');
-                    } else {
-                        $message_task_startdate=api_get_local_time($row['startdate_assig'], null, date_default_timezone_get());
-                    }
-
-                    if ($row['enddate_assig']=='0000-00-00 00:00:00') {
-                        $message_task_enddate=get_lang('No');
-                    } else {
-                        $message_task_endate=api_get_local_time($row['enddate_assig'], null, date_default_timezone_get());
-                    }
-
-                    if ($row['delayedsubmit']==0) {
-                        $message_task_delayedsubmit=get_lang('No');
-                    } else {
-                        $message_task_delayedsubmit=get_lang('Yes');
-                    }
-                    if ($row['max_version']==0) {
-                        $message_task_max_version=get_lang('No');
-                    } else {
-                        $message_task_max_version=$row['max_version'];
-                    }
-                    if ($row['max_text']==0) {
-                        $message_task_max_text=get_lang('No');
-                    } else {
-                        $message_task_max_text=$row['max_text'];
-                    }
-
-                    //comp message
-                    $message_task='<b>'.get_lang('DescriptionOfTheTask').'</b><p>'.$row['task'].'</p><hr>';
-                    $message_task.='<p>'.get_lang('StartDate').': '.$message_task_startdate.'</p>';
-                    $message_task.='<p>'.get_lang('EndDate').': '.$message_task_enddate;
-                    $message_task.=' ('.get_lang('AllowLaterSends').') '.$message_task_delayedsubmit.'</p>';
-                    $message_task.='<p>'.get_lang('OtherSettings').': '.get_lang('NMaxVersion').': '.$message_task_max_version;
-                    $message_task.=' '.get_lang('NMaxWords').': '.$message_task_max_text;
-                    //display message
-                    Display::display_normal_message($message_task,false);
-                }
-
-                if ($row['progress']==$row['fprogress1'] && !empty($row['fprogress1'])) {
-                    $feedback_message='<b>'.get_lang('Feedback').'</b><p>'.api_htmlentities($row['feedback1']).'</p>';
-                    Display::display_normal_message($feedback_message, false);
-                } elseif ($row['progress']==$row['fprogress2'] && !empty($row['fprogress2'])) {
-                    $feedback_message='<b>'.get_lang('Feedback').'</b><p>'.api_htmlentities($row['feedback2']).'</p>';
-                    Display::display_normal_message($feedback_message, false);
-                } elseif ($row['progress']==$row['fprogress3'] && !empty($row['fprogress3'])) {
-                    $feedback_message='<b>'.get_lang('Feedback').'</b><p>'.api_htmlentities($row['feedback3']).'</p>';
-                    Display::display_normal_message($feedback_message, false);
-                }
-
-                //previous checking for concurrent editions
-                if ($row['is_editing']==0) {
-                    Display::display_normal_message(get_lang('WarningMaxEditingTime'));
-
-                    $time_edit = date("Y-m-d H:i:s");
-                    $sql='UPDATE '.$tbl_wiki.' SET is_editing="'.$_user['user_id'].'", time_edit="'.$time_edit.'" WHERE c_id = '.$course_id.' AND  id="'.$row['id'].'"';
-                    Database::query($sql);
-                } elseif ($row['is_editing']!=$_user['user_id']) {
-                    $timestamp_edit=strtotime($row['time_edit']);
-                    $time_editing=time()-$timestamp_edit;
-                    $max_edit_time=1200; // 20 minutes
-                    $rest_time=$max_edit_time-$time_editing;
-
-                    $userinfo = api_get_user_info($row['is_editing']);
-                    $username = api_htmlentities(sprintf(get_lang('LoginX'), $userinfo['username']), ENT_QUOTES);
-
-                    $is_being_edited= get_lang('ThisPageisBeginEditedBy').
-                    ' <a href=../user/userInfo.php?uInfo='.
-                    $userinfo['user_id'].'>'.
-                    Display::tag('span', api_htmlentities(api_get_person_name($userinfo['firstname'], $userinfo['lastname'])), array('title'=>$username)).
-                    '</a>. '.get_lang('ThisPageisBeginEditedTryLater').' '.date( "i",$rest_time).' '.get_lang('MinMinutes').'';
-                    Display::display_normal_message($is_being_edited, false);
-                    exit;
-                }
-
-                // Form.
-                echo '<div id="wikititle">'.$icon_assignment.str_repeat('&nbsp;',3).api_htmlentities($title).'</div>';
-                echo '<form name="form1" method="post" action="'.api_get_self().'?action=showpage&amp;title='.api_htmlentities(urlencode($page)).'&session_id='.api_htmlentities($_GET['session_id']).'&group_id='.api_htmlentities($_GET['group_id']).'">';
-
-                if ((api_is_allowed_to_edit(false,true) || api_is_platform_admin()) && $row['reflink'] != 'index') {
-                    echo '<a href="javascript://" onclick="advanced_parameters()" >
-                         <div id="plus_minus">&nbsp;'.
-                        Display::return_icon(
-                            'div_show.gif',
-                            get_lang('Show'),
-                            array('style'=>'vertical-align:middle')
-                        ).'&nbsp;'.get_lang('AdvancedParameters').'</div></a>';
-
-                    echo '<div id="options" style="display:none; margin: 20px;" >';
-
-                    // Task
-                    echo '<input type="checkbox" value="1" name="checktask" onclick="javascript: if(this.checked){document.getElementById(\'option4\').style.display=\'block\';}else{document.getElementById(\'option4\').style.display=\'none\';}"/>&nbsp;'.Display::return_icon('wiki_task.png', get_lang('DefineTask'),'',ICON_SIZE_SMALL).' '.get_lang('DescriptionOfTheTask').'';
-                    echo '&nbsp;&nbsp;&nbsp;<span id="msg_error4" style="display:none;color:red"></span>';
-                    echo '<div id="option4" style="padding:4px; margin:5px; border:1px dotted; display:none;">';
-                    echo '<table>';
-                    echo '<tr>';
-                    echo '<td>'.get_lang('DescriptionOfTheTask').'</td>';
-                    echo '</tr>';
-                    echo '<tr>';
-                    echo '<td>'.api_disp_html_area('task', $row['task'], '', '', null, array('ToolbarSet' => 'wiki_task', 'Width' => '100%', 'Height' => '200')).'</td>';
-                    echo '</tr>';
-                    echo '</table>';
-                    echo '</div>';
-
-                    // Feedback
-                    echo '<input type="checkbox" value="1" name="checkfeedback" onclick="javascript: if(this.checked){document.getElementById(\'option2\').style.display=\'block\';}else{document.getElementById(\'option2\').style.display=\'none\';}"/>&nbsp;'.get_lang('AddFeedback').'';
-                    echo '&nbsp;&nbsp;&nbsp;<span id="msg_error2" style="display:none;color:red"></span>';
-
-                    echo '<div id="option2" style="padding:4px; margin:5px; border:1px dotted; display:none;">';
-
-                    echo '<table border="0" style="font-weight:normal" align="center">';
-                    echo '<tr>';
-                    echo '<td colspan="2">'.get_lang('Feedback1').'</td>';
-                    echo '<td colspan="2">'.get_lang('Feedback2').'</td>';
-                    echo '<td colspan="2">'.get_lang('Feedback3').'</td>';
-                    echo '</tr>';
-                    echo '<tr>';
-                    echo '<td colspan="2"><textarea name="feedback1" cols="21" rows="4" >'.api_htmlentities($row['feedback1']).'</textarea></td>';
-                    echo '<td colspan="2"><textarea name="feedback2" cols="21" rows="4" >'.api_htmlentities($row['feedback2']).'</textarea></td>';
-                    echo '<td colspan="2"><textarea name="feedback3" cols="21" rows="4" >'.api_htmlentities($row['feedback3']).'</textarea></td>';
-                    echo '</tr>';
-                    echo '<tr>';
-                    echo '<td>'.get_lang('FProgress').':</td>';
-                    echo '<td><select name="fprogress1">';
-                     echo '<option value="'.api_htmlentities($row['fprogress1']).'" selected>'.api_htmlentities($row['fprogress1']).'</option>';
-                    echo '<option value="10">10</option>
-                       <option value="20">20</option>
-                       <option value="30">30</option>
-                       <option value="40">40</option>
-                       <option value="50">50</option>
-                       <option value="60">60</option>
-                       <option value="70">70</option>
-                       <option value="80">80</option>
-                       <option value="90">90</option>
-                       <option value="100">100</option>
-                       </select> %</td>';
-                    echo '<td>'.get_lang('FProgress').':</td>';
-                    echo '<td><select name="fprogress2">';
-                     echo '<option value="'.api_htmlentities($row['fprogress2']).'" selected>'.api_htmlentities($row['fprogress2']).'</option>';;
-                    echo '<option value="10">10</option>
-                       <option value="20">20</option>
-                       <option value="30">30</option>
-                       <option value="40">40</option>
-                       <option value="50">50</option>
-                       <option value="60">60</option>
-                       <option value="70">70</option>
-                       <option value="80">80</option>
-                       <option value="90">90</option>
-                       <option value="100">100</option>
-                       </select> %</td>';
-                    echo '<td>'.get_lang('FProgress').':</td>';
-                    echo '<td><select name="fprogress3">';
-                    echo '<option value="'.api_htmlentities($row['fprogress3']).'" selected>'.api_htmlentities($row['fprogress3']).'</option>';
-                    echo '<option value="10">10</option>
-                       <option value="20">20</option>
-                       <option value="30">30</option>
-                       <option value="40">40</option>
-                       <option value="50">50</option>
-                       <option value="60">60</option>
-                       <option value="70">70</option>
-                       <option value="80">80</option>
-                       <option value="90">90</option>
-                       <option value="100">100</option>
-                       </select> %</td>';
-                    echo '</tr>';
-                    echo '</table>';
-                    echo '</div>';
-
-                    //time limit
-                    echo  '<div>&nbsp;</div><input type="checkbox" value="1" name="checktimelimit" onclick="javascript: if(this.checked){document.getElementById(\'option1\').style.display=\'block\'; $pepe=\'a\';}else{document.getElementById(\'option1\').style.display=\'none\';}"/>&nbsp;'.get_lang('PutATimeLimit').'';
-                    echo  '&nbsp;&nbsp;&nbsp;<span id="msg_error1" style="display:none;color:red"></span>';
-                    echo  '<div id="option1" style="padding:4px; margin:5px; border:1px dotted; display:none;">';
-                    echo '<table width="100%" border="0" style="font-weight:normal">';
-                    echo '<tr>';
-                    echo '<td align="right" width="150">'.get_lang('StartDate').':</td>';
-                    echo '<td>';
-                    if ($row['startdate_assig']=='0000-00-00 00:00:00') {
-                        echo $wiki->draw_date_picker('startdate_assig').' <input type="checkbox" name="initstartdate" value="1"> '.get_lang('Yes').'/'.get_lang('No').'';
-                    } else {
-                        echo $wiki->draw_date_picker('startdate_assig', $row['startdate_assig']).' <input type="checkbox" name="initstartdate" value="1">'.get_lang('Yes').'/'.get_lang('No').'';
-                    }
-                    echo '</td>';
-                    echo '</tr>';
-                    echo '<tr>';
-                    echo '<td align="right" width="150">'.get_lang("EndDate").':</td>';
-                    echo '<td>';
-                    if ($row['enddate_assig']=='0000-00-00 00:00:00') {
-                        echo $wiki->draw_date_picker('enddate_assig').' <input type="checkbox" name="initenddate" value="1"> '.get_lang('Yes').'/'.get_lang('No').'';
-                    } else {
-                        echo $wiki->draw_date_picker('enddate_assig', $row['enddate_assig']).' <input type="checkbox" name="initenddate" value="1"> '.get_lang('Yes').'/'.get_lang('No').'';
-                    }
-                    echo '</td>';
-                    echo '</tr>';
-                    echo '<tr>';
-                    echo '<td align="right">'.get_lang('AllowLaterSends').':</td>';
-                    if ($row['delayedsubmit']==1) {
-                        $check_uncheck='checked';
-                    }
-                    echo '<td><input type="checkbox" name="delayedsubmit" value="1" '.$check_uncheck.'></td>';
-                    echo '</tr>';
-                    echo'</table>';
-                    echo '</div>';
-
-                    //other limit
-                    echo '<div>&nbsp;</div><input type="checkbox" value="1" name="checkotherlimit" onclick="javascript: if(this.checked){document.getElementById(\'option3\').style.display=\'block\';}else{document.getElementById(\'option3\').style.display=\'none\';}"/>&nbsp;'.get_lang('OtherSettings').'';
-                    echo '&nbsp;&nbsp;&nbsp;<span id="msg_error3" style="display:none;color:red"></span>';
-                    echo '<div id="option3" style="padding:4px; margin:5px; border:1px dotted; display:none;">';
-                    echo '<div style="font-weight:normal"; align="center">'.get_lang('NMaxWords').':&nbsp;<input type="text" name="max_text" size="3" value="'.$row['max_text'].'">&nbsp;&nbsp;'.get_lang('NMaxVersion').':&nbsp;<input type="text" name="max_version" size="3" value="'.$row['max_version'].'"></div>';
-                    echo '</div>';
-
-                    echo '</div>';
-                }
-
-                echo '<input type="hidden" name="page_id" value="'.$page_id.'">';
-                echo '<input type="hidden" name="reflink" value="'.api_htmlentities($page).'">';
-                echo '<input type="hidden" name="title" value="'.api_htmlentities($title).'">';
-
-                api_disp_html_area('content', $content, '', '', null, api_is_allowed_to_edit(null,true)
-                    ? array('ToolbarSet' => 'Wiki', 'Width' => '100%', 'Height' => '400')
-                    : array('ToolbarSet' => 'WikiStudent', 'Width' => '100%', 'Height' => '400', 'UserStatus' => 'student')
-                );
-                echo '<br/>';
-                echo '<br/>';
-
-                echo get_lang('Comments').':&nbsp;&nbsp;<input type="text" name="comment" size="40">&nbsp;&nbsp;&nbsp;';
-                echo '<input TYPE="hidden" NAME="assignment" VALUE="'.$row['assignment'].'"/>';
-                echo '<input TYPE="hidden" NAME="version" VALUE="'.$row['version'].'"/>';
-
-                //hack date for edit
-                echo '<input TYPE="hidden" NAME="startdate_assig" VALUE="'.$row['startdate_assig'].'"/>';
-                echo '<input TYPE="hidden" NAME="enddate_assig" VALUE="'.$row['enddate_assig'].'"/>';
-
-                echo get_lang('Progress').':&nbsp;&nbsp;<select name="progress" id="progress">';
-                echo '<option value="'.api_htmlentities($row['progress']).'" selected>'.api_htmlentities($row['progress']).'</option>';
-                echo '<option value="10">10</option>
-                <option value="20">20</option>
-                <option value="30">30</option>
-                <option value="40">40</option>
-                <option value="50">50</option>
-                <option value="60">60</option>
-                <option value="70">70</option>
-                <option value="80">80</option>
-                <option value="90">90</option>
-                <option value="100">100</option>
-                </select> %';
-                echo '<br/><br/>';
-                echo '<input type="hidden" name="wpost_id" value="'.md5(uniqid(rand(), true)).'">';//prevent double post
-                 //for save button Don't change name (see fckeditor/editor/plugins/customizations/fckplugin_compressed.js and fckplugin.js
-                echo '<button class="save" type="submit" name="SaveWikiChange">'.get_lang('Save').'</button>';
-                echo '</form>';
-            }
-        }
-    }
-}
-
-// Page history
-
-if ($action == 'history' or isset($_POST['HistoryDifferences'])) {
-    if (!$_GET['title']) {
-        Display::display_error_message(get_lang("MustSelectPage"));
-        exit;
-    }
-
-    /* First, see the property visibility that is at the last register and
-    therefore we should select descending order.
-    But to give ownership to each record,
-    this is no longer necessary except for the title. TODO: check this*/
-
-    $sql = 'SELECT * FROM '.$tbl_wiki.'
-            WHERE c_id = '.$course_id.' AND reflink="'.Database::escape_string($page).'" AND '.$groupfilter.$condition_session.'
-            ORDER BY id DESC';
-    $result=Database::query($sql);
-
-    $KeyVisibility = null;
-    $KeyAssignment = null;
-    $KeyTitle = null;
-    $KeyUserId = null;
-    while ($row=Database::fetch_array($result)) {
-        $KeyVisibility = $row['visibility'];
-        $KeyAssignment = $row['assignment'];
-        $KeyTitle = $row['title'];
-        $KeyUserId = $row['user_id'];
-    }
-    $icon_assignment = null;
-    if ($KeyAssignment == 1) {
-        $icon_assignment = Display::return_icon('wiki_assignment.png', get_lang('AssignmentDescExtra'), '', ICON_SIZE_SMALL);
-    } elseif($KeyAssignment == 2) {
-        $icon_assignment = Display::return_icon('wiki_work.png', get_lang('AssignmentWorkExtra'), '', ICON_SIZE_SMALL);
-    }
-
-    // Second, show
-
-    //if the page is hidden and is a job only sees its author and professor
-    if ($KeyVisibility == 1 ||
-        api_is_allowed_to_edit(false,true) ||
-        api_is_platform_admin() ||
-        (
-            $KeyAssignment==2 && $KeyVisibility==0 &&
-            (api_get_user_id() == $KeyUserId)
-        )
-    ) {
-        // We show the complete history
-        if (!isset($_POST['HistoryDifferences']) && !isset($_POST['HistoryDifferences2'])) {
-            $sql = 'SELECT * FROM '.$tbl_wiki.'
-                    WHERE
-                        c_id = '.$course_id.' AND
-                        reflink="'.Database::escape_string($page).'" AND
-                        '.$groupfilter.$condition_session.'
-                    ORDER BY id DESC';
-            $result = Database::query($sql);
-            $title		= $_GET['title'];
-            $group_id	= $_GET['group_id'];
-
-            echo '<div id="wikititle">';
-            echo $icon_assignment.'&nbsp;&nbsp;&nbsp;'.api_htmlentities($KeyTitle);
-            echo '</div>';
-
-            echo '<form id="differences" method="POST" action="index.php?cidReq='.$_course['id'].'&action=history&title='.api_htmlentities(urlencode($title)).'&session_id='.api_htmlentities($session_id).'&group_id='.api_htmlentities($group_id).'">';
-
-            echo '<ul style="list-style-type: none;">';
-            echo '<br/>';
-            echo '<button class="search" type="submit" name="HistoryDifferences" value="HistoryDifferences">'.get_lang('ShowDifferences').' '.get_lang('LinesDiff').'</button>';
-            echo '<button class="search" type="submit" name="HistoryDifferences2" value="HistoryDifferences2">'.get_lang('ShowDifferences').' '.get_lang('WordsDiff').'</button>';
-            echo '<br/><br/>';
-
-            $counter=0;
-            $total_versions=Database::num_rows($result);
-
-            while ($row=Database::fetch_array($result)) {
-                $userinfo = api_get_user_info($row['user_id']);
-                $username = api_htmlentities(sprintf(get_lang('LoginX'), $userinfo['username']), ENT_QUOTES);
-
-                echo '<li style="margin-bottom: 5px;">';
-                ($counter==0) ? $oldstyle='style="visibility: hidden;"':$oldstyle='';
-                ($counter==0) ? $newchecked=' checked':$newchecked='';
-                ($counter==$total_versions-1) ? $newstyle='style="visibility: hidden;"':$newstyle='';
-                ($counter==1) ? $oldchecked=' checked':$oldchecked='';
-                echo '<input name="old" value="'.$row['id'].'" type="radio" '.$oldstyle.' '.$oldchecked.'/> ';
-                echo '<input name="new" value="'.$row['id'].'" type="radio" '.$newstyle.' '.$newchecked.'/> ';
-                echo '<a href="'.api_get_self().'?action=showpage&amp;title='.api_htmlentities(urlencode($page)).'&amp;view='.$row['id'].'">';
-                echo '<a href="'.api_get_self().'?cidReq='.$_course['id'].'&action=showpage&amp;title='.api_htmlentities(urlencode($page)).'&amp;view='.$row['id'].'&session_id='.$session_id.'&group_id='.$group_id.'">';
-
-                echo api_get_local_time($row['dtime'], null, date_default_timezone_get());
-                echo '</a>';
-                echo ' ('.get_lang('Version').' '.$row['version'].')';
-                echo ' '.get_lang('By').' ';
-                if ($row['user_id']<>0) {
-                    echo '<a href="../user/userInfo.php?uInfo='.$userinfo['user_id'].'">'.
-                    Display::tag('span', api_htmlentities(api_get_person_name($userinfo['firstname'], $userinfo['lastname'])), array('title'=>$username)).
-                    '</a>';
-                } else {
-                    echo get_lang('Anonymous').' ('.api_htmlentities($row['user_ip']).')';
-                }
-                echo ' ( '.get_lang('Progress').': '.api_htmlentities($row['progress']).'%, ';
-                $comment = $row['comment'];
-                if (!empty($comment)) {
-                    echo get_lang('Comments').': '.api_htmlentities(api_substr($row['comment'],0,100));
-                    if (api_strlen($row['comment'])>100) {
-                        echo '... ';
-                    }
-                } else {
-                    echo get_lang('Comments').':  ---';
-                }
-                echo ' ) </li>';
-                $counter++;
-            } //end while
-
-            echo '<br/>';
-            echo '<button class="search" type="submit" name="HistoryDifferences" value="HistoryDifferences">'.get_lang('ShowDifferences').' '.get_lang('LinesDiff').'</button>';
-            echo '<button class="search" type="submit" name="HistoryDifferences2" value="HistoryDifferences2">'.get_lang('ShowDifferences').' '.get_lang('WordsDiff').'</button>';
-            echo '</ul></form>';
-        } else { // We show the differences between two versions
-            $version_old = array();
-            if (isset($_POST['old'])) {
-                $sql_old= "SELECT * FROM $tbl_wiki
-                           WHERE c_id = $course_id AND id='".Database::escape_string($_POST['old'])."'";
-                $result_old=Database::query($sql_old);
-                $version_old=Database::fetch_array($result_old);
-            }
-
-            $sql_new="SELECT * FROM $tbl_wiki WHERE c_id = $course_id AND id='".Database::escape_string($_POST['new'])."'";
-            $result_new=Database::query($sql_new);
-            $version_new=Database::fetch_array($result_new);
-            $oldTime = isset($version_old['dtime']) ? $version_old['dtime'] : null;
-            $oldContent = isset($version_old['content']) ? $version_old['content'] : null;
-
-            if (isset($_POST['HistoryDifferences'])) {
-                include 'diff.inc.php';
-                //title
-                echo '<div id="wikititle">'.api_htmlentities($version_new['title']).'
-                <font size="-2"><i>('.get_lang('DifferencesNew').'</i>
-                    <font style="background-color:#aaaaaa">'.$version_new['dtime'].'</font>
-                    <i>'.get_lang('DifferencesOld').'</i>
-                    <font style="background-color:#aaaaaa">'.$oldTime.'</font>
-                ) '.get_lang('Legend').':  <span class="diffAdded" >'.get_lang('WikiDiffAddedLine').'</span>
-                <span class="diffDeleted" >'.get_lang('WikiDiffDeletedLine').'</span> <span class="diffMoved">'.get_lang('WikiDiffMovedLine').'</span></font>
-                </div>';
-            }
-            if (isset($_POST['HistoryDifferences2'])) {
-                // including global PEAR diff libraries
-                require_once 'Text/Diff.php';
-                require_once 'Text/Diff/Renderer/inline.php';
-                //title
-                echo '<div id="wikititle">'.api_htmlentities($version_new['title']).'
-                <font size="-2"><i>('.get_lang('DifferencesNew').'</i> <font style="background-color:#aaaaaa">'.$version_new['dtime'].'</font>
-                <i>'.get_lang('DifferencesOld').'</i> <font style="background-color:#aaaaaa">'.$version_old['dtime'].'</font>)
-                '.get_lang('Legend').':  <span class="diffAddedTex" >'.get_lang('WikiDiffAddedTex').'</span>
-                <span class="diffDeletedTex" >'.get_lang('WikiDiffDeletedTex').'</span></font></div>';
-            }
-
-
-            if (isset($_POST['HistoryDifferences'])) {
-                echo '<table>'.diff($oldContent, $version_new['content'], true, 'format_table_line' ).'</table>'; // format_line mode is better for words
-                echo '<br />';
-                echo '<strong>'.get_lang('Legend').'</strong><div class="diff">' . "\n";
-                echo '<table><tr>';
-                echo  '<td>';
-                echo '</td><td>';
-                echo '<span class="diffEqual" >'.get_lang('WikiDiffUnchangedLine').'</span><br />';
-                echo '<span class="diffAdded" >'.get_lang('WikiDiffAddedLine').'</span><br />';
-                echo '<span class="diffDeleted" >'.get_lang('WikiDiffDeletedLine').'</span><br />';
-                echo '<span class="diffMoved" >'.get_lang('WikiDiffMovedLine').'</span><br />';
-                echo '</td>';
-                echo '</tr></table>';
-            }
-
-            if (isset($_POST['HistoryDifferences2'])) {
-                $lines1 = array(strip_tags($version_old['content'])); //without <> tags
-                $lines2 = array(strip_tags($version_new['content'])); //without <> tags
-                $diff = new Text_Diff($lines1, $lines2);
-                $renderer = new Text_Diff_Renderer_inline();
-                echo '<style>del{background:#fcc}ins{background:#cfc}</style>'.$renderer->render($diff); // Code inline
-                echo '<br />';
-                echo '<strong>'.get_lang('Legend').'</strong><div class="diff">' . "\n";
-                echo '<table><tr>';
-                echo  '<td>';
-                echo '</td><td>';
-                echo '<span class="diffAddedTex" >'.get_lang('WikiDiffAddedTex').'</span><br />';
-                echo '<span class="diffDeletedTex" >'.get_lang('WikiDiffDeletedTex').'</span><br />';
-                echo '</td>';
-                echo '</tr></table>';
-            }
-        }
-    }
-}
+Display::display_header($tool_name, 'Wiki');
 
-// Recent changes
-// @todo rss feed
-if ($action =='recentchanges') {
-    $wiki->recentChanges($page, $action);
+// check last version
+if (!empty($view)) {
+    $wiki->setWikiData($view);
+    $wiki->checkLastVersion($view);
 }
 
-// All pages
-if ($action == 'allpages') {
-    $wiki->allPages($action);
-}
+// Tool introduction
+Display::display_introduction_section(TOOL_WIKI);
 
-// Discuss pages
-if ($action == 'discuss') {
-    $wiki->getDiscuss($page);
-}
+$wiki->showActionBar();
+echo $wiki->getMessages();
+echo $content;
 
 Display::display_footer();

Разница между файлами не показана из-за своего большого размера
+ 280 - 303
main/wiki/wiki.inc.php


+ 97 - 1
src/ChamiloLMS/Component/DataFilesystem/DataFilesystem.php

@@ -6,6 +6,10 @@ use Symfony\Component\Finder\Finder;
 use Symfony\Component\Finder\SplFileInfo;
 use Symfony\Component\Filesystem\Filesystem;
 use Symfony\Component\Console;
+use Unoconv\Unoconv;
+use Sunra\PhpSimple\HtmlDomParser;
+use ChamiloLMS\Component\Editor\Connector;
+use ChamiloLMS\Component\Editor\Driver\CourseDriver;
 
 /**
  * @todo use Gaufrette to manage course files (some day)
@@ -24,11 +28,15 @@ class DataFilesystem
     /**
      * @param array $paths
      * @param Filesystem $filesystem
+     * @param Unoconv $unoconv
      */
-    public function __construct($paths, Filesystem $filesystem)
+    public function __construct($paths, Filesystem $filesystem, Connector $editor, $unoconv = null)
     {
         $this->paths = $paths;
         $this->fs = $filesystem;
+        $this->unoconv = $unoconv;
+        $this->editor = $editor;
+        $this->editor->setDriver('CourseDriver');
     }
 
     /**
@@ -140,4 +148,92 @@ class DataFilesystem
         $styleSheetFolder = $this->paths['root_sys'].'main/css';
         return $finder->directories()->depth('== 0')->in($styleSheetFolder);
     }
+
+    /**
+     * Creates a empty file inside the temp folder
+     * @param string $fileName
+     * @param string $extension
+     * @return string
+     */
+    public function createTempFile($fileName = null, $extension = null)
+    {
+        if (empty($fileName)) {
+            $fileName = mt_rand();
+        }
+        if (!empty($extension)) {
+            $extension = ".$extension";
+        }
+        $filePath = $this->paths['sys_temp_path'].$fileName.$extension;
+        $this->fs->touch($filePath);
+        if ($this->fs->exists($filePath)) {
+            return $filePath;
+        }
+        return null;
+    }
+
+    /**
+     * Converts ../courses/ABC/document/file.jpg to
+     * http://chamilo/courses/ABC/document/file.jpg
+     * @param string $content
+     * @return string
+     */
+    public function convertRelativeToAbsoluteUrl($content)
+    {
+        /** @var CourseDriver $courseDriver */
+        $courseDriver = $this->editor->getDriver('CourseDriver');
+
+        $dom = HtmlDomParser::str_get_html($content);
+        //var_dump($this->editor->getDrivers());
+        /** @var \simple_html_dom_node $image */
+        foreach ($dom->find('img') as $image) {
+            $image->src = str_replace(
+                $courseDriver->getCourseDocumentRelativeWebPath(),
+                $courseDriver->getCourseDocumentWebPath(),
+                $image->src
+            );
+        }
+        return $dom;
+    }
+
+    /**
+     * Save string in a temp file
+     * @param string $content
+     * @param string $fileName
+     * @param string $extension
+     *
+     * @return string file path
+     */
+    public function putContentInTempFile($content, $filename = null, $extension = null)
+    {
+        $file = $this->createTempFile($filename, $extension);
+        if (!empty($file)) {
+            $this->fs->dumpFile($file, $content);
+            return $file;
+        }
+        return null;
+    }
+
+    /**
+     * @param string $filePath
+     * @param string $format
+     * @return string
+     */
+    public function transcode($filePath, $format)
+    {
+        if ($this->fs->exists($filePath)) {
+            $fileInfo = pathinfo($filePath);
+            $fileName = $fileInfo['filename'];
+            $newFilePath = str_replace(
+                $fileInfo['basename'],
+                $fileName.'.'.$format, $filePath
+            );
+            $this->unoconv->transcode($filePath, $format, $newFilePath);
+            if ($this->fs->exists($newFilePath)) {
+                return $newFilePath;
+
+            }
+        }
+        return false;
+    }
+
 }

+ 24 - 9
src/ChamiloLMS/Component/Editor/Connector.php

@@ -170,7 +170,6 @@ class Connector
         return $driverUpdated;
     }
 
-
     /**
      * Get default driver settings.
      * @return array
@@ -269,19 +268,35 @@ class Connector
             )
         );
 
-        foreach ($this->getDriverList() as $driverName) {
-            $driverClass = $this->getDriverClass($driverName);
-            /** @var Driver $driver */
-            $driver = new $driverClass();
-            $driver->setName($driverName);
-            $driver->setConnector($this);
-            $this->addDriver($driver);
-        }
+        $this->setDrivers();
 
         $opts['roots'] = $this->getRoots();
         return $opts;
     }
 
+    /**
+     * Set drivers from list
+     */
+    public function setDrivers()
+    {
+        foreach ($this->getDriverList() as $driverName) {
+            $this->setDriver($driverName);
+        }
+    }
+
+    /**
+     * Sets a driver.
+     * @param string $driverName
+     */
+    public function setDriver($driverName)
+    {
+        $driverClass = $this->getDriverClass($driverName);
+        /** @var Driver $driver */
+        $driver = new $driverClass();
+        $driver->setName($driverName);
+        $driver->setConnector($this);
+        $this->addDriver($driver);
+    }
 
     /**
      * Simple function to demonstrate how to control file access using "accessControl" callback.

+ 16 - 2
src/ChamiloLMS/Component/Editor/Driver/CourseDriver.php

@@ -22,7 +22,7 @@ class CourseDriver extends Driver
             return array(
                 'driver' => 'CourseDriver',
                 'path' => $this->getCourseDocumentSysPath(),
-                'URL' => $this->getCourseDocumentWebPath(),
+                'URL' => $this->getCourseDocumentRelativeWebPath(),
                 'accessControl' => array($this, 'access'),
                 'alias' => $alias,
                 'attributes' => array(
@@ -58,7 +58,7 @@ class CourseDriver extends Driver
     /**
      * @return string
      */
-    public function getCourseDocumentWebPath()
+    public function getCourseDocumentRelativeWebPath()
     {
         $url = null;
         if (isset($this->connector->course)) {
@@ -68,6 +68,20 @@ class CourseDriver extends Driver
         return $url;
     }
 
+
+    /**
+     * @return string
+     */
+    public function getCourseDocumentWebPath()
+    {
+        $url = null;
+        if (isset($this->connector->course)) {
+            $directory = $this->connector->course->getDirectory();
+            $url = api_get_path(WEB_DATA_COURSE_PATH).$directory.'/document/';
+        }
+        return $url;
+    }
+
     /**
      * {@inheritdoc}
      */

+ 1 - 1
src/ChamiloLMS/Component/Editor/Driver/CourseUserDriver.php

@@ -28,7 +28,7 @@ class CourseUserDriver extends CourseDriver
                     'alias' => $alias,
                     'path' => $this->getCourseDocumentSysPath().$path,
                     //'alias' => $courseInfo['code'].' personal documents',
-                    'URL' => $this->getCourseDocumentWebPath().$path,
+                    'URL' => $this->getCourseDocumentRelativeWebPath().$path,
                     'accessControl' => 'access'
                 );
             }

+ 1 - 1
src/ChamiloLMS/Component/Editor/Driver/DropBoxDriver.php

@@ -81,7 +81,7 @@ class DropBoxDriver extends \elFinderVolumeMySQL implements InterfaceDriver
                         'alias' => 'dropbox',
                         'tmpPath' => $this->connector->paths['sys_temp_path'],
                         //'alias' => $courseInfo['code'].' personal documents',
-                        //'URL' => $this->getCourseDocumentWebPath().$path,
+                        //'URL' => $this->getCourseDocumentRelativeWebPath().$path,
                         'accessControl' => 'access'
                     );
                 }

+ 1 - 1
vendor/autoload.php

@@ -4,4 +4,4 @@
 
 require_once __DIR__ . '/composer' . '/autoload_real.php';
 
-return ComposerAutoloaderInit68de3dbf4a2a3e667c00f4d8391e6581::getLoader();
+return ComposerAutoloaderInitda8df92eadc454c2aaf367aac7d7b7ce::getLoader();

+ 0 - 24
vendor/composer/autoload_classmap.php

@@ -11,10 +11,6 @@ return array(
     'Absolute_Positioner' => $baseDir . '/main/inc/lib/phpdocx/pdf/include/absolute_positioner.cls.php',
     'AbstractLink' => $baseDir . '/main/gradebook/lib/be/abstractlink.class.php',
     'Abstract_Renderer' => $baseDir . '/main/inc/lib/phpdocx/pdf/include/abstract_renderer.cls.php',
-    'Access' => $baseDir . '/main/inc/lib/access.class.php',
-    'AccessAll' => $baseDir . '/main/inc/lib/access.class.php',
-    'AccessForbidden' => $baseDir . '/main/inc/lib/access.class.php',
-    'AccessToken' => $baseDir . '/main/inc/lib/access_token.class.php',
     'Accessurleditcoursestourl' => $baseDir . '/main/inc/lib/access_url_edit_courses_to_url_functions.lib.php',
     'Accessurleditsessionstourl' => $baseDir . '/main/inc/lib/access_url_edit_sessions_to_url_functions.lib.php',
     'Accessurledituserstourl' => $baseDir . '/main/inc/lib/access_url_edit_users_to_url_functions.lib.php',
@@ -22,7 +18,6 @@ return array(
     'AddManySessionToCategoryFunctions' => $baseDir . '/main/inc/lib/add_many_session_to_category_functions.lib.php',
     'AdminPage' => $baseDir . '/main/admin/admin_page.class.php',
     'Agenda' => $baseDir . '/main/inc/lib/agenda.lib.php',
-    'AjaxController' => $baseDir . '/main/inc/lib/ajax_controller.class.php',
     'Announcement' => $baseDir . '/main/coursecopy/classes/Announcement.class.php',
     'AnnouncementEmail' => $baseDir . '/main/inc/lib/announcement_email.class.php',
     'AnnouncementManager' => $baseDir . '/main/inc/lib/announcements.inc.php',
@@ -59,14 +54,12 @@ return array(
     'Cellmap' => $baseDir . '/main/inc/lib/phpdocx/pdf/include/cellmap.cls.php',
     'Certificate' => $baseDir . '/main/inc/lib/certificate.lib.php',
     'Cezpdf' => $baseDir . '/main/inc/lib/ezpdf/class.ezpdf.php',
-    'Chamilo' => $baseDir . '/main/inc/lib/chamilo.class.php',
     'ChamiloIndexer' => $baseDir . '/main/inc/lib/search/ChamiloIndexer.class.php',
     'ChamiloSession' => $baseDir . '/main/inc/lib/chamilo_session.class.php',
     'Chat' => $baseDir . '/main/inc/lib/chat.lib.php',
     'ClassManager' => $baseDir . '/main/inc/lib/classmanager.lib.php',
     'Collator' => $vendorDir . '/symfony/intl/Symfony/Component/Intl/Resources/stubs/Collator.php',
     'ConditionalLogin' => $baseDir . '/main/inc/lib/conditional_login.class.php',
-    'Controller' => $baseDir . '/main/inc/lib/controller.class.php',
     'Converter' => $baseDir . '/main/inc/lib/system/text/converter.class.php',
     'Course' => $baseDir . '/main/coursecopy/classes/Course.class.php',
     'CourseArchiver' => $baseDir . '/main/coursecopy/classes/CourseArchiver.class.php',
@@ -74,8 +67,6 @@ return array(
     'CourseCopyAttendance' => $baseDir . '/main/coursecopy/classes/Attendance.class.php',
     'CourseCopyLearnpath' => $baseDir . '/main/coursecopy/classes/CourseCopyLearnpath.class.php',
     'CourseDescription' => $baseDir . '/main/inc/lib/course_description.lib.php',
-    'CourseEntity' => $baseDir . '/main/inc/lib/course_entity.class.php',
-    'CourseEntityRepository' => $baseDir . '/main/inc/lib/course_entity_repository.class.php',
     'CourseHome' => $baseDir . '/main/inc/lib/course_home.lib.php',
     'CourseManager' => $baseDir . '/main/inc/lib/course.lib.php',
     'CourseRecycler' => $baseDir . '/main/coursecopy/classes/CourseRecycler.class.php',
@@ -189,8 +180,6 @@ return array(
     'DummyCourseCreator' => $baseDir . '/main/coursecopy/classes/DummyCourseCreator.class.php',
     'Encoding' => $baseDir . '/main/inc/lib/system/text/encoding.class.php',
     'EncodingConverter' => $baseDir . '/main/inc/lib/system/text/encoding_converter.class.php',
-    'Entity' => $baseDir . '/main/inc/lib/entity.class.php',
-    'EntityRepository' => $baseDir . '/main/inc/lib/entity_repository.class.php',
     'EvalForm' => $baseDir . '/main/gradebook/lib/fe/evalform.class.php',
     'EvalLink' => $baseDir . '/main/gradebook/lib/be/evallink.class.php',
     'Evaluation' => $baseDir . '/main/gradebook/lib/be/evaluation.class.php',
@@ -211,7 +200,6 @@ return array(
     'FacebookApiException' => $baseDir . '/main/auth/external_login/facebook-php-sdk/src/base_facebook.php',
     'FileManager' => $baseDir . '/main/inc/lib/fileManager.lib.php',
     'FileReader' => $baseDir . '/main/inc/lib/system/io/file_reader.class.php',
-    'FileStore' => $baseDir . '/main/inc/lib/file_store.class.php',
     'FileWriter' => $baseDir . '/main/inc/lib/system/io/file_writer.class.php',
     'FillBlanks' => $baseDir . '/main/exercice/fill_blanks.class.php',
     'FlatViewDataGenerator' => $baseDir . '/main/gradebook/lib/flatview_data_generator.class.php',
@@ -364,7 +352,6 @@ return array(
     'Inline_Positioner' => $baseDir . '/main/inc/lib/phpdocx/pdf/include/inline_positioner.cls.php',
     'Inline_Renderer' => $baseDir . '/main/inc/lib/phpdocx/pdf/include/inline_renderer.cls.php',
     'IntlDateFormatter' => $vendorDir . '/symfony/intl/Symfony/Component/Intl/Resources/stubs/IntlDateFormatter.php',
-    'Javascript' => $baseDir . '/main/inc/lib/javascript.class.php',
     'Javascript_Embedder' => $baseDir . '/main/inc/lib/phpdocx/pdf/include/javascript_embedder.cls.php',
     'KeyAuth' => $baseDir . '/main/auth/key/key_auth.class.php',
     'LearnpathLink' => $baseDir . '/main/gradebook/lib/be/learnpathlink.class.php',
@@ -444,12 +431,7 @@ return array(
     'MediaQuestion' => $baseDir . '/main/exercice/media_question.class.php',
     'MessageManager' => $baseDir . '/main/inc/lib/message.lib.php',
     'Model' => $baseDir . '/main/inc/lib/model.lib.php',
-    'Model\\Course' => $baseDir . '/main/inc/lib/course.class.php',
     'Model\\Document' => $baseDir . '/main/inc/lib/document.class.php',
-    'Model\\ItemProperty' => $baseDir . '/main/inc/lib/item_property.class.php',
-    'Model\\ItemPropertyRepository' => $baseDir . '/main/inc/lib/item_property.class.php',
-    'Model\\StudentPublication' => $baseDir . '/main/inc/lib/student_publication.class.php',
-    'Model\\StudentPublicationRepository' => $baseDir . '/main/inc/lib/student_publication.class.php',
     'MultipleAnswer' => $baseDir . '/main/exercice/multiple_answer.class.php',
     'MultipleAnswerCombination' => $baseDir . '/main/exercice/multiple_answer_combination.class.php',
     'MultipleAnswerCombinationTrueFalse' => $baseDir . '/main/exercice/multiple_answer_combination_true_false.class.php',
@@ -486,7 +468,6 @@ return array(
     'PGTStorageDB' => $baseDir . '/main/auth/cas/lib/CAS/PGTStorage/pgt-db.php',
     'PGTStorageFile' => $baseDir . '/main/auth/cas/lib/CAS/PGTStorage/pgt-file.php',
     'PHP_Evaluator' => $baseDir . '/main/inc/lib/phpdocx/pdf/include/php_evaluator.cls.php',
-    'Page' => $baseDir . '/main/inc/lib/page.class.php',
     'PageController' => $baseDir . '/main/inc/lib/page.lib.php',
     'Page_Cache' => $baseDir . '/main/inc/lib/phpdocx/pdf/include/page_cache.cls.php',
     'Page_Frame_Decorator' => $baseDir . '/main/inc/lib/phpdocx/pdf/include/page_frame_decorator.cls.php',
@@ -528,15 +509,11 @@ return array(
     'QuizQuestion' => $baseDir . '/main/coursecopy/classes/QuizQuestion.class.php',
     'QuizQuestionOption' => $baseDir . '/main/coursecopy/classes/QuizQuestionOption.class.php',
     'RSSCache' => $baseDir . '/main/inc/lib/magpierss/rss_cache.inc',
-    'Redirect' => $baseDir . '/main/inc/lib/redirect.class.php',
     'Renderer' => $baseDir . '/main/inc/lib/phpdocx/pdf/include/renderer.cls.php',
     'Resource' => $baseDir . '/main/coursecopy/classes/Resource.class.php',
-    'Response' => $baseDir . '/main/inc/lib/response.class.php',
     'Result' => $baseDir . '/main/gradebook/lib/be/result.class.php',
-    'ResultSet' => $baseDir . '/main/inc/lib/result_set.class.php',
     'ResultTable' => $baseDir . '/main/gradebook/lib/fe/resulttable.class.php',
     'ResultsDataGenerator' => $baseDir . '/main/gradebook/lib/results_data_generator.class.php',
-    'Rights' => $baseDir . '/main/inc/lib/rights.lib.php',
     'S3SoapClient' => $baseDir . '/main/inc/lib/elfinder/php/elFinderVolumeS3.class.php',
     'SVG' => $vendorDir . '/mpdf/mpdf/classes/svg.php',
     'ScoreDisplay' => $baseDir . '/main/gradebook/lib/scoredisplay.class.php',
@@ -684,7 +661,6 @@ return array(
     'UniqueAnswerNoOption' => $baseDir . '/main/exercice/unique_answer_no_option.class.php',
     'Uri' => $baseDir . '/main/inc/lib/uri.class.php',
     'UrlManager' => $baseDir . '/main/inc/lib/urlmanager.lib.php',
-    'UserApiKeyManager' => $baseDir . '/main/inc/lib/user_api_key_manager.class.php',
     'UserDataGenerator' => $baseDir . '/main/gradebook/lib/user_data_generator.class.php',
     'UserForm' => $baseDir . '/main/gradebook/lib/fe/userform.class.php',
     'UserGroup' => $baseDir . '/main/inc/lib/usergroup.lib.php',

+ 1 - 0
vendor/composer/autoload_namespaces.php

@@ -44,6 +44,7 @@ return array(
     'Symfony\\Bridge\\Monolog\\' => array($vendorDir . '/symfony/monolog-bridge'),
     'Symfony\\Bridge\\Doctrine\\' => array($vendorDir . '/symfony/doctrine-bridge'),
     'SwfTools' => array($vendorDir . '/swftools/swftools/src'),
+    'Sunra\\PhpSimple\\HtmlDomParser' => array($vendorDir . '/sunra/php-simple-html-dom-parser/Src'),
     'Silex\\Provider\\' => array($vendorDir . '/silex/web-profiler'),
     'SilexOpauth' => array($vendorDir . '/icehero/silex-opauth/src'),
     'SilexAssetic' => array($vendorDir . '/mheap/silex-assetic/src'),

+ 5 - 5
vendor/composer/autoload_real.php

@@ -2,7 +2,7 @@
 
 // autoload_real.php @generated by Composer
 
-class ComposerAutoloaderInit68de3dbf4a2a3e667c00f4d8391e6581
+class ComposerAutoloaderInitda8df92eadc454c2aaf367aac7d7b7ce
 {
     private static $loader;
 
@@ -19,9 +19,9 @@ class ComposerAutoloaderInit68de3dbf4a2a3e667c00f4d8391e6581
             return self::$loader;
         }
 
-        spl_autoload_register(array('ComposerAutoloaderInit68de3dbf4a2a3e667c00f4d8391e6581', 'loadClassLoader'), true, true);
+        spl_autoload_register(array('ComposerAutoloaderInitda8df92eadc454c2aaf367aac7d7b7ce', 'loadClassLoader'), true, true);
         self::$loader = $loader = new \Composer\Autoload\ClassLoader();
-        spl_autoload_unregister(array('ComposerAutoloaderInit68de3dbf4a2a3e667c00f4d8391e6581', 'loadClassLoader'));
+        spl_autoload_unregister(array('ComposerAutoloaderInitda8df92eadc454c2aaf367aac7d7b7ce', 'loadClassLoader'));
 
         $vendorDir = dirname(__DIR__);
         $baseDir = dirname($vendorDir);
@@ -45,14 +45,14 @@ class ComposerAutoloaderInit68de3dbf4a2a3e667c00f4d8391e6581
 
         $includeFiles = require __DIR__ . '/autoload_files.php';
         foreach ($includeFiles as $file) {
-            composerRequire68de3dbf4a2a3e667c00f4d8391e6581($file);
+            composerRequireda8df92eadc454c2aaf367aac7d7b7ce($file);
         }
 
         return $loader;
     }
 }
 
-function composerRequire68de3dbf4a2a3e667c00f4d8391e6581($file)
+function composerRequireda8df92eadc454c2aaf367aac7d7b7ce($file)
 {
     require $file;
 }

+ 45 - 0
vendor/composer/installed.json

@@ -5746,5 +5746,50 @@
             "assetic",
             "silex"
         ]
+    },
+    {
+        "name": "sunra/php-simple-html-dom-parser",
+        "version": "v1.5.0",
+        "version_normalized": "1.5.0.0",
+        "source": {
+            "type": "git",
+            "url": "https://github.com/sunra/php-simple-html-dom-parser.git",
+            "reference": "a0b80ace086c7e09085669205e1b3c2c9c7a453c"
+        },
+        "dist": {
+            "type": "zip",
+            "url": "https://api.github.com/repos/sunra/php-simple-html-dom-parser/zipball/a0b80ace086c7e09085669205e1b3c2c9c7a453c",
+            "reference": "a0b80ace086c7e09085669205e1b3c2c9c7a453c",
+            "shasum": ""
+        },
+        "require": {
+            "php": ">=5.3.2"
+        },
+        "time": "2013-05-04 14:32:03",
+        "type": "library",
+        "installation-source": "dist",
+        "autoload": {
+            "psr-0": {
+                "Sunra\\PhpSimple\\HtmlDomParser": "Src/"
+            }
+        },
+        "notification-url": "https://packagist.org/downloads/",
+        "license": [
+            "MIT"
+        ],
+        "authors": [
+            {
+                "name": "Sunra",
+                "email": "sunra@yandex.ru",
+                "homepage": "https://github.com/sunra"
+            }
+        ],
+        "description": "Composer adaptation of: A HTML DOM parser written in PHP5+ let you manipulate HTML in a very easy way! Require PHP 5+. Supports invalid HTML. Find tags on an HTML page with selectors just like jQuery. Extract contents from HTML in a single line.",
+        "homepage": "https://github.com/sunra/php-simple-html-dom-parser",
+        "keywords": [
+            "dom",
+            "html",
+            "parser"
+        ]
     }
 ]

+ 38 - 0
vendor/sunra/php-simple-html-dom-parser/README.md

@@ -0,0 +1,38 @@
+php-simple-html-dom-parser
+==========================
+
+Version 1.5
+
+Adaptation for Composer and PSR-0 of:
+
+A HTML DOM parser written in PHP5+ let you manipulate HTML in a very easy way!
+Require PHP 5+.
+Supports invalid HTML.
+Find tags on an HTML page with selectors just like jQuery.
+Extract contents from HTML in a single line.
+
+http://simplehtmldom.sourceforge.net/
+
+
+Install
+-------
+
+ composer.phar require
+  - package name: "sunra/php-simple-html-dom-parser": "dev-master"
+
+
+Usage
+-----
+
+```php
+use Sunra\PhpSimple\HtmlDomParser;
+
+...
+$dom = HtmlDomParser::str_get_html( $str );
+or 
+$dom = HtmlDomParser::file_get_html( $file_name );
+
+$elems = $dom->find($elem_name);
+...
+
+```

+ 20 - 0
vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/HtmlDomParser.php

@@ -0,0 +1,20 @@
+<?php
+// say me who add "О╩©" into start of file?
+// Becouse of this 3 symbol before <?php - php get error
+// i think it Sublime Text
+
+namespace Sunra\PhpSimple;
+
+require 'simplehtmldom_1_5'.DIRECTORY_SEPARATOR.'simple_html_dom.php';
+
+class HtmlDomParser {
+	
+    static public function file_get_html() {
+		return call_user_func_array ( '\file_get_html' , func_get_args() );
+    }
+
+    // get html dom from string
+    static public function str_get_html() {
+		return call_user_func_array ( '\str_get_html' , func_get_args() );
+	}
+}

+ 891 - 0
vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/app/google.htm

@@ -0,0 +1,891 @@
+
+
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml" >
+<head id="ctl00_Head1"><title>
+	FootballScoresLive - Previous Results
+</title><meta name="Keywords" content="football,soccer,score,goals,penalty,penalties,red cards,yellow cards,results,england,
+english,scotland,scottish,wales,welsh,europe,european,sms,results by sms" /><meta name="Description" content="FootballScoresLive offers continuous updates of scores from football (soccer) 
+matches in Britain, Europe, North and South America, and Asia, free direct to your web browser, 
+and by SMS to your mobile." /><link href="page.css" rel="stylesheet" type="text/css" /><link href="news.css" rel="stylesheet" type="text/css" /><link href="results.css" rel="stylesheet" type="text/css" />
+<script type="text/javascript" src="overlib.js"><!-- overLIB (c) Erik Bosrup --></script>
+<script type="text/javascript" src="MMfuncs.js"></script>
+<script type="text/javascript" src="swfdetect.js"></script>
+<script type="text/vbscript" src="swfver.vbs"></script>
+<link rel="shortcut icon" href="/favicon.ico" /><style type="text/css">
+	.atlas__delta { font-family:Lucida Console; }
+
+</style></head>
+<body onload="MM_preloadImages('images/buttons/englishNational_hl.jpg','images/buttons/englishLeagues_hl.jpg',
+'images/buttons/futureFixtures_hl.jpg','images/buttons/italianLeagues_hl.jpg','images/buttons/leagueTables_hl.jpg','images/buttons/login_hl.jpg','images/buttons/favourites_hl.jpg','images/buttons/personalise_hl.jpg','images/buttons/previousResults_hl.jpg','images/buttons/scottishLeagues_hl.jpg','images/buttons/seasonTicket_hl.jpg','images/buttons/spanishLeagues_hl.jpg','images/buttons/sponsored_hl.jpg','images/buttons/supermarket_hl.jpg','images/buttons/livescores_hl.jpg')" 
+onunload="MM_callJS('CheckFlash();')">
+<div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>
+    <form name="aspnetForm" method="post" action="MatchResults.aspx" id="aspnetForm">
+<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="dB6ayi9LZ+8oLEEG+Bb0EaB7S0yWNAwmwFJYNlmIPIfC1cvZYgBlKWTvoA4O9/nWx6kKCiBPFnSnfWNC5mLsqwKJAqRalzt4zBR7te1bjeJGgN0H2d1aCn3KgK2DLo6jp/xsNAQLvdqugFXdJ+7RvO58WASnJAH4vjnV2vTi6kKfuRGvNvzsfcybchbHQ+T2yUU9pTrLfSRSC6qEw00ANEJLyR8cnnsgTQhOcXFIPwCbFQEljWnQHmV6l+YMt9GeyxuhD7qL+JcVOPkqZ4TROE1TWmVLD8kOwmpEaMwINDlz/veOnNh/HVdabDznCkdFd3yzhpyyx4/mqWqp4GmkbsFyiUvZoKYin/4xf7L1Z0NfMamm3lZZMFpWz8AhmWcL99qa5kcLgjtXMzZvOKn6K/pud0lEVkvl3Kz2jXgzZPxh3qdX4Nx5anjttd6NKyF3wSlfVMk0j8zoZmja8HaqpwZZfSFnn+U7wWO6D9vzZKDJ/nxUbJHqEaLYYz+QD6zWHVfsEi3cZJlit0oOWatl8AjSHKPmFi3oD9jD3K/FiuhYFYkyk07Jpoe/6YvKgeisZaFYDQrqTTVGYul9rQRVRkUc0UVrt7TZJ/d08EXYKhWYRBx2xxQt3Yfbefr45GCComTUGOjml7DVITe9811QIXfgw5GaECa6aBi2hvYSB6gdhFlqrdqi/HK2DTcXFTyN5n749O3MgVJGSQtXP/xsTp3J1t2lOSMlz9hZYwQUDqOpaWZG2Ae8JmzhvdClyw1AxhJolgEGsutAtYhXFc16ihtjYd/JXx47zeBoB8temPCNJwpFmAN3iXV9nhu5RZ6q8hSnpfCBCn756EDnykItEhTStGovLsJG+QdRNsLE56mNtIxFxeAGrwLWJ260+QsRcvimNAERfZtow7Vx/JPMJLfXrvd1G6u0jP/uqJAQPP8WjVUUfAK5yJHi2PzzGTtFDPd7TJenlgzzyzTcPjJKib+W+CRBBboPRnro9659+79nZwYXdbHHDlQiNcBKZfYKohFHSteJRn4/XnUI2MAi+j9a5JfGs7syF7OWjvFCevTrS/toNPaPzM+muJF3/cLQA0kuM/OvaS+9Kj16BCdNfy6mPZMy6pD95xMGomu1adBwKvaTLMmjrt5Kgh5RxGrUf+pl1IoY9u8=" />
+
+
+<script src="/WebResource.axd?d=OSFApkHgVTFGp_WGnj5w0YyfbDgId8eejj1HHj2udCziBXq1lnucLLMhY2b4ssXravjY6R0n3Xz5xE3pKbfs7VC_WlWODN-9NNOB8qqY6cA1&amp;t=633112977674076250" type="text/javascript"></script>
+<script src="/WebResource.axd?d=OSFApkHgVTFGp_WGnj5w0YyfbDgId8eejj1HHj2udCziBXq1lnucLLMhY2b4ssXravjY6R0n3Xz5xE3pKbfs7blAzxonPUmCsga2GgPJUY41&amp;t=633112977674076250" type="text/javascript"></script>
+    <div>
+<table id="Table_01" width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
+	<tr>
+		<td colspan="2" rowspan="2" width="394" height="111" >
+            <a href="LiveScores.aspx">
+                <img src="images/fsl_logo.jpg" width="394" height="111" border="0" alt="FootballScoresLive logo" /></a></td>
+		<td height="81" width="100%" valign="middle" background="images/grass_top.jpg" align="center">
+            <a id="ctl00_lnkScores2Mobile" title="Click here for Live Scores to your mobile" href="live-premiership-football-scores-via-sms.aspx" style="display:inline-block;"><img title="Click here for Live Scores to your mobile" src="images/scores2mobile.jpg" border="0" /></a>
+        </td>
+		<td width="174" height="81" align="center" valign="middle" background="images/grass_top.jpg">
+            
+                <a href="Register.aspx"><img src="images/btn_reg.gif" border="0" /></a>
+                
+        </td>
+	</tr>
+	<tr style="color: yellow;">
+		<td width="237" height="30" align="center" valign="middle" background="images/visitors_bg.jpg" class="body12">
+            <strong>
+		For <span style="color: red">FREE</span> goals to your mobile</strong>
+            <a id="ctl00_HyperLink1" class="navlink" href="fixtures.aspx">Click Here</a></td>
+		<td align="center" valign="middle" bgcolor="#000000" class="body12">
+            <table width=100% border="0" cellpadding="0" cellspacing="0">
+            <tr style="color: white;">
+            <td>
+                
+                        <input type="submit" name="ctl00$LoginView5$btnLogin" value="LogIn" onclick="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(&quot;ctl00$LoginView5$btnLogin&quot;, &quot;&quot;, false, &quot;&quot;, &quot;login.aspx&quot;, false, false))" id="ctl00_LoginView5_btnLogin" />
+                    
+            </td>
+            <td>&nbsp;
+            </td>
+            </tr>
+            </table>
+	      </td>
+	</tr>
+<!--
+	<tr>
+		<td height="16" colspan="4" bgcolor="#000000">
+		    &nbsp;|&nbsp;<a href="default.aspx" class="navlink">Home</a>
+		    &nbsp;|&nbsp;<a href="live-premiership-football-scores-via-sms.aspx" class="navlink">SMS Service</a>
+		    &nbsp;|&nbsp;<a href="LiveScores.aspx" class="navlink">Live Scores</a>
+		    &nbsp;|&nbsp;<a href="MatchResults.aspx" class="navlink">Previous Results</a>
+		    &nbsp;|&nbsp;<a href="fixtures.aspx" class="navlink">Future Fixtures</a>&nbsp;|&nbsp;
+		       <a id="ctl00_LoginStatus2" class="navlink" href="javascript:__doPostBack('ctl00$LoginStatus2$ctl02','')">Login</a>&nbsp;|&nbsp;
+                    <a href="login/personal.aspx" class="navlink">Personalise</a>&nbsp;|&nbsp;
+                        
+                        <br />
+        </td>
+	</tr>
+-->
+	<tr height="100%">
+		<td width="174" align="center" valign="top" background="images/grass_left.jpg">
+<!--
+            <a href="#" onclick='window.external.AddFavorite(location.href,document.title);' class="navlink">
+            <img src="images/favourites.jpg" border="0"/></a>
+-->
+            <br />
+<table width="100%" border="0" cellspacing="0" cellpadding="0">
+      <tr>
+        <td>
+        <a href="#" onclick='window.external.AddFavorite(location.href,document.title);' class="navlink">
+        <img src="images/buttons/favourites.jpg" border="0" alt="Add this page to your favourites" name="fav" width="165" height="21" onmouseover="MM_swapImage('fav','','images/buttons/favourites_hl.jpg',1)" onmouseout="MM_swapImgRestore()" />
+        </a>
+        </td>
+      </tr>
+      <tr>
+        <td><img src="images/buttons/seasonTicket.jpg" border="0" alt="Season Ticket Goal Alerts - coming soon" name="season" width="166" height="22" onmouseover="MM_swapImage('season','','images/buttons/seasonTicket_hl.jpg',1)" onmouseout="MM_swapImgRestore()" /></td>
+      </tr>
+      <tr>
+        <td><img src="images/buttons/mobile.jpg" border="0" alt="Mobile Goal Alerts" name="mobile" width="166" height="20"  /></td>
+      </tr>
+      <tr>
+        <td><a href="live-premiership-football-scores-via-sms.aspx">
+        <img src="images/buttons/englishLeagues.jpg" alt="English Leagues" name="engLg" width="166" height="19" border="0" onmouseover="MM_swapImage('engLg','','images/buttons/englishLeagues_hl.jpg',1)" onmouseout="MM_swapImgRestore()" /></a></td>
+      </tr>
+      <tr>
+        <td><img src="images/buttons/englishNational.jpg" border="0" alt="English National Team - coming soon" name="engNat" width="166" height="18" onmouseover="MM_swapImage('engNat','','images/buttons/englishNational_hl.jpg',1)" onmouseout="MM_swapImgRestore()" /></td>
+      </tr>
+      <tr>
+        <td>
+            <a href="live-scottish-premier-league-football-scores-via-sms.aspx">
+                <img src="images/buttons/scottishLeagues.jpg" border="0" alt="Scottish Leagues" name="scotLg" width="166" height="18" onmouseover="MM_swapImage('scotLg','','images/buttons/scottishLeagues_hl.jpg',1)" onmouseout="MM_swapImgRestore()" /></a></td>
+      </tr>
+      <tr>
+        <td>
+            <a href="live-spain-football-scores-via-sms.aspx">
+                <img src="images/buttons/spanishLeagues.jpg" border="0" alt="Spanish Leagues" name="spanLg" width="166" height="18" onmouseover="MM_swapImage('spanLg','','images/buttons/spanishLeagues_hl.jpg',1)" onmouseout="MM_swapImgRestore()" /></a></td>
+      </tr>
+      <tr>
+        <td>
+            <a href="live-italy-football-scores-via-sms.aspx">
+                <img src="images/buttons/italianLeagues.jpg" border="0" alt="Italian Leagues" name="italLg" width="166" height="18" onmouseover="MM_swapImage('italLg','','images/buttons/italianLeagues_hl.jpg',1)" onmouseout="MM_swapImgRestore()" /></a></td>
+      </tr>
+      <tr>
+        <td><a href="LiveScores.aspx"><img src="images/buttons/livescores.jpg" border="0" alt="Live Scores" name="world" width="166" height="20" onmouseover="MM_swapImage('world','','images/buttons/livescores_hl.jpg',1)" onmouseout="MM_swapImgRestore()" /></a></td>
+      </tr>
+      <tr>
+        <td><img src="images/buttons/supermarket.jpg" border="0" alt="Football Supermarket - coming soon" name="super" width="166" height="20" onmouseover="MM_swapImage('super','','images/buttons/supermarket_hl.jpg',1)" onmouseout="MM_swapImgRestore()" /></td>
+      </tr>
+      <tr>
+        <td><a href="MatchResults.aspx"><img src="images/buttons/previousResults.jpg" border="0" alt="Previous Results" name="prev" width="166" height="20" onmouseover="MM_swapImage('prev','','images/buttons/previousResults_hl.jpg',1)" onmouseout="MM_swapImgRestore()" /></a></td>
+      </tr>
+      <tr>
+        <td><a href="fixtures.aspx"><img src="images/buttons/futureFixtures.jpg" border="0" alt="Future Fixtures" name="future" width="166" height="20" onmouseover="MM_swapImage('future','','images/buttons/futureFixtures_hl.jpg',1)" onmouseout="MM_swapImgRestore()" /></a></td>
+      </tr>
+      <tr>
+        <td><img src="images/buttons/leagueTables.jpg" border="0" alt="League Tables - coming soon" name="lgTbl" width="166" height="20" onmouseover="MM_swapImage('lgTbl','','images/buttons/leagueTables_hl.jpg',1)" onmouseout="MM_swapImgRestore()" /></td>
+      </tr>
+      <tr>
+        <td><img src="images/buttons/sponsored.jpg" border="0" alt="Sponsored Links - coming soon" name="spons" width="166" height="20" onmouseover="MM_swapImage('spons','','images/buttons/sponsored_hl.jpg',1)" onmouseout="MM_swapImgRestore()" /></td>
+      </tr>
+      <tr>
+        <td>&nbsp;</td>
+      </tr>
+      <tr>
+        <td><img src="images/buttons/personalise.jpg" border="0" alt="Personalise" name="pers" width="166" height="20" onmouseover="MM_swapImage('pers','','images/buttons/personalise_hl.jpg',1)" onmouseout="MM_swapImgRestore()" /></td>
+      </tr>
+      <tr>
+        <td>
+            <input id="ctl00_LoginStatus1" type="image" name="ctl00$LoginStatus1$ctl03" class="navlink" src="images/buttons/login.jpg" alt="Login" border="0" />
+      </tr>
+      <tr>
+      <td>
+                        
+                        <br />
+      </td>
+      </tr>
+    </table>
+            <a href="fixtures.aspx">
+            <img src="images/fsl_phone_static.jpg" width="130" height="238" border="0" />
+            </a>
+            <div id="ctl00_FixtureSelectPanel">
+	
+            <table border="0" cellpadding="0" cellspacing="0">
+                <tr style="background-color:Black; color:Green">
+                    <td colspan="2">
+                        <img id="ctl00_Image1" src="images/fixtures.jpg" border="0" /></td>
+                </tr>
+                <tr style="background-color:White">
+                    <td align="left">
+        <select name="ctl00$FixtureDropDown" id="ctl00_FixtureDropDown" title="Choose the date you want to see the fixtures" class="body">
+		<option value="18/12/2008 00:00:00">18/12/2008</option>
+		<option value="19/12/2008 00:00:00">19/12/2008</option>
+		<option value="20/12/2008 00:00:00">20/12/2008</option>
+		<option value="21/12/2008 00:00:00">21/12/2008</option>
+		<option value="22/12/2008 00:00:00">22/12/2008</option>
+		<option value="23/12/2008 00:00:00">23/12/2008</option>
+		<option value="26/12/2008 00:00:00">26/12/2008</option>
+		<option value="27/12/2008 00:00:00">27/12/2008</option>
+		<option value="28/12/2008 00:00:00">28/12/2008</option>
+		<option value="29/12/2008 00:00:00">29/12/2008</option>
+		<option value="30/12/2008 00:00:00">30/12/2008</option>
+		<option value="01/01/2009 00:00:00">01/01/2009</option>
+		<option value="02/01/2009 00:00:00">02/01/2009</option>
+
+	</select>
+            
+        </td>
+        <td align="right">
+            <input type="image" name="ctl00$FixtureButton" id="ctl00_FixtureButton" title="Click to see the fixtures on your chosen date" src="images/go.gif" align="absmiddle" onclick="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(&quot;ctl00$FixtureButton&quot;, &quot;&quot;, false, &quot;&quot;, &quot;fixtures.aspx&quot;, false, false))" border="0" />
+                  </td>
+                </tr>
+            </table>
+            
+</div>
+            <br />
+            <div style="text-align: center">
+                <table border="0" cellpadding="2" cellspacing="0">
+                    <tr>
+                        <td>
+                            <a href="live-premiership-football-scores-via-sms.aspx">
+                            <img src="images/flags2/england.jpg" border="0" alt="English Leagues goal alerts by SMS" /></a></td>
+                        <td>
+                            <a href="live-scottish-premier-league-football-scores-via-sms.aspx">
+                            <img src="images/flags2/scotland.jpg" border="0" alt="Scottish Leagues goal alerts by SMS" /></a></td>
+                        <td>
+                            <a href="live-spain-football-scores-via-sms.aspx">
+                            <img src="images/flags2/Spain.jpg" border="0" alt="Spanish Leagues goal alerts by SMS" /></a></td>
+                        <td>
+                            <a href="live-italy-football-scores-via-sms.aspx">
+                            <img src="images/flags2/Italy.jpg" border="0" alt="Italian Leagues goal alerts by SMS" /></a></td>
+                    </tr>
+                </table>
+            </div>
+            <br />
+            <img src="images/status.gif" width="110" height="127" /><br />
+		  <br />
+		    <img src="images/events.gif" width="110" height="115" /><br />
+	    </td>
+		<td width="100%" colspan="2" align="center" valign="top">
+        
+    
+    <div id="ctl00_ContentPlaceHolder1_UpdatePanel1">
+	
+<h1>Historical Football Archive - Updated Daily!</h1>
+<br />
+    <p class="body12">Missed the details of your football club's latest performance? 
+    Whether you support Manchester United or Cambridge United, Premiership club or Conference club, 
+    you will find it all here, with our fantastic soccer library of results over the last two weeks.
+    These pages contain the history & detailed results package for every football game from around the world 
+    from the last 14 match days, including not only every goal scored, but, game results, names of goal scorer, 
+    match results, red cards and plenty more! This service is automatically updated every 24 hours, 
+    simply select a date from the drop down menu :-
+     </p>
+    <select name="ctl00$ContentPlaceHolder1$DropDownList1" id="ctl00_ContentPlaceHolder1_DropDownList1">
+		<option selected="selected" value="17/12/2008 00:00:00">Wed 17/12/2008</option>
+		<option value="16/12/2008 00:00:00">Tue 16/12/2008</option>
+		<option value="15/12/2008 00:00:00">Mon 15/12/2008</option>
+		<option value="14/12/2008 00:00:00">Sun 14/12/2008</option>
+		<option value="13/12/2008 00:00:00">Sat 13/12/2008</option>
+		<option value="12/12/2008 00:00:00">Fri 12/12/2008</option>
+		<option value="11/12/2008 00:00:00">Thu 11/12/2008</option>
+		<option value="10/12/2008 00:00:00">Wed 10/12/2008</option>
+		<option value="09/12/2008 00:00:00">Tue 09/12/2008</option>
+		<option value="08/12/2008 00:00:00">Mon 08/12/2008</option>
+		<option value="07/12/2008 00:00:00">Sun 07/12/2008</option>
+		<option value="06/12/2008 00:00:00">Sat 06/12/2008</option>
+		<option value="05/12/2008 00:00:00">Fri 05/12/2008</option>
+		<option value="04/12/2008 00:00:00">Thu 04/12/2008</option>
+
+	</select>
+    
+<br /><br />
+
+        
+<table border="1" cellpadding="0" cellspacing="0" width="100%">
+    <tr>
+        <td style="text-align: left" class="header">
+            <span id="ctl00_ContentPlaceHolder1_Repeater1_ctl00_CompGames1_lblCompName">&nbsp;SCOTLAND - DIVISION 2</span></td>
+    </tr>
+    <tr>
+        <td>
+<div>
+		<table cellspacing="0" cellpadding="2" rules="all" border="1" id="ctl00_ContentPlaceHolder1_Repeater1_ctl00_CompGames1_GridView1" width="100%">
+			<tr class="header" align="left">
+				<th scope="col">Start</th><th scope="col">Stat</th><th scope="col">Min</th><th align="center" scope="col" width="17">R</th><th align="center" scope="col" width="17">P</th><th align="center" scope="col" width="17">O</th><th align="right" scope="col" width="30%">Home</th><th align="right" scope="col" width="10">   </th><th align="left" scope="col" width="10">   </th><th align="left" scope="col" width="30%">Away</th><th align="center" scope="col" width="17">R</th><th align="center" scope="col" width="17">P</th><th align="center" scope="col" width="17">O</th><th align="center" scope="col" width="17"><img src="images/info.gif" border="0" /></th><th scope="col" width="40%">Latest</th>
+			</tr><tr class="row">
+				<td>
+                19:45
+            </td><td>Pst       </td><td>-</td><td>
+                &nbsp;
+            </td><td>
+                &nbsp;
+            </td><td>
+                &nbsp;
+            </td><td align="right">STRANRAER</td><td align="right">0</td><td align="left">0</td><td align="left">PETERHEAD</td><td>
+                &nbsp;
+            </td><td>
+                &nbsp;
+            </td><td>
+                &nbsp;
+            </td><td>
+                &nbsp;
+            </td><td align="left">
+                &nbsp;
+            </td>
+			</tr>
+		</table>
+	</div>
+
+        </td>
+    </tr>
+</table>
+
+<br />
+
+    
+        
+<table border="1" cellpadding="0" cellspacing="0" width="100%">
+    <tr>
+        <td style="text-align: left" class="header">
+            <span id="ctl00_ContentPlaceHolder1_Repeater1_ctl01_CompGames1_lblCompName">&nbsp;ENGLAND - FA TROPHY - FIRST ROUND</span></td>
+    </tr>
+    <tr>
+        <td>
+<div>
+		<table cellspacing="0" cellpadding="2" rules="all" border="1" id="ctl00_ContentPlaceHolder1_Repeater1_ctl01_CompGames1_GridView1" width="100%">
+			<tr class="header" align="left">
+				<th scope="col">Start</th><th scope="col">Stat</th><th scope="col">Min</th><th align="center" scope="col" width="17">R</th><th align="center" scope="col" width="17">P</th><th align="center" scope="col" width="17">O</th><th align="right" scope="col" width="30%">Home</th><th align="right" scope="col" width="10">   </th><th align="left" scope="col" width="10">   </th><th align="left" scope="col" width="30%">Away</th><th align="center" scope="col" width="17">R</th><th align="center" scope="col" width="17">P</th><th align="center" scope="col" width="17">O</th><th align="center" scope="col" width="17"><img src="images/info.gif" border="0" /></th><th scope="col" width="40%">Latest</th>
+			</tr><tr class="row">
+				<td>
+                19:45
+            </td><td>FT        </td><td>-</td><td>
+                &nbsp;
+            </td><td>
+                &nbsp;
+            </td><td>
+                &nbsp;
+            </td><td align="right">SWINDON SUPERMARINE</td><td align="right">1</td><td align="left">0</td><td align="left">EASTBOURNE BOROUGH</td><td>
+                &nbsp;
+            </td><td>
+                &nbsp;
+            </td><td>
+                &nbsp;
+            </td><td>
+                <a class="poplink" href="javascript:void(0);" onmouseover="return overlib('<table border=0 cellpadding=2 cellspacing=0 width=250><tr align=left bgcolor=#ffffff><td><img src=\'images/info.gif\' /><b>Match information</b></td></tr><tr><td>Replayed if draw.</td></tr></table>',HAUTO,VAUTO,WIDTH,250);" onmouseout="return nd();"><img src="images/info.gif" border="0" /></a>
+            </td><td align="left">
+                <a class="poplink" href="javascript:void(0);" onmouseover="return overlib('<table><tr valign=top><td width=200><table border=1 cellspacing=0 cellpadding=2><tr valign=top><td width=20>Min</td><td width=20>&nbsp;</td><td width=120>Player</td></tr><tr><td>74</td><td><img align=\'top\' width=\'17\' height=\'16\' border=\'0\' src=\'images/ball.gif\' alt=\'goal\'></td><td nowrap=nowrap>EDENBOROUGH</td></tr></table></td><td width=200><table border=1 cellspacing=0 cellpadding=2><tr><td width=20>Min</td><td width=20>&nbsp;</td><td width=120>Player</td></tr></table></td></tr></table>',HAUTO,VAUTO,WIDTH,400);" onmouseout="return nd();">74<img align="top" width="17" height="16" border="0" src="images/ball.gif" alt="goal">EDENBOROUGH</a>
+            </td>
+			</tr>
+		</table>
+	</div>
+
+        </td>
+    </tr>
+</table>
+
+<br />
+
+    
+        
+<table border="1" cellpadding="0" cellspacing="0" width="100%">
+    <tr>
+        <td style="text-align: left" class="header">
+            <span id="ctl00_ContentPlaceHolder1_Repeater1_ctl02_CompGames1_lblCompName">&nbsp;EUROPE (UEFA) - UEFA CUP - GROUP STAGE</span></td>
+    </tr>
+    <tr>
+        <td>
+<div>
+		<table cellspacing="0" cellpadding="2" rules="all" border="1" id="ctl00_ContentPlaceHolder1_Repeater1_ctl02_CompGames1_GridView1" width="100%">
+			<tr class="header" align="left">
+				<th scope="col">Start</th><th scope="col">Stat</th><th scope="col">Min</th><th align="center" scope="col" width="17">R</th><th align="center" scope="col" width="17">P</th><th align="center" scope="col" width="17">O</th><th align="right" scope="col" width="30%">Home</th><th align="right" scope="col" width="10">   </th><th align="left" scope="col" width="10">   </th><th align="left" scope="col" width="30%">Away</th><th align="center" scope="col" width="17">R</th><th align="center" scope="col" width="17">P</th><th align="center" scope="col" width="17">O</th><th align="center" scope="col" width="17"><img src="images/info.gif" border="0" /></th><th scope="col" width="40%">Latest</th>
+			</tr><tr class="row">
+				<td>
+                19:45
+            </td><td>FT        </td><td>-</td><td>
+                &nbsp;
+            </td><td>
+                &nbsp;
+            </td><td>
+                &nbsp;
+            </td><td align="right">AC MILAN</td><td align="right">2</td><td align="left">2</td><td align="left">VfL WOLFSBURG</td><td>
+                &nbsp;
+            </td><td>
+                &nbsp;
+            </td><td>
+                &nbsp;
+            </td><td>
+                &nbsp;
+            </td><td align="left">
+                <a class="poplink" href="javascript:void(0);" onmouseover="return overlib('<table><tr valign=top><td width=200><table border=1 cellspacing=0 cellpadding=2><tr valign=top><td width=20>Min</td><td width=20>&nbsp;</td><td width=120>Player</td></tr><tr><td>17</td><td><img align=\'top\' width=\'17\' height=\'16\' border=\'0\' src=\'images/ball.gif\' alt=\'goal\'></td><td nowrap=nowrap>AMBROSINI</td></tr><tr><td>56</td><td><img align=\'top\' width=\'17\' height=\'16\' border=\'0\' src=\'images/ball.gif\' alt=\'goal\'></td><td nowrap=nowrap>PATO</td></tr></table></td><td width=200><table border=1 cellspacing=0 cellpadding=2><tr><td width=20>Min</td><td width=20>&nbsp;</td><td width=120>Player</td></tr><tr><td>55</td><td><img align=\'top\' width=\'17\' height=\'16\' border=\'0\' src=\'images/ball.gif\' alt=\'goal\'></td><td nowrap=nowrap>ZACCARDO</td></tr><tr><td>81</td><td><img align=\'top\' width=\'17\' height=\'16\' border=\'0\' src=\'images/ball.gif\' alt=\'goal\'></td><td nowrap=nowrap>SAGLIK</td></tr></table></td></tr></table>',HAUTO,VAUTO,WIDTH,400);" onmouseout="return nd();">81<img align="top" width="17" height="16" border="0" src="images/ball.gif" alt="goal">SAGLIK</a>
+            </td>
+			</tr><tr class="row_alt">
+				<td>
+                19:45
+            </td><td>FT        </td><td>-</td><td>
+                &nbsp;
+            </td><td bgcolor="Red">
+                1
+            </td><td>
+                &nbsp;
+            </td><td align="right">AJAX</td><td align="right">2</td><td align="left">2</td><td align="left">SLAVIA PRAHA</td><td>
+                &nbsp;
+            </td><td>
+                &nbsp;
+            </td><td>
+                &nbsp;
+            </td><td>
+                &nbsp;
+            </td><td align="left">
+                <a class="poplink" href="javascript:void(0);" onmouseover="return overlib('<table><tr valign=top><td width=200><table border=1 cellspacing=0 cellpadding=2><tr valign=top><td width=20>Min</td><td width=20>&nbsp;</td><td width=120>Player</td></tr><tr><td>4</td><td><img align=\'top\' width=\'17\' height=\'16\' border=\'0\' src=\'images/ball.gif\' alt=\'goal\'></td><td nowrap=nowrap>VERTONGHEN</td></tr><tr><td>90</td><td><img align=\'top\' width=\'17\' height=\'16\' border=\'0\' src=\'images/ball-pen.gif\' alt=\'penalty\'></td><td nowrap=nowrap>SUAREZ</td></tr></table></td><td width=200><table border=1 cellspacing=0 cellpadding=2><tr><td width=20>Min</td><td width=20>&nbsp;</td><td width=120>Player</td></tr><tr><td>13</td><td><img align=\'top\' width=\'17\' height=\'16\' border=\'0\' src=\'images/ball.gif\' alt=\'goal\'></td><td nowrap=nowrap>CERNY</td></tr><tr><td>41</td><td><img align=\'top\' width=\'17\' height=\'16\' border=\'0\' src=\'images/ball.gif\' alt=\'goal\'></td><td nowrap=nowrap>JAROLIM</td></tr></table></td></tr></table>',HAUTO,VAUTO,WIDTH,400);" onmouseout="return nd();">90<img align="top" width="17" height="16" border="0" src="images/ball-pen.gif" alt="penalty">SUAREZ</a>
+            </td>
+			</tr><tr class="row">
+				<td>
+                19:45
+            </td><td>FT        </td><td>-</td><td>
+                &nbsp;
+            </td><td>
+                &nbsp;
+            </td><td>
+                &nbsp;
+            </td><td align="right">CLUB BRUGGE</td><td align="right">0</td><td align="left">1</td><td align="left">FC COPENHAGEN</td><td>
+                &nbsp;
+            </td><td>
+                &nbsp;
+            </td><td>
+                &nbsp;
+            </td><td>
+                &nbsp;
+            </td><td align="left">
+                <a class="poplink" href="javascript:void(0);" onmouseover="return overlib('<table><tr valign=top><td width=200><table border=1 cellspacing=0 cellpadding=2><tr valign=top><td width=20>Min</td><td width=20>&nbsp;</td><td width=120>Player</td></tr></table></td><td width=200><table border=1 cellspacing=0 cellpadding=2><tr><td width=20>Min</td><td width=20>&nbsp;</td><td width=120>Player</td></tr><tr><td>58</td><td><img align=\'top\' width=\'17\' height=\'16\' border=\'0\' src=\'images/ball.gif\' alt=\'goal\'></td><td nowrap=nowrap>SANTIN</td></tr></table></td></tr></table>',HAUTO,VAUTO,WIDTH,400);" onmouseout="return nd();">58<img align="top" width="17" height="16" border="0" src="images/ball.gif" alt="goal">SANTIN</a>
+            </td>
+			</tr><tr class="row_alt">
+				<td>
+                19:45
+            </td><td>FT        </td><td>-</td><td>
+                &nbsp;
+            </td><td>
+                &nbsp;
+            </td><td>
+                &nbsp;
+            </td><td align="right">DEP. LA CORUNA</td><td align="right">1</td><td align="left">0</td><td align="left">NANCY</td><td>
+                &nbsp;
+            </td><td>
+                &nbsp;
+            </td><td>
+                &nbsp;
+            </td><td>
+                &nbsp;
+            </td><td align="left">
+                <a class="poplink" href="javascript:void(0);" onmouseover="return overlib('<table><tr valign=top><td width=200><table border=1 cellspacing=0 cellpadding=2><tr valign=top><td width=20>Min</td><td width=20>&nbsp;</td><td width=120>Player</td></tr><tr><td>74</td><td><img align=\'top\' width=\'17\' height=\'16\' border=\'0\' src=\'images/ball.gif\' alt=\'goal\'></td><td nowrap=nowrap>BODIPO</td></tr></table></td><td width=200><table border=1 cellspacing=0 cellpadding=2><tr><td width=20>Min</td><td width=20>&nbsp;</td><td width=120>Player</td></tr></table></td></tr></table>',HAUTO,VAUTO,WIDTH,400);" onmouseout="return nd();">74<img align="top" width="17" height="16" border="0" src="images/ball.gif" alt="goal">BODIPO</a>
+            </td>
+			</tr><tr class="row">
+				<td>
+                19:45
+            </td><td>FT        </td><td>-</td><td>
+                &nbsp;
+            </td><td>
+                &nbsp;
+            </td><td>
+                &nbsp;
+            </td><td align="right">FEYENOORD</td><td align="right">0</td><td align="left">1</td><td align="left">LECH POZNAN</td><td>
+                &nbsp;
+            </td><td>
+                &nbsp;
+            </td><td>
+                &nbsp;
+            </td><td>
+                &nbsp;
+            </td><td align="left">
+                <a class="poplink" href="javascript:void(0);" onmouseover="return overlib('<table><tr valign=top><td width=200><table border=1 cellspacing=0 cellpadding=2><tr valign=top><td width=20>Min</td><td width=20>&nbsp;</td><td width=120>Player</td></tr></table></td><td width=200><table border=1 cellspacing=0 cellpadding=2><tr><td width=20>Min</td><td width=20>&nbsp;</td><td width=120>Player</td></tr><tr><td>26</td><td><img align=\'top\' width=\'17\' height=\'16\' border=\'0\' src=\'images/ball.gif\' alt=\'goal\'></td><td nowrap=nowrap>DJURDJEVIC</td></tr></table></td></tr></table>',HAUTO,VAUTO,WIDTH,400);" onmouseout="return nd();">26<img align="top" width="17" height="16" border="0" src="images/ball.gif" alt="goal">DJURDJEVIC</a>
+            </td>
+			</tr><tr class="row_alt">
+				<td>
+                19:45
+            </td><td>FT        </td><td>-</td><td>
+                &nbsp;
+            </td><td>
+                &nbsp;
+            </td><td>
+                &nbsp;
+            </td><td align="right">HAMBURGER SV</td><td align="right">3</td><td align="left">1</td><td align="left">ASTON VILLA</td><td bgcolor="Red">
+                1
+            </td><td>
+                &nbsp;
+            </td><td>
+                &nbsp;
+            </td><td>
+                &nbsp;
+            </td><td align="left">
+                <a class="poplink" href="javascript:void(0);" onmouseover="return overlib('<table><tr valign=top><td width=200><table border=1 cellspacing=0 cellpadding=2><tr valign=top><td width=20>Min</td><td width=20>&nbsp;</td><td width=120>Player</td></tr><tr><td>18</td><td><img align=\'top\' width=\'17\' height=\'16\' border=\'0\' src=\'images/ball.gif\' alt=\'goal\'></td><td nowrap=nowrap>PETRIC</td></tr><tr><td>30</td><td><img align=\'top\' width=\'17\' height=\'16\' border=\'0\' src=\'images/ball.gif\' alt=\'goal\'></td><td nowrap=nowrap>OLIC</td></tr><tr><td>57</td><td><img align=\'top\' width=\'17\' height=\'16\' border=\'0\' src=\'images/ball.gif\' alt=\'goal\'></td><td nowrap=nowrap>OLIC</td></tr></table></td><td width=200><table border=1 cellspacing=0 cellpadding=2><tr><td width=20>Min</td><td width=20>&nbsp;</td><td width=120>Player</td></tr><tr><td>82</td><td><img align=\'top\' width=\'17\' height=\'16\' border=\'0\' src=\'images/ball.gif\' alt=\'goal\'></td><td nowrap=nowrap>DELFOUNESO</td></tr><tr><td>84</td><td><img align=\'top\' width=\'17\' height=\'16\' border=\'0\' src=\'images/redcard.gif\' alt=\'red card\'></td><td nowrap=nowrap>SIDWELL</td></tr></table></td></tr></table>',HAUTO,VAUTO,WIDTH,400);" onmouseout="return nd();">84<img align="top" width="17" height="16" border="0" src="images/redcard.gif" alt="red card">SIDWELL</a>
+            </td>
+			</tr><tr class="row">
+				<td>
+                19:45
+            </td><td>FT        </td><td>-</td><td>
+                &nbsp;
+            </td><td>
+                &nbsp;
+            </td><td>
+                &nbsp;
+            </td><td align="right">PORTSMOUTH</td><td align="right">3</td><td align="left">0</td><td align="left">HEERENVEEN</td><td>
+                &nbsp;
+            </td><td>
+                &nbsp;
+            </td><td>
+                &nbsp;
+            </td><td>
+                &nbsp;
+            </td><td align="left">
+                <a class="poplink" href="javascript:void(0);" onmouseover="return overlib('<table><tr valign=top><td width=200><table border=1 cellspacing=0 cellpadding=2><tr valign=top><td width=20>Min</td><td width=20>&nbsp;</td><td width=120>Player</td></tr><tr><td>40</td><td><img align=\'top\' width=\'17\' height=\'16\' border=\'0\' src=\'images/ball.gif\' alt=\'goal\'></td><td nowrap=nowrap>CROUCH</td></tr><tr><td>42</td><td><img align=\'top\' width=\'17\' height=\'16\' border=\'0\' src=\'images/ball.gif\' alt=\'goal\'></td><td nowrap=nowrap>CROUCH</td></tr><tr><td>90</td><td><img align=\'top\' width=\'17\' height=\'16\' border=\'0\' src=\'images/ball.gif\' alt=\'goal\'></td><td nowrap=nowrap>HREIDARSSON</td></tr></table></td><td width=200><table border=1 cellspacing=0 cellpadding=2><tr><td width=20>Min</td><td width=20>&nbsp;</td><td width=120>Player</td></tr></table></td></tr></table>',HAUTO,VAUTO,WIDTH,400);" onmouseout="return nd();">90<img align="top" width="17" height="16" border="0" src="images/ball.gif" alt="goal">HREIDARSSON</a>
+            </td>
+			</tr><tr class="row_alt">
+				<td>
+                19:45
+            </td><td>FT        </td><td>-</td><td>
+                &nbsp;
+            </td><td>
+                &nbsp;
+            </td><td>
+                &nbsp;
+            </td><td align="right">ST ETIENNE</td><td align="right">2</td><td align="left">2</td><td align="left">VALENCIA</td><td>
+                &nbsp;
+            </td><td>
+                &nbsp;
+            </td><td>
+                &nbsp;
+            </td><td>
+                &nbsp;
+            </td><td align="left">
+                <a class="poplink" href="javascript:void(0);" onmouseover="return overlib('<table><tr valign=top><td width=200><table border=1 cellspacing=0 cellpadding=2><tr valign=top><td width=20>Min</td><td width=20>&nbsp;</td><td width=120>Player</td></tr><tr><td>29</td><td><img align=\'top\' width=\'17\' height=\'16\' border=\'0\' src=\'images/ball.gif\' alt=\'goal\'></td><td nowrap=nowrap>ILAN</td></tr><tr><td>44</td><td><img align=\'top\' width=\'17\' height=\'16\' border=\'0\' src=\'images/ball.gif\' alt=\'goal\'></td><td nowrap=nowrap>ILAN</td></tr></table></td><td width=200><table border=1 cellspacing=0 cellpadding=2><tr><td width=20>Min</td><td width=20>&nbsp;</td><td width=120>Player</td></tr><tr><td>33</td><td><img align=\'top\' width=\'17\' height=\'16\' border=\'0\' src=\'images/ball.gif\' alt=\'goal\'></td><td nowrap=nowrap>MORIENTES</td></tr><tr><td>72</td><td><img align=\'top\' width=\'17\' height=\'16\' border=\'0\' src=\'images/ball.gif\' alt=\'goal\'></td><td nowrap=nowrap>ZIGIC</td></tr></table></td></tr></table>',HAUTO,VAUTO,WIDTH,400);" onmouseout="return nd();">72<img align="top" width="17" height="16" border="0" src="images/ball.gif" alt="goal">ZIGIC</a>
+            </td>
+			</tr>
+		</table>
+	</div>
+
+        </td>
+    </tr>
+</table>
+
+<br />
+
+    
+        
+<table border="1" cellpadding="0" cellspacing="0" width="100%">
+    <tr>
+        <td style="text-align: left" class="header">
+            <span id="ctl00_ContentPlaceHolder1_Repeater1_ctl03_CompGames1_lblCompName">&nbsp;INTERNATIONAL TOURNAMENTS - OMAN FOUR NATIONS TOUR</span></td>
+    </tr>
+    <tr>
+        <td>
+<div>
+		<table cellspacing="0" cellpadding="2" rules="all" border="1" id="ctl00_ContentPlaceHolder1_Repeater1_ctl03_CompGames1_GridView1" width="100%">
+			<tr class="header" align="left">
+				<th scope="col">Start</th><th scope="col">Stat</th><th scope="col">Min</th><th align="center" scope="col" width="17">R</th><th align="center" scope="col" width="17">P</th><th align="center" scope="col" width="17">O</th><th align="right" scope="col" width="30%">Home</th><th align="right" scope="col" width="10">   </th><th align="left" scope="col" width="10">   </th><th align="left" scope="col" width="30%">Away</th><th align="center" scope="col" width="17">R</th><th align="center" scope="col" width="17">P</th><th align="center" scope="col" width="17">O</th><th align="center" scope="col" width="17"><img src="images/info.gif" border="0" /></th><th scope="col" width="40%">Latest</th>
+			</tr><tr class="row">
+				<td>
+                14:00
+            </td><td>FT        </td><td>-</td><td>
+                &nbsp;
+            </td><td>
+                &nbsp;
+            </td><td>
+                &nbsp;
+            </td><td align="right">OMAN</td><td align="right">3</td><td align="left">1</td><td align="left">CHINA</td><td>
+                &nbsp;
+            </td><td>
+                &nbsp;
+            </td><td>
+                &nbsp;
+            </td><td>
+                <a class="poplink" href="javascript:void(0);" onmouseover="return overlib('<table border=0 cellpadding=2 cellspacing=0 width=250><tr align=left bgcolor=#ffffff><td><img src=\'images/info.gif\' /><b>Match information</b></td></tr><tr><td>Knock out.</td></tr></table>',HAUTO,VAUTO,WIDTH,250);" onmouseout="return nd();"><img src="images/info.gif" border="0" /></a>
+            </td><td align="left">
+                <a class="poplink" href="javascript:void(0);" onmouseover="return overlib('<table><tr valign=top><td width=200><table border=1 cellspacing=0 cellpadding=2><tr valign=top><td width=20>Min</td><td width=20>&nbsp;</td><td width=120>Player</td></tr><tr><td>47</td><td><img align=\'top\' width=\'17\' height=\'16\' border=\'0\' src=\'images/ball.gif\' alt=\'goal\'></td><td nowrap=nowrap>BASHEER</td></tr><tr><td>74</td><td><img align=\'top\' width=\'17\' height=\'16\' border=\'0\' src=\'images/ball.gif\' alt=\'goal\'></td><td nowrap=nowrap>SALEH</td></tr><tr><td>84</td><td><img align=\'top\' width=\'17\' height=\'16\' border=\'0\' src=\'images/ball.gif\' alt=\'goal\'></td><td nowrap=nowrap>SALEH</td></tr></table></td><td width=200><table border=1 cellspacing=0 cellpadding=2><tr><td width=20>Min</td><td width=20>&nbsp;</td><td width=120>Player</td></tr><tr><td>53</td><td><img align=\'top\' width=\'17\' height=\'16\' border=\'0\' src=\'images/ball.gif\' alt=\'goal\'></td><td nowrap=nowrap>BO</td></tr></table></td></tr></table>',HAUTO,VAUTO,WIDTH,400);" onmouseout="return nd();">84<img align="top" width="17" height="16" border="0" src="images/ball.gif" alt="goal">SALEH</a>
+            </td>
+			</tr><tr class="row_alt">
+				<td>
+                16:30
+            </td><td>FT        </td><td>-</td><td>
+                &nbsp;
+            </td><td>
+                &nbsp;
+            </td><td>
+                &nbsp;
+            </td><td align="right">ECUADOR</td><td align="right">1</td><td align="left">0</td><td align="left">IRAN</td><td bgcolor="Red">
+                1
+            </td><td>
+                &nbsp;
+            </td><td>
+                &nbsp;
+            </td><td>
+                <a class="poplink" href="javascript:void(0);" onmouseover="return overlib('<table border=0 cellpadding=2 cellspacing=0 width=250><tr align=left bgcolor=#ffffff><td><img src=\'images/info.gif\' /><b>Match information</b></td></tr><tr><td>Knock out.</td></tr></table>',HAUTO,VAUTO,WIDTH,250);" onmouseout="return nd();"><img src="images/info.gif" border="0" /></a>
+            </td><td align="left">
+                <a class="poplink" href="javascript:void(0);" onmouseover="return overlib('<table><tr valign=top><td width=200><table border=1 cellspacing=0 cellpadding=2><tr valign=top><td width=20>Min</td><td width=20>&nbsp;</td><td width=120>Player</td></tr><tr><td>55</td><td><img align=\'top\' width=\'17\' height=\'16\' border=\'0\' src=\'images/ball.gif\' alt=\'goal\'></td><td nowrap=nowrap>MARTINEZ</td></tr></table></td><td width=200><table border=1 cellspacing=0 cellpadding=2><tr><td width=20>Min</td><td width=20>&nbsp;</td><td width=120>Player</td></tr><tr><td>90</td><td><img align=\'top\' width=\'17\' height=\'16\' border=\'0\' src=\'images/redcard.gif\' alt=\'red card\'></td><td nowrap=nowrap>NEJAD</td></tr></table></td></tr></table>',HAUTO,VAUTO,WIDTH,400);" onmouseout="return nd();">90<img align="top" width="17" height="16" border="0" src="images/redcard.gif" alt="red card">NEJAD</a>
+            </td>
+			</tr>
+		</table>
+	</div>
+
+        </td>
+    </tr>
+</table>
+
+<br />
+
+    
+        
+<table border="1" cellpadding="0" cellspacing="0" width="100%">
+    <tr>
+        <td style="text-align: left" class="header">
+            <span id="ctl00_ContentPlaceHolder1_Repeater1_ctl04_CompGames1_lblCompName">&nbsp;ITALY - FA CUP - ROUND 16</span></td>
+    </tr>
+    <tr>
+        <td>
+<div>
+		<table cellspacing="0" cellpadding="2" rules="all" border="1" id="ctl00_ContentPlaceHolder1_Repeater1_ctl04_CompGames1_GridView1" width="100%">
+			<tr class="header" align="left">
+				<th scope="col">Start</th><th scope="col">Stat</th><th scope="col">Min</th><th align="center" scope="col" width="17">R</th><th align="center" scope="col" width="17">P</th><th align="center" scope="col" width="17">O</th><th align="right" scope="col" width="30%">Home</th><th align="right" scope="col" width="10">   </th><th align="left" scope="col" width="10">   </th><th align="left" scope="col" width="30%">Away</th><th align="center" scope="col" width="17">R</th><th align="center" scope="col" width="17">P</th><th align="center" scope="col" width="17">O</th><th align="center" scope="col" width="17"><img src="images/info.gif" border="0" /></th><th scope="col" width="40%">Latest</th>
+			</tr><tr class="row">
+				<td>
+                16:00
+            </td><td>FT        </td><td>-</td><td>
+                &nbsp;
+            </td><td>
+                &nbsp;
+            </td><td>
+                &nbsp;
+            </td><td align="right">FIORENTINA</td><td align="right">0</td><td align="left">1</td><td align="left">TORINO</td><td>
+                &nbsp;
+            </td><td>
+                &nbsp;
+            </td><td>
+                &nbsp;
+            </td><td>
+                <a class="poplink" href="javascript:void(0);" onmouseover="return overlib('<table border=0 cellpadding=2 cellspacing=0 width=250><tr align=left bgcolor=#ffffff><td><img src=\'images/info.gif\' /><b>Match information</b></td></tr><tr><td>Knock out.</td></tr></table>',HAUTO,VAUTO,WIDTH,250);" onmouseout="return nd();"><img src="images/info.gif" border="0" /></a>
+            </td><td align="left">
+                <a class="poplink" href="javascript:void(0);" onmouseover="return overlib('<table><tr valign=top><td width=200><table border=1 cellspacing=0 cellpadding=2><tr valign=top><td width=20>Min</td><td width=20>&nbsp;</td><td width=120>Player</td></tr></table></td><td width=200><table border=1 cellspacing=0 cellpadding=2><tr><td width=20>Min</td><td width=20>&nbsp;</td><td width=120>Player</td></tr><tr><td>19</td><td><img align=\'top\' width=\'17\' height=\'16\' border=\'0\' src=\'images/ball.gif\' alt=\'goal\'></td><td nowrap=nowrap>BIANCHI</td></tr></table></td></tr></table>',HAUTO,VAUTO,WIDTH,400);" onmouseout="return nd();">19<img align="top" width="17" height="16" border="0" src="images/ball.gif" alt="goal">BIANCHI</a>
+            </td>
+			</tr><tr class="row_alt">
+				<td>
+                20:00
+            </td><td>FT        </td><td>-</td><td>
+                &nbsp;
+            </td><td>
+                &nbsp;
+            </td><td>
+                &nbsp;
+            </td><td align="right">ROMA</td><td align="right">2</td><td align="left">0</td><td align="left">BOLOGNA</td><td>
+                &nbsp;
+            </td><td>
+                &nbsp;
+            </td><td>
+                &nbsp;
+            </td><td>
+                <a class="poplink" href="javascript:void(0);" onmouseover="return overlib('<table border=0 cellpadding=2 cellspacing=0 width=250><tr align=left bgcolor=#ffffff><td><img src=\'images/info.gif\' /><b>Match information</b></td></tr><tr><td>Knock out.</td></tr></table>',HAUTO,VAUTO,WIDTH,250);" onmouseout="return nd();"><img src="images/info.gif" border="0" /></a>
+            </td><td align="left">
+                <a class="poplink" href="javascript:void(0);" onmouseover="return overlib('<table><tr valign=top><td width=200><table border=1 cellspacing=0 cellpadding=2><tr valign=top><td width=20>Min</td><td width=20>&nbsp;</td><td width=120>Player</td></tr><tr><td>82</td><td><img align=\'top\' width=\'17\' height=\'16\' border=\'0\' src=\'images/ball.gif\' alt=\'goal\'></td><td nowrap=nowrap>VUCINIC</td></tr><tr><td>86</td><td><img align=\'top\' width=\'17\' height=\'16\' border=\'0\' src=\'images/ball.gif\' alt=\'goal\'></td><td nowrap=nowrap>VUCINIC</td></tr></table></td><td width=200><table border=1 cellspacing=0 cellpadding=2><tr><td width=20>Min</td><td width=20>&nbsp;</td><td width=120>Player</td></tr></table></td></tr></table>',HAUTO,VAUTO,WIDTH,400);" onmouseout="return nd();">86<img align="top" width="17" height="16" border="0" src="images/ball.gif" alt="goal">VUCINIC</a>
+            </td>
+			</tr>
+		</table>
+	</div>
+
+        </td>
+    </tr>
+</table>
+
+<br />
+
+    
+        
+<table border="1" cellpadding="0" cellspacing="0" width="100%">
+    <tr>
+        <td style="text-align: left" class="header">
+            <span id="ctl00_ContentPlaceHolder1_Repeater1_ctl05_CompGames1_lblCompName">&nbsp;ITALY - SERIE C1A</span></td>
+    </tr>
+    <tr>
+        <td>
+<div>
+		<table cellspacing="0" cellpadding="2" rules="all" border="1" id="ctl00_ContentPlaceHolder1_Repeater1_ctl05_CompGames1_GridView1" width="100%">
+			<tr class="header" align="left">
+				<th scope="col">Start</th><th scope="col">Stat</th><th scope="col">Min</th><th align="center" scope="col" width="17">R</th><th align="center" scope="col" width="17">P</th><th align="center" scope="col" width="17">O</th><th align="right" scope="col" width="30%">Home</th><th align="right" scope="col" width="10">   </th><th align="left" scope="col" width="10">   </th><th align="left" scope="col" width="30%">Away</th><th align="center" scope="col" width="17">R</th><th align="center" scope="col" width="17">P</th><th align="center" scope="col" width="17">O</th><th align="center" scope="col" width="17"><img src="images/info.gif" border="0" /></th><th scope="col" width="40%">Latest</th>
+			</tr><tr class="row">
+				<td>
+                13:30
+            </td><td>FT        </td><td>-</td><td>
+                &nbsp;
+            </td><td>
+                &nbsp;
+            </td><td>
+                &nbsp;
+            </td><td align="right">PRO SESTO</td><td align="right">0</td><td align="left">0</td><td align="left">LECCO</td><td>
+                &nbsp;
+            </td><td>
+                &nbsp;
+            </td><td>
+                &nbsp;
+            </td><td>
+                &nbsp;
+            </td><td align="left">
+                &nbsp;
+            </td>
+			</tr>
+		</table>
+	</div>
+
+        </td>
+    </tr>
+</table>
+
+<br />
+
+    
+        
+<table border="1" cellpadding="0" cellspacing="0" width="100%">
+    <tr>
+        <td style="text-align: left" class="header">
+            <span id="ctl00_ContentPlaceHolder1_Repeater1_ctl06_CompGames1_lblCompName">&nbsp;ITALY - SERIE C2A</span></td>
+    </tr>
+    <tr>
+        <td>
+<div>
+		<table cellspacing="0" cellpadding="2" rules="all" border="1" id="ctl00_ContentPlaceHolder1_Repeater1_ctl06_CompGames1_GridView1" width="100%">
+			<tr class="header" align="left">
+				<th scope="col">Start</th><th scope="col">Stat</th><th scope="col">Min</th><th align="center" scope="col" width="17">R</th><th align="center" scope="col" width="17">P</th><th align="center" scope="col" width="17">O</th><th align="right" scope="col" width="30%">Home</th><th align="right" scope="col" width="10">   </th><th align="left" scope="col" width="10">   </th><th align="left" scope="col" width="30%">Away</th><th align="center" scope="col" width="17">R</th><th align="center" scope="col" width="17">P</th><th align="center" scope="col" width="17">O</th><th align="center" scope="col" width="17"><img src="images/info.gif" border="0" /></th><th scope="col" width="40%">Latest</th>
+			</tr><tr class="row">
+				<td>
+                13:30
+            </td><td>FT        </td><td>-</td><td>
+                &nbsp;
+            </td><td>
+                &nbsp;
+            </td><td>
+                &nbsp;
+            </td><td align="right">MEZZOCORONA</td><td align="right">1</td><td align="left">3</td><td align="left">SAMBONIFACESE</td><td>
+                &nbsp;
+            </td><td>
+                &nbsp;
+            </td><td>
+                &nbsp;
+            </td><td>
+                &nbsp;
+            </td><td align="left">
+                <a class="poplink" href="javascript:void(0);" onmouseover="return overlib('<table><tr valign=top><td width=200><table border=1 cellspacing=0 cellpadding=2><tr valign=top><td width=20>Min</td><td width=20>&nbsp;</td><td width=120>Player</td></tr><tr><td>55</td><td><img align=\'top\' width=\'17\' height=\'16\' border=\'0\' src=\'images/ball.gif\' alt=\'goal\'></td><td nowrap=nowrap>&nbsp;</td></tr></table></td><td width=200><table border=1 cellspacing=0 cellpadding=2><tr><td width=20>Min</td><td width=20>&nbsp;</td><td width=120>Player</td></tr><tr><td>48</td><td><img align=\'top\' width=\'17\' height=\'16\' border=\'0\' src=\'images/ball.gif\' alt=\'goal\'></td><td nowrap=nowrap>&nbsp;</td></tr><tr><td>66</td><td><img align=\'top\' width=\'17\' height=\'16\' border=\'0\' src=\'images/ball.gif\' alt=\'goal\'></td><td nowrap=nowrap>&nbsp;</td></tr><tr><td>74</td><td><img align=\'top\' width=\'17\' height=\'16\' border=\'0\' src=\'images/ball.gif\' alt=\'goal\'></td><td nowrap=nowrap>&nbsp;</td></tr></table></td></tr></table>',HAUTO,VAUTO,WIDTH,400);" onmouseout="return nd();">74<img align="top" width="17" height="16" border="0" src="images/ball.gif" alt="goal">&nbsp;</a>
+            </td>
+			</tr>
+		</table>
+	</div>
+
+        </td>
+    </tr>
+</table>
+
+<br />
+
+    
+        
+<table border="1" cellpadding="0" cellspacing="0" width="100%">
+    <tr>
+        <td style="text-align: left" class="header">
+            <span id="ctl00_ContentPlaceHolder1_Repeater1_ctl07_CompGames1_lblCompName">&nbsp;SCOTLAND - FA CUP - THIRD ROUND</span></td>
+    </tr>
+    <tr>
+        <td>
+<div>
+		<table cellspacing="0" cellpadding="2" rules="all" border="1" id="ctl00_ContentPlaceHolder1_Repeater1_ctl07_CompGames1_GridView1" width="100%">
+			<tr class="header" align="left">
+				<th scope="col">Start</th><th scope="col">Stat</th><th scope="col">Min</th><th align="center" scope="col" width="17">R</th><th align="center" scope="col" width="17">P</th><th align="center" scope="col" width="17">O</th><th align="right" scope="col" width="30%">Home</th><th align="right" scope="col" width="10">   </th><th align="left" scope="col" width="10">   </th><th align="left" scope="col" width="30%">Away</th><th align="center" scope="col" width="17">R</th><th align="center" scope="col" width="17">P</th><th align="center" scope="col" width="17">O</th><th align="center" scope="col" width="17"><img src="images/info.gif" border="0" /></th><th scope="col" width="40%">Latest</th>
+			</tr><tr class="row">
+				<td>
+                13:30
+            </td><td>FT        </td><td>-</td><td>
+                &nbsp;
+            </td><td>
+                &nbsp;
+            </td><td>
+                &nbsp;
+            </td><td align="right">LOCHEE UTD</td><td align="right">1</td><td align="left">1</td><td align="left">AYR UTD</td><td>
+                &nbsp;
+            </td><td>
+                &nbsp;
+            </td><td>
+                &nbsp;
+            </td><td>
+                <a class="poplink" href="javascript:void(0);" onmouseover="return overlib('<table border=0 cellpadding=2 cellspacing=0 width=250><tr align=left bgcolor=#ffffff><td><img src=\'images/info.gif\' /><b>Match information</b></td></tr><tr><td>Replayed if draw.</td></tr></table>',HAUTO,VAUTO,WIDTH,250);" onmouseout="return nd();"><img src="images/info.gif" border="0" /></a>
+            </td><td align="left">
+                <a class="poplink" href="javascript:void(0);" onmouseover="return overlib('<table><tr valign=top><td width=200><table border=1 cellspacing=0 cellpadding=2><tr valign=top><td width=20>Min</td><td width=20>&nbsp;</td><td width=120>Player</td></tr><tr><td>86</td><td><img align=\'top\' width=\'17\' height=\'16\' border=\'0\' src=\'images/ball.gif\' alt=\'goal\'></td><td nowrap=nowrap>HAGAN</td></tr></table></td><td width=200><table border=1 cellspacing=0 cellpadding=2><tr><td width=20>Min</td><td width=20>&nbsp;</td><td width=120>Player</td></tr><tr><td>60</td><td><img align=\'top\' width=\'17\' height=\'16\' border=\'0\' src=\'images/ball.gif\' alt=\'goal\'></td><td nowrap=nowrap>WILLIAMS</td></tr></table></td></tr></table>',HAUTO,VAUTO,WIDTH,400);" onmouseout="return nd();">86<img align="top" width="17" height="16" border="0" src="images/ball.gif" alt="goal">HAGAN</a>
+            </td>
+			</tr>
+		</table>
+	</div>
+
+        </td>
+    </tr>
+</table>
+
+<br />
+
+    
+        
+<table border="1" cellpadding="0" cellspacing="0" width="100%">
+    <tr>
+        <td style="text-align: left" class="header">
+            <span id="ctl00_ContentPlaceHolder1_Repeater1_ctl08_CompGames1_lblCompName">&nbsp;WORLD (FIFA) - FIFA CLUB WORLD CHAMPIONSHIP - SEMI</span></td>
+    </tr>
+    <tr>
+        <td>
+<div>
+		<table cellspacing="0" cellpadding="2" rules="all" border="1" id="ctl00_ContentPlaceHolder1_Repeater1_ctl08_CompGames1_GridView1" width="100%">
+			<tr class="header" align="left">
+				<th scope="col">Start</th><th scope="col">Stat</th><th scope="col">Min</th><th align="center" scope="col" width="17">R</th><th align="center" scope="col" width="17">P</th><th align="center" scope="col" width="17">O</th><th align="right" scope="col" width="30%">Home</th><th align="right" scope="col" width="10">   </th><th align="left" scope="col" width="10">   </th><th align="left" scope="col" width="30%">Away</th><th align="center" scope="col" width="17">R</th><th align="center" scope="col" width="17">P</th><th align="center" scope="col" width="17">O</th><th align="center" scope="col" width="17"><img src="images/info.gif" border="0" /></th><th scope="col" width="40%">Latest</th>
+			</tr><tr class="row">
+				<td>
+                10:30
+            </td><td>FT        </td><td>-</td><td>
+                &nbsp;
+            </td><td>
+                &nbsp;
+            </td><td>
+                &nbsp;
+            </td><td align="right">PACHUCA (MEX)</td><td align="right">0</td><td align="left">2</td><td align="left">LIGA D.U. QUITO(ECU)</td><td>
+                &nbsp;
+            </td><td>
+                &nbsp;
+            </td><td>
+                &nbsp;
+            </td><td>
+                <a class="poplink" href="javascript:void(0);" onmouseover="return overlib('<table border=0 cellpadding=2 cellspacing=0 width=250><tr align=left bgcolor=#ffffff><td><img src=\'images/info.gif\' /><b>Match information</b></td></tr><tr><td>Playing at Tokyo, Japan. Knock out.</td></tr></table>',HAUTO,VAUTO,WIDTH,250);" onmouseout="return nd();"><img src="images/info.gif" border="0" /></a>
+            </td><td align="left">
+                <a class="poplink" href="javascript:void(0);" onmouseover="return overlib('<table><tr valign=top><td width=200><table border=1 cellspacing=0 cellpadding=2><tr valign=top><td width=20>Min</td><td width=20>&nbsp;</td><td width=120>Player</td></tr></table></td><td width=200><table border=1 cellspacing=0 cellpadding=2><tr><td width=20>Min</td><td width=20>&nbsp;</td><td width=120>Player</td></tr><tr><td>4</td><td><img align=\'top\' width=\'17\' height=\'16\' border=\'0\' src=\'images/ball.gif\' alt=\'goal\'></td><td nowrap=nowrap>BIELER</td></tr><tr><td>26</td><td><img align=\'top\' width=\'17\' height=\'16\' border=\'0\' src=\'images/ball.gif\' alt=\'goal\'></td><td nowrap=nowrap>BOLANOS</td></tr></table></td></tr></table>',HAUTO,VAUTO,WIDTH,400);" onmouseout="return nd();">26<img align="top" width="17" height="16" border="0" src="images/ball.gif" alt="goal">BOLANOS</a>
+            </td>
+			</tr>
+		</table>
+	</div>
+
+        </td>
+    </tr>
+</table>
+
+<br />
+
+    
+
+        
+</div>
+        <table border="0" cellpadding="5" cellspacing="0" style="width: 100%; height: 100%">
+            <tr class="newslinkspace">
+                <td style="width: 100%">
+                    View complete <a href="ResultsArchive.aspx" class="newslink">archive of FootballScoresLive.com Match Results</a>
+                </td>
+            </tr>
+        </table>
+
+        </td>
+		<td width="125" align="right" valign="top">
+	<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="120" height="600">
+      <param name="movie" value="http://www.footballscoreslive.com/images/fslSMSNew.swf" />
+      <param name="quality" value="high" />
+      <embed src="http://www.footballscoreslive.com/images/fslSMSNew.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="120" height="600"></embed>
+	</object>
+<script type="text/javascript"><!--
+google_ad_client = "pub-1398285862595543";
+google_ad_width = 120;
+google_ad_height = 600;
+google_ad_format = "120x600_as";
+google_ad_type = "text_image";
+google_ad_channel ="";
+google_color_border = "336699";
+google_color_bg = "FFFFFF";
+google_color_link = "0000FF";
+google_color_text = "000000";
+google_color_url = "008000";
+//--></script>
+<script type="text/javascript"
+  src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
+</script>
+</td>
+	</tr>
+	<tr>
+		<td>
+			<img src="images/spacer.gif" width="174" height="1" alt="" /></td>
+		<td>
+			<img src="images/spacer.gif" width="220" height="1" alt="" /></td>
+		<td>
+			<img src="images/spacer.gif" width="281" height="1" alt="" /></td>
+		<td>
+			<img src="images/spacer.gif" width="125" height="1" alt="" /></td>
+	</tr>
+	<tr>
+		<td height="16" colspan="4" bgcolor="#000000">
+		    &nbsp;|&nbsp;
+		    <a class="navlink" href="disclaimer.aspx">Disclaimer</a>&nbsp;|&nbsp;
+            <a class="navlink" href="privacy.aspx">Privacy</a>&nbsp;|&nbsp;
+		    <a href="aboutus.aspx" class="navlink">About Us</a>&nbsp;|&nbsp;
+		    <a href="NewsArchive.aspx" class="navlink">News Archive</a>&nbsp;|&nbsp;
+		</td>
+	</tr>
+</table>
+    
+    </div>
+    
+<input type="hidden" name="__PREVIOUSPAGE" id="__PREVIOUSPAGE" value="Xh65BZM36Ruds-iXM2l7LB-dXtc__8RpYzxQLE4V_YQ1" />
+<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="2ybQ+H9cPYUzPPi/5ComPVhU+jAYPdxVR+fOu2ZZbs2RxuAweOrbEg/qP5f+1OYLQI+oQJb98YQDTTMw+x86m7Np3/NYQHDjzX76RjJfW9nS6SnJVUi1nLHSh9c7wgfVB7UNjywCsU0hiMY1IUsYkR/rClTQE4j3Q4a4ub3Cqrn+b7fY3itatSObxb3L0Pq9E9vx/RpYI3jhA2RPCnO1WEQF2kEBAba5qqLwESWolSSdLqs5DRta8kholg0zw5EA5/R9+XiPqWwbk4n/TnTtdMwQq2iExD4eyjsLsE7bWnw=" />
+<script type="text/xml-script">
+<page xmlns:script="http://schemas.microsoft.com/xml-script/2005">
+  <components>
+    <pageRequestManager id="_PageRequestManager" updatePanelIDs="ctl00$ContentPlaceHolder1$UpdatePanel1" asyncPostbackControlIDs="ctl00_ContentPlaceHolder1_DropDownList1" scriptManagerID="ctl00$ContentPlaceHolder1$ScriptManager1" form="aspnetForm" />
+  </components>
+</page></script>
+<script type="text/javascript">
+</script>
+</form>
+</body>
+</html>

+ 144 - 0
vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/app/index.php

@@ -0,0 +1,144 @@
+<?php
+error_reporting(E_ALL);
+include_once('../simple_html_dom.php');
+
+$html = file_get_html('google.htm');
+//$html = file_get_html('youtube.htm');
+//$html = file_get_html('Product.ibatis.xml');
+
+
+$lang = '';
+$l=$html->find('html', 0);
+if ($l!==null)
+    $lang = $l->lang;
+if ($lang!='')
+    $lang = 'lang="'.$lang.'"';
+
+$charset = $html->find('meta[http-equiv*=content-type]', 0);
+$target = array();
+$query = '';
+
+if (isset($_REQUEST['query'])) {
+    $query = $_REQUEST['query'];
+    $target = $html->find($query);
+}
+
+function stat_dom($dom) {
+    $count_text = 0;
+    $count_comm = 0;
+    $count_elem = 0;
+    $count_tag_end = 0;
+    $count_unknown = 0;
+    
+    foreach($dom->nodes as $n) {
+        if ($n->nodetype==HDOM_TYPE_TEXT)
+            ++$count_text;
+        if ($n->nodetype==HDOM_TYPE_COMMENT)
+            ++$count_comm;
+        if ($n->nodetype==HDOM_TYPE_ELEMENT)
+            ++$count_elem;
+        if ($n->nodetype==HDOM_TYPE_ENDTAG)
+            ++$count_tag_end;
+        if ($n->nodetype==HDOM_TYPE_UNKNOWN)
+            ++$count_unknown;
+    }
+    
+    echo 'Total: '. count($dom->nodes).
+        ', Text: '.$count_text.
+        ', Commnet: '.$count_comm.
+        ', Tag: '.$count_elem.
+        ', End Tag: '.$count_tag_end.
+        ', Unknown: '.$count_unknown;
+}
+
+function dump_my_html_tree($node, $show_attr=true, $deep=0, $last=true) {
+    $count = count($node->nodes);
+    if ($count>0) {
+        if($last)
+            echo '<li class="expandable lastExpandable"><div class="hitarea expandable-hitarea lastExpandable-hitarea"></div>&lt;<span class="tag">'.htmlspecialchars($node->tag).'</span>';
+        else
+            echo '<li class="expandable"><div class="hitarea expandable-hitarea"></div>&lt;<span class="tag">'.htmlspecialchars($node->tag).'</span>';
+    }
+    else {
+        $laststr = ($last===false) ? '' : ' class="last"';
+        echo '<li'.$laststr.'>&lt;<span class="tag">'.htmlspecialchars($node->tag).'</span>';
+    }
+
+    if ($show_attr) {
+        foreach($node->attr as $k=>$v) {
+            echo ' '.htmlspecialchars($k).'="<span class="attr">'.htmlspecialchars($node->$k).'</span>"';
+        }
+    }
+    echo '&gt;';
+    
+    if ($node->tag==='text' || $node->tag==='comment') {
+        echo htmlspecialchars($node->innertext);
+        return;
+    }
+
+    if ($count>0) echo "\n<ul style=\"display: none;\">\n";
+    $i=0;
+    foreach($node->nodes as $c) {
+        $last = (++$i==$count) ? true : false;
+        dump_my_html_tree($c, $show_attr, $deep+1, $last);
+    }
+    if ($count>0)
+        echo "</ul>\n";
+
+    //if ($count>0) echo '&lt;/<span class="attr">'.htmlspecialchars($node->tag).'</span>&gt;';
+    echo "</li>\n";
+}
+?>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+
+<html <?=$lang?>>
+<head>
+    <?
+        if ($lang!='')
+            echo '<meta http-equiv="content-type" content="text/html; charset=utf-8"/>';
+        else if ($charset)
+            echo $charset;
+        else 
+            echo '<meta http-equiv="content-type" content="text/html; charset=iso-8859-1"/>';
+    ?>
+	<title>Simple HTML DOM Query Test</title>
+	<link rel="stylesheet" href="js/jquery.treeview.css" />
+	<link rel="stylesheet" href="js/screen.css" />
+	<style>
+        .tag { color: blue; }
+        .attr { color: #990033; }
+    </style>
+	<script src="js/jquery.js" type="text/javascript"></script>
+	<script src="js/jquery.treeview.js" type="text/javascript"></script>
+	<script type="text/javascript">
+    $(document).ready(function(){	
+        $("#html_tree").treeview({
+            control:"#sidetreecontrol",
+            collapsed: true,
+            prerendered: true
+        });
+	});
+    </script>
+	</head>
+	<body>
+	<div id="main">
+	<h4>Simple HTML DOM Test</h4>
+    <form name="form1" method="post" action="">
+        find: <input name="query" type="text" size="60" maxlength="60" value="<?=htmlspecialchars($query)?>">
+        <input type="submit" name="Submit" value="Go">
+    </form>
+    <br>
+	HTML STAT (<?stat_dom($html);?>)<br>
+    <br>
+	<div id="sidetreecontrol"><a href="?#">Collapse All</a> | <a href="?#">Expand All</a></div><br>
+	<ul class="treeview" id="html_tree">
+	    <?
+            ob_start();
+            foreach($target as $e)
+                dump_my_html_tree($e, true);
+            ob_end_flush();
+        ?>
+	</ul>
+</div>
+ 
+</body></html>

BIN
vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/app/js/images/treeview-default-line.gif


BIN
vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/app/js/images/treeview-default.gif


+ 3363 - 0
vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/app/js/jquery.js

@@ -0,0 +1,3363 @@
+(function(){
+/*
+ * jQuery 1.2.2b2 - New Wave Javascript
+ *
+ * Copyright (c) 2007 John Resig (jquery.com)
+ * Dual licensed under the MIT (MIT-LICENSE.txt)
+ * and GPL (GPL-LICENSE.txt) licenses.
+ *
+ * $Date: 2007-12-20 14:36:56 +0100 (Don, 20 Dez 2007) $
+ * $Rev: 4251 $
+ */
+
+// Map over jQuery in case of overwrite
+if ( window.jQuery )
+	var _jQuery = window.jQuery;
+
+var jQuery = window.jQuery = function( selector, context ) {
+	// The jQuery object is actually just the init constructor 'enhanced'
+	return new jQuery.prototype.init( selector, context );
+};
+
+// Map over the $ in case of overwrite
+if ( window.$ )
+	var _$ = window.$;
+	
+// Map the jQuery namespace to the '$' one
+window.$ = jQuery;
+
+// A simple way to check for HTML strings or ID strings
+// (both of which we optimize for)
+var quickExpr = /^[^<]*(<(.|\s)+>)[^>]*$|^#(\w+)$/;
+
+// Is it a simple selector
+var isSimple = /^.[^:#\[\.]*$/;
+
+jQuery.fn = jQuery.prototype = {
+	init: function( selector, context ) {
+		// Make sure that a selection was provided
+		selector = selector || document;
+
+		// Handle $(DOMElement)
+		if ( selector.nodeType ) {
+			this[0] = selector;
+			this.length = 1;
+			return this;
+
+		// Handle HTML strings
+		} else if ( typeof selector == "string" ) {
+			// Are we dealing with HTML string or an ID?
+			var match = quickExpr.exec( selector );
+
+			// Verify a match, and that no context was specified for #id
+			if ( match && (match[1] || !context) ) {
+
+				// HANDLE: $(html) -> $(array)
+				if ( match[1] )
+					selector = jQuery.clean( [ match[1] ], context );
+
+				// HANDLE: $("#id")
+				else {
+					var elem = document.getElementById( match[3] );
+
+					// Make sure an element was located
+					if ( elem )
+						// Handle the case where IE and Opera return items
+						// by name instead of ID
+						if ( elem.id != match[3] )
+							return jQuery().find( selector );
+
+						// Otherwise, we inject the element directly into the jQuery object
+						else {
+							this[0] = elem;
+							this.length = 1;
+							return this;
+						}
+
+					else
+						selector = [];
+				}
+
+			// HANDLE: $(expr, [context])
+			// (which is just equivalent to: $(content).find(expr)
+			} else
+				return new jQuery( context ).find( selector );
+
+		// HANDLE: $(function)
+		// Shortcut for document ready
+		} else if ( jQuery.isFunction( selector ) )
+			return new jQuery( document )[ jQuery.fn.ready ? "ready" : "load" ]( selector );
+
+		return this.setArray(
+			// HANDLE: $(array)
+			selector.constructor == Array && selector ||
+
+			// HANDLE: $(arraylike)
+			// Watch for when an array-like object, contains DOM nodes, is passed in as the selector
+			(selector.jquery || selector.length && selector != window && !selector.nodeType && selector[0] != undefined && selector[0].nodeType) && jQuery.makeArray( selector ) ||
+
+			// HANDLE: $(*)
+			[ selector ] );
+	},
+	
+	// The current version of jQuery being used
+	jquery: "@VERSION",
+
+	// The number of elements contained in the matched element set
+	size: function() {
+		return this.length;
+	},
+	
+	// The number of elements contained in the matched element set
+	length: 0,
+
+	// Get the Nth element in the matched element set OR
+	// Get the whole matched element set as a clean array
+	get: function( num ) {
+		return num == undefined ?
+
+			// Return a 'clean' array
+			jQuery.makeArray( this ) :
+
+			// Return just the object
+			this[ num ];
+	},
+	
+	// Take an array of elements and push it onto the stack
+	// (returning the new matched element set)
+	pushStack: function( elems ) {
+		// Build a new jQuery matched element set
+		var ret = jQuery( elems );
+
+		// Add the old object onto the stack (as a reference)
+		ret.prevObject = this;
+
+		// Return the newly-formed element set
+		return ret;
+	},
+	
+	// Force the current matched set of elements to become
+	// the specified array of elements (destroying the stack in the process)
+	// You should use pushStack() in order to do this, but maintain the stack
+	setArray: function( elems ) {
+		// Resetting the length to 0, then using the native Array push
+		// is a super-fast way to populate an object with array-like properties
+		this.length = 0;
+		Array.prototype.push.apply( this, elems );
+		
+		return this;
+	},
+
+	// Execute a callback for every element in the matched set.
+	// (You can seed the arguments with an array of args, but this is
+	// only used internally.)
+	each: function( callback, args ) {
+		return jQuery.each( this, callback, args );
+	},
+
+	// Determine the position of an element within 
+	// the matched set of elements
+	index: function( elem ) {
+		var ret = -1;
+
+		// Locate the position of the desired element
+		this.each(function(i){
+			if ( this == elem )
+				ret = i;
+		});
+
+		return ret;
+	},
+
+	attr: function( name, value, type ) {
+		var options = name;
+		
+		// Look for the case where we're accessing a style value
+		if ( name.constructor == String )
+			if ( value == undefined )
+				return this.length && jQuery[ type || "attr" ]( this[0], name ) || undefined;
+
+			else {
+				options = {};
+				options[ name ] = value;
+			}
+		
+		// Check to see if we're setting style values
+		return this.each(function(i){
+			// Set all the styles
+			for ( name in options )
+				jQuery.attr(
+					type ?
+						this.style :
+						this,
+					name, jQuery.prop( this, options[ name ], type, i, name )
+				);
+		});
+	},
+
+	css: function( key, value ) {
+		// ignore negative width and height values
+		if ( (key == 'width' || key == 'height') && parseFloat(value) < 0 )
+			value = undefined;
+		return this.attr( key, value, "curCSS" );
+	},
+
+	text: function( text ) {
+		if ( typeof text != "object" && text != null )
+			return this.empty().append( (this[0] && this[0].ownerDocument || document).createTextNode( text ) );
+
+		var ret = "";
+
+		jQuery.each( text || this, function(){
+			jQuery.each( this.childNodes, function(){
+				if ( this.nodeType != 8 )
+					ret += this.nodeType != 1 ?
+						this.nodeValue :
+						jQuery.fn.text( [ this ] );
+			});
+		});
+
+		return ret;
+	},
+
+	wrapAll: function( html ) {
+		if ( this[0] )
+			// The elements to wrap the target around
+			jQuery( html, this[0].ownerDocument )
+				.clone()
+				.insertBefore( this[0] )
+				.map(function(){
+					var elem = this;
+
+					while ( elem.firstChild )
+						elem = elem.firstChild;
+
+					return elem;
+				})
+				.append(this);
+
+		return this;
+	},
+
+	wrapInner: function( html ) {
+		return this.each(function(){
+			jQuery( this ).contents().wrapAll( html );
+		});
+	},
+
+	wrap: function( html ) {
+		return this.each(function(){
+			jQuery( this ).wrapAll( html );
+		});
+	},
+
+	append: function() {
+		return this.domManip(arguments, true, false, function(elem){
+			if (this.nodeType == 1)
+				this.appendChild( elem );
+		});
+	},
+
+	prepend: function() {
+		return this.domManip(arguments, true, true, function(elem){
+			if (this.nodeType == 1)
+				this.insertBefore( elem, this.firstChild );
+		});
+	},
+	
+	before: function() {
+		return this.domManip(arguments, false, false, function(elem){
+			this.parentNode.insertBefore( elem, this );
+		});
+	},
+
+	after: function() {
+		return this.domManip(arguments, false, true, function(elem){
+			this.parentNode.insertBefore( elem, this.nextSibling );
+		});
+	},
+
+	end: function() {
+		return this.prevObject || jQuery( [] );
+	},
+
+	find: function( selector ) {
+		var elems = jQuery.map(this, function(elem){
+			return jQuery.find( selector, elem );
+		});
+
+		return this.pushStack( /[^+>] [^+>]/.test( selector ) || selector.indexOf("..") > -1 ?
+			jQuery.unique( elems ) :
+			elems );
+	},
+
+	clone: function( events ) {
+		// Do the clone
+		var ret = this.map(function(){
+			if ( jQuery.browser.msie && !jQuery.isXMLDoc(this) ) {
+				// IE copies events bound via attachEvent when
+				// using cloneNode. Calling detachEvent on the
+				// clone will also remove the events from the orignal
+				// In order to get around this, we use innerHTML.
+				// Unfortunately, this means some modifications to 
+				// attributes in IE that are actually only stored 
+				// as properties will not be copied (such as the
+				// the name attribute on an input).
+				var clone = this.cloneNode(true),
+					container = document.createElement("div"),
+					container2 = document.createElement("div");
+				container.appendChild(clone);
+				container2.innerHTML = container.innerHTML;
+				return container2.firstChild;
+			} else
+				return this.cloneNode(true);
+		});
+
+		// Need to set the expando to null on the cloned set if it exists
+		// removeData doesn't work here, IE removes it from the original as well
+		// this is primarily for IE but the data expando shouldn't be copied over in any browser
+		var clone = ret.find("*").andSelf().each(function(){
+			if ( this[ expando ] != undefined )
+				this[ expando ] = null;
+		});
+		
+		// Copy the events from the original to the clone
+		if ( events === true )
+			this.find("*").andSelf().each(function(i){
+				var events = jQuery.data( this, "events" );
+
+				for ( var type in events )
+					for ( var handler in events[ type ] )
+						jQuery.event.add( clone[ i ], type, events[ type ][ handler ], events[ type ][ handler ].data );
+			});
+
+		// Return the cloned set
+		return ret;
+	},
+
+	filter: function( selector ) {
+		return this.pushStack(
+			jQuery.isFunction( selector ) &&
+			jQuery.grep(this, function(elem, i){
+				return selector.call( elem, i );
+			}) ||
+
+			jQuery.multiFilter( selector, this ) );
+	},
+
+	not: function( selector ) {
+		if ( selector.constructor == String )
+			// test special case where just one selector is passed in
+			if ( isSimple.test( selector ) )
+				return this.pushStack( jQuery.multiFilter( selector, this, true ) );
+			else
+				selector = jQuery.multiFilter( selector, this );
+
+		var isArrayLike = selector.length && selector[selector.length - 1] !== undefined && !selector.nodeType;
+		return this.filter(function() {
+			return isArrayLike ? jQuery.inArray( this, selector ) < 0 : this != selector;
+		});
+	},
+
+	add: function( selector ) {
+		return !selector ? this : this.pushStack( jQuery.merge( 
+			this.get(),
+			selector.constructor == String ? 
+				jQuery( selector ).get() :
+				selector.length != undefined && (!selector.nodeName || jQuery.nodeName(selector, "form")) ?
+					selector : [selector] ) );
+	},
+
+	is: function( selector ) {
+		return selector ?
+			jQuery.multiFilter( selector, this ).length > 0 :
+			false;
+	},
+
+	hasClass: function( selector ) {
+		return this.is( "." + selector );
+	},
+	
+	val: function( value ) {
+		if ( value == undefined ) {
+
+			if ( this.length ) {
+				var elem = this[0];
+
+				// We need to handle select boxes special
+				if ( jQuery.nodeName( elem, "select" ) ) {
+					var index = elem.selectedIndex,
+						values = [],
+						options = elem.options,
+						one = elem.type == "select-one";
+					
+					// Nothing was selected
+					if ( index < 0 )
+						return null;
+
+					// Loop through all the selected options
+					for ( var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++ ) {
+						var option = options[ i ];
+
+						if ( option.selected ) {
+							// Get the specifc value for the option
+							value = jQuery.browser.msie && !option.attributes.value.specified ? option.text : option.value;
+							
+							// We don't need an array for one selects
+							if ( one )
+								return value;
+							
+							// Multi-Selects return an array
+							values.push( value );
+						}
+					}
+					
+					return values;
+					
+				// Everything else, we just grab the value
+				} else
+					return (this[0].value || "").replace(/\r/g, "");
+
+			}
+
+			return undefined;
+		}
+
+		return this.each(function(){
+			if ( this.nodeType != 1 )
+				return;
+
+			if ( value.constructor == Array && /radio|checkbox/.test( this.type ) )
+				this.checked = (jQuery.inArray(this.value, value) >= 0 ||
+					jQuery.inArray(this.name, value) >= 0);
+
+			else if ( jQuery.nodeName( this, "select" ) ) {
+				var values = value.constructor == Array ?
+					value :
+					[ value ];
+
+				jQuery( "option", this ).each(function(){
+					this.selected = (jQuery.inArray( this.value, values ) >= 0 ||
+						jQuery.inArray( this.text, values ) >= 0);
+				});
+
+				if ( !values.length )
+					this.selectedIndex = -1;
+
+			} else
+				this.value = value;
+		});
+	},
+	
+	html: function( value ) {
+		return value == undefined ?
+			(this.length ?
+				this[0].innerHTML :
+				null) :
+			this.empty().append( value );
+	},
+
+	replaceWith: function( value ) {
+		return this.after( value ).remove();
+	},
+
+	eq: function( i ) {
+		return this.slice( i, i + 1 );
+	},
+
+	slice: function() {
+		return this.pushStack( Array.prototype.slice.apply( this, arguments ) );
+	},
+
+	map: function( callback ) {
+		return this.pushStack( jQuery.map(this, function(elem, i){
+			return callback.call( elem, i, elem );
+		}));
+	},
+
+	andSelf: function() {
+		return this.add( this.prevObject );
+	},
+	
+	domManip: function( args, table, reverse, callback ) {
+		var clone = this.length > 1, elems; 
+
+		return this.each(function(){
+			if ( !elems ) {
+				elems = jQuery.clean( args, this.ownerDocument );
+
+				if ( reverse )
+					elems.reverse();
+			}
+
+			var obj = this;
+
+			if ( table && jQuery.nodeName( this, "table" ) && jQuery.nodeName( elems[0], "tr" ) )
+				obj = this.getElementsByTagName("tbody")[0] || this.appendChild( this.ownerDocument.createElement("tbody") );
+
+			var scripts = jQuery( [] );
+
+			jQuery.each(elems, function(){
+				var elem = clone ?
+					jQuery( this ).clone( true )[0] :
+					this;
+
+				// execute all scripts after the elements have been injected
+				if ( jQuery.nodeName( elem, "script" ) ) {
+					scripts = scripts.add( elem );
+				} else {
+					// Remove any inner scripts for later evaluation
+					if ( elem.nodeType == 1 )
+						scripts = scripts.add( jQuery( "script", elem ).remove() );
+
+					// Inject the elements into the document
+					callback.call( obj, elem );
+				}
+			});
+
+			scripts.each( evalScript );
+		});
+	}
+};
+
+// Give the init function the jQuery prototype for later instantiation
+jQuery.prototype.init.prototype = jQuery.prototype;
+
+function evalScript( i, elem ) {
+	if ( elem.src )
+		jQuery.ajax({
+			url: elem.src,
+			async: false,
+			dataType: "script"
+		});
+
+	else
+		jQuery.globalEval( elem.text || elem.textContent || elem.innerHTML || "" );
+
+	if ( elem.parentNode )
+		elem.parentNode.removeChild( elem );
+}
+
+jQuery.extend = jQuery.fn.extend = function() {
+	// copy reference to target object
+	var target = arguments[0] || {}, i = 1, length = arguments.length, deep = false, options;
+
+	// Handle a deep copy situation
+	if ( target.constructor == Boolean ) {
+		deep = target;
+		target = arguments[1] || {};
+		// skip the boolean and the target
+		i = 2;
+	}
+
+	// Handle case when target is a string or something (possible in deep copy)
+	if ( typeof target != "object" && typeof target != "function" )
+		target = {};
+
+	// extend jQuery itself if only one argument is passed
+	if ( length == 1 ) {
+		target = this;
+		i = 0;
+	}
+
+	for ( ; i < length; i++ )
+		// Only deal with non-null/undefined values
+		if ( (options = arguments[ i ]) != null )
+			// Extend the base object
+			for ( var name in options ) {
+				// Prevent never-ending loop
+				if ( target === options[ name ] )
+					continue;
+
+				// Recurse if we're merging object values
+				if ( deep && options[ name ] && typeof options[ name ] == "object" && target[ name ] && !options[ name ].nodeType )
+					target[ name ] = jQuery.extend( target[ name ], options[ name ] );
+
+				// Don't bring in undefined values
+				else if ( options[ name ] != undefined )
+					target[ name ] = options[ name ];
+
+			}
+
+	// Return the modified object
+	return target;
+};
+
+var expando = "jQuery" + (new Date()).getTime(), uuid = 0, windowData = {};
+
+// exclude the following css properties to add px
+var exclude = /z-?index|font-?weight|opacity|zoom|line-?height/i;
+
+jQuery.extend({
+	noConflict: function( deep ) {
+		window.$ = _$;
+
+		if ( deep )
+			window.jQuery = _jQuery;
+
+		return jQuery;
+	},
+
+	// This may seem like some crazy code, but trust me when I say that this
+	// is the only cross-browser way to do this. --John
+	isFunction: function( fn ) {
+		return !!fn && typeof fn != "string" && !fn.nodeName && 
+			fn.constructor != Array && /function/i.test( fn + "" );
+	},
+	
+	// check if an element is in a (or is an) XML document
+	isXMLDoc: function( elem ) {
+		return elem.documentElement && !elem.body ||
+			elem.tagName && elem.ownerDocument && !elem.ownerDocument.body;
+	},
+
+	// Evalulates a script in a global context
+	globalEval: function( data ) {
+		data = jQuery.trim( data );
+
+		if ( data ) {
+			// Inspired by code by Andrea Giammarchi
+			// http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom.html
+			var head = document.getElementsByTagName("head")[0] || document.documentElement,
+				script = document.createElement("script");
+
+			script.type = "text/javascript";
+			if ( jQuery.browser.msie )
+				script.text = data;
+			else
+				script.appendChild( document.createTextNode( data ) );
+
+			head.appendChild( script );
+			head.removeChild( script );
+		}
+	},
+
+	nodeName: function( elem, name ) {
+		return elem.nodeName && elem.nodeName.toUpperCase() == name.toUpperCase();
+	},
+	
+	cache: {},
+	
+	data: function( elem, name, data ) {
+		elem = elem == window ?
+			windowData :
+			elem;
+
+		var id = elem[ expando ];
+
+		// Compute a unique ID for the element
+		if ( !id ) 
+			id = elem[ expando ] = ++uuid;
+
+		// Only generate the data cache if we're
+		// trying to access or manipulate it
+		if ( name && !jQuery.cache[ id ] )
+			jQuery.cache[ id ] = {};
+		
+		// Prevent overriding the named cache with undefined values
+		if ( data != undefined )
+			jQuery.cache[ id ][ name ] = data;
+		
+		// Return the named cache data, or the ID for the element	
+		return name ?
+			jQuery.cache[ id ][ name ] :
+			id;
+	},
+	
+	removeData: function( elem, name ) {
+		elem = elem == window ?
+			windowData :
+			elem;
+
+		var id = elem[ expando ];
+
+		// If we want to remove a specific section of the element's data
+		if ( name ) {
+			if ( jQuery.cache[ id ] ) {
+				// Remove the section of cache data
+				delete jQuery.cache[ id ][ name ];
+
+				// If we've removed all the data, remove the element's cache
+				name = "";
+
+				for ( name in jQuery.cache[ id ] )
+					break;
+
+				if ( !name )
+					jQuery.removeData( elem );
+			}
+
+		// Otherwise, we want to remove all of the element's data
+		} else {
+			// Clean up the element expando
+			try {
+				delete elem[ expando ];
+			} catch(e){
+				// IE has trouble directly removing the expando
+				// but it's ok with using removeAttribute
+				if ( elem.removeAttribute )
+					elem.removeAttribute( expando );
+			}
+
+			// Completely remove the data cache
+			delete jQuery.cache[ id ];
+		}
+	},
+
+	// args is for internal usage only
+	each: function( object, callback, args ) {
+		if ( args ) {
+			if ( object.length == undefined )
+				for ( var name in object )
+					callback.apply( object[ name ], args );
+			else
+				for ( var i = 0, length = object.length; i < length; i++ )
+					if ( callback.apply( object[ i ], args ) === false )
+						break;
+
+		// A special, fast, case for the most common use of each
+		} else {
+			if ( object.length == undefined )
+				for ( var name in object )
+					callback.call( object[ name ], name, object[ name ] );
+			else
+				for ( var i = 0, length = object.length, value = object[0]; 
+					i < length && callback.call( value, i, value ) !== false; value = object[++i] ){}
+		}
+
+		return object;
+	},
+	
+	prop: function( elem, value, type, i, name ) {
+			// Handle executable functions
+			if ( jQuery.isFunction( value ) )
+				value = value.call( elem, i );
+				
+			// Handle passing in a number to a CSS property
+			return value && value.constructor == Number && type == "curCSS" && !exclude.test( name ) ?
+				value + "px" :
+				value;
+	},
+
+	className: {
+		// internal only, use addClass("class")
+		add: function( elem, classNames ) {
+			jQuery.each((classNames || "").split(/\s+/), function(i, className){
+				if ( elem.nodeType == 1 && !jQuery.className.has( elem.className, className ) )
+					elem.className += (elem.className ? " " : "") + className;
+			});
+		},
+
+		// internal only, use removeClass("class")
+		remove: function( elem, classNames ) {
+			if (elem.nodeType == 1)
+				elem.className = classNames != undefined ?
+					jQuery.grep(elem.className.split(/\s+/), function(className){
+						return !jQuery.className.has( classNames, className );	
+					}).join(" ") :
+					"";
+		},
+
+		// internal only, use is(".class")
+		has: function( elem, className ) {
+			return jQuery.inArray( className, (elem.className || elem).toString().split(/\s+/) ) > -1;
+		}
+	},
+
+	// A method for quickly swapping in/out CSS properties to get correct calculations
+	swap: function( elem, options, callback ) {
+		var old = {};
+		// Remember the old values, and insert the new ones
+		for ( var name in options ) {
+			old[ name ] = elem.style[ name ];
+			elem.style[ name ] = options[ name ];
+		}
+
+		callback.call( elem );
+
+		// Revert the old values
+		for ( var name in options )
+			elem.style[ name ] = old[ name ];
+	},
+
+	css: function( elem, name, force ) {
+		if ( name == "width" || name == "height" ) {
+			var val, props = { position: "absolute", visibility: "hidden", display:"block" }, which = name == "width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ];
+		
+			function getWH() {
+				val = name == "width" ? elem.offsetWidth : elem.offsetHeight;
+				var padding = 0, border = 0;
+				jQuery.each( which, function() {
+					padding += parseFloat(jQuery.curCSS( elem, "padding" + this, true)) || 0;
+					border += parseFloat(jQuery.curCSS( elem, "border" + this + "Width", true)) || 0;
+				});
+				val -= Math.round(padding + border);
+			}
+		
+			if ( jQuery(elem).is(":visible") )
+				getWH();
+			else
+				jQuery.swap( elem, props, getWH );
+			
+			return Math.max(0, val);
+		}
+		
+		return jQuery.curCSS( elem, name, force );
+	},
+
+	curCSS: function( elem, name, force ) {
+		var ret;
+
+		// A helper method for determining if an element's values are broken
+		function color( elem ) {
+			if ( !jQuery.browser.safari )
+				return false;
+
+			var ret = document.defaultView.getComputedStyle( elem, null );
+			return !ret || ret.getPropertyValue("color") == "";
+		}
+
+		// We need to handle opacity special in IE
+		if ( name == "opacity" && jQuery.browser.msie ) {
+			ret = jQuery.attr( elem.style, "opacity" );
+
+			return ret == "" ?
+				"1" :
+				ret;
+		}
+		// Opera sometimes will give the wrong display answer, this fixes it, see #2037
+		if ( jQuery.browser.opera && name == "display" ) {
+			var save = elem.style.display;
+			elem.style.display = "block";
+			elem.style.display = save;
+		}
+		
+		// Make sure we're using the right name for getting the float value
+		if ( name.match( /float/i ) )
+			name = styleFloat;
+
+		if ( !force && elem.style[ name ] )
+			ret = elem.style[ name ];
+
+		else if ( document.defaultView && document.defaultView.getComputedStyle ) {
+
+			// Only "float" is needed here
+			if ( name.match( /float/i ) )
+				name = "float";
+
+			name = name.replace( /([A-Z])/g, "-$1" ).toLowerCase();
+
+			var getComputedStyle = document.defaultView.getComputedStyle( elem, null );
+
+			if ( getComputedStyle && !color( elem ) )
+				ret = getComputedStyle.getPropertyValue( name );
+
+			// If the element isn't reporting its values properly in Safari
+			// then some display: none elements are involved
+			else {
+				var swap = [], stack = [];
+
+				// Locate all of the parent display: none elements
+				for ( var a = elem; a && color(a); a = a.parentNode )
+					stack.unshift(a);
+
+				// Go through and make them visible, but in reverse
+				// (It would be better if we knew the exact display type that they had)
+				for ( var i = 0; i < stack.length; i++ )
+					if ( color( stack[ i ] ) ) {
+						swap[ i ] = stack[ i ].style.display;
+						stack[ i ].style.display = "block";
+					}
+
+				// Since we flip the display style, we have to handle that
+				// one special, otherwise get the value
+				ret = name == "display" && swap[ stack.length - 1 ] != null ?
+					"none" :
+					( getComputedStyle && getComputedStyle.getPropertyValue( name ) ) || "";
+
+				// Finally, revert the display styles back
+				for ( var i = 0; i < swap.length; i++ )
+					if ( swap[ i ] != null )
+						stack[ i ].style.display = swap[ i ];
+			}
+
+			// We should always get a number back from opacity
+			if ( name == "opacity" && ret == "" )
+				ret = "1";
+
+		} else if ( elem.currentStyle ) {
+			var camelCase = name.replace(/\-(\w)/g, function(all, letter){
+				return letter.toUpperCase();
+			});
+
+			ret = elem.currentStyle[ name ] || elem.currentStyle[ camelCase ];
+
+			// From the awesome hack by Dean Edwards
+			// http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
+
+			// If we're not dealing with a regular pixel number
+			// but a number that has a weird ending, we need to convert it to pixels
+			if ( !/^\d+(px)?$/i.test( ret ) && /^\d/.test( ret ) ) {
+				// Remember the original values
+				var style = elem.style.left, runtimeStyle = elem.runtimeStyle.left;
+
+				// Put in the new values to get a computed value out
+				elem.runtimeStyle.left = elem.currentStyle.left;
+				elem.style.left = ret || 0;
+				ret = elem.style.pixelLeft + "px";
+
+				// Revert the changed values
+				elem.style.left = style;
+				elem.runtimeStyle.left = runtimeStyle;
+			}
+		}
+
+		return ret;
+	},
+	
+	clean: function( elems, context ) {
+		var ret = [];
+		context = context || document;
+		// !context.createElement fails in IE with an error but returns typeof 'object'
+		if (typeof context.createElement == 'undefined') 
+			context = context.ownerDocument || context[0] && context[0].ownerDocument || document;
+
+		jQuery.each(elems, function(i, elem){
+			if ( !elem )
+				return;
+
+			if ( elem.constructor == Number )
+				elem = elem.toString();
+			
+			// Convert html string into DOM nodes
+			if ( typeof elem == "string" ) {
+				// Fix "XHTML"-style tags in all browsers
+				elem = elem.replace(/(<(\w+)[^>]*?)\/>/g, function(all, front, tag){
+					return tag.match(/^(abbr|br|col|img|input|link|meta|param|hr|area)$/i) ?
+						all :
+						front + "></" + tag + ">";
+				});
+
+				// Trim whitespace, otherwise indexOf won't work as expected
+				var tags = jQuery.trim( elem ).toLowerCase(), div = context.createElement("div");
+
+				var wrap =
+					// option or optgroup
+					!tags.indexOf("<opt") &&
+					[ 1, "<select multiple='multiple'>", "</select>" ] ||
+					
+					!tags.indexOf("<leg") &&
+					[ 1, "<fieldset>", "</fieldset>" ] ||
+					
+					tags.match(/^<(thead|tbody|tfoot|colg|cap)/) &&
+					[ 1, "<table>", "</table>" ] ||
+					
+					!tags.indexOf("<tr") &&
+					[ 2, "<table><tbody>", "</tbody></table>" ] ||
+					
+				 	// <thead> matched above
+					(!tags.indexOf("<td") || !tags.indexOf("<th")) &&
+					[ 3, "<table><tbody><tr>", "</tr></tbody></table>" ] ||
+					
+					!tags.indexOf("<col") &&
+					[ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ] ||
+
+					// IE can't serialize <link> and <script> tags normally
+					jQuery.browser.msie &&
+					[ 1, "div<div>", "</div>" ] ||
+					
+					[ 0, "", "" ];
+
+				// Go to html and back, then peel off extra wrappers
+				div.innerHTML = wrap[1] + elem + wrap[2];
+				
+				// Move to the right depth
+				while ( wrap[0]-- )
+					div = div.lastChild;
+				
+				// Remove IE's autoinserted <tbody> from table fragments
+				if ( jQuery.browser.msie ) {
+					
+					// String was a <table>, *may* have spurious <tbody>
+					var tbody = !tags.indexOf("<table") && tags.indexOf("<tbody") < 0 ?
+						div.firstChild && div.firstChild.childNodes :
+						
+						// String was a bare <thead> or <tfoot>
+						wrap[1] == "<table>" && tags.indexOf("<tbody") < 0 ?
+							div.childNodes :
+							[];
+				
+					for ( var j = tbody.length - 1; j >= 0 ; --j )
+						if ( jQuery.nodeName( tbody[ j ], "tbody" ) && !tbody[ j ].childNodes.length )
+							tbody[ j ].parentNode.removeChild( tbody[ j ] );
+					
+					// IE completely kills leading whitespace when innerHTML is used	
+					if ( /^\s/.test( elem ) )	
+						div.insertBefore( context.createTextNode( elem.match(/^\s*/)[0] ), div.firstChild );
+				
+				}
+				
+				elem = jQuery.makeArray( div.childNodes );
+			}
+
+			if ( elem.length === 0 && (!jQuery.nodeName( elem, "form" ) && !jQuery.nodeName( elem, "select" )) )
+				return;
+
+			if ( elem[0] == undefined || jQuery.nodeName( elem, "form" ) || elem.options )
+				ret.push( elem );
+
+			else
+				ret = jQuery.merge( ret, elem );
+
+		});
+
+		return ret;
+	},
+	
+	attr: function( elem, name, value ) {
+		// don't set attributes on text and comment nodes
+		if (!elem || elem.nodeType == 3 || elem.nodeType == 8)
+			return undefined;
+
+		var fix = jQuery.isXMLDoc( elem ) ?
+			{} :
+			jQuery.props;
+
+		// Safari mis-reports the default selected property of a hidden option
+		// Accessing the parent's selectedIndex property fixes it
+		if ( name == "selected" && jQuery.browser.safari )
+			elem.parentNode.selectedIndex;
+		
+		// Certain attributes only work when accessed via the old DOM 0 way
+		if ( fix[ name ] ) {
+			if ( value != undefined )
+				elem[ fix[ name ] ] = value;
+
+			return elem[ fix[ name ] ];
+
+		} else if ( jQuery.browser.msie && name == "style" )
+			return jQuery.attr( elem.style, "cssText", value );
+
+		else if ( value == undefined && jQuery.browser.msie && jQuery.nodeName( elem, "form" ) && (name == "action" || name == "method") )
+			return elem.getAttributeNode( name ).nodeValue;
+
+		// IE elem.getAttribute passes even for style
+		else if ( elem.tagName ) {
+
+			if ( value != undefined ) {
+				// We can't allow the type property to be changed (since it causes problems in IE)
+				if ( name == "type" && jQuery.nodeName( elem, "input" ) && elem.parentNode )
+					throw "type property can't be changed";
+
+				// convert the value to a string (all browsers do this but IE) see #1070
+				elem.setAttribute( name, "" + value );
+			}
+
+			if ( jQuery.browser.msie && /href|src/.test( name ) && !jQuery.isXMLDoc( elem ) ) 
+				return elem.getAttribute( name, 2 );
+
+			return elem.getAttribute( name );
+
+		// elem is actually elem.style ... set the style
+		} else {
+			// IE actually uses filters for opacity
+			if ( name == "opacity" && jQuery.browser.msie ) {
+				if ( value != undefined ) {
+					// IE has trouble with opacity if it does not have layout
+					// Force it by setting the zoom level
+					elem.zoom = 1; 
+	
+					// Set the alpha filter to set the opacity
+					elem.filter = (elem.filter || "").replace( /alpha\([^)]*\)/, "" ) +
+						(parseFloat( value ).toString() == "NaN" ? "" : "alpha(opacity=" + value * 100 + ")");
+				}
+	
+				return elem.filter && elem.filter.indexOf("opacity=") >= 0 ?
+					(parseFloat( elem.filter.match(/opacity=([^)]*)/)[1] ) / 100).toString() :
+					"";
+			}
+
+			name = name.replace(/-([a-z])/ig, function(all, letter){
+				return letter.toUpperCase();
+			});
+
+			if ( value != undefined )
+				elem[ name ] = value;
+
+			return elem[ name ];
+		}
+	},
+	
+	trim: function( text ) {
+		return (text || "").replace( /^\s+|\s+$/g, "" );
+	},
+
+	makeArray: function( array ) {
+		var ret = [];
+
+		// Need to use typeof to fight Safari childNodes crashes
+		if ( typeof array != "array" )
+			for ( var i = 0, length = array.length; i < length; i++ )
+				ret.push( array[ i ] );
+		else
+			ret = array.slice( 0 );
+
+		return ret;
+	},
+
+	inArray: function( elem, array ) {
+		for ( var i = 0, length = array.length; i < length; i++ )
+			if ( array[ i ] == elem )
+				return i;
+
+		return -1;
+	},
+
+	merge: function( first, second ) {
+		// We have to loop this way because IE & Opera overwrite the length
+		// expando of getElementsByTagName
+
+		// Also, we need to make sure that the correct elements are being returned
+		// (IE returns comment nodes in a '*' query)
+		if ( jQuery.browser.msie ) {
+			for ( var i = 0; second[ i ]; i++ )
+				if ( second[ i ].nodeType != 8 )
+					first.push( second[ i ] );
+
+		} else
+			for ( var i = 0; second[ i ]; i++ )
+				first.push( second[ i ] );
+
+		return first;
+	},
+
+	unique: function( array ) {
+		var ret = [], done = {};
+
+		try {
+
+			for ( var i = 0, length = array.length; i < length; i++ ) {
+				var id = jQuery.data( array[ i ] );
+
+				if ( !done[ id ] ) {
+					done[ id ] = true;
+					ret.push( array[ i ] );
+				}
+			}
+
+		} catch( e ) {
+			ret = array;
+		}
+
+		return ret;
+	},
+
+	grep: function( elems, callback, inv ) {
+		// If a string is passed in for the function, make a function
+		// for it (a handy shortcut)
+		if ( typeof callback == "string" )
+			callback = eval("false||function(a,i){return " + callback + "}");
+
+		var ret = [];
+
+		// Go through the array, only saving the items
+		// that pass the validator function
+		for ( var i = 0, length = elems.length; i < length; i++ )
+			if ( !inv && callback( elems[ i ], i ) || inv && !callback( elems[ i ], i ) )
+				ret.push( elems[ i ] );
+
+		return ret;
+	},
+
+	map: function( elems, callback ) {
+		var ret = [];
+
+		// Go through the array, translating each of the items to their
+		// new value (or values).
+		for ( var i = 0, length = elems.length; i < length; i++ ) {
+			var value = callback( elems[ i ], i );
+
+			if ( value !== null && value != undefined ) {
+				if ( value.constructor != Array )
+					value = [ value ];
+
+				ret = ret.concat( value );
+			}
+		}
+
+		return ret;
+	}
+});
+
+var userAgent = navigator.userAgent.toLowerCase();
+
+// Figure out what browser is being used
+jQuery.browser = {
+	version: (userAgent.match( /.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/ ) || [])[1],
+	safari: /webkit/.test( userAgent ),
+	opera: /opera/.test( userAgent ),
+	msie: /msie/.test( userAgent ) && !/opera/.test( userAgent ),
+	mozilla: /mozilla/.test( userAgent ) && !/(compatible|webkit)/.test( userAgent )
+};
+
+var styleFloat = jQuery.browser.msie ?
+	"styleFloat" :
+	"cssFloat";
+	
+jQuery.extend({
+	// Check to see if the W3C box model is being used
+	boxModel: !jQuery.browser.msie || document.compatMode == "CSS1Compat",
+	
+	props: {
+		"for": "htmlFor",
+		"class": "className",
+		"float": styleFloat,
+		cssFloat: styleFloat,
+		styleFloat: styleFloat,
+		innerHTML: "innerHTML",
+		className: "className",
+		value: "value",
+		disabled: "disabled",
+		checked: "checked",
+		readonly: "readOnly",
+		selected: "selected",
+		maxlength: "maxLength",
+		selectedIndex: "selectedIndex",
+		defaultValue: "defaultValue",
+		tagName: "tagName",
+		nodeName: "nodeName"
+	}
+});
+
+jQuery.each({
+	parent: "elem.parentNode",
+	parents: "jQuery.dir(elem,'parentNode')",
+	next: "jQuery.nth(elem,2,'nextSibling')",
+	prev: "jQuery.nth(elem,2,'previousSibling')",
+	nextAll: "jQuery.dir(elem,'nextSibling')",
+	prevAll: "jQuery.dir(elem,'previousSibling')",
+	siblings: "jQuery.sibling(elem.parentNode.firstChild,elem)",
+	children: "jQuery.sibling(elem.firstChild)",
+	contents: "jQuery.nodeName(elem,'iframe')?elem.contentDocument||elem.contentWindow.document:jQuery.makeArray(elem.childNodes)"
+}, function(name, fn){
+	fn = eval("false||function(elem){return " + fn + "}");
+
+	jQuery.fn[ name ] = function( selector ) {
+		var ret = jQuery.map( this, fn );
+
+		if ( selector && typeof selector == "string" )
+			ret = jQuery.multiFilter( selector, ret );
+
+		return this.pushStack( jQuery.unique( ret ) );
+	};
+});
+
+jQuery.each({
+	appendTo: "append",
+	prependTo: "prepend",
+	insertBefore: "before",
+	insertAfter: "after",
+	replaceAll: "replaceWith"
+}, function(name, original){
+	jQuery.fn[ name ] = function() {
+		var args = arguments;
+
+		return this.each(function(){
+			for ( var i = 0, length = args.length; i < length; i++ )
+				jQuery( args[ i ] )[ original ]( this );
+		});
+	};
+});
+
+jQuery.each({
+	removeAttr: function( name ) {
+		jQuery.attr( this, name, "" );
+		if (this.nodeType == 1) 
+			this.removeAttribute( name );
+	},
+
+	addClass: function( classNames ) {
+		jQuery.className.add( this, classNames );
+	},
+
+	removeClass: function( classNames ) {
+		jQuery.className.remove( this, classNames );
+	},
+
+	toggleClass: function( classNames ) {
+		jQuery.className[ jQuery.className.has( this, classNames ) ? "remove" : "add" ]( this, classNames );
+	},
+
+	remove: function( selector ) {
+		if ( !selector || jQuery.filter( selector, [ this ] ).r.length ) {
+			// Prevent memory leaks
+			jQuery( "*", this ).add(this).each(function(){
+				jQuery.event.remove(this);
+				jQuery.removeData(this);
+			});
+			if (this.parentNode)
+				this.parentNode.removeChild( this );
+		}
+	},
+
+	empty: function() {
+		// Remove element nodes and prevent memory leaks
+		jQuery( ">*", this ).remove();
+		
+		// Remove any remaining nodes
+		while ( this.firstChild )
+			this.removeChild( this.firstChild );
+	}
+}, function(name, fn){
+	jQuery.fn[ name ] = function(){
+		return this.each( fn, arguments );
+	};
+});
+
+jQuery.each([ "Height", "Width" ], function(i, name){
+	var type = name.toLowerCase();
+	
+	jQuery.fn[ type ] = function( size ) {
+		// Get window width or height
+		return this[0] == window ?
+			// Opera reports document.body.client[Width/Height] properly in both quirks and standards
+			jQuery.browser.opera && document.body[ "client" + name ] || 
+			
+			// Safari reports inner[Width/Height] just fine (Mozilla and Opera include scroll bar widths)
+			jQuery.browser.safari && window[ "inner" + name ] ||
+			
+			// Everyone else use document.documentElement or document.body depending on Quirks vs Standards mode
+			document.compatMode == "CSS1Compat" && document.documentElement[ "client" + name ] || document.body[ "client" + name ] :
+		
+			// Get document width or height
+			this[0] == document ?
+				// Either scroll[Width/Height] or offset[Width/Height], whichever is greater
+				Math.max( 
+					Math.max(document.body["scroll" + name], document.documentElement["scroll" + name]), 
+					Math.max(document.body["offset" + name], document.documentElement["offset" + name]) 
+				) :
+
+				// Get or set width or height on the element
+				size == undefined ?
+					// Get width or height on the element
+					(this.length ? jQuery.css( this[0], type ) : null) :
+
+					// Set the width or height on the element (default to pixels if value is unitless)
+					this.css( type, size.constructor == String ? size : size + "px" );
+	};
+});
+
+var chars = jQuery.browser.safari && parseInt(jQuery.browser.version) < 417 ?
+		"(?:[\\w*_-]|\\\\.)" :
+		"(?:[\\w\u0128-\uFFFF*_-]|\\\\.)",
+	quickChild = new RegExp("^>\\s*(" + chars + "+)"),
+	quickID = new RegExp("^(" + chars + "+)(#)(" + chars + "+)"),
+	quickClass = new RegExp("^([#.]?)(" + chars + "*)");
+
+jQuery.extend({
+	expr: {
+		"": "m[2]=='*'||jQuery.nodeName(a,m[2])",
+		"#": "a.getAttribute('id')==m[2]",
+		":": {
+			// Position Checks
+			lt: "i<m[3]-0",
+			gt: "i>m[3]-0",
+			nth: "m[3]-0==i",
+			eq: "m[3]-0==i",
+			first: "i==0",
+			last: "i==r.length-1",
+			even: "i%2==0",
+			odd: "i%2",
+
+			// Child Checks
+			"first-child": "a.parentNode.getElementsByTagName('*')[0]==a",
+			"last-child": "jQuery.nth(a.parentNode.lastChild,1,'previousSibling')==a",
+			"only-child": "!jQuery.nth(a.parentNode.lastChild,2,'previousSibling')",
+
+			// Parent Checks
+			parent: "a.firstChild",
+			empty: "!a.firstChild",
+
+			// Text Check
+			contains: "(a.textContent||a.innerText||jQuery(a).text()||'').indexOf(m[3])>=0",
+
+			// Visibility
+			visible: '"hidden"!=a.type&&jQuery.css(a,"display")!="none"&&jQuery.css(a,"visibility")!="hidden"',
+			hidden: '"hidden"==a.type||jQuery.css(a,"display")=="none"||jQuery.css(a,"visibility")=="hidden"',
+
+			// Form attributes
+			enabled: "!a.disabled",
+			disabled: "a.disabled",
+			checked: "a.checked",
+			selected: "a.selected||jQuery.attr(a,'selected')",
+
+			// Form elements
+			text: "'text'==a.type",
+			radio: "'radio'==a.type",
+			checkbox: "'checkbox'==a.type",
+			file: "'file'==a.type",
+			password: "'password'==a.type",
+			submit: "'submit'==a.type",
+			image: "'image'==a.type",
+			reset: "'reset'==a.type",
+			button: '"button"==a.type||jQuery.nodeName(a,"button")',
+			input: "/input|select|textarea|button/i.test(a.nodeName)",
+
+			// :has()
+			has: "jQuery.find(m[3],a).length",
+
+			// :header
+			header: "/h\\d/i.test(a.nodeName)",
+
+			// :animated
+			animated: "jQuery.grep(jQuery.timers,function(fn){return a==fn.elem;}).length"
+		}
+	},
+	
+	// The regular expressions that power the parsing engine
+	parse: [
+		// Match: [@value='test'], [@foo]
+		/^(\[) *@?([\w-]+) *([!*$^~=]*) *('?"?)(.*?)\4 *\]/,
+
+		// Match: :contains('foo')
+		/^(:)([\w-]+)\("?'?(.*?(\(.*?\))?[^(]*?)"?'?\)/,
+
+		// Match: :even, :last-chlid, #id, .class
+		new RegExp("^([:.#]*)(" + chars + "+)")
+	],
+
+	multiFilter: function( expr, elems, not ) {
+		var old, cur = [];
+
+		while ( expr && expr != old ) {
+			old = expr;
+			var f = jQuery.filter( expr, elems, not );
+			expr = f.t.replace(/^\s*,\s*/, "" );
+			cur = not ? elems = f.r : jQuery.merge( cur, f.r );
+		}
+
+		return cur;
+	},
+
+	find: function( t, context ) {
+		// Quickly handle non-string expressions
+		if ( typeof t != "string" )
+			return [ t ];
+
+		// check to make sure context is a DOM element or a document
+		if ( context && context.nodeType != 1 && context.nodeType != 9)
+			return [ ];
+
+		// Set the correct context (if none is provided)
+		context = context || document;
+
+		// Initialize the search
+		var ret = [context], done = [], last, nodeName;
+
+		// Continue while a selector expression exists, and while
+		// we're no longer looping upon ourselves
+		while ( t && last != t ) {
+			var r = [];
+			last = t;
+
+			t = jQuery.trim(t);
+
+			var foundToken = false;
+
+			// An attempt at speeding up child selectors that
+			// point to a specific element tag
+			var re = quickChild;
+			var m = re.exec(t);
+
+			if ( m ) {
+				nodeName = m[1].toUpperCase();
+
+				// Perform our own iteration and filter
+				for ( var i = 0; ret[i]; i++ )
+					for ( var c = ret[i].firstChild; c; c = c.nextSibling )
+						if ( c.nodeType == 1 && (nodeName == "*" || c.nodeName.toUpperCase() == nodeName) )
+							r.push( c );
+
+				ret = r;
+				t = t.replace( re, "" );
+				if ( t.indexOf(" ") == 0 ) continue;
+				foundToken = true;
+			} else {
+				re = /^([>+~])\s*(\w*)/i;
+
+				if ( (m = re.exec(t)) != null ) {
+					r = [];
+
+					var merge = {};
+					nodeName = m[2].toUpperCase();
+					m = m[1];
+
+					for ( var j = 0, rl = ret.length; j < rl; j++ ) {
+						var n = m == "~" || m == "+" ? ret[j].nextSibling : ret[j].firstChild;
+						for ( ; n; n = n.nextSibling )
+							if ( n.nodeType == 1 ) {
+								var id = jQuery.data(n);
+
+								if ( m == "~" && merge[id] ) break;
+								
+								if (!nodeName || n.nodeName.toUpperCase() == nodeName ) {
+									if ( m == "~" ) merge[id] = true;
+									r.push( n );
+								}
+								
+								if ( m == "+" ) break;
+							}
+					}
+
+					ret = r;
+
+					// And remove the token
+					t = jQuery.trim( t.replace( re, "" ) );
+					foundToken = true;
+				}
+			}
+
+			// See if there's still an expression, and that we haven't already
+			// matched a token
+			if ( t && !foundToken ) {
+				// Handle multiple expressions
+				if ( !t.indexOf(",") ) {
+					// Clean the result set
+					if ( context == ret[0] ) ret.shift();
+
+					// Merge the result sets
+					done = jQuery.merge( done, ret );
+
+					// Reset the context
+					r = ret = [context];
+
+					// Touch up the selector string
+					t = " " + t.substr(1,t.length);
+
+				} else {
+					// Optimize for the case nodeName#idName
+					var re2 = quickID;
+					var m = re2.exec(t);
+					
+					// Re-organize the results, so that they're consistent
+					if ( m ) {
+						m = [ 0, m[2], m[3], m[1] ];
+
+					} else {
+						// Otherwise, do a traditional filter check for
+						// ID, class, and element selectors
+						re2 = quickClass;
+						m = re2.exec(t);
+					}
+
+					m[2] = m[2].replace(/\\/g, "");
+
+					var elem = ret[ret.length-1];
+
+					// Try to do a global search by ID, where we can
+					if ( m[1] == "#" && elem && elem.getElementById && !jQuery.isXMLDoc(elem) ) {
+						// Optimization for HTML document case
+						var oid = elem.getElementById(m[2]);
+						
+						// Do a quick check for the existence of the actual ID attribute
+						// to avoid selecting by the name attribute in IE
+						// also check to insure id is a string to avoid selecting an element with the name of 'id' inside a form
+						if ( (jQuery.browser.msie||jQuery.browser.opera) && oid && typeof oid.id == "string" && oid.id != m[2] )
+							oid = jQuery('[@id="'+m[2]+'"]', elem)[0];
+
+						// Do a quick check for node name (where applicable) so
+						// that div#foo searches will be really fast
+						ret = r = oid && (!m[3] || jQuery.nodeName(oid, m[3])) ? [oid] : [];
+					} else {
+						// We need to find all descendant elements
+						for ( var i = 0; ret[i]; i++ ) {
+							// Grab the tag name being searched for
+							var tag = m[1] == "#" && m[3] ? m[3] : m[1] != "" || m[0] == "" ? "*" : m[2];
+
+							// Handle IE7 being really dumb about <object>s
+							if ( tag == "*" && ret[i].nodeName.toLowerCase() == "object" )
+								tag = "param";
+
+							r = jQuery.merge( r, ret[i].getElementsByTagName( tag ));
+						}
+
+						// It's faster to filter by class and be done with it
+						if ( m[1] == "." )
+							r = jQuery.classFilter( r, m[2] );
+
+						// Same with ID filtering
+						if ( m[1] == "#" ) {
+							var tmp = [];
+
+							// Try to find the element with the ID
+							for ( var i = 0; r[i]; i++ )
+								if ( r[i].getAttribute("id") == m[2] ) {
+									tmp = [ r[i] ];
+									break;
+								}
+
+							r = tmp;
+						}
+
+						ret = r;
+					}
+
+					t = t.replace( re2, "" );
+				}
+
+			}
+
+			// If a selector string still exists
+			if ( t ) {
+				// Attempt to filter it
+				var val = jQuery.filter(t,r);
+				ret = r = val.r;
+				t = jQuery.trim(val.t);
+			}
+		}
+
+		// An error occurred with the selector;
+		// just return an empty set instead
+		if ( t )
+			ret = [];
+
+		// Remove the root context
+		if ( ret && context == ret[0] )
+			ret.shift();
+
+		// And combine the results
+		done = jQuery.merge( done, ret );
+
+		return done;
+	},
+
+	classFilter: function(r,m,not){
+		m = " " + m + " ";
+		var tmp = [];
+		for ( var i = 0; r[i]; i++ ) {
+			var pass = (" " + r[i].className + " ").indexOf( m ) >= 0;
+			if ( !not && pass || not && !pass )
+				tmp.push( r[i] );
+		}
+		return tmp;
+	},
+
+	filter: function(t,r,not) {
+		var last;
+
+		// Look for common filter expressions
+		while ( t && t != last ) {
+			last = t;
+
+			var p = jQuery.parse, m;
+
+			for ( var i = 0; p[i]; i++ ) {
+				m = p[i].exec( t );
+
+				if ( m ) {
+					// Remove what we just matched
+					t = t.substring( m[0].length );
+
+					m[2] = m[2].replace(/\\/g, "");
+					break;
+				}
+			}
+
+			if ( !m )
+				break;
+
+			// :not() is a special case that can be optimized by
+			// keeping it out of the expression list
+			if ( m[1] == ":" && m[2] == "not" )
+				// optimize if only one selector found (most common case)
+				r = isSimple.test( m[3] ) ?
+					jQuery.filter(m[3], r, true).r :
+					jQuery( r ).not( m[3] );
+
+			// We can get a big speed boost by filtering by class here
+			else if ( m[1] == "." )
+				r = jQuery.classFilter(r, m[2], not);
+
+			else if ( m[1] == "[" ) {
+				var tmp = [], type = m[3];
+				
+				for ( var i = 0, rl = r.length; i < rl; i++ ) {
+					var a = r[i], z = a[ jQuery.props[m[2]] || m[2] ];
+					
+					if ( z == null || /href|src|selected/.test(m[2]) )
+						z = jQuery.attr(a,m[2]) || '';
+
+					if ( (type == "" && !!z ||
+						 type == "=" && z == m[5] ||
+						 type == "!=" && z != m[5] ||
+						 type == "^=" && z && !z.indexOf(m[5]) ||
+						 type == "$=" && z.substr(z.length - m[5].length) == m[5] ||
+						 (type == "*=" || type == "~=") && z.indexOf(m[5]) >= 0) ^ not )
+							tmp.push( a );
+				}
+				
+				r = tmp;
+
+			// We can get a speed boost by handling nth-child here
+			} else if ( m[1] == ":" && m[2] == "nth-child" ) {
+				var merge = {}, tmp = [],
+					// parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6'
+					test = /(-?)(\d*)n((?:\+|-)?\d*)/.exec(
+						m[3] == "even" && "2n" || m[3] == "odd" && "2n+1" ||
+						!/\D/.test(m[3]) && "0n+" + m[3] || m[3]),
+					// calculate the numbers (first)n+(last) including if they are negative
+					first = (test[1] + (test[2] || 1)) - 0, last = test[3] - 0;
+ 
+				// loop through all the elements left in the jQuery object
+				for ( var i = 0, rl = r.length; i < rl; i++ ) {
+					var node = r[i], parentNode = node.parentNode, id = jQuery.data(parentNode);
+
+					if ( !merge[id] ) {
+						var c = 1;
+
+						for ( var n = parentNode.firstChild; n; n = n.nextSibling )
+							if ( n.nodeType == 1 )
+								n.nodeIndex = c++;
+
+						merge[id] = true;
+					}
+
+					var add = false;
+
+					if ( first == 0 ) {
+						if ( node.nodeIndex == last )
+							add = true;
+					} else if ( (node.nodeIndex - last) % first == 0 && (node.nodeIndex - last) / first >= 0 )
+						add = true;
+
+					if ( add ^ not )
+						tmp.push( node );
+				}
+
+				r = tmp;
+
+			// Otherwise, find the expression to execute
+			} else {
+				var f = jQuery.expr[m[1]];
+				if ( typeof f != "string" )
+					f = jQuery.expr[m[1]][m[2]];
+
+				// Build a custom macro to enclose it
+				f = eval("false||function(a,i){return " + f + "}");
+
+				// Execute it against the current filter
+				r = jQuery.grep( r, f, not );
+			}
+		}
+
+		// Return an array of filtered elements (r)
+		// and the modified expression string (t)
+		return { r: r, t: t };
+	},
+
+	dir: function( elem, dir ){
+		var matched = [];
+		var cur = elem[dir];
+		while ( cur && cur != document ) {
+			if ( cur.nodeType == 1 )
+				matched.push( cur );
+			cur = cur[dir];
+		}
+		return matched;
+	},
+	
+	nth: function(cur,result,dir,elem){
+		result = result || 1;
+		var num = 0;
+
+		for ( ; cur; cur = cur[dir] )
+			if ( cur.nodeType == 1 && ++num == result )
+				break;
+
+		return cur;
+	},
+	
+	sibling: function( n, elem ) {
+		var r = [];
+
+		for ( ; n; n = n.nextSibling ) {
+			if ( n.nodeType == 1 && (!elem || n != elem) )
+				r.push( n );
+		}
+
+		return r;
+	}
+});
+
+/*
+ * A number of helper functions used for managing events.
+ * Many of the ideas behind this code orignated from 
+ * Dean Edwards' addEvent library.
+ */
+jQuery.event = {
+
+	// Bind an event to an element
+	// Original by Dean Edwards
+	add: function(elem, types, handler, data) {
+		if ( elem.nodeType == 3 || elem.nodeType == 8 )
+			return;
+
+		// For whatever reason, IE has trouble passing the window object
+		// around, causing it to be cloned in the process
+		if ( jQuery.browser.msie && elem.setInterval != undefined )
+			elem = window;
+
+		// Make sure that the function being executed has a unique ID
+		if ( !handler.guid )
+			handler.guid = this.guid++;
+			
+		// if data is passed, bind to handler 
+		if( data != undefined ) { 
+			// Create temporary function pointer to original handler 
+			var fn = handler; 
+
+			// Create unique handler function, wrapped around original handler 
+			handler = function() { 
+				// Pass arguments and context to original handler 
+				return fn.apply(this, arguments); 
+			};
+
+			// Store data in unique handler 
+			handler.data = data;
+
+			// Set the guid of unique handler to the same of original handler, so it can be removed 
+			handler.guid = fn.guid;
+		}
+
+		// Init the element's event structure
+		var events = jQuery.data(elem, "events") || jQuery.data(elem, "events", {}),
+			handle = jQuery.data(elem, "handle") || jQuery.data(elem, "handle", function(){
+				// returned undefined or false
+				var val;
+
+				// Handle the second event of a trigger and when
+				// an event is called after a page has unloaded
+				if ( typeof jQuery == "undefined" || jQuery.event.triggered )
+					return val;
+		
+				val = jQuery.event.handle.apply(elem, arguments);
+		
+				return val;
+			});
+			
+			// Handle multiple events seperated by a space
+			// jQuery(...).bind("mouseover mouseout", fn);
+			jQuery.each(types.split(/\s+/), function(index, type) {
+				// Namespaced event handlers
+				var parts = type.split(".");
+				type = parts[0];
+				handler.type = parts[1];
+
+				// Get the current list of functions bound to this event
+				var handlers = events[type];
+
+				// Init the event handler queue
+				if (!handlers) {
+					handlers = events[type] = {};
+		
+					// Check for a special event handler
+					// Only use addEventListener/attachEvent if the special
+					// events handler returns false
+					if ( !jQuery.event.special[type] || jQuery.event.special[type].setup.call(elem) === false ) {
+						// Bind the global event handler to the element
+						if (elem.addEventListener)
+							elem.addEventListener(type, handle, false);
+						else if (elem.attachEvent)
+							elem.attachEvent("on" + type, handle);
+					}
+				}
+
+				// Add the function to the element's handler list
+				handlers[handler.guid] = handler;
+
+				// Keep track of which events have been used, for global triggering
+				jQuery.event.global[type] = true;
+			});
+	},
+
+	guid: 1,
+	global: {},
+
+	// Detach an event or set of events from an element
+	remove: function(elem, types, handler) {
+		// don't do events on text and comment nodes
+		if ( elem.nodeType == 3 || elem.nodeType == 8 )
+			return;
+
+		var events = jQuery.data(elem, "events"), ret, index;
+
+		if ( events ) {
+			// Unbind all events for the element
+			if ( types == undefined )
+				for ( var type in events )
+					this.remove( elem, type );
+			else {
+				// types is actually an event object here
+				if ( types.type ) {
+					handler = types.handler;
+					types = types.type;
+				}
+				
+				// Handle multiple events seperated by a space
+				// jQuery(...).unbind("mouseover mouseout", fn);
+				jQuery.each(types.split(/\s+/), function(index, type){
+					// Namespaced event handlers
+					var parts = type.split(".");
+					type = parts[0];
+					
+					if ( events[type] ) {
+						// remove the given handler for the given type
+						if ( handler )
+							delete events[type][handler.guid];
+			
+						// remove all handlers for the given type
+						else
+							for ( handler in events[type] )
+								// Handle the removal of namespaced events
+								if ( !parts[1] || events[type][handler].type == parts[1] )
+									delete events[type][handler];
+
+						// remove generic event handler if no more handlers exist
+						for ( ret in events[type] ) break;
+						if ( !ret ) {
+							if ( !jQuery.event.special[type] || jQuery.event.special[type].teardown.call(elem) === false ) {
+								if (elem.removeEventListener)
+									elem.removeEventListener(type, jQuery.data(elem, "handle"), false);
+								else if (elem.detachEvent)
+									elem.detachEvent("on" + type, jQuery.data(elem, "handle"));
+							}
+							ret = null;
+							delete events[type];
+						}
+					}
+				});
+			}
+
+			// Remove the expando if it's no longer used
+			for ( ret in events ) break;
+			if ( !ret ) {
+				jQuery.removeData( elem, "events" );
+				jQuery.removeData( elem, "handle" );
+			}
+		}
+	},
+
+	trigger: function(type, data, elem, donative, extra) {
+		// Clone the incoming data, if any
+		data = jQuery.makeArray(data || []);
+
+		// Handle a global trigger
+		if ( !elem ) {
+			// Only trigger if we've ever bound an event for it
+			if ( this.global[type] )
+				jQuery("*").add([window, document]).trigger(type, data);
+
+		// Handle triggering a single element
+		} else {
+			// don't do events on text and comment nodes
+			if ( elem.nodeType == 3 || elem.nodeType == 8 )
+				return undefined;
+
+			var val, ret, fn = jQuery.isFunction( elem[ type ] || null ),
+				// Check to see if we need to provide a fake event, or not
+				event = !data[0] || !data[0].preventDefault;
+			
+			// Pass along a fake event
+			if ( event )
+				data.unshift( this.fix({ type: type, target: elem }) );
+
+			// Enforce the right trigger type
+			data[0].type = type;
+
+			// Trigger the event
+			if ( jQuery.isFunction( jQuery.data(elem, "handle") ) )
+				val = jQuery.data(elem, "handle").apply( elem, data );
+
+			// Handle triggering native .onfoo handlers
+			if ( !fn && elem["on"+type] && elem["on"+type].apply( elem, data ) === false )
+				val = false;
+
+			// Extra functions don't get the custom event object
+			if ( event )
+				data.shift();
+
+			// Handle triggering of extra function
+			if ( extra && jQuery.isFunction( extra ) ) {
+				// call the extra function and tack the current return value on the end for possible inspection
+				var ret = extra.apply( elem, data.concat( val ) );
+				// if anything is returned, give it precedence and have it overwrite the previous value
+				if (ret !== undefined)
+					val = ret;
+			}
+
+			// Trigger the native events (except for clicks on links)
+			if ( fn && donative !== false && val !== false && !(jQuery.nodeName(elem, 'a') && type == "click") ) {
+				this.triggered = true;
+				try {
+					elem[ type ]();
+				// prevent IE from throwing an error for some hidden elements
+				} catch (e) {}
+			}
+
+			this.triggered = false;
+		}
+
+		return val;
+	},
+
+	handle: function(event) {
+		// returned undefined or false
+		var val;
+
+		// Empty object is for triggered events with no data
+		event = jQuery.event.fix( event || window.event || {} ); 
+
+		// Namespaced event handlers
+		var parts = event.type.split(".");
+		event.type = parts[0];
+
+		var handlers = jQuery.data(this, "events") && jQuery.data(this, "events")[event.type], args = Array.prototype.slice.call( arguments, 1 );
+		args.unshift( event );
+
+		for ( var j in handlers ) {
+			var handler = handlers[j];
+			// Pass in a reference to the handler function itself
+			// So that we can later remove it
+			args[0].handler = handler;
+			args[0].data = handler.data;
+
+			// Filter the functions by class
+			if ( !parts[1] || handler.type == parts[1] ) {
+				var ret = handler.apply( this, args );
+
+				if ( val !== false )
+					val = ret;
+
+				if ( ret === false ) {
+					event.preventDefault();
+					event.stopPropagation();
+				}
+			}
+		}
+
+		// Clean up added properties in IE to prevent memory leak
+		if (jQuery.browser.msie)
+			event.target = event.preventDefault = event.stopPropagation =
+				event.handler = event.data = null;
+
+		return val;
+	},
+
+	fix: function(event) {
+		// Short-circuit if the event has already been fixed by jQuery.event.fix
+		if ( event[ expando ] )
+			return event;
+			
+		// store a copy of the original event object 
+		// and clone to set read-only properties
+		var originalEvent = event;
+		event = jQuery.extend({}, originalEvent);
+		
+		// Mark the event as fixed by jQuery.event.fix
+		event[ expando ] = true;
+		
+		// add preventDefault and stopPropagation since 
+		// they will not work on the clone
+		event.preventDefault = function() {
+			// if preventDefault exists run it on the original event
+			if (originalEvent.preventDefault)
+				originalEvent.preventDefault();
+			// otherwise set the returnValue property of the original event to false (IE)
+			originalEvent.returnValue = false;
+		};
+		event.stopPropagation = function() {
+			// if stopPropagation exists run it on the original event
+			if (originalEvent.stopPropagation)
+				originalEvent.stopPropagation();
+			// otherwise set the cancelBubble property of the original event to true (IE)
+			originalEvent.cancelBubble = true;
+		};
+		
+		// Fix target property, if necessary
+		if ( !event.target )
+			event.target = event.srcElement || document; // Fixes #1925 where srcElement might not be defined either
+				
+		// check if target is a textnode (safari)
+		if ( event.target.nodeType == 3 )
+			event.target = originalEvent.target.parentNode;
+
+		// Add relatedTarget, if necessary
+		if ( !event.relatedTarget && event.fromElement )
+			event.relatedTarget = event.fromElement == event.target ? event.toElement : event.fromElement;
+
+		// Calculate pageX/Y if missing and clientX/Y available
+		if ( event.pageX == null && event.clientX != null ) {
+			var doc = document.documentElement, body = document.body;
+			event.pageX = event.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc.clientLeft || 0);
+			event.pageY = event.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc.clientTop || 0);
+		}
+			
+		// Add which for key events
+		if ( !event.which && (event.charCode || event.keyCode) )
+			event.which = event.charCode || event.keyCode;
+		
+		// Add metaKey to non-Mac browsers (use ctrl for PC's and Meta for Macs)
+		if ( !event.metaKey && event.ctrlKey )
+			event.metaKey = event.ctrlKey;
+
+		// Add which for click: 1 == left; 2 == middle; 3 == right
+		// Note: button is not normalized, so don't use it
+		if ( !event.which && event.button )
+			event.which = (event.button & 1 ? 1 : ( event.button & 2 ? 3 : ( event.button & 4 ? 2 : 0 ) ));
+			
+		return event;
+	},
+	
+	special: {
+		ready: {
+			setup: function() {
+				// Make sure the ready event is setup
+				bindReady();
+				return;
+			},
+			
+			teardown: function() { return; }
+		},
+		
+		mouseenter: {
+			setup: function() {
+				if ( jQuery.browser.msie ) return false;
+				jQuery(this).bind("mouseover", jQuery.event.special.mouseenter.handler);
+				return true;
+			},
+		
+			teardown: function() {
+				if ( jQuery.browser.msie ) return false;
+				jQuery(this).unbind("mouseover", jQuery.event.special.mouseenter.handler);
+				return true;
+			},
+			
+			handler: function(event) {
+				// If we actually just moused on to a sub-element, ignore it
+				if ( withinElement(event, this) ) return true;
+				// Execute the right handlers by setting the event type to mouseenter
+				arguments[0].type = "mouseenter";
+				return jQuery.event.handle.apply(this, arguments);
+			}
+		},
+	
+		mouseleave: {
+			setup: function() {
+				if ( jQuery.browser.msie ) return false;
+				jQuery(this).bind("mouseout", jQuery.event.special.mouseleave.handler);
+				return true;
+			},
+		
+			teardown: function() {
+				if ( jQuery.browser.msie ) return false;
+				jQuery(this).unbind("mouseout", jQuery.event.special.mouseleave.handler);
+				return true;
+			},
+			
+			handler: function(event) {
+				// If we actually just moused on to a sub-element, ignore it
+				if ( withinElement(event, this) ) return true;
+				// Execute the right handlers by setting the event type to mouseleave
+				arguments[0].type = "mouseleave";
+				return jQuery.event.handle.apply(this, arguments);
+			}
+		}
+	}
+};
+
+jQuery.fn.extend({
+	bind: function( type, data, fn ) {
+		return type == "unload" ? this.one(type, data, fn) : this.each(function(){
+			jQuery.event.add( this, type, fn || data, fn && data );
+		});
+	},
+	
+	one: function( type, data, fn ) {
+		return this.each(function(){
+			jQuery.event.add( this, type, function(event) {
+				jQuery(this).unbind(event);
+				return (fn || data).apply( this, arguments);
+			}, fn && data);
+		});
+	},
+
+	unbind: function( type, fn ) {
+		return this.each(function(){
+			jQuery.event.remove( this, type, fn );
+		});
+	},
+
+	trigger: function( type, data, fn ) {
+		return this.each(function(){
+			jQuery.event.trigger( type, data, this, true, fn );
+		});
+	},
+
+	triggerHandler: function( type, data, fn ) {
+		if ( this[0] )
+			return jQuery.event.trigger( type, data, this[0], false, fn );
+		return undefined;
+	},
+
+	toggle: function() {
+		// Save reference to arguments for access in closure
+		var args = arguments;
+
+		return this.click(function(event) {
+			// Figure out which function to execute
+			this.lastToggle = 0 == this.lastToggle ? 1 : 0;
+			
+			// Make sure that clicks stop
+			event.preventDefault();
+			
+			// and execute the function
+			return args[this.lastToggle].apply( this, arguments ) || false;
+		});
+	},
+
+	hover: function(fnOver, fnOut) {
+		return this.bind('mouseenter', fnOver).bind('mouseleave', fnOut);
+	},
+	
+	ready: function(fn) {
+		// Attach the listeners
+		bindReady();
+
+		// If the DOM is already ready
+		if ( jQuery.isReady )
+			// Execute the function immediately
+			fn.call( document, jQuery );
+			
+		// Otherwise, remember the function for later
+		else
+			// Add the function to the wait list
+			jQuery.readyList.push( function() { return fn.call(this, jQuery); } );
+	
+		return this;
+	}
+});
+
+jQuery.extend({
+	isReady: false,
+	readyList: [],
+	// Handle when the DOM is ready
+	ready: function() {
+		// Make sure that the DOM is not already loaded
+		if ( !jQuery.isReady ) {
+			// Remember that the DOM is ready
+			jQuery.isReady = true;
+			
+			// If there are functions bound, to execute
+			if ( jQuery.readyList ) {
+				// Execute all of them
+				jQuery.each( jQuery.readyList, function(){
+					this.apply( document );
+				});
+				
+				// Reset the list of functions
+				jQuery.readyList = null;
+			}
+		
+			// Trigger any bound ready events
+			$(document).triggerHandler("ready");
+		}
+	}
+});
+
+var readyBound = false;
+
+function bindReady(){
+	if ( readyBound ) return;
+	readyBound = true;
+
+	// Mozilla, Opera (see further below for it) and webkit nightlies currently support this event
+	if ( document.addEventListener && !jQuery.browser.opera)
+		// Use the handy event callback
+		document.addEventListener( "DOMContentLoaded", jQuery.ready, false );
+	
+	// If IE is used and is not in a frame
+	// Continually check to see if the document is ready
+	if ( jQuery.browser.msie && window == top ) (function(){
+		if (jQuery.isReady) return;
+		try {
+			// If IE is used, use the trick by Diego Perini
+			// http://javascript.nwbox.com/IEContentLoaded/
+			document.documentElement.doScroll("left");
+		} catch( error ) {
+			setTimeout( arguments.callee, 0 );
+			return;
+		}
+		// and execute any waiting functions
+		jQuery.ready();
+	})();
+
+	if ( jQuery.browser.opera )
+		document.addEventListener( "DOMContentLoaded", function () {
+			if (jQuery.isReady) return;
+			for (var i = 0; i < document.styleSheets.length; i++)
+				if (document.styleSheets[i].disabled) {
+					setTimeout( arguments.callee, 0 );
+					return;
+				}
+			// and execute any waiting functions
+			jQuery.ready();
+		}, false);
+
+	if ( jQuery.browser.safari ) {
+		var numStyles;
+		(function(){
+			if (jQuery.isReady) return;
+			if ( document.readyState != "loaded" && document.readyState != "complete" ) {
+				setTimeout( arguments.callee, 0 );
+				return;
+			}
+			if ( numStyles === undefined )
+				numStyles = jQuery("style, link[rel=stylesheet]").length;
+			if ( document.styleSheets.length != numStyles ) {
+				setTimeout( arguments.callee, 0 );
+				return;
+			}
+			// and execute any waiting functions
+			jQuery.ready();
+		})();
+	}
+
+	// A fallback to window.onload, that will always work
+	jQuery.event.add( window, "load", jQuery.ready );
+}
+
+jQuery.each( ("blur,focus,load,resize,scroll,unload,click,dblclick," +
+	"mousedown,mouseup,mousemove,mouseover,mouseout,change,select," + 
+	"submit,keydown,keypress,keyup,error").split(","), function(i, name){
+	
+	// Handle event binding
+	jQuery.fn[name] = function(fn){
+		return fn ? this.bind(name, fn) : this.trigger(name);
+	};
+});
+
+// Checks if an event happened on an element within another element
+// Used in jQuery.event.special.mouseenter and mouseleave handlers
+var withinElement = function(event, elem) {
+	// Check if mouse(over|out) are still within the same parent element
+	var parent = event.relatedTarget;
+	// Traverse up the tree
+	while ( parent && parent != elem ) try { parent = parent.parentNode } catch(error) { parent = elem; };
+	// Return true if we actually just moused on to a sub-element
+	return parent == elem;
+};
+
+// Prevent memory leaks in IE
+// And prevent errors on refresh with events like mouseover in other browsers
+// Window isn't included so as not to unbind existing unload events
+jQuery(window).bind("unload", function() {
+	jQuery("*").add(document).unbind();
+});
+jQuery.fn.extend({
+	load: function( url, params, callback ) {
+		if ( jQuery.isFunction( url ) )
+			return this.bind("load", url);
+
+		var off = url.indexOf(" ");
+		if ( off >= 0 ) {
+			var selector = url.slice(off, url.length);
+			url = url.slice(0, off);
+		}
+
+		callback = callback || function(){};
+
+		// Default to a GET request
+		var type = "GET";
+
+		// If the second parameter was provided
+		if ( params )
+			// If it's a function
+			if ( jQuery.isFunction( params ) ) {
+				// We assume that it's the callback
+				callback = params;
+				params = null;
+
+			// Otherwise, build a param string
+			} else {
+				params = jQuery.param( params );
+				type = "POST";
+			}
+
+		var self = this;
+
+		// Request the remote document
+		jQuery.ajax({
+			url: url,
+			type: type,
+			dataType: "html",
+			data: params,
+			complete: function(res, status){
+				// If successful, inject the HTML into all the matched elements
+				if ( status == "success" || status == "notmodified" )
+					// See if a selector was specified
+					self.html( selector ?
+						// Create a dummy div to hold the results
+						jQuery("<div/>")
+							// inject the contents of the document in, removing the scripts
+							// to avoid any 'Permission Denied' errors in IE
+							.append(res.responseText.replace(/<script(.|\s)*?\/script>/g, ""))
+
+							// Locate the specified elements
+							.find(selector) :
+
+						// If not, just inject the full result
+						res.responseText );
+
+				self.each( callback, [res.responseText, status, res] );
+			}
+		});
+		return this;
+	},
+
+	serialize: function() {
+		return jQuery.param(this.serializeArray());
+	},
+	serializeArray: function() {
+		return this.map(function(){
+			return jQuery.nodeName(this, "form") ?
+				jQuery.makeArray(this.elements) : this;
+		})
+		.filter(function(){
+			return this.name && !this.disabled && 
+				(this.checked || /select|textarea/i.test(this.nodeName) || 
+					/text|hidden|password/i.test(this.type));
+		})
+		.map(function(i, elem){
+			var val = jQuery(this).val();
+			return val == null ? null :
+				val.constructor == Array ?
+					jQuery.map( val, function(val, i){
+						return {name: elem.name, value: val};
+					}) :
+					{name: elem.name, value: val};
+		}).get();
+	}
+});
+
+// Attach a bunch of functions for handling common AJAX events
+jQuery.each( "ajaxStart,ajaxStop,ajaxComplete,ajaxError,ajaxSuccess,ajaxSend".split(","), function(i,o){
+	jQuery.fn[o] = function(f){
+		return this.bind(o, f);
+	};
+});
+
+var jsc = (new Date).getTime();
+
+jQuery.extend({
+	get: function( url, data, callback, type ) {
+		// shift arguments if data argument was ommited
+		if ( jQuery.isFunction( data ) ) {
+			callback = data;
+			data = null;
+		}
+		
+		return jQuery.ajax({
+			type: "GET",
+			url: url,
+			data: data,
+			success: callback,
+			dataType: type
+		});
+	},
+
+	getScript: function( url, callback ) {
+		return jQuery.get(url, null, callback, "script");
+	},
+
+	getJSON: function( url, data, callback ) {
+		return jQuery.get(url, data, callback, "json");
+	},
+
+	post: function( url, data, callback, type ) {
+		if ( jQuery.isFunction( data ) ) {
+			callback = data;
+			data = {};
+		}
+
+		return jQuery.ajax({
+			type: "POST",
+			url: url,
+			data: data,
+			success: callback,
+			dataType: type
+		});
+	},
+
+	ajaxSetup: function( settings ) {
+		jQuery.extend( jQuery.ajaxSettings, settings );
+	},
+
+	ajaxSettings: {
+		global: true,
+		type: "GET",
+		timeout: 0,
+		contentType: "application/x-www-form-urlencoded",
+		processData: true,
+		async: true,
+		data: null
+	},
+	
+	// Last-Modified header cache for next request
+	lastModified: {},
+
+	ajax: function( s ) {
+		var jsonp, jsre = /=\?(&|$)/g, status, data;
+
+		// Extend the settings, but re-extend 's' so that it can be
+		// checked again later (in the test suite, specifically)
+		s = jQuery.extend(true, s, jQuery.extend(true, {}, jQuery.ajaxSettings, s));
+
+		// convert data if not already a string
+		if ( s.data && s.processData && typeof s.data != "string" )
+			s.data = jQuery.param(s.data);
+
+		// Handle JSONP Parameter Callbacks
+		if ( s.dataType == "jsonp" ) {
+			if ( s.type.toLowerCase() == "get" ) {
+				if ( !s.url.match(jsre) )
+					s.url += (s.url.match(/\?/) ? "&" : "?") + (s.jsonp || "callback") + "=?";
+			} else if ( !s.data || !s.data.match(jsre) )
+				s.data = (s.data ? s.data + "&" : "") + (s.jsonp || "callback") + "=?";
+			s.dataType = "json";
+		}
+
+		// Build temporary JSONP function
+		if ( s.dataType == "json" && (s.data && s.data.match(jsre) || s.url.match(jsre)) ) {
+			jsonp = "jsonp" + jsc++;
+
+			// Replace the =? sequence both in the query string and the data
+			if ( s.data )
+				s.data = (s.data + "").replace(jsre, "=" + jsonp + "$1");
+			s.url = s.url.replace(jsre, "=" + jsonp + "$1");
+
+			// We need to make sure
+			// that a JSONP style response is executed properly
+			s.dataType = "script";
+
+			// Handle JSONP-style loading
+			window[ jsonp ] = function(tmp){
+				data = tmp;
+				success();
+				complete();
+				// Garbage collect
+				window[ jsonp ] = undefined;
+				try{ delete window[ jsonp ]; } catch(e){}
+				if ( head )
+					head.removeChild( script );
+			};
+		}
+
+		if ( s.dataType == "script" && s.cache == null )
+			s.cache = false;
+
+		if ( s.cache === false && s.type.toLowerCase() == "get" ) {
+			var ts = (new Date()).getTime();
+			// try replacing _= if it is there
+			var ret = s.url.replace(/(\?|&)_=.*?(&|$)/, "$1_=" + ts + "$2");
+			// if nothing was replaced, add timestamp to the end
+			s.url = ret + ((ret == s.url) ? (s.url.match(/\?/) ? "&" : "?") + "_=" + ts : "");
+		}
+
+		// If data is available, append data to url for get requests
+		if ( s.data && s.type.toLowerCase() == "get" ) {
+			s.url += (s.url.match(/\?/) ? "&" : "?") + s.data;
+
+			// IE likes to send both get and post data, prevent this
+			s.data = null;
+		}
+
+		// Watch for a new set of requests
+		if ( s.global && ! jQuery.active++ )
+			jQuery.event.trigger( "ajaxStart" );
+
+		// If we're requesting a remote document
+		// and trying to load JSON or Script with a GET
+		if ( (!s.url.indexOf("http") || !s.url.indexOf("//")) && ( s.dataType == "script" || s.dataType =="json" ) && s.type.toLowerCase() == "get" ) {
+			var head = document.getElementsByTagName("head")[0];
+			var script = document.createElement("script");
+			script.src = s.url;
+			if (s.scriptCharset)
+				script.charset = s.scriptCharset;
+
+			// Handle Script loading
+			if ( !jsonp ) {
+				var done = false;
+
+				// Attach handlers for all browsers
+				script.onload = script.onreadystatechange = function(){
+					if ( !done && (!this.readyState || 
+							this.readyState == "loaded" || this.readyState == "complete") ) {
+						done = true;
+						success();
+						complete();
+						head.removeChild( script );
+					}
+				};
+			}
+
+			head.appendChild(script);
+
+			// We handle everything using the script element injection
+			return undefined;
+		}
+
+		var requestDone = false;
+
+		// Create the request object; Microsoft failed to properly
+		// implement the XMLHttpRequest in IE7, so we use the ActiveXObject when it is available
+		var xml = window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
+
+		// Open the socket
+		xml.open(s.type, s.url, s.async);
+
+		// Need an extra try/catch for cross domain requests in Firefox 3
+		try {
+			// Set the correct header, if data is being sent
+			if ( s.data )
+				xml.setRequestHeader("Content-Type", s.contentType);
+
+			// Set the If-Modified-Since header, if ifModified mode.
+			if ( s.ifModified )
+				xml.setRequestHeader("If-Modified-Since",
+					jQuery.lastModified[s.url] || "Thu, 01 Jan 1970 00:00:00 GMT" );
+
+			// Set header so the called script knows that it's an XMLHttpRequest
+			xml.setRequestHeader("X-Requested-With", "XMLHttpRequest");
+		} catch(e){}
+
+		// Allow custom headers/mimetypes
+		if ( s.beforeSend )
+			s.beforeSend(xml);
+			
+		if ( s.global )
+			jQuery.event.trigger("ajaxSend", [xml, s]);
+
+		// Wait for a response to come back
+		var onreadystatechange = function(isTimeout){
+			// The transfer is complete and the data is available, or the request timed out
+			if ( !requestDone && xml && (xml.readyState == 4 || isTimeout == "timeout") ) {
+				requestDone = true;
+				
+				// clear poll interval
+				if (ival) {
+					clearInterval(ival);
+					ival = null;
+				}
+				
+				status = isTimeout == "timeout" && "timeout" ||
+					!jQuery.httpSuccess( xml ) && "error" ||
+					s.ifModified && jQuery.httpNotModified( xml, s.url ) && "notmodified" ||
+					"success";
+
+				if ( status == "success" ) {
+					// Watch for, and catch, XML document parse errors
+					try {
+						// process the data (runs the xml through httpData regardless of callback)
+						data = jQuery.httpData( xml, s.dataType );
+					} catch(e) {
+						status = "parsererror";
+					}
+				}
+
+				// Make sure that the request was successful or notmodified
+				if ( status == "success" ) {
+					// Cache Last-Modified header, if ifModified mode.
+					var modRes;
+					try {
+						modRes = xml.getResponseHeader("Last-Modified");
+					} catch(e) {} // swallow exception thrown by FF if header is not available
+	
+					if ( s.ifModified && modRes )
+						jQuery.lastModified[s.url] = modRes;
+
+					// JSONP handles its own success callback
+					if ( !jsonp )
+						success();	
+				} else
+					jQuery.handleError(s, xml, status);
+
+				// Fire the complete handlers
+				complete();
+
+				// Stop memory leaks
+				if ( s.async )
+					xml = null;
+			}
+		};
+		
+		if ( s.async ) {
+			// don't attach the handler to the request, just poll it instead
+			var ival = setInterval(onreadystatechange, 13); 
+
+			// Timeout checker
+			if ( s.timeout > 0 )
+				setTimeout(function(){
+					// Check to see if the request is still happening
+					if ( xml ) {
+						// Cancel the request
+						xml.abort();
+	
+						if( !requestDone )
+							onreadystatechange( "timeout" );
+					}
+				}, s.timeout);
+		}
+			
+		// Send the data
+		try {
+			xml.send(s.data);
+		} catch(e) {
+			jQuery.handleError(s, xml, null, e);
+		}
+		
+		// firefox 1.5 doesn't fire statechange for sync requests
+		if ( !s.async )
+			onreadystatechange();
+
+		function success(){
+			// If a local callback was specified, fire it and pass it the data
+			if ( s.success )
+				s.success( data, status );
+
+			// Fire the global callback
+			if ( s.global )
+				jQuery.event.trigger( "ajaxSuccess", [xml, s] );
+		}
+
+		function complete(){
+			// Process result
+			if ( s.complete )
+				s.complete(xml, status);
+
+			// The request was completed
+			if ( s.global )
+				jQuery.event.trigger( "ajaxComplete", [xml, s] );
+
+			// Handle the global AJAX counter
+			if ( s.global && ! --jQuery.active )
+				jQuery.event.trigger( "ajaxStop" );
+		}
+		
+		// return XMLHttpRequest to allow aborting the request etc.
+		return xml;
+	},
+
+	handleError: function( s, xml, status, e ) {
+		// If a local callback was specified, fire it
+		if ( s.error ) s.error( xml, status, e );
+
+		// Fire the global callback
+		if ( s.global )
+			jQuery.event.trigger( "ajaxError", [xml, s, e] );
+	},
+
+	// Counter for holding the number of active queries
+	active: 0,
+
+	// Determines if an XMLHttpRequest was successful or not
+	httpSuccess: function( r ) {
+		try {
+			// IE error sometimes returns 1223 when it should be 204 so treat it as success, see #1450
+			return !r.status && location.protocol == "file:" ||
+				( r.status >= 200 && r.status < 300 ) || r.status == 304 || r.status == 1223 ||
+				jQuery.browser.safari && r.status == undefined;
+		} catch(e){}
+		return false;
+	},
+
+	// Determines if an XMLHttpRequest returns NotModified
+	httpNotModified: function( xml, url ) {
+		try {
+			var xmlRes = xml.getResponseHeader("Last-Modified");
+
+			// Firefox always returns 200. check Last-Modified date
+			return xml.status == 304 || xmlRes == jQuery.lastModified[url] ||
+				jQuery.browser.safari && xml.status == undefined;
+		} catch(e){}
+		return false;
+	},
+
+	httpData: function( r, type ) {
+		var ct = r.getResponseHeader("content-type");
+		var xml = type == "xml" || !type && ct && ct.indexOf("xml") >= 0;
+		var data = xml ? r.responseXML : r.responseText;
+
+		if ( xml && data.documentElement.tagName == "parsererror" )
+			throw "parsererror";
+
+		// If the type is "script", eval it in global context
+		if ( type == "script" )
+			jQuery.globalEval( data );
+
+		// Get the JavaScript object, if JSON is used.
+		if ( type == "json" )
+			data = eval("(" + data + ")");
+
+		return data;
+	},
+
+	// Serialize an array of form elements or a set of
+	// key/values into a query string
+	param: function( a ) {
+		var s = [];
+
+		// If an array was passed in, assume that it is an array
+		// of form elements
+		if ( a.constructor == Array || a.jquery )
+			// Serialize the form elements
+			jQuery.each( a, function(){
+				s.push( encodeURIComponent(this.name) + "=" + encodeURIComponent( this.value ) );
+			});
+
+		// Otherwise, assume that it's an object of key/value pairs
+		else
+			// Serialize the key/values
+			for ( var j in a )
+				// If the value is an array then the key names need to be repeated
+				if ( a[j] && a[j].constructor == Array )
+					jQuery.each( a[j], function(){
+						s.push( encodeURIComponent(j) + "=" + encodeURIComponent( this ) );
+					});
+				else
+					s.push( encodeURIComponent(j) + "=" + encodeURIComponent( a[j] ) );
+
+		// Return the resulting serialization
+		return s.join("&").replace(/%20/g, "+");
+	}
+
+});
+jQuery.fn.extend({
+	show: function(speed,callback){
+		return speed ?
+			this.animate({
+				height: "show", width: "show", opacity: "show"
+			}, speed, callback) :
+			
+			this.filter(":hidden").each(function(){
+				this.style.display = this.oldblock || "";
+				if ( jQuery.css(this,"display") == "none" ) {
+					var elem = jQuery("<" + this.tagName + " />").appendTo("body");
+					this.style.display = elem.css("display");
+					elem.remove();
+				}
+			}).end();
+	},
+	
+	hide: function(speed,callback){
+		return speed ?
+			this.animate({
+				height: "hide", width: "hide", opacity: "hide"
+			}, speed, callback) :
+			
+			this.filter(":visible").each(function(){
+				this.oldblock = this.oldblock || jQuery.css(this,"display");
+				this.style.display = "none";
+			}).end();
+	},
+
+	// Save the old toggle function
+	_toggle: jQuery.fn.toggle,
+	
+	toggle: function( fn, fn2 ){
+		return jQuery.isFunction(fn) && jQuery.isFunction(fn2) ?
+			this._toggle( fn, fn2 ) :
+			fn ?
+				this.animate({
+					height: "toggle", width: "toggle", opacity: "toggle"
+				}, fn, fn2) :
+				this.each(function(){
+					jQuery(this)[ jQuery(this).is(":hidden") ? "show" : "hide" ]();
+				});
+	},
+	
+	slideDown: function(speed,callback){
+		return this.animate({height: "show"}, speed, callback);
+	},
+	
+	slideUp: function(speed,callback){
+		return this.animate({height: "hide"}, speed, callback);
+	},
+
+	slideToggle: function(speed, callback){
+		return this.animate({height: "toggle"}, speed, callback);
+	},
+	
+	fadeIn: function(speed, callback){
+		return this.animate({opacity: "show"}, speed, callback);
+	},
+	
+	fadeOut: function(speed, callback){
+		return this.animate({opacity: "hide"}, speed, callback);
+	},
+	
+	fadeTo: function(speed,to,callback){
+		return this.animate({opacity: to}, speed, callback);
+	},
+	
+	animate: function( prop, speed, easing, callback ) {
+		var optall = jQuery.speed(speed, easing, callback);
+
+		return this[ optall.queue === false ? "each" : "queue" ](function(){
+			if ( this.nodeType != 1)
+				return false;
+
+			var opt = jQuery.extend({}, optall);
+			var hidden = jQuery(this).is(":hidden"), self = this;
+			
+			for ( var p in prop ) {
+				if ( prop[p] == "hide" && hidden || prop[p] == "show" && !hidden )
+					return jQuery.isFunction(opt.complete) && opt.complete.apply(this);
+
+				if ( p == "height" || p == "width" ) {
+					// Store display property
+					opt.display = jQuery.css(this, "display");
+
+					// Make sure that nothing sneaks out
+					opt.overflow = this.style.overflow;
+				}
+			}
+
+			if ( opt.overflow != null )
+				this.style.overflow = "hidden";
+
+			opt.curAnim = jQuery.extend({}, prop);
+			
+			jQuery.each( prop, function(name, val){
+				var e = new jQuery.fx( self, opt, name );
+
+				if ( /toggle|show|hide/.test(val) )
+					e[ val == "toggle" ? hidden ? "show" : "hide" : val ]( prop );
+				else {
+					var parts = val.toString().match(/^([+-]=)?([\d+-.]+)(.*)$/),
+						start = e.cur(true) || 0;
+
+					if ( parts ) {
+						var end = parseFloat(parts[2]),
+							unit = parts[3] || "px";
+
+						// We need to compute starting value
+						if ( unit != "px" ) {
+							self.style[ name ] = (end || 1) + unit;
+							start = ((end || 1) / e.cur(true)) * start;
+							self.style[ name ] = start + unit;
+						}
+
+						// If a +=/-= token was provided, we're doing a relative animation
+						if ( parts[1] )
+							end = ((parts[1] == "-=" ? -1 : 1) * end) + start;
+
+						e.custom( start, end, unit );
+					} else
+						e.custom( start, val, "" );
+				}
+			});
+
+			// For JS strict compliance
+			return true;
+		});
+	},
+	
+	queue: function(type, fn){
+		if ( jQuery.isFunction(type) || ( type && type.constructor == Array )) {
+			fn = type;
+			type = "fx";
+		}
+
+		if ( !type || (typeof type == "string" && !fn) )
+			return queue( this[0], type );
+
+		return this.each(function(){
+			if ( this.nodeType != 1)
+				return;
+
+			if ( fn.constructor == Array )
+				queue(this, type, fn);
+			else {
+				queue(this, type).push( fn );
+			
+				if ( queue(this, type).length == 1 )
+					fn.apply(this);
+			}
+		});
+	},
+
+	stop: function(clearQueue, gotoEnd){
+		var timers = jQuery.timers;
+
+		if (clearQueue)
+			this.queue([]);
+
+		this.each(function(){
+			// go in reverse order so anything added to the queue during the loop is ignored
+			for ( var i = timers.length - 1; i >= 0; i-- )
+				if ( timers[i].elem == this ) {
+					if (gotoEnd)
+						// force the next step to be the last
+						timers[i](true);
+					timers.splice(i, 1);
+				}
+		});
+
+		// start the next in the queue if the last step wasn't forced
+		if (!gotoEnd)
+			this.dequeue();
+
+		return this;
+	}
+
+});
+
+var queue = function( elem, type, array ) {
+	if ( !elem )
+		return undefined;
+
+	type = type || "fx";
+
+	var q = jQuery.data( elem, type + "queue" );
+
+	if ( !q || array )
+		q = jQuery.data( elem, type + "queue", 
+			array ? jQuery.makeArray(array) : [] );
+
+	return q;
+};
+
+jQuery.fn.dequeue = function(type){
+	type = type || "fx";
+
+	return this.each(function(){
+		var q = queue(this, type);
+
+		q.shift();
+
+		if ( q.length )
+			q[0].apply( this );
+	});
+};
+
+jQuery.extend({
+	
+	speed: function(speed, easing, fn) {
+		var opt = speed && speed.constructor == Object ? speed : {
+			complete: fn || !fn && easing || 
+				jQuery.isFunction( speed ) && speed,
+			duration: speed,
+			easing: fn && easing || easing && easing.constructor != Function && easing
+		};
+
+		opt.duration = (opt.duration && opt.duration.constructor == Number ? 
+			opt.duration : 
+			{ slow: 600, fast: 200 }[opt.duration]) || 400;
+	
+		// Queueing
+		opt.old = opt.complete;
+		opt.complete = function(){
+			if ( opt.queue !== false )
+				jQuery(this).dequeue();
+			if ( jQuery.isFunction( opt.old ) )
+				opt.old.apply( this );
+		};
+	
+		return opt;
+	},
+	
+	easing: {
+		linear: function( p, n, firstNum, diff ) {
+			return firstNum + diff * p;
+		},
+		swing: function( p, n, firstNum, diff ) {
+			return ((-Math.cos(p*Math.PI)/2) + 0.5) * diff + firstNum;
+		}
+	},
+	
+	timers: [],
+	timerId: null,
+
+	fx: function( elem, options, prop ){
+		this.options = options;
+		this.elem = elem;
+		this.prop = prop;
+
+		if ( !options.orig )
+			options.orig = {};
+	}
+
+});
+
+jQuery.fx.prototype = {
+
+	// Simple function for setting a style value
+	update: function(){
+		if ( this.options.step )
+			this.options.step.apply( this.elem, [ this.now, this ] );
+
+		(jQuery.fx.step[this.prop] || jQuery.fx.step._default)( this );
+
+		// Set display property to block for height/width animations
+		if ( this.prop == "height" || this.prop == "width" )
+			this.elem.style.display = "block";
+	},
+
+	// Get the current size
+	cur: function(force){
+		if ( this.elem[this.prop] != null && this.elem.style[this.prop] == null )
+			return this.elem[ this.prop ];
+
+		var r = parseFloat(jQuery.css(this.elem, this.prop, force));
+		return r && r > -10000 ? r : parseFloat(jQuery.curCSS(this.elem, this.prop)) || 0;
+	},
+
+	// Start an animation from one number to another
+	custom: function(from, to, unit){
+		this.startTime = (new Date()).getTime();
+		this.start = from;
+		this.end = to;
+		this.unit = unit || this.unit || "px";
+		this.now = this.start;
+		this.pos = this.state = 0;
+		this.update();
+
+		var self = this;
+		function t(gotoEnd){
+			return self.step(gotoEnd);
+		}
+
+		t.elem = this.elem;
+
+		jQuery.timers.push(t);
+
+		if ( jQuery.timerId == null ) {
+			jQuery.timerId = setInterval(function(){
+				var timers = jQuery.timers;
+				
+				for ( var i = 0; i < timers.length; i++ )
+					if ( !timers[i]() )
+						timers.splice(i--, 1);
+
+				if ( !timers.length ) {
+					clearInterval( jQuery.timerId );
+					jQuery.timerId = null;
+				}
+			}, 13);
+		}
+	},
+
+	// Simple 'show' function
+	show: function(){
+		// Remember where we started, so that we can go back to it later
+		this.options.orig[this.prop] = jQuery.attr( this.elem.style, this.prop );
+		this.options.show = true;
+
+		// Begin the animation
+		this.custom(0, this.cur());
+
+		// Make sure that we start at a small width/height to avoid any
+		// flash of content
+		if ( this.prop == "width" || this.prop == "height" )
+			this.elem.style[this.prop] = "1px";
+		
+		// Start by showing the element
+		jQuery(this.elem).show();
+	},
+
+	// Simple 'hide' function
+	hide: function(){
+		// Remember where we started, so that we can go back to it later
+		this.options.orig[this.prop] = jQuery.attr( this.elem.style, this.prop );
+		this.options.hide = true;
+
+		// Begin the animation
+		this.custom(this.cur(), 0);
+	},
+
+	// Each step of an animation
+	step: function(gotoEnd){
+		var t = (new Date()).getTime();
+
+		if ( gotoEnd || t > this.options.duration + this.startTime ) {
+			this.now = this.end;
+			this.pos = this.state = 1;
+			this.update();
+
+			this.options.curAnim[ this.prop ] = true;
+
+			var done = true;
+			for ( var i in this.options.curAnim )
+				if ( this.options.curAnim[i] !== true )
+					done = false;
+
+			if ( done ) {
+				if ( this.options.display != null ) {
+					// Reset the overflow
+					this.elem.style.overflow = this.options.overflow;
+				
+					// Reset the display
+					this.elem.style.display = this.options.display;
+					if ( jQuery.css(this.elem, "display") == "none" )
+						this.elem.style.display = "block";
+				}
+
+				// Hide the element if the "hide" operation was done
+				if ( this.options.hide )
+					this.elem.style.display = "none";
+
+				// Reset the properties, if the item has been hidden or shown
+				if ( this.options.hide || this.options.show )
+					for ( var p in this.options.curAnim )
+						jQuery.attr(this.elem.style, p, this.options.orig[p]);
+			}
+
+			// If a callback was provided, execute it
+			if ( done && jQuery.isFunction( this.options.complete ) )
+				// Execute the complete function
+				this.options.complete.apply( this.elem );
+
+			return false;
+		} else {
+			var n = t - this.startTime;
+			this.state = n / this.options.duration;
+
+			// Perform the easing function, defaults to swing
+			this.pos = jQuery.easing[this.options.easing || (jQuery.easing.swing ? "swing" : "linear")](this.state, n, 0, 1, this.options.duration);
+			this.now = this.start + ((this.end - this.start) * this.pos);
+
+			// Perform the next step of the animation
+			this.update();
+		}
+
+		return true;
+	}
+
+};
+
+jQuery.fx.step = {
+	scrollLeft: function(fx){
+		fx.elem.scrollLeft = fx.now;
+	},
+
+	scrollTop: function(fx){
+		fx.elem.scrollTop = fx.now;
+	},
+
+	opacity: function(fx){
+		jQuery.attr(fx.elem.style, "opacity", fx.now);
+	},
+
+	_default: function(fx){
+		fx.elem.style[ fx.prop ] = fx.now + fx.unit;
+	}
+};
+// The Offset Method
+// Originally By Brandon Aaron, part of the Dimension Plugin
+// http://jquery.com/plugins/project/dimensions
+jQuery.fn.offset = function() {
+	var left = 0, top = 0, elem = this[0], results;
+	
+	if ( elem ) with ( jQuery.browser ) {
+		var parent       = elem.parentNode, 
+		    offsetChild  = elem,
+		    offsetParent = elem.offsetParent, 
+		    doc          = elem.ownerDocument,
+		    safari2      = safari && parseInt(version) < 522,
+		    fixed        = jQuery.css(elem, "position") == "fixed";
+	
+		// Use getBoundingClientRect if available
+		if ( elem.getBoundingClientRect ) {
+			var box = elem.getBoundingClientRect();
+		
+			// Add the document scroll offsets
+			add(box.left + Math.max(doc.documentElement.scrollLeft, doc.body.scrollLeft),
+				box.top  + Math.max(doc.documentElement.scrollTop,  doc.body.scrollTop));
+		
+			// IE adds the HTML element's border, by default it is medium which is 2px
+			// IE 6 and 7 quirks mode the border width is overwritable by the following css html { border: 0; }
+			// IE 7 standards mode, the border is always 2px
+			// This border/offset is typically represented by the clientLeft and clientTop properties
+			// However, in IE6 and 7 quirks mode the clientLeft and clientTop properties are not updated when overwriting it via CSS
+			// Therefore this method will be off by 2px in IE while in quirksmode
+			add( -doc.documentElement.clientLeft, -doc.documentElement.clientTop );
+	
+		// Otherwise loop through the offsetParents and parentNodes
+		} else {
+		
+			// Initial element offsets
+			add( elem.offsetLeft, elem.offsetTop );
+			
+			// Get parent offsets
+			while ( offsetParent ) {
+				// Add offsetParent offsets
+				add( offsetParent.offsetLeft, offsetParent.offsetTop );
+			
+				// Mozilla and Safari > 2 does not include the border on offset parents
+				// However Mozilla adds the border for table or table cells
+				if ( mozilla && !/^t(able|d|h)$/i.test(offsetParent.tagName) || safari && !safari2 )
+					border( offsetParent );
+					
+				// Add the document scroll offsets if position is fixed on any offsetParent
+				if ( !fixed && jQuery.css(offsetParent, "position") == "fixed" )
+					fixed = true;
+			
+				// Set offsetChild to previous offsetParent unless it is the body element
+				offsetChild  = /^body$/i.test(offsetParent.tagName) ? offsetChild : offsetParent;
+				// Get next offsetParent
+				offsetParent = offsetParent.offsetParent;
+			}
+		
+			// Get parent scroll offsets
+			while ( parent && parent.tagName && !/^body|html$/i.test(parent.tagName) ) {
+				// Remove parent scroll UNLESS that parent is inline or a table to work around Opera inline/table scrollLeft/Top bug
+				if ( !/^inline|table.*$/i.test(jQuery.css(parent, "display")) )
+					// Subtract parent scroll offsets
+					add( -parent.scrollLeft, -parent.scrollTop );
+			
+				// Mozilla does not add the border for a parent that has overflow != visible
+				if ( mozilla && jQuery.css(parent, "overflow") != "visible" )
+					border( parent );
+			
+				// Get next parent
+				parent = parent.parentNode;
+			}
+		
+			// Safari <= 2 doubles body offsets with a fixed position element/offsetParent or absolutely positioned offsetChild
+			// Mozilla doubles body offsets with a non-absolutely positioned offsetChild
+			if ( (safari2 && (fixed || jQuery.css(offsetChild, "position") == "absolute")) || 
+				(mozilla && jQuery.css(offsetChild, "position") != "absolute") )
+					add( -doc.body.offsetLeft, -doc.body.offsetTop );
+			
+			// Add the document scroll offsets if position is fixed
+			if ( fixed )
+				add(Math.max(doc.documentElement.scrollLeft, doc.body.scrollLeft),
+					Math.max(doc.documentElement.scrollTop,  doc.body.scrollTop));
+		}
+
+		// Return an object with top and left properties
+		results = { top: top, left: left };
+	}
+
+	function border(elem) {
+		add( jQuery.curCSS(elem, "borderLeftWidth", true), jQuery.curCSS(elem, "borderTopWidth", true) );
+	}
+
+	function add(l, t) {
+		left += parseInt(l) || 0;
+		top += parseInt(t) || 0;
+	}
+
+	return results;
+};
+})();

+ 68 - 0
vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/app/js/jquery.treeview.css

@@ -0,0 +1,68 @@
+.treeview, .treeview ul { 
+	padding: 0;
+	margin: 0;
+	list-style: none;
+}
+
+.treeview ul {
+	background-color: white;
+	margin-top: 4px;
+}
+
+.treeview .hitarea {
+	background: url(images/treeview-default.gif) -64px -25px no-repeat;
+	height: 16px;
+	width: 16px;
+	margin-left: -16px;
+	float: left;
+	cursor: pointer;
+}
+/* fix for IE6 */
+* html .hitarea {
+	display: inline;
+	float:none;
+}
+
+.treeview li { 
+	margin: 0;
+	padding: 3px 0pt 3px 16px;
+}
+
+.treeview a.selected {
+	background-color: #eee;
+}
+
+#treecontrol { margin: 1em 0; display: none; }
+
+.treeview .hover { color: red; cursor: pointer; }
+
+.treeview li { background: url(images/treeview-default-line.gif) 0 0 no-repeat; }
+.treeview li.collapsable, .treeview li.expandable { background-position: 0 -176px; }
+
+.treeview .expandable-hitarea { background-position: -80px -3px; }
+
+.treeview li.last { background-position: 0 -1766px }
+.treeview li.lastCollapsable, .treeview li.lastExpandable { background-image: url(images/treeview-default.gif); }  
+.treeview li.lastCollapsable { background-position: 0 -111px }
+.treeview li.lastExpandable { background-position: -32px -67px }
+
+.treeview div.lastCollapsable-hitarea, .treeview div.lastExpandable-hitarea { background-position: 0; }
+
+.treeview-red li { background-image: url(images/treeview-red-line.gif); }
+.treeview-red .hitarea, .treeview-red li.lastCollapsable, .treeview-red li.lastExpandable { background-image: url(images/treeview-red.gif); } 
+
+.treeview-black li { background-image: url(images/treeview-black-line.gif); }
+.treeview-black .hitarea, .treeview-black li.lastCollapsable, .treeview-black li.lastExpandable { background-image: url(images/treeview-black.gif); }  
+
+.treeview-gray li { background-image: url(images/treeview-gray-line.gif); }
+.treeview-gray .hitarea, .treeview-gray li.lastCollapsable, .treeview-gray li.lastExpandable { background-image: url(images/treeview-gray.gif); } 
+
+.treeview-famfamfam li { background-image: url(images/treeview-famfamfam-line.gif); }
+.treeview-famfamfam .hitarea, .treeview-famfamfam li.lastCollapsable, .treeview-famfamfam li.lastExpandable { background-image: url(images/treeview-famfamfam.gif); } 
+
+
+.filetree li { padding: 3px 0 2px 16px; }
+.filetree span.folder, .filetree span.file { padding: 1px 0 1px 16px; display: block; }
+.filetree span.folder { background: url(images/folder.gif) 0 0 no-repeat; }
+.filetree li.expandable span.folder { background: url(images/folder-closed.gif) 0 0 no-repeat; }
+.filetree span.file { background: url(images/file.gif) 0 0 no-repeat; }

+ 251 - 0
vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/app/js/jquery.treeview.js

@@ -0,0 +1,251 @@
+/*
+ * Treeview 1.4 - jQuery plugin to hide and show branches of a tree
+ * 
+ * http://bassistance.de/jquery-plugins/jquery-plugin-treeview/
+ * http://docs.jquery.com/Plugins/Treeview
+ *
+ * Copyright (c) 2007 Jörn Zaefferer
+ *
+ * Dual licensed under the MIT and GPL licenses:
+ *   http://www.opensource.org/licenses/mit-license.php
+ *   http://www.gnu.org/licenses/gpl.html
+ *
+ * Revision: $Id: jquery.treeview.js 4684 2008-02-07 19:08:06Z joern.zaefferer $
+ *
+ */
+
+;(function($) {
+
+	$.extend($.fn, {
+		swapClass: function(c1, c2) {
+			var c1Elements = this.filter('.' + c1);
+			this.filter('.' + c2).removeClass(c2).addClass(c1);
+			c1Elements.removeClass(c1).addClass(c2);
+			return this;
+		},
+		replaceClass: function(c1, c2) {
+			return this.filter('.' + c1).removeClass(c1).addClass(c2).end();
+		},
+		hoverClass: function(className) {
+			className = className || "hover";
+			return this.hover(function() {
+				$(this).addClass(className);
+			}, function() {
+				$(this).removeClass(className);
+			});
+		},
+		heightToggle: function(animated, callback) {
+			animated ?
+				this.animate({ height: "toggle" }, animated, callback) :
+				this.each(function(){
+					jQuery(this)[ jQuery(this).is(":hidden") ? "show" : "hide" ]();
+					if(callback)
+						callback.apply(this, arguments);
+				});
+		},
+		heightHide: function(animated, callback) {
+			if (animated) {
+				this.animate({ height: "hide" }, animated, callback);
+			} else {
+				this.hide();
+				if (callback)
+					this.each(callback);				
+			}
+		},
+		prepareBranches: function(settings) {
+			if (!settings.prerendered) {
+				// mark last tree items
+				this.filter(":last-child:not(ul)").addClass(CLASSES.last);
+				// collapse whole tree, or only those marked as closed, anyway except those marked as open
+				this.filter((settings.collapsed ? "" : "." + CLASSES.closed) + ":not(." + CLASSES.open + ")").find(">ul").hide();
+			}
+			// return all items with sublists
+			return this.filter(":has(>ul)");
+		},
+		applyClasses: function(settings, toggler) {
+			this.filter(":has(>ul):not(:has(>a))").find(">span").click(function(event) {
+				toggler.apply($(this).next());
+			}).add( $("a", this) ).hoverClass();
+			
+			if (!settings.prerendered) {
+				// handle closed ones first
+				this.filter(":has(>ul:hidden)")
+						.addClass(CLASSES.expandable)
+						.replaceClass(CLASSES.last, CLASSES.lastExpandable);
+						
+				// handle open ones
+				this.not(":has(>ul:hidden)")
+						.addClass(CLASSES.collapsable)
+						.replaceClass(CLASSES.last, CLASSES.lastCollapsable);
+						
+	            // create hitarea
+				this.prepend("<div class=\"" + CLASSES.hitarea + "\"/>").find("div." + CLASSES.hitarea).each(function() {
+					var classes = "";
+					$.each($(this).parent().attr("class").split(" "), function() {
+						classes += this + "-hitarea ";
+					});
+					$(this).addClass( classes );
+				});
+			}
+			
+			// apply event to hitarea
+			this.find("div." + CLASSES.hitarea).click( toggler );
+		},
+		treeview: function(settings) {
+			
+			settings = $.extend({
+				cookieId: "treeview"
+			}, settings);
+			
+			if (settings.add) {
+				return this.trigger("add", [settings.add]);
+			}
+			
+			if ( settings.toggle ) {
+				var callback = settings.toggle;
+				settings.toggle = function() {
+					return callback.apply($(this).parent()[0], arguments);
+				};
+			}
+		
+			// factory for treecontroller
+			function treeController(tree, control) {
+				// factory for click handlers
+				function handler(filter) {
+					return function() {
+						// reuse toggle event handler, applying the elements to toggle
+						// start searching for all hitareas
+						toggler.apply( $("div." + CLASSES.hitarea, tree).filter(function() {
+							// for plain toggle, no filter is provided, otherwise we need to check the parent element
+							return filter ? $(this).parent("." + filter).length : true;
+						}) );
+						return false;
+					};
+				}
+				// click on first element to collapse tree
+				$("a:eq(0)", control).click( handler(CLASSES.collapsable) );
+				// click on second to expand tree
+				$("a:eq(1)", control).click( handler(CLASSES.expandable) );
+				// click on third to toggle tree
+				$("a:eq(2)", control).click( handler() ); 
+			}
+		
+			// handle toggle event
+			function toggler() {
+				$(this)
+					.parent()
+					// swap classes for hitarea
+					.find(">.hitarea")
+						.swapClass( CLASSES.collapsableHitarea, CLASSES.expandableHitarea )
+						.swapClass( CLASSES.lastCollapsableHitarea, CLASSES.lastExpandableHitarea )
+					.end()
+					// swap classes for parent li
+					.swapClass( CLASSES.collapsable, CLASSES.expandable )
+					.swapClass( CLASSES.lastCollapsable, CLASSES.lastExpandable )
+					// find child lists
+					.find( ">ul" )
+					// toggle them
+					.heightToggle( settings.animated, settings.toggle );
+				if ( settings.unique ) {
+					$(this).parent()
+						.siblings()
+						// swap classes for hitarea
+						.find(">.hitarea")
+							.replaceClass( CLASSES.collapsableHitarea, CLASSES.expandableHitarea )
+							.replaceClass( CLASSES.lastCollapsableHitarea, CLASSES.lastExpandableHitarea )
+						.end()
+						.replaceClass( CLASSES.collapsable, CLASSES.expandable )
+						.replaceClass( CLASSES.lastCollapsable, CLASSES.lastExpandable )
+						.find( ">ul" )
+						.heightHide( settings.animated, settings.toggle );
+				}
+			}
+			
+			function serialize() {
+				function binary(arg) {
+					return arg ? 1 : 0;
+				}
+				var data = [];
+				branches.each(function(i, e) {
+					data[i] = $(e).is(":has(>ul:visible)") ? 1 : 0;
+				});
+				$.cookie(settings.cookieId, data.join("") );
+			}
+			
+			function deserialize() {
+				var stored = $.cookie(settings.cookieId);
+				if ( stored ) {
+					var data = stored.split("");
+					branches.each(function(i, e) {
+						$(e).find(">ul")[ parseInt(data[i]) ? "show" : "hide" ]();
+					});
+				}
+			}
+			
+			// add treeview class to activate styles
+			this.addClass("treeview");
+			
+			// prepare branches and find all tree items with child lists
+			var branches = this.find("li").prepareBranches(settings);
+			
+			switch(settings.persist) {
+			case "cookie":
+				var toggleCallback = settings.toggle;
+				settings.toggle = function() {
+					serialize();
+					if (toggleCallback) {
+						toggleCallback.apply(this, arguments);
+					}
+				};
+				deserialize();
+				break;
+			case "location":
+				var current = this.find("a").filter(function() { return this.href.toLowerCase() == location.href.toLowerCase(); });
+				if ( current.length ) {
+					current.addClass("selected").parents("ul, li").add( current.next() ).show();
+				}
+				break;
+			}
+			
+			branches.applyClasses(settings, toggler);
+				
+			// if control option is set, create the treecontroller and show it
+			if ( settings.control ) {
+				treeController(this, settings.control);
+				$(settings.control).show();
+			}
+			
+			return this.bind("add", function(event, branches) {
+				$(branches).prev()
+					.removeClass(CLASSES.last)
+					.removeClass(CLASSES.lastCollapsable)
+					.removeClass(CLASSES.lastExpandable)
+				.find(">.hitarea")
+					.removeClass(CLASSES.lastCollapsableHitarea)
+					.removeClass(CLASSES.lastExpandableHitarea);
+				$(branches).find("li").andSelf().prepareBranches(settings).applyClasses(settings, toggler);
+			});
+		}
+	});
+	
+	// classes used by the plugin
+	// need to be styled via external stylesheet, see first example
+	var CLASSES = $.fn.treeview.classes = {
+		open: "open",
+		closed: "closed",
+		expandable: "expandable",
+		expandableHitarea: "expandable-hitarea",
+		lastExpandableHitarea: "lastExpandable-hitarea",
+		collapsable: "collapsable",
+		collapsableHitarea: "collapsable-hitarea",
+		lastCollapsableHitarea: "lastCollapsable-hitarea",
+		lastCollapsable: "lastCollapsable",
+		lastExpandable: "lastExpandable",
+		last: "last",
+		hitarea: "hitarea"
+	};
+	
+	// provide backwards compability
+	$.fn.Treeview = $.fn.treeview;
+	
+})(jQuery);

+ 24 - 0
vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/app/js/screen.css

@@ -0,0 +1,24 @@
+html, body {height:100%; margin: 0; padding: 0; }
+
+html>body {
+	font-size: 16px; 
+	font-size: 68.75%;
+} /* Reset Base Font Size */
+
+body {
+	font-family: Verdana, helvetica, arial, sans-serif;
+	font-size: 68.75%;
+	background: #fff;
+	color: #333;
+}
+
+h1, h2 { font-family: 'trebuchet ms', verdana, arial; padding: 10px; margin: 0 }
+h1 { font-size: large }
+
+#banner { padding: 15px; background-color: #06b; color: white; font-size: large; border-bottom: 1px solid #ccc;
+    background: url(bg.gif) repeat-x; text-align: center }
+#banner a { color: white; }
+
+#main { padding: 1em; }
+
+a img { border: none; }

+ 109 - 0
vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/change_log.txt

@@ -0,0 +1,109 @@
+#$Rev: 194 $
+[Updates - add some ability to insert and create nodes.]
+[1: add ability to search the "noise" array]
+
+[PHP Simple HTML Dom version 1.5 released.]
+1: Memory leak fixed!
+2: Added support for detecting the source html character set.  This is used to convert characters when plaintext is requested.
+3: Other little fixes and features, too numerous to categorize.
+
+[On going]
+1. Error of "file_get_contents()" will be thrown as an exception.
+2. Add flag: LOCK_EX while calling "file_put_contents()". 
+3. Fix the typo of "token_blank_t".
+
+
+[PHP Simple HTML DOM Parser v1.11 is released]
+1. Supports xpath generated from Firebug.
+2. New method "dump" of "simple_html_dom_node".
+3. New attribute "xmltext" of "simple_html_dom_node".
+4. remove preg_quote on selector match function: [attribute*=value];
+5. Element "Comment" will treat as children.
+6. Fixed the problem with <pre>.
+7. Fixed bug #2207477 (does not load some pages properly).
+8. Fixed bug #2315853 (Error with character after < sign).
+
+
+[PHP Simple HTML DOM Parser v1.10 is released]
+1. Negative indexes supports of "find" method, thanks for Vadim Voituk.
+2. Constructor with automatically load contents either text or file/url, thanks for Antcs.
+3. Fully supports wildcard in selectors.
+4. Fixed bug of confusing by the < symbol inside the text.
+5. Fixed bug of dash in selectors.
+6. Fixed bug of <nobr>.
+7. Fixed bug #2155883 (Nested List Parses Incorrectly).
+8. Fixed bug #2155113 (error with unclosed html tags).
+
+
+[PHP Simple HTML DOM Parser v1.00 is released]
+1. New method "getAllAttributes" of "simple_html_dom_node".
+2. Fix the bug of selector in some critical conditions.
+3. Fix the bug of striping php tags.
+4. Fix the bug of remove_noise().
+5. Fix the bug of noise in attributes.
+6. Supports full javascript string in selector: $e->find("a[onclick=alert('hello')]").
+7. Change selector "*=" to case-insentive.
+
+
+[PHP Simple HTML DOM Parser v0.99 is released]
+1. Performance turning (boost 10%).
+2. Memory requirement reduce 25%.
+3. Change function name from "file_get_dom()" to "file_get_html()".
+4. Change function name from "str_get_dom()" to "str_get_html()".
+5. Fixed bug #2011286 (Error with unclosed html tags).
+6. Fixed bug #2012551 (Error parsing divs).
+7. Fixed bug #2020924 (Error for missed tag.).
+8. Fixed bug (problem with <body> tag's innertext).
+
+
+[PHP Simple HTML DOM Parser v0.98 is released]
+1. Performance turning (boost 20%).
+2. Supports "multiple class" selector feature: <div class="a b c"></div>.
+3. New "callback function" feature.
+4. New "multiple selectors" feature: $dom->find('p,a,b');
+5. New examples.
+6. Supports extract contents from HTML features:  $dom->plaintext;
+7. Fix the bug of $dom->clear().
+8. Fix the bug of text nodes' innertext.
+9. Fix the bug of comment nodes' innertext.
+10. Fix the bug of decendent selector with optional tags.
+11. Change simple_html_dom_node method name from "text()" to "makeup()". 
+
+
+[PHP Simple HTML DOM Parser v0.97 is released]
+1. Important!! file and class name changed (html_dom_parser->simple_html_dom)!
+2. Important!! ($dom->save_file) will not support anymore.
+3. New node type "comment" (eg. $dom->find('comment')).
+4. Add self-closing tags: 'base', 'spacer'.
+5. Fix the bug of outertext (th).
+6. Fix the bug of regular expression escaping chars ($dom->find).
+7. Fix the bug while line-breaker and "\t" in tags.
+8. Remove example "example_customize_parser.php".
+9. New example "simple_html_dom_utility.php".
+
+
+[PHP Simple HTML DOM Parser v0.96 is released]
+1. (Request #1936000) New DOM operations(first_child, last_child, next_sibling, previous_sibling).
+2. New method to remove attribute.
+3. Add the solution while server behind proxy in FAQ (Thanks to Yousuke Shaggy).
+4. Add traverse section in manual.
+5. Now file_get_dom supports full file_get_contents parameters.
+6. Fix the bug of self-closing tags in the end of file.
+7. Fix the bug of blanks in the end of tag.
+8. Add Reference section in manual.
+#. Fix some typo of testcase.
+
+
+[PHP Simple HTML DOM Parser v0.95 is released]
+1. New attribute filters (Thanks to Yousuke Kumakura).
+2. Fix the bug of optional-closing tags.
+3. Fix the bug of parsing the line break next to the tag's name.
+4. Supports tag name with namespace.
+#. Refine structure of testcase.
+
+
+[PHP Simple HTML DOM Parser v0.94 is released]
+1. Stop infinity loop while tthe source content is BAD HTML.
+2. Fix the bug of adding new attributes to self closing tags.
+3. Fix the bug of customize parser without $dom->remove_noise();
+4. Add FAQ section in manual.

+ 54 - 0
vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/example/example_advanced_selector.php

@@ -0,0 +1,54 @@
+<?php
+// example of how to use advanced selector features
+include('../simple_html_dom.php');
+
+// -----------------------------------------------------------------------------
+// descendant selector
+$str = <<<HTML
+<div>
+    <div>
+        <div class="foo bar">ok</div>
+    </div>
+</div>
+HTML;
+
+$html = str_get_html($str);
+echo $html->find('div div div', 0)->innertext . '<br>'; // result: "ok"
+
+// -----------------------------------------------------------------------------
+// nested selector
+$str = <<<HTML
+<ul id="ul1">
+    <li>item:<span>1</span></li>
+    <li>item:<span>2</span></li>
+</ul>
+<ul id="ul2">
+    <li>item:<span>3</span></li>
+    <li>item:<span>4</span></li>
+</ul>
+HTML;
+
+$html = str_get_html($str);
+foreach($html->find('ul') as $ul) {
+    foreach($ul->find('li') as $li)
+        echo $li->innertext . '<br>';
+}
+
+// -----------------------------------------------------------------------------
+// parsing checkbox
+$str = <<<HTML
+<form name="form1" method="post" action="">
+    <input type="checkbox" name="checkbox1" value="checkbox1" checked>item1<br>
+    <input type="checkbox" name="checkbox2" value="checkbox2">item2<br>
+    <input type="checkbox" name="checkbox3" value="checkbox3" checked>item3<br>
+</form>
+HTML;
+
+$html = str_get_html($str);
+foreach($html->find('input[type=checkbox]') as $checkbox) {
+    if ($checkbox->checked)
+        echo $checkbox->name . ' is checked<br>';
+    else
+        echo $checkbox->name . ' is not checked<br>';
+}
+?>

+ 37 - 0
vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/example/example_basic_selector.php

@@ -0,0 +1,37 @@
+<?php
+// example of how to use basic selector to retrieve HTML contents
+include('../simple_html_dom.php');
+ 
+// get DOM from URL or file
+$html = file_get_html('http://www.google.com/');
+
+// find all link
+foreach($html->find('a') as $e) 
+    echo $e->href . '<br>';
+
+// find all image
+foreach($html->find('img') as $e)
+    echo $e->src . '<br>';
+
+// find all image with full tag
+foreach($html->find('img') as $e)
+    echo $e->outertext . '<br>';
+
+// find all div tags with id=gbar
+foreach($html->find('div#gbar') as $e)
+    echo $e->innertext . '<br>';
+
+// find all span tags with class=gb1
+foreach($html->find('span.gb1') as $e)
+    echo $e->outertext . '<br>';
+
+// find all td tags with attribite align=center
+foreach($html->find('td[align=center]') as $e)
+    echo $e->innertext . '<br>';
+    
+// extract text from table
+echo $html->find('td[align="center"]', 1)->plaintext.'<br><hr>';
+
+// extract text from HTML
+echo $html->plaintext;
+?>

+ 28 - 0
vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/example/example_callback.php

@@ -0,0 +1,28 @@
+<?php
+include_once('../simple_html_dom.php');
+
+
+// 1. Write a function with parameter "$element"
+function my_callback($element) {
+    if ($element->tag=='input')
+        $element->outertext = 'input';
+
+    if ($element->tag=='img')
+        $element->outertext = 'img';
+
+    if ($element->tag=='a')
+        $element->outertext = 'a';
+}
+
+
+// 2. create HTML Dom
+$html = file_get_html('http://www.google.com/');
+
+
+// 3. Register the callback function with it's function name
+$html->set_callback('my_callback');
+
+
+// 4. Callback function will be invoked while dumping
+echo $html;
+?>

+ 5 - 0
vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/example/example_extract_html.php

@@ -0,0 +1,5 @@
+<?php
+include_once('../simple_html_dom.php');
+
+echo file_get_html('http://www.google.com/')->plaintext;
+?>

+ 18 - 0
vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/example/example_modify_contents.php

@@ -0,0 +1,18 @@
+<?php
+// example of how to modify HTML contents
+include('../simple_html_dom.php');
+
+// get DOM from URL or file
+$html = file_get_html('http://www.google.com/');
+
+// remove all image
+foreach($html->find('img') as $e)
+    $e->outertext = '';
+
+// replace all input
+foreach($html->find('input') as $e)
+    $e->outertext = '[INPUT]';
+
+// dump contents
+echo $html;
+?>

+ 44 - 0
vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/example/scraping/example_scraping_digg.php

@@ -0,0 +1,44 @@
+<?php
+include_once('../../simple_html_dom.php');
+
+function scraping_digg() {
+    // create HTML DOM
+    $html = file_get_html('http://digg.com/');
+
+    // get news block
+    foreach($html->find('div.news-summary') as $article) {
+        // get title
+        $item['title'] = trim($article->find('h3', 0)->plaintext);
+        // get details
+        $item['details'] = trim($article->find('p', 0)->plaintext);
+        // get intro
+        $item['diggs'] = trim($article->find('li a strong', 0)->plaintext);
+
+        $ret[] = $item;
+    }
+    
+    // clean up memory
+    $html->clear();
+    unset($html);
+
+    return $ret;
+}
+
+
+// -----------------------------------------------------------------------------
+// test it!
+
+// "http://digg.com" will check user_agent header...
+ini_set('user_agent', 'My-Application/2.5');
+
+$ret = scraping_digg();
+
+foreach($ret as $v) {
+    echo $v['title'].'<br>';
+    echo '<ul>';
+    echo '<li>'.$v['details'].'</li>';
+    echo '<li>Diggs: '.$v['diggs'].'</li>';
+    echo '</ul>';
+}
+
+?>

+ 51 - 0
vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/example/scraping/example_scraping_imdb.php

@@ -0,0 +1,51 @@
+<?php
+include_once('../../simple_html_dom.php');
+
+function scraping_IMDB($url) {
+    // create HTML DOM
+    $html = file_get_html($url);
+
+    // get title
+    $ret['Title'] = $html->find('title', 0)->innertext;
+
+    // get rating
+    $ret['Rating'] = $html->find('div[class="general rating"] b', 0)->innertext;
+
+    // get overview
+    foreach($html->find('div[class="info"]') as $div) {
+        // skip user comments
+        if($div->find('h5', 0)->innertext=='User Comments:')
+            return $ret;
+
+        $key = '';
+        $val = '';
+
+        foreach($div->find('*') as $node) {
+            if ($node->tag=='h5')
+                $key = $node->plaintext;
+
+            if ($node->tag=='a' && $node->plaintext!='more')
+                $val .= trim(str_replace("\n", '', $node->plaintext));
+
+            if ($node->tag=='text')
+                $val .= trim(str_replace("\n", '', $node->plaintext));
+        }
+
+        $ret[$key] = $val;
+    }
+    
+    // clean up memory
+    $html->clear();
+    unset($html);
+
+    return $ret;
+}
+
+
+// -----------------------------------------------------------------------------
+// test it!
+$ret = scraping_IMDB('http://imdb.com/title/tt0335266/');
+
+foreach($ret as $k=>$v)
+    echo '<strong>'.$k.' </strong>'.$v.'<br>';
+?>

+ 35 - 0
vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/example/scraping/example_scraping_slashdot.php

@@ -0,0 +1,35 @@
+<?php
+include_once('../../simple_html_dom.php');
+
+function scraping_slashdot() {
+    // create HTML DOM
+    $html = file_get_html('http://slashdot.org/');
+
+    // get article block
+    foreach($html->find('div[id^=firehose-]') as $article) {
+        // get title
+        $item['title'] = trim($article->find('a.datitle', 0)->plaintext);
+        // get body
+        $item['body'] = trim($article->find('div.body', 0)->plaintext);
+
+        $ret[] = $item;
+    }
+    
+    // clean up memory
+    $html->clear();
+    unset($html);
+
+    return $ret;
+}
+
+// -----------------------------------------------------------------------------
+// test it!
+$ret = scraping_slashdot();
+
+foreach($ret as $v) {
+    echo $v['title'].'<br>';
+    echo '<ul>';
+    echo '<li>'.$v['body'].'</li>';
+    echo '</ul>';
+}
+?>

+ 35 - 0
vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/example/simple_html_dom_utility.php

@@ -0,0 +1,35 @@
+<?php
+include_once('../simple_html_dom.php');
+
+// -----------------------------------------------------------------------------
+// remove HTML comments
+function html_no_comment($url) {
+    // create HTML DOM
+    $html = file_get_html($url);
+
+    // remove all comment elements
+    foreach($html->find('comment') as $e)
+        $e->outertext = '';
+
+    $ret = $html->save();
+
+    // clean up memory
+    $html->clear();
+    unset($html);
+
+    return $ret;
+}
+
+// -----------------------------------------------------------------------------
+// search elements that contains an specific text
+function find_contains($html, $selector, $keyword, $index=-1) {
+    $ret = array();
+    foreach ($html->find($selector) as $e) {
+        if (strpos($e->innertext, $keyword)!==false)
+            $ret[] = $e;
+    }
+
+    if ($index<0) return $ret;
+    return (isset($ret[$index])) ? $ret[$index] : null;
+}
+?>

+ 113 - 0
vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/manual/css/default.css

@@ -0,0 +1,113 @@
+/*$Rev: 46 $*/
+
+body {
+margin: 0;
+padding: 0;
+font-family: verdana,arial,helvetica,sans-serif;
+font-size: 11px;
+color: #4F5155;
+}
+
+#content {
+margin: 0 20px 0 20px;
+line-height: 16px;
+padding: 0;
+}
+
+h1 {
+font-size: 18px;
+margin: 0;
+padding: 0 0 2px 0;
+background-color: #D0D0D0;
+text-align: center;
+}
+
+h2 {
+background-color: #727EA3;
+border-right: 1px solid #D0D0D0;
+border-bottom: 1px solid #D0D0D0;
+color: #FFFFFF;
+font-size: 14px;
+font-weight: bold;
+margin: 14px 0 4px 0;
+padding: 1px 10px 1px 10px;
+}
+
+ul {
+margin-top: 0;
+margin-bottom: 0;
+line-height:1.5em;
+list-style-image:url(bullet.gif);
+list-style-type:square;
+}
+
+.top {
+font-size: 11px;
+float: right;
+}
+
+.code {
+font-size: 11px;
+font-family: Monaco, Verdana, Sans-serif;
+line-height: 14px;
+background-color: #f6f6f6;
+border-bottom: 1px solid #D0D0D0;
+border-top: 1px solid #A0A0A0;
+border-left: 1px solid #A0A0A0;
+border-right: 1px solid #D0D0D0;
+color: #002166;
+display: block;
+margin: 2px 0 2px 0;
+padding: 2px 10px 2px 10px;
+}
+
+.code A:link {color: #002166; text-decoration: none; font-weight: bold;}
+.code A:visited {color: #002166; text-decoration: none; font-weight: bold;}
+.code A:active {color: #002166; text-decoration: none; font-weight: bold;}
+.code A:hover {color: #0000ff; text-decoration: underline; font-weight: bold;}
+
+.code .keyword {
+color: #007700;
+}
+
+.code .comment {
+font-size: 10px;
+color: #888;
+}
+
+.code .var {
+color: #770000;
+}
+
+th {
+font-family: Lucida Grande, Verdana, Geneva, Sans-serif;
+color: #000000;
+background-color: #CFD4E6;
+margin: 2px 2px 2px 2px;
+padding: 2px 2px 2px 2px;
+font-size: 13px;
+font-weight: normal;
+font-style: normal;
+}
+
+td {
+background-color: #dddddd;
+}
+
+.description {
+font-family: Lucida Grande, Verdana, Geneva, Sans-serif;
+font-size: 11px;
+color: #333;
+text-ident: 30px;
+font-style: normal;
+}
+
+.returns {
+font-family: Monaco, Verdana, Sans-serif;
+font-size: 10px;
+color: #888;
+float: left;
+text-align: right;
+margin: 0 4px 0 0;
+width: 48px;
+}

+ 116 - 0
vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/manual/css/ui.tabs.css

@@ -0,0 +1,116 @@
+/* Caution! Ensure accessibility in print and other media types... */
+@media projection, screen { /* Use class for showing/hiding tab content, so that visibility can be better controlled in different media types... */
+    .ui-tabs-hide {
+        display: none;
+    }
+}
+
+/* Hide useless elements in print layouts... */
+@media print {
+    .ui-tabs-nav {
+        display: none;
+    }
+}
+
+/* Skin */
+.ui-tabs-nav, .ui-tabs-panel {
+    font-family: "Trebuchet MS", Trebuchet, Verdana, Helvetica, Arial, sans-serif;
+    font-size: 12px;
+}
+.ui-tabs-nav {
+    list-style: none;
+    margin: 0;
+    padding: 0 0 0 4px;
+}
+.ui-tabs-nav:after { /* clearing without presentational markup, IE gets extra treatment */
+    display: block;
+    clear: both;
+    content: " ";
+}
+.ui-tabs-nav li {
+    float: left;
+    margin: 0 0 0 1px;
+    min-width: 84px; /* be nice to Opera */
+}
+.ui-tabs-nav a, .ui-tabs-nav a span {
+    display: block;
+    padding: 0 10px;
+    background: url(../img/tab.png) no-repeat;
+}
+.ui-tabs-nav a {
+    margin: 1px 0 0; /* position: relative makes opacity fail for disabled tab in IE */
+    padding-left: 0;
+    color: #27537a;
+    font-weight: bold;
+    line-height: 1.2;
+    text-align: center;
+    text-decoration: none;
+    white-space: nowrap; /* required in IE 6 */    
+    outline: 0; /* prevent dotted border in Firefox */
+}
+.ui-tabs-nav .ui-tabs-selected a {
+    position: relative;
+    top: 1px;
+    z-index: 2;
+    margin-top: 0;
+    color: #000;
+}
+.ui-tabs-nav a span {
+    width: 64px; /* IE 6 treats width as min-width */
+    min-width: 64px;
+    height: 18px; /* IE 6 treats height as min-height */
+    min-height: 18px;
+    padding-top: 6px;
+    padding-right: 0;
+}
+*>.ui-tabs-nav a span { /* hide from IE 6 */
+    width: auto;
+    height: auto;
+}
+.ui-tabs-nav .ui-tabs-selected a span {
+    padding-bottom: 1px;
+}
+.ui-tabs-nav .ui-tabs-selected a, .ui-tabs-nav a:hover, .ui-tabs-nav a:focus, .ui-tabs-nav a:active {
+    background-position: 100% -150px;
+}
+.ui-tabs-nav a, .ui-tabs-nav .ui-tabs-disabled a:hover, .ui-tabs-nav .ui-tabs-disabled a:focus, .ui-tabs-nav .ui-tabs-disabled a:active {
+    background-position: 100% -100px;
+}
+.ui-tabs-nav .ui-tabs-selected a span, .ui-tabs-nav a:hover span, .ui-tabs-nav a:focus span, .ui-tabs-nav a:active span {
+    background-position: 0 -50px;
+}
+.ui-tabs-nav a span, .ui-tabs-nav .ui-tabs-disabled a:hover span, .ui-tabs-nav .ui-tabs-disabled a:focus span, .ui-tabs-nav .ui-tabs-disabled a:active span {
+    background-position: 0 0;
+}
+.ui-tabs-nav .ui-tabs-selected a:link, .ui-tabs-nav .ui-tabs-selected a:visited, .ui-tabs-nav .ui-tabs-disabled a:link, .ui-tabs-nav .ui-tabs-disabled a:visited { /* @ Opera, use pseudo classes otherwise it confuses cursor... */
+    cursor: text;
+}
+.ui-tabs-nav a:hover, .ui-tabs-nav a:focus, .ui-tabs-nav a:active,
+.ui-tabs-nav .ui-tabs-unselect a:hover, .ui-tabs-nav .ui-tabs-unselect a:focus, .ui-tabs-nav .ui-tabs-unselect a:active { /* @ Opera, we need to be explicit again here now... */
+    cursor: pointer;
+}
+.ui-tabs-disabled {
+    opacity: .4;
+    filter: alpha(opacity=40);
+}
+.ui-tabs-panel {
+    border-top: 1px solid #97a5b0;
+    padding: 2px 4px 2px 4px;
+    background: #fff; /* declare background color for container to avoid distorted fonts in IE while fading */
+    border: 1px solid #D0D0D0;
+    border-bottom: 1px solid #A0A0A0;
+    border-right: 1px solid #A0A0A0;
+}
+.ui-tabs-loading em {
+    padding: 0 0 0 20px;
+    background: url(loading.gif) no-repeat 0 50%;
+}
+
+/* Additional IE specific bug fixes... */
+* html .ui-tabs-nav { /* auto clear, @ IE 6 & IE 7 Quirks Mode */
+    display: inline-block;
+}
+*:first-child+html .ui-tabs-nav  { /* @ IE 7 Standards Mode - do not group selectors, otherwise IE 6 will ignore complete rule (because of the unknown + combinator)... */
+    display: inline-block;
+}
+

BIN
vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/manual/img/tab.png


Разница между файлами не показана из-за своего большого размера
+ 10 - 0
vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/manual/js/jquery-1.2.3.pack.js


Разница между файлами не показана из-за своего большого размера
+ 9 - 0
vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/manual/js/ui.tabs.pack.js


+ 448 - 0
vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/manual/manual.htm

@@ -0,0 +1,448 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+<title>PHP Simple HTML DOM Parser: Manual</title>
+<link href="css/default.css" rel="stylesheet" type="text/css">
+<link rel="stylesheet" href="css/ui.tabs.css" type="text/css" media="print, projection, screen">
+<script type="text/javascript" src="js/jquery-1.2.3.pack.js"></script>
+<script type="text/javascript" src="js/ui.tabs.pack.js"></script>
+<script language="JavaScript" type="text/JavaScript">
+	$(document).ready(function(){
+		$(function() {$('#container_quickstart > ul').tabs();});
+		$(function() {$('#container_create > ul').tabs();});
+		$(function() {$('#container_find > ul').tabs();});
+		$(function() {$('#container_access > ul').tabs();});
+		$(function() {$('#container_traverse > ul').tabs();});
+		$(function() {$('#container_dump > ul').tabs();});
+		$(function() {$('#container_callback > ul').tabs();});
+	});
+</script>
+</head>
+<body>
+<h1><a name="top"></a>PHP Simple HTML DOM Parser Manual</h1>
+<div id="content">
+  <h2>Index</h2>
+  <ul>
+		<li><a href="#section_quickstart">Quick Start</a></li>
+    <li><a href="#section_create">How to create HTML DOM object?</a></li>
+    <li><a href="#section_find">How to find HTML elements?</a></li>
+    <li><a href="#section_access">How to access the HTML element's attributes?</a> </li>
+    <li><a href="#section_traverse">How to traverse the DOM tree?</a></li>
+    <li><a href="#section_dump">How to dump contents of DOM object?</a></li>
+		<li><a href="#section_callback">How to customize the parsing behavior?</a></li>
+    <li><a href="manual_api.htm">API Reference</a></li>
+    <li><a href="manual_faq.htm">FAQ</a></li>
+  </ul>
+	
+	<a name="section_quickstart"></a>
+  <h2>Quick Start</h2>
+  <a class="top" href="#top">Top</a>
+	<div id="container_quickstart">
+    <ul>
+      <li><a href="#fragment-11"><span>Get HTML elements</span></a></li>
+      <li><a href="#fragment-12"><span>Modify HTML elements</span></a></li>
+      <li><a href="#fragment-13"><span>Extract contents from HTML</span></a></li>
+      <li><a href="#fragment-14"><span>Scraping Slashdot!</span></a></li>
+    </ul>
+    <div id="fragment-11">
+      <div class="code">
+        <span class="comment">// Create DOM from URL or file</span><br>
+        $html = <strong>file_get_html</strong>(<span class="var">'http://www.google.com/'</span>);<br>
+        <br>
+        <span class="comment">// Find all images </span><br>
+        foreach($html-&gt;<strong>find</strong>(<span class="var">'img'</span>) as $element) <br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo $element-&gt;<strong>src</strong> . <span class="var">'&lt;br&gt;'</span>;<br>
+<br>
+<span class="comment">// Find all links </span><br>
+foreach($html-&gt;<strong>find</strong>(<span class="var">'a'</span>) as $element) <br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo $element-&gt;<strong>href</strong> . <span class="var">'&lt;br&gt;'</span>;      </div>
+    </div>
+    <div id="fragment-12">
+      <div class="code">
+        <span class="comment">// Create DOM from string</span><br>
+        $html = <strong>str_get_html</strong>(<span class="var">'&lt;div id=&quot;hello&quot;&gt;Hello&lt;/div&gt;&lt;div id=&quot;world&quot;&gt;World&lt;/div&gt;'</span>);<span class="comment"><br>
+        <br>
+        </span>
+        
+$html-&gt;<strong>find</strong>(<span class="var">'div', 1</span>)-&gt;<strong>class</strong> = <span class="var">'bar'</span>;<br>
+<br>
+$html-&gt;<strong>find</strong>(<span class="var">'div[id=hello]', 0</span>)-&gt;<strong>innertext</strong> = <span class="var">'foo'</span>;<br>
+        <br>
+        echo $html; <span class="comment">// Output: &lt;div id=&quot;hello&quot;&gt;<strong>foo</strong>&lt;/div&gt;&lt;div id=&quot;world&quot; <strong>class=&quot;bar&quot;</strong>&gt;World&lt;/div&gt;</span> </div>
+    </div>
+    <div id="fragment-13">
+      <div class="code"><br>
+        <span class="comment">// Dump contents (without tags) from HTML</span><br>
+        echo <strong>file_get_html</strong>(<span class="var">'http://www.google.com/'</span>)-&gt;<strong>plaintext</strong>;
+				<br>
+				<br>
+      </div>
+    </div>
+    <div id="fragment-14">
+      <div class="code">
+        <span class="comment">// Create DOM from URL</span><br>
+        $html = <strong>file_get_html</strong>(<span class="var">'http://slashdot.org/'</span>);<br>
+        <br>
+        <span class="comment">// Find all article blocks</span><br>
+        foreach($html-&gt;<strong>find</strong>(<span class="var">'div.article'</span>) as $article) {<br>
+&nbsp;&nbsp;&nbsp;&nbsp;$item[<span class="var">'title'</span>]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;= $article-&gt;<strong>find</strong>(<span class="var">'div.title'</span>, <span class="var">0</span>)-&gt;<strong>plaintext</strong>;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;$item[<span class="var">'intro'</span>]&nbsp;&nbsp;&nbsp;&nbsp;= $article-&gt;<strong>find</strong>(<span class="var">'div.intro'</span>, <span class="var">0</span>)-&gt;<strong>plaintext</strong>;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;$item[<span class="var">'details'</span>]&nbsp;= $article-&gt;<strong>find</strong>(<span class="var">'div.details'</span>, <span class="var">0</span>)-&gt;<strong>plaintext</strong>;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;$articles[] = $item;<br>
+        }<br>
+        <br>
+        print_r($articles);
+      </div>
+    </div>
+  </div>
+	
+  <a name="section_create"></a>
+  <h2>How to create HTML DOM object?</h2>
+  <a class="top" href="#top">Top</a>
+  <div id="container_create">
+    <ul>
+      <li><a href="#frag_create_quick"><span>Quick way</span></a></li>
+      <li><a href="#frag_create_oo"><span>Object-oriented way</span></a></li>
+    </ul>
+    <div id="frag_create_quick">
+      <div class="code"><span class="comment">// Create a DOM object from a string</span><br>
+        $html = <strong>str_get_html</strong>(<span class="var">'&lt;html&gt;&lt;body&gt;Hello!&lt;/body&gt;&lt;/html&gt;'</span>);<br>
+        <br>
+        <span class="comment">// Create a DOM object from a URL</span><br>
+        $html = <strong>file_get_html</strong>(<span class="var">'http://www.google.com/'</span>);<br>
+        <br>
+        <span class="comment">// Create a DOM object from a HTML file</span><br>
+        $html = <strong>file_get_html</strong>(<span class="var">'test.htm'</span>);<span class="comment"><br>
+        </span></div>
+    </div>
+    <div id="frag_create_oo">
+      <div class="code"><span class="comment">// Create a DOM object</span><br>
+        $html = new <strong>simple_html_dom</strong>();<br>
+        <br>
+        <span class="comment">// Load HTML from a string</span><br>
+        $html-&gt;<strong>load</strong>(<span class="var">'&lt;html&gt;&lt;body&gt;Hello!&lt;/body&gt;&lt;/html&gt;'</span>);<br>
+        <br>
+        <span class="comment">// Load HTML from a URL </span> <br>
+        $html-&gt;<strong>load_file</strong>(<span class="var">'http://www.google.com/'</span>);<br>
+        <br>
+        <span class="comment">// Load HTML from a HTML file</span> <br>
+        $html-&gt;<strong>load_file</strong>(<span class="var">'test.htm'</span>);</div>
+    </div>
+  </div>
+  <a name="section_find"></a>
+  <h2>How to find HTML elements?</h2>
+  <a class="top" href="#top">Top</a>
+  <div id="container_find">
+    <ul>
+      <li><a href="#frag_find_basic"><span>Basics</span></a></li>
+      <li><a href="#frag_find_advanced"><span>Advanced</span></a></li>
+      <li><a href="#frag_find_chain"><span>Descendant selectors</span></a></li>
+      <li><a href="#frag_find_nested"><span>Nested selectors</span></a></li>
+      <li><a href="#frag_find_attr"><span>Attribute Filters</span></a></li>
+      <li><a href="#frag_find_textcomment"><span>Text &amp; Comments</span></a></li>
+    </ul>
+    <div id="frag_find_basic">
+      <div class="code"> <span class="comment">// Find all <strong>anchors</strong>, returns a <strong>array</strong> of element objects</span><br>
+        $ret = $html-&gt;find(<span class="var">'<strong>a</strong>'</span>);<br>
+        <br>
+        <span class="comment">// Find <strong>(N)th</strong>  <strong>anchor</strong>, returns element object or <strong>null</strong> if not found</span> <span class="comment">(zero based)</span><br>
+        $ret = $html-&gt;find(<span class="var">'<strong>a</strong>', <strong>0</strong></span>);<br>
+        <br>
+        <span class="comment">// Find <strong>lastest</strong> <strong>anchor</strong>, returns element object or <strong>null</strong> if not found</span> <span class="comment">(zero based)</span><br>
+$ret = $html-&gt;find(<span class="var">'<strong>a</strong>', <strong>-1</strong></span>);        <br>
+        <br>
+        <span class="comment">// Find all <strong>&lt;div&gt;</strong> with the <strong>id</strong> attribute</span><br>
+$ret = $html-&gt;find(<span class="var">'<strong>div[id]</strong>'</span>);<br>        
+<br>
+        <span class="comment">// Find all <strong>&lt;div&gt;</strong> which attribute <strong>id=foo</strong></span><br>
+$ret = $html-&gt;find(<span class="var">'<strong>div[id=foo]</strong>'</span>);        <br>
+      </div>
+    </div>
+    <div id="frag_find_advanced">
+      <div class="code"><span class="comment">// Find all element which <strong>id</strong>=foo</span><br>
+        $ret = $html-&gt;find(<span class="var">'<strong>#foo</strong>'</span>);<br>
+        <br>
+        <span class=comment>// Find all element which <strong>class</strong>=foo</span><br>
+        $ret = $html-&gt;find(<span class=var>'<strong>.foo</strong>'</span>);<br>
+        <br>
+        <span class="comment">// Find all element has attribute<strong> id</strong></span><br>
+$ret = $html-&gt;find(<span class="var">'<strong>*[id]</strong>'</span>);        <br>
+        <br>
+        <span class="comment">// Find all <strong>anchors</strong> and <strong>images</strong> </span><br>
+$ret = $html-&gt;find(<span class="var">'<strong>a, img</strong>'</span>);        <br>
+        <br>
+        <span class="comment">// Find all <strong>anchors</strong> and <strong>images</strong> with the "title" attribute</span><br>
+				$ret = $html-&gt;find(<span class="var">'<strong>a[title], img[title]</strong>'</span>);<br>
+      </div>
+    </div>
+    <div id="frag_find_attr">
+      <div class="code">
+				Supports these operators in attribute selectors:<br><br>
+        <table cellpadding="1" cellspacing="1">
+          <tr>
+            <th width="25%">Filter</th>
+            <th width="75%">Description</th>
+          </tr>
+          <tr>
+            <td>[attribute]</td>
+            <td>Matches elements that <strong>have</strong> the specified attribute.</td>
+          </tr>
+          <tr>
+              <td>[!attribute]</td>
+              <td>Matches elements that <strong>don't have</strong> the specified attribute.</td>
+          </tr>
+          <tr>
+            <td>[attribute=value]</td>
+            <td>Matches elements that have the specified attribute with a <strong>certain value</strong>.</td>
+          </tr>
+          <tr>
+            <td>[attribute!=value]</td>
+            <td>Matches elements that <strong>don't have</strong> the specified attribute with a certain value.</td>
+          </tr>
+          <tr>
+            <td>[attribute^=value]</td>
+            <td>Matches elements that have the specified attribute and it <strong>starts</strong> with a certain value.</td>
+          </tr>
+          <tr>
+            <td>[attribute$=value]</td>
+            <td>Matches elements that have the specified attribute and it <strong>ends</strong> with a certain value.</td>
+          </tr>
+          <tr>
+            <td>[attribute*=value]</td>
+            <td>Matches elements that have the specified attribute and it <strong>contains</strong> a certain value.</td>
+          </tr>
+        </table>
+      </div>
+    </div>
+    <div id="frag_find_chain">
+      <div class="code"><span class="comment">// Find all &lt;li&gt; in &lt;ul&gt; </span><br>
+        $es = $html-&gt;find(<span class="var">'<strong>ul li</strong>'</span>);<br>
+        <br>
+        <span class="comment">// Find Nested &lt;div&gt; </span><span class="comment">tags</span><br>
+        $es = $html-&gt;find(<span class="var">'<strong>div div div</strong>'</span>); <br>
+        <br>
+        <span class="comment">// Find all &lt;td&gt; in &lt;table&gt; which class=hello </span><br>
+        $es = $html-&gt;find(<span class="var">'<strong>table.hello td</strong>'</span>);<br>
+        <br>
+        <span class="comment">// Find all td tags with attribite align=center in table tags </span><br>
+        $es = $html-&gt;find(<span class="var">''<strong>table</strong><strong> td[align=center]</strong>'</span>);<br>
+      </div>
+    </div>
+    <div id="frag_find_textcomment">
+      <div class="code"><span class="comment"> // Find all text blocks </span><br>
+        $es = $html-&gt;find(<span class="var">'<strong>text</strong>'</span>);<br>
+        <br>
+        <span class="comment">// Find all comment (&lt;!--...--&gt;) blocks </span><br>
+        $es = $html-&gt;find(<span class="var">'<strong>comment</strong>'</span>);<br>
+      </div>
+    </div>
+    <div id="frag_find_nested">
+      <div class="code"> <span class="comment">// Find all &lt;li&gt; in &lt;ul&gt; </span><br>
+        foreach($html-&gt;find(<span class="var">'<strong>ul</strong>'</span>) as $ul) <br>
+        {<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; foreach($ul-&gt;find(<span class="var">'<strong>li</strong>'</span>) as $li) <br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="comment">// do something...</span><br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
+        }<br>
+        <br>
+        <span class="comment">// Find first &lt;li&gt; in first &lt;ul&gt;</span> <br>
+        $e = $html-&gt;find(<span class="var">'<strong>ul</strong>', <strong>0</strong></span>)-&gt;find(<span class="var">'<strong>li</strong>', <strong>0</strong></span>);<br>
+      </div>
+    </div>
+  </div>
+  <a name="section_access"></a>
+  <h2>How to access the HTML element's attributes?</h2>
+  <a class="top" href="#top">Top</a>
+  <div id="container_access">
+    <ul>
+      <li><a href="#frag_access_attr"><span>Get, Set and Remove attributes</span></a></li>
+      <li><a href="#frag_access_special"><span>Magic attributes</span></a></li>
+      <li><a href="#frag_access_tips"><span>Tips</span></a></li>
+    </ul>
+    <div id="frag_access_attr">
+      <div class="code"> 
+        <span class="comment">// <strong>Get</strong> a attribute ( If the attribute is <strong>non-value</strong> attribute (eg. checked, selected...), it will returns <strong>true</strong> or <strong>false</strong>)</span><br>
+        $value = $e-&gt;<strong>href</strong>;<br>
+        <br>
+        <span class="comment">// <strong>Set</strong> a attribute(If the attribute is <strong>non-value</strong> attribute (eg. checked, selected...), set it's value as <strong>true</strong> or <strong>false</strong>)</span><br>
+        $e-&gt;<strong>href</strong> = <span class="var">'my link'</span>;<br>
+        <br>
+        <span class="comment">// <strong>Remove</strong> a attribute, set it's value as null! </span><br>
+        $e-&gt;<strong>href</strong> = <strong><span class="var">null</span></strong>;<br>
+        <br>
+        <span class="comment">// <strong>Determine</strong> whether a attribute exist?</span> <br>
+if(isset($e-&gt;<strong>href</strong>)) <br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo <span class="var">'href exist!'</span>;<br>
+      </div>
+    </div>
+    <div id="frag_access_special">
+      <div class="code"> <span class="comment">// Example</span><br>
+        <span class="hl-var">$</span><span class="hl-code">html = </span>str_get_html<span class="hl-brackets">(</span><span class="var">&quot;&lt;div&gt;foo &lt;b&gt;bar&lt;/b&gt;&lt;/div&gt;&quot;</span><span class="hl-brackets">)</span><span class="hl-code">;</span> <br>
+        $e = $html-&gt;find(<span class="var">&quot;div&quot;</span>, <span class="var">0</span>);<br>
+        <br>
+        echo $e-&gt;<strong>tag</strong>; <span class="comment">// Returns: &quot; <strong>div</strong>&quot;</span><br>
+        echo $e-&gt;<strong>outertext</strong>; <span class="comment">// Returns: &quot; <strong>&lt;div&gt;foo &lt;b&gt;bar&lt;/b&gt;&lt;/div&gt;</strong>&quot;</span><br>
+        echo $e-&gt;<strong>innertext</strong>; <span class="comment">// Returns: &quot; <strong>foo &lt;b&gt;bar&lt;/b&gt;</strong>&quot;</span><br>
+        echo $e-&gt;<strong>plaintext</strong>; <span class="comment">// Returns: &quot; <strong>foo </strong><strong>bar</strong>&quot;<br>
+        <br>
+        </span>
+        <table cellspacing="1" cellpadding="1">
+          <tr bgcolor="#CCCCCC">
+            <th width="25%">Attribute Name</th>
+            <th width="75%">Usage</th>
+          </tr>
+          <tr>
+            <td>$e-&gt;<strong>tag</strong></td>
+            <td>Read or write the <strong>tag name</strong> of element.</td>
+          </tr>
+          <tr>
+            <td>$e-&gt;<strong>outertext</strong></td>
+            <td>Read or write the <strong>outer HTML text </strong> of element.</td>
+          </tr>
+          <tr>
+            <td>$e-&gt;<strong>innertext</strong></td>
+            <td>Read or write the <strong>inner HTML text </strong> of element.</td>
+          </tr>
+          <tr>
+            <td>$e-&gt;<strong>plaintext</strong></td>
+            <td>Read or write the <strong>plain text </strong> of element.</td>
+          </tr>
+        </table>
+      </div>
+    </div>
+    <div id="frag_access_tips">
+      <div class="code"><span class="comment">// <strong>Extract</strong> contents from HTML </span><br>
+echo <strong>$html</strong>-&gt;<strong>plaintext</strong>;<br>
+<br> 
+<span class="comment">
+        // <strong>Wrap</strong> a element</span><br>
+        $e-&gt;<strong>outertext</strong> = <span class="var">'&lt;div class=&quot;wrap&quot;&gt;'</span> . $e-&gt;<strong>outertext</strong> . <span class="var">'&lt;div&gt;</span>';<br>
+        <br>
+        <span class="comment">// <strong>Remove</strong> a element, set it's outertext as an empty string </span><br>
+        $e-&gt;<strong>outertext</strong> = <span class="var">''</span>;<br>
+        <br>
+        <span class="comment">// <strong>Append</strong> a element</span><br>
+$e-&gt;<strong>outertext</strong> = $e-&gt;<strong>outertext</strong> . <span class="var">'&lt;div&gt;foo</span><span class="var">&lt;div&gt;</span>';<br>
+<br>
+<span class="comment">// <strong>Insert</strong> a element</span><br>
+$e-&gt;<strong>outertext</strong> = <span class="var">'&lt;div&gt;foo</span><span class="var">&lt;div&gt;</span>' . $e-&gt;<strong>outertext</strong>;<br>
+      </div>
+    </div>
+  </div>
+  <a name="section_traverse"></a>
+  <h2>How to traverse the DOM tree?</h2>
+  <a class="top" href="#top">Top</a>
+  <div id="container_traverse">
+    <ul>
+      <li><a href="#frag_traverse_background"><span>Background Knowledge</span></a></li>
+      <li><a href="#frag_traverse_traverse"><span>Traverse the DOM tree</span></a></li>
+    </ul>
+    <div id="frag_traverse_background">
+      <div class="code"> <span class="comment">// If you are not so familiar with HTML DOM, check this <a href="http://php.net/manual/en/book.dom.php" target="_blank"><span class="var">link</span></a> to learn more... </span><br>
+        <br>
+        <span class="comment">// Example</span><br>
+        echo $html-&gt;<strong>find</strong>(<span class="var">&quot;#div1&quot;, 0</span>)-&gt;<strong>children</strong>(<span class="var">1</span>)-&gt;<strong>children</strong>(<span class="var">1</span>)-&gt;<strong>children</strong>(<span class="var">2</span>)-&gt;<span class="var">id</span>;<br>
+        <span class="comment">// or</span> <br>
+        echo $html-&gt;<strong>getElementById</strong>(<span class="var">&quot;div1&quot;</span>)-&gt;<strong>childNodes</strong>(<span class="var">1</span>)-&gt;<strong>childNodes</strong>(<span class="var">1</span>)-&gt;<strong>childNodes</strong>(<span class="var">2</span>)-&gt;<strong>getAttribute</strong>(<span class="var">'id'</span>); </div>
+    </div>
+    <div id="frag_traverse_traverse">
+      <div class="code">You can also call methods with <a href="manual_api.htm#camel"><span class="var">Camel naming convertions</span></a>.<br>
+        <table cellspacing="1" cellpadding="1">
+          <tr>
+            <th> Method </th>
+            <th> Description</th>
+          </tr>
+          <tr>
+            <td>
+              <div class="returns">mixed</div>$e-&gt;<strong>children</strong> ( <span class="var">[int $index]</span> ) </td>
+            <td>Returns the Nth <strong>child object</strong> if <strong>index</strong> is set, otherwise return an <strong>array of children</strong>. </td>
+          </tr>
+          <tr>
+            <td>
+              <div class="returns">element</div>$e-&gt;<strong>parent</strong> () </td>
+            <td>Returns the <strong>parent</strong> of element. </td>
+          </tr>
+          <tr>
+            <td>
+              <div class="returns">element</div>$e-&gt;<strong>first_child</strong> () </td>
+            <td>Returns the <strong>first child</strong> of element, or <strong>null</strong> if not found. </td>
+          </tr>
+          <tr>
+            <td>
+              <div class="returns">element</div>$e-&gt;<strong>last_child</strong> () </td>
+            <td>Returns the <strong>last child</strong> of element, or <strong>null</strong> if not found. </td>
+          </tr>
+          <tr>
+            <td>
+              <div class="returns">element</div>$e-&gt;<strong>next_sibling</strong> () </td>
+            <td>Returns the <strong>next sibling</strong> of element, or<strong> null</strong> if not found. </td>
+          </tr>
+          <tr>
+            <td>
+              <div class="returns">element</div>$e-&gt;<strong>prev_sibling</strong> () </td>
+            <td>Returns the <strong>previous sibling</strong> of element, or <strong>null</strong> if not found. </td>
+          </tr>
+        </table>
+      </div>
+    </div>
+    
+  </div>
+  <a name="section_dump"></a>
+  <h2>How to dump contents of DOM object?</h2>
+  <a class="top" href="#top">Top</a>
+  <div id="container_dump">
+    <ul>
+      <li><a href="#frag_dump_quick"><span>Quick way</span></a></li>
+      <li><a href="#frag_dump_oo"><span>Object-oriented way</span></a></li>
+    </ul>
+    <div id="frag_dump_oo">
+      <div class="code"><span class="comment">// </span><span class="comment">Dumps the internal DOM tree back into string </span><br>
+        $str = $html-&gt;<strong>save</strong>();<br>
+        <br>
+        <span class="comment">// Dumps the internal DOM tree back into a file</span> <br>
+        $html-&gt;<strong>save</strong>(<span class="var">'result.htm'</span>);</div>
+    </div>
+    <div id="frag_dump_quick">
+      <div class="code"><span class="comment">// </span><span class="comment">Dumps the internal DOM tree back into string </span><br>
+        $str = $html;<br>
+        <br>
+        <span class="comment">// Print it!</span><br>
+        echo $html; <br>
+      </div>
+    </div>
+  </div>
+	<a name="section_callback"></a>
+  <h2>How to customize the parsing behavior?</h2>
+  <a class="top" href="#top">Top</a>
+  <div id="container_callback">
+    <ul>
+      <li><a href="#frag_callback"><span>Callback function</span></a></li>
+    </ul>
+    <div id="frag_callback">
+      <div class="code"><span class="comment">// Write a function with parameter &quot;<strong>$element</strong>&quot;</span><br>
+        function my_callback(<span class="var">$element</span>) {<br>
+        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">// Hide all &lt;b&gt; tags </span><br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if ($element-&gt;tag==<span class="var">'b'</span>)<br> 
+        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$element-&gt;outertext = '';<br>
+        } <br>
+        <br>
+        <span class="comment">// Register the  callback function with it's <strong>function name</strong></span><br>
+        $html-&gt;<strong>set_callback</strong>(<span class="var">'my_callback'</span>);<br>
+        <br>
+        <span class="comment">// Callback function will be invoked while dumping</span><br>
+        echo $html;
+      </div>
+    </div>
+  </div>
+
+  <div><br>
+    Author: S.C. Chen (me578022@gmail.com)<br>
+Original idea is from Jose Solorzano's <a href="http://php-html.sourceforge.net/">HTML Parser for PHP 4</a>. <br>
+Contributions by: Contributions by: Yousuke Kumakura, Vadim Voituk, Antcs<br>
+  </div>
+</div>
+</body>
+</html>
+<!--$Rev: 165 $-->

+ 320 - 0
vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/manual/manual_api.htm

@@ -0,0 +1,320 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+<title>PHP Simple HTML DOM Parser: API Reference</title>
+<link href="css/default.css" rel="stylesheet" type="text/css">
+</head>
+<body>
+<h1><a name="top"></a>PHP Simple HTML DOM Parser Manual</h1>
+<div id="content">
+  <h2>Index</h2>
+  <ul>
+    <li><a href="manual.htm">Back</a></li>
+    <li><a href="#api">API Reference</a></li>
+    <li><a href="#camel">Camel naming conventions</a></li>
+  </ul>
+  <a name="api"></a>
+  <h2>API Reference</h2>
+  <a class="top" href="#top">Top</a>
+  <div class="code"> <strong>Helper</strong> functions
+    <table width="100%" cellpadding="1" cellspacing="1">
+      <tr>
+        <th width="320">Name</th>
+        <th>Description</th>
+      </tr>
+      <tr>
+        <td><span class="returns">object</span> str_get_html ( <span class="var">string $content</span> )</td>
+        <td class="description">Creates a DOM object from a string.</td>
+      </tr>
+      <tr>
+        <td><span class="returns">object</span> file_get_html ( <span class="var">string $filename</span> )</td>
+        <td class="description">Creates a DOM object from a file or a URL.</td>
+      </tr>
+    </table>
+    <br>
+    <strong>DOM</strong> methods &amp; properties <br>
+    <table width="100%" cellpadding="1" cellspacing="1">
+      <tr>
+        <th width="320"> Name</th>
+        <th> Description</th>
+      </tr>
+      <tr>
+          <td>
+              <div class="returns">void</div>
+              __construct ( <span class="var">[string $filename]</span> )</td>
+          <td class="description">Constructor, set the filename parameter will automatically load the contents, either text or file/url.</td>
+      </tr>
+      <tr>
+        <td>
+          <div class="returns">string</div>
+          plaintext</td>
+        <td class="description">Returns the contents extracted from HTML.</td>
+      </tr>
+      <tr>
+        <td>
+          <div class="returns">void</div>
+          clear ()</td>
+        <td class="description">Clean up memory.</td>
+      </tr>
+      <tr>
+        <td>
+          <div class="returns">void</div>
+          load ( <span class="var">string $content </span>)</td>
+        <td class="description"> Load contents from a <strong>string</strong>. </td>
+      </tr>
+      <tr>
+        <td>
+          <div class="returns">string</div>
+          save ( <span class="var">[string $filename]</span> )</td>
+        <td class="description">Dumps the internal DOM tree back into a <strong>string</strong>. If the $filename is set, result string will save to file. </td>
+      </tr>
+      <tr>
+        <td>
+          <div class="returns">void</div>
+          load_file (<span class="var"> string $filename</span> )</td>
+        <td class="description"> Load contents from a from a file or a URL.</td>
+      </tr>
+      <tr>
+        <td>
+          <div class="returns">void</div>
+          set_callback ( <span class="var">string $function_name </span>)</td>
+        <td class="description">Set a callback function. </td>
+      </tr>
+      <tr>
+        <td>
+          <div class="returns">mixed</div>
+          find (<span class="var"> string $selector [, int $index] </span>)</td>
+        <td class="description">Find elements by the CSS selector. Returns the Nth element <strong>object</strong> if <strong>index</strong> is set, otherwise return an <strong>array</strong> of object. </td>
+      </tr>
+    </table>
+    <br>
+    <strong>Element</strong> methods &amp; properties <br>
+    <table width="100%" cellpadding="1" cellspacing="1">
+      <tr>
+        <th width="320">Name</th>
+        <th>Description</th>
+      </tr>
+      <tr>
+        <td>
+          <div class="returns">string</div>
+          <span class="var">[attribute]</span></td>
+        <td class="description">Read or write element's attribure value. </td>
+      </tr>
+      <tr>
+        <td>
+          <div class="returns">string</div>
+          tag</td>
+        <td class="description">Read or write the tag name of element.</td>
+      </tr>
+      <tr>
+        <td>
+          <div class="returns">string</div>
+          outertext</td>
+        <td class="description">Read or write the outer HTML text of element.</td>
+      </tr>
+      <tr>
+        <td>
+          <div class="returns">string</div>
+          innertext</td>
+        <td class="description">Read or write the inner HTML text of element.</td>
+      </tr>
+      <tr>
+        <td>
+          <div class="returns">string</div>
+          plaintext</td>
+        <td class="description">Read or write the plain text of element.</td>
+      </tr>
+      <tr>
+        <td>
+          <div class="returns">mixed</div>
+          find (<span class="var"> string $selector [, int $index] </span>)</td>
+        <td class="description">Find children by the CSS selector. Returns the Nth element <strong>object</strong> if <strong>index</strong> is set, otherwise, return an <strong>array</strong> of object. </td>
+      </tr>
+    </table>
+    <strong><br>
+    DOM</strong> traversing<br>
+    <table width="100%" cellpadding="1" cellspacing="1">
+      <tr>
+        <th width="320">Name</th>
+        <th>Description</th>
+      </tr>
+      <tr>
+        <td>
+          <div class="returns">mixed</div>
+          $e-&gt;children ( <span class="var">[int $index]</span> ) </td>
+        <td class="description">Returns the Nth child <strong>object</strong> if <strong>index</strong> is set, otherwise return an <strong>array</strong> of children. </td>
+      </tr>
+      <tr>
+        <td>
+          <div class="returns">element</div>
+          $e-&gt;parent () </td>
+        <td class="description">Returns the parent of element. </td>
+      </tr>
+      <tr>
+        <td>
+          <div class="returns">element</div>
+          $e-&gt;first_child () </td>
+        <td class="description">Returns the first child of element, or <strong>null</strong> if not found. </td>
+      </tr>
+      <tr>
+        <td>
+          <div class="returns">element</div>
+          $e-&gt;last_child () </td>
+        <td class="description">Returns the last child of element, or <strong>null</strong> if not found. </td>
+      </tr>
+      <tr>
+        <td>
+          <div class="returns">element</div>
+          $e-&gt;next_sibling () </td>
+        <td class="description">Returns the next sibling of element, or<strong> null</strong> if not found. </td>
+      </tr>
+      <tr>
+        <td>
+          <div class="returns">element</div>
+          $e-&gt;prev_sibling () </td>
+        <td class="description">Returns the previous sibling of element, or <strong>null</strong> if not found. </td>
+      </tr>
+    </table>
+  </div>
+  <a name="camel"></a>
+  <h2>Camel naming convertions</h2>
+  <a class="top" href="#top">Top</a>
+  <div class="code">You can also call methods with W3C STANDARD camel naming convertions.<br>
+    <br>
+    <table width="100%" cellpadding="1" cellspacing="1">
+      <tr>
+        <th width="50%">Method</th>
+        <th>Mapping</th>
+      </tr>
+      <tr bgcolor="#EEEEEE">
+          <td>
+              <div class="returns">array</div>
+              $e-&gt;getAllAttributes () </td>
+          <td>
+              <div class="returns">array</div>
+              $e-&gt;<span class="var">attr</span></td>
+      </tr>
+      <tr bgcolor="#EEEEEE">
+        <td>
+          <div class="returns">string</div>
+          $e-&gt;getAttribute ( <span class="var">$name</span> ) </td>
+        <td>
+          <div class="returns">string</div>
+          $e-&gt;<span class="var">attribute</span></td>
+      </tr>
+      <tr bgcolor="#EEEEEE">
+        <td>
+          <div class="returns">void</div>
+          $e-&gt;setAttribute ( <span class="var">$name, $value</span> ) </td>
+        <td>
+          <div class="returns">void</div>
+          $value = $e-&gt;<span class="var">attribute</span></td>
+      </tr>
+      <tr bgcolor="#EEEEEE">
+        <td>
+          <div class="returns">bool</div>
+          $e-&gt;hasAttribute ( <span class="var">$name</span> ) </td>
+        <td>
+          <div class="returns">bool</div>
+          isset($e-&gt;<span class="var">attribute</span>)</td>
+      </tr>
+      <tr bgcolor="#EEEEEE">
+        <td>
+          <div class="returns">void</div>
+          $e-&gt;removeAttribute ( <span class="var">$name</span> ) </td>
+        <td>
+          <div class="returns">void</div>
+          $e-&gt;<span class="var">attribute</span> = null</td>
+      </tr>
+      <tr bgcolor="#EEEEEE">
+        <td>
+          <div class="returns">element</div>
+          $e-&gt;getElementById ( <span class="var">$id</span> ) </td>
+        <td>
+          <div class="returns">mixed</div>
+          $e-&gt;find (<span class="var"> &quot;#$id&quot;, 0 </span>)</td>
+      </tr>
+      <tr bgcolor="#EEEEEE">
+        <td>
+          <div class="returns">mixed</div>
+          $e-&gt;getElementsById ( <span class="var">$id [,$index] </span> ) </td>
+        <td>
+          <div class="returns">mixed</div>
+          $e-&gt;find (<span class="var"> &quot;#$id&quot; [, int $index] </span>)</td>
+      </tr>
+      <tr bgcolor="#EEEEEE">
+        <td>
+          <div class="returns">element</div>
+          $e-&gt;getElementByTagName (<span class="var">$name</span> ) </td>
+        <td>
+          <div class="returns">mixed</div>
+          $e-&gt;find (<span class="var"> $name, 0 </span>)</td>
+      </tr>
+      <tr bgcolor="#EEEEEE">
+        <td>
+          <div class="returns">mixed</div>
+          $e-&gt;getElementsByTagName ( <span class="var">$name [, $index]</span> ) </td>
+        <td>
+          <div class="returns">mixed</div>
+          $e-&gt;find (<span class="var"> $name [, int $index] </span>)</td>
+      </tr>
+      <tr bgcolor="#EEEEEE">
+        <td>
+          <div class="returns">element</div>
+          $e-&gt;parentNode () </td>
+        <td>
+          <div class="returns">element</div>
+          $e-&gt;parent () </td>
+      </tr>
+      <tr bgcolor="#EEEEEE">
+        <td>
+          <div class="returns">mixed</div>
+          $e-&gt;childNodes ( <span class="var">[$index]</span> ) </td>
+        <td>
+          <div class="returns">mixed</div>
+          $e-&gt;children ( <span class="var">[int $index]</span> ) </td>
+      </tr>
+      <tr bgcolor="#EEEEEE">
+        <td>
+          <div class="returns">element</div>
+          $e-&gt;firstChild () </td>
+        <td>
+          <div class="returns">element</div>
+          $e-&gt;first_child () </td>
+      </tr>
+      <tr bgcolor="#EEEEEE">
+        <td>
+          <div class="returns">element</div>
+          $e-&gt;lastChild () </td>
+        <td>
+          <div class="returns">element</div>
+          $e-&gt;last_child () </td>
+      </tr>
+      <tr bgcolor="#EEEEEE">
+        <td>
+          <div class="returns">element</div>
+          $e-&gt;nextSibling () </td>
+        <td>
+          <div class="returns">element</div>
+          $e-&gt;next_sibling () </td>
+      </tr>
+      <tr bgcolor="#EEEEEE">
+        <td>
+          <div class="returns">element</div>
+          $e-&gt;previousSibling () </td>
+        <td>
+          <div class="returns">element</div>
+          $e-&gt;prev_sibling () </td>
+      </tr>
+    </table>
+  </div>
+  <div><br>
+    Author: S.C. Chen (me578022@gmail.com)<br>
+Original idea is from Jose Solorzano's <a href="http://php-html.sourceforge.net/">HTML Parser for PHP 4</a>. <br>
+Contributions by: Contributions by: Yousuke Kumakura, Vadim Voituk, Antcs<br>
+  </div>
+</div>
+</body>
+</html>
+<!--$Rev: 165 $-->

+ 91 - 0
vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/manual/manual_faq.htm

@@ -0,0 +1,91 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+<title>PHP Simple HTML DOM Parser: FAQ</title>
+<link href="css/default.css" rel="stylesheet" type="text/css">
+</head>
+<body>
+<h1><a name="top"></a>PHP Simple HTML DOM Parser Manual</h1>
+<div id="content">
+  <h2>FAQ</h2>
+  <ul>
+		<li><a href="manual.htm">Back</a></li>
+		<li><a href="#find">Problem with finding</a></li>
+    <li><a href="#hosting">Problem with hosting</a></li>
+    <li><a href="#proxy">Behind a proxy</a></li>
+    <li><a href="#memory_leak">Memory leak!</a></li>
+  </ul>
+	<div>
+		<a name="find"></a>
+    <h2>Problem with finding</h2>
+    <a class="top" href="#top">Top</a>
+	  <div class="code"> <span class="var">Q:</span> Element not found in such case:<br>
+	    $html-&gt;find('div[style=<span class="var">padding: 0px 2px;</span>] span[class=rf]');<br>
+      <br>
+      <span class="var">A:</span> If there is blank in selectors, quote it!  <br>
+      $html-&gt;find('div[style=<strong class="var">&quot;padding: 0px 2px;&quot;</strong>] span[class=rf]');</div>
+		<a name="hosting"></a>
+    <h2>Problem with hosting</h2>
+    <a class="top" href="#top">Top</a>
+    <div class="code"> <span class="var">Q:</span> On my local server everything works fine, but when I put it on my esternal server it doesn't work. <br>
+      <br>
+      <span class="var">A:</span> The "file_get_dom" function is a wrapper of "file_get_contents" function,  you must set "<strong>allow_url_fopen</strong>" as <strong>TRUE</strong> in "php.ini" to allow accessing files via HTTP or FTP. However, some hosting venders disabled PHP's "allow_url_fopen" flag for security issues... PHP provides excellent support for "curl" library to do the same job, Use curl to get the page, then call "str_get_dom" to create DOM object. <br>
+      <br>
+      Example: <br>
+       <br>
+      $curl = curl_init(); <br>
+      curl_setopt(<span class="var">$curl, CURLOPT_URL, 'http://????????'</span>);  <br>
+      curl_setopt(<span class="var">$curl, CURLOPT_RETURNTRANSFER, 1</span>);  <br>
+      curl_setopt(<span class="var">$curl, CURLOPT_CONNECTTIMEOUT, 10</span>);  <br>
+      $str = curl_exec(<span class="var">$curl</span>);  <br>
+      curl_close($curl);  <br>
+       <br>
+      $html= <strong>str_get_html</strong>($str); <br>
+      ...  </div>
+    <a name="proxy"></a>
+    <div>
+      <h2>Behind a proxy</h2>
+      <a class="top" href="#top">Top</a>
+      <div class="code"> <span class="var">Q:</span> My server is behind a Proxy and i can't use file_get_contents b/c it returns a unauthorized error.<br>
+        <br>
+        <span class="var">A:</span> Thanks for Shaggy to provide the solution: <br>
+         <br>
+        <span class="comment">// Define a context for HTTP. </span><br>
+        $context = array<br>
+        ( <br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="var">'http'</span> =&gt; array<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ( <br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="var">'proxy'</span> =&gt; <span class="var">'addresseproxy:portproxy'</span>, <span class="comment">// This needs to be the server and the port of the NTLM Authentication Proxy Server. </span><br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="var"> 'request_fulluri'</span> =&gt; true, <br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ), <br>
+        ); <br>
+        <br>
+        $context = <strong>stream_context_create</strong>($context); <br>
+         <br>
+        $html= <strong>file_get_html</strong>(<span class="var">'http://www.php.net'</span>, <span class="var">false</span>, <span class="var">$context</span>); <br>
+        ...<br>
+      </div>
+    </div>
+    <a name="memory_leak"></a>
+    <h2>Memory leak!</h2>
+    <a class="top" href="#top">Top</a>
+    <div class="code"> <span class="var">Q:</span> This script is leaking memory seriously... After it finished running, it's not cleaning up dom object properly from memory.. <br>
+      <br>
+      <span class="var">A:</span> Due to php5 circular references memory leak, after creating DOM object, you must call $dom-&gt;clear() to free memory if call file_get_dom() more then once. <br>
+      <br>
+      Example: <br>
+      <br>
+      $html = file_get_html(...); <br>
+      <span class="comment">// do something... </span><br>
+      $html-&gt;clear(); <br>
+      unset($html);</div>
+    <br>
+    Author: S.C. Chen (me578022@gmail.com)<br>
+Original idea is from Jose Solorzano's <a href="http://php-html.sourceforge.net/">HTML Parser for PHP 4</a>. <br>
+Contributions by: Yousuke Kumakura, Vadim Voituk, Antcs<br>
+  </div>
+</div>
+</body>
+</html>
+<!--$Rev: 165 $-->

+ 1721 - 0
vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/simple_html_dom.php

@@ -0,0 +1,1721 @@
+<?php
+/**
+ * Website: http://sourceforge.net/projects/simplehtmldom/
+ * Acknowledge: Jose Solorzano (https://sourceforge.net/projects/php-html/)
+ * Contributions by:
+ *     Yousuke Kumakura (Attribute filters)
+ *     Vadim Voituk (Negative indexes supports of "find" method)
+ *     Antcs (Constructor with automatically load contents either text or file/url)
+ *
+ * all affected sections have comments starting with "PaperG"
+ *
+ * Paperg - Added case insensitive testing of the value of the selector.
+ * Paperg - Added tag_start for the starting index of tags - NOTE: This works but not accurately.
+ *  This tag_start gets counted AFTER \r\n have been crushed out, and after the remove_noice calls so it will not reflect the REAL position of the tag in the source,
+ *  it will almost always be smaller by some amount.
+ *  We use this to determine how far into the file the tag in question is.  This "percentage will never be accurate as the $dom->size is the "real" number of bytes the dom was created from.
+ *  but for most purposes, it's a really good estimation.
+ * Paperg - Added the forceTagsClosed to the dom constructor.  Forcing tags closed is great for malformed html, but it CAN lead to parsing errors.
+ * Allow the user to tell us how much they trust the html.
+ * Paperg add the text and plaintext to the selectors for the find syntax.  plaintext implies text in the innertext of a node.  text implies that the tag is a text node.
+ * This allows for us to find tags based on the text they contain.
+ * Create find_ancestor_tag to see if a tag is - at any level - inside of another specific tag.
+ * Paperg: added parse_charset so that we know about the character set of the source document.
+ *  NOTE:  If the user's system has a routine called get_last_retrieve_url_contents_content_type availalbe, we will assume it's returning the content-type header from the
+ *  last transfer or curl_exec, and we will parse that and use it in preference to any other method of charset detection.
+ *
+ * Found infinite loop in the case of broken html in restore_noise.  Rewrote to protect from that.
+ * PaperG (John Schlick) Added get_display_size for "IMG" tags.
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @author S.C. Chen <me578022@gmail.com>
+ * @author John Schlick
+ * @author Rus Carroll
+ * @version 1.5 ($Rev: 196 $)
+ * @package PlaceLocalInclude
+ * @subpackage simple_html_dom
+ */
+
+/**
+ * All of the Defines for the classes below.
+ * @author S.C. Chen <me578022@gmail.com>
+ */
+define('HDOM_TYPE_ELEMENT', 1);
+define('HDOM_TYPE_COMMENT', 2);
+define('HDOM_TYPE_TEXT',    3);
+define('HDOM_TYPE_ENDTAG',  4);
+define('HDOM_TYPE_ROOT',    5);
+define('HDOM_TYPE_UNKNOWN', 6);
+define('HDOM_QUOTE_DOUBLE', 0);
+define('HDOM_QUOTE_SINGLE', 1);
+define('HDOM_QUOTE_NO',     3);
+define('HDOM_INFO_BEGIN',   0);
+define('HDOM_INFO_END',     1);
+define('HDOM_INFO_QUOTE',   2);
+define('HDOM_INFO_SPACE',   3);
+define('HDOM_INFO_TEXT',    4);
+define('HDOM_INFO_INNER',   5);
+define('HDOM_INFO_OUTER',   6);
+define('HDOM_INFO_ENDSPACE',7);
+define('DEFAULT_TARGET_CHARSET', 'UTF-8');
+define('DEFAULT_BR_TEXT', "\r\n");
+define('DEFAULT_SPAN_TEXT', " ");
+define('MAX_FILE_SIZE', 600000);
+// helper functions
+// -----------------------------------------------------------------------------
+// get html dom from file
+// $maxlen is defined in the code as PHP_STREAM_COPY_ALL which is defined as -1.
+function file_get_html($url, $use_include_path = false, $context=null, $offset = -1, $maxLen=-1, $lowercase = true, $forceTagsClosed=true, $target_charset = DEFAULT_TARGET_CHARSET, $stripRN=true, $defaultBRText=DEFAULT_BR_TEXT, $defaultSpanText=DEFAULT_SPAN_TEXT)
+{
+    // We DO force the tags to be terminated.
+    $dom = new simple_html_dom(null, $lowercase, $forceTagsClosed, $target_charset, $stripRN, $defaultBRText, $defaultSpanText);
+    // For sourceforge users: uncomment the next line and comment the retreive_url_contents line 2 lines down if it is not already done.
+    $contents = file_get_contents($url, $use_include_path, $context, $offset);
+    // Paperg - use our own mechanism for getting the contents as we want to control the timeout.
+    //$contents = retrieve_url_contents($url);
+    if (empty($contents) || strlen($contents) > MAX_FILE_SIZE)
+    {
+        return false;
+    }
+    // The second parameter can force the selectors to all be lowercase.
+    $dom->load($contents, $lowercase, $stripRN);
+    return $dom;
+}
+
+// get html dom from string
+function str_get_html($str, $lowercase=true, $forceTagsClosed=true, $target_charset = DEFAULT_TARGET_CHARSET, $stripRN=true, $defaultBRText=DEFAULT_BR_TEXT, $defaultSpanText=DEFAULT_SPAN_TEXT)
+{
+    $dom = new simple_html_dom(null, $lowercase, $forceTagsClosed, $target_charset, $stripRN, $defaultBRText, $defaultSpanText);
+    if (empty($str) || strlen($str) > MAX_FILE_SIZE)
+    {
+        $dom->clear();
+        return false;
+    }
+    $dom->load($str, $lowercase, $stripRN);
+    return $dom;
+}
+
+// dump html dom tree
+function dump_html_tree($node, $show_attr=true, $deep=0)
+{
+    $node->dump($node);
+}
+
+
+/**
+ * simple html dom node
+ * PaperG - added ability for "find" routine to lowercase the value of the selector.
+ * PaperG - added $tag_start to track the start position of the tag in the total byte index
+ *
+ * @package PlaceLocalInclude
+ */
+class simple_html_dom_node
+{
+    public $nodetype = HDOM_TYPE_TEXT;
+    public $tag = 'text';
+    public $attr = array();
+    public $children = array();
+    public $nodes = array();
+    public $parent = null;
+    // The "info" array - see HDOM_INFO_... for what each element contains.
+    public $_ = array();
+    public $tag_start = 0;
+    private $dom = null;
+
+    function __construct($dom)
+    {
+        $this->dom = $dom;
+        $dom->nodes[] = $this;
+    }
+
+    function __destruct()
+    {
+        $this->clear();
+    }
+
+    function __toString()
+    {
+        return $this->outertext();
+    }
+
+    // clean up memory due to php5 circular references memory leak...
+    function clear()
+    {
+        $this->dom = null;
+        $this->nodes = null;
+        $this->parent = null;
+        $this->children = null;
+    }
+
+    // dump node's tree
+    function dump($show_attr=true, $deep=0)
+    {
+        $lead = str_repeat('    ', $deep);
+
+        echo $lead.$this->tag;
+        if ($show_attr && count($this->attr)>0)
+        {
+            echo '(';
+            foreach ($this->attr as $k=>$v)
+                echo "[$k]=>\"".$this->$k.'", ';
+            echo ')';
+        }
+        echo "\n";
+
+        if ($this->nodes)
+        {
+            foreach ($this->nodes as $c)
+            {
+                $c->dump($show_attr, $deep+1);
+            }
+        }
+    }
+
+
+    // Debugging function to dump a single dom node with a bunch of information about it.
+    function dump_node($echo=true)
+    {
+
+        $string = $this->tag;
+        if (count($this->attr)>0)
+        {
+            $string .= '(';
+            foreach ($this->attr as $k=>$v)
+            {
+                $string .= "[$k]=>\"".$this->$k.'", ';
+            }
+            $string .= ')';
+        }
+        if (count($this->_)>0)
+        {
+            $string .= ' $_ (';
+            foreach ($this->_ as $k=>$v)
+            {
+                if (is_array($v))
+                {
+                    $string .= "[$k]=>(";
+                    foreach ($v as $k2=>$v2)
+                    {
+                        $string .= "[$k2]=>\"".$v2.'", ';
+                    }
+                    $string .= ")";
+                } else {
+                    $string .= "[$k]=>\"".$v.'", ';
+                }
+            }
+            $string .= ")";
+        }
+
+        if (isset($this->text))
+        {
+            $string .= " text: (" . $this->text . ")";
+        }
+
+        $string .= " HDOM_INNER_INFO: '";
+        if (isset($node->_[HDOM_INFO_INNER]))
+        {
+            $string .= $node->_[HDOM_INFO_INNER] . "'";
+        }
+        else
+        {
+            $string .= ' NULL ';
+        }
+
+        $string .= " children: " . count($this->children);
+        $string .= " nodes: " . count($this->nodes);
+        $string .= " tag_start: " . $this->tag_start;
+        $string .= "\n";
+
+        if ($echo)
+        {
+            echo $string;
+            return;
+        }
+        else
+        {
+            return $string;
+        }
+    }
+
+    // returns the parent of node
+    // If a node is passed in, it will reset the parent of the current node to that one.
+    function parent($parent=null)
+    {
+        // I am SURE that this doesn't work properly.
+        // It fails to unset the current node from it's current parents nodes or children list first.
+        if ($parent !== null)
+        {
+            $this->parent = $parent;
+            $this->parent->nodes[] = $this;
+            $this->parent->children[] = $this;
+        }
+
+        return $this->parent;
+    }
+
+    // verify that node has children
+    function has_child()
+    {
+        return !empty($this->children);
+    }
+
+    // returns children of node
+    function children($idx=-1)
+    {
+        if ($idx===-1)
+        {
+            return $this->children;
+        }
+        if (isset($this->children[$idx])) return $this->children[$idx];
+        return null;
+    }
+
+    // returns the first child of node
+    function first_child()
+    {
+        if (count($this->children)>0)
+        {
+            return $this->children[0];
+        }
+        return null;
+    }
+
+    // returns the last child of node
+    function last_child()
+    {
+        if (($count=count($this->children))>0)
+        {
+            return $this->children[$count-1];
+        }
+        return null;
+    }
+
+    // returns the next sibling of node
+    function next_sibling()
+    {
+        if ($this->parent===null)
+        {
+            return null;
+        }
+
+        $idx = 0;
+        $count = count($this->parent->children);
+        while ($idx<$count && $this!==$this->parent->children[$idx])
+        {
+            ++$idx;
+        }
+        if (++$idx>=$count)
+        {
+            return null;
+        }
+        return $this->parent->children[$idx];
+    }
+
+    // returns the previous sibling of node
+    function prev_sibling()
+    {
+        if ($this->parent===null) return null;
+        $idx = 0;
+        $count = count($this->parent->children);
+        while ($idx<$count && $this!==$this->parent->children[$idx])
+            ++$idx;
+        if (--$idx<0) return null;
+        return $this->parent->children[$idx];
+    }
+
+    // function to locate a specific ancestor tag in the path to the root.
+    function find_ancestor_tag($tag)
+    {
+        global $debugObject;
+        if (is_object($debugObject)) { $debugObject->debugLogEntry(1); }
+
+        // Start by including ourselves in the comparison.
+        $returnDom = $this;
+
+        while (!is_null($returnDom))
+        {
+            if (is_object($debugObject)) { $debugObject->debugLog(2, "Current tag is: " . $returnDom->tag); }
+
+            if ($returnDom->tag == $tag)
+            {
+                break;
+            }
+            $returnDom = $returnDom->parent;
+        }
+        return $returnDom;
+    }
+
+    // get dom node's inner html
+    function innertext()
+    {
+        if (isset($this->_[HDOM_INFO_INNER])) return $this->_[HDOM_INFO_INNER];
+        if (isset($this->_[HDOM_INFO_TEXT])) return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]);
+
+        $ret = '';
+        foreach ($this->nodes as $n)
+            $ret .= $n->outertext();
+        return $ret;
+    }
+
+    // get dom node's outer text (with tag)
+    function outertext()
+    {
+        global $debugObject;
+        if (is_object($debugObject))
+        {
+            $text = '';
+            if ($this->tag == 'text')
+            {
+                if (!empty($this->text))
+                {
+                    $text = " with text: " . $this->text;
+                }
+            }
+            $debugObject->debugLog(1, 'Innertext of tag: ' . $this->tag . $text);
+        }
+
+        if ($this->tag==='root') return $this->innertext();
+
+        // trigger callback
+        if ($this->dom && $this->dom->callback!==null)
+        {
+            call_user_func_array($this->dom->callback, array($this));
+        }
+
+        if (isset($this->_[HDOM_INFO_OUTER])) return $this->_[HDOM_INFO_OUTER];
+        if (isset($this->_[HDOM_INFO_TEXT])) return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]);
+
+        // render begin tag
+        if ($this->dom && $this->dom->nodes[$this->_[HDOM_INFO_BEGIN]])
+        {
+            $ret = $this->dom->nodes[$this->_[HDOM_INFO_BEGIN]]->makeup();
+        } else {
+            $ret = "";
+        }
+
+        // render inner text
+        if (isset($this->_[HDOM_INFO_INNER]))
+        {
+            // If it's a br tag...  don't return the HDOM_INNER_INFO that we may or may not have added.
+            if ($this->tag != "br")
+            {
+                $ret .= $this->_[HDOM_INFO_INNER];
+            }
+        } else {
+            if ($this->nodes)
+            {
+                foreach ($this->nodes as $n)
+                {
+                    $ret .= $this->convert_text($n->outertext());
+                }
+            }
+        }
+
+        // render end tag
+        if (isset($this->_[HDOM_INFO_END]) && $this->_[HDOM_INFO_END]!=0)
+            $ret .= '</'.$this->tag.'>';
+        return $ret;
+    }
+
+    // get dom node's plain text
+    function text()
+    {
+        if (isset($this->_[HDOM_INFO_INNER])) return $this->_[HDOM_INFO_INNER];
+        switch ($this->nodetype)
+        {
+            case HDOM_TYPE_TEXT: return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]);
+            case HDOM_TYPE_COMMENT: return '';
+            case HDOM_TYPE_UNKNOWN: return '';
+        }
+        if (strcasecmp($this->tag, 'script')===0) return '';
+        if (strcasecmp($this->tag, 'style')===0) return '';
+
+        $ret = '';
+        // In rare cases, (always node type 1 or HDOM_TYPE_ELEMENT - observed for some span tags, and some p tags) $this->nodes is set to NULL.
+        // NOTE: This indicates that there is a problem where it's set to NULL without a clear happening.
+        // WHY is this happening?
+        if (!is_null($this->nodes))
+        {
+            foreach ($this->nodes as $n)
+            {
+                $ret .= $this->convert_text($n->text());
+            }
+
+            // If this node is a span... add a space at the end of it so multiple spans don't run into each other.  This is plaintext after all.
+            if ($this->tag == "span")
+            {
+                $ret .= $this->dom->default_span_text;
+            }
+
+
+        }
+        return $ret;
+    }
+
+    function xmltext()
+    {
+        $ret = $this->innertext();
+        $ret = str_ireplace('<![CDATA[', '', $ret);
+        $ret = str_replace(']]>', '', $ret);
+        return $ret;
+    }
+
+    // build node's text with tag
+    function makeup()
+    {
+        // text, comment, unknown
+        if (isset($this->_[HDOM_INFO_TEXT])) return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]);
+
+        $ret = '<'.$this->tag;
+        $i = -1;
+
+        foreach ($this->attr as $key=>$val)
+        {
+            ++$i;
+
+            // skip removed attribute
+            if ($val===null || $val===false)
+                continue;
+
+            $ret .= $this->_[HDOM_INFO_SPACE][$i][0];
+            //no value attr: nowrap, checked selected...
+            if ($val===true)
+                $ret .= $key;
+            else {
+                switch ($this->_[HDOM_INFO_QUOTE][$i])
+                {
+                    case HDOM_QUOTE_DOUBLE: $quote = '"'; break;
+                    case HDOM_QUOTE_SINGLE: $quote = '\''; break;
+                    default: $quote = '';
+                }
+                $ret .= $key.$this->_[HDOM_INFO_SPACE][$i][1].'='.$this->_[HDOM_INFO_SPACE][$i][2].$quote.$val.$quote;
+            }
+        }
+        $ret = $this->dom->restore_noise($ret);
+        return $ret . $this->_[HDOM_INFO_ENDSPACE] . '>';
+    }
+
+    // find elements by css selector
+    //PaperG - added ability for find to lowercase the value of the selector.
+    function find($selector, $idx=null, $lowercase=false)
+    {
+        $selectors = $this->parse_selector($selector);
+        if (($count=count($selectors))===0) return array();
+        $found_keys = array();
+
+        // find each selector
+        for ($c=0; $c<$count; ++$c)
+        {
+            // The change on the below line was documented on the sourceforge code tracker id 2788009
+            // used to be: if (($levle=count($selectors[0]))===0) return array();
+            if (($levle=count($selectors[$c]))===0) return array();
+            if (!isset($this->_[HDOM_INFO_BEGIN])) return array();
+
+            $head = array($this->_[HDOM_INFO_BEGIN]=>1);
+
+            // handle descendant selectors, no recursive!
+            for ($l=0; $l<$levle; ++$l)
+            {
+                $ret = array();
+                foreach ($head as $k=>$v)
+                {
+                    $n = ($k===-1) ? $this->dom->root : $this->dom->nodes[$k];
+                    //PaperG - Pass this optional parameter on to the seek function.
+                    $n->seek($selectors[$c][$l], $ret, $lowercase);
+                }
+                $head = $ret;
+            }
+
+            foreach ($head as $k=>$v)
+            {
+                if (!isset($found_keys[$k]))
+                    $found_keys[$k] = 1;
+            }
+        }
+
+        // sort keys
+        ksort($found_keys);
+
+        $found = array();
+        foreach ($found_keys as $k=>$v)
+            $found[] = $this->dom->nodes[$k];
+
+        // return nth-element or array
+        if (is_null($idx)) return $found;
+        else if ($idx<0) $idx = count($found) + $idx;
+        return (isset($found[$idx])) ? $found[$idx] : null;
+    }
+
+    // seek for given conditions
+    // PaperG - added parameter to allow for case insensitive testing of the value of a selector.
+    protected function seek($selector, &$ret, $lowercase=false)
+    {
+        global $debugObject;
+        if (is_object($debugObject)) { $debugObject->debugLogEntry(1); }
+
+        list($tag, $key, $val, $exp, $no_key) = $selector;
+
+        // xpath index
+        if ($tag && $key && is_numeric($key))
+        {
+            $count = 0;
+            foreach ($this->children as $c)
+            {
+                if ($tag==='*' || $tag===$c->tag) {
+                    if (++$count==$key) {
+                        $ret[$c->_[HDOM_INFO_BEGIN]] = 1;
+                        return;
+                    }
+                }
+            }
+            return;
+        }
+
+        $end = (!empty($this->_[HDOM_INFO_END])) ? $this->_[HDOM_INFO_END] : 0;
+        if ($end==0) {
+            $parent = $this->parent;
+            while (!isset($parent->_[HDOM_INFO_END]) && $parent!==null) {
+                $end -= 1;
+                $parent = $parent->parent;
+            }
+            $end += $parent->_[HDOM_INFO_END];
+        }
+
+        for ($i=$this->_[HDOM_INFO_BEGIN]+1; $i<$end; ++$i) {
+            $node = $this->dom->nodes[$i];
+
+            $pass = true;
+
+            if ($tag==='*' && !$key) {
+                if (in_array($node, $this->children, true))
+                    $ret[$i] = 1;
+                continue;
+            }
+
+            // compare tag
+            if ($tag && $tag!=$node->tag && $tag!=='*') {$pass=false;}
+            // compare key
+            if ($pass && $key) {
+                if ($no_key) {
+                    if (isset($node->attr[$key])) $pass=false;
+                } else {
+                    if (($key != "plaintext") && !isset($node->attr[$key])) $pass=false;
+                }
+            }
+            // compare value
+            if ($pass && $key && $val  && $val!=='*') {
+                // If they have told us that this is a "plaintext" search then we want the plaintext of the node - right?
+                if ($key == "plaintext") {
+                    // $node->plaintext actually returns $node->text();
+                    $nodeKeyValue = $node->text();
+                } else {
+                    // this is a normal search, we want the value of that attribute of the tag.
+                    $nodeKeyValue = $node->attr[$key];
+                }
+                if (is_object($debugObject)) {$debugObject->debugLog(2, "testing node: " . $node->tag . " for attribute: " . $key . $exp . $val . " where nodes value is: " . $nodeKeyValue);}
+
+                //PaperG - If lowercase is set, do a case insensitive test of the value of the selector.
+                if ($lowercase) {
+                    $check = $this->match($exp, strtolower($val), strtolower($nodeKeyValue));
+                } else {
+                    $check = $this->match($exp, $val, $nodeKeyValue);
+                }
+                if (is_object($debugObject)) {$debugObject->debugLog(2, "after match: " . ($check ? "true" : "false"));}
+
+                // handle multiple class
+                if (!$check && strcasecmp($key, 'class')===0) {
+                    foreach (explode(' ',$node->attr[$key]) as $k) {
+                        // Without this, there were cases where leading, trailing, or double spaces lead to our comparing blanks - bad form.
+                        if (!empty($k)) {
+                            if ($lowercase) {
+                                $check = $this->match($exp, strtolower($val), strtolower($k));
+                            } else {
+                                $check = $this->match($exp, $val, $k);
+                            }
+                            if ($check) break;
+                        }
+                    }
+                }
+                if (!$check) $pass = false;
+            }
+            if ($pass) $ret[$i] = 1;
+            unset($node);
+        }
+        // It's passed by reference so this is actually what this function returns.
+        if (is_object($debugObject)) {$debugObject->debugLog(1, "EXIT - ret: ", $ret);}
+    }
+
+    protected function match($exp, $pattern, $value) {
+        global $debugObject;
+        if (is_object($debugObject)) {$debugObject->debugLogEntry(1);}
+
+        switch ($exp) {
+            case '=':
+                return ($value===$pattern);
+            case '!=':
+                return ($value!==$pattern);
+            case '^=':
+                return preg_match("/^".preg_quote($pattern,'/')."/", $value);
+            case '$=':
+                return preg_match("/".preg_quote($pattern,'/')."$/", $value);
+            case '*=':
+                if ($pattern[0]=='/') {
+                    return preg_match($pattern, $value);
+                }
+                return preg_match("/".$pattern."/i", $value);
+        }
+        return false;
+    }
+
+    protected function parse_selector($selector_string) {
+        global $debugObject;
+        if (is_object($debugObject)) {$debugObject->debugLogEntry(1);}
+
+        // pattern of CSS selectors, modified from mootools
+        // Paperg: Add the colon to the attrbute, so that it properly finds <tag attr:ibute="something" > like google does.
+        // Note: if you try to look at this attribute, yo MUST use getAttribute since $dom->x:y will fail the php syntax check.
+// Notice the \[ starting the attbute?  and the @? following?  This implies that an attribute can begin with an @ sign that is not captured.
+// This implies that an html attribute specifier may start with an @ sign that is NOT captured by the expression.
+// farther study is required to determine of this should be documented or removed.
+//        $pattern = "/([\w-:\*]*)(?:\#([\w-]+)|\.([\w-]+))?(?:\[@?(!?[\w-]+)(?:([!*^$]?=)[\"']?(.*?)[\"']?)?\])?([\/, ]+)/is";
+        $pattern = "/([\w-:\*]*)(?:\#([\w-]+)|\.([\w-]+))?(?:\[@?(!?[\w-:]+)(?:([!*^$]?=)[\"']?(.*?)[\"']?)?\])?([\/, ]+)/is";
+        preg_match_all($pattern, trim($selector_string).' ', $matches, PREG_SET_ORDER);
+        if (is_object($debugObject)) {$debugObject->debugLog(2, "Matches Array: ", $matches);}
+
+        $selectors = array();
+        $result = array();
+        //print_r($matches);
+
+        foreach ($matches as $m) {
+            $m[0] = trim($m[0]);
+            if ($m[0]==='' || $m[0]==='/' || $m[0]==='//') continue;
+            // for browser generated xpath
+            if ($m[1]==='tbody') continue;
+
+            list($tag, $key, $val, $exp, $no_key) = array($m[1], null, null, '=', false);
+            if (!empty($m[2])) {$key='id'; $val=$m[2];}
+            if (!empty($m[3])) {$key='class'; $val=$m[3];}
+            if (!empty($m[4])) {$key=$m[4];}
+            if (!empty($m[5])) {$exp=$m[5];}
+            if (!empty($m[6])) {$val=$m[6];}
+
+            // convert to lowercase
+            if ($this->dom->lowercase) {$tag=strtolower($tag); $key=strtolower($key);}
+            //elements that do NOT have the specified attribute
+            if (isset($key[0]) && $key[0]==='!') {$key=substr($key, 1); $no_key=true;}
+
+            $result[] = array($tag, $key, $val, $exp, $no_key);
+            if (trim($m[7])===',') {
+                $selectors[] = $result;
+                $result = array();
+            }
+        }
+        if (count($result)>0)
+            $selectors[] = $result;
+        return $selectors;
+    }
+
+    function __get($name) {
+        if (isset($this->attr[$name]))
+        {
+            return $this->convert_text($this->attr[$name]);
+        }
+        switch ($name) {
+            case 'outertext': return $this->outertext();
+            case 'innertext': return $this->innertext();
+            case 'plaintext': return $this->text();
+            case 'xmltext': return $this->xmltext();
+            default: return array_key_exists($name, $this->attr);
+        }
+    }
+
+    function __set($name, $value) {
+        switch ($name) {
+            case 'outertext': return $this->_[HDOM_INFO_OUTER] = $value;
+            case 'innertext':
+                if (isset($this->_[HDOM_INFO_TEXT])) return $this->_[HDOM_INFO_TEXT] = $value;
+                return $this->_[HDOM_INFO_INNER] = $value;
+        }
+        if (!isset($this->attr[$name])) {
+            $this->_[HDOM_INFO_SPACE][] = array(' ', '', '');
+            $this->_[HDOM_INFO_QUOTE][] = HDOM_QUOTE_DOUBLE;
+        }
+        $this->attr[$name] = $value;
+    }
+
+    function __isset($name) {
+        switch ($name) {
+            case 'outertext': return true;
+            case 'innertext': return true;
+            case 'plaintext': return true;
+        }
+        //no value attr: nowrap, checked selected...
+        return (array_key_exists($name, $this->attr)) ? true : isset($this->attr[$name]);
+    }
+
+    function __unset($name) {
+        if (isset($this->attr[$name]))
+            unset($this->attr[$name]);
+    }
+
+    // PaperG - Function to convert the text from one character set to another if the two sets are not the same.
+    function convert_text($text)
+    {
+        global $debugObject;
+        if (is_object($debugObject)) {$debugObject->debugLogEntry(1);}
+
+        $converted_text = $text;
+
+        $sourceCharset = "";
+        $targetCharset = "";
+
+        if ($this->dom)
+        {
+            $sourceCharset = strtoupper($this->dom->_charset);
+            $targetCharset = strtoupper($this->dom->_target_charset);
+        }
+        if (is_object($debugObject)) {$debugObject->debugLog(3, "source charset: " . $sourceCharset . " target charaset: " . $targetCharset);}
+
+        if (!empty($sourceCharset) && !empty($targetCharset) && (strcasecmp($sourceCharset, $targetCharset) != 0))
+        {
+            // Check if the reported encoding could have been incorrect and the text is actually already UTF-8
+            if ((strcasecmp($targetCharset, 'UTF-8') == 0) && ($this->is_utf8($text)))
+            {
+                $converted_text = $text;
+            }
+            else
+            {
+                $converted_text = iconv($sourceCharset, $targetCharset, $text);
+            }
+        }
+
+        // Lets make sure that we don't have that silly BOM issue with any of the utf-8 text we output.
+        if ($targetCharset == 'UTF-8')
+        {
+            if (substr($converted_text, 0, 3) == "\xef\xbb\xbf")
+            {
+                $converted_text = substr($converted_text, 3);
+            }
+            if (substr($converted_text, -3) == "\xef\xbb\xbf")
+            {
+                $converted_text = substr($converted_text, 0, -3);
+            }
+        }
+
+        return $converted_text;
+    }
+
+    /**
+    * Returns true if $string is valid UTF-8 and false otherwise.
+    *
+    * @param mixed $str String to be tested
+    * @return boolean
+    */
+    static function is_utf8($str)
+    {
+        $c=0; $b=0;
+        $bits=0;
+        $len=strlen($str);
+        for($i=0; $i<$len; $i++)
+        {
+            $c=ord($str[$i]);
+            if($c > 128)
+            {
+                if(($c >= 254)) return false;
+                elseif($c >= 252) $bits=6;
+                elseif($c >= 248) $bits=5;
+                elseif($c >= 240) $bits=4;
+                elseif($c >= 224) $bits=3;
+                elseif($c >= 192) $bits=2;
+                else return false;
+                if(($i+$bits) > $len) return false;
+                while($bits > 1)
+                {
+                    $i++;
+                    $b=ord($str[$i]);
+                    if($b < 128 || $b > 191) return false;
+                    $bits--;
+                }
+            }
+        }
+        return true;
+    }
+    /*
+    function is_utf8($string)
+    {
+        //this is buggy
+        return (utf8_encode(utf8_decode($string)) == $string);
+    }
+    */
+
+    /**
+     * Function to try a few tricks to determine the displayed size of an img on the page.
+     * NOTE: This will ONLY work on an IMG tag. Returns FALSE on all other tag types.
+     *
+     * @author John Schlick
+     * @version April 19 2012
+     * @return array an array containing the 'height' and 'width' of the image on the page or -1 if we can't figure it out.
+     */
+    function get_display_size()
+    {
+        global $debugObject;
+
+        $width = -1;
+        $height = -1;
+
+        if ($this->tag !== 'img')
+        {
+            return false;
+        }
+
+        // See if there is aheight or width attribute in the tag itself.
+        if (isset($this->attr['width']))
+        {
+            $width = $this->attr['width'];
+        }
+
+        if (isset($this->attr['height']))
+        {
+            $height = $this->attr['height'];
+        }
+
+        // Now look for an inline style.
+        if (isset($this->attr['style']))
+        {
+            // Thanks to user gnarf from stackoverflow for this regular expression.
+            $attributes = array();
+            preg_match_all("/([\w-]+)\s*:\s*([^;]+)\s*;?/", $this->attr['style'], $matches, PREG_SET_ORDER);
+            foreach ($matches as $match) {
+              $attributes[$match[1]] = $match[2];
+            }
+
+            // If there is a width in the style attributes:
+            if (isset($attributes['width']) && $width == -1)
+            {
+                // check that the last two characters are px (pixels)
+                if (strtolower(substr($attributes['width'], -2)) == 'px')
+                {
+                    $proposed_width = substr($attributes['width'], 0, -2);
+                    // Now make sure that it's an integer and not something stupid.
+                    if (filter_var($proposed_width, FILTER_VALIDATE_INT))
+                    {
+                        $width = $proposed_width;
+                    }
+                }
+            }
+
+            // If there is a width in the style attributes:
+            if (isset($attributes['height']) && $height == -1)
+            {
+                // check that the last two characters are px (pixels)
+                if (strtolower(substr($attributes['height'], -2)) == 'px')
+                {
+                    $proposed_height = substr($attributes['height'], 0, -2);
+                    // Now make sure that it's an integer and not something stupid.
+                    if (filter_var($proposed_height, FILTER_VALIDATE_INT))
+                    {
+                        $height = $proposed_height;
+                    }
+                }
+            }
+
+        }
+
+        // Future enhancement:
+        // Look in the tag to see if there is a class or id specified that has a height or width attribute to it.
+
+        // Far future enhancement
+        // Look at all the parent tags of this image to see if they specify a class or id that has an img selector that specifies a height or width
+        // Note that in this case, the class or id will have the img subselector for it to apply to the image.
+
+        // ridiculously far future development
+        // If the class or id is specified in a SEPARATE css file thats not on the page, go get it and do what we were just doing for the ones on the page.
+
+        $result = array('height' => $height,
+                        'width' => $width);
+        return $result;
+    }
+
+    // camel naming conventions
+    function getAllAttributes() {return $this->attr;}
+    function getAttribute($name) {return $this->__get($name);}
+    function setAttribute($name, $value) {$this->__set($name, $value);}
+    function hasAttribute($name) {return $this->__isset($name);}
+    function removeAttribute($name) {$this->__set($name, null);}
+    function getElementById($id) {return $this->find("#$id", 0);}
+    function getElementsById($id, $idx=null) {return $this->find("#$id", $idx);}
+    function getElementByTagName($name) {return $this->find($name, 0);}
+    function getElementsByTagName($name, $idx=null) {return $this->find($name, $idx);}
+    function parentNode() {return $this->parent();}
+    function childNodes($idx=-1) {return $this->children($idx);}
+    function firstChild() {return $this->first_child();}
+    function lastChild() {return $this->last_child();}
+    function nextSibling() {return $this->next_sibling();}
+    function previousSibling() {return $this->prev_sibling();}
+    function hasChildNodes() {return $this->has_child();}
+    function nodeName() {return $this->tag;}
+    function appendChild($node) {$node->parent($this); return $node;}
+
+}
+
+/**
+ * simple html dom parser
+ * Paperg - in the find routine: allow us to specify that we want case insensitive testing of the value of the selector.
+ * Paperg - change $size from protected to public so we can easily access it
+ * Paperg - added ForceTagsClosed in the constructor which tells us whether we trust the html or not.  Default is to NOT trust it.
+ *
+ * @package PlaceLocalInclude
+ */
+class simple_html_dom
+{
+    public $root = null;
+    public $nodes = array();
+    public $callback = null;
+    public $lowercase = false;
+    // Used to keep track of how large the text was when we started.
+    public $original_size;
+    public $size;
+    protected $pos;
+    protected $doc;
+    protected $char;
+    protected $cursor;
+    protected $parent;
+    protected $noise = array();
+    protected $token_blank = " \t\r\n";
+    protected $token_equal = ' =/>';
+    protected $token_slash = " />\r\n\t";
+    protected $token_attr = ' >';
+    // Note that this is referenced by a child node, and so it needs to be public for that node to see this information.
+    public $_charset = '';
+    public $_target_charset = '';
+    protected $default_br_text = "";
+    public $default_span_text = "";
+
+    // use isset instead of in_array, performance boost about 30%...
+    protected $self_closing_tags = array('img'=>1, 'br'=>1, 'input'=>1, 'meta'=>1, 'link'=>1, 'hr'=>1, 'base'=>1, 'embed'=>1, 'spacer'=>1);
+    protected $block_tags = array('root'=>1, 'body'=>1, 'form'=>1, 'div'=>1, 'span'=>1, 'table'=>1);
+    // Known sourceforge issue #2977341
+    // B tags that are not closed cause us to return everything to the end of the document.
+    protected $optional_closing_tags = array(
+        'tr'=>array('tr'=>1, 'td'=>1, 'th'=>1),
+        'th'=>array('th'=>1),
+        'td'=>array('td'=>1),
+        'li'=>array('li'=>1),
+        'dt'=>array('dt'=>1, 'dd'=>1),
+        'dd'=>array('dd'=>1, 'dt'=>1),
+        'dl'=>array('dd'=>1, 'dt'=>1),
+        'p'=>array('p'=>1),
+        'nobr'=>array('nobr'=>1),
+        'b'=>array('b'=>1),
+		'option'=>array('option'=>1),
+    );
+
+    function __construct($str=null, $lowercase=true, $forceTagsClosed=true, $target_charset=DEFAULT_TARGET_CHARSET, $stripRN=true, $defaultBRText=DEFAULT_BR_TEXT, $defaultSpanText=DEFAULT_SPAN_TEXT)
+    {
+        if ($str)
+        {
+            if (preg_match("/^http:\/\//i",$str) || is_file($str))
+            {
+                $this->load_file($str);
+            }
+            else
+            {
+                $this->load($str, $lowercase, $stripRN, $defaultBRText, $defaultSpanText);
+            }
+        }
+        // Forcing tags to be closed implies that we don't trust the html, but it can lead to parsing errors if we SHOULD trust the html.
+        if (!$forceTagsClosed) {
+            $this->optional_closing_array=array();
+        }
+        $this->_target_charset = $target_charset;
+    }
+
+    function __destruct()
+    {
+        $this->clear();
+    }
+
+    // load html from string
+    function load($str, $lowercase=true, $stripRN=true, $defaultBRText=DEFAULT_BR_TEXT, $defaultSpanText=DEFAULT_SPAN_TEXT)
+    {
+        global $debugObject;
+
+        // prepare
+        $this->prepare($str, $lowercase, $stripRN, $defaultBRText, $defaultSpanText);
+        // strip out comments
+        $this->remove_noise("'<!--(.*?)-->'is");
+        // strip out cdata
+        $this->remove_noise("'<!\[CDATA\[(.*?)\]\]>'is", true);
+        // Per sourceforge http://sourceforge.net/tracker/?func=detail&aid=2949097&group_id=218559&atid=1044037
+        // Script tags removal now preceeds style tag removal.
+        // strip out <script> tags
+        $this->remove_noise("'<\s*script[^>]*[^/]>(.*?)<\s*/\s*script\s*>'is");
+        $this->remove_noise("'<\s*script\s*>(.*?)<\s*/\s*script\s*>'is");
+        // strip out <style> tags
+        $this->remove_noise("'<\s*style[^>]*[^/]>(.*?)<\s*/\s*style\s*>'is");
+        $this->remove_noise("'<\s*style\s*>(.*?)<\s*/\s*style\s*>'is");
+        // strip out preformatted tags
+        $this->remove_noise("'<\s*(?:code)[^>]*>(.*?)<\s*/\s*(?:code)\s*>'is");
+        // strip out server side scripts
+        $this->remove_noise("'(<\?)(.*?)(\?>)'s", true);
+        // strip smarty scripts
+        $this->remove_noise("'(\{\w)(.*?)(\})'s", true);
+
+        // parsing
+        while ($this->parse());
+        // end
+        $this->root->_[HDOM_INFO_END] = $this->cursor;
+        $this->parse_charset();
+
+        // make load function chainable
+        return $this;
+
+    }
+
+    // load html from file
+    function load_file()
+    {
+        $args = func_get_args();
+        $this->load(call_user_func_array('file_get_contents', $args), true);
+        // Throw an error if we can't properly load the dom.
+        if (($error=error_get_last())!==null) {
+            $this->clear();
+            return false;
+        }
+    }
+
+    // set callback function
+    function set_callback($function_name)
+    {
+        $this->callback = $function_name;
+    }
+
+    // remove callback function
+    function remove_callback()
+    {
+        $this->callback = null;
+    }
+
+    // save dom as string
+    function save($filepath='')
+    {
+        $ret = $this->root->innertext();
+        if ($filepath!=='') file_put_contents($filepath, $ret, LOCK_EX);
+        return $ret;
+    }
+
+    // find dom node by css selector
+    // Paperg - allow us to specify that we want case insensitive testing of the value of the selector.
+    function find($selector, $idx=null, $lowercase=false)
+    {
+        return $this->root->find($selector, $idx, $lowercase);
+    }
+
+    // clean up memory due to php5 circular references memory leak...
+    function clear()
+    {
+        foreach ($this->nodes as $n) {$n->clear(); $n = null;}
+        // This add next line is documented in the sourceforge repository. 2977248 as a fix for ongoing memory leaks that occur even with the use of clear.
+        if (isset($this->children)) foreach ($this->children as $n) {$n->clear(); $n = null;}
+        if (isset($this->parent)) {$this->parent->clear(); unset($this->parent);}
+        if (isset($this->root)) {$this->root->clear(); unset($this->root);}
+        unset($this->doc);
+        unset($this->noise);
+    }
+
+    function dump($show_attr=true)
+    {
+        $this->root->dump($show_attr);
+    }
+
+    // prepare HTML data and init everything
+    protected function prepare($str, $lowercase=true, $stripRN=true, $defaultBRText=DEFAULT_BR_TEXT, $defaultSpanText=DEFAULT_SPAN_TEXT)
+    {
+        $this->clear();
+
+        // set the length of content before we do anything to it.
+        $this->size = strlen($str);
+        // Save the original size of the html that we got in.  It might be useful to someone.
+        $this->original_size = $this->size;
+
+        //before we save the string as the doc...  strip out the \r \n's if we are told to.
+        if ($stripRN) {
+            $str = str_replace("\r", " ", $str);
+            $str = str_replace("\n", " ", $str);
+
+            // set the length of content since we have changed it.
+            $this->size = strlen($str);
+        }
+
+        $this->doc = $str;
+        $this->pos = 0;
+        $this->cursor = 1;
+        $this->noise = array();
+        $this->nodes = array();
+        $this->lowercase = $lowercase;
+        $this->default_br_text = $defaultBRText;
+        $this->default_span_text = $defaultSpanText;
+        $this->root = new simple_html_dom_node($this);
+        $this->root->tag = 'root';
+        $this->root->_[HDOM_INFO_BEGIN] = -1;
+        $this->root->nodetype = HDOM_TYPE_ROOT;
+        $this->parent = $this->root;
+        if ($this->size>0) $this->char = $this->doc[0];
+    }
+
+    // parse html content
+    protected function parse()
+    {
+        if (($s = $this->copy_until_char('<'))==='')
+        {
+            return $this->read_tag();
+        }
+
+        // text
+        $node = new simple_html_dom_node($this);
+        ++$this->cursor;
+        $node->_[HDOM_INFO_TEXT] = $s;
+        $this->link_nodes($node, false);
+        return true;
+    }
+
+    // PAPERG - dkchou - added this to try to identify the character set of the page we have just parsed so we know better how to spit it out later.
+    // NOTE:  IF you provide a routine called get_last_retrieve_url_contents_content_type which returns the CURLINFO_CONTENT_TYPE from the last curl_exec
+    // (or the content_type header from the last transfer), we will parse THAT, and if a charset is specified, we will use it over any other mechanism.
+    protected function parse_charset()
+    {
+        global $debugObject;
+
+        $charset = null;
+
+        if (function_exists('get_last_retrieve_url_contents_content_type'))
+        {
+            $contentTypeHeader = get_last_retrieve_url_contents_content_type();
+            $success = preg_match('/charset=(.+)/', $contentTypeHeader, $matches);
+            if ($success)
+            {
+                $charset = $matches[1];
+                if (is_object($debugObject)) {$debugObject->debugLog(2, 'header content-type found charset of: ' . $charset);}
+            }
+
+        }
+
+        if (empty($charset))
+        {
+            $el = $this->root->find('meta[http-equiv=Content-Type]',0);
+            if (!empty($el))
+            {
+                $fullvalue = $el->content;
+                if (is_object($debugObject)) {$debugObject->debugLog(2, 'meta content-type tag found' . $fullvalue);}
+
+                if (!empty($fullvalue))
+                {
+                    $success = preg_match('/charset=(.+)/', $fullvalue, $matches);
+                    if ($success)
+                    {
+                        $charset = $matches[1];
+                    }
+                    else
+                    {
+                        // If there is a meta tag, and they don't specify the character set, research says that it's typically ISO-8859-1
+                        if (is_object($debugObject)) {$debugObject->debugLog(2, 'meta content-type tag couldn\'t be parsed. using iso-8859 default.');}
+                        $charset = 'ISO-8859-1';
+                    }
+                }
+            }
+        }
+
+        // If we couldn't find a charset above, then lets try to detect one based on the text we got...
+        if (empty($charset))
+        {
+            // Have php try to detect the encoding from the text given to us.
+            $charset = mb_detect_encoding($this->root->plaintext . "ascii", $encoding_list = array( "UTF-8", "CP1252" ) );
+            if (is_object($debugObject)) {$debugObject->debugLog(2, 'mb_detect found: ' . $charset);}
+
+            // and if this doesn't work...  then we need to just wrongheadedly assume it's UTF-8 so that we can move on - cause this will usually give us most of what we need...
+            if ($charset === false)
+            {
+                if (is_object($debugObject)) {$debugObject->debugLog(2, 'since mb_detect failed - using default of utf-8');}
+                $charset = 'UTF-8';
+            }
+        }
+
+        // Since CP1252 is a superset, if we get one of it's subsets, we want it instead.
+        if ((strtolower($charset) == strtolower('ISO-8859-1')) || (strtolower($charset) == strtolower('Latin1')) || (strtolower($charset) == strtolower('Latin-1')))
+        {
+            if (is_object($debugObject)) {$debugObject->debugLog(2, 'replacing ' . $charset . ' with CP1252 as its a superset');}
+            $charset = 'CP1252';
+        }
+
+        if (is_object($debugObject)) {$debugObject->debugLog(1, 'EXIT - ' . $charset);}
+
+        return $this->_charset = $charset;
+    }
+
+    // read tag info
+    protected function read_tag()
+    {
+        if ($this->char!=='<')
+        {
+            $this->root->_[HDOM_INFO_END] = $this->cursor;
+            return false;
+        }
+        $begin_tag_pos = $this->pos;
+        $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
+
+        // end tag
+        if ($this->char==='/')
+        {
+            $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
+            // This represents the change in the simple_html_dom trunk from revision 180 to 181.
+            // $this->skip($this->token_blank_t);
+            $this->skip($this->token_blank);
+            $tag = $this->copy_until_char('>');
+
+            // skip attributes in end tag
+            if (($pos = strpos($tag, ' '))!==false)
+                $tag = substr($tag, 0, $pos);
+
+            $parent_lower = strtolower($this->parent->tag);
+            $tag_lower = strtolower($tag);
+
+            if ($parent_lower!==$tag_lower)
+            {
+                if (isset($this->optional_closing_tags[$parent_lower]) && isset($this->block_tags[$tag_lower]))
+                {
+                    $this->parent->_[HDOM_INFO_END] = 0;
+                    $org_parent = $this->parent;
+
+                    while (($this->parent->parent) && strtolower($this->parent->tag)!==$tag_lower)
+                        $this->parent = $this->parent->parent;
+
+                    if (strtolower($this->parent->tag)!==$tag_lower) {
+                        $this->parent = $org_parent; // restore origonal parent
+                        if ($this->parent->parent) $this->parent = $this->parent->parent;
+                        $this->parent->_[HDOM_INFO_END] = $this->cursor;
+                        return $this->as_text_node($tag);
+                    }
+                }
+                else if (($this->parent->parent) && isset($this->block_tags[$tag_lower]))
+                {
+                    $this->parent->_[HDOM_INFO_END] = 0;
+                    $org_parent = $this->parent;
+
+                    while (($this->parent->parent) && strtolower($this->parent->tag)!==$tag_lower)
+                        $this->parent = $this->parent->parent;
+
+                    if (strtolower($this->parent->tag)!==$tag_lower)
+                    {
+                        $this->parent = $org_parent; // restore origonal parent
+                        $this->parent->_[HDOM_INFO_END] = $this->cursor;
+                        return $this->as_text_node($tag);
+                    }
+                }
+                else if (($this->parent->parent) && strtolower($this->parent->parent->tag)===$tag_lower)
+                {
+                    $this->parent->_[HDOM_INFO_END] = 0;
+                    $this->parent = $this->parent->parent;
+                }
+                else
+                    return $this->as_text_node($tag);
+            }
+
+            $this->parent->_[HDOM_INFO_END] = $this->cursor;
+            if ($this->parent->parent) $this->parent = $this->parent->parent;
+
+            $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
+            return true;
+        }
+
+        $node = new simple_html_dom_node($this);
+        $node->_[HDOM_INFO_BEGIN] = $this->cursor;
+        ++$this->cursor;
+        $tag = $this->copy_until($this->token_slash);
+        $node->tag_start = $begin_tag_pos;
+
+        // doctype, cdata & comments...
+        if (isset($tag[0]) && $tag[0]==='!') {
+            $node->_[HDOM_INFO_TEXT] = '<' . $tag . $this->copy_until_char('>');
+
+            if (isset($tag[2]) && $tag[1]==='-' && $tag[2]==='-') {
+                $node->nodetype = HDOM_TYPE_COMMENT;
+                $node->tag = 'comment';
+            } else {
+                $node->nodetype = HDOM_TYPE_UNKNOWN;
+                $node->tag = 'unknown';
+            }
+            if ($this->char==='>') $node->_[HDOM_INFO_TEXT].='>';
+            $this->link_nodes($node, true);
+            $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
+            return true;
+        }
+
+        // text
+        if ($pos=strpos($tag, '<')!==false) {
+            $tag = '<' . substr($tag, 0, -1);
+            $node->_[HDOM_INFO_TEXT] = $tag;
+            $this->link_nodes($node, false);
+            $this->char = $this->doc[--$this->pos]; // prev
+            return true;
+        }
+
+        if (!preg_match("/^[\w-:]+$/", $tag)) {
+            $node->_[HDOM_INFO_TEXT] = '<' . $tag . $this->copy_until('<>');
+            if ($this->char==='<') {
+                $this->link_nodes($node, false);
+                return true;
+            }
+
+            if ($this->char==='>') $node->_[HDOM_INFO_TEXT].='>';
+            $this->link_nodes($node, false);
+            $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
+            return true;
+        }
+
+        // begin tag
+        $node->nodetype = HDOM_TYPE_ELEMENT;
+        $tag_lower = strtolower($tag);
+        $node->tag = ($this->lowercase) ? $tag_lower : $tag;
+
+        // handle optional closing tags
+        if (isset($this->optional_closing_tags[$tag_lower]) )
+        {
+            while (isset($this->optional_closing_tags[$tag_lower][strtolower($this->parent->tag)]))
+            {
+                $this->parent->_[HDOM_INFO_END] = 0;
+                $this->parent = $this->parent->parent;
+            }
+            $node->parent = $this->parent;
+        }
+
+        $guard = 0; // prevent infinity loop
+        $space = array($this->copy_skip($this->token_blank), '', '');
+
+        // attributes
+        do
+        {
+            if ($this->char!==null && $space[0]==='')
+            {
+                break;
+            }
+            $name = $this->copy_until($this->token_equal);
+            if ($guard===$this->pos)
+            {
+                $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
+                continue;
+            }
+            $guard = $this->pos;
+
+            // handle endless '<'
+            if ($this->pos>=$this->size-1 && $this->char!=='>') {
+                $node->nodetype = HDOM_TYPE_TEXT;
+                $node->_[HDOM_INFO_END] = 0;
+                $node->_[HDOM_INFO_TEXT] = '<'.$tag . $space[0] . $name;
+                $node->tag = 'text';
+                $this->link_nodes($node, false);
+                return true;
+            }
+
+            // handle mismatch '<'
+            if ($this->doc[$this->pos-1]=='<') {
+                $node->nodetype = HDOM_TYPE_TEXT;
+                $node->tag = 'text';
+                $node->attr = array();
+                $node->_[HDOM_INFO_END] = 0;
+                $node->_[HDOM_INFO_TEXT] = substr($this->doc, $begin_tag_pos, $this->pos-$begin_tag_pos-1);
+                $this->pos -= 2;
+                $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
+                $this->link_nodes($node, false);
+                return true;
+            }
+
+            if ($name!=='/' && $name!=='') {
+                $space[1] = $this->copy_skip($this->token_blank);
+                $name = $this->restore_noise($name);
+                if ($this->lowercase) $name = strtolower($name);
+                if ($this->char==='=') {
+                    $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
+                    $this->parse_attr($node, $name, $space);
+                }
+                else {
+                    //no value attr: nowrap, checked selected...
+                    $node->_[HDOM_INFO_QUOTE][] = HDOM_QUOTE_NO;
+                    $node->attr[$name] = true;
+                    if ($this->char!='>') $this->char = $this->doc[--$this->pos]; // prev
+                }
+                $node->_[HDOM_INFO_SPACE][] = $space;
+                $space = array($this->copy_skip($this->token_blank), '', '');
+            }
+            else
+                break;
+        } while ($this->char!=='>' && $this->char!=='/');
+
+        $this->link_nodes($node, true);
+        $node->_[HDOM_INFO_ENDSPACE] = $space[0];
+
+        // check self closing
+        if ($this->copy_until_char_escape('>')==='/')
+        {
+            $node->_[HDOM_INFO_ENDSPACE] .= '/';
+            $node->_[HDOM_INFO_END] = 0;
+        }
+        else
+        {
+            // reset parent
+            if (!isset($this->self_closing_tags[strtolower($node->tag)])) $this->parent = $node;
+        }
+        $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
+
+        // If it's a BR tag, we need to set it's text to the default text.
+        // This way when we see it in plaintext, we can generate formatting that the user wants.
+        // since a br tag never has sub nodes, this works well.
+        if ($node->tag == "br")
+        {
+            $node->_[HDOM_INFO_INNER] = $this->default_br_text;
+        }
+
+        return true;
+    }
+
+    // parse attributes
+    protected function parse_attr($node, $name, &$space)
+    {
+        // Per sourceforge: http://sourceforge.net/tracker/?func=detail&aid=3061408&group_id=218559&atid=1044037
+        // If the attribute is already defined inside a tag, only pay atetntion to the first one as opposed to the last one.
+        if (isset($node->attr[$name]))
+        {
+            return;
+        }
+
+        $space[2] = $this->copy_skip($this->token_blank);
+        switch ($this->char) {
+            case '"':
+                $node->_[HDOM_INFO_QUOTE][] = HDOM_QUOTE_DOUBLE;
+                $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
+                $node->attr[$name] = $this->restore_noise($this->copy_until_char_escape('"'));
+                $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
+                break;
+            case '\'':
+                $node->_[HDOM_INFO_QUOTE][] = HDOM_QUOTE_SINGLE;
+                $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
+                $node->attr[$name] = $this->restore_noise($this->copy_until_char_escape('\''));
+                $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
+                break;
+            default:
+                $node->_[HDOM_INFO_QUOTE][] = HDOM_QUOTE_NO;
+                $node->attr[$name] = $this->restore_noise($this->copy_until($this->token_attr));
+        }
+        // PaperG: Attributes should not have \r or \n in them, that counts as html whitespace.
+        $node->attr[$name] = str_replace("\r", "", $node->attr[$name]);
+        $node->attr[$name] = str_replace("\n", "", $node->attr[$name]);
+        // PaperG: If this is a "class" selector, lets get rid of the preceeding and trailing space since some people leave it in the multi class case.
+        if ($name == "class") {
+            $node->attr[$name] = trim($node->attr[$name]);
+        }
+    }
+
+    // link node's parent
+    protected function link_nodes(&$node, $is_child)
+    {
+        $node->parent = $this->parent;
+        $this->parent->nodes[] = $node;
+        if ($is_child)
+        {
+            $this->parent->children[] = $node;
+        }
+    }
+
+    // as a text node
+    protected function as_text_node($tag)
+    {
+        $node = new simple_html_dom_node($this);
+        ++$this->cursor;
+        $node->_[HDOM_INFO_TEXT] = '</' . $tag . '>';
+        $this->link_nodes($node, false);
+        $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
+        return true;
+    }
+
+    protected function skip($chars)
+    {
+        $this->pos += strspn($this->doc, $chars, $this->pos);
+        $this->char = ($this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
+    }
+
+    protected function copy_skip($chars)
+    {
+        $pos = $this->pos;
+        $len = strspn($this->doc, $chars, $pos);
+        $this->pos += $len;
+        $this->char = ($this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
+        if ($len===0) return '';
+        return substr($this->doc, $pos, $len);
+    }
+
+    protected function copy_until($chars)
+    {
+        $pos = $this->pos;
+        $len = strcspn($this->doc, $chars, $pos);
+        $this->pos += $len;
+        $this->char = ($this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
+        return substr($this->doc, $pos, $len);
+    }
+
+    protected function copy_until_char($char)
+    {
+        if ($this->char===null) return '';
+
+        if (($pos = strpos($this->doc, $char, $this->pos))===false) {
+            $ret = substr($this->doc, $this->pos, $this->size-$this->pos);
+            $this->char = null;
+            $this->pos = $this->size;
+            return $ret;
+        }
+
+        if ($pos===$this->pos) return '';
+        $pos_old = $this->pos;
+        $this->char = $this->doc[$pos];
+        $this->pos = $pos;
+        return substr($this->doc, $pos_old, $pos-$pos_old);
+    }
+
+    protected function copy_until_char_escape($char)
+    {
+        if ($this->char===null) return '';
+
+        $start = $this->pos;
+        while (1)
+        {
+            if (($pos = strpos($this->doc, $char, $start))===false)
+            {
+                $ret = substr($this->doc, $this->pos, $this->size-$this->pos);
+                $this->char = null;
+                $this->pos = $this->size;
+                return $ret;
+            }
+
+            if ($pos===$this->pos) return '';
+
+            if ($this->doc[$pos-1]==='\\') {
+                $start = $pos+1;
+                continue;
+            }
+
+            $pos_old = $this->pos;
+            $this->char = $this->doc[$pos];
+            $this->pos = $pos;
+            return substr($this->doc, $pos_old, $pos-$pos_old);
+        }
+    }
+
+    // remove noise from html content
+    // save the noise in the $this->noise array.
+    protected function remove_noise($pattern, $remove_tag=false)
+    {
+        global $debugObject;
+        if (is_object($debugObject)) { $debugObject->debugLogEntry(1); }
+
+        $count = preg_match_all($pattern, $this->doc, $matches, PREG_SET_ORDER|PREG_OFFSET_CAPTURE);
+
+        for ($i=$count-1; $i>-1; --$i)
+        {
+            $key = '___noise___'.sprintf('% 5d', count($this->noise)+1000);
+            if (is_object($debugObject)) { $debugObject->debugLog(2, 'key is: ' . $key); }
+            $idx = ($remove_tag) ? 0 : 1;
+            $this->noise[$key] = $matches[$i][$idx][0];
+            $this->doc = substr_replace($this->doc, $key, $matches[$i][$idx][1], strlen($matches[$i][$idx][0]));
+        }
+
+        // reset the length of content
+        $this->size = strlen($this->doc);
+        if ($this->size>0)
+        {
+            $this->char = $this->doc[0];
+        }
+    }
+
+    // restore noise to html content
+    function restore_noise($text)
+    {
+        global $debugObject;
+        if (is_object($debugObject)) { $debugObject->debugLogEntry(1); }
+
+        while (($pos=strpos($text, '___noise___'))!==false)
+        {
+            // Sometimes there is a broken piece of markup, and we don't GET the pos+11 etc... token which indicates a problem outside of us...
+            if (strlen($text) > $pos+15)
+            {
+                $key = '___noise___'.$text[$pos+11].$text[$pos+12].$text[$pos+13].$text[$pos+14].$text[$pos+15];
+                if (is_object($debugObject)) { $debugObject->debugLog(2, 'located key of: ' . $key); }
+
+                if (isset($this->noise[$key]))
+                {
+                    $text = substr($text, 0, $pos).$this->noise[$key].substr($text, $pos+16);
+                }
+                else
+                {
+                    // do this to prevent an infinite loop.
+                    $text = substr($text, 0, $pos).'UNDEFINED NOISE FOR KEY: '.$key . substr($text, $pos+16);
+                }
+            }
+            else
+            {
+                // There is no valid key being given back to us... We must get rid of the ___noise___ or we will have a problem.
+                $text = substr($text, 0, $pos).'NO NUMERIC NOISE KEY' . substr($text, $pos+11);
+            }
+        }
+        return $text;
+    }
+
+    // Sometimes we NEED one of the noise elements.
+    function search_noise($text)
+    {
+        global $debugObject;
+        if (is_object($debugObject)) { $debugObject->debugLogEntry(1); }
+
+        foreach($this->noise as $noiseElement)
+        {
+            if (strpos($noiseElement, $text)!==false)
+            {
+                return $noiseElement;
+            }
+        }
+    }
+    function __toString()
+    {
+        return $this->root->innertext();
+    }
+
+    function __get($name)
+    {
+        switch ($name)
+        {
+            case 'outertext':
+                return $this->root->innertext();
+            case 'innertext':
+                return $this->root->innertext();
+            case 'plaintext':
+                return $this->root->text();
+            case 'charset':
+                return $this->_charset;
+            case 'target_charset':
+                return $this->_target_charset;
+        }
+    }
+
+    // camel naming conventions
+    function childNodes($idx=-1) {return $this->root->childNodes($idx);}
+    function firstChild() {return $this->root->first_child();}
+    function lastChild() {return $this->root->last_child();}
+    function createElement($name, $value=null) {return @str_get_html("<$name>$value</$name>")->first_child();}
+    function createTextNode($value) {return @end(str_get_html($value)->nodes);}
+    function getElementById($id) {return $this->find("#$id", 0);}
+    function getElementsById($id, $idx=null) {return $this->find("#$id", $idx);}
+    function getElementByTagName($name) {return $this->find($name, 0);}
+    function getElementsByTagName($name, $idx=-1) {return $this->find($name, $idx);}
+    function loadFile() {$args = func_get_args();$this->load_file($args);}
+}
+
+?>

+ 24 - 0
vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/testcase/all_test.php

@@ -0,0 +1,24 @@
+<?php
+// $Rev: 175 $
+error_reporting(E_ALL);
+
+function quick_test($html_dom, $str, $selector, $params=array('inner'=>'', 'plain'=>'', 'outer'=>'')) {
+    $html_dom->load($str);
+    $e = $html_dom->find($selector, 0);
+    if (isset($params['inner']))
+        assert($e->innertext===$params['inner']);
+    if (isset($params['plain']))
+        assert($e->plaintext===$params['plain']);
+    if (isset($params['outer']))
+        assert($e->outertext===$params['outer']);
+    assert($html_dom==$str);
+}
+
+foreach (new DirectoryIterator(getcwd()) as $entry) {
+    if ($entry->isFile() && strpos($entry, '_testcase.')>0) {
+        echo basename($entry);
+        require_once($entry);
+        echo '<br>...pass!<br><br>';
+    }
+}
+?>

+ 74 - 0
vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/testcase/callback_testcase.php

@@ -0,0 +1,74 @@
+<?php
+// $Rev: 179 $
+// -----------------------------------------------------------------------------
+// setup
+error_reporting(E_ALL);
+require_once('../simple_html_dom.php');
+$dom = new simple_html_dom;
+
+// -----------------------------------------------------------------------------
+// test problem of last emelemt not found
+$str = <<<HTML
+<img src="src0"><p>foo</p><img src="src2">
+HTML;
+
+function callback_1($e) {
+    if ($e->tag==='img')
+        $e->outertext = '';
+}
+
+$dom->load($str);
+$dom->set_callback('callback_1');
+assert($dom=='<p>foo</p>');
+
+// -----------------------------------------------
+// innertext test
+function callback_2($e) {
+    if ($e->tag==='p')
+        $e->innertext = 'bar';
+}
+
+$dom->load($str);
+$dom->set_callback('callback_2');
+assert($dom=='<img src="src0"><p>bar</p><img src="src2">');
+
+// -----------------------------------------------
+// attributes test
+function callback_3($e) {
+    if ($e->tag==='img')
+        $e->src = 'foo';
+}
+
+$dom->load($str);
+$dom->set_callback('callback_3');
+assert($dom=='<img src="foo"><p>foo</p><img src="foo">');
+
+function callback_4($e) {
+    if ($e->tag==='img')
+        $e->id = 'foo';
+}
+
+$dom->set_callback('callback_4');
+assert($dom=='<img src="foo" id="foo"><p>foo</p><img src="foo" id="foo">');
+
+// -----------------------------------------------
+// attributes test2
+//$dom = str_get_dom($str);
+$dom->load($str);
+$dom->remove_callback();
+$dom->find('img', 0)->id = "foo";
+assert($dom=='<img src="src0" id="foo"><p>foo</p><img src="src2">');
+
+function callback_5($e) {
+    if ($e->src==='src0')
+        unset($e->id);
+}
+
+$dom->set_callback('callback_5');
+assert($dom==$str);
+
+// -----------------------------------------------------------------------------
+// tear down
+$dom->clear();
+unset($dom);
+?>

+ 386 - 0
vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/testcase/dom_testcase.php

@@ -0,0 +1,386 @@
+<?php
+// $Rev: 180 $
+// -----------------------------------------------------------------------------
+// setup
+error_reporting(E_ALL);
+require_once('../simple_html_dom.php');
+$html = new simple_html_dom;
+
+// -----------------------------------------------------------------------------
+// DOM tree test
+$html->load('');
+$e = $html->root;
+assert($e->first_child()==null);
+assert($e->last_child()==null);
+assert($e->next_sibling()==null);
+assert($e->prev_sibling()==null);
+// -----------------------------------------------
+$str = '<div id="div1"></div>';
+$html->load($str);
+
+$e = $html->root;
+assert($e->first_child()->id=='div1');
+assert($e->last_child()->id=='div1');
+assert($e->next_sibling()==null);
+assert($e->prev_sibling()==null);
+assert($e->plaintext=='');
+assert($e->innertext=='<div id="div1"></div>');
+assert($e->outertext==$str);
+// -----------------------------------------------
+$str = <<<HTML
+<div id="div1">
+    <div id="div10"></div>
+    <div id="div11"></div>
+    <div id="div12"></div>
+</div>
+HTML;
+$html->load($str);
+assert($html==$str);
+
+$e = $html->find('div#div1', 0);
+assert(isset($e->id)==true);
+assert(isset($e->_not_exist)==false);
+assert($e->first_child()->id=='div10');
+assert($e->last_child()->id=='div12');
+assert($e->next_sibling()==null);
+assert($e->prev_sibling()==null);
+// -----------------------------------------------
+$str = <<<HTML
+<div id="div0">
+    <div id="div00"></div>
+</div>
+<div id="div1">
+    <div id="div10"></div>
+    <div id="div11"></div>
+    <div id="div12"></div>
+</div>
+<div id="div2"></div>
+HTML;
+$html->load($str);
+assert($html==$str);
+
+$e = $html->find('div#div1', 0);
+assert($e->first_child()->id=='div10');
+assert($e->last_child()->id=='div12');
+assert($e->next_sibling()->id=='div2');
+assert($e->prev_sibling()->id=='div0');
+
+$e = $html->find('div#div2', 0);
+assert($e->first_child()==null);
+assert($e->last_child()==null);
+
+$e = $html->find('div#div0 div#div00', 0);
+assert($e->first_child()==null);
+assert($e->last_child()==null);
+assert($e->next_sibling()==null);
+assert($e->prev_sibling()==null);
+// -----------------------------------------------
+$str = <<<HTML
+<div id="div0">
+    <div id="div00"></div>
+</div>
+<div id="div1">
+    <div id="div10"></div>
+    <div id="div11">
+        <div id="div110"></div>
+        <div id="div111">
+            <div id="div1110"></div>
+            <div id="div1111"></div>
+            <div id="div1112"></div>
+        </div>
+        <div id="div112"></div>
+    </div>
+    <div id="div12"></div>
+</div>
+<div id="div2"></div>
+HTML;
+$html->load($str);
+assert($html==$str);
+
+assert($html->find("#div1", 0)->id=='div1');
+assert($html->find("#div1", 0)->children(0)->id=='div10');
+assert($html->find("#div1", 0)->children(1)->children(1)->id=='div111');
+assert($html->find("#div1", 0)->children(1)->children(1)->children(2)->id=='div1112');
+
+// -----------------------------------------------------------------------------
+// no value attr test
+$str = <<<HTML
+<form name="form1" method="post" action="">
+    <input type="checkbox" name="checkbox0" checked value="checkbox0">aaa<br>
+    <input type="checkbox" name="checkbox1" value="checkbox1">bbb<br>
+    <input type="checkbox" name="checkbox2" value="checkbox2" checked>ccc<br>
+</form>
+HTML;
+$html->load($str);
+assert($html==$str);
+
+$counter = 0;
+foreach($html->find('input[type=checkbox]') as $checkbox) {
+    if (isset($checkbox->checked)) {
+        assert($checkbox->value=="checkbox$counter");
+        $counter += 2;
+    }
+}
+
+$counter = 0;
+foreach($html->find('input[type=checkbox]') as $checkbox) {
+    if ($checkbox->checked) {
+        assert($checkbox->value=="checkbox$counter");
+        $counter += 2;
+    }
+}
+
+$es = $html->find('input[type=checkbox]');
+$es[1]->checked = true;
+assert($es[1]->outertext=='<input type="checkbox" name="checkbox1" value="checkbox1" checked>');
+$es[0]->checked = false;
+assert($es[0]=='<input type="checkbox" name="checkbox0" value="checkbox0">');
+$es[0]->checked = true;
+assert($es[0]->outertext=='<input type="checkbox" name="checkbox0" checked value="checkbox0">');
+
+// -----------------------------------------------------------------------------
+// remove attr test
+$str = <<<HTML
+<input type="checkbox" name="checkbox0">
+<input type = "checkbox" name = 'checkbox1' value = "checkbox1">
+HTML;
+
+$html->load($str);
+assert($html==$str);
+$e = $html->find('[name=checkbox0]', 0);
+$e->name = null;
+assert($e=='<input type="checkbox">');
+$e->type = null;
+assert($e=='<input>');
+
+// -----------------------------------------------
+$html->load($str);
+assert($html==$str);
+$e = $html->find('[name=checkbox0]', 0);
+$e->name = null;
+assert($e=='<input type="checkbox">');
+$e->type = null;
+assert($e=='<input>');
+
+// -----------------------------------------------
+$html->load($str);
+assert($html==$str);
+$e = $html->find('[name=checkbox1]', 0);
+$e->value = null;
+assert($e=="<input type = \"checkbox\" name = 'checkbox1'>");
+$e->type = null;
+assert($e=="<input name = 'checkbox1'>");
+$e->name = null;
+assert($e=='<input>');
+
+$html->load($str);
+assert($html==$str);
+$e = $html->find('[name=checkbox1]', 0);
+$e->type = null;
+assert($e=="<input name = 'checkbox1' value = \"checkbox1\">");
+$e->name = null;
+assert($e=='<input value = "checkbox1">');
+$e->value = null;
+assert($e=='<input>');
+
+// -----------------------------------------------------------------------------
+// remove no value attr test
+$str = <<<HTML
+<input type="checkbox" checked name='checkbox0'>
+<input type="checkbox" name='checkbox1' checked>
+HTML;
+$html->load($str);
+assert($html==$str);
+$e = $html->find('[name=checkbox1]', 0);
+$e->type = NULL;
+assert($e=="<input name='checkbox1' checked>");
+$e->name = null;
+assert($e=="<input checked>");
+$e->checked = NULL;
+assert($e=="<input>");
+
+// -----------------------------------------------
+$html->load($str);
+assert($html==$str);
+$e = $html->find('[name=checkbox0]', 0);
+$e->type = NULL;
+assert($e=="<input checked name='checkbox0'>");
+$e->name = NULL;
+assert($e=='<input checked>');
+$e->checked = NULL;
+assert($e=='<input>');
+
+$html->load($str);
+assert($html==$str);
+$e = $html->find('[name=checkbox0]', 0);
+$e->checked = NULL;
+assert($e=="<input type=\"checkbox\" name='checkbox0'>");
+$e->name = NULL;
+assert($e=='<input type="checkbox">');
+$e->type = NULL;
+assert($e=="<input>");
+
+// -----------------------------------------------------------------------------
+// extract text
+$str = <<<HTML
+<b>okok</b>
+HTML;
+$html->load($str);
+assert($html==$str);
+assert($html->plaintext=='okok');
+
+$str = <<<HTML
+<div><b>okok</b></div>
+HTML;
+$html->load($str);
+assert($html==$str);
+assert($html->plaintext=='okok');
+
+$str = <<<HTML
+<div><b>okok</b>
+HTML;
+$html->load($str);
+assert($html==$str);
+assert($html->plaintext=='okok');
+
+$str = <<<HTML
+<b>okok</b></div>
+HTML;
+$html->load($str);
+assert($html==$str);
+assert($html->plaintext=='okok</div>');
+
+
+// -----------------------------------------------------------------------------
+// old fashion camel naming conventions test
+$str = <<<HTML
+<input type="checkbox" id="checkbox" name="checkbox" value="checkbox" checked>
+<input type="checkbox" id="checkbox1" name="checkbox1" value="checkbox1">
+<input type="checkbox" id="checkbox2" name="checkbox2" value="checkbox2" checked>
+HTML;
+$html->load($str);
+assert($html==$str);
+
+assert($html->getElementByTagName('input')->hasAttribute('checked')==true);
+assert($html->getElementsByTagName('input', 1)->hasAttribute('checked')==false);
+assert($html->getElementsByTagName('input', 1)->hasAttribute('not_exist')==false);
+
+assert($html->find('input', 0)->value==$html->getElementByTagName('input')->getAttribute('value'));
+assert($html->find('input', 1)->value==$html->getElementsByTagName('input', 1)->getAttribute('value'));
+
+assert($html->find('#checkbox1', 0)->value==$html->getElementById('checkbox1')->getAttribute('value'));
+assert($html->find('#checkbox2', 0)->value==$html->getElementsById('checkbox2', 0)->getAttribute('value'));
+
+$e = $html->find('[name=checkbox]', 0);
+assert($e->getAttribute('value')=='checkbox');
+assert($e->getAttribute('checked')==true);
+assert($e->getAttribute('not_exist')=='');
+
+$e->setAttribute('value', 'okok');
+assert($e=='<input type="checkbox" id="checkbox" name="checkbox" value="okok" checked>');
+
+$e->setAttribute('checked', false);
+assert($e=='<input type="checkbox" id="checkbox" name="checkbox" value="okok">');
+
+$e->setAttribute('checked', true);
+assert($e=='<input type="checkbox" id="checkbox" name="checkbox" value="okok" checked>');
+
+$e->removeAttribute('value');
+assert($e=='<input type="checkbox" id="checkbox" name="checkbox" checked>');
+
+$e->removeAttribute('checked');
+assert($e=='<input type="checkbox" id="checkbox" name="checkbox">');
+
+// -----------------------------------------------
+$str = <<<HTML
+<div id="div1">
+    <div id="div10"></div>
+    <div id="div11"></div>
+    <div id="div12"></div>
+</div>
+HTML;
+$html->load($str);
+assert($html==$str);
+
+$e = $html->find('div#div1', 0);
+assert($e->firstChild()->getAttribute('id')=='div10');
+assert($e->lastChild()->getAttribute('id')=='div12');
+assert($e->nextSibling()==null);
+assert($e->previousSibling()==null);
+
+// -----------------------------------------------
+$str = <<<HTML
+<div id="div0">
+    <div id="div00"></div>
+</div>
+<div id="div1">
+    <div id="div10"></div>
+    <div id="div11">
+        <div id="div110"></div>
+        <div id="div111">
+            <div id="div1110"></div>
+            <div id="div1111"></div>
+            <div id="div1112"></div>
+        </div>
+        <div id="div112"></div>
+    </div>
+    <div id="div12"></div>
+</div>
+<div id="div2"></div>
+HTML;
+$html->load($str);
+assert($html==$str);
+
+assert($html->getElementById("div1")->hasAttribute('id')==true);
+assert($html->getElementById("div1")->hasAttribute('not_exist')==false);
+
+assert($html->getElementById("div1")->getAttribute('id')=='div1');
+assert($html->getElementById("div1")->childNodes(0)->getAttribute('id')=='div10');
+assert($html->getElementById("div1")->childNodes(1)->childNodes(1)->getAttribute('id')=='div111');
+assert($html->getElementById("div1")->childNodes(1)->childNodes(1)->childNodes(2)->getAttribute('id')=='div1112');
+
+assert($html->getElementsById("div1", 0)->childNodes(1)->id=='div11');
+assert($html->getElementsById("div1", 0)->childNodes(1)->childNodes(1)->getAttribute('id')=='div111');
+assert($html->getElementsById("div1", 0)->childNodes(1)->childNodes(1)->childNodes(1)->getAttribute('id')=='div1111');
+
+// -----------------------------------------------
+$str = <<<HTML
+<ul class="menublock">
+    </li>
+        <ul>
+            <li>
+                <a href="http://www.cyberciti.biz/tips/pollsarchive">Polls Archive</a>
+            </li>
+        </ul>
+    </li>
+</ul>
+HTML;
+$html->load($str);
+
+$ul = $html->find('ul', 0);
+assert($ul->first_child()->tag==='ul');
+
+// -----------------------------------------------
+$str = <<<HTML
+<ul>
+    <li>Item 1 
+        <ul>
+            <li>Sub Item 1 </li>
+            <li>Sub Item 2 </li>
+        </ul>
+    </li>
+    <li>Item 2 </li>
+</ul>
+HTML;
+
+$html->load($str);
+assert($html==$str);
+
+$ul = $html->find('ul', 0);
+assert($ul->first_child()->tag==='li');
+assert($ul->first_child()->next_sibling()->tag==='li');
+// -----------------------------------------------------------------------------
+// tear down
+$html->clear();
+unset($html);
+?>

+ 247 - 0
vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/testcase/element_testcase.php

@@ -0,0 +1,247 @@
+<?php
+// -----------------------------------------------------------------------------
+// setup
+error_reporting(E_ALL);
+require_once('../simple_html_dom.php');
+$dom = new simple_html_dom;
+
+// -----------------------------------------------------------------------------
+// innertext test
+$str = <<<HTML
+<html>
+    <head></head>
+    <body>
+        <br>
+        <span>foo</span>
+    </body>
+</html>
+HTML;
+$dom->load($str);
+assert($dom==$str);
+// -----------------------------------------------
+$str = <<<HTML
+<html>
+    <head></head>
+    <body>
+        <br>
+        <span>bar</span>
+    </body>
+</html>
+HTML;
+$dom->load($str);
+$dom->find('span', 0)->innertext = 'bar';
+assert($dom==$str);
+// -----------------------------------------------
+$str = <<<HTML
+<html>
+    <head>ok</head>
+    <body>
+        <br>
+        <span>bar</span>
+    </body>
+</html>
+HTML;
+$dom->load($str);
+$dom->find('head', 0)->innertext = 'ok';
+assert($dom==$str);
+// -----------------------------------------------
+$str = <<<HTML
+<b>foo</b>
+HTML;
+$dom->load($str);
+
+$e = $dom->find('b text', 0);
+assert($e->innertext=='foo');
+assert($e->outertext=='foo');
+$e->innertext = 'bar';
+assert($e->innertext=='bar');
+assert($e->outertext=='bar');
+$e = $dom->find('b', 0);
+assert($e->innertext=='bar');
+assert($e->outertext=='<b>bar</b>');
+
+// -----------------------------------------------------------------------------
+// outertext test
+$str = <<<HTML
+<table>
+<tr><th>Head1</th><th>Head2</th><th>Head3</th></tr>
+<tr><td>1</td><td>2</td><td>3</td></tr>
+</table>
+HTML;
+$dom->load($str);
+assert($dom->find('tr', 0)->outertext=='<tr><th>Head1</th><th>Head2</th><th>Head3</th></tr>');
+assert($dom->find('tr', 1)->outertext=='<tr><td>1</td><td>2</td><td>3</td></tr>');
+// -----------------------------------------------
+$str = <<<HTML
+<table><tr><th>Head1</th><th>Head2</th><th>Head3</th><tr><td>1</td><td>2</td><td>3</td></table>
+HTML;
+$dom->load($str);
+assert($dom->find('tr', 0)->outertext=='<tr><th>Head1</th><th>Head2</th><th>Head3</th>');
+assert($dom->find('tr', 1)->outertext=='<tr><td>1</td><td>2</td><td>3</td>');
+
+// -----------------------------------------------
+$str = <<<HTML
+<ul><li><b>li11</b></li><li><b>li12</b></li></ul><ul><li><b>li21</b></li><li><b>li22</b></li></ul>
+HTML;
+$dom->load($str);
+assert($dom->find('ul', 0)->outertext=='<ul><li><b>li11</b></li><li><b>li12</b></li></ul>');
+assert($dom->find('ul', 1)->outertext=='<ul><li><b>li21</b></li><li><b>li22</b></li></ul>');
+
+// -----------------------------------------------
+$str = <<<HTML
+<ul><li><b>li11</b></li><li><b>li12</b></li><ul><li><b>li21</b></li><li><b>li22</b></li>
+HTML;
+$dom->load($str);
+assert($dom->find('ul', 0)->outertext=='<ul><li><b>li11</b></li><li><b>li12</b></li><ul><li><b>li21</b></li><li><b>li22</b></li>');
+assert($dom->find('ul', 1)->outertext=='<ul><li><b>li21</b></li><li><b>li22</b></li>');
+
+// -----------------------------------------------
+$str = <<<HTML
+<ul><li><b>li11</b><li><b>li12</b></li><ul><li><b>li21</b></li><li><b>li22</b>
+HTML;
+$dom->load($str);
+assert($dom->find('ul', 0)->outertext=='<ul><li><b>li11</b><li><b>li12</b></li><ul><li><b>li21</b></li><li><b>li22</b>');
+assert($dom->find('ul', 1)->outertext=='<ul><li><b>li21</b></li><li><b>li22</b>');
+
+// -----------------------------------------------
+$str = <<<HTML
+<table>
+<tr><th>Head1</th><th>Head2</th><th>Head3</th></tr>
+<tr><td>1</td><td>2</td><td>3</td></tr>
+</table>
+HTML;
+$dom->load($str);
+assert($dom->find('tr', 0)->outertext=='<tr><th>Head1</th><th>Head2</th><th>Head3</th></tr>');
+assert($dom->find('tr', 1)->outertext=='<tr><td>1</td><td>2</td><td>3</td></tr>');
+
+// -----------------------------------------------------------------------------
+// replacement test
+$str = <<<HTML
+<div class="class1" id="id2" ><div class="class2">ok</div></div>
+HTML;
+$dom->load($str);
+$es = $dom->find('div');
+assert(count($es)==2);
+assert($es[0]->innertext=='<div class="class2">ok</div>');
+assert($es[0]->outertext=='<div class="class1" id="id2" ><div class="class2">ok</div></div>');
+
+// test isset
+$es[0]->class = 'class_test';
+assert(isset($es[0]->class)===true);
+assert(isset($es[0]->okok)===false);
+
+// test replacement
+$es[0]->class = 'class_test';
+assert($es[0]->outertext=='<div class="class_test" id="id2" ><div class="class2">ok</div></div>');
+
+// test replacement
+$es[0]->tag = 'span';
+assert($es[0]->outertext=='<span class="class_test" id="id2" ><div class="class2">ok</div></span>');
+
+// test unset (no more support...)
+//$dom = str_get_dom($str);
+//$es = $dom->find('div');
+//unset($es[0]->class);
+//assert($es[0]->outertext=='<div id="id2" ><div class="class2">ok</div></div>');
+
+$dom->load($str);
+$es = $dom->find('div');
+unset($es[0]->attr['class']);
+assert($es[0]->outertext=='<div id="id2" ><div class="class2">ok</div></div>');
+
+// -----------------------------------------------
+$str = <<<HTML
+<select name=something><options>blah</options><options>blah2</options></select>
+HTML;
+$dom->load($str);
+$e = $dom->find('select[name=something]', 0);
+$e->innertext = '';
+assert($e->outertext =='<select name=something></select>');
+
+// -----------------------------------------------------------------------------
+// nested replacement test
+$str = <<<HTML
+<div class="class0" id="id0" ><div class="class1">ok</div></div>
+HTML;
+$dom->load($str);
+$es = $dom->find('div');
+assert(count($es)==2);
+assert($es[0]->innertext=='<div class="class1">ok</div>');
+assert($es[0]->outertext=='<div class="class0" id="id0" ><div class="class1">ok</div></div>');
+assert($es[1]->innertext=='ok');
+assert($es[1]->outertext=='<div class="class1">ok</div>');
+
+// test replacement
+$es[1]->innertext = 'okok';
+assert($es[1]->outertext=='<div class="class1">okok</div>');
+assert($es[0]->outertext=='<div class="class0" id="id0" ><div class="class1">okok</div></div>');
+assert($dom=='<div class="class0" id="id0" ><div class="class1">okok</div></div>');
+
+$es[1]->class = 'class_test';
+assert($es[1]->outertext=='<div class="class_test">okok</div>');
+assert($es[0]->outertext=='<div class="class0" id="id0" ><div class="class_test">okok</div></div>');
+assert($dom=='<div class="class0" id="id0" ><div class="class_test">okok</div></div>');
+
+$es[0]->class = 'class_test';
+assert($es[0]->outertext=='<div class="class_test" id="id0" ><div class="class_test">okok</div></div>');
+assert($dom=='<div class="class_test" id="id0" ><div class="class_test">okok</div></div>');
+
+$es[0]->innertext = 'okokok';
+assert($es[0]->outertext=='<div class="class_test" id="id0" >okokok</div>');
+assert($dom=='<div class="class_test" id="id0" >okokok</div>');
+
+// -----------------------------------------------------------------------------
+// <p> test
+$str = <<<HTML
+<div class="class0">
+    <p>ok0<a href="#">link0</a></p>
+    <div class="class1"><p>ok1<a href="#">link1</a></p></div>
+    <div class="class2"></div>
+    <p>ok2<a href="#">link2</a></p>
+</div>
+HTML;
+$dom->load($str);
+$es  = $dom->find('p');
+assert($es[0]->innertext=='ok0<a href="#">link0</a>');
+assert($es[1]->innertext=='ok1<a href="#">link1</a>');
+assert($es[2]->innertext=='ok2<a href="#">link2</a>');
+assert($dom->find('p', 0)->plaintext=='ok0link0');
+assert($dom->find('p', 1)->plaintext=='ok1link1');
+assert($dom->find('p', 2)->plaintext=='ok2link2');
+
+$count = 0;
+foreach($dom->find('p') as $p) {
+    $a = $p->find('a');
+    assert($a[0]->innertext=='link'.$count);
+    ++$count;
+}
+
+$es = $dom->find('p a');
+assert($es[0]->innertext=='link0');
+assert($es[1]->innertext=='link1');
+assert($es[2]->innertext=='link2');
+assert($dom->find('p a', 0)->plaintext=='link0');
+assert($dom->find('p a', 1)->plaintext=='link1');
+assert($dom->find('p a', 2)->plaintext=='link2');
+
+assert($dom==$str);
+
+// -----------------------------------------------------------------------------
+// <embed> test
+$str = <<<HTML
+<EMBED 
+   SRC="../graphics/sounds/1812over.mid"
+   HEIGHT=60 WIDTH=144>
+HTML;
+$dom->load($str);
+$e = $dom->find('embed', 0);
+assert($e->src=='../graphics/sounds/1812over.mid');
+assert($e->height=='60');
+assert($e->width=='144');
+assert($dom==strtolower($str));
+
+// -----------------------------------------------------------------------------
+// tear down
+$dom->clear();
+unset($dom);
+?>

+ 658 - 0
vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/testcase/invalid_testcase.php

@@ -0,0 +1,658 @@
+<?php
+// -----------------------------------------------------------------------------
+// setup
+error_reporting(E_ALL);
+require_once('../simple_html_dom.php');
+$dom = new simple_html_dom;
+
+// -----------------------------------------------------------------------------
+//self-closing tags test
+$str = <<<HTML
+<hr>
+HTML;
+$dom->load($str);
+$e = $dom->find('hr', 0);
+$e->id= 'foo';
+assert($e->outertext=='<hr id="foo">');
+// -----------------------------------------------
+$str = <<<HTML
+<hr/>
+HTML;
+$dom->load($str);
+$e = $dom->find('hr', 0);
+$e->id= 'foo';
+assert($e->outertext=='<hr id="foo"/>');
+// -----------------------------------------------
+$str = <<<HTML
+<hr />
+HTML;
+$dom->load($str);
+$e = $dom->find('hr', 0);
+$e->id= 'foo';
+assert($e->outertext=='<hr id="foo" />');
+// -----------------------------------------------
+$str = <<<HTML
+<hr>
+HTML;
+$dom->load($str);
+$e = $dom->find('hr', 0);
+$e->id= 'foo';
+$e->class = 'bar';
+assert($e->outertext=='<hr id="foo" class="bar">');
+// -----------------------------------------------
+$str = <<<HTML
+<hr/>
+HTML;
+$dom->load($str);
+$e = $dom->find('hr', 0);
+$e->id= 'foo';
+$e->class = 'bar';
+assert($e->outertext=='<hr id="foo" class="bar"/>');
+// -----------------------------------------------
+$str = <<<HTML
+<hr />
+HTML;
+$dom->load($str);
+$e = $dom->find('hr', 0);
+$e->id= 'foo';
+$e->class = 'bar';
+assert($e->outertext=='<hr id="foo" class="bar" />');
+// -----------------------------------------------
+$str = <<<HTML
+<hr id="foo" kk=ll>
+HTML;
+$dom->load($str);
+$e = $dom->find('hr', 0);
+$e->class = 'bar';
+assert($e->outertext=='<hr id="foo" kk=ll class="bar">');
+// -----------------------------------------------
+$str = <<<HTML
+<hr id="foo" kk="ll"/>
+HTML;
+$dom->load($str);
+$e = $dom->find('hr', 0);
+$e->class = 'bar';
+assert($e->outertext=='<hr id="foo" kk="ll" class="bar"/>');
+// -----------------------------------------------
+$str = <<<HTML
+<hr id="foo" kk=ll />
+HTML;
+$dom->load($str);
+$e = $dom->find('hr', 0);
+$e->class = 'bar';
+assert($e->outertext=='<hr id="foo" kk=ll class="bar" />');
+
+// -----------------------------------------------
+$str = <<<HTML
+<div><nobr></div>
+HTML;
+$dom->load($str);
+$e = $dom->find('nobr', 0);
+assert($e->outertext=='<nobr>');
+
+// -----------------------------------------------------------------------------
+// optional closing tags test
+$str = <<<HTML
+<body>
+</b><.b></a>
+</body>
+HTML;
+$dom = str_get_html($str);
+assert($dom->find('body', 0)->outertext==$str);
+
+// -----------------------------------------------
+$str = <<<HTML
+<html>
+    <body>
+        <a>foo</a>
+        <a>foo2</a>
+HTML;
+$dom = str_get_html($str);
+assert($dom==$str);
+assert($dom->find('html body a', 1)->innertext=='foo2');
+
+// -----------------------------------------------
+$str = <<<HTML
+HTML;
+$dom = str_get_html($str);
+assert($dom==$str);
+assert($dom->find('html a', 1)===null);
+//assert($dom->find('html a', 1)->innertext=='foo2');
+
+// -----------------------------------------------
+$str = <<<HTML
+<body>
+<div>
+</body>
+HTML;
+$dom = str_get_html($str);
+assert($dom==$str);
+assert($dom->find('body', 0)->outertext==$str);
+
+// -----------------------------------------------
+$str = <<<HTML
+<body>
+<div> </a> </div>
+</body>
+HTML;
+$dom = str_get_html($str);
+
+assert($dom->find('body', 0)->outertext==$str);
+
+// -----------------------------------------------
+$str = <<<HTML
+<table>
+    <tr>
+        <td><b>aa</b>
+    <tr>
+        <td><b>bb</b>
+</table>
+HTML;
+$dom = str_get_html($str);
+
+assert($dom==$str);
+
+// -----------------------------------------------
+$str = <<<HTML
+<table>
+<tr><td>1<td>2<td>3
+</table>
+HTML;
+$dom = str_get_html($str);
+assert(count($dom->find('td'))==3);
+assert($dom->find('td', 0)->innertext=='1');
+assert($dom->find('td', 0)->outertext=='<td>1');
+assert($dom->find('td', 1)->innertext=='2');
+assert($dom->find('td', 1)->outertext=='<td>2');
+assert($dom->find('td', 2)->innertext=="3\r\n");
+assert($dom->find('td', 2)->outertext=="<td>3\r\n");
+
+// -----------------------------------------------
+$str = <<<HTML
+<table>
+<tr>
+    <td><b>1</b></td>
+    <td><b>2</b></td>
+    <td><b>3</b></td>
+</table>
+HTML;
+$dom = str_get_html($str);
+assert(count($dom->find('tr td'))==3);
+
+// -----------------------------------------------
+$str = <<<HTML
+<table>
+<tr><td><b>11</b></td><td><b>12</b></td><td><b>13</b></td>
+<tr><td><b>21</b></td><td><b>32</b></td><td><b>43</b></td>
+</table>
+HTML;
+$dom = str_get_html($str);
+assert(count($dom->find('tr'))==2);
+assert(count($dom->find('tr td'))==6);
+assert($dom->find('tr', 1)->outertext=="<tr><td><b>21</b></td><td><b>32</b></td><td><b>43</b></td>\r\n");
+assert($dom->find('tr', 1)->innertext=="<td><b>21</b></td><td><b>32</b></td><td><b>43</b></td>\r\n");
+assert($dom->find('tr', 1)->plaintext=="213243\r\n");
+
+// -----------------------------------------------
+$str = <<<HTML
+<p>1
+<p>2</p>
+<p>3
+HTML;
+$dom = str_get_html($str);
+assert(count($dom->find('p'))==3);
+assert($dom->find('p', 0)->innertext=="1\r\n");
+assert($dom->find('p', 0)->outertext=="<p>1\r\n");
+assert($dom->find('p', 1)->innertext=="2");
+assert($dom->find('p', 1)->outertext=="<p>2</p>");
+assert($dom->find('p', 2)->innertext=="3");
+assert($dom->find('p', 2)->outertext=="<p>3");
+
+// -----------------------------------------------
+$str = <<<HTML
+<nobr>1
+<nobr>2</nobr>
+<nobr>3
+HTML;
+$dom = str_get_html($str);
+assert(count($dom->find('nobr'))==3);
+assert($dom->find('nobr', 0)->innertext=="1\r\n");
+assert($dom->find('nobr', 0)->outertext=="<nobr>1\r\n");
+assert($dom->find('nobr', 1)->innertext=="2");
+assert($dom->find('nobr', 1)->outertext=="<nobr>2</nobr>");
+assert($dom->find('nobr', 2)->innertext=="3");
+assert($dom->find('nobr', 2)->outertext=="<nobr>3");
+
+// -----------------------------------------------
+$str = <<<HTML
+<dl><dt>1<dd>2<dt>3<dd>4</dl>
+HTML;
+$dom = str_get_html($str);
+assert(count($dom->find('dt'))==2);
+assert(count($dom->find('dd'))==2);
+assert($dom->find('dt', 0)->innertext=="1");
+assert($dom->find('dt', 0)->outertext=="<dt>1");
+assert($dom->find('dt', 1)->innertext=="3");
+assert($dom->find('dt', 1)->outertext=="<dt>3");
+assert($dom->find('dd', 0)->innertext=="2");
+assert($dom->find('dd', 0)->outertext=="<dd>2");
+assert($dom->find('dd', 1)->innertext=="4");
+assert($dom->find('dd', 1)->outertext=="<dd>4");
+
+// -----------------------------------------------
+$str = <<<HTML
+<dl id="dl1"><dt>11<dd>12<dt>13<dd>14</dl>
+<dl id="dl2"><dt>21<dd>22<dt>23<dd>24</dl>
+HTML;
+$dom = str_get_html($str);
+assert(count($dom->find('#dl1 dt'))==2);
+assert(count($dom->find('#dl2  dd'))==2);
+assert($dom->find('dl', 0)->innertext=="<dt>11<dd>12<dt>13<dd>14");
+assert($dom->find('dl', 1)->innertext=="<dt>21<dd>22<dt>23<dd>24");
+
+// -----------------------------------------------
+$str = <<<HTML
+<ul id="ul1"><li><b>1</b><li><b>2</b></ul>
+<ul id="ul2"><li><b>3</b><li><b>4</b></ul>
+HTML;
+$dom = str_get_html($str);
+assert(count($dom->find('ul[id=ul1] li'))==2);
+
+// -----------------------------------------------------------------------------
+// invalid test
+$str = <<<HTML
+<div>
+    <div class="class0" id="id0" >
+    <img class="class0" id="id0" src="src0">
+    </img>
+    <img class="class0" id="id0" src="src0">
+    </div>
+</div>
+HTML;
+$dom->load($str);
+assert(count($dom->find('img'))==2);
+assert(count($dom->find('img'))==2);
+assert($dom==$str);
+
+// -----------------------------------------------
+$str = <<<HTML
+<div>
+    <div class="class0" id="id0" >
+    <span></span>
+    </span>
+    <span></span>
+    </div>
+</div>
+HTML;
+
+$dom->load($str);
+assert(count($dom->find('span'))==2);
+assert(count($dom->find('div'))==2);
+assert($dom==$str);
+
+// -----------------------------------------------
+$str = <<<HTML
+<div>
+    <div class="class0" id="id0" >
+    <span></span>
+    <span>
+    <span></span>
+    </div>
+</div>
+HTML;
+$dom->load($str);
+assert(count($dom->find('span'))==3);
+assert(count($dom->find('div'))==2);
+assert($dom==$str);
+
+// -----------------------------------------------
+$str = <<<HTML
+<ul class="menublock">
+    </li>
+        <ul>
+            <li>
+                <a href="http://www.cyberciti.biz/tips/pollsarchive">Polls Archive</a>
+            </li>
+        </ul>
+    </li>
+</ul>
+HTML;
+$dom->load($str);
+assert(count($dom->find('ul'))==2);
+assert(count($dom->find('ul ul'))==1);
+assert(count($dom->find('li'))==1);
+assert(count($dom->find('a'))==1);
+assert($dom==$str);
+
+// -----------------------------------------------
+$str = <<<HTML
+<td>
+    <div>
+        </span>
+    </div>
+</td>
+HTML;
+$dom->load($str);
+assert(count($dom->find('td'))==1);
+assert(count($dom->find('div'))==1);
+assert(count($dom->find('td div'))==1);
+assert($dom==$str);
+
+// -----------------------------------------------
+$str = <<<HTML
+<td>
+    <div>
+        </b>
+    </div>
+</td>
+HTML;
+$dom->load($str);
+assert(count($dom->find('td'))==1);
+assert(count($dom->find('div'))==1);
+assert(count($dom->find('td div'))==1);
+assert($dom==$str);
+
+// -----------------------------------------------
+$str = <<<HTML
+<td>
+    <div></div>
+    </div>
+</td>
+HTML;
+$dom->load($str);
+assert(count($dom->find('td'))==1);
+assert(count($dom->find('div'))==1);
+assert(count($dom->find('td div'))==1);
+assert($dom==$str);
+
+// -----------------------------------------------
+$str = <<<HTML
+<html>
+    <body>
+        <table>
+            <tr>
+                foo</span>
+                <span>bar</span>
+                </span>important
+            </tr>
+        </table>
+    </bod>
+</html>
+HTML;
+$dom->load($str);
+assert(count($dom->find('table span'))===1);
+assert($dom->find('table span', 0)->innertext==='bar');
+assert($dom==$str);
+
+// -----------------------------------------------
+$str = <<<HTML
+<td>
+    <div>
+        <font>
+            <b>foo</b>
+    </div>
+</td>
+HTML;
+$dom->load($str);
+assert(count($dom->find('td div font b'))==1);
+assert($dom==$str);
+
+// -----------------------------------------------
+$str = <<<HTML
+<span style="okokok">
+... then slow into 287 
+    <i> 
+        <b> 
+            <font color="#0000CC">(hanover0...more volume between 202 & 53 
+            <i> 
+                <b> 
+                    <font color="#0000CC">(parsippany)</font> 
+                </b>
+            </i>
+            ...then sluggish in spots out to dover chester road 
+            <i> 
+                <b> 
+                    <font color="#0000CC">(randolph)</font> 
+                </b> 
+            </i>..then traffic light delays out to route 46 
+            <i> 
+                <b> 
+                    <font color="#0000CC">(roxbury)</font> 
+                </b> 
+            </i>/eb slow into 202 
+            <i> 
+                <b> 
+                    <font color="#0000CC">(morris plains)</font> 
+                </b> 
+            </i> & again into 287 
+            <i> 
+                <b> 
+                    <font color="#0000CC">(hanover)</font>
+                </b> 
+            </i> 
+</span>. 
+<td class="d N4 c">52</td> 
+HTML;
+$dom->load($str);
+assert(count($dom->find('span td'))==0);
+assert($dom==$str);
+
+// -----------------------------------------------------------------------------
+// invalid '<'
+// -----------------------------------------------
+$str = <<<HTML
+<td><b>test :</b>1 gram but <5 grams</td>
+HTML;
+$dom->load($str);
+assert($dom->find('td', 0)->innertext==='<b>test :</b>1 gram but <5 grams');
+assert($dom->find('td', 0)->plaintext==='test :1 gram but <5 grams');
+assert($dom==$str);
+
+$str = <<<HTML
+<td><b>test :</b>1 gram but<5 grams</td>
+HTML;
+$dom->load($str);
+assert($dom->find('td', 0)->innertext==='<b>test :</b>1 gram but<5 grams');
+assert($dom->find('td', 0)->plaintext==='test :1 gram but<5 grams');
+assert($dom==$str);
+
+$str = <<<HTML
+<td><b>test :</b>1 gram but< 5 grams</td>
+HTML;
+$dom->load($str);
+assert($dom->find('td', 0)->innertext==='<b>test :</b>1 gram but< 5 grams');
+assert($dom->find('td', 0)->plaintext==='test :1 gram but< 5 grams');
+assert($dom==$str);
+
+$str = <<<HTML
+<td><b>test :</b>1 gram but < 5 grams</td>
+HTML;
+$dom->load($str);
+assert($dom->find('td', 0)->innertext==='<b>test :</b>1 gram but < 5 grams');
+assert($dom->find('td', 0)->plaintext==='test :1 gram but < 5 grams');
+assert($dom==$str);
+
+$str = <<<HTML
+<td><b>test :</b>1 gram but 5< grams</td>
+HTML;
+$dom->load($str);
+assert($dom->find('td', 0)->innertext==='<b>test :</b>1 gram but 5< grams');
+assert($dom->find('td', 0)->plaintext==='test :1 gram but 5< grams');
+assert($dom==$str);
+
+$str = <<<HTML
+<td><b>test :</b>1 gram but 5 < grams</td>
+HTML;
+$dom->load($str);
+assert($dom->find('td', 0)->innertext==='<b>test :</b>1 gram but 5 < grams');
+assert($dom->find('td', 0)->plaintext==='test :1 gram but 5 < grams');
+assert($dom==$str);
+
+$str = <<<HTML
+<td><b>test :</b>1 gram but 5 <grams</td>
+HTML;
+$dom->load($str);
+assert($dom->find('td', 0)->innertext==='<b>test :</b>1 gram but 5 <grams');
+assert($dom->find('td', 0)->plaintext==='test :1 gram but 5 <grams');
+assert($dom==$str);
+// -----------------------------------------------
+$str = <<<HTML
+<td><b>test :</b>1 gram but 5< grams</td>
+HTML;
+$dom->load($str);
+assert($dom->find('td', 0)->innertext==='<b>test :</b>1 gram but 5< grams');
+assert($dom->find('td', 0)->plaintext==='test :1 gram but 5< grams');
+assert($dom==$str);
+
+$str = <<<HTML
+<td><b>test :</b>1 gram but5< grams</td>
+HTML;
+$dom->load($str);
+assert($dom->find('td', 0)->innertext==='<b>test :</b>1 gram but5< grams');
+assert($dom->find('td', 0)->plaintext==='test :1 gram but5< grams');
+assert($dom==$str);
+
+$str = <<<HTML
+<td><b>test :</b>1 gram but 5 <grams</td>
+HTML;
+$dom->load($str);
+assert($dom->find('td', 0)->innertext==='<b>test :</b>1 gram but 5 <grams');
+assert($dom->find('td', 0)->plaintext==='test :1 gram but 5 <grams');
+assert($dom==$str);
+
+$str = <<<HTML
+<td><b>test :</b>1 gram but 5<grams</td>
+HTML;
+$dom->load($str);
+assert($dom->find('td', 0)->innertext==='<b>test :</b>1 gram but 5<grams');
+assert($dom->find('td', 0)->plaintext==='test :1 gram but 5<grams');
+assert($dom==$str);
+
+$str = <<<HTML
+<td><b>test :</b>1 gram but 5 <grams</td>
+HTML;
+$dom->load($str);
+assert($dom->find('td', 0)->innertext==='<b>test :</b>1 gram but 5 <grams');
+assert($dom->find('td', 0)->plaintext==='test :1 gram but 5 <grams');
+assert($dom==$str);
+
+// -----------------------------------------------------------------------------
+// invalid '>'
+// -----------------------------------------------
+$str = <<<HTML
+<td><b>test :</b>1 gram but >5 grams</td>
+HTML;
+$dom->load($str);
+assert($dom->find('td', 0)->innertext==='<b>test :</b>1 gram but >5 grams');
+assert($dom->find('td', 0)->plaintext==='test :1 gram but >5 grams');
+assert($dom==$str);
+
+$str = <<<HTML
+<td><b>test :</b>1 gram but>5 grams</td>
+HTML;
+$dom->load($str);
+assert($dom->find('td', 0)->innertext==='<b>test :</b>1 gram but>5 grams');
+assert($dom->find('td', 0)->plaintext==='test :1 gram but>5 grams');
+assert($dom==$str);
+
+$str = <<<HTML
+<td><b>test :</b>1 gram but> 5 grams</td>
+HTML;
+$dom->load($str);
+assert($dom->find('td', 0)->innertext==='<b>test :</b>1 gram but> 5 grams');
+assert($dom->find('td', 0)->plaintext==='test :1 gram but> 5 grams');
+assert($dom==$str);
+
+$str = <<<HTML
+<td><b>test :</b>1 gram but > 5 grams</td>
+HTML;
+$dom->load($str);
+assert($dom->find('td', 0)->innertext==='<b>test :</b>1 gram but > 5 grams');
+assert($dom->find('td', 0)->plaintext==='test :1 gram but > 5 grams');
+assert($dom==$str);
+
+$str = <<<HTML
+<td><b>test :</b>1 gram but 5> grams</td>
+HTML;
+$dom->load($str);
+assert($dom->find('td', 0)->innertext==='<b>test :</b>1 gram but 5> grams');
+assert($dom->find('td', 0)->plaintext==='test :1 gram but 5> grams');
+assert($dom==$str);
+
+$str = <<<HTML
+<td><b>test :</b>1 gram but 5 > grams</td>
+HTML;
+$dom->load($str);
+assert($dom->find('td', 0)->innertext==='<b>test :</b>1 gram but 5 > grams');
+assert($dom->find('td', 0)->plaintext==='test :1 gram but 5 > grams');
+assert($dom==$str);
+
+$str = <<<HTML
+<td><b>test :</b>1 gram but 5 >grams</td>
+HTML;
+$dom->load($str);
+assert($dom->find('td', 0)->innertext==='<b>test :</b>1 gram but 5 >grams');
+assert($dom->find('td', 0)->plaintext==='test :1 gram but 5 >grams');
+assert($dom==$str);
+// -----------------------------------------------
+$str = <<<HTML
+<td><b>test :</b>1 gram but 5> grams</td>
+HTML;
+$dom->load($str);
+assert($dom->find('td', 0)->innertext==='<b>test :</b>1 gram but 5> grams');
+assert($dom->find('td', 0)->plaintext==='test :1 gram but 5> grams');
+assert($dom==$str);
+
+$str = <<<HTML
+<td><b>test :</b>1 gram but5> grams</td>
+HTML;
+$dom->load($str);
+assert($dom->find('td', 0)->innertext==='<b>test :</b>1 gram but5> grams');
+assert($dom->find('td', 0)->plaintext==='test :1 gram but5> grams');
+assert($dom==$str);
+
+$str = <<<HTML
+<td><b>test :</b>1 gram but 5 >grams</td>
+HTML;
+$dom->load($str);
+assert($dom->find('td', 0)->innertext==='<b>test :</b>1 gram but 5 >grams');
+assert($dom->find('td', 0)->plaintext==='test :1 gram but 5 >grams');
+assert($dom==$str);
+
+$str = <<<HTML
+<td><b>test :</b>1 gram but 5>grams</td>
+HTML;
+$dom->load($str);
+assert($dom->find('td', 0)->innertext==='<b>test :</b>1 gram but 5>grams');
+assert($dom->find('td', 0)->plaintext==='test :1 gram but 5>grams');
+assert($dom==$str);
+
+$str = <<<HTML
+<td><b>test :</b>1 gram but 5 >grams</td>
+HTML;
+$dom->load($str);
+assert($dom->find('td', 0)->innertext==='<b>test :</b>1 gram but 5 >grams');
+assert($dom->find('td', 0)->plaintext==='test :1 gram but 5 >grams');
+assert($dom==$str);
+
+// -----------------------------------------------------------------------------
+// BAD HTML test
+$str = <<<HTML
+<strong class="see <a href="http://www.oeb.harvard.edu/faculty/girguis/">http://www.oeb.harvard.edu/faculty/girguis/</a>">.</strong></p> 
+HTML;
+$dom->load($str);
+// -----------------------------------------------
+$str = <<<HTML
+<a href="http://www.oeb.harvard.edu/faculty/girguis\">http://www.oeb.harvard.edu/faculty/girguis/</a>">
+HTML;
+$dom->load($str);
+// -----------------------------------------------
+$str = <<<HTML
+<strong class="''""";;''""";;\"\''''\"""''''""''>""'''"'" '
+HTML;
+$dom->load($str);
+// -----------------------------------------------------------------------------
+// tear down
+$dom->clear();
+unset($dom);
+?>

Разница между файлами не показана из-за своего большого размера
+ 10 - 0
vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/testcase/jquery-1.2.3.pack.js


+ 68 - 0
vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/testcase/mass_test.php

@@ -0,0 +1,68 @@
+<?php
+// $Rev: 174 $
+error_reporting(E_ALL);
+include_once('../simple_html_dom.php');
+
+$dir = './html/';
+
+$files = array(
+    array('name'=>'empty.htm',          'url'=>''),
+    array('name'=>'smarty_1.htm',       'url'=>'guestbook.tpl'),
+    array('name'=>'smarty_2.htm',       'url'=>'guestbook_form.tpl'),
+    
+    array('name'=>'google.htm',         'url'=>'http://www.google.com/'),
+    array('name'=>'senate.htm',         'url'=>'http://www.senate.gov/legislative/LIS/roll_call_lists/roll_call_vote_cfm.cfm?congress=101&session=2&vote=00317'),
+    array('name'=>'cyberciti.htm',      'url'=>'http://www.cyberciti.biz/tips/configure-ubuntu-grub-to-load-freebsd.html'),
+    array('name'=>'myspace.htm',        'url'=>'http://www.myspace.com/'),
+    array('name'=>'mootools.htm',       'url'=>'http://www.mootools.net/'),
+    array('name'=>'jquery.htm',         'url'=>'http://jquery.com/'),
+    array('name'=>'scriptaculo.htm',    'url'=>'http://script.aculo.us/'),
+    array('name'=>'apache.htm',         'url'=>'http://www.apache.org/'),
+    array('name'=>'microsoft.htm',      'url'=>'http://www.microsoft.com/'),
+    array('name'=>'slashdot.htm',       'url'=>'http://www.slashdot.org/'),
+    array('name'=>'ror.htm',            'url'=>'http://www.rubyonrails.org/'),
+    array('name'=>'yahoo.htm',          'url'=>'http://www.yahoo.com/'),
+    array('name'=>'phpbb.htm',          'url'=>'http://www.phpbb.com/'),
+    array('name'=>'python.htm',         'url'=>'http://www.python.org/'),
+    array('name'=>'lua.htm',            'url'=>'http://www.lua.org/'),
+    array('name'=>'php.htm',            'url'=>'http://www.php.net/'),
+    array('name'=>'ibm.htm',            'url'=>'http://www.ibm.com/'),
+    array('name'=>'java.htm',           'url'=>'http://java.sun.com/'),
+    array('name'=>'flickr.htm',         'url'=>'http://www.flickr.com/tour/upload/'),
+    array('name'=>'amazon.htm',         'url'=>'http://www.amazon.com/'),
+    array('name'=>'youtube.htm',        'url'=>'http://www.youtube.com/watch?v=kib05Ip6GSo&feature=bz302'),
+);
+
+
+echo 'memory: '.memory_get_usage().'<br>';
+$dom = new simple_html_dom;
+
+foreach($files as $f) {
+    // get file from url
+    if($f['url']!='') file_put_contents($dir.$f['name'], file_get_contents($f['url']));
+    else file_put_contents($dir.$f['name'], '');
+
+    $start = microtime();
+    $dom->load(file_get_contents($dir.$f['name']), false);
+    list($eu, $es) = explode(' ', microtime());
+    list($bu, $bs) = explode(' ', $start);
+    echo sprintf('(%.1f)', ((float)$eu+(float)$es-(float)$bu-(float)$bs)*1000).'<br>';
+    
+    if (file_get_contents($dir.$f['name'])!=$dom->save()) {
+        echo "[<font color='red'>failed</font>] ".$f['name']."<br>";
+        $dom->save($dir.$f['name'].'.error');
+    }
+    else
+        echo "[success] ".$f['name']."<br>";
+
+    echo 'memory: '.memory_get_usage().'<br>';
+
+    flush();
+    set_time_limit(0);
+}
+
+$dom->clear();
+unset($dom);
+echo '<br>memory: '.memory_get_usage().'<br>';
+
+?>

+ 121 - 0
vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/testcase/memory_test.php

@@ -0,0 +1,121 @@
+<?php
+// $Rev: 179 $
+error_reporting(E_ALL);
+include_once('../simple_html_dom.php');
+
+// -----------------------------------------------------------------------------
+function dump_memory($init_size) {
+    $peak = number_format(memory_get_peak_usage()/1024, 0, '.', ',');
+    $curr = number_format(memory_get_usage()/1024, 0, '.', ',');
+    $diff = $curr - $init_size;
+    echo 'peak: ' .  $peak . ' kb, end: ' . $curr . ' kb, add: ' . $diff . " kb<br>";
+}
+
+// -----------------------------------------------------------------------------
+$filename = './html/google.htm';
+//$filename = 'test.htm';
+
+// -----------------------------------------------------------------------------
+// test_load_file_memory
+function test_load_file_memory($filename, $init_size) {
+    echo '[load file] init memory: '.number_format(memory_get_usage()/1024, 0, '.', ',').'<br>';
+    echo '--------------------------------------------------------------------<br>';
+    flush();
+    for($i=0; $i<3; ++$i) {
+        $str = file_get_contents($filename);
+        
+        dump_memory($init_size);
+        unset($str);
+    }
+    echo 'after loop: '.number_format(memory_get_usage(), 0, '.', ',').'<br>';
+    echo '--------------------------------------------------------------------<br>';
+    flush();
+}
+
+// -----------------------------------------------------------------------------
+// test_multi_objects_str_get_html
+function test_multi_str_get_html($filename, $init_size) {
+    global $__g_node_mgr;
+    
+    $str = file_get_contents($filename);
+    echo '[str_get_html] init memory: '.number_format(memory_get_usage()/1024, 0, '.', ',').'<br>';
+    echo '--------------------------------------------------------------------<br>';
+    flush();
+    for($i=0; $i<3; ++$i) {
+        $html = str_get_html($str);
+        dump_memory($init_size);
+        flush();
+    }
+    echo 'after loop: '.number_format(memory_get_usage(), 0, '.', ',').'<br>';
+    echo '--------------------------------------------------------------------<br>';
+    flush();
+    unset($str);
+}
+
+// -----------------------------------------------------------------------------
+// test_multi_file_get_html
+function test_multi_file_get_html($filename, $init_size) {
+    echo '[file_get_html] init memory: '.number_format(memory_get_usage()/1024, 0, '.', ',').'<br>';
+    echo '--------------------------------------------------------------------<br>';
+    flush();
+    for($i=0; $i<3; ++$i) {
+        $html = file_get_html($filename);
+        //$html->clear();
+        unset($html);
+        dump_memory($init_size);
+        flush();
+    }
+    echo 'after loop: '.number_format(memory_get_usage(), 0, '.', ',').'<br>';
+    echo '--------------------------------------------------------------------<br>';
+    flush();
+}
+/*
+// -----------------------------------------------------------------------------
+// test_multi_objects_clear_memory
+function test_multi_objects_file_get_html_clear_memory($filename) {
+echo '<br><br>[one object]<br>init memory: '.number_format(memory_get_usage(), 0, '.', ',').'<br>';
+echo '------------------------------------------<br>';
+flush();
+$html = new simple_html_dom;
+for($i=0; $i<3; ++$i) {
+    $html->load_file($filename);
+    $html->clear();
+    dump_memory();
+}
+unset($dom);
+echo 'final: '.number_format(memory_get_usage(), 0, '.', ',').'<br>';
+flush();
+
+
+echo '<br><br>[multi objects without clear memory]<br>init memory: '.number_format(memory_get_usage(), 0, '.', ',').'<br>';
+echo '------------------------------------------<br>';
+flush();
+for($i=0; $i<3; ++$i) {
+    $html = file_get_html($filename);
+    dump_memory();
+}
+echo 'final: '.number_format(memory_get_usage(), 0, '.', ',').'<br>';
+flush();
+*/
+
+// -----------------------------------------------------------------------------
+// begin test
+$init_size = number_format(memory_get_usage(), 0, '.', ',');
+echo 'init ' . $init_size . " bytes<br>";
+flush();
+
+echo '<br>before function: '.number_format(memory_get_usage()/1024, 0, '.', ',').'<br>';
+test_load_file_memory($filename, $init_size);
+echo 'after function: '.number_format(memory_get_usage()/1024, 0, '.', ',').'<br><br>';
+flush();
+
+echo '<br>before function: '.number_format(memory_get_usage()/1024, 0, '.', ',').'<br>';
+test_multi_file_get_html($filename, $init_size);
+echo 'after function: '.number_format(memory_get_usage()/1024, 0, '.', ',').'<br><br>';
+flush();
+
+echo '<br>before function: '.number_format(memory_get_usage()/1024, 0, '.', ',').'<br>';
+test_multi_file_get_html($filename, $init_size);
+echo 'after function: '.number_format(memory_get_usage()/1024, 0, '.', ',').'<br><br>';
+flush();
+?>

+ 60 - 0
vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/testcase/misc_testcase.php

@@ -0,0 +1,60 @@
+<?php
+// $Rev: 133 $
+// -----------------------------------------------------------------------------
+// setup
+error_reporting(E_ALL);
+require_once('../simple_html_dom.php');
+$dom = new simple_html_dom;
+
+
+// -----------------------------------------------------------------------------
+// test problem of last emelemt not found
+$str = <<<HTML
+<img class="class0" id="id0" src="src0">
+<img class="class1" id="id1" src="src1">
+<img class="class2" id="id2" src="src2">
+HTML;
+
+$dom->load($str);
+$es = $dom->find('img');
+assert(count($es)==3);
+assert($es[0]->src=='src0');
+assert($es[1]->src=='src1');
+assert($es[2]->src=='src2');
+assert($es[0]->innertext=='');
+assert($es[1]->innertext=='');
+assert($es[2]->innertext=='');
+assert($es[0]->outertext=='<img class="class0" id="id0" src="src0">');
+assert($es[1]->outertext=='<img class="class1" id="id1" src="src1">');
+assert($es[2]->outertext=='<img class="class2" id="id2" src="src2">');
+assert($dom->find('img', 0)->src=='src0');
+assert($dom->find('img', 1)->src=='src1');
+assert($dom->find('img', 2)->src=='src2');
+assert($dom->find('img', 3)===null);
+assert($dom->find('img', 99)===null);
+assert($dom->save()==$str);
+
+// -----------------------------------------------------------------------------
+// test error tag
+$str = <<<HTML
+<img class="class0" id="id0" src="src0"><p>p1</p>
+<img class="class1" id="id1" src="src1"><p>
+<img class="class2" id="id2" src="src2"></a></div>
+HTML;
+
+$dom = str_get_html($str);
+$es = $dom->find('img');
+assert(count($es)==3);
+assert($es[0]->src=='src0');
+assert($es[1]->src=='src1');
+assert($es[2]->src=='src2');
+
+$es = $dom->find('p');
+assert($es[0]->innertext=='p1');
+assert($dom==$str);
+
+// -----------------------------------------------------------------------------
+// tear down
+$dom->clear();
+unset($dom);
+?>

+ 40 - 0
vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/testcase/performance_test.php

@@ -0,0 +1,40 @@
+<?php
+// $Rev: 133 $
+error_reporting(E_ALL);
+
+include_once('../simple_html_dom.php');
+
+$all = 0;
+$min = 10000;
+$max = 0;
+$count = 20;
+
+$str = file_get_contents('./html/google.htm');
+$html = new simple_html_dom;
+
+for ($i=0; $i<$count; ++$i) {
+    $start = microtime();
+
+    $html->load($str, false);
+
+    list($eu, $es) = explode(' ', microtime());
+    list($bu, $bs) = explode(' ', $start);
+
+    $diff = ((float)$eu+(float)$es-(float)$bu-(float)$bs)*1000;
+
+    if ($diff>$max)
+        $max = $diff;
+
+    if ($diff<$min)
+        $min = $diff;
+
+    $all += $diff;
+    echo sprintf('(%.1f)', $diff).'<br>';
+}
+
+echo '<br>-------------------------<br>';
+echo 'min: ' . $min . '<br>';
+echo 'max: ' . $max . '<br>';
+
+echo '<br>avg: ' . $all/$count . '<br>';
+?>

+ 12 - 0
vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/testcase/reader/all_test.php

@@ -0,0 +1,12 @@
+<?php
+// $Rev: 129 $
+error_reporting(E_ALL);
+
+foreach (new DirectoryIterator(getcwd()) as $entry) {
+    if ($entry->isFile() && strpos($entry, '_testcase.')>0) {
+        echo basename($entry);
+        require_once($entry);
+        echo '<br>...pass!<br><br>';
+    }
+}
+?>

+ 243 - 0
vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/testcase/reader/element_testcase.php

@@ -0,0 +1,243 @@
+<?php
+// $Rev: 130 $
+// -----------------------------------------------------------------------------
+// setup
+error_reporting(E_ALL);
+require_once('../../simple_html_dom_reader.php');
+$dom = new simple_html_dom;
+
+// -----------------------------------------------------------------------------
+// attribute test
+$str = <<<HTML
+<div onclick="bar('aa')">foo</div>
+HTML;
+$dom->load($str);
+assert($dom->find('div', 0)==$str);
+// -----------------------------------------------
+$str = <<<HTML
+<div onclick='bar("aa")'>foo</div>
+HTML;
+$dom->load($str);
+assert($dom->find('div', 0)==$str);
+
+// -----------------------------------------------------------------------------
+// innertext test
+$str = <<<HTML
+<html><head></head><body><br><span>foo</span></body></html>
+HTML;
+$dom->load($str);
+assert($dom==$str);
+// -----------------------------------------------
+$str = <<<HTML
+<html><head></head><body><br><span>bar</span></body></html>
+HTML;
+$dom->find('span', 0)->innertext = 'bar';
+assert($dom==$str);
+// -----------------------------------------------
+$str = <<<HTML
+<html><head>ok</head><body><br><span>bar</span></body></html>
+HTML;
+$dom->find('head', 0)->innertext = 'ok';
+assert($dom==$str);
+
+// -----------------------------------------------------------------------------
+// outertext test
+$str = <<<HTML
+<table>
+<tr><th>Head1</th><th>Head2</th><th>Head3</th></tr>
+<tr><td>1</td><td>2</td><td>3</td></tr>
+</table>
+HTML;
+$dom->load($str);
+assert($dom->find('tr', 0)->outertext=='<tr><th>Head1</th><th>Head2</th><th>Head3</th></tr>');
+assert($dom->find('tr', 1)->outertext=='<tr><td>1</td><td>2</td><td>3</td></tr>');
+// -----------------------------------------------
+$str = <<<HTML
+<table><tr><th>Head1</th><th>Head2</th><th>Head3</th><tr><td>1</td><td>2</td><td>3</td></table>
+HTML;
+$dom->load($str);
+assert($dom->find('tr', 0)->outertext=='<tr><th>Head1</th><th>Head2</th><th>Head3</th></tr>');
+assert($dom->find('tr', 1)->outertext=='<tr><td>1</td><td>2</td><td>3</td></tr>');
+
+// -----------------------------------------------
+$str = <<<HTML
+<ul><li><b>li11</b></li><li><b>li12</b></li></ul><ul><li><b>li21</b></li><li><b>li22</b></li></ul>
+HTML;
+$dom->load($str);
+assert($dom->find('ul', 0)->outertext=='<ul><li><b>li11</b></li><li><b>li12</b></li></ul>');
+assert($dom->find('ul', 1)->outertext=='<ul><li><b>li21</b></li><li><b>li22</b></li></ul>');
+
+// -----------------------------------------------
+$str = <<<HTML
+<ul><li><b>li11</b></li><li><b>li12</b></li><ul><li><b>li21</b></li><li><b>li22</b></li>
+HTML;
+//$dom->load($str);             
+//assert($dom->find('ul', 0)->outertext=='<ul><li><b>li11</b></li><li><b>li12</b></li></ul>');
+//assert($dom->find('ul', 1)->outertext=='<ul><li><b>li21</b></li><li><b>li22</b></li></ul>');
+
+// -----------------------------------------------
+$str = <<<HTML
+<ul><li><b>li11</b><li><b>li12</b></li><ul><li><b>li21</b></li><li><b>li22</b>
+HTML;
+//$dom->load($str);
+//assert($dom->find('ul', 0)->outertext=='<ul><li><b>li11</b><li><b>li12</b></li>');
+//assert($dom->find('ul', 1)->outertext=='<ul><li><b>li21</b></li><li><b>li22</b>');
+
+// -----------------------------------------------
+$str = <<<HTML
+<table>
+<tr><th>Head1</th><th>Head2</th><th>Head3</th></tr>
+<tr><td>1</td><td>2</td><td>3</td></tr>
+</table>
+HTML;
+$dom->load($str);
+assert($dom->find('tr', 0)->outertext=='<tr><th>Head1</th><th>Head2</th><th>Head3</th></tr>');
+assert($dom->find('tr', 1)->outertext=='<tr><td>1</td><td>2</td><td>3</td></tr>');
+
+// -----------------------------------------------------------------------------
+// replacement test
+$str = <<<HTML
+<div class="class1" id="id2" ><div class="class2">ok</div></div>
+HTML;
+$dom->load($str);
+$es = $dom->find('div');
+assert(count($es)==2);
+assert($es[0]->innertext=='<div class="class2">ok</div>');
+assert($es[0]->outertext=='<div class="class1" id="id2"><div class="class2">ok</div></div>');
+
+// test isset
+$es[0]->class = 'class_test';
+assert(isset($es[0]->class)===true);
+assert(isset($es[0]->okok)===false);
+
+// test replacement
+$es[0]->class = 'class_test';
+assert($es[0]->outertext=='<div class="class_test" id="id2"><div class="class2">ok</div></div>');
+
+// test replacement
+//$es[0]->tag = 'span';
+//assert($es[0]->outertext=='<span class="class_test" id="id2"><div class="class2">ok</div></span>');
+
+// test unset (no more support...)
+//$dom = str_get_dom($str);
+//$es = $dom->find('div');
+//unset($es[0]->class);
+//assert($es[0]->outertext=='<div id="id2" ><div class="class2">ok</div></div>');
+
+//$dom->load($str);
+//$es = $dom->find('div');
+//unset($es[0]->attr['class']);
+//assert($es[0]->outertext=='<div id="id2"><div class="class2">ok</div></div>');
+
+// -----------------------------------------------
+$str = <<<HTML
+<select name=something><options>blah</options><options>blah2</options></select>
+HTML;
+$dom->load($str);
+$e = $dom->find('select[name=something]', 0);
+$e->innertext = '';
+assert($e->outertext =='<select name="something"></select>');
+
+// -----------------------------------------------------------------------------
+// nested replacement test
+$str = <<<HTML
+<div class="class0" id="id0"><div class="class1">ok</div></div>
+HTML;
+$dom->load($str);
+$es = $dom->find('div');
+assert(count($es)==2);
+assert($es[0]->innertext=='<div class="class1">ok</div>');
+assert($es[0]->outertext=='<div class="class0" id="id0"><div class="class1">ok</div></div>');
+assert($es[1]->innertext=='ok');
+assert($es[1]->outertext=='<div class="class1">ok</div>');
+
+// test replacement
+$es[1]->innertext = 'okok';
+assert($es[1]->outertext=='<div class="class1">okok</div>');
+assert($es[0]->outertext=='<div class="class0" id="id0"><div class="class1">okok</div></div>');
+//assert($dom=='<div class="class0" id="id0"><div class="class1">okok</div></div>');
+
+$es[1]->class = 'class_test';
+assert($es[1]->outertext=='<div class="class_test">okok</div>');
+assert($es[0]->outertext=='<div class="class0" id="id0"><div class="class_test">okok</div></div>');
+//assert($dom=='<div class="class0" id="id0"><div class="class_test">okok</div></div>');
+
+$es[0]->class = 'class_test';
+assert($es[0]->outertext=='<div class="class_test" id="id0"><div class="class_test">okok</div></div>');
+//assert($dom=='<div class="class_test" id="id0"><div class="class_test">okok</div></div>');
+
+$es[0]->innertext = 'okokok';
+assert($es[0]->outertext=='<div class="class_test" id="id0">okokok</div>');
+//assert($dom=='<div class="class_test" id="id0">okokok</div>');
+
+// -----------------------------------------------------------------------------
+// <p> test
+$str = <<<HTML
+<div class="class0"><p>ok0<a href="#">link0</a></p><div class="class1"><p>ok1<a href="#">link1</a></p></div><div class="class2"></div><p>ok2<a href="#">link2</a></p></div>
+HTML;
+$dom->load($str);
+$es  = $dom->find('p');
+assert($es[0]->innertext=='ok0<a href="#">link0</a>');
+assert($es[1]->innertext=='ok1<a href="#">link1</a>');
+assert($es[2]->innertext=='ok2<a href="#">link2</a>');
+assert($dom->find('p', 0)->plaintext=='ok0link0');
+assert($dom->find('p', 1)->plaintext=='ok1link1');
+assert($dom->find('p', 2)->plaintext=='ok2link2');
+
+$count = 0;
+foreach($dom->find('p') as $p) {
+    $a = $p->find('a');
+    assert($a[0]->innertext=='link'.$count);
+    ++$count;
+}
+
+$es = $dom->find('p a');
+assert($es[0]->innertext=='link0');
+assert($es[1]->innertext=='link1');
+assert($es[2]->innertext=='link2');
+assert($dom->find('p a', 0)->plaintext=='link0');
+assert($dom->find('p a', 1)->plaintext=='link1');
+assert($dom->find('p a', 2)->plaintext=='link2');
+
+// -----------------------------------------------------------------------------
+// <embed> test
+$str = <<<HTML
+<EMBED SRC="../graphics/sounds/1812over.mid" HEIGHT="60" WIDTH="144"></EMBED>
+HTML;
+$dom->load($str);
+$e = $dom->find('embed', 0);
+assert($e->src=='../graphics/sounds/1812over.mid');
+assert($e->height=='60');
+assert($e->width=='144');
+assert($e==strtolower($str));
+
+// -----------------------------------------------------------------------------
+// <pre> test
+$str = <<<HTML
+<div class="class0" id="id0" >
+    <pre>
+        <input type=submit name="btnG" value="go" onclick='goto("url0")'>
+    </pre>
+</div>
+HTML;
+$dom->load($str);
+//assert(count($dom->find('input'))==0);
+
+// -----------------------------------------------------------------------------
+// <code> test
+$str = <<<HTML
+<div class="class0" id="id0" >
+    <CODE>
+        <input type=submit name="btnG" value="go" onclick='goto("url0")'>
+    </CODE>
+</div>
+HTML;
+$dom->load($str);
+assert(count($dom->find('code'))==1);
+//assert(count($dom->find('input'))==0);
+
+// -----------------------------------------------------------------------------
+// tear down
+$dom->clear();
+unset($dom);
+?>

+ 103 - 0
vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/testcase/reader/memory_test.php

@@ -0,0 +1,103 @@
+<?php
+// $Rev: 130 $
+// -----------------------------------------------------------------------------
+error_reporting(E_ALL);
+
+include_once('../../simple_html_dom_reader.php');
+
+$filename = '../html/google.htm';
+
+function dump_memory() {
+    echo 'peak: ' . number_format(memory_get_peak_usage(), 0, '.', ',') . ' bytes, end: ' . number_format(memory_get_usage(), 0, '.', ',') . " bytes<br>";
+}
+
+function stat_dom($dom) {
+    $count_text = 0;
+    $count_comm = 0;
+    $count_elem = 0;
+    $count_tag_end = 0;
+    
+    foreach($dom->nodes as $n) {
+        if ($n->nodetype==HDOM_TYPE_TEXT)
+            ++$count_text;
+        if ($n->nodetype==HDOM_TYPE_COMMENT)
+            ++$count_comm;
+        if ($n->nodetype==HDOM_TYPE_ELEMENT)
+            ++$count_elem;
+        if ($n->nodetype==HDOM_TYPE_ENDTAG)
+            ++$count_tag_end;
+    }
+    
+    echo 'Total: '. count($dom->nodes).', Text: '.$count_text.', Commnet: '.$count_comm.', Tag: '.$count_elem.', End Tag: '.$count_tag_end.'<br>';
+}
+
+echo 'init ' . number_format(memory_get_usage(), 0, '.', ',') . " bytes";
+
+
+echo '<br><br>[load file]<br>init memory: '.number_format(memory_get_usage(), 0, '.', ',').'<br>';
+echo '------------------------------------------<br>';
+flush();
+for($i=0; $i<3; ++$i) {
+    $str = file_get_contents($filename);
+    unset($str);
+    dump_memory();
+}
+echo 'final: '.number_format(memory_get_usage(), 0, '.', ',').'<br>';
+flush();
+
+
+$str = file_get_contents($filename);
+echo '<br><br>[multi objects str_get_dom clear memory]<br>init memory: '.number_format(memory_get_usage(), 0, '.', ',').'<br>';
+echo '------------------------------------------<br>';
+flush();
+for($i=0; $i<3; ++$i) {
+    $dom = str_get_dom($str);
+    //stat_dom($dom);
+    $dom->clear();
+    unset($dom);
+    dump_memory();
+    flush();
+}
+echo 'final: '.number_format(memory_get_usage(), 0, '.', ',').'<br>';
+flush();
+
+echo '<br><br>[multi objects file_get_dom clear memory]<br>init memory: '.number_format(memory_get_usage(), 0, '.', ',').'<br>';
+echo '------------------------------------------<br>';
+flush();
+for($i=0; $i<3; ++$i) {
+    $dom = file_get_dom($filename);
+    //stat_dom($dom);
+    $dom->clear();
+    unset($dom);
+    dump_memory();
+    flush();
+}
+echo 'final: '.number_format(memory_get_usage(), 0, '.', ',').'<br>';
+flush();
+
+
+echo '<br><br>[one object]<br>init memory: '.number_format(memory_get_usage(), 0, '.', ',').'<br>';
+echo '------------------------------------------<br>';
+flush();
+$dom = new simple_html_dom;
+for($i=0; $i<3; ++$i) {
+    $dom->load_file($filename);
+    $dom->clear();
+    dump_memory();
+}
+unset($dom);
+echo 'final: '.number_format(memory_get_usage(), 0, '.', ',').'<br>';
+flush();
+
+
+
+echo '<br><br>[multi objects without clear memory]<br>init memory: '.number_format(memory_get_usage(), 0, '.', ',').'<br>';
+echo '------------------------------------------<br>';
+flush();
+for($i=0; $i<3; ++$i) {
+    $dom = file_get_dom($filename);
+    dump_memory();
+}
+echo 'final: '.number_format(memory_get_usage(), 0, '.', ',').'<br>';
+flush();
+?>

+ 38 - 0
vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/testcase/reader/performance_test.php

@@ -0,0 +1,38 @@
+<?php
+// $Rev: 130 $
+// -----------------------------------------------------------------------------
+error_reporting(E_ALL);
+
+include_once('../../simple_html_dom_reader.php');
+
+$all = 0;
+$min = 10000;
+$max = 0;
+$count = 20;
+
+$str = file_get_contents('../html/google.htm');
+$dom = new simple_html_dom;
+
+for ($i=0; $i<$count; ++$i) {
+    $start = microtime();
+    $dom->load($str, false);
+    list($eu, $es) = explode(' ', microtime());
+    list($bu, $bs) = explode(' ', $start);
+
+    if (((float)$eu+(float)$es-(float)$bu-(float)$bs)*1000 > $max)
+        $max = ((float)$eu+(float)$es-(float)$bu-(float)$bs)*1000;
+
+    if (((float)$eu+(float)$es-(float)$bu-(float)$bs)*1000 < $min)
+        $min = ((float)$eu+(float)$es-(float)$bu-(float)$bs)*1000;
+    
+    $all += ((float)$eu+(float)$es-(float)$bu-(float)$bs)*1000;
+    echo sprintf('(%.1f)', ((float)$eu+(float)$es-(float)$bu-(float)$bs)*1000).'<br>';
+    $dom->clear();
+}
+
+echo '<br>-------------------------<br>';
+echo 'min: ' . $min . '<br>';
+echo 'max: ' . $max . '<br>';
+
+echo '<br>avg: ' . $all/$count . '<br>';
+?>

+ 584 - 0
vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/testcase/reader/selector_testcase.php

@@ -0,0 +1,584 @@
+<?php
+// $Rev: 130 $
+// -----------------------------------------------------------------------------
+// setup
+error_reporting(E_ALL);
+require_once('../../simple_html_dom_reader.php');
+$dom = new simple_html_dom;
+
+// -----------------------------------------------------------------------------
+// "\t" or "\n" in tag test
+// std selector test 1
+$str = <<<HTML
+<img 
+class="class0" id="id0" src="src0">
+<img
+ class="class1" id="id1" src="src1">
+<img class="class2" id="id2" src="src2">
+HTML;
+$dom->load($str);
+$e = $dom->find('img');
+assert(count($e)==3);
+
+// -----------------------------------------------------------------------------
+// std selector test
+$str = <<<HTML
+<img class="class0" id="id0" src="src0">
+<img class="class1" id="id1" src="src1">
+<img class="class2" id="id2" src="src2">
+HTML;
+$dom->load($str);
+
+// -----------------------------------------------
+// all
+//$e = $dom->find('*');
+//assert(count($e)==3);
+
+// -----------------------------------------------
+// tag
+assert(count($dom->find('img'))==3);
+
+// -----------------------------------------------
+// class
+$es = $dom->find('img.class0');
+assert(count($es)==1);
+assert($es[0]->src=='src0');
+assert($es[0]->innertext=='');
+assert($es[0]->outertext=='<img class="class0" id="id0" src="src0">');
+
+$es = $dom->find('.class0');
+assert(count($es)==1);
+assert($es[0]->src=='src0');
+assert($es[0]->innertext=='');
+assert($es[0]->outertext=='<img class="class0" id="id0" src="src0">');
+
+// -----------------------------------------------
+// id
+$es = $dom->find('img#id1');
+assert(count($es)==1);
+assert($es[0]->src=='src1');
+assert($es[0]->innertext=='');
+assert($es[0]->outertext=='<img class="class1" id="id1" src="src1">');
+
+$es = $dom->find('#id2');
+assert(count($es)==1);
+assert($es[0]->src=='src2');
+assert($es[0]->innertext=='');
+assert($es[0]->outertext=='<img class="class2" id="id2" src="src2">');
+
+// -----------------------------------------------
+// attr
+$es = $dom->find('img[src="src0"]');
+assert(count($es)==1);
+assert($es[0]->src=='src0');
+assert($es[0]->innertext=='');
+assert($es[0]->outertext=='<img class="class0" id="id0" src="src0">');
+
+$es = $dom->find('img[src=src0]');
+assert(count($es)==1);
+assert($es[0]->src=='src0');
+assert($es[0]->innertext=='');
+assert($es[0]->outertext=='<img class="class0" id="id0" src="src0">');
+
+$es = $dom->find('[src=src0]');
+assert(count($es)==1);
+assert($es[0]->src=='src0');
+assert($es[0]->innertext=='');
+assert($es[0]->outertext=='<img class="class0" id="id0" src="src0">');
+
+$es = $dom->find('[src="src0"]');
+assert(count($es)==1);
+assert($es[0]->src=='src0');
+assert($es[0]->innertext=='');
+assert($es[0]->outertext=='<img class="class0" id="id0" src="src0">');
+
+// -----------------------------------------------
+// text
+$str = <<<HTML
+<b>text1</b><b>text2</b>
+HTML;
+$dom->load($str);
+$es = $dom->find('text');
+assert(count($es)==2);
+assert($es[0]->innertext=='text1');
+assert($es[0]->outertext=='text1');
+assert($es[0]->plaintext=='text1');
+assert($es[1]->innertext=='text2');
+assert($es[1]->outertext=='text2');
+assert($es[1]->plaintext=='text2');
+
+$str = <<<HTML
+<b>text1</b><b>text2</b>
+HTML;
+$dom->load($str);
+$es = $dom->find('b text');
+assert(count($es)==2);
+assert($es[0]->innertext=='text1');
+assert($es[0]->outertext=='text1');
+assert($es[0]->plaintext=='text1');
+assert($es[1]->innertext=='text2');
+assert($es[1]->outertext=='text2');
+assert($es[1]->plaintext=='text2');
+
+
+// -----------------------------------------------
+// xml namespace test
+$str = <<<HTML
+<bw:bizy id="date">text</bw:bizy>
+HTML;
+$dom->load($str);
+$es = $dom->find('bw:bizy');
+assert(count($es)==0);
+
+// -----------------------------------------------
+// user defined tag name test
+$str = <<<HTML
+<div_test id="1">text</div_test>
+HTML;
+$dom->load($str);
+$es = $dom->find('div_test');
+assert(count($es)==1);
+assert($es[0]->id=='1');
+// -----------------------------------------------
+$str = <<<HTML
+<div-test id="1">text</div-test>
+HTML;
+$dom->load($str);
+$es = $dom->find('div-test');
+assert(count($es)==1);
+assert($es[0]->id=='1');
+// -----------------------------------------------
+$str = <<<HTML
+<div::test id="1">text</div::test>
+HTML;
+$dom->load($str);
+$es = $dom->find('div::test');
+assert(count($es)==0);
+
+// -----------------------------------------------
+// find all occurrences of id="1" regardless of the tag
+$str = <<<HTML
+<img class="class0" id="1" src="src0">
+<img class="class1" id="2" src="src1">
+<div class="class2" id="1">ok</div>
+HTML;
+$dom->load($str);
+$es = $dom->find('[id=1]');
+assert(count($es)==2);
+assert($es[0]->tag=='img');
+assert($es[1]->tag=='div');
+
+// -----------------------------------------------------------------------------
+// multiple selector test
+$str = <<<HTML
+<div class="class0" id="id0" >
+    <div class="class1" id="id1">
+        <div class="class2" id="id2">ok</div>
+    </div>
+</div>
+HTML;
+$dom->load($str);
+
+$es = $dom->find('div');
+assert(count($es)==3);
+assert($es[0]->id=='id0');
+assert($es[1]->id=='id1');
+assert($es[2]->id=='id2');
+
+$es = $dom->find('div div');
+assert(count($es)==2);
+assert($es[0]->id=='id1');
+assert($es[1]->id=='id2');
+
+$es = $dom->find('div div div');
+assert(count($es)==1);
+assert($es[0]->id=='id2');
+
+// -----------------------------------------------------------------------------
+// multiple selector test 2
+$str = <<<HTML
+<table>
+    <tr>
+        <td>0</td>
+        <td>1</td>
+    </tr>
+</table>
+<table>
+    <tr>
+        <td>2</td>
+        <td>3</td>
+    </tr>
+</table>
+HTML;
+$dom->load($str);
+$es = $dom->find('table td');
+assert(count($es)==4);
+assert($es[0]->innertext=='0');
+assert($es[1]->innertext=='1');
+assert($es[2]->innertext=='2');
+assert($es[3]->innertext=='3');
+
+// -----------------------------------------------------------------------------
+// multiple selector test 3
+$str = <<<HTML
+<table>
+    <tr>
+        <td>
+            <table class="hello">
+                <tr>
+                    <td>0</td>
+                    <td>1</td>
+                </tr>
+            </table>
+        </td>
+    </tr>
+</table>
+<table class="hello">
+    <tr>
+        <td>2</td>
+        <td>3</td>
+    </tr>
+</table>
+HTML;
+$dom = str_get_dom($str);
+$es = $dom->find('table.hello td');
+assert(count($es)==4);
+assert($es[0]->innertext=='0');
+assert($es[1]->innertext=='1');
+assert($es[2]->innertext=='2');
+assert($es[3]->innertext=='3');
+
+// -----------------------------------------------------------------------------
+// nested selector test
+$str = <<<HTML
+<ul>
+    <li>0</li>
+    <li>1</li>
+</ul>
+<ul>
+    <li>2</li>
+    <li>3</li>
+</ul>
+HTML;
+$dom = str_get_dom($str);
+$es= $dom->find('ul');
+assert(count($es)==2);
+
+foreach($es as $n) {
+    $li = $n->find('li');
+    assert(count($li)==2);
+}
+
+$es= $dom->find('li');
+assert(count($es)==4);
+assert($es[0]->innertext=='0');
+assert($es[1]->innertext=='1');
+assert($es[2]->innertext=='2');
+assert($es[3]->innertext=='3');
+assert($es[0]->outertext=='<li>0</li>');
+assert($es[1]->outertext=='<li>1</li>');
+assert($es[2]->outertext=='<li>2</li>');
+assert($es[3]->outertext=='<li>3</li>');
+
+$counter = 0;
+foreach($dom->find('ul') as $ul) {
+    foreach($ul->find('li') as $li) {
+        assert($li->innertext=="$counter");
+            assert($li->outertext=="<li>$counter</li>");
+        ++$counter;
+    }
+}
+
+// -----------------------------------------------------------------------------
+//  [attribute=value] selector
+$str = <<<HTML
+<input type="radio" name="newsletter" value="Hot Fuzz" />
+<input type="radio" name="newsletters" value="Cold Fusion" />
+<input type="radio" name="accept" value="Evil Plans" />
+HTML;
+$dom->load($str);
+
+$es = $dom->find('[name=newsletter]');
+assert(count($es)==1);
+assert($es[0]->name=='newsletter');
+assert($es[0]->value=='Hot Fuzz');
+assert($es[0]->outertext=='<input type="radio" name="newsletter" value="Hot Fuzz">');
+
+$es = $dom->find('[name="newsletter"]');
+assert(count($es)==1);
+assert($es[0]->name=='newsletter');
+assert($es[0]->value=='Hot Fuzz');
+assert($es[0]->outertext=='<input type="radio" name="newsletter" value="Hot Fuzz">');
+
+// -----------------------------------------------------------------------------
+//  [attribute!=value] selector
+$str = <<<HTML
+<input type="radio" name="newsletter" value="Hot Fuzz" />
+<input type="radio" name="newsletter" value="Cold Fusion" />
+<input type="radio" name="accept" value="Evil Plans" />
+HTML;
+$dom->load($str);
+
+$es = $dom->find('[name!=newsletter]');
+assert(count($es)==1);
+assert($es[0]->name=='accept');
+assert($es[0]->value=='Evil Plans');
+assert($es[0]->outertext=='<input type="radio" name="accept" value="Evil Plans">');
+
+$es = $dom->find('[name!="newsletter"]');
+assert(count($es)==1);
+assert($es[0]->name=='accept');
+assert($es[0]->value=='Evil Plans');
+assert($es[0]->outertext=='<input type="radio" name="accept" value="Evil Plans">');
+
+$es = $dom->find("[name!='newsletter']");
+assert(count($es)==1);
+assert($es[0]->name=='accept');
+assert($es[0]->value=='Evil Plans');
+assert($es[0]->outertext=='<input type="radio" name="accept" value="Evil Plans">');
+
+// -----------------------------------------------------------------------------
+//  [attribute^=value] selector
+$str = <<<HTML
+<input name="newsletter" />
+<input name="milkman" />
+<input name="newsboy" />
+HTML;
+$dom->load($str);
+
+$es = $dom->find('[name^=news]');
+assert(count($es)==2);
+assert($es[0]->name=='newsletter');
+assert($es[0]->outertext=='<input name="newsletter">');
+assert($es[1]->name=='newsboy');
+assert($es[1]->outertext=='<input name="newsboy">');
+
+$es = $dom->find('[name^="news"]');
+assert(count($es)==2);
+assert($es[0]->name=='newsletter');
+assert($es[0]->outertext=='<input name="newsletter">');
+assert($es[1]->name=='newsboy');
+assert($es[1]->outertext=='<input name="newsboy">');
+
+// -----------------------------------------------------------------------------
+//  [attribute$=value] selector
+$str = <<<HTML
+<input name="newsletter" />
+<input name="milkman" />
+<input name="jobletter" />
+HTML;
+$dom->load($str);
+
+$es = $dom->find('[name$=letter]');
+assert(count($es)==2);
+assert($es[0]->name=='newsletter');
+assert($es[0]->outertext=='<input name="newsletter">');
+assert($es[1]->name=='jobletter');
+assert($es[1]->outertext=='<input name="jobletter">');
+
+$es = $dom->find('[name$="letter"]');
+assert(count($es)==2);
+assert($es[0]->name=='newsletter');
+assert($es[0]->outertext=='<input name="newsletter">');
+assert($es[1]->name=='jobletter');
+assert($es[1]->outertext=='<input name="jobletter">');
+
+// -----------------------------------------------------------------------------
+//  [attribute*=value] selector
+$str = <<<HTML
+<input name="man-news" />
+<input name="milkman" />
+<input name="letterman2" />
+<input name="newmilk" />
+<div class="foo hello bar"></div>
+<div class="foo bar hello"></div>
+<div class="hello foo bar"></div>
+HTML;
+$dom->load($str);
+
+$es = $dom->find('[name*=man]');
+assert(count($es)==3);
+assert($es[0]->name=='man-news');
+assert($es[0]->outertext=='<input name="man-news">');
+assert($es[1]->name=='milkman');
+assert($es[1]->outertext=='<input name="milkman">');
+assert($es[2]->name=='letterman2');
+assert($es[2]->outertext=='<input name="letterman2">');
+
+$es = $dom->find('[name*="man"]');
+assert(count($es)==3);
+assert($es[0]->name=='man-news');
+assert($es[0]->outertext=='<input name="man-news">');
+assert($es[1]->name=='milkman');
+assert($es[1]->outertext=='<input name="milkman">');
+assert($es[2]->name=='letterman2');
+assert($es[2]->outertext=='<input name="letterman2">');
+
+$es = $dom->find('[class*=hello]');
+assert($es[0]->outertext=='<div class="foo hello bar"></div>');
+assert($es[1]->outertext=='<div class="foo bar hello"></div>');
+assert($es[2]->outertext=='<div class="hello foo bar"></div>');
+
+// -----------------------------------------------------------------------------
+// Testcase for '[]' names element
+//  normal checkbox
+$str = <<<HTML
+<input type="checkbox" name="news" value="foo" />
+<input type="checkbox" name="news" value="bar">
+<input type="checkbox" name="news" value="baz" />
+HTML;
+$dom->load($str);
+$es = $dom->find('[name=news]');
+assert(count($es)==3);
+assert($es[0]->name=='news');
+assert($es[0]->value=='foo');
+assert($es[1]->name=='news');
+assert($es[1]->value=='bar');
+assert($es[2]->name=='news');
+assert($es[2]->value=='baz');
+
+// -----------------------------------------------------------------------------
+//  with '[]' names checkbox
+$str = <<<HTML
+<input type="checkbox" name="news[]" value="foo" />
+<input type="checkbox" name="news[]" value="bar">
+<input type="checkbox" name="news[]" value="baz" />
+HTML;
+$dom->load($str);
+$es = $dom->find('[name=news[]]');
+assert(count($es)==3);
+assert($es[0]->name=='news[]');
+assert($es[0]->value=='foo');
+assert($es[1]->name=='news[]');
+assert($es[1]->value=='bar');
+assert($es[2]->name=='news[]');
+assert($es[2]->value=='baz');
+
+// -----------------------------------------------------------------------------
+//  with '[]' names checkbox 2
+$str = <<<HTML
+<input type="checkbox" name="news[foo]" value="foo" />
+<input type="checkbox" name="news[bar]" value="bar">
+HTML;
+$dom->load($str);
+$es = $dom->find('[name=news[foo]]');
+assert(count($es)==1);
+assert($es[0]->name=='news[foo]');
+assert($es[0]->value=='foo');
+
+// -----------------------------------------------------------------------------
+// regular expression syntax escaping
+$str = <<<HTML
+<div>
+<a href="image/one.png">one</a>
+<a href="image/two.jpg">two</a>
+<a href="/favorites/aaa">three (text)</a>
+</div>
+HTML;
+$dom->load($str);
+assert(count($dom->find('a[href^="image/"]'))==2);
+assert(count($dom->find('a[href*="/favorites/"]'))==1);
+
+// -----------------------------------------------------------------------------
+// multiple class test
+$str = <<<HTML
+<div class="hello">should verify</div>
+<div class="foo hello bar">should verify</div>
+<div class="foo bar hello">should verify</div>
+<div class="hello foo bar">should verify</div>
+<div class="helloworld">should not verify</div>
+<div class="worldhello">should not verify</div>
+<div class="worldhelloworld">should not verify</div>
+HTML;
+
+$dom->load($str);
+$es = $dom->find('[class="hello"],[class*="hello "],[class*=" hello"]');
+assert(count($es)==4);
+assert($es[0]->class=='hello');
+assert($es[1]->class=='foo hello bar');
+assert($es[2]->class=='foo bar hello');
+assert($es[3]->class=='hello foo bar');
+
+$es = $dom->find('.hello');
+assert(count($es)==4);
+assert($es[0]->class=='hello');
+assert($es[1]->class=='foo hello bar');
+assert($es[2]->class=='foo bar hello');
+assert($es[3]->class=='hello foo bar');
+
+// -----------------------------------------------------------------------------
+// multiple class test 2
+$str = <<<HTML
+<div class="aa bb"></div>
+HTML;
+$dom->load($str);
+assert(count($dom->find('[class=aa]'))==1);
+assert(count($dom->find('[class=bb]'))==1);
+assert(count($dom->find('[class="aa bb"]'))==1);
+assert(count($dom->find('[class=aa], [class=bb]'))==1);
+
+// -----------------------------------------------------------------------------
+// multiple selector test
+$str = <<<HTML
+<p>aaa</p>
+<b>bbb</b>
+<i>ccc</i>
+HTML;
+$dom->load($str);
+
+$es = $dom->find('p,b,i');
+assert(count($es)==3);
+assert($es[0]->tag=='p');
+assert($es[1]->tag=='b');
+assert($es[2]->tag=='i');
+
+$es = $dom->find('p, b, i');
+assert(count($es)==3);
+assert($es[0]->tag=='p');
+assert($es[1]->tag=='b');
+assert($es[2]->tag=='i');
+
+$es = $dom->find('p,  b  ,   i');
+assert(count($es)==3);
+assert($es[0]->tag=='p');
+assert($es[1]->tag=='b');
+assert($es[2]->tag=='i');
+
+$es = $dom->find('p ,b ,i');
+assert(count($es)==3);
+assert($es[0]->tag=='p');
+assert($es[1]->tag=='b');
+assert($es[2]->tag=='i');
+
+$es = $dom->find('b,p,i');
+assert(count($es)==3);
+assert($es[0]->tag=='p');
+assert($es[1]->tag=='b');
+assert($es[2]->tag=='i');
+
+$es = $dom->find('i,b,p');
+assert(count($es)==3);
+assert($es[0]->tag=='p');
+assert($es[1]->tag=='b');
+assert($es[2]->tag=='i');
+
+$es = $dom->find('p,b,i,p,b');
+assert(count($es)==3);
+assert($es[0]->tag=='p');
+assert($es[1]->tag=='b');
+assert($es[2]->tag=='i');
+
+// -----------------------------------------------------------------------------
+// multiple selector test 2
+$str = <<<HTML
+<img title="aa" src="src">
+<a href="href" title="aa"></a>
+HTML;
+$dom->load($str);
+assert(count($dom->find('a[title], img[title]'))==2);
+
+// -----------------------------------------------------------------------------
+// tear down
+$dom->clear();
+unset($dom);
+?>

+ 742 - 0
vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/testcase/selector_testcase.php

@@ -0,0 +1,742 @@
+<?php
+// $Rev: 172 $
+// -----------------------------------------------------------------------------
+// setup
+error_reporting(E_ALL);
+require_once('../simple_html_dom.php');
+$dom = new simple_html_dom;
+
+// -----------------------------------------------------------------------------
+// "\t" or "\n" in tag test
+$str = <<<HTML
+<img 
+class="class0" id="id0" src="src0">
+<img
+ class="class1" id="id1" src="src1">
+<img class="class2" id="id2" src="src2">
+HTML;
+$dom->load($str);
+$e = $dom->find('img');
+assert(count($e)==3);
+
+// -----------------------------------------------------------------------------
+// std selector test
+$str = <<<HTML
+<div>
+<img class="class0" id="id0" src="src0">
+<img class="class1" id="id1" src="src1">
+<img class="class2" id="id2" src="src2">
+</div>
+HTML;
+$dom->load($str);
+
+// -----------------------------------------------
+// wildcard
+assert(count($dom->find('*'))==1);
+assert(count($dom->find('div *'))==3);
+assert(count($dom->find('div img *'))==0);
+
+
+assert(count($dom->find(' * '))==1);
+assert(count($dom->find(' div  * '))==3);
+assert(count($dom->find(' div  img  *'))==0);
+
+// -----------------------------------------------
+// tag
+assert(count($dom->find('img'))==3);
+assert(count($dom->find('text'))==4);
+
+// -----------------------------------------------
+// class
+$es = $dom->find('img.class0');
+assert(count($es)==1);
+assert($es[0]->src=='src0');
+assert($es[0]->innertext=='');
+assert($es[0]->outertext=='<img class="class0" id="id0" src="src0">');
+
+$es = $dom->find('.class0');
+assert(count($es)==1);
+assert($es[0]->src=='src0');
+assert($es[0]->innertext=='');
+assert($es[0]->outertext=='<img class="class0" id="id0" src="src0">');
+
+// -----------------------------------------------
+// index
+assert($dom->find('img', 0)->src=='src0');
+assert($dom->find('img', 1)->src=='src1');
+assert($dom->find('img', 2)->src=='src2');
+assert($dom->find('img', -3)->src=='src0');
+assert($dom->find('img', -2)->src=='src1');
+assert($dom->find('img', -1)->src=='src2');
+
+// -----------------------------------------------
+// id
+$es = $dom->find('img#id1');
+assert(count($es)==1);
+assert($es[0]->src=='src1');
+assert($es[0]->innertext=='');
+assert($es[0]->outertext=='<img class="class1" id="id1" src="src1">');
+
+$es = $dom->find('#id2');
+assert(count($es)==1);
+assert($es[0]->src=='src2');
+assert($es[0]->innertext=='');
+assert($es[0]->outertext=='<img class="class2" id="id2" src="src2">');
+
+// -----------------------------------------------
+// attr
+$es = $dom->find('img[src="src0"]');
+assert(count($es)==1);
+assert($es[0]->src=='src0');
+assert($es[0]->innertext=='');
+assert($es[0]->outertext=='<img class="class0" id="id0" src="src0">');
+
+$es = $dom->find('img[src=src0]');
+assert(count($es)==1);
+assert($es[0]->src=='src0');
+assert($es[0]->innertext=='');
+assert($es[0]->outertext=='<img class="class0" id="id0" src="src0">');
+
+// -----------------------------------------------------------------------------
+// wildcard
+$es = $dom->find('*[src]');
+assert(count($es)==3);
+
+$es = $dom->find('*[src=*]');
+assert(count($es)==3);
+
+$es = $dom->find('*[alt=*]');
+assert(count($es)==0);
+
+$es = $dom->find('*[src="src0"]');
+assert(count($es)==1);
+assert($es[0]->src=='src0');
+assert($es[0]->innertext=='');
+assert($es[0]->outertext=='<img class="class0" id="id0" src="src0">');
+
+$es = $dom->find('*[src=src0]');
+assert(count($es)==1);
+assert($es[0]->src=='src0');
+assert($es[0]->innertext=='');
+assert($es[0]->outertext=='<img class="class0" id="id0" src="src0">');
+
+$es = $dom->find('[src=src0]');
+assert(count($es)==1);
+assert($es[0]->src=='src0');
+assert($es[0]->innertext=='');
+assert($es[0]->outertext=='<img class="class0" id="id0" src="src0">');
+
+$es = $dom->find('[src="src0"]');
+assert(count($es)==1);
+assert($es[0]->src=='src0');
+assert($es[0]->innertext=='');
+assert($es[0]->outertext=='<img class="class0" id="id0" src="src0">');
+
+$es = $dom->find('*#id1');
+assert(count($es)==1);
+assert($es[0]->src=='src1');
+assert($es[0]->innertext=='');
+assert($es[0]->outertext=='<img class="class1" id="id1" src="src1">');
+
+$es = $dom->find('*.class0');
+assert(count($es)==1);
+assert($es[0]->src=='src0');
+assert($es[0]->innertext=='');
+assert($es[0]->outertext=='<img class="class0" id="id0" src="src0">');
+
+
+// -----------------------------------------------------------------------------
+// text
+$str = <<<HTML
+<b>text1</b><b>text2</b>
+HTML;
+$dom->load($str);
+$es = $dom->find('text');
+assert(count($es)==2);
+assert($es[0]->innertext=='text1');
+assert($es[0]->outertext=='text1');
+assert($es[0]->plaintext=='text1');
+assert($es[1]->innertext=='text2');
+assert($es[1]->outertext=='text2');
+assert($es[1]->plaintext=='text2');
+
+$str = <<<HTML
+<b>text1</b><b>text2</b>
+HTML;
+$dom->load($str);
+$es = $dom->find('b text');
+assert(count($es)==2);
+assert($es[0]->innertext=='text1');
+assert($es[0]->outertext=='text1');
+assert($es[0]->plaintext=='text1');
+assert($es[1]->innertext=='text2');
+assert($es[1]->outertext=='text2');
+assert($es[1]->plaintext=='text2');
+
+
+// -----------------------------------------------------------------------------
+// xml namespace test
+$str = <<<HTML
+<bw:bizy id="date">text</bw:bizy>
+HTML;
+$dom->load($str);
+$es = $dom->find('bw:bizy');
+assert(count($es)==1);
+assert($es[0]->id=='date');
+
+// -----------------------------------------------------------------------------
+// user defined tag name test
+$str = <<<HTML
+<div_test id="1">text</div_test>
+HTML;
+$dom->load($str);
+$es = $dom->find('div_test');
+assert(count($es)==1);
+assert($es[0]->id=='1');
+
+// -----------------------------------------------
+$str = <<<HTML
+<div-test id="1">text</div-test>
+HTML;
+$dom->load($str);
+$es = $dom->find('div-test');
+assert(count($es)==1);
+assert($es[0]->id=='1');
+
+// -----------------------------------------------
+$str = <<<HTML
+<div::test id="1">text</div::test>
+HTML;
+$dom->load($str);
+$es = $dom->find('div::test');
+assert(count($es)==1);
+assert($es[0]->id=='1');
+
+// -----------------------------------------------
+// find all occurrences of id="1" regardless of the tag
+$str = <<<HTML
+<img class="class0" id="1" src="src0">
+<img class="class1" id="2" src="src1">
+<div class="class2" id="1">ok</div>
+HTML;
+$dom->load($str);
+$es = $dom->find('[id=1]');
+assert(count($es)==2);
+assert($es[0]->tag=='img');
+assert($es[1]->tag=='div');
+
+// -----------------------------------------------------------------------------
+// multiple selector test
+$str = <<<HTML
+<div class="class0" id="id0" ><div class="class1" id="id1"><div class="class2" id="id2">ok</div><div style="st1 st2" id="id3"><span class="id4">ok</span></div></div></div>
+HTML;
+$dom->load($str);
+
+$es = $dom->find('div');
+assert(count($es)==4);
+assert($es[0]->id=='id0');
+assert($es[1]->id=='id1');
+assert($es[2]->id=='id2');
+
+$es = $dom->find('div div');
+assert(count($es)==3);
+assert($es[0]->id=='id1');
+assert($es[1]->id=='id2');
+
+$es = $dom->find('div div div');
+assert(count($es)==2);
+assert($es[0]->id=='id2');
+
+$es = $dom->find('.class0 .class1 .class2');
+assert(count($es)==1);
+assert($es[0]->id=='id2');
+
+$es = $dom->find('#id0 #id1 #id2');
+assert(count($es)==1);
+assert($es[0]->id=='id2');
+
+$es = $dom->find('div[id=id0] div[id=id1] div[id=id2]');
+assert(count($es)==1);
+assert($es[0]->id=='id2');
+
+$es = $dom->find('div[id="id0"] div[id="id1"] div[id="id2"]');
+assert(count($es)==1);
+assert($es[0]->id=='id2');
+
+$es = $dom->find('div[id=id0] div[id="id1"] div[id="id2"]');
+assert(count($es)==1);
+assert($es[0]->id=='id2');
+
+$es = $dom->find('div[id="id0"] div[id=id1] div[id="id2"]');
+assert(count($es)==1);
+assert($es[0]->id=='id2');
+
+$es = $dom->find('div[id="id0"] div[id="id1"] div[id=id2]');
+assert(count($es)==1);
+assert($es[0]->id=='id2');
+
+$es = $dom->find("div[id='id0'] div[id='id1'] div[id='id2']");
+assert(count($es)==1);
+assert($es[0]->id=='id2');
+
+$es = $dom->find('[id=id0] [id=id1] [id=id2]');
+assert(count($es)==1);
+assert($es[0]->id=='id2');
+
+$es = $dom->find('[id] [id] [id]');
+assert(count($es)==2);
+assert($es[0]->id=='id2');
+assert($es[1]->id=='id3');
+
+$es = $dom->find('[id=id0] [id=id1] [id=id3]');
+assert(count($es)==1);
+assert($es[0]->id=='id3');
+
+$es = $dom->find('[id=id0] [id=id1] [style="st1 st2"]');
+assert(count($es)==1);
+assert($es[0]->id=='id3');
+
+$es = $dom->find('[id=id0] [id=id1] [style=st1 st2]');
+assert(count($es)==1);
+assert($es[0]->id=='id3');
+
+$es = $dom->find('[id=id0] [id=id1] [style=st1 st2] span[class=id4]');
+assert(count($es)==1);
+assert($es[0]->innertext=='ok');
+
+$es = $dom->find('[id=id0] [id=id1] [style="st1 st2"] span[class="id4"]');
+assert(count($es)==1);
+assert($es[0]->innertext=='ok');
+
+// -----------------------------------------------
+$str = <<<HTML
+<table>
+    <tr>
+        <td>0</td>
+        <td>1</td>
+    </tr>
+</table>
+<table>
+    <tr>
+        <td>2</td>
+        <td>3</td>
+    </tr>
+</table>
+HTML;
+$dom->load($str);
+$es = $dom->find('table td');
+assert(count($es)==4);
+assert($es[0]->innertext=='0');
+assert($es[1]->innertext=='1');
+assert($es[2]->innertext=='2');
+assert($es[3]->innertext=='3');
+
+// -----------------------------------------------------------------------------
+// multiple selector test 3
+$str = <<<HTML
+<table>
+    <tr>
+        <td>
+            <table class="hello">
+                <tr>
+                    <td>0</td>
+                    <td>1</td>
+                </tr>
+            </table>
+        </td>
+    </tr>
+</table>
+<table class="hello">
+    <tr>
+        <td>2</td>
+        <td>3</td>
+    </tr>
+</table>
+HTML;
+$dom = str_get_html($str);
+$es = $dom->find('table.hello td');
+assert(count($es)==4);
+assert($es[0]->innertext=='0');
+assert($es[1]->innertext=='1');
+assert($es[2]->innertext=='2');
+assert($es[3]->innertext=='3');
+
+// -----------------------------------------------------------------------------
+// nested selector test
+$str = <<<HTML
+<ul>
+    <li>0</li>
+    <li>1</li>
+</ul>
+<ul>
+    <li>2</li>
+    <li>3</li>
+</ul>
+HTML;
+$dom = str_get_html($str);
+$es= $dom->find('ul');
+assert(count($es)==2);
+foreach($es as $n) {
+    $li = $n->find('li');
+    assert(count($li)==2);
+}
+
+$es= $dom->find('li');
+assert(count($es)==4);
+assert($es[0]->innertext=='0');
+assert($es[1]->innertext=='1');
+assert($es[2]->innertext=='2');
+assert($es[3]->innertext=='3');
+assert($es[0]->outertext=='<li>0</li>');
+assert($es[1]->outertext=='<li>1</li>');
+assert($es[2]->outertext=='<li>2</li>');
+assert($es[3]->outertext=='<li>3</li>');
+
+$counter = 0;
+foreach($dom->find('ul') as $ul) {
+    foreach($ul->find('li') as $li) {
+        assert($li->innertext=="$counter");
+            assert($li->outertext=="<li>$counter</li>");
+        ++$counter;
+    }
+}
+
+// -----------------------------------------------------------------------------
+//  [attribute=value] selector
+$str = <<<HTML
+<input type="radio" name="newsletter" value="Hot Fuzz" />
+<input type="radio" name="newsletters" value="Cold Fusion" />
+<input type="radio" name="accept" value="Evil Plans" />
+HTML;
+$dom->load($str);
+
+$es = $dom->find('[name=newsletter]');
+assert(count($es)==1);
+assert($es[0]->name=='newsletter');
+assert($es[0]->value=='Hot Fuzz');
+assert($es[0]->outertext=='<input type="radio" name="newsletter" value="Hot Fuzz" />');
+
+$es = $dom->find('[name="newsletter"]');
+assert(count($es)==1);
+assert($es[0]->name=='newsletter');
+assert($es[0]->value=='Hot Fuzz');
+assert($es[0]->outertext=='<input type="radio" name="newsletter" value="Hot Fuzz" />');
+
+// -----------------------------------------------------------------------------
+//  [attribute!=value] selector
+$str = <<<HTML
+<input type="radio" name="newsletter" value="Hot Fuzz" />
+<input type="radio" name="newsletter" value="Cold Fusion" />
+<input type="radio" name="accept" value="Evil Plans" />
+HTML;
+$dom->load($str);
+
+$es = $dom->find('[name!=newsletter]');
+assert(count($es)==1);
+assert($es[0]->name=='accept');
+assert($es[0]->value=='Evil Plans');
+assert($es[0]->outertext=='<input type="radio" name="accept" value="Evil Plans" />');
+
+$es = $dom->find('[name!="newsletter"]');
+assert(count($es)==1);
+assert($es[0]->name=='accept');
+assert($es[0]->value=='Evil Plans');
+assert($es[0]->outertext=='<input type="radio" name="accept" value="Evil Plans" />');
+
+$es = $dom->find("[name!='newsletter']");
+assert(count($es)==1);
+assert($es[0]->name=='accept');
+assert($es[0]->value=='Evil Plans');
+assert($es[0]->outertext=='<input type="radio" name="accept" value="Evil Plans" />');
+
+// -----------------------------------------------------------------------------
+//  [attribute^=value] selector
+$str = <<<HTML
+<input name="newsletter" />
+<input name="milkman" />
+<input name="newsboy" />
+HTML;
+$dom->load($str);
+
+$es = $dom->find('[name^=news]');
+assert(count($es)==2);
+assert($es[0]->name=='newsletter');
+assert($es[0]->outertext=='<input name="newsletter" />');
+assert($es[1]->name=='newsboy');
+assert($es[1]->outertext=='<input name="newsboy" />');
+
+$es = $dom->find('[name^="news"]');
+assert(count($es)==2);
+assert($es[0]->name=='newsletter');
+assert($es[0]->outertext=='<input name="newsletter" />');
+assert($es[1]->name=='newsboy');
+assert($es[1]->outertext=='<input name="newsboy" />');
+
+// -----------------------------------------------------------------------------
+//  [attribute$=value] selector
+$str = <<<HTML
+<input name="newsletter" />
+<input name="milkman" />
+<input name="jobletter" />
+HTML;
+$dom->load($str);
+
+$es = $dom->find('[name$=letter]');
+assert(count($es)==2);
+assert($es[0]->name=='newsletter');
+assert($es[0]->outertext=='<input name="newsletter" />');
+assert($es[1]->name=='jobletter');
+assert($es[1]->outertext=='<input name="jobletter" />');
+
+$es = $dom->find('[name$="letter"]');
+assert(count($es)==2);
+assert($es[0]->name=='newsletter');
+assert($es[0]->outertext=='<input name="newsletter" />');
+assert($es[1]->name=='jobletter');
+assert($es[1]->outertext=='<input name="jobletter" />');
+
+// -----------------------------------------------------------------------------
+//  [attribute*=value] selector
+$str = <<<HTML
+<input name="man-news" />
+<input name="milkman" />
+<input name="letterman2" />
+<input name="newmilk" />
+<div class="foo hello bar"></div>
+<div class="foo bar hello"></div>
+<div class="hello foo bar"></div>
+HTML;
+$dom->load($str);
+
+$es = $dom->find('[name*=man]');
+assert(count($es)==3);
+assert($es[0]->name=='man-news');
+assert($es[0]->outertext=='<input name="man-news" />');
+assert($es[1]->name=='milkman');
+assert($es[1]->outertext=='<input name="milkman" />');
+assert($es[2]->name=='letterman2');
+assert($es[2]->outertext=='<input name="letterman2" />');
+
+$es = $dom->find('[name*="man"]');
+assert(count($es)==3);
+assert($es[0]->name=='man-news');
+assert($es[0]->outertext=='<input name="man-news" />');
+assert($es[1]->name=='milkman');
+assert($es[1]->outertext=='<input name="milkman" />');
+assert($es[2]->name=='letterman2');
+assert($es[2]->outertext=='<input name="letterman2" />');
+
+$es = $dom->find('[class*=hello]');
+assert($es[0]->outertext=='<div class="foo hello bar"></div>');
+assert($es[1]->outertext=='<div class="foo bar hello"></div>');
+assert($es[2]->outertext=='<div class="hello foo bar"></div>');
+
+// -----------------------------------------------------------------------------
+// Testcase for '[]' names element
+//  normal checkbox
+$str = <<<HTML
+<input type="checkbox" name="news" value="foo" />
+<input type="checkbox" name="news" value="bar">
+<input type="checkbox" name="news" value="baz" />
+HTML;
+$dom->load($str);
+$es = $dom->find('[name=news]');
+assert(count($es)==3);
+assert($es[0]->name=='news');
+assert($es[0]->value=='foo');
+assert($es[1]->name=='news');
+assert($es[1]->value=='bar');
+assert($es[2]->name=='news');
+assert($es[2]->value=='baz');
+
+// -----------------------------------------------------------------------------
+//  with '[]' names checkbox
+$str = <<<HTML
+<input type="checkbox" name="news[]" value="foo" />
+<input type="checkbox" name="news[]" value="bar">
+<input type="checkbox" name="news[]" value="baz" />
+HTML;
+$dom->load($str);
+$es = $dom->find('[name=news[]]');
+assert(count($es)==3);
+assert($es[0]->name=='news[]');
+assert($es[0]->value=='foo');
+assert($es[1]->name=='news[]');
+assert($es[1]->value=='bar');
+assert($es[2]->name=='news[]');
+assert($es[2]->value=='baz');
+
+// -----------------------------------------------------------------------------
+//  with '[]' names checkbox 2
+$str = <<<HTML
+<input type="checkbox" name="news[foo]" value="foo" />
+<input type="checkbox" name="news[bar]" value="bar">
+HTML;
+$dom->load($str);
+$es = $dom->find('[name=news[foo]]');
+assert(count($es)==1);
+assert($es[0]->name=='news[foo]');
+assert($es[0]->value=='foo');
+
+// -----------------------------------------------------------------------------
+//  with '[]' names 3
+$str = <<<HTML
+<div name="div[]">
+    <input type="checkbox" name="checkbox[]" value="foo" />
+</div>
+HTML;
+$dom->load($str);
+$es = $dom->find('div[name=div[]] input[name=checkbox[]]');
+assert(count($es)==1);
+assert($es[0]->value=='foo');
+
+// -----------------------------------------------------------------------------
+// regular expression
+$str = <<<HTML
+<div>
+<a href="image/one.png">one</a>
+<a href="image/two.jpg">two</a>
+<a href="/favorites/aaa">three (text)</a>
+</div>
+HTML;
+$dom->load($str);
+assert(count($dom->find('a[href^="image/"]'))==2);
+assert(count($dom->find('a[href*="/favorites/"]'))==1);
+
+$str = <<<HTML
+<html>
+    <body>
+        <div id="news-id-123">okok</div>
+    </bod>
+</html>
+HTML;
+$dom->load($str);
+assert(count($dom->find('div[id*=news-id-[0-9]+]'))==1);
+assert(count($dom->find('div[id*=/news-id-[0-9]+/i]'))==1);
+
+// -----------------------------------------------------------------------------
+// multiple class test
+$str = <<<HTML
+<div class="hello">should verify</div>
+<div class="foo hello bar">should verify</div>
+<div class="foo bar hello">should verify</div>
+<div class="hello foo bar">should verify</div>
+<div class="helloworld">should not verify</div>
+<div class="worldhello">should not verify</div>
+<div class="worldhelloworld">should not verify</div>
+HTML;
+
+$dom->load($str);
+$es = $dom->find('[class="hello"],[class*="hello "],[class*=" hello"]');
+assert(count($es)==4);
+assert($es[0]->class=='hello');
+assert($es[1]->class=='foo hello bar');
+assert($es[2]->class=='foo bar hello');
+assert($es[3]->class=='hello foo bar');
+
+$es = $dom->find('.hello');
+assert(count($es)==4);
+assert($es[0]->class=='hello');
+assert($es[1]->class=='foo hello bar');
+assert($es[2]->class=='foo bar hello');
+assert($es[3]->class=='hello foo bar');
+
+// -----------------------------------------------
+$str = <<<HTML
+<div class="aa bb"></div>
+HTML;
+$dom->load($str);
+assert(count($dom->find('[class=aa]'))==1);
+assert(count($dom->find('[class=bb]'))==1);
+assert(count($dom->find('[class="aa bb"]'))==1);
+assert(count($dom->find('[class=aa], [class=bb]'))==1);
+
+// -----------------------------------------------------------------------------
+// multiple selector test
+$str = <<<HTML
+<p>aaa</p>
+<b>bbb</b>
+<i>ccc</i>
+HTML;
+$dom->load($str);
+
+$es = $dom->find('p,b,i');
+assert(count($es)==3);
+assert($es[0]->tag=='p');
+assert($es[1]->tag=='b');
+assert($es[2]->tag=='i');
+
+$es = $dom->find('p, b, i');
+assert(count($es)==3);
+assert($es[0]->tag=='p');
+assert($es[1]->tag=='b');
+assert($es[2]->tag=='i');
+
+$es = $dom->find('p,  b  ,   i');
+assert(count($es)==3);
+assert($es[0]->tag=='p');
+assert($es[1]->tag=='b');
+assert($es[2]->tag=='i');
+
+$es = $dom->find('p ,b ,i');
+assert(count($es)==3);
+assert($es[0]->tag=='p');
+assert($es[1]->tag=='b');
+assert($es[2]->tag=='i');
+
+$es = $dom->find('b,p,i');
+assert(count($es)==3);
+assert($es[0]->tag=='p');
+assert($es[1]->tag=='b');
+assert($es[2]->tag=='i');
+
+$es = $dom->find('i,b,p');
+assert(count($es)==3);
+assert($es[0]->tag=='p');
+assert($es[1]->tag=='b');
+assert($es[2]->tag=='i');
+
+$es = $dom->find('p,b,i,p,b');
+assert(count($es)==3);
+assert($es[0]->tag=='p');
+assert($es[1]->tag=='b');
+assert($es[2]->tag=='i');
+
+// -----------------------------------------------
+$str = <<<HTML
+<img title="aa" src="src">
+<a href="href" title="aa"></a>
+HTML;
+$dom->load($str);
+assert(count($dom->find('a[title], img[title]'))==2);
+
+// -----------------------------------------------------------------------------
+// elements that do NOT have the specified attribute
+$str = <<<HTML
+<img id="aa" src="src">
+<img src="src">
+HTML;
+$dom->load($str);
+assert(count($dom->find('img[!id]'))==1);
+
+// -----------------------------------------------------------------------------
+//js test
+$str = <<<HTML
+<a onMouseover="dropdownmenu(this, event, 'messagesmenu')" class="n" href="messagecenter.cfm?key=972489434">foo</a>
+HTML;
+$dom->load($str);
+assert($dom->find('a[onMouseover="dropdownmenu(this, event, \'messagesmenu\')"]',0)->innertext=='foo');
+assert($dom->find("a[onMouseover=dropdownmenu(this, event, 'messagesmenu')]",0)->innertext=='foo');
+
+// -----------------------------------------------------------------------------
+//dash test
+$str = '<meta http-equiv="content-type" content="text/html; charset=utf-8" />';
+
+$dom->load($str);
+assert($dom->find('meta[http-equiv=content-type]', 0)->content==='text/html; charset=utf-8');
+
+// -----------------------------------------------------------------------------
+// tear down
+$dom->clear();
+unset($dom);
+?>

+ 27 - 0
vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/testcase/slick_test.php

@@ -0,0 +1,27 @@
+<?php
+// $Rev: 133 $
+error_reporting(E_ALL);
+include_once('../simple_html_dom.php');
+
+$start = microtime();
+list($bu, $bs) = explode(' ', $start);
+$html = file_get_html('slickspeed.htm');
+list($eu, $es) = explode(' ', microtime());
+echo sprintf('parse (%.1f)', ((float)$eu+(float)$es-(float)$bu-(float)$bs)*1000).'<br><br>';
+
+assert(count($html->find('#title'))==1);
+assert(count($html->find('div'))==51);
+assert(count($html->find('div[class]'))==51);
+assert(count($html->find('div.example'))==43);
+assert(count($html->find('div[class=example]'))==43);
+assert(count($html->find('.note'))==14);
+
+assert(count($html->find('div[class^=exa]'))==43);
+assert(count($html->find('div[class$=mple]'))==43);
+assert(count($html->find('div[class*=e]'))==50);
+assert(count($html->find('div[class!=made_up]'))==51);
+
+assert(count($html->find('p'))==324);
+
+echo 'All pass!<br>';
+?>

+ 2888 - 0
vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/testcase/slickspeed.htm

@@ -0,0 +1,2888 @@
+<!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01//EN' 'http://www.w3.org/TR/html4/strict.dtd'>
+<html lang="en">
+ <head>
+  <title>Selectors</title>
+  <link href="default.css" type="text/css" rel="stylesheet">
+  <link href="http://www.w3.org/StyleSheets/TR/W3C-WD.css" type="text/css" rel="stylesheet">
+  <script src="jquery-1.2.3.pack.js"></script>
+<script language="JavaScript" type="text/JavaScript">
+	$(document).ready(function(){
+		console.log($('a').size());
+        /*
+        $('div,p,a').each(
+            function(idx) {
+                console.log(this.href);
+            }
+        );
+        */
+	});
+</script>
+ </head>
+ <body>
+  <div class="head">
+   <p id="p1"><a id="a1" href="http://www.w3.org/"><img height=48 alt=W3C src="http://www.w3.org/Icons/w3c_home" width=72></a>
+
+   <h1 id="title">Selectors</h1>
+
+   <h2>W3C Working Draft 15 December 2005</h2>
+
+   <dl>
+
+    <dt>This version:
+
+    <dd><a id="a2" href="http://www.w3.org/TR/2005/WD-css3-selectors-20051215">
+                 http://www.w3.org/TR/2005/WD-css3-selectors-20051215</a>
+
+    <dt>Latest version:
+
+    <dd><a id="a3" href="http://www.w3.org/TR/css3-selectors">
+                 http://www.w3.org/TR/css3-selectors</a>
+
+    <dt>Previous version:
+
+    <dd><a id="a4" href="http://www.w3.org/TR/2001/CR-css3-selectors-20011113">
+                 http://www.w3.org/TR/2001/CR-css3-selectors-20011113</a>
+
+    <dt><a id="a5" name=editors-list></a>Editors:
+
+    <dd class="vcard"><span class="fn">Daniel Glazman</span> (Invited Expert)</dd>
+
+    <dd class="vcard"><a id="a6" lang="tr" class="url fn" href="http://www.tantek.com/">Tantek &Ccedil;elik</a> (Invited Expert)
+
+    <dd class="vcard"><a id="a7" href="mailto:ian@hixie.ch" class="url fn">Ian Hickson</a> (<span
+    class="company"><a id="a8" href="http://www.google.com/">Google</a></span>)
+
+    <dd class="vcard"><span class="fn">Peter Linss</span> (former editor, <span class="company"><a
+    id="a9" href="http://www.netscape.com/">Netscape/AOL</a></span>)
+
+    <dd class="vcard"><span class="fn">John Williams</span> (former editor, <span class="company"><a
+    id="a10" href="http://www.quark.com/">Quark, Inc.</a></span>)
+
+   </dl>
+
+   <p id="p2" class="copyright"><a
+   id="a11" href="http://www.w3.org/Consortium/Legal/ipr-notice#Copyright">
+   Copyright</a> &copy; 2005 <a id="a12" href="http://www.w3.org/"><abbr
+   title="World Wide Web Consortium">W3C</abbr></a><sup>&reg;</sup>
+   (<a id="a13" href="http://www.csail.mit.edu/"><abbr title="Massachusetts
+   Institute of Technology">MIT</abbr></a>, <a
+   href="http://www.ercim.org/"><acronym title="European Research
+   Consortium for Informatics and Mathematics">ERCIM</acronym></a>, <a
+   href="http://www.keio.ac.jp/">Keio</a>), All Rights Reserved.  W3C
+   <a
+   href="http://www.w3.org/Consortium/Legal/ipr-notice#Legal_Disclaimer">liability</a>,
+   <a
+   href="http://www.w3.org/Consortium/Legal/ipr-notice#W3C_Trademarks">trademark</a>,
+   <a
+   href="http://www.w3.org/Consortium/Legal/copyright-documents">document
+   use</a> rules apply.
+
+   <hr title="Separator for header">
+
+  </div>
+
+  <h2><a name=abstract></a>Abstract</h2>
+
+  <p id="p3"><em>Selectors</em> are patterns that match against elements in a
+  tree. Selectors have been optimized for use with HTML and XML, and
+  are designed to be usable in performance-critical code.</p>
+
+  <p id="p4"><acronym title="Cascading Style Sheets">CSS</acronym> (Cascading
+  Style Sheets) is a language for describing the rendering of <acronym
+  title="Hypertext Markup Language">HTML</acronym> and <acronym
+  title="Extensible Markup Language">XML</acronym> documents on
+  screen, on paper, in speech, etc. CSS uses Selectors for binding
+  style properties to elements in the document. This document
+  describes extensions to the selectors defined in CSS level 2. These
+  extended selectors will be used by CSS level 3.
+
+  <p id="p5">Selectors define the following function:</p>
+
+  <pre>expression &#x2217; element &rarr; boolean</pre>
+
+  <p id="p6">That is, given an element and a selector, this specification
+  defines whether that element matches the selector.</p>
+
+  <p>These expressions can also be used, for instance, to select a set
+  of elements, or a single element from a set of elements, by
+  evaluating the expression across all the elements in a
+  subtree. <acronym title="Simple Tree Transformation
+  Sheets">STTS</acronym> (Simple Tree Transformation Sheets), a
+  language for transforming XML trees, uses this mechanism. <a href="#refsSTTS">[STTS]</a></p>
+
+  <h2><a name=status></a>Status of this document</h2>
+
+  <p><em>This section describes the status of this document at the
+  time of its publication. Other documents may supersede this
+  document. A list of current W3C publications and the latest revision
+  of this technical report can be found in the <a
+  href="http://www.w3.org/TR/">W3C technical reports index at
+  http://www.w3.org/TR/.</a></em></p>
+
+  <p>This document describes the selectors that already exist in <a
+  href="#refsCSS1"><abbr title="CSS level 1">CSS1</abbr></a> and <a
+  href="#refsCSS21"><abbr title="CSS level 2">CSS2</abbr></a>, and
+  also proposes new selectors for <abbr title="CSS level
+  3">CSS3</abbr> and other languages that may need them.</p>
+
+  <p>The CSS Working Group doesn't expect that all implementations of
+  CSS3 will have to implement all selectors. Instead, there will
+  probably be a small number of variants of CSS3, called profiles. For
+  example, it may be that only a profile for interactive user agents
+  will include all of the selectors.</p>
+
+  <p>This specification is a last call working draft for the the <a
+  href="http://www.w3.org/Style/CSS/members">CSS Working Group</a>
+  (<a href="/Style/">Style Activity</a>). This
+  document is a revision of the <a
+  href="http://www.w3.org/TR/2001/CR-css3-selectors-20011113/">Candidate
+  Recommendation dated 2001 November 13</a>, and has incorporated
+  implementation feedback received in the past few years. It is
+  expected that this last call will proceed straight to Proposed
+  Recommendation stage since it is believed that interoperability will
+  be demonstrable.</p>
+
+  <p>All persons are encouraged to review and implement this
+  specification and return comments to the (<a
+  href="http://lists.w3.org/Archives/Public/www-style/">archived</a>)
+  public mailing list <a
+  href="http://www.w3.org/Mail/Lists.html#www-style">www-style</a>
+  (see <a href="http://www.w3.org/Mail/Request">instructions</a>). W3C
+  Members can also send comments directly to the CSS Working
+  Group.
+  The deadline for comments is 14 January 2006.</p>
+
+  <p>This is still a draft document and may be updated, replaced, or
+  obsoleted by other documents at any time. It is inappropriate to
+  cite a W3C Working Draft as other than &quot;work in progress&quot;.
+
+  <p>This document may be available in <a
+  href="http://www.w3.org/Style/css3-selectors-updates/translations">translation</a>.
+  The English version of this specification is the only normative
+  version.
+
+  <div class="subtoc">
+
+   <h2><a name=contents>Table of contents</a></h2>
+
+   <ul class="toc">
+    <li class="tocline2"><a href="#context">1. Introduction</a>
+     <ul>
+      <li><a href="#dependencies">1.1. Dependencies</a> </li>
+      <li><a href="#terminology">1.2. Terminology</a> </li>
+      <li><a href="#changesFromCSS2">1.3. Changes from CSS2</a> </li>
+     </ul>
+    <li class="tocline2"><a href="#selectors">2. Selectors</a>
+    <li class="tocline2"><a href="#casesens">3. Case sensitivity</a>
+    <li class="tocline2"><a href="#selector-syntax">4. Selector syntax</a>
+    <li class="tocline2"><a href="#grouping">5. Groups of selectors</a>
+    <li class="tocline2"><a href="#simple-selectors">6. Simple selectors</a>
+     <ul class="toc">
+      <li class="tocline3"><a href="#type-selectors">6.1. Type selectors</a>
+       <ul class="toc">
+        <li class="tocline4"><a href="#typenmsp">6.1.1. Type selectors and namespaces</a></li>
+       </ul>
+      <li class="tocline3"><a href="#universal-selector">6.2. Universal selector</a>
+       <ul>
+        <li><a href="#univnmsp">6.2.1. Universal selector and namespaces</a></li>
+       </ul>
+      <li class="tocline3"><a href="#attribute-selectors">6.3. Attribute selectors</a>
+       <ul class="toc">
+        <li class="tocline4"><a href="#attribute-representation">6.3.1. Representation of attributes and attributes values</a>
+        <li><a href="#attribute-substrings">6.3.2. Substring matching attribute selectors</a>
+        <li class="tocline4"><a href="#attrnmsp">6.3.3. Attribute selectors and namespaces</a>
+        <li class="tocline4"><a href="#def-values">6.3.4. Default attribute values in DTDs</a></li>
+       </ul>
+      <li class="tocline3"><a href="#class-html">6.4. Class selectors</a>
+      <li class="tocline3"><a href="#id-selectors">6.5. ID selectors</a>
+      <li class="tocline3"><a href="#pseudo-classes">6.6. Pseudo-classes</a>
+       <ul class="toc">
+        <li class="tocline4"><a href="#dynamic-pseudos">6.6.1. Dynamic pseudo-classes</a>
+        <li class="tocline4"><a href="#target-pseudo">6.6.2. The :target pseudo-class</a>
+        <li class="tocline4"><a href="#lang-pseudo">6.6.3. The :lang() pseudo-class</a>
+        <li class="tocline4"><a href="#UIstates">6.6.4. UI element states pseudo-classes</a>
+        <li class="tocline4"><a href="#structural-pseudos">6.6.5. Structural pseudo-classes</a>
+         <ul>
+          <li><a href="#root-pseudo">:root pseudo-class</a>
+          <li><a href="#nth-child-pseudo">:nth-child() pseudo-class</a>
+          <li><a href="#nth-last-child-pseudo">:nth-last-child()</a>
+          <li><a href="#nth-of-type-pseudo">:nth-of-type() pseudo-class</a>
+          <li><a href="#nth-last-of-type-pseudo">:nth-last-of-type()</a>
+          <li><a href="#first-child-pseudo">:first-child pseudo-class</a>
+          <li><a href="#last-child-pseudo">:last-child pseudo-class</a>
+          <li><a href="#first-of-type-pseudo">:first-of-type pseudo-class</a>
+          <li><a href="#last-of-type-pseudo">:last-of-type pseudo-class</a>
+          <li><a href="#only-child-pseudo">:only-child pseudo-class</a>
+          <li><a href="#only-of-type-pseudo">:only-of-type pseudo-class</a>
+          <li><a href="#empty-pseudo">:empty pseudo-class</a></li>
+         </ul>
+        <li class="tocline4"><a href="#negation">6.6.7. The negation pseudo-class</a></li>
+       </ul>
+      </li>
+     </ul>
+    <li><a href="#pseudo-elements">7. Pseudo-elements</a>
+     <ul>
+      <li><a href="#first-line">7.1. The ::first-line pseudo-element</a>
+      <li><a href="#first-letter">7.2. The ::first-letter pseudo-element</a>
+      <li><a href="#UIfragments">7.3. The ::selection pseudo-element</a>
+      <li><a href="#gen-content">7.4. The ::before and ::after pseudo-elements</a></li>
+     </ul>
+    <li class="tocline2"><a href="#combinators">8. Combinators</a>
+     <ul class="toc">
+      <li class="tocline3"><a href="#descendant-combinators">8.1. Descendant combinators</a>
+      <li class="tocline3"><a href="#child-combinators">8.2. Child combinators</a>
+      <li class="tocline3"><a href="#sibling-combinators">8.3. Sibling combinators</a>
+       <ul class="toc">
+        <li class="tocline4"><a href="#adjacent-sibling-combinators">8.3.1. Adjacent sibling combinator</a>
+        <li class="tocline4"><a href="#general-sibling-combinators">8.3.2. General sibling combinator</a></li>
+       </ul>
+      </li>
+     </ul>
+    <li class="tocline2"><a href="#specificity">9. Calculating a selector's specificity</a>
+    <li class="tocline2"><a href="#w3cselgrammar">10. The grammar of Selectors</a>
+     <ul class="toc">
+      <li class="tocline3"><a href="#grammar">10.1. Grammar</a>
+      <li class="tocline3"><a href="#lex">10.2. Lexical scanner</a></li>
+     </ul>
+    <li class="tocline2"><a href="#downlevel">11. Namespaces and down-level clients</a>
+    <li class="tocline2"><a href="#profiling">12. Profiles</a>
+    <li><a href="#Conformance">13. Conformance and requirements</a>
+    <li><a href="#Tests">14. Tests</a>
+    <li><a href="#ACKS">15. Acknowledgements</a>
+    <li class="tocline2"><a href="#references">16. References</a>
+   </ul>
+
+  </div>
+
+  <h2><a name=context>1. Introduction</a></h2>
+
+  <h3><a name=dependencies></a>1.1. Dependencies</h3>
+
+  <p>Some features of this specification are specific to CSS, or have
+  particular limitations or rules specific to CSS. In this
+  specification, these have been described in terms of CSS2.1. <a
+  href="#refsCSS21">[CSS21]</a></p>
+
+  <h3><a name=terminology></a>1.2. Terminology</h3>
+
+  <p>All of the text of this specification is normative except
+  examples, notes, and sections explicitly marked as
+  non-normative.</p>
+
+  <h3><a name=changesFromCSS2></a>1.3. Changes from CSS2</h3>
+ 
+  <p><em>This section is non-normative.</em></p>
+
+  <p>The main differences between the selectors in CSS2 and those in
+  Selectors are:
+
+  <ul>
+
+   <li>the list of basic definitions (selector, group of selectors,
+   simple selector, etc.) has been changed; in particular, what was
+   referred to in CSS2 as a simple selector is now called a sequence
+   of simple selectors, and the term "simple selector" is now used for
+   the components of this sequence</li>
+
+   <li>an optional namespace component is now allowed in type element
+   selectors, the universal selector and attribute selectors</li>
+
+   <li>a <a href="#general-sibling-combinators">new combinator</a> has been introduced</li>
+
+   <li>new simple selectors including substring matching attribute
+   selectors, and new pseudo-classes</li>
+
+   <li>new pseudo-elements, and introduction of the "::" convention
+   for pseudo-elements</li>
+
+   <li>the grammar has been rewritten</li>
+
+   <li>profiles to be added to specifications integrating Selectors
+   and defining the set of selectors which is actually supported by
+   each specification</li>
+
+   <li>Selectors are now a CSS3 Module and an independent
+   specification; other specifications can now refer to this document
+   independently of CSS</li>
+
+   <li>the specification now has its own test suite</li>
+
+  </ul>
+
+<h2><a name=selectors></a>2. Selectors</h2>
+
+<p><em>This section is non-normative, as it merely summarizes the
+following sections.</em></p>
+
+<p>A Selector represents a structure. This structure can be used as a
+condition (e.g. in a CSS rule) that determines which elements a
+selector matches in the document tree, or as a flat description of the
+HTML or XML fragment corresponding to that structure.</p>
+
+<p>Selectors may range from simple element names to rich contextual
+representations.</p>
+
+<p>The following table summarizes the Selector syntax:</p>
+
+<table class="selectorsReview">
+  <thead>
+  <tr>
+    <th class="pattern">Pattern</th>
+    <th class="meaning">Meaning</th>
+    <th class="described">Described in section</th>
+    <th class="origin">First defined in CSS level</th></tr>
+  <tbody>
+  <tr>
+    <td class="pattern">*</td>
+    <td class="meaning">any element</td>
+    <td class="described"><a
+      href="#universal-selector">Universal
+      selector</a></td>
+    <td class="origin">2</td></tr>
+  <tr>
+    <td class="pattern">E</td>
+    <td class="meaning">an element of type E</td>
+    <td class="described"><a
+      href="#type-selectors">Type selector</a></td>
+    <td class="origin">1</td></tr>
+  <tr>
+    <td class="pattern">E[foo]</td>
+    <td class="meaning">an E element with a "foo" attribute</td>
+    <td class="described"><a
+      href="#attribute-selectors">Attribute
+      selectors</a></td>
+    <td class="origin">2</td></tr>
+  <tr>
+    <td class="pattern">E[foo="bar"]</td>
+    <td class="meaning">an E element whose "foo" attribute value is exactly
+      equal to "bar"</td>
+    <td class="described"><a
+      href="#attribute-selectors">Attribute
+      selectors</a></td>
+    <td class="origin">2</td></tr>
+  <tr>
+    <td class="pattern">E[foo~="bar"]</td>
+    <td class="meaning">an E element whose "foo" attribute value is a list of
+      space-separated values, one of which is exactly equal to "bar"</td>
+    <td class="described"><a
+      href="#attribute-selectors">Attribute
+      selectors</a></td>
+    <td class="origin">2</td></tr>
+  <tr>
+    <td class="pattern">E[foo^="bar"]</td>
+    <td class="meaning">an E element whose "foo" attribute value begins exactly
+      with the string "bar"</td>
+    <td class="described"><a
+      href="#attribute-selectors">Attribute
+      selectors</a></td>
+    <td class="origin">3</td></tr>
+  <tr>
+    <td class="pattern">E[foo$="bar"]</td>
+    <td class="meaning">an E element whose "foo" attribute value ends exactly
+      with the string "bar"</td>
+    <td class="described"><a
+      href="#attribute-selectors">Attribute
+      selectors</a></td>
+    <td class="origin">3</td></tr>
+  <tr>
+    <td class="pattern">E[foo*="bar"]</td>
+    <td class="meaning">an E element whose "foo" attribute value contains the
+      substring "bar"</td>
+    <td class="described"><a
+      href="#attribute-selectors">Attribute
+      selectors</a></td>
+    <td class="origin">3</td></tr>
+  <tr>
+    <td class="pattern">E[hreflang|="en"]</td>
+    <td class="meaning">an E element whose "hreflang" attribute has a hyphen-separated
+      list of values beginning (from the left) with "en"</td>
+    <td class="described"><a
+      href="#attribute-selectors">Attribute
+      selectors</a></td>
+    <td class="origin">2</td></tr>
+  <tr>
+    <td class="pattern">E:root</td>
+    <td class="meaning">an E element, root of the document</td>
+    <td class="described"><a
+      href="#structural-pseudos">Structural
+      pseudo-classes</a></td>
+    <td class="origin">3</td></tr>
+  <tr>
+    <td class="pattern">E:nth-child(n)</td>
+    <td class="meaning">an E element, the n-th child of its parent</td>
+    <td class="described"><a
+      href="#structural-pseudos">Structural
+      pseudo-classes</a></td>
+    <td class="origin">3</td></tr>
+  <tr>
+    <td class="pattern">E:nth-last-child(n)</td>
+    <td class="meaning">an E element, the n-th child of its parent, counting
+      from the last one</td>
+    <td class="described"><a
+      href="#structural-pseudos">Structural
+      pseudo-classes</a></td>
+    <td class="origin">3</td></tr>
+  <tr>
+    <td class="pattern">E:nth-of-type(n)</td>
+    <td class="meaning">an E element, the n-th sibling of its type</td>
+    <td class="described"><a
+      href="#structural-pseudos">Structural
+      pseudo-classes</a></td>
+    <td class="origin">3</td></tr>
+  <tr>
+    <td class="pattern">E:nth-last-of-type(n)</td>
+    <td class="meaning">an E element, the n-th sibling of its type, counting
+      from the last one</td>
+    <td class="described"><a
+      href="#structural-pseudos">Structural
+      pseudo-classes</a></td>
+    <td class="origin">3</td></tr>
+  <tr>
+    <td class="pattern">E:first-child</td>
+    <td class="meaning">an E element, first child of its parent</td>
+    <td class="described"><a
+      href="#structural-pseudos">Structural
+      pseudo-classes</a></td>
+    <td class="origin">2</td></tr>
+  <tr>
+    <td class="pattern">E:last-child</td>
+    <td class="meaning">an E element, last child of its parent</td>
+    <td class="described"><a
+      href="#structural-pseudos">Structural
+      pseudo-classes</a></td>
+    <td class="origin">3</td></tr>
+  <tr>
+    <td class="pattern">E:first-of-type</td>
+    <td class="meaning">an E element, first sibling of its type</td>
+    <td class="described"><a
+      href="#structural-pseudos">Structural
+      pseudo-classes</a></td>
+    <td class="origin">3</td></tr>
+  <tr>
+    <td class="pattern">E:last-of-type</td>
+    <td class="meaning">an E element, last sibling of its type</td>
+    <td class="described"><a
+      href="#structural-pseudos">Structural
+      pseudo-classes</a></td>
+    <td class="origin">3</td></tr>
+  <tr>
+    <td class="pattern">E:only-child</td>
+    <td class="meaning">an E element, only child of its parent</td>
+    <td class="described"><a
+      href="#structural-pseudos">Structural
+      pseudo-classes</a></td>
+    <td class="origin">3</td></tr>
+  <tr>
+    <td class="pattern">E:only-of-type</td>
+    <td class="meaning">an E element, only sibling of its type</td>
+    <td class="described"><a
+      href="#structural-pseudos">Structural
+      pseudo-classes</a></td>
+    <td class="origin">3</td></tr>
+  <tr>
+    <td class="pattern">E:empty</td>
+    <td class="meaning">an E element that has no children (including text
+    nodes)</td>
+    <td class="described"><a
+      href="#structural-pseudos">Structural
+      pseudo-classes</a></td>
+    <td class="origin">3</td></tr>
+  <tr>
+    <td class="pattern">E:link<br>E:visited</td>
+    <td class="meaning">an E element being the source anchor of a hyperlink of
+      which the target is not yet visited (:link) or already visited
+    (:visited)</td>
+    <td class="described"><a
+      href="#link">The link
+      pseudo-classes</a></td>
+    <td class="origin">1</td></tr>
+  <tr>
+    <td class="pattern">E:active<br>E:hover<br>E:focus</td>
+    <td class="meaning">an E element during certain user actions</td>
+    <td class="described"><a
+      href="#useraction-pseudos">The user
+      action pseudo-classes</a></td>
+    <td class="origin">1 and 2</td></tr>
+  <tr>
+    <td class="pattern">E:target</td>
+    <td class="meaning">an E element being the target of the referring URI</td>
+    <td class="described"><a
+      href="#target-pseudo">The target
+      pseudo-class</a></td>
+    <td class="origin">3</td></tr>
+  <tr>
+    <td class="pattern">E:lang(fr)</td>
+    <td class="meaning">an element of type E in language "fr" (the document
+      language specifies how language is determined)</td>
+    <td class="described"><a
+      href="#lang-pseudo">The :lang()
+      pseudo-class</a></td>
+    <td class="origin">2</td></tr>
+  <tr>
+    <td class="pattern">E:enabled<br>E:disabled</td>
+    <td class="meaning">a user interface element E which is enabled or
+    disabled</td>
+    <td class="described"><a
+      href="#UIstates">The UI element states
+      pseudo-classes</a></td>
+    <td class="origin">3</td></tr>
+  <tr>
+    <td class="pattern">E:checked<!--<br>E:indeterminate--></td>
+    <td class="meaning">a user interface element E which is checked<!-- or in an
+      indeterminate state--> (for instance a radio-button or checkbox)</td>
+    <td class="described"><a
+      href="#UIstates">The UI element states
+      pseudo-classes</a></td>
+    <td class="origin">3</td></tr>
+  <tr>
+    <td class="pattern">E::first-line</td>
+    <td class="meaning">the first formatted line of an E element</td>
+    <td class="described"><a
+      href="#first-line">The ::first-line
+      pseudo-element</a></td>
+    <td class="origin">1</td></tr>
+  <tr>
+    <td class="pattern">E::first-letter</td>
+    <td class="meaning">the first formatted letter of an E element</td>
+    <td class="described"><a
+      href="#first-letter">The ::first-letter
+      pseudo-element</a></td>
+    <td class="origin">1</td></tr>
+  <tr>
+    <td class="pattern">E::selection</td>
+    <td class="meaning">the portion of an E element that is currently
+      selected/highlighted by the user</td>
+    <td class="described"><a
+      href="#UIfragments">The UI element
+      fragments pseudo-elements</a></td>
+    <td class="origin">3</td></tr>
+  <tr>
+    <td class="pattern">E::before</td>
+    <td class="meaning">generated content before an E element</td>
+    <td class="described"><a
+      href="#gen-content">The ::before
+      pseudo-element</a></td>
+    <td class="origin">2</td></tr>
+  <tr>
+    <td class="pattern">E::after</td>
+    <td class="meaning">generated content after an E element</td>
+    <td class="described"><a
+      href="#gen-content">The ::after
+      pseudo-element</a></td>
+    <td class="origin">2</td></tr>
+  <tr>
+    <td class="pattern">E.warning</td>
+    <td class="meaning">an E element whose class is
+"warning" (the document language specifies how class is determined).</td>
+    <td class="described"><a
+      href="#class-html">Class
+    selectors</a></td>
+    <td class="origin">1</td></tr>
+  <tr>
+    <td class="pattern">E#myid</td>
+    <td class="meaning">an E element with ID equal to "myid".</td>
+    <td class="described"><a
+      href="#id-selectors">ID
+    selectors</a></td>
+    <td class="origin">1</td></tr>
+  <tr>
+    <td class="pattern">E:not(s)</td>
+    <td class="meaning">an E element that does not match simple selector s</td>
+    <td class="described"><a
+      href="#negation">Negation
+      pseudo-class</a></td>
+    <td class="origin">3</td></tr>
+  <tr>
+    <td class="pattern">E F</td>
+    <td class="meaning">an F element descendant of an E element</td>
+    <td class="described"><a
+      href="#descendant-combinators">Descendant
+      combinator</a></td>
+    <td class="origin">1</td></tr>
+  <tr>
+    <td class="pattern">E &gt; F</td>
+    <td class="meaning">an F element child of an E element</td>
+    <td class="described"><a
+      href="#child-combinators">Child
+      combinator</a></td>
+    <td class="origin">2</td></tr>
+  <tr>
+    <td class="pattern">E + F</td>
+    <td class="meaning">an F element immediately preceded by an E element</td>
+    <td class="described"><a
+      href="#adjacent-sibling-combinators">Adjacent sibling combinator</a></td>
+    <td class="origin">2</td></tr>
+  <tr>
+    <td class="pattern">E ~ F</td>
+    <td class="meaning">an F element preceded by an E element</td>
+    <td class="described"><a
+      href="#general-sibling-combinators">General sibling combinator</a></td>
+    <td class="origin">3</td></tr></tbody></table>
+
+<p>The meaning of each selector is derived from the table above by
+prepending "matches" to the contents of each cell in the "Meaning"
+column.</p>
+
+<h2><a name=casesens>3. Case sensitivity</a></h2>
+
+<p>The case sensitivity of document language element names, attribute
+names, and attribute values in selectors depends on the document
+language. For example, in HTML, element names are case-insensitive,
+but in XML, they are case-sensitive.</p>
+
+<h2><a name=selector-syntax>4. Selector syntax</a></h2>
+
+<p>A <dfn><a name=selector>selector</a></dfn> is a chain of one
+or more <a href="#sequence">sequences of simple selectors</a>
+separated by <a href="#combinators">combinators</a>.</p>
+
+<p>A <dfn><a name=sequence>sequence of simple selectors</a></dfn>
+is a chain of <a href="#simple-selectors-dfn">simple selectors</a>
+that are not separated by a <a href="#combinators">combinator</a>. It
+always begins with a <a href="#type-selectors">type selector</a> or a
+<a href="#universal-selector">universal selector</a>. No other type
+selector or universal selector is allowed in the sequence.</p>
+
+<p>A <dfn><a name=simple-selectors-dfn></a><a
+href="#simple-selectors">simple selector</a></dfn> is either a <a
+href="#type-selectors">type selector</a>, <a
+href="#universal-selector">universal selector</a>, <a
+href="#attribute-selectors">attribute selector</a>, <a
+href="#class-html">class selector</a>, <a
+href="#id-selectors">ID selector</a>, <a
+href="#content-selectors">content selector</a>, or <a
+href="#pseudo-classes">pseudo-class</a>. One <a
+href="#pseudo-elements">pseudo-element</a> may be appended to the last
+sequence of simple selectors.</p>
+
+<p><dfn>Combinators</dfn> are: white space, &quot;greater-than
+sign&quot; (U+003E, <code>&gt;</code>), &quot;plus sign&quot; (U+002B,
+<code>+</code>) and &quot;tilde&quot; (U+007E, <code>~</code>).  White
+space may appear between a combinator and the simple selectors around
+it. <a name=whitespace></a>Only the characters "space" (U+0020), "tab"
+(U+0009), "line feed" (U+000A), "carriage return" (U+000D), and "form
+feed" (U+000C) can occur in white space. Other space-like characters,
+such as "em-space" (U+2003) and "ideographic space" (U+3000), are
+never part of white space.</p>
+
+<p>The elements of a document tree that are represented by a selector
+are the <dfn><a name=subject></a>subjects of the selector</dfn>. A
+selector consisting of a single sequence of simple selectors
+represents any element satisfying its requirements. Prepending another
+sequence of simple selectors and a combinator to a sequence imposes
+additional matching constraints, so the subjects of a selector are
+always a subset of the elements represented by the last sequence of
+simple selectors.</p>
+
+<p>An empty selector, containing no sequence of simple selectors and
+no pseudo-element, is an <a href="#Conformance">invalid
+selector</a>.</p>
+
+<h2><a name=grouping>5. Groups of selectors</a></h2>
+
+<p>When several selectors share the same declarations, they may be
+grouped into a comma-separated list. (A comma is U+002C.)</p>
+
+<div class="example">
+<p>CSS examples:</p>
+<p>In this example, we condense three rules with identical
+declarations into one. Thus,</p>
+<pre>h1 { font-family: sans-serif }
+h2 { font-family: sans-serif }
+h3 { font-family: sans-serif }</pre>
+<p>is equivalent to:</p>
+<pre>h1, h2, h3 { font-family: sans-serif }</pre>
+</div>
+
+<p><strong>Warning</strong>: the equivalence is true in this example
+because all the selectors are valid selectors. If just one of these
+selectors were invalid, the entire group of selectors would be
+invalid. This would invalidate the rule for all three heading
+elements, whereas in the former case only one of the three individual
+heading rules would be invalidated.</p>
+
+
+<h2><a name=simple-selectors>6. Simple selectors</a></h2>
+
+<h3><a name=type-selectors>6.1. Type selector</a></h3>
+
+<p>A <dfn>type selector</dfn> is the name of a document language
+element type. A type selector represents an instance of the element
+type in the document tree.</p>
+
+<div class="example">
+ <p>Example:</p>
+ <p>The following selector represents an <code>h1</code> element in the document tree:</p>
+ <pre>h1</pre>
+</div>
+
+
+<h4><a name=typenmsp>6.1.1. Type selectors and namespaces</a></h4>
+
+<p>Type selectors allow an optional namespace (<a
+href="#refsXMLNAMES">[XMLNAMES]</a>) component. A namespace prefix
+that has been previously declared may be prepended to the element name
+separated by the namespace separator &quot;vertical bar&quot;
+(U+007C, <code>|</code>).</p>
+
+<p>The namespace component may be left empty to indicate that the
+selector is only to represent elements with no declared namespace.</p>
+
+<p>An asterisk may be used for the namespace prefix, indicating that
+the selector represents elements in any namespace (including elements
+with no namespace).</p>
+
+<p>Element type selectors that have no namespace component (no
+namespace separator), represent elements without regard to the
+element's namespace (equivalent to "<code>*|</code>") unless a default
+namespace has been declared. If a default namespace has been declared,
+the selector will represent only elements in the default
+namespace.</p>
+
+<p>A type selector containing a namespace prefix that has not been
+previously declared is an <a href="#Conformance">invalid</a> selector.
+The mechanism for declaring a namespace prefix is left up to the
+language implementing Selectors. In CSS, such a mechanism is defined
+in the General Syntax module.</p>
+
+<p>In a namespace-aware client, element type selectors will only match
+against the <a
+href="http://www.w3.org/TR/REC-xml-names/#NT-LocalPart">local part</a>
+of the element's <a
+href="http://www.w3.org/TR/REC-xml-names/#ns-qualnames">qualified
+name</a>. See <a href="#downlevel">below</a> for notes about matching
+behaviors in down-level clients.</p>
+
+<p>In summary:</p>
+
+<dl>
+  <dt><code>ns|E</code></dt>
+  <dd>elements with name E in namespace ns</dd>
+  <dt><code>*|E</code></dt>
+  <dd>elements with name E in any namespace, including those without any
+  declared namespace</dd>
+  <dt><code>|E</code></dt>
+  <dd>elements with name E without any declared namespace</dd>
+  <dt><code>E</code></dt>
+  <dd>if no default namespace has been specified, this is equivalent to *|E.
+  Otherwise it is equivalent to ns|E where ns is the default namespace.</dd>
+</dl>
+
+<div class="example">
+ <p>CSS examples:</p>
+
+ <pre>@namespace foo url(http://www.example.com);
+ foo|h1 { color: blue }
+ foo|* { color: yellow }
+ |h1 { color: red }
+ *|h1 { color: green }
+ h1 { color: green }</pre>
+
+ <p>The first rule will match only <code>h1</code> elements in the
+ "http://www.example.com" namespace.</p>
+
+ <p>The second rule will match all elements in the
+ "http://www.example.com" namespace.</p>
+
+ <p>The third rule will match only <code>h1</code> elements without
+ any declared namespace.</p>
+
+ <p>The fourth rule will match <code>h1</code> elements in any
+ namespace (including those without any declared namespace).</p>
+
+ <p>The last rule is equivalent to the fourth rule because no default
+ namespace has been defined.</p>
+
+</div>
+
+<h3><a name=universal-selector>6.2. Universal selector</a> </h3>
+
+<p>The <dfn>universal selector</dfn>, written &quot;asterisk&quot;
+(<code>*</code>), represents the qualified name of any element
+type. It represents any single element in the document tree in any
+namespace (including those without any declared namespace) if no
+default namespace has been specified. If a default namespace has been
+specified, see <a href="#univnmsp">Universal selector and
+Namespaces</a> below.</p>
+
+<p>If the universal selector is not the only component of a sequence
+of simple selectors, the <code>*</code> may be omitted.</p>
+
+<div class="example">
+ <p>Examples:</p>
+ <ul>
+  <li><code>*[hreflang|=en]</code> and <code>[hreflang|=en]</code> are equivalent,</li>
+  <li><code>*.warning</code> and <code>.warning</code> are equivalent,</li>
+  <li><code>*#myid</code> and <code>#myid</code> are equivalent.</li>
+ </ul>
+</div>
+
+<p class="note"><strong>Note:</strong> it is recommended that the
+<code>*</code>, representing the universal selector, not be
+omitted.</p>
+
+<h4><a name=univnmsp>6.2.1. Universal selector and namespaces</a></h4>
+
+<p>The universal selector allows an optional namespace component. It
+is used as follows:</p>
+
+<dl>
+ <dt><code>ns|*</code></dt>
+ <dd>all elements in namespace ns</dd>
+ <dt><code>*|*</code></dt>
+ <dd>all elements</dd>
+ <dt><code>|*</code></dt>
+ <dd>all elements without any declared namespace</dd>
+ <dt><code>*</code></dt>
+ <dd>if no default namespace has been specified, this is equivalent to *|*.
+ Otherwise it is equivalent to ns|* where ns is the default namespace.</dd>
+</dl>
+
+<p>A universal selector containing a namespace prefix that has not
+been previously declared is an <a href="#Conformance">invalid</a>
+selector.  The mechanism for declaring a namespace prefix is left up
+to the language implementing Selectors.  In CSS, such a mechanism is
+defined in the General Syntax module.</p>
+
+
+<h3><a name=attribute-selectors>6.3. Attribute selectors</a></h3>
+
+<p>Selectors allow the representation of an element's attributes. When
+a selector is used as an expression to match against an element,
+attribute selectors must be considered to match an element if that
+element has an attribute that matches the attribute represented by the
+attribute selector.</p>
+
+<h4><a name=attribute-representation>6.3.1. Attribute presence and values
+selectors</a></h4>
+
+<p>CSS2 introduced four attribute selectors:</p>
+
+<dl>
+  <dt><code>[att]</code>
+  <dd>Represents an element with the <code>att</code> attribute, whatever the value of
+  the attribute.</dd>
+  <dt><code>[att=val]</code></dt>
+  <dd>Represents an element with the <code>att</code> attribute whose value is exactly
+  "val".</dd>
+  <dt><code>[att~=val]</code></dt>
+  <dd>Represents an element with the <code>att</code> attribute whose value is a <a
+  href="#whitespace">whitespace</a>-separated list of words, one of
+  which is exactly "val". If "val" contains whitespace, it will never
+  represent anything (since the words are <em>separated</em> by
+  spaces).</dd>
+  <dt><code>[att|=val]</code>
+  <dd>Represents an element with the <code>att</code> attribute, its value either
+  being exactly "val" or beginning with "val" immediately followed by
+  "-" (U+002D).  This is primarily intended to allow language subcode
+  matches (e.g., the <code>hreflang</code> attribute on the
+  <code>link</code> element in HTML) as described in RFC 3066 (<a
+  href="#refsRFC3066">[RFC3066]</a>).  For <code>lang</code> (or
+  <code>xml:lang</code>) language subcode matching, please see <a
+  href="#lang-pseudo">the <code>:lang</code> pseudo-class</a>.</dd>
+</dl>
+
+<p>Attribute values must be identifiers or strings. The
+case-sensitivity of attribute names and values in selectors depends on
+the document language.</p>
+
+<div class="example">
+
+  <p>Examples:</p>
+
+  <p>The following attribute selector represents an <code>h1</code>
+  element that carries the <code>title</code> attribute, whatever its
+  value:</p>
+
+  <pre>h1[title]</pre>
+
+  <p>In the following example, the selector represents a
+  <code>span</code> element whose <code>class</code> attribute has
+  exactly the value "example":</p>
+
+  <pre>span[class="example"]</pre>
+
+  <p>Multiple attribute selectors can be used to represent several
+  attributes of an element, or several conditions on the same
+  attribute. Here, the selector represents a <code>span</code> element
+  whose <code>hello</code> attribute has exactly the value "Cleveland"
+  and whose <code>goodbye</code> attribute has exactly the value
+  "Columbus":</p>
+
+  <pre>span[hello="Cleveland"][goodbye="Columbus"]</pre>
+
+  <p>The following selectors illustrate the differences between "="
+  and "~=".  The first selector will represent, for example, the value
+  "copyright copyleft copyeditor" on a <code>rel</code> attribute. The
+  second selector will only represent an <code>a</code> element with
+  an <code>href</code> attribute having the exact value
+  "http://www.w3.org/".</p>
+
+  <pre>a[rel~="copyright"]
+a[href="http://www.w3.org/"]</pre>
+
+  <p>The following selector represents a <code>link</code> element
+  whose <code>hreflang</code> attribute is exactly "fr".</p>
+
+  <pre>link[hreflang=fr]</pre>
+
+  <p>The following selector represents a <code>link</code> element for
+  which the values of the <code>hreflang</code> attribute begins with
+  "en", including "en", "en-US", and "en-cockney":</p>
+
+  <pre>link[hreflang|="en"]</pre>
+
+  <p>Similarly, the following selectors represents a
+  <code>DIALOGUE</code> element whenever it has one of two different
+  values for an attribute <code>character</code>:</p>
+
+  <pre>DIALOGUE[character=romeo]
+DIALOGUE[character=juliet]</pre>
+
+</div>
+
+<h4><a name=attribute-substrings></a>6.3.2. Substring matching attribute
+selectors</h4>
+
+<p>Three additional attribute selectors are provided for matching
+substrings in the value of an attribute:</p>
+
+<dl>
+  <dt><code>[att^=val]</code></dt>
+  <dd>Represents an element with the <code>att</code> attribute whose value begins
+  with the prefix "val".</dd>
+  <dt><code>[att$=val]</code>
+  <dd>Represents an element with the <code>att</code> attribute whose value ends with
+  the suffix "val".</dd>
+  <dt><code>[att*=val]</code>
+  <dd>Represents an element with the <code>att</code> attribute whose value contains
+  at least one instance of the substring "val".</dd>
+</dl>
+
+<p>Attribute values must be identifiers or strings. The
+case-sensitivity of attribute names in selectors depends on the
+document language.</p>
+
+<div class="example">
+ <p>Examples:</p>
+ <p>The following selector represents an HTML <code>object</code>, referencing an
+ image:</p>
+ <pre>object[type^="image/"]</pre>
+ <p>The following selector represents an HTML anchor <code>a</code> with an
+ <code>href</code> attribute whose value ends with ".html".</p>
+ <pre>a[href$=".html"]</pre>
+ <p>The following selector represents an HTML paragraph with a <code>title</code>
+ attribute whose value contains the substring "hello"</p>
+ <pre>p[title*="hello"]</pre>
+</div>
+
+<h4><a name=attrnmsp>6.3.3. Attribute selectors and namespaces</a></h4>
+
+<p>Attribute selectors allow an optional namespace component to the
+attribute name. A namespace prefix that has been previously declared
+may be prepended to the attribute name separated by the namespace
+separator &quot;vertical bar&quot; (<code>|</code>). In keeping with
+the Namespaces in the XML recommendation, default namespaces do not
+apply to attributes, therefore attribute selectors without a namespace
+component apply only to attributes that have no declared namespace
+(equivalent to "<code>|attr</code>"). An asterisk may be used for the
+namespace prefix indicating that the selector is to match all
+attribute names without regard to the attribute's namespace.
+
+<p>An attribute selector with an attribute name containing a namespace
+prefix that has not been previously declared is an <a
+href="#Conformance">invalid</a> selector.  The mechanism for declaring
+a namespace prefix is left up to the language implementing Selectors.
+In CSS, such a mechanism is defined in the General Syntax module.
+
+<div class="example">
+  <p>CSS examples:</p>
+  <pre>@namespace foo "http://www.example.com";
+[foo|att=val] { color: blue }
+[*|att] { color: yellow }
+[|att] { color: green }
+[att] { color: green }</pre>
+
+  <p>The first rule will match only elements with the attribute
+  <code>att</code> in the "http://www.example.com" namespace with the
+  value "val".</p>
+
+  <p>The second rule will match only elements with the attribute
+  <code>att</code> regardless of the namespace of the attribute
+  (including no declared namespace).</p>
+
+  <p>The last two rules are equivalent and will match only elements
+  with the attribute <code>att</code> where the attribute is not
+  declared to be in a namespace.</p>
+
+</div>
+
+<h4><a name=def-values>6.3.4. Default attribute values in DTDs</a></h4>
+
+<p>Attribute selectors represent explicitly set attribute values in
+the document tree. Default attribute values may be defined in a DTD or
+elsewhere, but cannot always be selected by attribute
+selectors. Selectors should be designed so that they work even if the
+default values are not included in the document tree.</p>
+
+<p>More precisely, a UA is <em>not</em> required to read an "external
+subset" of the DTD but <em>is</em> required to look for default
+attribute values in the document's "internal subset." (See <a
+href="#refsXML10">[XML10]</a> for definitions of these subsets.)</p>
+
+<p>A UA that recognizes an XML namespace <a
+href="#refsXMLNAMES">[XMLNAMES]</a> is not required to use its
+knowledge of that namespace to treat default attribute values as if
+they were present in the document. (For example, an XHTML UA is not
+required to use its built-in knowledge of the XHTML DTD.)</p>
+
+<p class="note"><strong>Note:</strong> Typically, implementations
+choose to ignore external subsets.</p>
+
+<div class="example">
+<p>Example:</p>
+
+<p>Consider an element EXAMPLE with an attribute "notation" that has a
+default value of "decimal". The DTD fragment might be</p>
+
+<pre class="dtd-example">&lt;!ATTLIST EXAMPLE notation (decimal,octal) "decimal"></pre>
+
+<p>If the style sheet contains the rules</p>
+
+<pre>EXAMPLE[notation=decimal] { /*... default property settings ...*/ }
+EXAMPLE[notation=octal]   { /*... other settings...*/ }</pre>
+
+<p>the first rule will not match elements whose "notation" attribute
+is set by default, i.e. not set explicitly. To catch all cases, the
+attribute selector for the default value must be dropped:</p>
+
+<pre>EXAMPLE                   { /*... default property settings ...*/ }
+EXAMPLE[notation=octal]   { /*... other settings...*/ }</pre>
+
+<p>Here, because the selector <code>EXAMPLE[notation=octal]</code> is
+more specific than the tag
+selector alone, the style declarations in the second rule will override
+those in the first for elements that have a "notation" attribute value
+of "octal". Care has to be taken that all property declarations that
+are to apply only to the default case are overridden in the non-default
+cases' style rules.</p>
+
+</div>
+
+<h3><a name=class-html>6.4. Class selectors</a></h3>
+
+<p>Working with HTML, authors may use the period (U+002E,
+<code>.</code>) notation as an alternative to the <code>~=</code>
+notation when representing the <code>class</code> attribute. Thus, for
+HTML, <code>div.value</code> and <code>div[class~=value]</code> have
+the same meaning. The attribute value must immediately follow the
+&quot;period&quot; (<code>.</code>).</p>
+
+<p>UAs may apply selectors using the period (.) notation in XML
+documents if the UA has namespace-specific knowledge that allows it to
+determine which attribute is the &quot;class&quot; attribute for the
+respective namespace. One such example of namespace-specific knowledge
+is the prose in the specification for a particular namespace (e.g. SVG
+1.0 <a href="#refsSVG">[SVG]</a> describes the <a
+href="http://www.w3.org/TR/2001/PR-SVG-20010719/styling.html#ClassAttribute">SVG
+&quot;class&quot; attribute</a> and how a UA should interpret it, and
+similarly MathML 1.01 <a href="#refsMATH">[MATH]</a> describes the <a
+href="http://www.w3.org/1999/07/REC-MathML-19990707/chapter2.html#sec2.3.4">MathML
+&quot;class&quot; attribute</a>.)</p>
+
+<div class="example">
+ <p>CSS examples:</p>
+
+ <p>We can assign style information to all elements with
+ <code>class~="pastoral"</code> as follows:</p>
+
+  <pre>*.pastoral { color: green }  /* all elements with class~=pastoral */</pre>
+
+  <p>or just</p>
+
+  <pre>.pastoral { color: green }  /* all elements with class~=pastoral */</pre>
+
+  <p>The following assigns style only to H1 elements with
+  <code>class~="pastoral"</code>:</p>
+
+  <pre>H1.pastoral { color: green }  /* H1 elements with class~=pastoral */</pre>
+
+  <p>Given these rules, the first H1 instance below would not have
+  green text, while the second would:</p>
+
+  <pre>&lt;H1&gt;Not green&lt;/H1&gt;
+&lt;H1 class="pastoral"&gt;Very green&lt;/H1&gt;</pre>
+
+</div>
+
+<p>To represent a subset of "class" values, each value must be preceded
+by a ".", in any order.</P>
+
+<div class="example">
+
+  <p>CSS example:</p>
+
+  <p>The following rule matches any P element whose "class" attribute
+  has been assigned a list of <a
+  href="#whitespace">whitespace</a>-separated values that includes
+  "pastoral" and "marine":</p>
+
+  <pre>p.pastoral.marine { color: green }</pre>
+
+  <p>This rule matches when <code>class="pastoral blue aqua
+  marine"</code> but does not match for <code>class="pastoral
+  blue"</code>.</p>
+
+</div>
+
+<p class="note"><strong>Note:</strong> Because CSS gives considerable
+power to the "class" attribute, authors could conceivably design their
+own "document language" based on elements with almost no associated
+presentation (such as DIV and SPAN in HTML) and assigning style
+information through the "class" attribute.  Authors should avoid this
+practice since the structural elements of a document language often
+have recognized and accepted meanings and author-defined classes may
+not.</p>
+
+<p class="note"><strong>Note:</strong> If an element has multiple
+class attributes, their values must be concatenated with spaces
+between the values before searching for the class. As of this time the
+working group is not aware of any manner in which this situation can
+be reached, however, so this behavior is explicitly non-normative in
+this specification.</p>
+
+<h3><a name=id-selectors>6.5. ID selectors</a></h3>
+
+<p>Document languages may contain attributes that are declared to be
+of type ID. What makes attributes of type ID special is that no two
+such attributes can have the same value in a document, regardless of
+the type of the elements that carry them; whatever the document
+language, an ID typed attribute can be used to uniquely identify its
+element. In HTML all ID attributes are named "id"; XML applications
+may name ID attributes differently, but the same restriction
+applies.</p>
+
+<p>An ID-typed attribute of a document language allows authors to
+assign an identifier to one element instance in the document tree. W3C
+ID selectors represent an element instance based on its identifier. An
+ID selector contains a &quot;number sign&quot; (U+0023,
+<code>#</code>) immediately followed by the ID value, which must be an
+identifier.</p>
+
+<p>Selectors does not specify how a UA knows the ID-typed attribute of
+an element. The UA may, e.g., read a document's DTD, have the
+information hard-coded or ask the user.
+
+<div class="example">
+  <p>Examples:</p>
+  <p>The following ID selector represents an <code>h1</code> element
+  whose ID-typed attribute has the value "chapter1":</p>
+  <pre>h1#chapter1</pre>
+  <p>The following ID selector represents any element whose ID-typed
+  attribute has the value "chapter1":</p>
+  <pre>#chapter1</pre>
+  <p>The following selector represents any element whose ID-typed
+  attribute has the value "z98y".</p>
+  <pre>*#z98y</pre>
+</div>
+
+<p class="note"><strong>Note.</strong> In XML 1.0 <a
+href="#refsXML10">[XML10]</a>, the information about which attribute
+contains an element's IDs is contained in a DTD or a schema. When
+parsing XML, UAs do not always read the DTD, and thus may not know
+what the ID of an element is (though a UA may have namespace-specific
+knowledge that allows it to determine which attribute is the ID
+attribute for that namespace). If a style sheet designer knows or
+suspects that a UA may not know what the ID of an element is, he
+should use normal attribute selectors instead:
+<code>[name=p371]</code> instead of <code>#p371</code>.  Elements in
+XML 1.0 documents without a DTD do not have IDs at all.</p>
+
+<p>If an element has multiple ID attributes, all of them must be
+treated as IDs for that element for the purposes of the ID
+selector. Such a situation could be reached using mixtures of xml:id,
+DOM3 Core, XML DTDs, and namespace-specific knowledge.</p>
+
+<h3><a name=pseudo-classes>6.6. Pseudo-classes</a></h3>
+
+<p>The pseudo-class concept is introduced to permit selection based on
+information that lies outside of the document tree or that cannot be
+expressed using the other simple selectors.</p>
+
+<p>A pseudo-class always consists of a &quot;colon&quot;
+(<code>:</code>) followed by the name of the pseudo-class and
+optionally by a value between parentheses.</p>
+
+<p>Pseudo-classes are allowed in all sequences of simple selectors
+contained in a selector. Pseudo-classes are allowed anywhere in
+sequences of simple selectors, after the leading type selector or
+universal selector (possibly omitted). Pseudo-class names are
+case-insensitive. Some pseudo-classes are mutually exclusive, while
+others can be applied simultaneously to the same
+element. Pseudo-classes may be dynamic, in the sense that an element
+may acquire or lose a pseudo-class while a user interacts with the
+document.</p>
+
+
+<h4><a name=dynamic-pseudos>6.6.1. Dynamic pseudo-classes</a></h4>
+
+<p>Dynamic pseudo-classes classify elements on characteristics other
+than their name, attributes, or content, in principle characteristics
+that cannot be deduced from the document tree.</p>
+
+<p>Dynamic pseudo-classes do not appear in the document source or
+document tree.</p>
+
+
+<h5>The <a name=link>link pseudo-classes: :link and :visited</a></h5>
+
+<p>User agents commonly display unvisited links differently from
+previously visited ones. Selectors
+provides the pseudo-classes <code>:link</code> and
+<code>:visited</code> to distinguish them:</p>
+
+<ul>
+  <li>The <code>:link</code> pseudo-class applies to links that have
+  not yet been visited.</li>
+  <li>The <code>:visited</code> pseudo-class applies once the link has
+  been visited by the user. </li>
+</ul>
+
+<p>After some amount of time, user agents may choose to return a
+visited link to the (unvisited) ':link' state.</p>
+
+<p>The two states are mutually exclusive.</p>
+
+<div class="example">
+
+  <p>Example:</p>
+
+  <p>The following selector represents links carrying class
+  <code>external</code> and already visited:</p>
+
+  <pre>a.external:visited</pre>
+
+</div>
+
+<p class="note"><strong>Note:</strong> It is possible for style sheet
+authors to abuse the :link and :visited pseudo-classes to determine
+which sites a user has visited without the user's consent.
+
+<p>UAs may therefore treat all links as unvisited links, or implement
+other measures to preserve the user's privacy while rendering visited
+and unvisited links differently.</p>
+
+<h5>The <a name=useraction-pseudos>user action pseudo-classes
+:hover, :active, and :focus</a></h5>
+
+<p>Interactive user agents sometimes change the rendering in response
+to user actions. Selectors provides
+three pseudo-classes for the selection of an element the user is
+acting on.</p>
+
+<ul>
+
+  <li>The <code>:hover</code> pseudo-class applies while the user
+  designates an element with a pointing device, but does not activate
+  it. For example, a visual user agent could apply this pseudo-class
+  when the cursor (mouse pointer) hovers over a box generated by the
+  element. User agents not that do not support <a
+  href="http://www.w3.org/TR/REC-CSS2/media.html#interactive-media-group">interactive
+  media</a> do not have to support this pseudo-class. Some conforming
+  user agents that support <a
+  href="http://www.w3.org/TR/REC-CSS2/media.html#interactive-media-group">interactive
+  media</a> may not be able to support this pseudo-class (e.g., a pen
+  device that does not detect hovering).</li>
+
+  <li>The <code>:active</code> pseudo-class applies while an element
+  is being activated by the user. For example, between the times the
+  user presses the mouse button and releases it.</li>
+
+  <li>The <code>:focus</code> pseudo-class applies while an element
+  has the focus (accepts keyboard or mouse events, or other forms of
+  input). </li>
+
+</ul>
+
+<p>There may be document language or implementation specific limits on
+which elements can become <code>:active</code> or acquire
+<code>:focus</code>.</p>
+
+<p>These pseudo-classes are not mutually exclusive. An element may
+match several pseudo-classes at the same time.</p>
+
+<p>Selectors doesn't define if the parent of an element that is
+':active' or ':hover' is also in that state.</p>
+
+<div class="example">
+  <p>Examples:</p>
+  <pre>a:link    /* unvisited links */
+a:visited /* visited links */
+a:hover   /* user hovers */
+a:active  /* active links */</pre>
+  <p>An example of combining dynamic pseudo-classes:</p>
+  <pre>a:focus
+a:focus:hover</pre>
+  <p>The last selector matches <code>a</code> elements that are in
+  the pseudo-class :focus and in the pseudo-class :hover.</p>
+</div>
+
+<p class="note"><strong>Note:</strong> An element can be both ':visited'
+and ':active' (or ':link' and ':active').</p>
+
+<h4><a name=target-pseudo>6.6.2. The target pseudo-class :target</a></h4>
+
+<p>Some URIs refer to a location within a resource. This kind of URI
+ends with a &quot;number sign&quot; (#) followed by an anchor
+identifier (called the fragment identifier).</p>
+
+<p>URIs with fragment identifiers link to a certain element within the
+document, known as the target element. For instance, here is a URI
+pointing to an anchor named <code>section_2</code> in an HTML
+document:</p>
+
+<pre>http://example.com/html/top.html#section_2</pre>
+
+<p>A target element can be represented by the <code>:target</code>
+pseudo-class. If the document's URI has no fragment identifier, then
+the document has no target element.</p>
+
+<div class="example">
+ <p>Example:</p>
+ <pre>p.note:target</pre>
+ <p>This selector represents a <code>p</code> element of class
+ <code>note</code> that is the target element of the referring
+ URI.</p>
+</div>
+
+<div class="example">
+ <p>CSS example:</p>
+ <p>Here, the <code>:target</code> pseudo-class is used to make the
+ target element red and place an image before it, if there is one:</p>
+ <pre>*:target { color : red }
+*:target::before { content : url(target.png) }</pre>
+</div>
+
+<h4><a name=lang-pseudo>6.6.3. The language pseudo-class :lang</a></h4>
+
+<p>If the document language specifies how the human language of an
+element is determined, it is possible to write selectors that
+represent an element based on its language. For example, in HTML <a
+href="#refsHTML4">[HTML4]</a>, the language is determined by a
+combination of the <code>lang</code> attribute, the <code>meta</code>
+element, and possibly by information from the protocol (such as HTTP
+headers). XML uses an attribute called <code>xml:lang</code>, and
+there may be other document language-specific methods for determining
+the language.</p>
+
+<p>The pseudo-class <code>:lang(C)</code> represents an element that
+is in language C. Whether an element is represented by a
+<code>:lang()</code> selector is based solely on the identifier C
+being either equal to, or a hyphen-separated substring of, the
+element's language value, in the same way as if performed by the <a
+href="#attribute-representation">'|='</a> operator in attribute
+selectors. The identifier C does not have to be a valid language
+name.</p>
+
+<p>C must not be empty. (If it is, the selector is invalid.)</p>
+
+<p class="note"><strong>Note:</strong> It is recommended that
+documents and protocols indicate language using codes from RFC 3066 <a
+href="#refsRFC3066">[RFC3066]</a> or its successor, and by means of
+"xml:lang" attributes in the case of XML-based documents <a
+href="#refsXML10">[XML10]</a>. See <a
+href="http://www.w3.org/International/questions/qa-lang-2or3.html">
+"FAQ: Two-letter or three-letter language codes."</a></p>
+
+<div class="example">
+  <p>Examples:</p>
+  <p>The two following selectors represent an HTML document that is in
+  Belgian, French, or German. The two next selectors represent
+  <code>q</code> quotations in an arbitrary element in Belgian, French,
+  or German.</p>
+  <pre>html:lang(fr-be)
+html:lang(de)
+:lang(fr-be) &gt; q
+:lang(de) &gt; q</pre>
+</div>
+
+<h4><a name=UIstates>6.6.4. The UI element states pseudo-classes</a></h4>
+
+<h5><a name=enableddisabled>The :enabled and :disabled pseudo-classes</a></h5>
+
+<p>The <code>:enabled</code> pseudo-class allows authors to customize
+the look of user interface elements that are enabled &mdash; which the
+user can select or activate in some fashion (e.g. clicking on a button
+with a mouse).  There is a need for such a pseudo-class because there
+is no way to programmatically specify the default appearance of say,
+an enabled <code>input</code> element without also specifying what it
+would look like when it was disabled.</p>
+
+<p>Similar to <code>:enabled</code>, <code>:disabled</code> allows the
+author to specify precisely how a disabled or inactive user interface
+element should look.</p>
+
+<p>Most elements will be neither enabled nor disabled.  An element is
+enabled if the user can either activate it or transfer the focus to
+it. An element is disabled if it could be enabled, but the user cannot
+presently activate it or transfer focus to it.</p>
+
+
+<h5><a name=checked>The :checked pseudo-class</a></h5>
+
+<p>Radio and checkbox elements can be toggled by the user. Some menu
+items are "checked" when the user selects them. When such elements are
+toggled "on" the <code>:checked</code> pseudo-class applies. The
+<code>:checked</code> pseudo-class initially applies to such elements
+that have the HTML4 <code>selected</code> and <code>checked</code>
+attributes as described in <a
+href="http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.2.1">Section
+17.2.1 of HTML4</a>, but of course the user can toggle "off" such
+elements in which case the <code>:checked</code> pseudo-class would no
+longer apply. While the <code>:checked</code> pseudo-class is dynamic
+in nature, and is altered by user action, since it can also be based
+on the presence of the semantic HTML4 <code>selected</code> and
+<code>checked</code> attributes, it applies to all media.
+
+
+<h5><a name=indeterminate>The :indeterminate pseudo-class</a></h5>
+
+<div class="note">
+
+<p>Radio and checkbox elements can be toggled by the user, but are
+sometimes in an indeterminate state, neither checked nor unchecked.
+This can be due to an element attribute, or DOM manipulation.</p>
+
+<p>A future version of this specification may introduce an 
+<code>:indeterminate</code> pseudo-class that applies to such elements.
+<!--While the <code>:indeterminate</code> pseudo-class is dynamic in
+nature, and is altered by user action, since it can also be based on
+the presence of an element attribute, it applies to all media.</p>
+
+<p>Components of a radio-group initialized with no pre-selected choice
+are an example of :indeterminate state.--></p>
+
+</div>
+
+
+<h4><a name=structural-pseudos>6.6.5. Structural pseudo-classes</a></h4>
+
+<p>Selectors introduces the concept of <dfn>structural
+pseudo-classes</dfn> to permit selection based on extra information that lies in
+the document tree but cannot be represented by other simple selectors or
+combinators. 
+
+<p>Note that standalone pieces of PCDATA (text nodes in the DOM) are
+not counted when calculating the position of an element in the list of
+children of its parent. When calculating the position of an element in
+the list of children of its parent, the index numbering starts at 1.
+
+
+<h5><a name=root-pseudo>:root pseudo-class</a></h5>
+
+<p>The <code>:root</code> pseudo-class represents an element that is
+the root of the document. In HTML 4, this is always the
+<code>HTML</code> element.
+
+
+<h5><a name=nth-child-pseudo>:nth-child() pseudo-class</a></h5>
+
+<p>The
+<code>:nth-child(<var>a</var><code>n</code>+<var>b</var>)</code>
+pseudo-class notation represents an element that has
+<var>a</var><code>n</code>+<var>b</var>-1 siblings
+<strong>before</strong> it in the document tree, for a given positive
+integer or zero value of <code>n</code>, and has a parent element. In
+other words, this matches the <var>b</var>th child of an element after
+all the children have been split into groups of <var>a</var> elements
+each. For example, this allows the selectors to address every other
+row in a table, and could be used to alternate the color
+of paragraph text in a cycle of four. The <var>a</var> and
+<var>b</var> values must be zero, negative integers or positive
+integers. The index of the first child of an element is 1.
+
+<p>In addition to this, <code>:nth-child()</code> can take
+'<code>odd</code>' and '<code>even</code>' as arguments instead.
+'<code>odd</code>' has the same signification as <code>2n+1</code>,
+and '<code>even</code>' has the same signification as <code>2n</code>.
+
+
+<div class="example">
+<p>Examples:</p>
+<pre>tr:nth-child(2n+1) /* represents every odd row of an HTML table */
+tr:nth-child(odd)  /* same */
+tr:nth-child(2n)   /* represents every even row of an HTML table */
+tr:nth-child(even) /* same */
+
+/* Alternate paragraph colours in CSS */
+p:nth-child(4n+1) { color: navy; }
+p:nth-child(4n+2) { color: green; }
+p:nth-child(4n+3) { color: maroon; }
+p:nth-child(4n+4) { color: purple; }</pre>
+</div>
+
+<p>When <var>a</var>=0, no repeating is used, so for example
+<code>:nth-child(0n+5)</code> matches only the fifth child. When
+<var>a</var>=0, the <var>a</var><code>n</code> part need not be
+included, so the syntax simplifies to
+<code>:nth-child(<var>b</var>)</code> and the last example simplifies
+to <code>:nth-child(5)</code>.
+
+<div class="example">
+<p>Examples:</p>
+<pre>foo:nth-child(0n+1)   /* represents an element foo, first child of its parent element */
+foo:nth-child(1)      /* same */</pre>
+</div>
+
+<p>When <var>a</var>=1, the number may be omitted from the rule.
+
+<div class="example">
+<p>Examples:</p>
+<p>The following selectors are therefore equivalent:</p>
+<pre>bar:nth-child(1n+0)   /* represents all bar elements, specificity (0,1,1) */
+bar:nth-child(n+0)    /* same */
+bar:nth-child(n)      /* same */
+bar                   /* same but lower specificity (0,0,1) */</pre>
+</div>
+
+<p>If <var>b</var>=0, then every <var>a</var>th element is picked. In
+such a case, the <var>b</var> part may be omitted.
+
+<div class="example">
+<p>Examples:</p>
+<pre>tr:nth-child(2n+0) /* represents every even row of an HTML table */
+tr:nth-child(2n) /* same */</pre>
+</div>
+
+<p>If both <var>a</var> and <var>b</var> are equal to zero, the
+pseudo-class represents no element in the document tree.</p>
+
+<p>The value <var>a</var> can be negative, but only the positive
+values of <var>a</var><code>n</code>+<var>b</var>, for
+<code>n</code>&ge;0, may represent an element in the document
+tree.</p>
+
+<div class="example">
+<p>Example:</p>
+<pre>html|tr:nth-child(-n+6)  /* represents the 6 first rows of XHTML tables */</pre>
+</div>
+
+<p>When the value <var>b</var> is negative, the "+" character in the
+expression must be removed (it is effectively replaced by the "-"
+character indicating the negative value of <var>b</var>).</p>
+
+<div class="example">
+<p>Examples:</p>
+<pre>:nth-child(10n-1)  /* represents the 9th, 19th, 29th, etc, element */
+:nth-child(10n+9)  /* Same */
+:nth-child(10n+-1) /* Syntactically invalid, and would be ignored */</pre>
+</div>
+
+
+<h5><a name=nth-last-child-pseudo>:nth-last-child() pseudo-class</a></h5>
+
+<p>The <code>:nth-last-child(<var>a</var>n+<var>b</var>)</code>
+pseudo-class notation represents an element that has
+<var>a</var><code>n</code>+<var>b</var>-1 siblings
+<strong>after</strong> it in the document tree, for a given positive
+integer or zero value of <code>n</code>, and has a parent element. See
+<code>:nth-child()</code> pseudo-class for the syntax of its argument.
+It also accepts the '<code>even</code>' and '<code>odd</code>' values
+as arguments.
+
+
+<div class="example">
+<p>Examples:</p>
+<pre>tr:nth-last-child(-n+2)    /* represents the two last rows of an HTML table */
+
+foo:nth-last-child(odd)    /* represents all odd foo elements in their parent element,
+                              counting from the last one */</pre>
+</div>
+
+
+<h5><a name=nth-of-type-pseudo>:nth-of-type() pseudo-class</a></h5>
+
+<p>The <code>:nth-of-type(<var>a</var>n+<var>b</var>)</code>
+pseudo-class notation represents an element that has
+<var>a</var><code>n</code>+<var>b</var>-1 siblings with the same
+element name <strong>before</strong> it in the document tree, for a
+given zero or positive integer value of <code>n</code>, and has a
+parent element. In other words, this matches the <var>b</var>th child
+of that type after all the children of that type have been split into
+groups of a elements each. See <code>:nth-child()</code> pseudo-class
+for the syntax of its argument. It also accepts the
+'<code>even</code>' and '<code>odd</code>' values.
+
+
+<div class="example">
+<p>CSS example:</p>
+<p>This allows an author to alternate the position of floated images:</p>
+<pre>img:nth-of-type(2n+1) { float: right; }
+img:nth-of-type(2n) { float: left; }</pre>
+</div>
+
+
+<h5><a name=nth-last-of-type-pseudo>:nth-last-of-type() pseudo-class</a></h5>
+
+<p>The <code>:nth-last-of-type(<var>a</var>n+<var>b</var>)</code>
+pseudo-class notation represents an element that has
+<var>a</var><code>n</code>+<var>b</var>-1 siblings with the same
+element name <strong>after</strong> it in the document tree, for a
+given zero or positive integer value of <code>n</code>, and has a
+parent element. See <code>:nth-child()</code> pseudo-class for the
+syntax of its argument. It also accepts the '<code>even</code>' and '<code>odd</code>' values.
+
+
+<div class="example">
+ <p>Example:</p>
+ <p>To represent all <code>h2</code> children of an XHTML
+ <code>body</code> except the first and last, one could use the
+ following selector:</p>
+ <pre>body &gt; h2:nth-of-type(n+2):nth-last-of-type(n+2)</pre>
+ <p>In this case, one could also use <code>:not()</code>, although the
+ selector ends up being just as long:</p>
+ <pre>body &gt; h2:not(:first-of-type):not(:last-of-type)</pre>
+</div>
+
+
+<h5><a name=first-child-pseudo>:first-child pseudo-class</a></h5>
+
+<p>Same as <code>:nth-child(1)</code>. The <code>:first-child</code> pseudo-class
+represents an element that is the first child of some other element.
+
+
+<div class="example">
+  <p>Examples:</p>
+  <p>The following selector represents a <code>p</code> element that is
+  the first child of a <code>div</code> element:</p>
+  <pre>div &gt; p:first-child</pre>
+  <p>This selector can represent the <code>p</code> inside the
+  <code>div</code> of the following fragment:</p>
+  <pre>&lt;p&gt; The last P before the note.&lt;/p&gt;
+&lt;div class="note"&gt;
+   &lt;p&gt; The first P inside the note.&lt;/p&gt;
+&lt;/div&gt;</pre>but cannot represent the second <code>p</code> in the following
+fragment: 
+  <pre>&lt;p&gt; The last P before the note.&lt;/p&gt;
+&lt;div class="note"&gt;
+   &lt;h2&gt; Note &lt;/h2&gt;
+   &lt;p&gt; The first P inside the note.&lt;/p&gt;
+&lt;/div&gt;</pre>
+  <p>The following two selectors are usually equivalent:</p>
+  <pre>* &gt; a:first-child /* a is first child of any element */
+a:first-child /* Same (assuming a is not the root element) */</pre>
+</div>
+
+<h5><a name=last-child-pseudo>:last-child pseudo-class</a></h5>
+
+<p>Same as <code>:nth-last-child(1)</code>. The <code>:last-child</code> pseudo-class
+represents an element that is the last child of some other element. 
+
+<div class="example">
+ <p>Example:</p>
+ <p>The following selector represents a list item <code>li</code> that
+ is the last child of an ordered list <code>ol</code>.
+ <pre>ol &gt; li:last-child</pre>
+</div>
+
+<h5><a name=first-of-type-pseudo>:first-of-type pseudo-class</a></h5>
+
+<p>Same as <code>:nth-of-type(1)</code>. The <code>:first-of-type</code> pseudo-class
+represents an element that is the first sibling of its type in the list of
+children of its parent element. 
+
+<div class="example">
+<p>Example:</p>
+<p>The following selector represents a definition title
+<code>dt</code> inside a definition list <code>dl</code>, this
+<code>dt</code> being the first of its type in the list of children of
+its parent element.</p>
+<pre>dl dt:first-of-type</pre>
+<p>It is a valid description for the first two <code>dt</code>
+elements in the following example but not for the third one:</p>
+<pre>&lt;dl&gt;
+ &lt;dt&gt;gigogne&lt;/dt&gt;
+ &lt;dd&gt;
+  &lt;dl&gt;
+   &lt;dt&gt;fus&eacute;e&lt;/dt&gt;
+   &lt;dd&gt;multistage rocket&lt;/dd&gt;
+   &lt;dt&gt;table&lt;/dt&gt;
+   &lt;dd&gt;nest of tables&lt;/dd&gt;
+  &lt;/dl&gt;
+ &lt;/dd&gt;
+&lt;/dl&gt;</pre>
+</div>
+
+<h5><a name=last-of-type-pseudo>:last-of-type pseudo-class</a></h5>
+
+<p>Same as <code>:nth-last-of-type(1)</code>. The
+<code>:last-of-type</code> pseudo-class represents an element that is
+the last sibling of its type in the list of children of its parent
+element.</p>
+
+<div class="example">
+ <p>Example:</p>
+ <p>The following selector represents the last data cell
+ <code>td</code> of a table row.</p>
+ <pre>tr &gt; td:last-of-type</pre>
+</div>
+
+<h5><a name=only-child-pseudo>:only-child pseudo-class</a></h5>
+
+<p>Represents an element that has a parent element and whose parent
+element has no other element children. Same as
+<code>:first-child:last-child</code> or
+<code>:nth-child(1):nth-last-child(1)</code>, but with a lower
+specificity.</p>
+
+<h5><a name=only-of-type-pseudo>:only-of-type pseudo-class</a></h5>
+
+<p>Represents an element that has a parent element and whose parent
+element has no other element children with the same element name. Same
+as <code>:first-of-type:last-of-type</code> or
+<code>:nth-of-type(1):nth-last-of-type(1)</code>, but with a lower
+specificity.</p>
+
+
+<h5><a name=empty-pseudo></a>:empty pseudo-class</h5>
+
+<p>The <code>:empty</code> pseudo-class represents an element that has
+no children at all. In terms of the DOM, only element nodes and text
+nodes (including CDATA nodes and entity references) whose data has a
+non-zero length must be considered as affecting emptiness; comments,
+PIs, and other nodes must not affect whether an element is considered
+empty or not.</p>
+
+<div class="example">
+ <p>Examples:</p>
+ <p><code>p:empty</code> is a valid representation of the following fragment:</p>
+ <pre>&lt;p&gt;&lt;/p&gt;</pre>
+ <p><code>foo:empty</code> is not a valid representation for the
+ following fragments:</p>
+ <pre>&lt;foo&gt;bar&lt;/foo&gt;</pre>
+ <pre>&lt;foo&gt;&lt;bar&gt;bla&lt;/bar&gt;&lt;/foo&gt;</pre>
+ <pre>&lt;foo&gt;this is not &lt;bar&gt;:empty&lt;/bar&gt;&lt;/foo&gt;</pre>
+</div>
+
+<h4><a name=content-selectors>6.6.6. Blank</a></h4> <!-- It's the Return of Appendix H!!! Run away! -->
+
+<p>This section intentionally left blank.</p>
+<!-- (used to be :contains()) -->
+
+<h4><a name=negation></a>6.6.7. The negation pseudo-class</h4>
+
+<p>The negation pseudo-class, <code>:not(<var>X</var>)</code>, is a
+functional notation taking a <a href="#simple-selectors-dfn">simple
+selector</a> (excluding the negation pseudo-class itself and
+pseudo-elements) as an argument. It represents an element that is not
+represented by the argument.
+
+<!-- pseudo-elements are not simple selectors, so the above paragraph
+may be a bit confusing -->
+
+<div class="example">
+  <p>Examples:</p>
+  <p>The following CSS selector matches all <code>button</code>
+  elements in an HTML document that are not disabled.</p>
+  <pre>button:not([DISABLED])</pre>
+  <p>The following selector represents all but <code>FOO</code>
+  elements.</p>
+  <pre>*:not(FOO)</pre>
+  <p>The following group of selectors represents all HTML elements
+  except links.</p>
+  <pre>html|*:not(:link):not(:visited)</pre>
+</div>
+
+<p>Default namespace declarations do not affect the argument of the
+negation pseudo-class unless the argument is a universal selector or a
+type selector.</p>
+
+<div class="example">
+  <p>Examples:</p>
+  <p>Assuming that the default namespace is bound to
+  "http://example.com/", the following selector represents all
+  elements that are not in that namespace:</p>
+  <pre>*|*:not(*)</pre>
+  <p>The following CSS selector matches any element being hovered,
+  regardless of its namespace. In particular, it is not limited to
+  only matching elements in the default namespace that are not being
+  hovered, and elements not in the default namespace don't match the
+  rule when they <em>are</em> being hovered.</p>
+  <pre>*|*:not(:hover)</pre>
+</div>
+
+<p class="note"><strong>Note</strong>: the :not() pseudo allows
+useless selectors to be written.  For instance <code>:not(*|*)</code>,
+which represents no element at all, or <code>foo:not(bar)</code>,
+which is equivalent to <code>foo</code> but with a higher
+specificity.</p>
+
+<h3><a name=pseudo-elements>7. Pseudo-elements</a></h3>
+
+<p>Pseudo-elements create abstractions about the document tree beyond
+those specified by the document language. For instance, document
+languages do not offer mechanisms to access the first letter or first
+line of an element's content. Pseudo-elements allow designers to refer
+to this otherwise inaccessible information. Pseudo-elements may also
+provide designers a way to refer to content that does not exist in the
+source document (e.g., the <code>::before</code> and
+<code>::after</code> pseudo-elements give access to generated
+content).</p>
+
+<p>A pseudo-element is made of two colons (<code>::</code>) followed
+by the name of the pseudo-element.</p>
+
+<p>This <code>::</code> notation is introduced by the current document
+in order to establish a discrimination between pseudo-classes and
+pseudo-elements.  For compatibility with existing style sheets, user
+agents must also accept the previous one-colon notation for
+pseudo-elements introduced in CSS levels 1 and 2 (namely,
+<code>:first-line</code>, <code>:first-letter</code>,
+<code>:before</code> and <code>:after</code>). This compatibility is
+not allowed for the new pseudo-elements introduced in CSS level 3.</p>
+
+<p>Only one pseudo-element may appear per selector, and if present it
+must appear after the sequence of simple selectors that represents the
+<a href="#subject">subjects</a> of the selector. <span class="note">A
+future version of this specification may allow multiple
+pesudo-elements per selector.</span></p>
+
+<h4><a name=first-line>7.1. The ::first-line pseudo-element</a></h4>
+
+<p>The <code>::first-line</code> pseudo-element describes the contents
+of the first formatted line of an element.
+
+<div class="example">
+<p>CSS example:</p>
+<pre>p::first-line { text-transform: uppercase }</pre>
+<p>The above rule means "change the letters of the first line of every
+paragraph to uppercase".</p>
+</div>
+
+<p>The selector <code>p::first-line</code> does not match any real
+HTML element. It does match a pseudo-element that conforming user
+agents will insert at the beginning of every paragraph.</p>
+
+<p>Note that the length of the first line depends on a number of
+factors, including the width of the page, the font size, etc.  Thus,
+an ordinary HTML paragraph such as:</p>
+
+<pre>
+&lt;P&gt;This is a somewhat long HTML 
+paragraph that will be broken into several 
+lines. The first line will be identified
+by a fictional tag sequence. The other lines 
+will be treated as ordinary lines in the 
+paragraph.&lt;/P&gt;
+</pre>
+
+<p>the lines of which happen to be broken as follows:
+
+<pre>
+THIS IS A SOMEWHAT LONG HTML PARAGRAPH THAT
+will be broken into several lines. The first
+line will be identified by a fictional tag 
+sequence. The other lines will be treated as 
+ordinary lines in the paragraph.
+</pre>
+
+<p>This paragraph might be "rewritten" by user agents to include the
+<em>fictional tag sequence</em> for <code>::first-line</code>. This
+fictional tag sequence helps to show how properties are inherited.</p>
+
+<pre>
+&lt;P&gt;<b>&lt;P::first-line&gt;</b> This is a somewhat long HTML 
+paragraph that <b>&lt;/P::first-line&gt;</b> will be broken into several
+lines. The first line will be identified 
+by a fictional tag sequence. The other lines 
+will be treated as ordinary lines in the 
+paragraph.&lt;/P&gt;
+</pre>
+
+<p>If a pseudo-element breaks up a real element, the desired effect
+can often be described by a fictional tag sequence that closes and
+then re-opens the element. Thus, if we mark up the previous paragraph
+with a <code>span</code> element:</p>
+
+<pre>
+&lt;P&gt;<b>&lt;SPAN class="test"&gt;</b> This is a somewhat long HTML
+paragraph that will be broken into several
+lines.<b>&lt;/SPAN&gt;</b> The first line will be identified
+by a fictional tag sequence. The other lines 
+will be treated as ordinary lines in the 
+paragraph.&lt;/P&gt;
+</pre>
+
+<p>the user agent could simulate start and end tags for
+<code>span</code> when inserting the fictional tag sequence for
+<code>::first-line</code>.
+
+<pre>
+&lt;P&gt;&lt;P::first-line&gt;<b>&lt;SPAN class="test"&gt;</b> This is a
+somewhat long HTML
+paragraph that will <b>&lt;/SPAN&gt;</b>&lt;/P::first-line&gt;<b>&lt;SPAN class="test"&gt;</b> be
+broken into several
+lines.<b>&lt;/SPAN&gt;</b> The first line will be identified
+by a fictional tag sequence. The other lines
+will be treated as ordinary lines in the 
+paragraph.&lt;/P&gt;
+</pre>
+
+<p>In CSS, the <code>::first-line</code> pseudo-element can only be
+attached to a block-level element, an inline-block, a table-caption,
+or a table-cell.</p>
+
+<p><a name="first-formatted-line"></a>The "first formatted line" of an
+element may occur inside a
+block-level descendant in the same flow (i.e., a block-level
+descendant that is not positioned and not a float). E.g., the first
+line of the <code>div</code> in <code>&lt;DIV>&lt;P>This
+line...&lt;/P>&lt/DIV></code> is the first line of the <code>p</code> (assuming
+that both <code>p</code> and <code>div</code> are block-level).
+
+<p>The first line of a table-cell or inline-block cannot be the first
+formatted line of an ancestor element. Thus, in <code>&lt;DIV&gt;&lt;P
+STYLE="display: inline-block">Hello&lt;BR&gt;Goodbye&lt;/P&gt;
+etcetera&lt;/DIV&gt;</code> the first formatted line of the
+<code>div</code> is not the line "Hello".
+
+<p class="note">Note that the first line of the <code>p</code> in this
+fragment: <code>&lt;p&gt&lt;br&gt;First...</code> doesn't contain any
+letters (assuming the default style for <code>br</code> in HTML
+4). The word "First" is not on the first formatted line.
+
+<p>A UA should act as if the fictional start tags of the
+<code>::first-line</code> pseudo-elements were nested just inside the
+innermost enclosing block-level element. (Since CSS1 and CSS2 were
+silent on this case, authors should not rely on this behavior.) Here
+is an example. The fictional tag sequence for</p>
+
+<pre>
+&lt;DIV>
+  &lt;P>First paragraph&lt;/P>
+  &lt;P>Second paragraph&lt;/P>
+&lt;/DIV>
+</pre>
+
+<p>is</p>
+
+<pre>
+&lt;DIV>
+  &lt;P>&lt;DIV::first-line>&lt;P::first-line>First paragraph&lt;/P::first-line>&lt;/DIV::first-line>&lt;/P>
+  &lt;P>&lt;P::first-line>Second paragraph&lt;/P::first-line>&lt;/P>
+&lt;/DIV>
+</pre>
+
+<p>The <code>::first-line</code> pseudo-element is similar to an
+inline-level element, but with certain restrictions. In CSS, the
+following properties apply to a <code>::first-line</code>
+pseudo-element: font properties, color property, background
+properties, 'word-spacing', 'letter-spacing', 'text-decoration',
+'vertical-align', 'text-transform', 'line-height'. UAs may apply other
+properties as well.</p>
+
+
+<h4><a name=first-letter>7.2. The ::first-letter pseudo-element</a></h4>
+
+<p>The <code>::first-letter</code> pseudo-element represents the first
+letter of the first line of a block, if it is not preceded by any
+other content (such as images or inline tables) on its line. The
+::first-letter pseudo-element may be used for "initial caps" and "drop
+caps", which are common typographical effects. This type of initial
+letter is similar to an inline-level element if its 'float' property
+is 'none'; otherwise, it is similar to a floated element.</p>
+
+<p>In CSS, these are the properties that apply to <code>::first-letter</code>
+pseudo-elements: font properties, 'text-decoration', 'text-transform',
+'letter-spacing', 'word-spacing' (when appropriate), 'line-height',
+'float', 'vertical-align' (only if 'float' is 'none'), margin
+properties, padding properties, border properties, color property,
+background properties.  UAs may apply other properties as well.  To
+allow UAs to render a typographically correct drop cap or initial cap,
+the UA may choose a line-height, width and height based on the shape
+of the letter, unlike for normal elements.</p>
+
+<div class="example">
+<p>Example:</p>
+<p>This example shows a possible rendering of an initial cap. Note
+that the 'line-height' that is inherited by the <code>::first-letter</code>
+pseudo-element is 1.1, but the UA in this example has computed the
+height of the first letter differently, so that it doesn't cause any
+unnecessary space between the first two lines. Also note that the
+fictional start tag of the first letter is inside the <span>span</span>, and thus
+the font weight of the first letter is normal, not bold as the <span>span</span>:
+<pre>
+p { line-height: 1.1 }
+p::first-letter { font-size: 3em; font-weight: normal }
+span { font-weight: bold }
+...
+&lt;p>&lt;span>Het hemelsche&lt;/span> gerecht heeft zich ten lange lesten&lt;br>
+Erbarremt over my en mijn benaeuwde vesten&lt;br>
+En arme burgery, en op mijn volcx gebed&lt;br>
+En dagelix geschrey de bange stad ontzet.
+</pre>
+<div class="figure">
+<p><img src="initial-cap.png" alt="Image illustrating the ::first-letter pseudo-element">
+</div>
+</div>
+
+<div class="example">
+<p>The following CSS will make a drop cap initial letter span about two lines:</p>
+
+<pre>
+&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"&gt;
+&lt;HTML&gt;
+ &lt;HEAD&gt;
+  &lt;TITLE&gt;Drop cap initial letter&lt;/TITLE&gt;
+  &lt;STYLE type="text/css"&gt;
+   P               { font-size: 12pt; line-height: 1.2 }
+   P::first-letter { font-size: 200%; font-weight: bold; float: left }
+   SPAN            { text-transform: uppercase }
+  &lt;/STYLE&gt;
+ &lt;/HEAD&gt;
+ &lt;BODY&gt;
+  &lt;P&gt;&lt;SPAN&gt;The first&lt;/SPAN&gt; few words of an article
+    in The Economist.&lt;/P&gt;
+ &lt;/BODY&gt;
+&lt;/HTML&gt;
+</pre>
+
+<p>This example might be formatted as follows:</p>
+
+<div class="figure">
+<P><img src="first-letter.gif" alt="Image illustrating the combined effect of the ::first-letter and ::first-line pseudo-elements"></p>
+</div>
+
+<p>The <span class="index-inst" title="fictional tag
+sequence">fictional tag sequence</span> is:</p>
+
+<pre>
+&lt;P&gt;
+&lt;SPAN&gt;
+&lt;P::first-letter&gt;
+T
+&lt;/P::first-letter&gt;he first
+&lt;/SPAN&gt; 
+few words of an article in the Economist.
+&lt;/P&gt;
+</pre>
+
+<p>Note that the <code>::first-letter</code> pseudo-element tags abut
+the content (i.e., the initial character), while the ::first-line
+pseudo-element start tag is inserted right after the start tag of the
+block element.</p> </div>
+
+<p>In order to achieve traditional drop caps formatting, user agents
+may approximate font sizes, for example to align baselines. Also, the
+glyph outline may be taken into account when formatting.</p>
+
+<p>Punctuation (i.e, characters defined in Unicode in the "open" (Ps),
+"close" (Pe), "initial" (Pi). "final" (Pf) and "other" (Po)
+punctuation classes), that precedes or follows the first letter should
+be included. <a href="#refsUNICODE">[UNICODE]</a></p>
+
+<div class="figure">
+<P><img src="first-letter2.gif" alt="Quotes that precede the
+first letter should be included."></p>
+</div>
+
+<p>The <code>::first-letter</code> also applies if the first letter is
+in fact a digit, e.g., the "6" in "67 million dollars is a lot of
+money."</p>
+
+<p>In CSS, the <code>::first-letter</code> pseudo-element applies to
+block, list-item, table-cell, table-caption, and inline-block
+elements. <span class="note">A future version of this specification
+may allow this pesudo-element to apply to more element
+types.</span></p>
+
+<p>The <code>::first-letter</code> pseudo-element can be used with all
+such elements that contain text, or that have a descendant in the same
+flow that contains text. A UA should act as if the fictional start tag
+of the ::first-letter pseudo-element is just before the first text of
+the element, even if that first text is in a descendant.</p>
+
+<div class="example">
+<p>Example:</p>
+<p>The fictional tag sequence for this HTMLfragment:
+<pre>&lt;div>
+&lt;p>The first text.</pre>
+<p>is:
+<pre>&lt;div>
+&lt;p>&lt;div::first-letter>&lt;p::first-letter>T&lt;/...>&lt;/...>he first text.</pre>
+</div>
+
+<p>The first letter of a table-cell or inline-block cannot be the
+first letter of an ancestor element. Thus, in <code>&lt;DIV&gt;&lt;P
+STYLE="display: inline-block">Hello&lt;BR&gt;Goodbye&lt;/P&gt;
+etcetera&lt;/DIV&gt;</code> the first letter of the <code>div</code> is not the
+letter "H". In fact, the <code>div</code> doesn't have a first letter.
+
+<p>The first letter must occur on the <a
+href="#first-formatted-line">first formatted line.</a> For example, in
+this fragment: <code>&lt;p&gt&lt;br&gt;First...</code> the first line
+doesn't contain any letters and <code>::first-letter</code> doesn't
+match anything (assuming the default style for <code>br</code> in HTML
+4). In particular, it does not match the "F" of "First."
+
+<p>In CSS, if an element is a list item ('display: list-item'), the
+<code>::first-letter</code> applies to the first letter in the
+principal box after the marker. UAs may ignore
+<code>::first-letter</code> on list items with 'list-style-position:
+inside'. If an element has <code>::before</code> or
+<code>::after</code> content, the <code>::first-letter</code> applies
+to the first letter of the element <em>including</em> that content.
+
+<div class="example">
+<p>Example:</p>
+<p>After the rule 'p::before {content: "Note: "}', the selector
+'p::first-letter' matches the "N" of "Note".</p>
+</div>
+
+<p>Some languages may have specific rules about how to treat certain
+letter combinations. In Dutch, for example, if the letter combination
+"ij" appears at the beginning of a word, both letters should be
+considered within the <code>::first-letter</code> pseudo-element.
+
+<p>If the letters that would form the ::first-letter are not in the
+same element, such as "'T" in <code>&lt;p>'&lt;em>T...</code>, the UA
+may create a ::first-letter pseudo-element from one of the elements,
+both elements, or simply not create a pseudo-element.</p>
+
+<p>Similarly, if the first letter(s) of the block are not at the start
+of the line (for example due to bidirectional reordering), then the UA
+need not create the pseudo-element(s).
+
+<div class="example">
+<p>Example:</p>
+<p><a name="overlapping-example">The following example</a> illustrates
+how overlapping pseudo-elements may interact.  The first letter of
+each P element will be green with a font size of '24pt'. The rest of
+the first formatted line will be 'blue' while the rest of the
+paragraph will be 'red'.</p>
+
+<pre>p { color: red; font-size: 12pt }
+p::first-letter { color: green; font-size: 200% }
+p::first-line { color: blue }
+
+&lt;P&gt;Some text that ends up on two lines&lt;/P&gt;</pre>
+
+<p>Assuming that a line break will occur before the word "ends", the
+<span class="index-inst" title="fictional tag sequence">fictional tag
+sequence</span> for this fragment might be:</p>
+
+<pre>&lt;P&gt;
+&lt;P::first-line&gt;
+&lt;P::first-letter&gt; 
+S 
+&lt;/P::first-letter&gt;ome text that 
+&lt;/P::first-line&gt; 
+ends up on two lines 
+&lt;/P&gt;</pre>
+
+<p>Note that the <code>::first-letter</code> element is inside the <code>::first-line</code>
+element.  Properties set on <code>::first-line</code> are inherited by
+<code>::first-letter</code>, but are overridden if the same property is set on
+<code>::first-letter</code>.</p>
+</div>
+
+
+<h4><a name=UIfragments>7.3.</a> <a name=selection>The ::selection pseudo-element</a></h4>
+
+<p>The <code>::selection</code> pseudo-element applies to the portion
+of a document that has been highlighted by the user. This also
+applies, for example, to selected text within an editable text
+field. This pseudo-element should not be confused with the <code><a
+href="#checked">:checked</a></code> pseudo-class (which used to be
+named <code>:selected</code>)
+
+<p>Although the <code>::selection</code> pseudo-element is dynamic in
+nature, and is altered by user action, it is reasonable to expect that
+when a UA re-renders to a static medium (such as a printed page, see
+<a href="#refsCSS21">[CSS21]</a>) which was originally rendered to a
+dynamic medium (like screen), the UA may wish to transfer the current
+<code>::selection</code> state to that other medium, and have all the
+appropriate formatting and rendering take effect as well. This is not
+required &mdash; UAs may omit the <code>::selection</code>
+pseudo-element for static media.
+
+<p>These are the CSS properties that apply to <code>::selection</code>
+pseudo-elements: color, background, cursor (optional), outline
+(optional). The computed value of the 'background-image' property on
+<code>::selection</code> may be ignored.
+
+
+<h4><a name=gen-content>7.4. The ::before and ::after pseudo-elements</a></h4>
+
+<p>The <code>::before</code> and <code>::after</code> pseudo-elements
+can be used to describe generated content before or after an element's
+content. They are explained in CSS 2.1 <a
+href="#refsCSS21">[CSS21]</a>.</p>
+
+<p>When the <code>::first-letter</code> and <code>::first-line</code>
+pseudo-elements are combined with <code>::before</code> and
+<code>::after</code>, they apply to the first letter or line of the
+element including the inserted text.</p>
+
+<h2><a name=combinators>8. Combinators</a></h2>
+
+<h3><a name=descendant-combinators>8.1. Descendant combinator</a></h3>
+
+<p>At times, authors may want selectors to describe an element that is
+the descendant of another element in the document tree (e.g., "an
+<code>EM</code> element that is contained within an <code>H1</code>
+element"). Descendant combinators express such a relationship. A
+descendant combinator is <a href="#whitespace">white space</a> that
+separates two sequences of simple selectors.  A selector of the form
+"<code>A B</code>" represents an element <code>B</code> that is an
+arbitrary descendant of some ancestor element <code>A</code>.
+
+<div class="example">
+ <p>Examples:</p>
+ <p>For example, consider the following selector:</p>
+ <pre>h1 em</pre>
+ <p>It represents an <code>em</code> element being the descendant of
+ an <code>h1</code> element. It is a correct and valid, but partial,
+ description of the following fragment:</p>
+ <pre>&lt;h1&gt;This &lt;span class="myclass"&gt;headline
+is &lt;em&gt;very&lt;/em&gt; important&lt;/span&gt;&lt;/h1&gt;</pre>
+ <p>The following selector:</p>
+ <pre>div * p</pre>
+ <p>represents a <code>p</code> element that is a grandchild or later
+ descendant of a <code>div</code> element. Note the whitespace on
+ either side of the "*" is not part of the universal selector; the
+ whitespace is a combinator indicating that the DIV must be the
+ ancestor of some element, and that that element must be an ancestor
+ of the P.</p>
+ <p>The following selector, which combines descendant combinators and
+ <a href="#attribute-selectors">attribute selectors</a>, represents an
+ element that (1) has the <code>href</code> attribute set and (2) is
+ inside a <code>p</code> that is itself inside a <code>div</code>:</p>
+ <pre>div p *[href]</pre>
+</div>
+
+<h3><a name=child-combinators>8.2. Child combinators</a></h3>
+
+<p>A <dfn>child combinator</dfn> describes a childhood relationship
+between two elements. A child combinator is made of the
+&quot;greater-than sign&quot; (<code>&gt;</code>) character and
+separates two sequences of simple selectors.
+
+
+<div class="example">
+ <p>Examples:</p>
+ <p>The following selector represents a <code>p</code> element that is
+ child of <code>body</code>:</p>
+ <pre>body &gt; p</pre>
+ <p>The following example combines descendant combinators and child
+ combinators.</p>
+ <pre>div ol&gt;li p</pre><!-- LEAVE THOSE SPACES OUT! see below -->
+ <p>It represents a <code>p</code> element that is a descendant of an
+ <code>li</code> element; the <code>li</code> element must be the
+ child of an <code>ol</code> element; the <code>ol</code> element must
+ be a descendant of a <code>div</code>. Notice that the optional white
+ space around the "&gt;" combinator has been left out.</p>
+</div>
+
+<p>For information on selecting the first child of an element, please
+see the section on the <code><a
+href="#structural-pseudos">:first-child</a></code> pseudo-class
+above.</p>
+
+<h3><a name=sibling-combinators>8.3. Sibling combinators</a></h3>
+
+<p>There are two different sibling combinators: the adjacent sibling
+combinator and the general sibling combinator. In both cases,
+non-element nodes (e.g. text between elements) are ignored when
+considering adjacency of elements.</p>
+
+<h4><a name=adjacent-sibling-combinators>8.3.1. Adjacent sibling combinator</a></h4>
+
+<p>The adjacent sibling combinator is made of the &quot;plus
+sign&quot; (U+002B, <code>+</code>) character that separates two
+sequences of simple selectors. The elements represented by the two
+sequences share the same parent in the document tree and the element
+represented by the first sequence immediately precedes the element
+represented by the second one.</p>
+
+<div class="example">
+ <p>Examples:</p>
+ <p>The following selector represents a <code>p</code> element
+ immediately following a <code>math</code> element:</p>
+ <pre>math + p</pre>
+ <p>The following selector is conceptually similar to the one in the
+ previous example, except that it adds an attribute selector &mdash; it
+ adds a constraint to the <code>h1</code> element, that it must have
+ <code>class="opener"</code>:</p>
+ <pre>h1.opener + h2</pre>
+</div>
+
+
+<h4><a name=general-sibling-combinators>8.3.2. General sibling combinator</a></h4>
+
+<p>The general sibling combinator is made of the &quot;tilde&quot;
+(U+007E, <code>~</code>) character that separates two sequences of
+simple selectors. The elements represented by the two sequences share
+the same parent in the document tree and the element represented by
+the first sequence precedes (not necessarily immediately) the element
+represented by the second one.</p>
+
+<div class="example">
+ <p>Example:</p>
+ <pre>h1 ~ pre</pre>
+ <p>represents a <code>pre</code> element following an <code>h1</code>. It
+ is a correct and valid, but partial, description of:</p>
+ <pre>&lt;h1&gt;Definition of the function a&lt;/h1&gt;
+&lt;p&gt;Function a(x) has to be applied to all figures in the table.&lt;/p&gt;
+&lt;pre&gt;function a(x) = 12x/13.5&lt;/pre&gt;</pre>
+</div>
+
+<h2><a name=specificity>9. Calculating a selector's specificity</a></h2>
+
+<p>A selector's specificity is calculated as follows:</p>
+
+<ul>
+  <li>count the number of ID selectors in the selector (= a)</li>
+  <li>count the number of class selectors, attributes selectors, and pseudo-classes in the selector (= b)</li>
+  <li>count the number of element names in the selector (= c)</li>
+  <li>ignore pseudo-elements</li>
+</ul>
+
+<p>Selectors inside <a href="#negation">the negation pseudo-class</a>
+are counted like any other, but the negation itself does not count as
+a pseudo-class.</p>
+
+<p>Concatenating the three numbers a-b-c (in a number system with a
+large base) gives the specificity.</p>
+
+<div class="example">
+<p>Examples:</p>
+<pre>*               /* a=0 b=0 c=0 -&gt; specificity =   0 */
+LI              /* a=0 b=0 c=1 -&gt; specificity =   1 */
+UL LI           /* a=0 b=0 c=2 -&gt; specificity =   2 */
+UL OL+LI        /* a=0 b=0 c=3 -&gt; specificity =   3 */
+H1 + *[REL=up]  /* a=0 b=1 c=1 -&gt; specificity =  11 */
+UL OL LI.red    /* a=0 b=1 c=3 -&gt; specificity =  13 */
+LI.red.level    /* a=0 b=2 c=1 -&gt; specificity =  21 */
+#x34y           /* a=1 b=0 c=0 -&gt; specificity = 100 */
+#s12:not(FOO)   /* a=1 b=0 c=1 -&gt; specificity = 101 */
+</pre>
+</div>
+
+<p class="note"><strong>Note:</strong> the specificity of the styles
+specified in an HTML <code>style</code> attribute is described in CSS
+2.1. <a href="#refsCSS21">[CSS21]</a>.</p>
+
+<h2><a name=w3cselgrammar>10. The grammar of Selectors</a></h2>
+
+<h3><a name=grammar>10.1. Grammar</a></h3>
+
+<p>The grammar below defines the syntax of Selectors.  It is globally
+LL(1) and can be locally LL(2) (but note that most UA's should not use
+it directly, since it doesn't express the parsing conventions). The
+format of the productions is optimized for human consumption and some
+shorthand notations beyond Yacc (see <a href="#refsYACC">[YACC]</a>)
+are used:</p>
+
+<ul>
+  <li><b>*</b>: 0 or more
+  <li><b>+</b>: 1 or more
+  <li><b>?</b>: 0 or 1
+  <li><b>|</b>: separates alternatives
+  <li><b>[ ]</b>: grouping </li>
+</ul>
+
+<p>The productions are:</p>
+
+<pre>selectors_group
+  : selector [ COMMA S* selector ]*
+  ;
+
+selector
+  : simple_selector_sequence [ combinator simple_selector_sequence ]*
+  ;
+
+combinator
+  /* combinators can be surrounded by white space */
+  : PLUS S* | GREATER S* | TILDE S* | S+
+  ;
+
+simple_selector_sequence
+  : [ type_selector | universal ]
+    [ HASH | class | attrib | pseudo | negation ]*
+  | [ HASH | class | attrib | pseudo | negation ]+
+  ;
+
+type_selector
+  : [ namespace_prefix ]? element_name
+  ;
+
+namespace_prefix
+  : [ IDENT | '*' ]? '|'
+  ;
+
+element_name
+  : IDENT
+  ;
+
+universal
+  : [ namespace_prefix ]? '*'
+  ;
+
+class
+  : '.' IDENT
+  ;
+
+attrib
+  : '[' S* [ namespace_prefix ]? IDENT S*
+        [ [ PREFIXMATCH |
+            SUFFIXMATCH |
+            SUBSTRINGMATCH |
+            '=' |
+            INCLUDES |
+            DASHMATCH ] S* [ IDENT | STRING ] S*
+        ]? ']'
+  ;
+
+pseudo
+  /* '::' starts a pseudo-element, ':' a pseudo-class */
+  /* Exceptions: :first-line, :first-letter, :before and :after. */
+  /* Note that pseudo-elements are restricted to one per selector and */
+  /* occur only in the last simple_selector_sequence. */
+  : ':' ':'? [ IDENT | functional_pseudo ]
+  ;
+
+functional_pseudo
+  : FUNCTION S* expression ')'
+  ;
+
+expression
+  /* In CSS3, the expressions are identifiers, strings, */
+  /* or of the form "an+b" */
+  : [ [ PLUS | '-' | DIMENSION | NUMBER | STRING | IDENT ] S* ]+
+  ;
+
+negation
+  : NOT S* negation_arg S* ')'
+  ;
+
+negation_arg
+  : type_selector | universal | HASH | class | attrib | pseudo
+  ;</pre>
+
+
+<h3><a name=lex>10.2. Lexical scanner</a></h3>
+
+<p>The following is the <a name=x3>tokenizer</a>, written in Flex (see
+<a href="#refsFLEX">[FLEX]</a>) notation. The tokenizer is
+case-insensitive.</p>
+
+<p>The two occurrences of "\377" represent the highest character
+number that current versions of Flex can deal with (decimal 255). They
+should be read as "\4177777" (decimal 1114111), which is the highest
+possible code point in Unicode/ISO-10646. <a
+href="#refsUNICODE">[UNICODE]</a></p>
+
+<pre>%option case-insensitive
+
+ident     [-]?{nmstart}{nmchar}*
+name      {nmchar}+
+nmstart   [_a-z]|{nonascii}|{escape}
+nonascii  [^\0-\177]
+unicode   \\[0-9a-f]{1,6}(\r\n|[ \n\r\t\f])?
+escape    {unicode}|\\[^\n\r\f0-9a-f]
+nmchar    [_a-z0-9-]|{nonascii}|{escape}
+num       [0-9]+|[0-9]*\.[0-9]+
+string    {string1}|{string2}
+string1   \"([^\n\r\f\\"]|\\{nl}|{nonascii}|{escape})*\"
+string2   \'([^\n\r\f\\']|\\{nl}|{nonascii}|{escape})*\'
+invalid   {invalid1}|{invalid2}
+invalid1  \"([^\n\r\f\\"]|\\{nl}|{nonascii}|{escape})*
+invalid2  \'([^\n\r\f\\']|\\{nl}|{nonascii}|{escape})*
+nl        \n|\r\n|\r|\f
+w         [ \t\r\n\f]*
+
+%%
+
+[ \t\r\n\f]+     return S;
+
+"~="             return INCLUDES;
+"|="             return DASHMATCH;
+"^="             return PREFIXMATCH;
+"$="             return SUFFIXMATCH;
+"*="             return SUBSTRINGMATCH;
+{ident}          return IDENT;
+{string}         return STRING;
+{ident}"("       return FUNCTION;
+{num}            return NUMBER;
+"#"{name}        return HASH;
+{w}"+"           return PLUS;
+{w}"&gt;"           return GREATER;
+{w}","           return COMMA;
+{w}"~"           return TILDE;
+":not("          return NOT;
+@{ident}         return ATKEYWORD;
+{invalid}        return INVALID;
+{num}%           return PERCENTAGE;
+{num}{ident}     return DIMENSION;
+"&lt;!--"           return CDO;
+"--&gt;"            return CDC;
+
+"url("{w}{string}{w}")"                           return URI;
+"url("{w}([!#$%&*-~]|{nonascii}|{escape})*{w}")"  return URI;
+U\+[0-9a-f?]{1,6}(-[0-9a-f]{1,6})?                return UNICODE_RANGE;
+
+\/\*[^*]*\*+([^/*][^*]*\*+)*\/                    /* ignore comments */
+
+.                return *yytext;</pre>
+
+
+
+<h2><a name=downlevel>11. Namespaces and down-level clients</a></h2>
+
+<p>An important issue is the interaction of CSS selectors with XML
+documents in web clients that were produced prior to this
+document. Unfortunately, due to the fact that namespaces must be
+matched based on the URI which identifies the namespace, not the
+namespace prefix, some mechanism is required to identify namespaces in
+CSS by their URI as well. Without such a mechanism, it is impossible
+to construct a CSS style sheet which will properly match selectors in
+all cases against a random set of XML documents. However, given
+complete knowledge of the XML document to which a style sheet is to be
+applied, and a limited use of namespaces within the XML document, it
+is possible to construct a style sheet in which selectors would match
+elements and attributes correctly.</p>
+
+<p>It should be noted that a down-level CSS client will (if it
+properly conforms to CSS forward compatible parsing rules) ignore all
+<code>@namespace</code> at-rules, as well as all style rules that make
+use of namespace qualified element type or attribute selectors. The
+syntax of delimiting namespace prefixes in CSS was deliberately chosen
+so that down-level CSS clients would ignore the style rules rather
+than possibly match them incorrectly.</p>
+
+<p>The use of default namespaces in CSS makes it possible to write
+element type selectors that will function in both namespace aware CSS
+clients as well as down-level clients. It should be noted that
+down-level clients may incorrectly match selectors against XML
+elements in other namespaces.</p>
+
+<p>The following are scenarios and examples in which it is possible to
+construct style sheets which would function properly in web clients
+that do not implement this proposal.</p>
+
+<ol>
+  <li>
+
+   <p>The XML document does not use namespaces.</p>
+
+   <ul>
+
+    <li>In this case, it is obviously not necessary to declare or use
+    namespaces in the style sheet. Standard CSS element type and
+    attribute selectors will function adequately in a down-level
+    client.</li>
+
+    <li>In a CSS namespace aware client, the default behavior of
+    element selectors matching without regard to namespace will
+    function properly against all elements, since no namespaces are
+    present. However, the use of specific element type selectors that
+    match only elements that have no namespace ("<code>|name</code>")
+    will guarantee that selectors will match only XML elements that do
+    not have a declared namespace. </li>
+
+   </ul>
+
+  </li>
+
+  <li>
+
+   <p>The XML document defines a single, default namespace used
+   throughout the document. No namespace prefixes are used in element
+   names.</p>
+
+   <ul>
+
+    <li>In this case, a down-level client will function as if
+    namespaces were not used in the XML document at all. Standard CSS
+    element type and attribute selectors will match against all
+    elements. </li>
+
+   </ul>
+
+  </li>
+
+  <li>
+
+   <p>The XML document does <b>not</b> use a default namespace, all
+   namespace prefixes used are known to the style sheet author, and
+   there is a direct mapping between namespace prefixes and namespace
+   URIs. (A given prefix may only be mapped to one namespace URI
+   throughout the XML document; there may be multiple prefixes mapped
+   to the same URI).</p>
+
+   <ul>
+
+    <li>In this case, the down-level client will view and match
+    element type and attribute selectors based on their fully
+    qualified name, not the local part as outlined in the <a
+    href="#typenmsp">Type selectors and Namespaces</a> section. CSS
+    selectors may be declared using an escaped colon "<code>\:</code>"
+    to describe the fully qualified names, e.g.
+    "<code>html\:h1</code>" will match
+    <code>&lt;html:h1&gt;</code>. Selectors using the qualified name
+    will only match XML elements that use the same prefix. Other
+    namespace prefixes used in the XML that are mapped to the same URI
+    will not match as expected unless additional CSS style rules are
+    declared for them.</li>
+
+    <li>Note that selectors declared in this fashion will
+    <em>only</em> match in down-level clients. A CSS namespace aware
+    client will match element type and attribute selectors based on
+    the name's local part. Selectors declared with the fully
+    qualified name will not match (unless there is no namespace prefix
+    in the fully qualified name).</li>
+
+   </ul>
+
+  </li>
+
+ </ol>
+
+<p>In other scenarios: when the namespace prefixes used in the XML are
+not known in advance by the style sheet author; or a combination of
+elements with no namespace are used in conjunction with elements using
+a default namespace; or the same namespace prefix is mapped to
+<em>different</em> namespace URIs within the same document, or in
+different documents; it is impossible to construct a CSS style sheet
+that will function properly against all elements in those documents,
+unless, the style sheet is written using a namespace URI syntax (as
+outlined in this document or similar) and the document is processed by
+a CSS and XML namespace aware client.</p>
+
+<h2><a name=profiling>12. Profiles</a></h2>
+
+<p>Each specification using Selectors must define the subset of W3C
+Selectors it allows and excludes, and describe the local meaning of
+all the components of that subset.</p>
+
+<p>Non normative examples:
+
+<div class="profile">
+<table class="tprofile">
+  <tbody>
+  <tr>
+    <th class="title" colspan=2>Selectors profile</th></tr>
+  <tr>
+    <th>Specification</th>
+    <td>CSS level 1</td></tr>
+  <tr>
+    <th>Accepts</th>
+    <td>type selectors<br>class selectors<br>ID selectors<br>:link,
+      :visited and :active pseudo-classes<br>descendant combinator
+     <br>::first-line and ::first-letter pseudo-elements</td></tr>
+  <tr>
+    <th>Excludes</th>
+    <td>
+      
+<p>universal selector<br>attribute selectors<br>:hover and :focus
+      pseudo-classes<br>:target pseudo-class<br>:lang() pseudo-class<br>all UI
+      element states pseudo-classes<br>all structural
+      pseudo-classes<br>negation pseudo-class<br>all
+      UI element fragments pseudo-elements<br>::before and ::after
+      pseudo-elements<br>child combinators<br>sibling combinators
+      
+<p>namespaces</td></tr>
+  <tr>
+    <th>Extra constraints</th>
+    <td>only one class selector allowed per sequence of simple
+  selectors</td></tr></tbody></table><br><br>
+<table class="tprofile">
+  <tbody>
+  <tr>
+    <th class="title" colspan=2>Selectors profile</th></tr>
+  <tr>
+    <th>Specification</th>
+    <td>CSS level 2</td></tr>
+  <tr>
+    <th>Accepts</th>
+    <td>type selectors<br>universal selector<br>attribute presence and
+      values selectors<br>class selectors<br>ID selectors<br>:link, :visited,
+      :active, :hover, :focus, :lang() and :first-child pseudo-classes
+     <br>descendant combinator<br>child combinator<br>adjacent sibling
+      combinator<br>::first-line and ::first-letter pseudo-elements<br>::before
+      and ::after pseudo-elements</td></tr>
+  <tr>
+    <th>Excludes</th>
+    <td>
+      
+<p>content selectors<br>substring matching attribute
+      selectors<br>:target pseudo-classes<br>all UI element
+      states pseudo-classes<br>all structural pseudo-classes other
+      than :first-child<br>negation pseudo-class<br>all UI element
+      fragments pseudo-elements<br>general sibling combinators
+      
+<p>namespaces</td></tr>
+  <tr>
+    <th>Extra constraints</th>
+    <td>more than one class selector per sequence of simple selectors (CSS1
+      constraint) allowed</td></tr></tbody></table>
+
+<p>In CSS, selectors express pattern matching rules that determine which style
+rules apply to elements in the document tree. 
+
+<p>The following selector (CSS level 2) will <b>match</b> all anchors <code>a</code>
+with attribute <code>name</code> set inside a section 1 header <code>h1</code>: 
+<pre>h1 a[name]</pre>
+
+<p>All CSS declarations attached to such a selector are applied to elements
+matching it. </div>
+
+<div class="profile">
+<table class="tprofile">
+  <tbody>
+  <tr>
+    <th class="title" colspan=2>Selectors profile</th></tr>
+  <tr>
+    <th>Specification</th>
+      <td>STTS 3</td>
+    </tr>
+  <tr>
+    <th>Accepts</th>
+    <td>
+      
+<p>type selectors<br>universal selectors<br>attribute selectors<br>class
+      selectors<br>ID selectors<br>all structural pseudo-classes<br>
+          all combinators
+      
+<p>namespaces</td></tr>
+  <tr>
+    <th>Excludes</th>
+    <td>non-accepted pseudo-classes<br>pseudo-elements<br></td></tr>
+  <tr>
+    <th>Extra constraints</th>
+    <td>some selectors and combinators are not allowed in fragment
+      descriptions on the right side of STTS declarations.</td></tr></tbody></table>
+  
+<p>Selectors can be used in STTS 3 in two different
+    manners: 
+<ol>
+  <li>a selection mechanism equivalent to CSS selection mechanism: declarations
+  attached to a given selector are applied to elements matching that selector,
+  <li>fragment descriptions that appear on the right side of declarations.
+</li></ol></div>
+
+<h2><a name=Conformance></a>13. Conformance and requirements</h2>
+
+<p>This section defines conformance with the present specification only.
+
+<p>The inability of a user agent to implement part of this specification due to
+the limitations of a particular device (e.g., non interactive user agents will
+probably not implement dynamic pseudo-classes because they make no sense without
+interactivity) does not imply non-conformance.
+
+<p>All specifications reusing Selectors must contain a <a
+href="#profiling">Profile</a> listing the
+subset of Selectors it accepts or excludes, and describing the constraints
+it adds to the current specification. 
+
+<p>Invalidity is caused by a parsing error, e.g. an unrecognized token or a token
+which is not allowed at the current parsing point.
+
+<p>User agents must observe the rules for handling parsing errors:
+<ul>
+  <li>a simple selector containing an undeclared namespace prefix is invalid</li>
+  <li>a selector containing an invalid simple selector, an invalid combinator
+    or an invalid token is invalid. </li>
+  <li>a group of selectors containing an invalid selector is invalid.</li>
+</ul>
+
+<p>Specifications reusing Selectors must define how to handle parsing
+errors. (In the case of CSS, the entire rule in which the selector is
+used is dropped.)</p>
+
+<!-- Apparently all these references are out of date:
+<p>Implementations of this specification must behave as
+"recipients of text data" as defined by <a href="#refsCWWW">[CWWW]</a>
+when parsing selectors and attempting matches. (In particular,
+implementations must assume the data is normalized and must not
+normalize it.) Normative rules for matching strings are defined in
+<a href="#refsCWWW">[CWWW]</a> and <a
+href="#refsUNICODE">[UNICODE]</a> and apply to implementations of this
+specification.</p>-->
+
+<h2><a name=Tests></a>14. Tests</h2>
+
+<p>This specification has <a
+href="http://www.w3.org/Style/CSS/Test/CSS3/Selectors/current/">a test
+suite</a> allowing user agents to verify their basic conformance to
+the specification. This test suite does not pretend to be exhaustive
+and does not cover all possible combined cases of Selectors.</p>
+
+<h2><a name=ACKS></a>15. Acknowledgements</h2>
+
+<p>The CSS working group would like to thank everyone who has sent
+comments on this specification over the years.</p>
+
+<p>The working group would like to extend special thanks to Donna
+McManus, Justin Baker, Joel Sklar, and Molly Ives Brower who perfermed
+the final editorial review.</p>
+
+<h2><a name=references>16. References</a></h2>
+
+<dl class="refs">
+
+  <dt>[CSS1]
+  <dd><a name=refsCSS1></a> Bert Bos, H&aring;kon Wium Lie; "<cite>Cascading Style Sheets, level 1</cite>", W3C Recommendation, 17 Dec 1996, revised 11 Jan 1999
+  <dd>(<code><a href="http://www.w3.org/TR/REC-CSS1">http://www.w3.org/TR/REC-CSS1</a></code>)
+
+  <dt>[CSS21]
+  <dd><a name=refsCSS21></a> Bert Bos, Tantek &Ccedil;elik, Ian Hickson, H&aring;kon Wium Lie, editors; "<cite>Cascading Style Sheets, level 2 revision 1</cite>", W3C Working Draft, 13 June 2005 
+  <dd>(<code><a href="http://www.w3.org/TR/CSS21">http://www.w3.org/TR/CSS21</a></code>)
+
+  <dt>[CWWW]
+  <dd><a name=refsCWWW></a> Martin J. D&uuml;rst, Fran&ccedil;ois Yergeau, Misha Wolf, Asmus Freytag, Tex Texin, editors; "<cite>Character Model for the World Wide Web</cite>", W3C Recommendation, 15 February 2005
+  <dd>(<code><a href="http://www.w3.org/TR/charmod/">http://www.w3.org/TR/charmod/</a></code>)
+
+  <dt>[FLEX]
+  <dd><a name="refsFLEX"></a> "<cite>Flex: The Lexical Scanner Generator</cite>", Version 2.3.7, ISBN 1882114213
+
+  <dt>[HTML4]
+  <dd><a name="refsHTML4"></a> Dave Ragget, Arnaud Le Hors, Ian Jacobs, editors; "<cite>HTML 4.01 Specification</cite>", W3C Recommendation, 24 December 1999
+  <dd>(<a href="http://www.w3.org/TR/html4/"><code>http://www.w3.org/TR/html4/</code></a>)
+
+  <dt>[MATH]
+  <dd><a name="refsMATH"></a> Patrick Ion, Robert Miner, editors; "<cite>Mathematical Markup Language (MathML) 1.01</cite>", W3C Recommendation, revision of 7 July 1999
+  <dd>(<code><a href="http://www.w3.org/TR/REC-MathML/">http://www.w3.org/TR/REC-MathML/</a></code>)
+
+  <dt>[RFC3066]
+  <dd><a name="refsRFC3066"></a> H. Alvestrand; "<cite>Tags for the Identification of Languages</cite>", Request for Comments 3066, January 2001
+  <dd>(<a href="http://www.ietf.org/rfc/rfc3066.txt"><code>http://www.ietf.org/rfc/rfc3066.txt</code></a>)
+
+  <dt>[STTS]
+  <dd><a name=refsSTTS></a> Daniel Glazman; "<cite>Simple Tree Transformation Sheets 3</cite>", Electricit&eacute; de France, submission to the W3C, 11 November 1998 
+  <dd>(<code><a href="http://www.w3.org/TR/NOTE-STTS3">http://www.w3.org/TR/NOTE-STTS3</a></code>)
+
+  <dt>[SVG]
+  <dd><a name="refsSVG"></a> Jon Ferraiolo, &#34276;&#27810; &#28147;, Dean Jackson, editors; "<cite>Scalable Vector Graphics (SVG) 1.1 Specification</cite>", W3C Recommendation, 14 January 2003
+  <dd>(<code><a href="http://www.w3.org/TR/SVG/">http://www.w3.org/TR/SVG/</a></code>)
+
+  <dt>[UNICODE]</dt>
+  <dd><a name="refsUNICODE"></a> <cite><a
+   href="http://www.unicode.org/versions/Unicode4.1.0/">The Unicode Standard, Version 4.1</a></cite>, The Unicode Consortium. Boston, MA, Addison-Wesley, March 2005. ISBN 0-321-18578-1, as amended by <a href="http://www.unicode.org/versions/Unicode4.0.1/">Unicode 4.0.1</a> and <a href="http://www.unicode.org/versions/Unicode4.1.0/">Unicode  4.1.0</a>.
+  <dd>(<code><a href="http://www.unicode.org/versions/">http://www.unicode.org/versions/</a></code>)</dd>
+
+  <dt>[XML10]
+  <dd><a name="refsXML10"></a> Tim Bray, Jean Paoli, C. M. Sperberg-McQueen, Eve Maler, Fran&ccedil;ois Yergeau, editors; "<cite>Extensible Markup Language (XML) 1.0 (Third Edition)</cite>", W3C Recommendation, 4 February 2004
+  <dd>(<a href="http://www.w3.org/TR/REC-xml/"><code>http://www.w3.org/TR/REC-xml/</code></a>)
+
+  <dt>[XMLNAMES]
+  <dd><a name="refsXMLNAMES"></a> Tim Bray, Dave Hollander, Andrew Layman, editors; "<cite>Namespaces in XML</cite>", W3C Recommendation, 14 January 1999
+  <dd>(<a href="http://www.w3.org/TR/REC-xml-names/"><code>http://www.w3.org/TR/REC-xml-names/</code></a>)
+
+  <dt>[YACC]
+  <dd><a name="refsYACC"></a> S. C. Johnson; "<cite>YACC &mdash; Yet another compiler compiler</cite>", Technical Report, Murray Hill, 1975
+
+</dl>
+</body>
+</html>

+ 243 - 0
vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/testcase/std_testcase.php

@@ -0,0 +1,243 @@
+<?php
+// $Rev: 115 $
+// -----------------------------------------------------------------------------
+// setup
+error_reporting(E_ALL);
+require_once('../simple_html_dom.php');
+$dom = new simple_html_dom;
+
+// -----------------------------------------------------------------------------
+// empty test
+$str = '';
+$dom->load($str);
+assert($dom->save()==$str);
+// -----------------------------------------------
+$str = null;
+$dom->load($str);
+assert($dom->save()==$str);
+
+// -----------------------------------------------------------------------------
+// text test
+$str = <<<HTML
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+                      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"></html>
+HTML;
+$dom->load($str);
+assert(count($dom->find('unknown'))==1);
+assert(count($dom->find('text'))==1);
+
+// -----------------------------------------------------------------------------
+// string quote test
+$str = <<<HTML
+<div class="class0" id="id0" >
+    okok<br>
+    <input type=submit name="btnG" value="go" onclick='goto("url0")'>
+    <br/>
+    <div><input type=submit name="btnG2" value="go" onclick="goto('url1'+'\'')"/></div>
+    <input type=submit name="btnG2" value="go" onclick="goto('url2')"/>
+    <div><input type=submit name="btnG2" value="go" onclick='goto("url4"+"\"")'></div>
+    <br/>
+</div>
+HTML;
+$dom->load($str);
+$es = $dom->find('input');
+assert(count($es)==4);
+assert($es[0]->onclick=='goto("url0")');
+assert($es[1]->onclick=="goto('url1'+'\'')");
+assert($es[2]->onclick=="goto('url2')");
+assert($es[3]->onclick=='goto("url4"+"\"")');
+
+// -----------------------------------------------------------------------------
+// clone test
+$str = <<<HTML
+<div class="class0" id="id0" >
+    okok<br>
+    <input type=submit name="btnG" value="go" onclick='goto("url0")'>
+    <br/>
+    <div><input type=submit name="btnG2" value="go" onclick="goto('url1'+'\'')"/></div>
+    <input type=submit name="btnG2" value="go" onclick="goto('url2')"/>
+    <div><input type=submit name="btnG2" value="go" onclick='goto("url4"+"\"")'></div>
+    <br/>
+</div>
+HTML;
+$dom->load($str);
+$es = $dom->find('input');
+assert(count($es)==4);
+assert($es[0]->onclick=='goto("url0")');
+assert($es[1]->onclick=="goto('url1'+'\'')");
+assert($es[2]->onclick=="goto('url2')");
+assert($es[3]->onclick=='goto("url4"+"\"")');
+
+unset($es);
+$dom2 = clone($dom);
+$es = $dom2->find('input');
+assert(count($es)==4);
+assert($es[0]->onclick=='goto("url0")');
+assert($es[1]->onclick=="goto('url1'+'\'')");
+assert($es[2]->onclick=="goto('url2')");
+assert($es[3]->onclick=='goto("url4"+"\"")');
+
+// -----------------------------------------------
+$str = <<<HTML
+<div class='class0' id="id0" aa='aa' bb="bb" cc='"cc"' dd="'dd'"></div>
+HTML;
+$dom->load($str);
+assert($dom==$str);
+assert($dom->save()==$str);
+
+// -----------------------------------------------------------------------------
+// monkey test
+$str = <<<HTML
+<
+HTML;
+$dom->load($str);
+assert($dom==$str);
+assert($dom->save()==$str);
+// -----------------------------------------------
+$str = <<<HTML
+<
+
+HTML;
+$dom->load($str);
+assert($dom==$str);
+assert($dom->save()==$str);
+// -----------------------------------------------
+$str = <<<HTML
+
+
+<
+HTML;
+$dom->load($str);
+assert($dom==$str);
+assert($dom->save()==$str);
+// -----------------------------------------------
+$str = <<<HTML
+<a
+HTML;
+$dom->load($str);
+assert($dom==$str);
+assert($dom->save()==$str);
+// -----------------------------------------------
+$str = <<<HTML
+<a<
+HTML;
+$dom->load($str);
+assert($dom==$str);
+assert($dom->save()==$str);
+// -----------------------------------------------
+$str = <<<HTML
+<<<<ab
+HTML;
+$dom->load($str);
+assert($dom==$str);
+assert($dom->save()==$str);
+// -----------------------------------------------
+$str = <<<HTML
+<<<<ab  
+HTML;
+$dom->load($str);
+assert($dom==$str);
+assert($dom->save()==$str);
+// -----------------------------------------------
+$str = <<<HTML
+<<><<>ab  
+HTML;
+$dom->load($str);
+assert($dom==$str);
+assert($dom->save()==$str);
+// -----------------------------------------------
+$str = <<<HTML
+<abc
+
+HTML;
+$dom->load($str);
+assert($dom==$str);
+assert($dom->save()==$str);
+// -----------------------------------------------
+$str = <<<HTML
+>
+HTML;
+$dom->load($str);
+assert($dom==$str);
+assert($dom->save()==$str);
+// -----------------------------------------------
+// $str = <<<HTML
+// <abc
+// (<1 mol%) 
+// HTML;
+// $dom->load($str);
+// echo $dom;
+// assert($dom==$str);
+// assert($dom->save()==$str);
+// -----------------------------------------------
+$str = <<<HTML
+(<1 mol%) 
+HTML;
+$dom->load($str);
+assert($dom==$str);
+assert($dom->save()==$str);
+
+// -----------------------------------------------------------------------------
+// rnadom string test
+function str_random($length)
+{
+    $str = "";
+    srand((double)microtime()*1000000);
+    $char_list = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+    $char_list .= "abcdefghijklmnopqrstuvwxyz";
+    $char_list .= "1234567890";
+    $char_list .= "<>!?[]%^&*()";
+    for($i=0; $i<$length; ++$i)
+        $str .= substr($char_list,(rand()%(strlen($char_list))), 1);
+    return $str;
+}
+
+for($i=0; $i<60; ++$i) {
+    $str = str_random($i);
+    //echo $str."\n<br>";
+    $dom->load($str, false);
+    //echo $dom->save()."\n<br>";
+    assert($dom==$str);
+}
+
+// -----------------------------------------------------------------------------
+// lowercase test
+$str = <<<HTML
+<img class="class0" id="id0" src="src0">
+HTML;
+$dom->load($str);
+assert(count($dom->find('img'))==1);
+assert(count($dom->find('IMG'))==1);
+assert(isset($dom->find('img', 0)->class));
+assert(!isset($dom->find('img', 0)->CLASS));
+assert($dom->find('img', 0)->class=='class0');
+assert($dom==$str);
+// -----------------------------------------------
+$str = <<<HTML
+<IMG CLASS="class0" ID="id0" SRC="src0">
+HTML;
+$dom->load($str);
+assert(count($dom->find('img'))==1);
+assert(count($dom->find('IMG'))==1);
+assert(isset($dom->find('img', 0)->class));
+assert(!isset($dom->find('img', 0)->CLASS));
+assert($dom->find('img', 0)->class=='class0');
+assert($dom==strtolower($str));
+// -----------------------------------------------
+$str = <<<HTML
+<IMG CLASS="class0" ID="id0" SRC="src0">
+HTML;
+$dom->load($str, false);
+assert(count($dom->find('img'))==0);
+assert(count($dom->find('IMG'))==1);
+assert(isset($dom->find('IMG', 0)->CLASS));
+assert(!isset($dom->find('IMG', 0)->class));
+assert($dom->find('IMG', 0)->CLASS=='class0');
+assert($dom==$str);
+
+// -----------------------------------------------------------------------------
+// tear down
+$dom->clear();
+unset($dom);
+?>

+ 137 - 0
vendor/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/simplehtmldom_1_5/testcase/strip_testcase.php

@@ -0,0 +1,137 @@
+<?php
+// $Rev: 169 $
+// -----------------------------------------------------------------------------
+// setup
+error_reporting(E_ALL);
+require_once('../simple_html_dom.php');
+$dom = new simple_html_dom;
+
+// -----------------------------------------------------------------------------
+// comments test
+$str = <<<HTML
+<div class="class0" id="id0" >
+    <!--
+        <input type=submit name="btnG" value="go" onclick='goto("url0")'>
+    -->
+</div>
+HTML;
+$dom->load($str);
+assert(count($dom->find('input'))==0);
+
+// -----------------------------------------------------------------------------
+// <code> test
+$str = <<<HTML
+<div class="class0" id="id0" >
+    <CODE>
+        <input type=submit name="btnG" value="go" onclick='goto("url0")'>
+    </CODE>
+</div>
+HTML;
+$dom->load($str);
+assert(count($dom->find('code'))==1);
+assert(count($dom->find('input'))==0);
+
+// -----------------------------------------------------------------------------
+// <pre> & <code> test
+$str = <<<HTML
+<PRE><CODE CLASS=Java>
+    <input type=submit name="btnG" value="go" onclick='goto("url0")'>
+</CODE></PRE>
+HTML;
+$dom->load($str);
+assert(count($dom->find('pre'))==1);
+assert(count($dom->find('input'))==0);
+
+// -----------------------------------------------------------------------------
+// <script> & <style> test
+$str = <<<HTML
+<script type="text/javascript" src="test.js"></script>
+<script type="text/javascript" src="test.js"/>
+
+<style type="text/css">
+@import url("style.css");
+</style>
+
+<script type="text/javascript">
+var foo = "bar";
+</script>
+HTML;
+$dom->load($str);
+assert(count($dom->find('style'))==1);
+assert(count($dom->find('script'))==3);
+
+// -----------------------------------------------------------------------------
+// php short tag test
+$str = <<<HTML
+<a href="<?=h('ok')?>">hello</a>
+<input type=submit name="btnG" value="<?php echoh('ok')?>">
+HTML;
+$dom->load($str);
+assert($dom->find('a', 0)->href==="<?=h('ok')?>");
+assert($dom->find('input', 0)->value==="<?php echoh('ok')?>");
+
+// -----------------------------------------------------------------------------
+// noise stripping test
+$str = <<<HTML
+<!--
+<img class="class0" id="id0" src="src0">-->
+<img class="class1" id="id1" src="src1">
+<!--<img class="class2" id="id2" src="src2">
+-->
+HTML;
+$dom->load($str);
+assert(count($dom->find('img'))==1);
+assert($dom==$str);
+// -----------------------------------------------
+$str = <<<HTML
+<script type="text/javascript" src="test1.js">ss</script>
+<script type="text/javascript" src="test2.js"/>
+<script type="text/javascript" src="test3.js" />
+<script type="text/javascript" src="test4.js" 
+/>
+
+<script type="text/javascript" src="test5.js"/>
+
+<style>
+@import url("style1.css");
+</style>
+
+<script>
+var foo = "bar";
+</script>
+
+<style type="text/css">
+@import url("style2.css");
+</style>
+
+<style>
+div,td,.n a,.n a:visited{color:#000}.ts td,.tc{padding:0}.ts,.tb{border-collapse:collapse}.ti,.bl{display:inline}.ti{display:inline-table}.f,.m{color:#666}.flc,a.fl{color:#77c}a,.w,.q:visited,.q:active,.q,.b a,.b a:visited,.mblink:visited{color:#00c}a:visited{color:#551a8b}a:active{color:red}.t{background:#d5ddf3;
+color:#000;
+padding:5px 1px 4px}.bb{border-bottom:1px solid #36c}.bt{border-top:1px solid #36c}.j{width:34em}.h{color:#36c}.i{color:#a90a08}.a{color:green}.z{display:none}div.n{margin-top:1ex}.n a,.n .i{font-size:10pt}.n .i,.b a{font-weight:bold}.b a{font-size:12pt}.std{font-size:82%}#np,#nn,.nr,#logo span,.ch{cursor:pointer;cursor:hand}.ta{padding:3px 3px 3px 5px}#tpa2,#tpa3{padding-top:9px}#gbar{float:left;height:22px;padding-left:2px}.gbh,.gb2 div{border-top:1px solid #c9d7f1;
+</style>
+
+<!-- BEGIN ADVERTPRO ADVANCED CODE BLOCK -->
+
+<script language="JavaScript" type="text/javascript">
+<!--
+document.write('<SCR'+'IPT src="zone?zid=159&pid=0&random='+Math.floor(89999999*Math.random()+10000000)+'&millis='+new Date().getTime()+'" language="JavaScript" type="text/javascript"></SCR'+'IPT>');
+//-->
+</script>
+
+<!-- END ADVERTPRO ADVANCED CODE BLOCK -->
+
+<script type="text/javascript">
+var foo = "bar";
+</script>
+HTML;
+$dom->load($str);
+assert(count($dom->find('script'))==8);
+assert(count($dom->find('style'))==3);
+//echo "\n\n\n\n".$dom->save();
+assert($dom==$str);
+
+// -----------------------------------------------------------------------------
+// tear down
+$dom->clear();
+unset($dom);
+?>

+ 24 - 0
vendor/sunra/php-simple-html-dom-parser/composer.json

@@ -0,0 +1,24 @@
+{
+    "name": "sunra/php-simple-html-dom-parser",
+    "type": "library",
+    "description": "Composer adaptation of: A HTML DOM parser written in PHP5+ let you manipulate HTML in a very easy way! Require PHP 5+. Supports invalid HTML. Find tags on an HTML page with selectors just like jQuery. Extract contents from HTML in a single line.",    
+    "keywords": ["html", "dom", "parser"],
+    "homepage": "https://github.com/sunra/php-simple-html-dom-parser",
+    "license": "MIT",
+    "authors": [
+        {            
+            "homepage": "http://sourceforge.net/projects/simplehtmldom/"
+        },
+        {
+            "name": "Sunra",
+            "email": "sunra@yandex.ru",
+            "homepage": "https://github.com/sunra"
+        }   
+    ],
+    "require": {
+        "php": ">=5.3.2"        
+    },
+    "autoload": {
+        "psr-0": { "Sunra\\PhpSimple\\HtmlDomParser": "Src/" }
+    }    
+}

+ 3 - 3
web/ChamiloLMS/css/base.css

@@ -10,7 +10,6 @@ html {
 }
 
 body {
-    margin-bottom: 60px;
     background-color: #383e4b;
     /* The html and body elements cannot have any padding or margin. */
 }
@@ -202,6 +201,7 @@ footer .container .row {
 .actions {
     margin-top: 10px;
     margin-bottom: 10px;
+    width:100%;
 }
 
 .actions form {
@@ -6767,10 +6767,10 @@ header .navbar {
 }
 
 footer {
-    position: absolute;
+    /*position: absolute;
     bottom: 0;
     width: 100%;
-    height: 60px;
+    height: 60px;*/
     background-color: #f5f5f5;
 }
 

Некоторые файлы не были показаны из-за большого количества измененных файлов