当前位置: 首页>>代码示例>>PHP>>正文


PHP TimeExpressionParser::getText方法代码示例

本文整理汇总了PHP中TimeExpressionParser::getText方法的典型用法代码示例。如果您正苦于以下问题:PHP TimeExpressionParser::getText方法的具体用法?PHP TimeExpressionParser::getText怎么用?PHP TimeExpressionParser::getText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TimeExpressionParser的用法示例。


在下文中一共展示了TimeExpressionParser::getText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getDisplayValue

 /**
  * Options:
  * 		rawDate - if true, returns date as an array of start and end historic timestames
  *		sortable - if true a language-independent sortable representation is returned.
  *		getDirectDate - get underlying historic timestamp (floatval)
  */
 public function getDisplayValue($pa_options = null)
 {
     if (!is_array($pa_options)) {
         $pa_options = array();
     }
     if (isset($pa_options['rawDate']) && $pa_options['rawDate']) {
         return array(0 => $this->opn_start_date, 1 => $this->opn_end_date, 'start' => $this->opn_start_date, 'end' => $this->opn_end_date);
     }
     if (caGetOption('GET_DIRECT_DATE', $pa_options, false) || caGetOption('getDirectDate', $pa_options, false)) {
         return $this->opn_start_date;
     }
     if (isset($pa_options['sortable']) && $pa_options['sortable']) {
         if (!$this->opn_start_date || !$this->opn_end_date) {
             return null;
         }
         return $this->opn_start_date . '/' . $this->opn_end_date;
     }
     $o_date_config = Configuration::load(__CA_CONF_DIR__ . '/datetime.conf');
     $vs_date_format = $o_date_config->get('dateFormat');
     $vs_cache_key = md5($vs_date_format . $this->opn_start_date . $this->opn_end_date);
     // pull from cache
     if (isset(DateRangeAttributeValue::$s_date_cache[$vs_cache_key])) {
         return DateRangeAttributeValue::$s_date_cache[$vs_cache_key];
     }
     // if neither start nor end date are set, the setHistoricTimestamps() call below will
     // fail and the TEP will return the text for whatever happened to be parsed previously
     // so we have to init() before trying
     DateRangeAttributeValue::$o_tep->init();
     if ($vs_date_format == 'original') {
         return DateRangeAttributeValue::$s_date_cache[$vs_cache_key] = $this->ops_text_value;
     } else {
         if (!is_array($va_settings = MemoryCache::fetch($this->getElementID(), 'ElementSettings'))) {
             $t_element = new ca_metadata_elements($this->getElementID());
             $va_settings = MemoryCache::fetch($this->getElementID(), 'ElementSettings');
         }
         DateRangeAttributeValue::$o_tep->setHistoricTimestamps($this->opn_start_date, $this->opn_end_date);
         return DateRangeAttributeValue::$s_date_cache[$vs_cache_key] = DateRangeAttributeValue::$o_tep->getText(array_merge(array('isLifespan' => $va_settings['isLifespan']), $pa_options));
         //$this->ops_text_value;
     }
 }
开发者ID:samrahman,项目名称:providence,代码行数:46,代码来源:DateRangeAttributeValue.php

示例2: Index

 /**
  * "My Account" screen
  */
 function Index()
 {
     if (!$this->request->isLoggedIn()) {
         return;
     }
     $t_order = new ca_commerce_orders();
     $this->view->setVar('t_order', $t_order);
     # -- open orders
     $va_open_orders = $t_order->getOrders(array('user_id' => $this->request->getUserID(), 'order_status' => array('OPEN', 'SUBMITTED', 'AWAITING_PAYMENT', 'IN_PROCESSING', 'PROCESSED', 'PROCESSED_AWAITING_DIGITIZATION', 'FULFILLED', 'REOPENED')));
     $this->view->setVar('open_order_list', $va_open_orders);
     # --- recent orders
     $this->view->setVar('recent_orders_age_threshold', $vn_recent_orders_age_threshold = (int) $this->opo_client_services_config->get('recent_orders_age_threshold'));
     $vn_c = time() - 60 * 60 * 24 * $vn_recent_orders_age_threshold;
     $o_tep = new TimeExpressionParser();
     $o_tep->setUnixTimestamps($vn_c, time());
     $va_recent_orders = $t_order->getOrders(array('user_id' => $this->request->getUserID(), 'created_on' => $o_tep->getText()));
     $this->view->setVar('recent_order_list', $va_recent_orders);
     # -- all orders
     $va_all_orders = $t_order->getOrders(array('user_id' => $this->request->getUserID()));
     $this->view->setVar('all_order_list', $va_all_orders);
     $va_closed_orders = $t_order->getOrders(array('user_id' => $this->request->getUserID(), 'order_status' => array('COMPLETED')));
     $this->view->setVar('closed_order_list', $va_closed_orders);
     $this->render("Account/my_account_html.php");
 }
开发者ID:guaykuru,项目名称:pawtucket,代码行数:27,代码来源:AccountController.php

