示例#1
0
 public function __construct(\Explorer\Manual\Manual $manual)
 {
     $this->manual = $manual;
     $this->widget = new \GtkHTML();
     $manuals = $manual->getLoadedManuals();
     if (count($manuals)) {
         $index = '<table><tr><th>Title</th><th>Filename</th><th>Files</th></tr>';
         foreach ($manuals as $m) {
             $index .= '<tr><td>' . htmlentities($m['title']) . '</td>' . '<td>' . htmlentities($m['filename']) . '</td>' . '<td>' . count($m['archive']) . '</td></tr>';
         }
         $index .= '</table>';
     } else {
         $index = '<p><b>No Manuals found!</b><p><p>Please place some manuals in <i>' . getcwd() . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . '</i> or configure the manual path in your phpexplorer.ini file and restart the explorer!</p>';
     }
     $this->widget->load_from_string(file_get_contents('data/index.html', FILE_USE_INCLUDE_PATH) . $index);
     $this->widget->show_all();
 }
 public function onFullTextSearchClick()
 {
     if (!$this->manual) {
         // TODO: One might think aobut using an external browser or the online docs...
         $dialog = new \GtkMessageDialog($this->glade->get_widget('mainwindow'), 0, \Gtk::MESSAGE_ERROR, \Gtk::BUTTONS_OK, 'GtkHTML needed');
         $dialog->set_markup('For doing full text searches GtkHTML support is required in your PHP configuration.');
         $dialog->run();
         $dialog->destroy();
         return;
     }
     $input = trim($this->glade->get_widget('searchentry')->get_text());
     if (strlen($input) == 0) {
         $dialog = new \GtkMessageDialog($this->glade->get_widget('mainwindow'), 0, \Gtk::MESSAGE_ERROR, \Gtk::BUTTONS_OK, 'No input');
         $dialog->set_markup('No search term entered');
         $dialog->run();
         $dialog->destroy();
         return;
     }
     $results = $this->manual->searchFulltext($input);
     $store = new \GtkTreeStore(\GObject::TYPE_STRING, \GObject::TYPE_PHP_VALUE);
     foreach ($results as $title => $found) {
         $man_container = $store->append(null, array($title, null));
         $basenamelen = strlen('phar://' . $found->getArchiveFileName());
         echo 'phar://' . $found->getArchiveFileName(), "\n";
         foreach ($found as $item) {
             /** @var $item \SplFileObject */
             $doc = \DomDocument::loadHTMLFile($item->getPathname());
             $caption = $doc->getElementsByTagName('title')->item(0)->firstChild->wholeText;
             $store->append($man_container, array($caption, $item));
         }
     }
     $tree = $this->glade->get_widget('searchtreeview');
     $tree->set_model($store);
     $tree->get_selection()->connect('changed', array($this->mainWindow, 'onSearchResultClick'));
     /* TODO: Move to view  */
     $cell_renderer = new \GtkCellRendererText();
     $colExt = new \GtkTreeViewColumn('', $cell_renderer, 'text', 0);
     $tree->append_column($colExt);
 }