Exemple #1
0
		<div style="clear:both; height:1px;"><!-- empty --></div></div><!-- end pageArea -->
		<div id="footer">
			<?php 
print $this->request->config->get('page_footer_text');
?>
<!-- 
			[<?php 
print $this->request->session->elapsedTime(4) . 's';
?>
/<?php 
print caGetMemoryUsage();
?>
]
			-->
		</div><!-- end footer -->
<?php 
print TooltipManager::getLoadHTML();
?>
	<div id="caMediaPanel"> 
		<div id="close"><a href="#" onclick="caMediaPanel.hidePanel(); return false;">&nbsp;&nbsp;&nbsp;</a></div>
		<div id="caMediaPanelContentArea">
		
		</div>
	</div>
	<script type="text/javascript">
	/*
		Set up the "caMediaPanel" panel that will be triggered by links in object detail
		Note that the actual <div>'s implementing the panel are located here in views/pageFormat/pageFooter.php
	*/
	var caMediaPanel;
	jQuery(document).ready(function() {
 /**
  * Forces a full reindex of all rows in the database or, optionally, a single table
  *
  * @param array $pa_table_names
  * @param array $pa_options Reindexing options:
  *			showProgress
  *			interactiveProgressDisplay
  *			log
  *			callback
  * @return null|false
  */
 public function reindex($pa_table_names = null, $pa_options = null)
 {
     define('__CollectiveAccess_IS_REINDEXING__', 1);
     $t_timer = new Timer();
     $pb_display_progress = isset($pa_options['showProgress']) ? (bool) $pa_options['showProgress'] : true;
     $pb_interactive_display = isset($pa_options['interactiveProgressDisplay']) ? (bool) $pa_options['interactiveProgressDisplay'] : false;
     $ps_callback = isset($pa_options['callback']) ? (string) $pa_options['callback'] : false;
     if ($pa_table_names) {
         if (!is_array($pa_table_names)) {
             $pa_table_names = array($pa_table_names);
         }
         $va_table_names = array();
         foreach ($pa_table_names as $vs_table) {
             if ($this->opo_datamodel->tableExists($vs_table)) {
                 $vn_num = $this->opo_datamodel->getTableNum($vs_table);
                 if ($pb_display_progress) {
                     print "\nTRUNCATING {$vs_table}\n\n";
                 }
                 $this->opo_engine->truncateIndex($vn_num);
                 $t_instance = $this->opo_datamodel->getInstanceByTableName($vs_table, true);
                 $va_table_names[$vn_num] = array('name' => $vs_table, 'num' => $vn_num, 'displayName' => $t_instance->getProperty('NAME_PLURAL'));
             }
         }
         if (!sizeof($va_table_names)) {
             return false;
         }
     } else {
         // full reindex
         $this->opo_engine->truncateIndex();
         $va_table_names = $this->getIndexedTables();
     }
     $o_db = $this->opo_db;
     if ($pb_display_progress || $ps_callback) {
         $va_names = array();
         foreach ($va_table_names as $vn_table_num => $va_table_info) {
             $va_names[] = $va_table_info['displayName'];
         }
         if ($pb_display_progress) {
             print "\nWILL INDEX [" . join(", ", $va_names) . "]\n\n";
         }
     }
     $vn_tc = 0;
     foreach ($va_table_names as $vn_table_num => $va_table_info) {
         $vs_table = $va_table_info['name'];
         $t_table_timer = new Timer();
         $t_instance = $this->opo_datamodel->getInstanceByTableName($vs_table, true);
         $vs_table_pk = $t_instance->primaryKey();
         $vn_table_num = $t_instance->tableNum();
         $va_fields_to_index = $this->getFieldsToIndex($vn_table_num);
         if (!is_array($va_fields_to_index) || sizeof($va_fields_to_index) == 0) {
             continue;
         }
         $qr_all = $o_db->query("SELECT " . $t_instance->primaryKey() . " FROM {$vs_table}");
         $vn_num_rows = $qr_all->numRows();
         if ($pb_display_progress) {
             print CLIProgressBar::start($vn_num_rows, _t('Indexing %1', $t_instance->getProperty('NAME_PLURAL')));
         }
         $vn_c = 0;
         $va_ids = $qr_all->getAllFieldValues($t_instance->primaryKey());
         $va_element_ids = null;
         if (method_exists($t_instance, "getApplicableElementCodes")) {
             $va_element_ids = array_keys($t_instance->getApplicableElementCodes(null, false, false));
         }
         $vn_table_num = $t_instance->tableNum();
         $vs_table_pk = $t_instance->primaryKey();
         $va_field_data = array();
         $va_intrinsic_list = $this->getFieldsToIndex($vs_table, $vs_table, array('intrinsicOnly' => true));
         $va_intrinsic_list[$vs_table_pk] = array();
         foreach ($va_ids as $vn_i => $vn_id) {
             if (!($vn_i % 200)) {
                 // Pre-load attribute values for next 200 items to index; improves index performance
                 $va_id_slice = array_slice($va_ids, $vn_i, 200);
                 if ($va_element_ids) {
                     ca_attributes::prefetchAttributes($o_db, $vn_table_num, $va_id_slice, $va_element_ids);
                 }
                 $qr_field_data = $o_db->query("\n\t\t\t\t\t\tSELECT " . join(", ", array_keys($va_intrinsic_list)) . " \n\t\t\t\t\t\tFROM {$vs_table}\n\t\t\t\t\t\tWHERE {$vs_table_pk} IN (?)\t\n\t\t\t\t\t", array($va_id_slice));
                 $va_field_data = array();
                 while ($qr_field_data->nextRow()) {
                     $va_field_data[(int) $qr_field_data->get($vs_table_pk)] = $qr_field_data->getRow();
                 }
             }
             $this->indexRow($vn_table_num, $vn_id, $va_field_data[$vn_id], true, null, array(), array());
             if ($pb_display_progress && $pb_interactive_display) {
                 CLIProgressBar::setMessage("Memory: " . caGetMemoryUsage());
                 print CLIProgressBar::next();
             }
             if ($ps_callback && !($vn_c % 100)) {
                 $ps_callback($vn_c, $vn_num_rows, null, null, (double) $t_timer->getTime(2), memory_get_usage(true), $va_table_names, $vn_table_num, $t_instance->getProperty('NAME_PLURAL'), $vn_tc + 1);
             }
             $vn_c++;
         }
         $qr_all->free();
         unset($t_instance);
         if ($pb_display_progress && $pb_interactive_display) {
             print CLIProgressBar::finish();
         }
         $this->opo_engine->optimizeIndex($vn_table_num);
         $vn_tc++;
     }
     if ($pb_display_progress) {
         print "\n\n\nDone! [Indexing for " . join(", ", $va_names) . " took " . caFormatInterval((double) $t_timer->getTime(4)) . "]\n";
         print "Note that if you're using an external search service like Apache Solr, the data may only now be sent to the actual service because it was buffered until now. So you still might have to wait a while for the script to finish.\n";
     }
     if ($ps_callback) {
         $ps_callback(1, 1, _t('Elapsed time: %1', caFormatInterval((double) $t_timer->getTime(2))), _t('Index rebuild complete!'), (double) $t_timer->getTime(2), memory_get_usage(true), $va_table_names, null, null, sizeof($va_table_names));
     }
 }