示例3: DownloadUserReport

 public function DownloadUserReport()
 {
     $vs_download_format = $this->request->getParameter("download_format", pString);
     if (!$vs_download_format) {
         $vs_download_format = "tab";
     }
     $this->view->setVar("download_format", $vs_download_format);
     switch ($vs_download_format) {
         default:
         case "tab":
             $this->view->setVar("file_extension", "txt");
             $this->view->setVar("mimetype", "text/plain");
             $vs_delimiter_col = "\t";
             $vs_delimiter_row = "\n";
             break;
             # -----------------------------------
         # -----------------------------------
         case "csv":
             $this->view->setVar("file_extension", "txt");
             $this->view->setVar("mimetype", "text/plain");
             $vs_delimiter_col = ",";
             $vs_delimiter_row = "\n";
             break;
             # -----------------------------------
     }
     $o_db = new Db();
     $t_user = new ca_users();
     $va_fields = array("lname", "fname", "email", "user_name", "userclass", "active", "last_login");
     $va_profile_prefs = $t_user->getValidPreferences('profile');
     $va_profile_prefs_labels = array();
     foreach ($va_profile_prefs as $vs_pref) {
         $va_pref_info = $t_user->getPreferenceInfo($vs_pref);
         $va_profile_prefs_labels[$vs_pref] = $va_pref_info["label"];
     }
     $qr_users = $o_db->query("SELECT * FROM ca_users ORDER BY user_id DESC");
     if ($qr_users->numRows()) {
         $va_rows = array();
         # --- headings
         $va_row = array();
         # --- headings for field values
         foreach ($va_fields as $vs_field) {
             switch ($vs_field) {
                 case "last_login":
                     $va_row[] = _t("Last login");
                     break;
                     # --------------------
                 # --------------------
                 default:
                     $va_row[] = $t_user->getDisplayLabel("ca_users." . $vs_field);
                     break;
                     # --------------------
             }
         }
         # --- headings for profile prefs
         foreach ($va_profile_prefs_labels as $vs_pref => $vs_pref_label) {
             $va_row[] = $vs_pref_label;
         }
         $va_rows[] = join($vs_delimiter_col, $va_row);
         reset($va_fields);
         reset($va_profile_prefs_labels);
         $o_tep = new TimeExpressionParser();
         while ($qr_users->nextRow()) {
             $va_row = array();
             # --- fields
             foreach ($va_fields as $vs_field) {
                 switch ($vs_field) {
                     case "userclass":
                         $va_row[] = $t_user->getChoiceListValue($vs_field, $qr_users->get("ca_users." . $vs_field));
                         break;
                         # -----------------------
                     # -----------------------
                     case "active":
                         $va_row[] = $qr_users->get("ca_users." . $vs_field) == 1 ? _t("active") : _t("not active");
                         break;
                         # -----------------------
                     # -----------------------
                     case "last_login":
                         //if (!is_array($va_vars = $qr_users->getVars('vars'))) { $va_vars = array(); }
                         if (!is_array($va_vars = $qr_users->getVars('volatile_vars'))) {
                             $va_vars = array();
                         }
                         if ($va_vars['last_login'] > 0) {
                             $o_tep->setUnixTimestamps($va_vars['last_login'], $va_vars['last_login']);
                             $va_row[] = $o_tep->getText();
                         } else {
                             $va_row[] = "-";
                         }
                         break;
                         # -----------------------
                     # -----------------------
                     default:
                         if ($vs_download_format == "csv") {
                             $va_row[] = str_replace(",", "-", $qr_users->get("ca_users." . $vs_field));
                         } else {
                             $va_row[] = $qr_users->get("ca_users." . $vs_field);
                         }
                         break;
                         # -----------------------
                 }
             }
//.........这里部分代码省略.........
开发者ID:samrahman,项目名称:providence,代码行数:101,代码来源:UsersController.php

示例4: caNavButton

    print $va_user['lname'] . ', ' . $va_user['fname'];
    ?>
				</td>
				<td>
					<?php 
    print $va_user['email'];
    ?>
				</td>
				<td>
					<?php 
    print $va_user['active'] ? _t('Yes') : _t('No');
    ?>
				</td>
				<td>
					<?php 
    print $va_user['last_login'] > 0 ? $o_tep->getText() : '-';
    ?>
				</td>
				<td>
					<nobr><?php 
    print caNavButton($this->request, __CA_NAV_BUTTON_EDIT__, _t("Edit"), 'administrate/access', 'Users', 'Edit', array('user_id' => $va_user['user_id']), array(), array('icon_position' => __CA_NAV_BUTTON_ICON_POS_LEFT__, 'use_class' => 'list-button', 'no_background' => true, 'dont_show_content' => true));
    ?>
					<?php 
    print caNavButton($this->request, __CA_NAV_BUTTON_DELETE__, _t("Delete"), 'administrate/access', 'Users', 'Delete', array('user_id' => $va_user['user_id']), array(), array('icon_position' => __CA_NAV_BUTTON_ICON_POS_LEFT__, 'use_class' => 'list-button', 'no_background' => true, 'dont_show_content' => true));
    ?>
</nobr>
				</td>
			</tr>
<?php 
}
?>
开发者ID:guaykuru,项目名称:pawtucket,代码行数:31,代码来源:user_list_html.php

示例5: getRelatedItems


//.........这里部分代码省略.........
             } else {
                 if ($t_rel_item && ($vs_sort = $t_rel_item->getProperty('ID_NUMBERING_SORT_FIELD'))) {
                     $vs_order_by = " ORDER BY " . $t_rel_item->tableName() . ".{$vs_sort}";
                     $vs_sort_fld = $vs_sort;
                     $va_selects[] = $t_rel_item->tableName() . ".{$vs_sort}";
                 }
             }
             $vs_sql = "\n\t\t\t\t\tSELECT " . join(', ', $va_selects) . "\n\t\t\t\t\tFROM " . $va_path[0] . "\n\t\t\t\t\t" . join("\n", array_merge($va_joins, $va_joins_post_add)) . "\n\t\t\t\t\tWHERE\n\t\t\t\t\t\t" . join(' AND ', array_merge($va_wheres, array('(' . $va_path[1] . '.' . $vs_other_field . ' IN (' . join(',', $va_row_ids) . '))'))) . "\n\t\t\t\t\t{$vs_order_by}";
             //print "<pre>$vs_sql</pre>\n";
             $qr_res = $o_db->query($vs_sql);
             if ($vb_uses_relationship_types) {
                 $va_rel_types = $t_rel->getRelationshipInfo($va_path[1]);
             }
             $vn_c = 0;
             if ($vn_start > 0) {
                 $qr_res->seek($vn_start);
             }
             while ($qr_res->nextRow()) {
                 if ($vn_c >= $vn_limit) {
                     break;
                 }
                 $va_row = $qr_res->getRow();
                 $vn_id = $va_row[$vs_key] . '/' . $va_row['row_id'];
                 $vs_sort_key = $qr_res->get($vs_sort_fld);
                 $vs_display_label = $va_row[$vs_label_display_field];
                 //unset($va_row[$vs_label_display_field]);
                 if (!$va_rels[$vs_sort_key][$vn_id]) {
                     $va_rels[$vs_sort_key][$vn_id] = $qr_res->getRow();
                 }
                 if ($vb_uses_effective_dates) {
                     // return effective dates as display/parse-able text
                     if ($va_rels[$vs_sort_key][$vn_id]['sdatetime'] || $va_rels[$vs_sort_key][$vn_id]['edatetime']) {
                         $o_tep->setHistoricTimestamps($va_rels[$vs_sort_key][$vn_id]['sdatetime'], $va_rels[$vs_sort_key][$vn_id]['edatetime']);
                         $va_rels[$vs_sort_key][$vn_id]['effective_date'] = $o_tep->getText();
                     }
                 }
                 $vn_locale_id = $qr_res->get('locale_id');
                 if (isset($pa_options['returnLocaleCodes']) && $pa_options['returnLocaleCodes']) {
                     $va_rels[$vs_v]['locale_id'] = $vn_locale_id = $t_locale->localeIDToCode($vn_locale_id);
                 }
                 $va_rels[$vs_sort_key][$vn_id]['labels'][$vn_locale_id] = $vb_return_labels_as_array ? $va_row : $vs_display_label;
                 $va_rels[$vs_sort_key][$vn_id]['_key'] = $vs_key;
                 $va_rels[$vs_sort_key][$vn_id]['direction'] = $vs_direction;
                 $vn_c++;
                 if ($vb_uses_relationship_types) {
                     $va_rels[$vs_sort_key][$vn_id]['relationship_typename'] = $vs_direction == 'ltor' ? $va_rel_types[$va_row['relationship_type_id']]['typename'] : $va_rel_types[$va_row['relationship_type_id']]['typename_reverse'];
                     $va_rels[$vs_sort_key][$vn_id]['relationship_type_code'] = $va_rel_types[$va_row['relationship_type_id']]['type_code'];
                 }
                 //
                 // Return data in an arrangement more convenient for the data importer
                 //
                 if ($pa_options['groupFields']) {
                     $vs_rel_pk = $t_rel_item->primaryKey();
                     if ($t_rel_item_label) {
                         foreach ($t_rel_item_label->getFormFields() as $vs_field => $va_field_info) {
                             if (!isset($va_rels[$vs_v][$vs_field]) || $vs_field == $vs_rel_pk) {
                                 continue;
                             }
                             $va_rels[$vs_v]['preferred_labels'][$vs_field] = $va_rels[$vs_v][$vs_field];
                             unset($va_rels[$vs_v][$vs_field]);
                         }
                     }
                     foreach ($t_rel_item->getFormFields() as $vs_field => $va_field_info) {
                         if (!isset($va_rels[$vs_v][$vs_field]) || $vs_field == $vs_rel_pk) {
                             continue;
                         }
开发者ID:kai-iak,项目名称:pawtucket2,代码行数:67,代码来源:BundlableLabelableBaseModelWithAttributes.php

示例6: renderWidget

 public function renderWidget($ps_widget_id, &$pa_settings)
 {
     parent::renderWidget($ps_widget_id, $pa_settings);
     global $g_ui_locale_id;
     if (!in_array($pa_settings['display_type'], BaseWidget::$s_widget_settings['recentlyCreatedWidget']["display_type"]["options"])) {
         return "";
     }
     if ($t_table = $this->opo_datamodel->getInstanceByTableName($pa_settings['display_type'], true)) {
         $vo_db = new Db();
         $o_tep = new TimeExpressionParser();
         if ($pa_settings["display_limit"] && intval($pa_settings["display_limit"]) > 0 && intval($pa_settings["display_limit"]) < 1000) {
             $vn_limit = intval($pa_settings["display_limit"]);
         } else {
             $vn_limit = 11;
         }
         $vs_deleted_sql = '';
         if ($t_table->hasField('deleted')) {
             $vs_deleted_sql = " AND (t.deleted = 0) ";
         }
         $vs_idno_sql = '';
         if ($t_table->hasField('idno')) {
             $vs_idno_sql = "t.idno,";
         } elseif ($t_table->hasField('idno_stub')) {
             $vs_idno_sql = "t.idno_stub,";
         }
         $vs_sql = "\n\t\t\t\t\tSELECT\n\t\t\t\t\t\tt.{$t_table->primaryKey()},\n\t\t\t\t\t\tlt.{$t_table->getLabelDisplayField()},\n\t\t\t\t\t\t{$vs_idno_sql}\n\t\t\t\t\t\tlt.locale_id\n\t\t\t\t\tFROM\n\t\t\t\t\t\t{$t_table->tableName()} t\n\t\t\t\t\tINNER JOIN\n\t\t\t\t\t\t{$t_table->getLabelTableName()} AS lt ON t.{$t_table->primaryKey()} = lt.{$t_table->primaryKey()}\n\t\t\t\t\tWHERE\n\t\t\t\t\t\t(lt.is_preferred = 1) \n\t\t\t\t\t\t{$vs_deleted_sql}\n\t\t\t\t\tORDER BY\n\t\t\t\t\t\tt.{$t_table->primaryKey()} DESC\n\t\t\t\t\tLIMIT\n\t\t\t\t\t\t{$vn_limit}\n\t\t\t\t";
         $qr_records = $vo_db->query($vs_sql);
         $va_item_list = array();
         while ($qr_records->nextRow() && sizeof($va_item_list) < intval($pa_settings["display_limit"])) {
             if (isset($va_item_list[$qr_records->get($t_table->primaryKey())])) {
                 // we only overwrite if we hit one with UI locale (i.e. the first hit wins if there is no label in UI locale)
                 if (!(intval($qr_records->get($t_table->getLabelTableName() . ".locale_id")) == intval($g_ui_locale_id))) {
                     continue;
                 }
             }
             $vs_sql = "\n\t\t\t\t\t\tSELECT\n\t\t\t\t\t\t\tlog_datetime\n\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\tca_change_log\n\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\tlogged_table_num = " . (int) $t_table->tableNum() . "\n\t\t\t\t\t\tAND\n\t\t\t\t\t\t\tchangetype = 'I'\n\t\t\t\t\t\tAND\n\t\t\t\t\t\t\tlogged_row_id = " . (int) $qr_records->get($t_table->primaryKey()) . "\n\t\t\t\t\t";
             $qr_create_date = $vo_db->query($vs_sql);
             if ($qr_create_date->nextRow()) {
                 $vn_time_created = intval($qr_create_date->get("log_datetime"));
                 $o_tep->setUnixTimestamps($vn_time_created, $vn_time_created);
                 $va_options = $this->opb_dont_show_timestamp ? array('timeOmit' => true) : null;
                 $vs_datetime_text = $o_tep->getText($va_options);
             } else {
                 $vs_datetime_text = '';
             }
             $va_item_list[$qr_records->get($t_table->primaryKey())] = array("display" => $qr_records->get($t_table->getLabelTableName() . "." . $t_table->getLabelDisplayField()), "idno" => $qr_records->get("idno"), "idno_stub" => $qr_records->get("idno_stub"), "locale_id" => $qr_records->get($t_table->getLabelTableName() . ".locale_id"), "datetime" => $vs_datetime_text);
         }
         if (!(intval($pa_settings["height_px"]) > 30 && intval($pa_settings["height_px"]) < 1000)) {
             // if value is not within reasonable boundaries, set it to default
             $this->opo_view->setVar("height_px", 270);
         } else {
             $this->opo_view->setVar("height_px", intval($pa_settings["height_px"]));
         }
         $this->opo_view->setVar('item_list', $va_item_list);
         $this->opo_view->setVar('table_num', $this->opo_datamodel->getTableNum($t_table->tableName()));
         $this->opo_view->setVar('request', $this->getRequest());
         $this->opo_view->setVar('table_display', $this->opa_table_display_names[$t_table->tableName()]);
         $this->opo_view->setVar('idno_display', isset($pa_settings["display_idno"]) ? $pa_settings["display_idno"] : FALSE);
         return $this->opo_view->render('main_html.php');
     }
 }
开发者ID:idiscussforum,项目名称:providence,代码行数:61,代码来源:recentlyCreatedWidget.php

示例7: getAccessExpirationDates

 /**
  * 
  *
  * @param int $pn_user_id user_id of user to check set access for
  * @param int $pn_access type of access required. Use __CA_SET_READ_ACCESS__ for read-only access or __CA_SET_EDIT_ACCESS__ for editing (full) access
  * @param int $pa_set_ids The ids of the sets to check. If omitted then currently loaded set will be checked. Can also be set to a single integer.
  * @return int
  */
 public function getAccessExpirationDates($pn_user_id, $pn_access, $pa_set_ids = null, $pa_options = null)
 {
     if (!is_array($pa_set_ids)) {
         if (!$pa_set_ids) {
             $pa_set_ids = $this->get('set_id');
         }
         if (!$pa_set_ids) {
             return null;
         }
         $pa_set_ids = array($pa_set_ids);
     }
     foreach ($pa_set_ids as $vn_i => $vn_set_id) {
         $pa_set_ids[$vn_i] = (int) $vn_set_id;
     }
     $o_db = $this->getDb();
     $qr_res = $o_db->query("\n\t\t\tSELECT sxg.set_id, sxg.sdatetime, sxg.edatetime, s.user_id\n\t\t\tFROM ca_sets_x_user_groups sxg\n\t\t\tINNER JOIN ca_user_groups AS ug ON sxg.group_id = ug.group_id\n\t\t\tINNER JOIN ca_users_x_groups AS uxg ON uxg.group_id = ug.group_id\n\t\t\tINNER JOIN ca_sets AS s ON s.set_id = sxg.set_id\n\t\t\tWHERE \n\t\t\t\t(sxg.access >= ?) AND (uxg.user_id = ?) AND (sxg.set_id IN (?)) AND (s.deleted = 0)\n\t\t\t\tAND\n\t\t\t\t(\n\t\t\t\t\tsxg.sdatetime <= " . time() . " AND sxg.edatetime >= " . time() . "\n\t\t\t\t)\n\t\t", (int) $pn_access, (int) $pn_user_id, $pa_set_ids);
     $o_tep = new TimeExpressionParser();
     $va_expiration_times = array();
     while ($qr_res->nextRow()) {
         if ($qr_res->get('user_id') == $pn_user_id) {
             $va_expiration_times[$vn_set_id] = -1;
             continue;
         }
         $vn_set_id = $qr_res->get('set_id');
         $vn_exp = $qr_res->get('edatetime');
         if (!isset($va_expiration_times[$vn_set_id]) || $va_expiration_times[$vn_set_id] < $vn_exp) {
             $o_tep->setUnixTimestamps($vn_exp, $vn_exp);
             $vs_text = $o_tep->getText();
             $va_expiration_times[$vn_set_id] = $vs_text;
         }
     }
     $qr_res = $o_db->query("\n\t\t\tSELECT sxu.set_id, sxu.sdatetime, sxu.edatetime, s.user_id\n\t\t\tFROM ca_sets_x_users sxu\n\t\t\tINNER JOIN ca_users AS u ON sxu.user_id = u.user_id\n\t\t\tINNER JOIN ca_sets AS s ON s.set_id = sxu.set_id\n\t\t\tWHERE \n\t\t\t\t(sxu.access >= ?) AND (u.user_id = ?) AND (sxu.set_id IN (?)) AND (s.deleted = 0)\n\t\t\t\tAND\n\t\t\t\t(\n\t\t\t\t\tsxu.sdatetime <= " . time() . " AND sxu.edatetime >= " . time() . "\n\t\t\t\t)\n\t\t", (int) $pn_access, (int) $pn_user_id, $pa_set_ids);
     while ($qr_res->nextRow()) {
         if ($qr_res->get('user_id') == $pn_user_id) {
             $va_expiration_times[$vn_set_id] = -1;
             continue;
         }
         $vn_set_id = $qr_res->get('set_id');
         $vn_exp = $qr_res->get('edatetime');
         if (!isset($va_expiration_times[$vn_set_id]) || $va_expiration_times[$vn_set_id] < $vn_exp) {
             $o_tep->setUnixTimestamps($vn_exp, $vn_exp);
             $vs_text = $o_tep->getText();
             $va_expiration_times[$vn_set_id] = $vs_text;
         }
     }
     return $va_expiration_times;
 }
开发者ID:kai-iak,项目名称:providence,代码行数:55,代码来源:ca_sets.php

示例8: _getChangeLogFromRawData

 /**
  *
  */
 private function _getChangeLogFromRawData($pa_data, $pn_table_num, $pa_options = null)
 {
     //print "<pre>".print_r($pa_data, true)."</pre>\n";
     $va_log_output = array();
     $vs_blank_placeholder = '&lt;' . _t('BLANK') . '&gt;';
     $o_tep = new TimeExpressionParser();
     if (!$pa_options) {
         $pa_options = array();
     }
     if (sizeof($pa_data)) {
         //
         // Init
         //
         $o_datamodel = Datamodel::load();
         $va_change_types = array('I' => _t('Added'), 'U' => _t('Edited'), 'D' => _t('Deleted'));
         $vs_label_table_name = $vs_label_display_name = '';
         $t_item = $o_datamodel->getInstanceByTableNum($pn_table_num, true);
         $vs_label_table_name = $vn_label_table_num = $vs_label_display_name = null;
         if (method_exists($t_item, 'getLabelTableName')) {
             $t_item_label = $t_item->getLabelTableInstance();
             $vs_label_table_name = $t_item->getLabelTableName();
             $vn_label_table_num = $t_item_label->tableNum();
             $vs_label_display_name = $t_item_label->getProperty('NAME_SINGULAR');
         }
         //
         // Group data by unit
         //
         $va_grouped_data = array();
         foreach ($pa_data as $va_log_entry) {
             $va_grouped_data[$va_log_entry['unit_id']]['ca_table_num_' . $va_log_entry['logged_table_num']][] = $va_log_entry;
         }
         //
         // Process units
         //
         $va_attributes = array();
         foreach ($va_grouped_data as $vn_unit_id => $va_log_entries_by_table) {
             foreach ($va_log_entries_by_table as $vs_table_key => $va_log_entries) {
                 foreach ($va_log_entries as $va_log_entry) {
                     $va_changes = array();
                     if (!is_array($va_log_entry['snapshot'])) {
                         $va_log_entry['snapshot'] = array();
                     }
                     //
                     // Get date/time stamp for display
                     //
                     $o_tep->setUnixTimestamps($va_log_entry['log_datetime'], $va_log_entry['log_datetime']);
                     if ($this->opb_dont_show_timestamp_in_change_log) {
                         $vs_datetime = $o_tep->getText(array('timeOmit' => true));
                     } else {
                         $vs_datetime = $o_tep->getText();
                     }
                     //
                     // Get user name
                     //
                     $vs_user = $va_log_entry['fname'] . ' ' . $va_log_entry['lname'];
                     $vs_email = $va_log_entry['email'];
                     // The "logged" table/row is the row to which the change was actually applied
                     // The "subject" table/row is the row to which the change is considered to have been made for workflow purposes.
                     //
                     // For example: if an entity is related to an object, strictly speaking the logging occurs on the ca_objects_x_entities
                     // row (ca_objects_x_entities is the "logged" table), but the subject is ca_objects since it's only in the context of the
                     // object (and probably the ca_entities row as well) that you can about the change.
                     //
                     $t_obj = $o_datamodel->getInstanceByTableNum($va_log_entry['logged_table_num'], true);
                     // get instance for logged table
                     if (!$t_obj) {
                         continue;
                     }
                     $vs_subject_display_name = '???';
                     $vn_subject_row_id = null;
                     $vn_subject_table_num = null;
                     if (isset($pa_options['return_item_names']) && $pa_options['return_item_names']) {
                         if (!($vn_subject_table_num = $va_log_entry['subject_table_num'])) {
                             $vn_subject_table_num = $va_log_entry['logged_table_num'];
                             $vn_subject_row_id = $va_log_entry['logged_row_id'];
                         } else {
                             $vn_subject_row_id = $va_log_entry['subject_row_id'];
                         }
                         if ($t_subject = $o_datamodel->getInstanceByTableNum($vn_subject_table_num, true)) {
                             if ($t_subject->load($vn_subject_row_id)) {
                                 if (method_exists($t_subject, 'getLabelForDisplay')) {
                                     $vs_subject_display_name = $t_subject->getLabelForDisplay(false);
                                 } else {
                                     if ($vs_idno_field = $t_subject->getProperty('ID_NUMBERING_ID_FIELD')) {
                                         $vs_subject_display_name = $t_subject->getProperty('NAME_SINGULAR') . ' [' . $t_subject->get($vs_idno_field) . ']';
                                     } else {
                                         $vs_subject_display_name = $t_subject->getProperty('NAME_SINGULAR') . ' [' . $vn_subject_row_id . ']';
                                     }
                                 }
                             }
                         }
                     }
                     //
                     // Get item changes
                     //
                     // ---------------------------------------------------------------
                     // is this an intrinsic field?
//.........这里部分代码省略.........
开发者ID:idiscussforum,项目名称:providence,代码行数:101,代码来源:ApplicationChangeLog.php

示例9: get

 /**
  * Get a field value of the table row that is represented by this object.
  *
  * @param string $ps_field field name
  * @param array $pa_options options array; can be omitted.
  * It should be an associative array of boolean (except one of the options) flags. In case that some of the options are not set, they are treated as 'false'.
  * Possible options (keys) are:
  * 		BINARY: return field value as is
  * 		FILTER_HTML_SPECIAL_CHARS: convert all applicable chars to their html entities
  * 		DONT_PROCESS_GLOSSARY_TAGS: ?
  * 		CONVERT_HTML_BREAKS: similar to nl2br()
  * 		convertLineBreaks: same as CONVERT_HTML_BREAKS
  * 		getDirectDate: return raw date value from database if $ps_field adresses a date field, otherwise the value will be parsed using the TimeExpressionParser::getText() method
  * 		getDirectTime: return raw time value from database if $ps_field adresses a time field, otherwise the value will be parsed using the TimeExpressionParser::getText() method
  * 		TIMECODE_FORMAT: set return format for fields representing time ranges possible (string) values: COLON_DELIMITED, HOURS_MINUTES_SECONDS, RAW; data will be passed through floatval() by default
  * 		QUOTE: set return value into quotes
  * 		URL_ENCODE: value will be passed through urlencode()
  * 		ESCAPE_FOR_XML: convert <, >, &, ' and " characters for XML use
  * 		DONT_STRIP_SLASHES: if set to true, return value will not be passed through stripslashes()
  * 		template: formatting string to use for returned value; ^<fieldname> placeholder is used to represent field value in template
  * 		returnAsArray: if true, fields that can return multiple values [currently only <table_name>.children.<field>] will return values in an indexed array; default is false
  * 		returnAllLocales:
  * 		delimiter: if set, value is used as delimiter when fields that can return multiple fields are returned as strings; default is a single space
  * 		convertCodesToDisplayText: if set, id values refering to foreign keys are returned as preferred label text in the current locale
  * 		returnURL: if set then url is returned for media, otherwise an HTML tag for display is returned
  * 		dateFormat: format to return created or lastModified dates in. Valid values are iso8601 or text
  *		checkAccess = array of access values to filter results by; if defined only items with the specified access code(s) are returned. Only supported for table that have an "access" field.
  *		sort = optional field to sort returned values on. The field specifiers are fields with or without table name specified.	 
  *		sort_direction = direction to sort results by, either 'asc' for ascending order or 'desc' for descending order; default is 'asc'	 
  */
 public function get($ps_field, $pa_options = null)
 {
     if (!$ps_field) {
         return null;
     }
     if (!is_array($pa_options)) {
         $pa_options = array();
     }
     $vb_return_as_array = caGetOption('returnAsArray', $pa_options, false);
     $vb_return_with_structure = caGetOption('returnWithStructure', $pa_options, false);
     $vb_return_all_locales = caGetOption('returnAllLocales', $pa_options, false);
     $vs_delimiter = caGetOption('delimiter', $pa_options, ' ');
     if (($vb_return_with_structure || $vb_return_all_locales) && !$vb_return_as_array) {
         $vb_return_as_array = true;
     }
     $vn_row_id = $this->getPrimaryKey();
     if ($vb_return_as_array && $vb_return_as_array) {
         $vn_locale_id = $this->hasField('locale_id') ? $this->get('locale_id') : null;
     }
     $va_tmp = explode('.', $ps_field);
     if (sizeof($va_tmp) > 1) {
         if ($va_tmp[0] === $this->tableName()) {
             //
             // Return created on or last modified
             //
             if (in_array($va_tmp[1], array('created', 'lastModified'))) {
                 if ($vb_return_as_array) {
                     return $va_tmp[1] == 'lastModified' ? $this->getLastChangeTimestamp() : $this->getCreationTimestamp();
                 } else {
                     $va_data = $va_tmp[1] == 'lastModified' ? $this->getLastChangeTimestamp() : $this->getCreationTimestamp();
                     $vs_subfield = isset($va_tmp[2]) && isset($va_data[$va_tmp[2]]) ? $va_tmp[2] : 'timestamp';
                     $vm_val = $va_data[$vs_subfield];
                     if ($vs_subfield == 'timestamp') {
                         $o_tep = new TimeExpressionParser();
                         $o_tep->setUnixTimestamps($vm_val, $vm_val);
                         $vm_val = $o_tep->getText($pa_options);
                     }
                     return $vm_val;
                 }
             }
             //
             // Generalized get
             //
             $va_field_info = $this->getFieldInfo($va_tmp[1]);
             switch (sizeof($va_tmp)) {
                 case 2:
                     // support <table_name>.<field_name> syntax
                     $ps_field = $va_tmp[1];
                     break;
                 default:
                     // > 2 elements
                     // media field?
                     if ($va_field_info['FIELD_TYPE'] === FT_MEDIA && !isset($pa_options['returnAsArray']) && !$pa_options['returnAsArray']) {
                         $o_media_settings = new MediaProcessingSettings($va_tmp[0], $va_tmp[1]);
                         $va_versions = $o_media_settings->getMediaTypeVersions('*');
                         $vs_version = $va_tmp[2];
                         if (!isset($va_versions[$vs_version])) {
                             $va_available_versions = array_keys($va_versions);
                             $vs_version = $va_tmp[2] = array_shift($va_available_versions);
                         }
                         if (isset($va_tmp[3])) {
                             return $this->getMediaInfo($va_tmp[1], $vs_version, 'width');
                         } else {
                             if (isset($pa_options['returnURL']) && $pa_options['returnURL']) {
                                 return $this->getMediaUrl($va_tmp[1], $vs_version, $pa_options);
                             } else {
                                 return $this->getMediaTag($va_tmp[1], $vs_version, $pa_options);
                             }
                         }
                     }
//.........这里部分代码省略.........
开发者ID:samrahman,项目名称:providence,代码行数:101,代码来源:BaseModel.php

示例10: getComments

 /**
  *
  */
 public function getComments($ps_mode = null, $pn_limit = null, $pa_options = null)
 {
     $o_db = $this->getDb();
     $vs_where = '';
     switch ($ps_mode) {
         case 'moderated':
             $vs_where = "WHERE cic.moderated_on IS NOT NULL";
             break;
         case 'unmoderated':
             $vs_where = "WHERE cic.moderated_on IS NULL";
             break;
     }
     if (intval($pn_limit) > 0) {
         $vs_limit = " LIMIT " . intval($pn_limit);
     }
     $o_tep = new TimeExpressionParser();
     $qr_res = $o_db->query("\n\t\t\tSELECT cic.*, u.user_id, u.fname, u.lname, u.email user_email\n\t\t\tFROM ca_item_comments cic\n\t\t\tLEFT JOIN ca_users AS u ON u.user_id = cic.user_id\n\t\t\t{$vs_where} ORDER BY cic.created_on DESC {$vs_limit}\n\t\t");
     $o_datamodel = $this->getAppDatamodel();
     $va_comments = array();
     while ($qr_res->nextRow()) {
         $vn_datetime = $qr_res->get('created_on');
         $o_tep->setUnixTimestamps($vn_datetime, $vn_datetime);
         $va_row = $qr_res->getRow();
         $va_row['created_on'] = $o_tep->getText();
         $t_table = $o_datamodel->getInstanceByTableNum($qr_res->get('table_num'), true);
         if ($t_table->load($qr_res->get('row_id'))) {
             $va_row['commented_on'] = $t_table->getLabelForDisplay(false);
             if ($vs_idno = $t_table->get('idno')) {
                 $va_row['commented_on'] .= ' [' . $vs_idno . ']';
             }
         }
         foreach (array("media1", "media2", "media3", "media4") as $vs_media_field) {
             $va_media_versions = array();
             $va_media_versions = $qr_res->getMediaVersions($vs_media_field);
             $va_media = array();
             if (is_array($va_media_versions) && sizeof($va_media_versions) > 0) {
                 foreach ($va_media_versions as $vs_version) {
                     $va_image_info = array();
                     $va_image_info = $qr_res->getMediaInfo($vs_media_field, $vs_version);
                     $va_image_info["TAG"] = $qr_res->getMediaTag($vs_media_field, $vs_version);
                     $va_image_info["URL"] = $qr_res->getMediaUrl($vs_media_field, $vs_version);
                     $va_media[$vs_version] = $va_image_info;
                 }
                 $va_row[$vs_media_field] = $va_media;
             }
         }
         $va_comments[] = $va_row;
     }
     return $va_comments;
 }
开发者ID:idiscussforum,项目名称:providence,代码行数:53,代码来源:ca_item_comments.php

示例11: getAllTags

 /**
  * Returns all tags attached to any kind of row.
  * If the optional $pb_moderation_status parameter is passed then only tags matching the criteria will be returned:
  *		Passing $pb_moderation_status = TRUE will cause only moderated tags to be returned
  *		Passing $pb_moderation_status = FALSE will cause only unmoderated tags to be returned
  *		If you want both moderated and unmoderated tags to be returned then omit the parameter or pass a null value
  *
  * @param bool $pb_moderation_status To return only unmoderated tags set to FALSE; to return only moderated tags set to TRUE; to return all tags set to null or omit
  * @param int $pn_limit Maximum number of tags to return. Default is 0 - no limit.
  * 
  * @return array
  */
 public function getAllTags($pb_moderation_status = null, $pn_limit = 0)
 {
     $o_db = $this->getDb();
     $vs_where = '';
     if ($pb_moderation_status === true) {
         $vs_where = ' WHERE cixt.moderated_on IS NULL';
     } elseif ($pb_moderation_status === false) {
         $vs_where = ' WHERE cixt.moderated_on IS NOT NULL';
     } else {
         $vs_where = '';
     }
     $vs_limit = "";
     if (intval($pn_limit) > 0) {
         $vs_limit = " LIMIT " . intval($pn_limit);
     }
     $o_tep = new TimeExpressionParser();
     $qr_res = $o_db->query("\n\t\t\tSELECT cit.*, cixt.*, u.user_id, u.fname, u.lname, u.email user_email\n\t\t\tFROM ca_items_x_tags cixt\n\t\t\tLEFT JOIN ca_users AS u ON u.user_id = cixt.user_id\n\t\t\tINNER JOIN ca_item_tags AS cit ON cit.tag_id = cixt.tag_id\n\t\t\t{$vs_where} ORDER BY cixt.created_on DESC {$vs_limit}\n\t\t");
     $o_datamodel = $this->getAppDatamodel();
     $va_tags = array();
     while ($qr_res->nextRow()) {
         $vn_datetime = $qr_res->get('created_on');
         $o_tep->setUnixTimestamps($vn_datetime, $vn_datetime);
         $va_row = $qr_res->getRow();
         $va_row['created_on'] = $o_tep->getText();
         $t_table = $o_datamodel->getInstanceByTableNum($qr_res->get('table_num'), true);
         if ($t_table->load($qr_res->get('row_id'))) {
             $va_row['item_tagged'] = $t_table->getLabelForDisplay(false);
             if ($vs_idno = $t_table->get('idno')) {
                 $va_row['item_tagged'] .= ' [' . $vs_idno . ']';
             }
         }
         $va_tags[] = $va_row;
     }
     return $va_tags;
 }
开发者ID:idiscussforum,项目名称:providence,代码行数:47,代码来源:ca_item_tags.php

示例12: _get

 /**
  * Implementation of primary get() functionality
  */
 private function _get($ps_field, $pa_options = null)
 {
     if (!is_array($pa_options)) {
         $pa_options = array();
     }
     if (isset($pa_options['restrictToType']) && (!isset($pa_options['restrict_to_type']) || !$pa_options['restrict_to_type'])) {
         $pa_options['restrict_to_type'] = $pa_options['restrictToType'];
     }
     if (isset($pa_options['restrictToTypes']) && (!isset($pa_options['restrict_to_types']) || !$pa_options['restrict_to_types'])) {
         $pa_options['restrict_to_types'] = $pa_options['restrictToTypes'];
     }
     if (isset($pa_options['restrictToRelationshipTypes']) && (!isset($pa_options['restrict_to_relationship_types']) || !$pa_options['restrict_to_relationship_types'])) {
         $pa_options['restrict_to_relationship_types'] = $pa_options['restrictToRelationshipTypes'];
     }
     if (isset($pa_options['excludeType']) && (!isset($pa_options['exclude_type']) || !$pa_options['exclude_type'])) {
         $pa_options['exclude_type'] = $pa_options['excludeType'];
     }
     if (isset($pa_options['excludeTypes']) && (!isset($pa_options['exclude_types']) || !$pa_options['exclude_types'])) {
         $pa_options['exclude_types'] = $pa_options['excludeTypes'];
     }
     if (isset($pa_options['excludeRelationshipTypes']) && (!isset($pa_options['exclude_relationship_types']) || !$pa_options['exclude_relationship_types'])) {
         $pa_options['exclude_relationship_types'] = $pa_options['excludeRelationshipTypes'];
     }
     $vb_return_as_array = caGetOption('returnAsArray', $pa_options, false, array('castTo' => 'bool'));
     $vb_return_all_locales = caGetOption('returnAllLocales', $pa_options, false, array('castTo' => 'bool'));
     $vb_return_as_link = caGetOption('returnAsLink', $pa_options, false, array('castTo' => 'bool'));
     $vs_return_as_link_text = caGetOption('returnAsLinkText', $pa_options, '');
     $vs_return_as_link_target = caGetOption('returnAsLinkTarget', $pa_options, '');
     $vs_return_as_link_attributes = caGetOption('returnAsLinkAttributes', $pa_options, array(), array('castTo' => 'array'));
     $va_original_path_components = $va_path_components = $this->getFieldPathComponents($ps_field);
     if ($va_path_components['table_name'] != $this->ops_table_name) {
         $vs_access_chk_key = $va_path_components['table_name'] . ($va_path_components['field_name'] ? '.' . $va_path_components['field_name'] : '');
     } else {
         $vs_access_chk_key = $va_path_components['field_name'];
     }
     if (caGetBundleAccessLevel($this->ops_table_name, $vs_access_chk_key) == __CA_BUNDLE_ACCESS_NONE__) {
         return null;
     }
     $vo_request = caGetOption('request', $pa_options, null);
     unset($pa_options['request']);
     // first see if the search engine can provide the field value directly (fastest)
     if (!(($vs_value = $this->opo_engine_result->get($ps_field, $pa_options)) === false)) {
         if ($vb_return_as_array) {
             if ($vb_return_all_locales) {
                 return array(1 => $vs_value);
             } else {
                 return array($vs_value);
             }
         } else {
             return $vs_value;
         }
     }
     $vs_template = caGetOption('template', $pa_options, null);
     $vs_delimiter = caGetOption('delimiter', $pa_options, ' ');
     $vs_hierarchical_delimiter = caGetOption('hierarchicalDelimiter', $pa_options, ' ');
     if ($vb_return_all_locales && !$vb_return_as_array) {
         $vb_return_as_array = true;
     }
     if (isset($pa_options['sort']) && !is_array($pa_options['sort'])) {
         $pa_options['sort'] = array($pa_options['sort']);
     }
     if (is_array($va_sort_fields = isset($pa_options['sort']) && is_array($pa_options['sort']) ? $pa_options['sort'] : null)) {
         foreach ($va_sort_fields as $vn_i => $vs_sort_fld) {
             if (!trim($vs_sort_fld)) {
                 unset($va_sort_fields[$vn_i]);
             }
         }
     }
     $vn_row_id = $this->opo_engine_result->get($this->ops_table_pk);
     // try to lazy load (slower)...
     //
     // Are we getting timestamp (created on or last modified) info?
     //
     if ($va_path_components['table_name'] == $this->ops_table_name && $va_path_components['field_name'] == 'created') {
         if (!isset($this->opa_timestamp_cache['created_on'][$this->ops_table_name][$vn_row_id])) {
             $this->prefetchChangeLogData($this->ops_table_name, $this->opo_engine_result->currentRow(), $this->getOption('prefetch'));
         }
         if ($vb_return_as_array) {
             return $this->opa_timestamp_cache['created_on'][$this->ops_table_name][$vn_row_id];
         } else {
             $vs_subfield = $va_path_components['subfield_name'] ? $va_path_components['subfield_name'] : 'timestamp';
             $vm_val = $this->opa_timestamp_cache['created_on'][$this->ops_table_name][$vn_row_id][$vs_subfield];
             if ($vs_subfield == 'timestamp') {
                 $o_tep = new TimeExpressionParser();
                 $o_tep->setUnixTimestamps($vm_val, $vm_val);
                 $vm_val = $o_tep->getText($pa_options);
             }
             return $vm_val;
         }
     }
     if ($va_path_components['table_name'] == $this->ops_table_name && $va_path_components['field_name'] == 'lastModified') {
         if (!isset($this->opa_timestamp_cache['last_changed'][$this->ops_table_name][$vn_row_id])) {
             $this->prefetchChangeLogData($this->ops_table_name, $this->opo_engine_result->currentRow(), $this->getOption('prefetch'));
         }
         if ($vb_return_as_array) {
             return $this->opa_timestamp_cache['last_changed'][$this->ops_table_name][$vn_row_id];
         } else {
//.........这里部分代码省略.........
开发者ID:ffarago,项目名称:pawtucket2,代码行数:101,代码来源:SearchResult.php

示例13: caNavButton

    if ($vo_result->getMediaTag('ca_item_comments.media1', "thumbnail")) {
        print "<span style='white-space: nowrap;'>" . $vo_result->getMediaTag("ca_item_comments.media1", "thumbnail");
        print caNavButton($this->request, __CA_NAV_BUTTON_DOWNLOAD__, _t('Download'), '', 'manage', 'Comments', 'DownloadMedia', array('version' => 'original', 'comment_id' => $vo_result->get('ca_item_comments.comment_id'), 'mode' => 'search', 'download' => 1), array(), array('no_background' => true, 'dont_show_content' => true));
        print "</span>";
    }
    ?>
					</td>
					<td>
						<?php 
    print ($vn_tmp = $vo_result->get('ca_item_comments.rating')) ? $vn_tmp : "-";
    ?>
					</td>
					<td>
<?php 
    $o_tep->setUnixTimestamps($vn_tmp = $vo_result->get('ca_item_comments.created_on'), $vn_tmp);
    print $o_tep->getText();
    ?>
					</td>
					<td>
<?php 
    $vs_commented_on = "";
    if ($t_table->load($vo_result->get('ca_item_comments.row_id'))) {
        $vs_commented_on = $t_table->getLabelForDisplay(false);
        if ($vs_idno = $t_table->get('idno')) {
            $vs_commented_on .= ' [' . $vs_idno . ']';
        }
    }
    print $vs_commented_on;
    ?>
					</td>
					<td>
开发者ID:idiscussforum,项目名称:providence,代码行数:31,代码来源:ca_item_comments_list_html.php

示例14: time

 * GNU General Public License. (http://www.gnu.org/copyleft/gpl.html). See
 * the "license.txt" file for details, or visit the CollectiveAccess web site at
 * http://www.CollectiveAccess.org
 *
 * ----------------------------------------------------------------------
 */
$po_request = $this->getVar('request');
$vs_widget_id = $this->getVar('widget_id');
$vn_table_num = $this->getVar('table_num');
$t_log = $this->getVar('change_log');
$vn_threshold_in_seconds = $this->getVar('threshold_in_hours') * 3600;
$vn_end_date_for_display = time();
$vn_start_date_for_display = $vn_end_date_for_display - $vn_threshold_in_seconds;
$o_tep = new TimeExpressionParser();
$o_tep->setUnixTimestamps($vn_start_date_for_display, $vn_end_date_for_display);
$vn_displayed_date_range = $o_tep->getText(array('timeOmit' => true));
$va_log_entries = array_reverse($t_log->getRecentChanges($vn_table_num, $vn_threshold_in_seconds, 1000));
// reverse to put most recent up top
?>
<div class="dashboardWidgetContentContainer">
<?php 
if (sizeof($va_log_entries) > 0) {
    ?>
			<div class="dashboardWidgetHeading"><?php 
    print _t("Changes to <strong>%1</strong> from %2", $this->getVar('table_name_plural'), $vn_displayed_date_range);
    ?>
</div>
			<div class="dashboardWidgetScrollMedium" style="padding-left:10px;"><ul>
<?php 
    foreach ($va_log_entries as $vs_log_key => $va_log_entry) {
        // $va_log_entry is a list of changes performed by a user as a unit (at a single instant in time)
开发者ID:idiscussforum,项目名称:providence,代码行数:31,代码来源:main_html.php

示例15: refine

 /**
  *
  */
 public function refine(&$pa_destination_data, $pa_group, $pa_item, $pa_source_data, $pa_options = null)
 {
     $o_log = isset($pa_options['log']) && is_object($pa_options['log']) ? $pa_options['log'] : null;
     $pm_value = $pa_source_data[$pa_item['source']];
     // not actually used
     $va_item_dest = explode(".", $pa_item['destination']);
     $vs_item_terminal = array_pop($va_item_dest);
     $vs_group_terminal = array_pop($va_item_dest);
     $o_tep = new TimeExpressionParser();
     $o_tep->setLanguage('en_US');
     switch ($vs_mode = $pa_item['settings']['dateJoiner_mode']) {
         default:
         case 'range':
             $vs_date_expression = $pa_item['settings']['dateJoiner_expression'];
             $vs_date_start = $pa_item['settings']['dateJoiner_start'];
             $vs_date_end = $pa_item['settings']['dateJoiner_end'];
             if ($vs_date_expression && ($vs_exp = BaseRefinery::parsePlaceholder($vs_date_expression, $pa_source_data, $pa_item, $vn_c, array('reader' => caGetOption('reader', $pa_options, null), 'returnAsString' => true, 'delimiter' => ' ')))) {
                 if ($o_tep->parse($vs_exp)) {
                     return $o_tep->getText();
                 } else {
                     if ($o_log) {
                         $o_log->logWarn(_t('[dateJoinerRefinery] Could not parse date expression %1 assembled from range', $vs_exp));
                     }
                 }
             }
             $va_date = array();
             if ($vs_date_start = BaseRefinery::parsePlaceholder($vs_date_start, $pa_source_data, $pa_item, $vn_c, array('reader' => caGetOption('reader', $pa_options, null), 'returnAsString' => true, 'delimiter' => ' '))) {
                 if (!($vs_skip_start_exp = $pa_item['settings']['dateJoiner_skipStartIfExpression']) || !ExpressionParser::evaluate($vs_skip_start_exp, array_merge($pa_source_data, array('start' => $vs_date_start, 'end' => $vs_date_end, 'expression' => $ps_expression)))) {
                     $va_date[] = $vs_date_start;
                 } elseif ($vs_skip_start_replacement = $pa_item['settings']['dateJoiner_skipStartIfExpressionReplacementValue']) {
                     $va_date[] = $vs_skip_start_replacement;
                 }
             }
             if ($vs_date_end = BaseRefinery::parsePlaceholder($vs_date_end, $pa_source_data, $pa_item, $vn_c, array('reader' => caGetOption('reader', $pa_options, null), 'returnAsString' => true, 'delimiter' => ' '))) {
                 if (!($vs_skip_end_exp = $pa_item['settings']['dateJoiner_skipEndIfExpression']) || !ExpressionParser::evaluate($vs_skip_end_exp, array_merge($pa_source_data, array('start' => $vs_date_start, 'end' => $vs_date_end, 'expression' => $ps_expression)))) {
                     $va_date[] = $vs_date_end;
                 } elseif ($vs_skip_end_replacement = $pa_item['settings']['dateJoiner_skipEndIfExpressionReplacementValue']) {
                     $va_date[] = $vs_skip_end_replacement;
                 }
             }
             foreach ($va_date as $vn_i => $vs_date) {
                 $va_date[$vn_i] = preg_replace("![^\\d]+\$!", "", $vs_date);
             }
             $vs_date_expression = join(" - ", $va_date);
             if ($vs_date_expression && ($vs_exp = BaseRefinery::parsePlaceholder($vs_date_expression, $pa_source_data, $pa_item, $vn_c, array('reader' => caGetOption('reader', $pa_options, null), 'returnAsString' => true, 'delimiter' => ' ')))) {
                 if ($o_tep->parse($vs_exp)) {
                     return $o_tep->getText();
                 } else {
                     if ($o_log) {
                         $o_log->logWarn(_t('[dateJoinerRefinery] Could not parse date expression %1 assembled from range', $vs_exp));
                     }
                 }
             }
             break;
         case 'multiColumnDate':
             $va_month_list = $o_tep->getMonthList();
             $va_date = array();
             if ($vs_date_month = trim(BaseRefinery::parsePlaceholder($pa_item['settings']['dateJoiner_month'], $pa_source_data, $pa_item, $vn_c, array('reader' => caGetOption('reader', $pa_options, null), 'returnAsString' => true, 'delimiter' => ' ')))) {
                 if (($vn_m = array_search($vs_date_month, $va_month_list)) !== false) {
                     $vs_date_month = $vn_m + 1;
                 }
                 $va_date[] = $vs_date_month;
             }
             if ($vs_date_day = trim(BaseRefinery::parsePlaceholder($pa_item['settings']['dateJoiner_day'], $pa_source_data, $pa_item, $vn_c, array('reader' => caGetOption('reader', $pa_options, null), 'returnAsString' => true, 'delimiter' => ' ')))) {
                 $va_date[] = $vs_date_day;
             }
             if ($vs_date_year = trim(BaseRefinery::parsePlaceholder($pa_item['settings']['dateJoiner_year'], $pa_source_data, $pa_item, $vn_c, array('reader' => caGetOption('reader', $pa_options, null), 'returnAsString' => true, 'delimiter' => ' ')))) {
                 $va_date[] = $vs_date_year;
             }
             if (sizeof($va_date)) {
                 // TODO: this is assuming US-style dates for now
                 if ($o_tep->parse(join("/", $va_date))) {
                     return $o_tep->getText();
                 } else {
                     if ($o_log) {
                         $o_log->logWarn(_t('[dateJoinerRefinery] Could not parse date expression %1 assembled from multiColumnDate', join("/", $va_date)));
                     }
                 }
             }
             break;
         case 'multiColumnRange':
             $va_dates = array();
             $va_month_list = $o_tep->getMonthList();
             // Process start date
             $va_date = array();
             if ($vs_date_month = trim(BaseRefinery::parsePlaceholder($pa_item['settings']['dateJoiner_startMonth'], $pa_source_data, $pa_item, $vn_c, array('reader' => caGetOption('reader', $pa_options, null), 'returnAsString' => true, 'delimiter' => ' ')))) {
                 if (($vn_m = array_search($vs_date_month, $va_month_list)) !== false) {
                     $vs_date_month = $vn_m + 1;
                 }
                 $va_date[] = $vs_date_month;
             }
             if ($vs_date_day = trim(BaseRefinery::parsePlaceholder($pa_item['settings']['dateJoiner_startDay'], $pa_source_data, $pa_item, $vn_c, array('reader' => caGetOption('reader', $pa_options, null), 'returnAsString' => true, 'delimiter' => ' ')))) {
                 $va_date[] = $vs_date_day;
             }
             if ($vs_date_year = trim(BaseRefinery::parsePlaceholder($pa_item['settings']['dateJoiner_startYear'], $pa_source_data, $pa_item, $vn_c, array('reader' => caGetOption('reader', $pa_options, null), 'returnAsString' => true, 'delimiter' => ' ')))) {
                 $va_date[] = $vs_date_year;
             }
//.........这里部分代码省略.........
开发者ID:idiscussforum,项目名称:providence,代码行数:101,代码来源:dateJoinerRefinery.php


注:本文中的TimeExpressionParser::getText方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。