本文整理汇总了PHP中caFormatInterval函数的典型用法代码示例。如果您正苦于以下问题:PHP caFormatInterval函数的具体用法?PHP caFormatInterval怎么用?PHP caFormatInterval使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了caFormatInterval函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: caIncrementHierachicalReindexProgress
function caIncrementHierachicalReindexProgress($ps_table_message, $pn_elapsed_time, $pn_memory_used, $pa_table_list, $pn_table_num, $ps_display_name, $pn_tables_processed)
{
if (is_null($ps_table_message)) {
$ps_table_message = _t('Indexing %1 (%2/%3)', $ps_display_name, $pn_tables_processed, sizeof($pa_table_list));
}
$pn_table_percentage = $pn_tables_processed / sizeof($pa_table_list) * 100;
print "<script type='text/javascript'>";
print "jQuery('#progressbarTables').progressbar('value',{$pn_table_percentage}); jQuery('#searchReindexTableStatus').html('{$ps_table_message}');";
print "jQuery('#searchReindexElapsedTime').html('" . caFormatInterval($pn_elapsed_time) . "/" . sprintf("%4.2f mb", $pn_memory_used / 1048576) . "');";
print "</script>";
caFlushOutput();
}
示例2: caIncrementBatchEditorProgress
function caIncrementBatchEditorProgress($po_request, $pn_rows_complete, $pn_total_rows, $ps_message, $pn_elapsed_time, $pn_memory_used, $pn_num_processed, $pn_num_errors)
{
$pn_percentage = $pn_rows_complete / $pn_total_rows * 100;
if (is_null($ps_message)) {
$ps_message = _t('Processed %1/%2', $pn_rows_complete, $pn_total_rows);
}
$ps_message = addslashes($ps_message);
print "<script type='text/javascript'>";
print "jQuery('#progressbar').progressbar('value',{$pn_percentage}); jQuery('#batchProcessingTableStatus').html('{$ps_message}');";
print "jQuery('#batchProcessingElapsedTime').html('" . caFormatInterval($pn_elapsed_time) . "/" . sprintf("%4.2f mb", $pn_memory_used / 1048576) . "');";
print "jQuery('#batchProcessingCounts').html('" . addslashes(_t("%1 processed; %2 errors", $pn_num_processed, $pn_num_errors)) . "');";
print "</script>";
caFlushOutput();
}
示例3: caIncrementSortValueReloadProgress
function caIncrementSortValueReloadProgress($pn_rows_complete, $pn_total_rows, $ps_row_message, $ps_table_message, $pn_elapsed_time, $pn_memory_used, $pa_table_list, $pn_table_num, $ps_display_name, $pn_tables_processed)
{
$pn_percentage = $pn_rows_complete / $pn_total_rows * 100;
if (is_null($ps_row_message)) {
$ps_row_message = _t('Reloading %1/%2', $pn_rows_complete, $pn_total_rows);
}
if (is_null($ps_table_message)) {
$ps_table_message = _t('Reloading sort values for %1 (%2/%3)', $ps_display_name, $pn_tables_processed, sizeof($pa_table_list));
}
$pn_table_percentage = $pn_tables_processed / sizeof($pa_table_list) * 100;
print "<script type='text/javascript'>";
print "jQuery('#progressbarTables').progressbar('value',{$pn_table_percentage}); jQuery('#searchReindexTableStatus').html('{$ps_table_message}');";
print "jQuery('#progressbarRows').progressbar('value',{$pn_percentage}); jQuery('#searchReindexRowStatus').html('{$ps_row_message}');";
print "jQuery('#searchReindexElapsedTime').html('" . caFormatInterval($pn_elapsed_time) . "/" . sprintf("%4.2f mb", $pn_memory_used / 1048576) . "');";
print "</script>";
caFlushOutput();
}
示例4: caGetRepresentationDimensionsForDisplay
/**
* Returns text describing dimensions of object representation
*
* @param DbResult or ca_object_representations instance $po_rep An object containing representation data. Can be either a DbResult object (ie. a query result) or ca_object_representations instance (an instance representing a row in the ca_object_representation class)
* @param string $ps_version the name of the media version to return dimensions information for
* @param array $pa_options Array of options, including:
* returnAsArray = if set an array with elements of the dimensions display text is returned
* @return mixed Text ready for display describing dimensions of the representation's media. Can be array if 'returnAsArray' option is set.
*/
function caGetRepresentationDimensionsForDisplay($po_rep, $ps_version, $pa_options = null)
{
$va_tmp = $po_rep->getMediaInfo('media', $ps_version);
$va_dimensions = array();
if (isset($va_tmp['WIDTH']) && isset($va_tmp['HEIGHT'])) {
if (($vn_w = $va_tmp['WIDTH']) && ($vn_h = $va_tmp['HEIGHT'])) {
$va_dimensions[] = $va_tmp['WIDTH'] . 'p x ' . $va_tmp['HEIGHT'] . 'p';
}
}
if (isset($va_tmp['PROPERTIES']['bitdepth']) && ($vn_depth = $va_tmp['PROPERTIES']['bitdepth'])) {
$va_dimensions[] = intval($vn_depth) . ' bpp';
}
if (isset($va_tmp['PROPERTIES']['colorspace']) && ($vs_colorspace = $va_tmp['PROPERTIES']['colorspace'])) {
$va_dimensions[] = $vs_colorspace;
}
if (isset($va_tmp['PROPERTIES']['resolution']) && is_array($va_resolution = $va_tmp['PROPERTIES']['resolution'])) {
if (isset($va_resolution['x']) && isset($va_resolution['y']) && $va_resolution['x'] && $va_resolution['y']) {
// TODO: units for resolution? right now assume pixels per inch
if ($va_resolution['x'] == $va_resolution['y']) {
$va_dimensions[] = $va_resolution['x'] . 'ppi';
} else {
$va_dimensions[] = $va_resolution['x'] . 'x' . $va_resolution['y'] . 'ppi';
}
}
}
if (isset($va_tmp['PROPERTIES']['duration']) && ($vn_duration = $va_tmp['PROPERTIES']['duration'])) {
$va_dimensions[] = caFormatInterval($vn_duration);
}
if (isset($va_tmp['PROPERTIES']['pages']) && ($vn_pages = $va_tmp['PROPERTIES']['pages'])) {
$va_dimensions[] = $vn_pages . ' ' . ($vn_pages == 1 ? _t('page') : _t('pages'));
}
if (!isset($va_tmp['PROPERTIES']['filesize']) || !($vn_filesize = $va_tmp['PROPERTIES']['filesize'])) {
$vn_filesize = @filesize($po_rep->getMediaPath('media', $ps_version));
}
if ($vn_filesize) {
$va_dimensions[] = caFormatFileSize($vn_filesize);
}
if (isset($pa_options['returnAsArray']) && $pa_options['returnAsArray']) {
return $va_dimensions;
}
return join('; ', $va_dimensions);
}
示例5: reindex
/**
* Forces a full reindex of all rows in the database or, optionally, a single table
*
* @param array $pa_table_name
* @param array $pa_options Reindexing options:
* showProgress
* interactiveProgressDisplay
* log
* callback
*/
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);
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();
$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;
while ($qr_all->nextRow()) {
$t_instance->load($qr_all->get($t_instance->primaryKey()));
$t_instance->doSearchIndexing(array(), true, $this->opo_engine->engineName());
if ($pb_display_progress && $pb_interactive_display) {
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";
}
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));
}
}
示例6: GetJobStatus
/**
* Return via Ajax current status of running tool job
*/
public function GetJobStatus()
{
if (!$this->request->isLoggedIn() || !$this->request->user->canDoAction('can_use_plugin_tools')) {
$this->response->setRedirect($this->request->config->get('error_display_url') . '/n/3500?r=' . urlencode($this->request->getFullUrlPath()));
return;
}
$ps_job_id = $this->request->getParameter('job_id', pString);
$o_progress = new ProgressBar('WebUI', null, $ps_job_id);
$va_data = $o_progress->getDataForJobID();
$va_data['elapsedTime'] = caFormatInterval(time() - $va_data['start']);
$this->view->setVar('jobinfo', $va_data);
$this->render('tools/tool_runjob_json.php');
}
示例7: dispatchLoopShutdown
public function dispatchLoopShutdown()
{
//
// Force output to be sent - we need the client to have the page before
// we start flushing progress bar updates
//
$app = AppController::getInstance();
$req = $app->getRequest();
$resp = $app->getResponse();
$resp->sendResponse();
$resp->clearContent();
//
// Do reindexing
//
if ($req->isLoggedIn() && $req->user->canDoAction('can_do_search_reindex')) {
set_time_limit(3600 * 8);
$o_db = new Db();
$t_timer = new Timer();
$va_table_names = array('ca_objects', 'ca_object_lots', 'ca_places', 'ca_entities', 'ca_occurrences', 'ca_collections', 'ca_storage_locations', 'ca_object_representations', 'ca_representation_annotations', 'ca_lists', 'ca_list_items', 'ca_loans', 'ca_movements', 'ca_tours', 'ca_tour_stops');
$vn_tc = 0;
foreach ($va_table_names as $vs_table) {
require_once __CA_MODELS_DIR__ . "/{$vs_table}.php";
$t_table = new $vs_table();
$vs_pk = $t_table->primaryKey();
$qr_res = $o_db->query("SELECT {$vs_pk} FROM {$vs_table}");
if ($vs_label_table_name = $t_table->getLabelTableName()) {
require_once __CA_MODELS_DIR__ . "/{$vs_label_table_name}.php";
$va_table_names[] = $vs_label_table_name;
$t_label = new $vs_label_table_name();
$vs_label_pk = $t_label->primaryKey();
$qr_labels = $o_db->query("SELECT {$vs_label_pk} FROM {$vs_label_table_name}");
$vn_c = 0;
$vn_num_rows = $qr_labels->numRows();
$vn_table_num = $t_label->tableNum();
while ($qr_labels->nextRow()) {
$vn_label_pk_val = $qr_labels->get($vs_label_pk);
if (!($vn_c % 100)) {
caIncrementSortValueReloadProgress($vn_c, $vn_num_rows, null, null, $t_timer->getTime(2), memory_get_usage(true), $va_table_names, $vn_table_num, $t_label->getProperty('NAME_PLURAL'), $vn_tc + 1);
}
if ($t_label->load($vn_label_pk_val)) {
$t_label->setMode(ACCESS_WRITE);
$t_label->update();
}
$vn_c++;
}
$vn_tc++;
}
$vn_table_num = $t_table->tableNum();
$vn_num_rows = $qr_res->numRows();
$vn_c = 0;
while ($qr_res->nextRow()) {
$vn_pk_val = $qr_res->get($vs_pk);
if (!($vn_c % 100)) {
caIncrementSortValueReloadProgress($vn_c, $vn_num_rows, null, null, $t_timer->getTime(2), memory_get_usage(true), $va_table_names, $vn_table_num, $t_table->getProperty('NAME_PLURAL'), $vn_tc + 1);
}
if ($t_table->load($vn_pk_val)) {
$t_table->setMode(ACCESS_WRITE);
if ($vs_table == 'ca_object_representations') {
$t_table->set('md5', $t_table->getMediaInfo('ca_object_representations.media', 'original', 'MD5'));
$t_table->set('mimetype', $t_table->getMediaInfo('ca_object_representations.media', 'original', 'MIMETYPE'));
$va_media_info = $t_table->getMediaInfo('ca_object_representations.media');
$t_table->set('original_filename', $va_media_info['ORIGINAL_FILENAME']);
}
$t_table->update();
if ($vs_table == 'ca_object_representations') {
if (!$t_table->getPreferredLabelCount()) {
$t_table->addLabel(array('name' => trim($va_media_info['ORIGINAL_FILENAME']) ? $va_media_info['ORIGINAL_FILENAME'] : _t('Representation')), $pn_locale_id, null, true);
}
}
}
$vn_c++;
}
$vn_tc++;
}
caIncrementSortValueReloadProgress(1, 1, _t('Elapsed time: %1', caFormatInterval($t_timer->getTime(2))), _t('Index rebuild complete!'), $t_timer->getTime(2), memory_get_usage(true), $va_table_names, null, null, sizeof($va_table_names));
}
}
示例8: reindex
//.........这里部分代码省略.........
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));
}
}
示例9: getItemInfo
/**
*
*/
public function getItemInfo()
{
$ps_search = str_replace('"', '', $this->request->getParameter('search', pString));
$va_values = array();
$t_item = new ca_commerce_order_items();
$o_search = new ObjectSearch();
$qr_res = $o_search->search("ca_objects.idno:\"{$ps_search}\"");
if (!$qr_res->numHits()) {
$qr_res = $o_search->search($ps_search);
}
$va_object_ids = array();
while ($qr_res->nextHit()) {
$va_object_ids[] = (int) $qr_res->get('ca_objects.object_id');
}
$va_items = array('search' => $ps_search, 'matches' => array());
if (sizeof($va_object_ids)) {
$o_db = new Db();
$qr_items = $o_db->query("\n\t\t\t\t\tSELECT i.item_id, o.order_id\n\t\t\t\t\tFROM ca_commerce_order_items i\n\t\t\t\t\tINNER JOIN ca_commerce_orders AS o ON o.order_id = i.order_id\n\t\t\t\t\tWHERE\n\t\t\t\t\t\tobject_id IN (?) AND o.order_type = 'L' AND i.loan_return_date IS NULL\n\t\t\t\t", array($va_object_ids));
while ($qr_items->nextRow()) {
$t_item = new ca_commerce_order_items($qr_items->get('item_id'));
$t_order = $t_item->getOrder();
$va_values = $t_item->getFieldValuesArray();
$va_values['user'] = $t_order->getOrderTransactionUserName();
// get object label
$t_object = $t_item->getItemObject();
$va_values['object'] = $t_object->get('ca_objects.preferred_labels.name');
$va_values['idno'] = $t_object->get('ca_objects.idno');
// generate display dates
$va_values['loan_checkout_date_raw'] = $va_values['loan_checkout_date'];
$va_values['loan_checkout_date'] = caGetLocalizedDate($va_values['loan_checkout_date'], array('dateFormat' => 'delimited', 'timeOmit' => true));
$va_values['loan_due_date_raw'] = $va_values['loan_due_date'];
$va_values['loan_due_date'] = caGetLocalizedDate($va_values['loan_due_date'], array('dateFormat' => 'delimited', 'timeOmit' => true));
if ($va_values['loan_due_date_raw'] < time()) {
$va_values['loan_due_date'] .= " (<em>" . _t("Overdue by %1", caFormatInterval(time() - $va_values['loan_due_date_raw'], 2)) . "</em>)";
}
$va_values['order_number'] = $t_order->getOrderNumber();
$va_rep = $t_object->getPrimaryRepresentation(array('thumbnail'));
$va_values['thumbnail_tag'] = $va_rep['tags']['thumbnail'];
$va_items['matches'][] = $va_values;
}
}
$this->view->setVar('items', $va_items);
return $this->render('ajax_order_item_info_json.php');
}
示例10: getOrders
//.........这里部分代码省略.........
if (isset($pa_options['loan_return_date']) && strlen($pa_options['loan_return_date'])) {
if (is_array($va_dates = caDateToUnixTimestamps($pa_options['loan_return_date']))) {
$va_sql_wheres[] = "(i.loan_return_date BETWEEN ? AND ?)";
$va_sql_values[] = (double) $va_dates['start'];
$va_sql_values[] = (double) $va_dates['end'];
}
}
if (isset($pa_options['shipping_date']) && strlen($pa_options['shipping_date'])) {
$o_tep = new TimeExpressionParser();
if ($o_tep->parse($pa_options['shipping_date'])) {
$va_dates = $o_tep->getUnixTimestamps();
$va_sql_wheres[] = "(o.shipping_date BETWEEN ? AND ?)";
$va_sql_values[] = (double) $va_dates['start'];
$va_sql_values[] = (double) $va_dates['end'];
}
}
if (isset($pa_options['shipped_on_date']) && strlen($pa_options['shipped_on_date'])) {
$o_tep = new TimeExpressionParser();
if ($o_tep->parse($pa_options['shipped_on_date'])) {
$va_dates = $o_tep->getUnixTimestamps();
$va_sql_wheres[] = "(o.shipped_on_date BETWEEN ? AND ?)";
$va_sql_values[] = (double) $va_dates['start'];
$va_sql_values[] = (double) $va_dates['end'];
}
}
if (isset($pa_options['search']) && strlen($pa_options['search'])) {
$o_search = new CommerceOrderSearch();
if ($qr_hits = $o_search->search($pa_options['search'])) {
$va_ids = array();
while ($qr_hits->nextHit()) {
$va_ids[] = $qr_hits->get('order_id');
}
if (sizeof($va_ids)) {
$va_sql_wheres[] = "(o.order_id IN (?))";
$va_sql_values[] = $va_ids;
} else {
$va_sql_wheres[] = "(o.order_id = 0)";
}
}
}
$vs_sql_wheres = '';
if (sizeof($va_sql_wheres)) {
$vs_sql_wheres = " AND " . join(" AND ", $va_sql_wheres);
}
// Get item additional fees
$qr_res = $o_db->query($vs_sql = "\n\t \t\tSELECT \n\t \t\t\to.order_id, i.item_id, i.additional_fees\n\t \t\tFROM ca_commerce_orders o\n\t \t\tLEFT JOIN ca_commerce_order_items AS i ON o.order_id = i.order_id\n\t \t\t" . ($vb_join_transactions ? "INNER JOIN ca_commerce_transactions AS t ON t.transaction_id = o.transaction_id" : "") . "\n\t \t\tWHERE\n\t \t\t\to.deleted = 0 {$vs_sql_wheres}\n\t \t\t\t\n\t \t", $va_sql_values);
$va_additional_fee_codes = $this->opo_client_services_config->getAssoc($this->get('order_type') == 'L' ? 'additional_loan_fees' : 'additional_order_item_fees');
$va_order_item_additional_fees = array();
while ($qr_res->nextRow()) {
$va_fees = caUnserializeForDatabase($qr_res->get('additional_fees'));
$vn_fee_total = 0;
foreach ($va_additional_fee_codes as $vs_code => $va_info) {
if (isset($va_fees[$vs_code])) {
$vn_fee_total += (double) $va_fees[$vs_code];
}
}
$va_order_item_additional_fees[$qr_res->get('order_id')] += $vn_fee_total;
}
// Get overdue items (only if type is set to [L]oan)
if (isset($pa_options['type']) && $pa_options['type'] == 'L') {
$qr_res = $o_db->query("\n\t\t\t\tSELECT \n\t\t\t\t\to.order_id, \n\t\t\t\t\tmin(i.loan_checkout_date) loan_checkout_date, min(i.loan_due_date) loan_due_date\n\t\t\t\tFROM ca_commerce_orders o\n\t\t\t\tINNER JOIN ca_commerce_order_items AS i ON o.order_id = i.order_id\n\t \t\t\t" . ($vb_join_transactions ? "INNER JOIN ca_commerce_transactions AS t ON t.transaction_id = o.transaction_id" : "") . "\n\t\t\t\tWHERE\n\t\t\t\t\to.deleted = 0 AND i.loan_return_date IS NULL\n\t\t\t\t\t{$vs_sql_wheres}\n\t\t\t\tGROUP BY o.order_id\n\t\t\t\t\t\n\t\t\t", $va_sql_values);
$va_due_dates = $va_overdue_dates = array();
$vn_t = time();
while ($qr_res->nextRow()) {
$vn_due_date = $qr_res->get('loan_due_date');
if ($vn_due_date > $vn_t) {
$va_due_dates[$qr_res->get('order_id')] = caFormatInterval($vn_due_date - $vn_t, 2);
} else {
$va_overdue_dates[$qr_res->get('order_id')] = caFormatInterval($vn_t - $vn_due_date, 2);
}
}
}
// Get item totals
$qr_res = $o_db->query($vs_sql = "\n\t \t\tSELECT \n\t \t\t\to.*, \n\t \t\t\tsum(i.fee) order_total_item_fees, \n\t \t\t\tsum(i.tax) order_total_item_tax, \n\t \t\t\t((o.shipping_cost) + (i.shipping_cost)) order_total_shipping, \n\t \t\t\t((o.handling_cost) + (i.handling_cost)) order_total_handling, \n\t \t\t\tcount(*) num_items, \n\t \t\t\tmin(i.loan_checkout_date) loan_checkout_date_start, min(i.loan_due_date) loan_due_date_start, min(i.loan_return_date) loan_return_date_start,\n\t \t\t\tmax(i.loan_checkout_date) loan_checkout_date_end, max(i.loan_due_date) loan_due_date_end, max(i.loan_return_date) loan_return_date_end\n\t \t\tFROM ca_commerce_orders o\n\t \t\tLEFT JOIN ca_commerce_order_items AS i ON o.order_id = i.order_id\n\t \t\t" . ($vb_join_transactions ? "INNER JOIN ca_commerce_transactions AS t ON t.transaction_id = o.transaction_id" : "") . "\n\t \t\tWHERE\n\t \t\t\to.deleted = 0 {$vs_sql_wheres}\n\t \t\tGROUP BY o.order_id\n\t \t\tORDER BY\n\t \t\t\to.created_on DESC\n\t \t\t\t\n\t \t", $va_sql_values);
//print $vs_sql."; ".print_r($va_sql_values, true);
$va_orders = array();
while ($qr_res->nextRow()) {
$va_order = $qr_res->getRow();
$va_order['order_number'] = date('mdY', $va_order['created_on']) . '-' . $va_order['order_id'];
// order additional fees
$vn_additional_order_fees = 0;
if (is_array($va_additional_fees = caUnserializeForDatabase($va_order['additional_fees']))) {
foreach ($va_additional_fees as $vs_code => $vn_fee) {
$vn_additional_order_fees += $vn_fee;
}
}
$va_order['order_total'] = $va_order['order_total_item_fees'] + $va_order['order_total_item_tax'] + $va_order['order_total_shipping'] + $va_order['order_total_handling'] + $vn_additional_order_fees + (double) $va_order_item_additional_fees[$qr_res->get('order_id')];
if (isset($va_overdue_dates[$va_order['order_id']])) {
$va_order['is_overdue'] = true;
$va_order['overdue_period'] = $va_overdue_dates[$va_order['order_id']];
} else {
if (isset($va_due_dates[$va_order['order_id']])) {
$va_order['is_overdue'] = false;
$va_order['due_period'] = $va_due_dates[$va_order['order_id']];
}
}
$va_orders[] = $va_order;
}
return $va_orders;
}
示例11: importMetadata
/**
* Import metadata using a mapping
*
* @param RequestHTTP $po_request The current request
* @param string $ps_source A path to a file or directory of files to import
* @param string $ps_importer The code of the importer (mapping) to use
* @param string $ps_input_format The format of the source data
* @param array $pa_options
* progressCallback =
* reportCallback =
* sendMail =
* dryRun =
* importAllDatasets =
* log = log directory path
* logLevel = KLogger constant for minimum log level to record. Default is KLogger::INFO. Constants are, in descending order of shrillness:
* KLogger::EMERG = Emergency messages (system is unusable)
* KLogger::ALERT = Alert messages (action must be taken immediately)
* KLogger::CRIT = Critical conditions
* KLogger::ERR = Error conditions
* KLogger::WARN = Warnings
* KLogger::NOTICE = Notices (normal but significant conditions)
* KLogger::INFO = Informational messages
* KLogger::DEBUG = Debugging messages
*/
public static function importMetadata($po_request, $ps_source, $ps_importer, $ps_input_format, $pa_options = null)
{
$va_errors = $va_noticed = array();
$vn_start_time = time();
$o_config = Configuration::load();
if (!ca_data_importers::mappingExists($ps_importer)) {
$va_errors['general'] = array('idno' => "*", 'label' => "*", 'errors' => array(_t('Importer %1 does not exist', $ps_importer)), 'status' => 'ERROR');
return false;
}
$vs_log_dir = caGetOption('log', $pa_options, null);
$vs_log_level = caGetOption('logLevel', $pa_options, "INFO");
$vb_import_all_datasets = caGetOption('importAllDatasets', $pa_options, false);
$vb_dry_run = caGetOption('dryRun', $pa_options, false);
$vn_log_level = BatchProcessor::_logLevelStringToNumber($vs_log_level);
if (!isURL($ps_source) && is_dir($ps_source)) {
$va_sources = caGetDirectoryContentsAsList($ps_source, true, false, false, false);
} else {
$va_sources = array($ps_source);
}
$vn_file_num = 0;
foreach ($va_sources as $vs_source) {
$vn_file_num++;
if (!ca_data_importers::importDataFromSource($vs_source, $ps_importer, array('fileNumber' => $vn_file_num, 'numberOfFiles' => sizeof($va_sources), 'logDirectory' => $o_config->get('batch_metadata_import_log_directory'), 'request' => $po_request, 'format' => $ps_input_format, 'showCLIProgressBar' => false, 'useNcurses' => false, 'progressCallback' => isset($pa_options['progressCallback']) ? $pa_options['progressCallback'] : null, 'reportCallback' => isset($pa_options['reportCallback']) ? $pa_options['reportCallback'] : null, 'logDirectory' => $vs_log_dir, 'logLevel' => $vn_log_level, 'dryRun' => $vb_dry_run, 'importAllDatasets' => $vb_import_all_datasets))) {
$va_errors['general'][] = array('idno' => "*", 'label' => "*", 'errors' => array(_t("Could not import source %1", $ps_source)), 'status' => 'ERROR');
return false;
} else {
$va_notices['general'][] = array('idno' => "*", 'label' => "*", 'errors' => array(_t("Imported data from source %1", $ps_source)), 'status' => 'SUCCESS');
//return true;
}
}
$vn_elapsed_time = time() - $vn_start_time;
if (isset($pa_options['sendMail']) && $pa_options['sendMail']) {
if ($vs_email = trim($po_request->user->get('email'))) {
caSendMessageUsingView($po_request, array($vs_email => $po_request->user->get('fname') . ' ' . $po_request->user->get('lname')), __CA_ADMIN_EMAIL__, _t('[%1] Batch metadata import completed', $po_request->config->get('app_display_name')), 'batch_metadata_import_completed.tpl', array('notices' => $va_notices, 'errors' => $va_errors, 'numErrors' => sizeof($va_errors), 'numProcessed' => sizeof($va_notices), 'subjectNameSingular' => _t('row'), 'subjectNamePlural' => _t('rows'), 'startedOn' => caGetLocalizedDate($vn_start_time), 'completedOn' => caGetLocalizedDate(time()), 'elapsedTime' => caFormatInterval($vn_elapsed_time)));
}
}
if (isset($pa_options['sendSMS']) && $pa_options['sendSMS']) {
SMS::send($po_request->getUserID(), _t("[%1] Metadata import processing for begun at %2 is complete", $po_request->config->get('app_display_name'), caGetLocalizedDate($vn_start_time)));
}
return array('errors' => $va_errors, 'notices' => $va_notices, 'processing_time' => caFormatInterval($vn_elapsed_time));
}
示例12: importMetadata
/**
* @param array $pa_options
* progressCallback =
* reportCallback =
* sendMail =
* log = log directory path
* logLevel = KLogger loglevel. Default is "INFO"
*/
public static function importMetadata($po_request, $ps_source, $ps_importer, $ps_input_format, $pa_options = null)
{
$va_errors = $va_noticed = array();
$vn_start_time = time();
$o_config = Configuration::load();
if (!ca_data_importers::mappingExists($ps_importer)) {
$va_errors['general'] = array('idno' => "*", 'label' => "*", 'errors' => array(_t('Importer %1 does not exist', $ps_importer)), 'status' => 'ERROR');
return false;
}
$vs_log_dir = isset($pa_options['log']) ? $pa_options['log'] : null;
$vn_log_level = KLogger::INFO;
switch ($vs_log_level = isset($pa_options['logLevel']) ? $pa_options['logLevel'] : "INFO") {
case 'DEBUG':
$vn_log_level = KLogger::DEBUG;
break;
case 'NOTICE':
$vn_log_level = KLogger::NOTICE;
break;
case 'WARN':
$vn_log_level = KLogger::WARN;
break;
case 'ERR':
$vn_log_level = KLogger::ERR;
break;
case 'CRIT':
$vn_log_level = KLogger::CRIT;
break;
case 'ALERT':
$vn_log_level = KLogger::ALERT;
break;
default:
case 'INFO':
$vn_log_level = KLogger::INFO;
break;
}
if (!ca_data_importers::importDataFromSource($ps_source, $ps_importer, array('logDirectory' => $o_config->get('batch_metadata_import_log_directory'), 'request' => $po_request, 'format' => $ps_input_format, 'showCLIProgressBar' => false, 'useNcurses' => false, 'progressCallback' => isset($pa_options['progressCallback']) ? $pa_options['progressCallback'] : null, 'reportCallback' => isset($pa_options['reportCallback']) ? $pa_options['reportCallback'] : null, 'logDirectory' => $vs_log_dir, 'logLevel' => $vn_log_level))) {
$va_errors['general'] = array('idno' => "*", 'label' => "*", 'errors' => array(_t("Could not import source %1", $vs_data_source)), 'status' => 'ERROR');
return false;
} else {
$va_notices['general'] = array('idno' => "*", 'label' => "*", 'errors' => array(_t("Imported data from source %1", $vs_data_source)), 'status' => 'SUCCESS');
//return true;
}
$vn_elapsed_time = time() - $vn_start_time;
if (isset($pa_options['sendMail']) && $pa_options['sendMail']) {
if ($vs_email = trim($po_request->user->get('email'))) {
caSendMessageUsingView($po_request, array($vs_email => $po_request->user->get('fname') . ' ' . $po_request->user->get('lname')), __CA_ADMIN_EMAIL__, _t('[%1] Batch metadata import completed', $po_request->config->get('app_display_name')), 'batch_metadata_import_completed.tpl', array('notices' => $va_notices, 'errors' => $va_errors, 'numErrors' => sizeof($va_errors), 'numProcessed' => sizeof($va_notices), 'subjectNameSingular' => _t('row'), 'subjectNamePlural' => _t('rows'), 'startedOn' => $vs_started_on, 'completedOn' => caGetLocalizedDate(time()), 'elapsedTime' => caFormatInterval($vn_elapsed_time)));
}
}
if (isset($pa_options['sendSMS']) && $pa_options['sendSMS']) {
SMS::send($po_request->getUserID(), _t("[%1] Metadata import processing for begun at %2 is complete", $po_request->config->get('app_display_name'), $vs_started_on));
}
return array('errors' => $va_errors, 'notices' => $va_notices, 'processing_time' => caFormatInterval($vn_elapsed_time));
}
示例13: GetImportStatus
/**
* Return via Ajax current status of running import job
*/
public function GetImportStatus()
{
if (!$this->request->user->canDoAction('can_import_worldcat')) {
return;
}
$ps_job_id = $this->request->getParameter('job_id', pString);
$o_progress = new ProgressBar('WebUI', null, $ps_job_id);
$va_data = $o_progress->getDataForJobID();
$va_data['elapsedTime'] = caFormatInterval(time() - $va_data['start']);
$this->view->setVar('info', $va_data);
$this->render('import_run_json.php');
}
示例14: caLoadULAN
//.........这里部分代码省略.........
switch ($o_xml->nodeType) {
case XMLReader::ELEMENT:
$o_xml->read();
$va_subject['related_subjects'][] = $o_xml->value;
break;
}
break;
# ---------------------------
}
}
$o_xml->close();
}
$o_log->logInfo("Begin linking ULAN terms in hierarchy");
print "\n\nLINKING TERMS IN HIERARCHY...\n";
$vn_last_message_length = 0;
$t_list = new ca_lists();
$t_item = new ca_list_items();
$t_item->setMode(ACCESS_WRITE);
$vn_list_root_id = $t_list->getRootListItemID($vn_list_id);
foreach ($va_parent_child_links as $vs_child_id => $vs_parent_id) {
print str_repeat(chr(8), $vn_last_message_length);
$vs_message = "\tLINKING {$vs_child_id} to parent {$vs_parent_id}";
if (($vn_l = 100 - strlen($vs_message)) < 1) {
$vn_l = 1;
}
$vs_message .= str_repeat(' ', $vn_l);
$vn_last_message_length = strlen($vs_message);
print $vs_message;
if (in_array($vs_parent_id, array('500000000', '500000001'))) {
if (!$t_item->load($vn_child_item_id)) {
$o_log->logError("Could not load item for {$vs_child_id} (was translated to item_id={$vn_child_item_id})");
continue;
}
$t_item->set('parent_id', $vn_list_root_id);
$t_item->update(array('dontCheckCircularReferences' => true, 'dontSetHierarchicalIndexing' => true));
if ($t_item->numErrors()) {
$o_log->logError("Could not set parent_id for {$vs_child_id} to root): " . join('; ', $t_item->getErrors()));
continue;
}
$va_ulan_id_to_item_id[$vs_parent_id] = $vn_list_root_id;
}
if (!($vn_child_item_id = $va_ulan_id_to_item_id[$vs_child_id])) {
$o_log->logError("No list item id for child_id {$vs_child_id} (were there previous errors?)");
continue;
}
if (!($vn_parent_item_id = $va_ulan_id_to_item_id[$vs_parent_id])) {
$o_log->logError("No list item id for parent_id {$vs_parent_id} (were there previous errors?)");
continue;
}
if (!$t_item->load($vn_child_item_id)) {
$o_log->logError("Could not load item for {$vs_child_id} (was translated to item_id={$vn_child_item_id})");
continue;
}
$t_item->set('parent_id', $vn_parent_item_id);
$t_item->update(array('dontCheckCircularReferences' => true, 'dontSetHierarchicalIndexing' => true));
if ($t_item->numErrors()) {
$o_log->logError("Could not set parent_id for {$vs_child_id} (was translated to item_id={$vn_child_item_id}): " . join('; ', $t_item->getErrors()));
}
}
if ($vn_list_item_relation_type_id_related > 0) {
$o_log->logInfo("Begin adding ULAN related term links");
$vn_last_message_length = 0;
$t_item = new ca_list_items();
$t_link = new ca_list_items_x_list_items();
$t_link->setMode(ACCESS_WRITE);
foreach ($va_item_item_links as $vs_left_id => $vs_right_id) {
print str_repeat(chr(8), $vn_last_message_length);
$vs_message = "\tLINKING {$vs_left_id} to {$vs_right_id}";
if (($vn_l = 100 - strlen($vs_message)) < 1) {
$vn_l = 1;
}
$vs_message .= str_repeat(' ', $vn_l);
$vn_last_message_length = strlen($vs_message);
print $vs_message;
if (!($vn_left_item_id = $va_ulan_id_to_item_id[$vs_left_id])) {
$o_log->logError("No list item id for left_id {$vs_left_id} (were there previous errors?)");
continue;
}
if (!($vn_right_item_id = $va_ulan_id_to_item_id[$vs_right_id])) {
$o_log->logError("No list item id for right_id {$vs_right_id} (were there previous errors?)");
continue;
}
$t_link->set('term_left_id', $vn_left_item_id);
$t_link->set('term_right_id', $vn_right_item_id);
$t_link->set('type_id', $vn_list_item_relation_type_id_related);
$t_link->insert();
if ($t_link->numErrors()) {
$o_log->logError("Could not set link between {$vs_left_id} (was translated to item_id={$vn_left_item_id}) and {$vs_right_id} (was translated to item_id={$vn_right_item_id}): " . join('; ', $t_link->getErrors()));
}
}
} else {
$o_log->logWarn("Skipped import of term-term relationships because the ca_list_items_x_list_items 'related' relationship type is not defined for your installation");
}
$vn_duration = $t->getTime(1);
$vs_time = caFormatInterval($vn_duration);
$o_log->logInfo("Rebuilding hierarchical indices...");
$t_item->rebuildAllHierarchicalIndexes();
$o_log->logInfo("ULAN import complete. Took {$vs_time} ({$vn_duration})");
print "\n\nIMPORT COMPLETE. Took {$vs_time} ({$vn_duration})\n";
}
示例15: caIncrementBatchMetadataImportProgress
function caIncrementBatchMetadataImportProgress($po_request, $pn_file_number, $pn_number_of_files, $ps_file_path, $pn_rows_complete, $pn_total_rows, $ps_message, $pn_elapsed_time, $pn_memory_used, $pn_num_processed, $pn_num_errors)
{
if ($pn_total_rows == 0) {
return;
}
$pn_percentage = $pn_rows_complete / $pn_total_rows * 100;
if (is_null($ps_message)) {
$ps_message = _t('Processed %1/%2', $pn_rows_complete, $pn_total_rows);
}
$ps_message = addslashes($ps_message);
$ps_file_message = _t('File %1/%2 [%3]', $pn_file_number, $pn_number_of_files, pathinfo($ps_file_path, PATHINFO_FILENAME));
$pn_file_percentage = $pn_file_number / $pn_number_of_files * 100;
print "<script type='text/javascript'>";
if ($pn_number_of_files <= 1) {
print "jQuery('#batchProcessingTableProgressGroup').hide();";
}
print "jQuery('#progressbarFiles').progressbar('value',{$pn_file_percentage}); jQuery('#batchProcessingFileCount').html('{$ps_file_message}');";
print "jQuery('#progressbar').progressbar('value',{$pn_percentage}); jQuery('#batchProcessingRowProgressGroup').html('{$ps_message}');";
print "jQuery('#batchProcessingElapsedTime').html('" . caFormatInterval($pn_elapsed_time) . "/" . sprintf("%4.2f mb", $pn_memory_used / 1048576) . "');";
print "jQuery('#batchProcessingCounts').html('" . addslashes(_t("%1 processed; %2 errors", $pn_num_processed, $pn_num_errors)) . "');";
print "</script>";
caFlushOutput();
}