* @copyright Copyright (C) 2002-2005 Markus Westphal, * 2006-2008 Malcolm Cowe, 2010 Matteo Lucarelli, * 2010-2012 Uwe Steinmann * @version Release: @package_version@ */ /** * Include parent class */ require_once("class.Bootstrap.php"); /** * Class which outputs the html page for Indexer view * * @category DMS * @package SeedDMS * @author Markus Westphal, Malcolm Cowe, Uwe Steinmann * @copyright Copyright (C) 2002-2005 Markus Westphal, * 2006-2008 Malcolm Cowe, 2010 Matteo Lucarelli, * 2010-2012 Uwe Steinmann * @version Release: @package_version@ */ class SeedDMS_View_Indexer extends SeedDMS_Bootstrap_Style { function js() { /* {{{ */ $dms = $this->params['dms']; $user = $this->params['user']; header('Content-Type: application/javascript'); ?> var queue_count = 0; // Number of functions being called var funcArray = []; // Array of functions waiting var MAX_REQUESTS = 5; // Max requests var CALL_WAIT = 100; // 100ms var docstoindex = 0; // total number of docs to index function check_queue() { // Check if count doesn't exceeds or if there aren't any functions to call console.log('Queue has ' + funcArray.length + '/' + docstoindex + ' items'); console.log('Currently processing ' + queue_count + ' requests (' + $.active + ')'); if(queue_count >= MAX_REQUESTS) { setTimeout(function() { check_queue() }, CALL_WAIT); return; } if(funcArray.length == 0) { return; } docid = funcArray.pop(); $('#status_'+docid).html('Processsing ...'); $.ajax({url: '../op/op.Ajax.php', type: 'GET', dataType: "json", data: {command: 'indexdocument', id: docid}, beforeSend: function() { queue_count++; // Add request to the counter $('.queue-bar').css('width', (queue_count*100/MAX_REQUESTS)+'%'); }, error: function(xhr, textstatus) { noty({ text: textstatus, type: 'error', dismissQueue: true, layout: 'topRight', theme: 'defaultTheme', timeout: 5000, }); }, success: function(data) { // console.log('success ' + data.data); if(data.success) { if(data.cmd) $('#status_'+data.data).html(''); else $('#status_'+data.data).html(''); } else { $('#status_'+data.data).html(''); noty({ text: '

Docid: ' + data.data + ' (' + data.mimetype + ')

' + '

Cmd: ' + data.cmd + '

' + data.message, type: 'error', dismissQueue: true, layout: 'topRight', theme: 'defaultTheme', timeout: 25000, }); } }, complete: function(xhr, textstatus) { queue_count--; // Substract request to the counter $('.queue-bar').css('width', (queue_count*100/MAX_REQUESTS)+'%'); $('.total-bar').css('width', (100 - (funcArray.length+queue_count)*100/docstoindex)+'%'); $('.total-bar').text(Math.round(100 - (funcArray.length+queue_count)*100/docstoindex)+' %'); if(funcArray.length+queue_count == 0) $('.total-bar').addClass('bar-success'); } }); setTimeout(function() { check_queue() }, CALL_WAIT); } $(document).ready( function() { $('.tree-toggle').click(function () { $(this).parent().children('ul.tree').toggle(200); }); $('.indexme').each(function(index) { var element = $(this); var docid = element.data('docid'); element.html(''); funcArray.push(docid); }); docstoindex = funcArray.length; check_queue(); // First call to start polling. It will call itself each 100ms }); params['forceupdate']; set_time_limit(30); // echo $indent."D ".htmlspecialchars($folder->getName())."\n"; echo '\n"; } /* }}} */ function show() { /* {{{ */ $dms = $this->params['dms']; $user = $this->params['user']; $index = $this->params['index']; $indexconf = $this->params['indexconf']; $forceupdate = $this->params['forceupdate']; $folder = $this->params['folder']; $this->converters = $this->params['converters']; $this->timeout = $this->params['timeout']; $this->htmlStartPage(getMLText("admin_tools")); $this->globalNavigation(); $this->contentStart(); $this->pageNavigation(getMLText("admin_tools"), "admin_tools"); $this->contentHeading(getMLText("update_fulltext_index")); ?>
tree($dms, $index, $indexconf, $folder); echo "
"; $index->commit(); $index->optimize(); $this->contentEnd(); $this->htmlEndPage(); } /* }}} */ } ?>