本文整理汇总了PHP中ca_locales::localeCodeToID方法的典型用法代码示例。如果您正苦于以下问题:PHP ca_locales::localeCodeToID方法的具体用法?PHP ca_locales::localeCodeToID怎么用?PHP ca_locales::localeCodeToID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ca_locales
的用法示例。
在下文中一共展示了ca_locales::localeCodeToID方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct($po_request, $ps_table = "")
{
$this->opo_request = $po_request;
$this->ops_table = $ps_table;
$this->opo_dm = Datamodel::load();
$this->opa_errors = array();
$this->ops_method = $this->opo_request->getRequestMethod();
if (!in_array($this->ops_method, array("PUT", "DELETE", "GET", "POST", "OPTIONS"))) {
$this->addError("Invalid HTTP request method");
}
$this->opn_id = $this->opo_request->getParameter("id", pString);
// we allow for a string to support fetching by idno; typically it's a numeric id
if ($vs_locale = $this->opo_request->getParameter('lang', pString)) {
global $g_ui_locale, $g_ui_locale_id, $_;
$g_ui_locale = $vs_locale;
$t_locale = new ca_locales();
if ($g_ui_locale_id = $t_locale->localeCodeToID($vs_locale)) {
$g_ui_locale = $vs_locale;
if (!initializeLocale($g_ui_locale)) {
die("Error loading locale " . $g_ui_locale);
}
$this->opo_request->reloadAppConfig();
}
}
$vs_post_data = $this->opo_request->getRawPostData();
if (strlen(trim($vs_post_data)) > 0) {
$this->opa_post = json_decode($vs_post_data, true);
if (!is_array($this->opa_post)) {
$this->addError(_t("Data sent via POST doesn't seem to be in JSON format"));
}
} else {
if ($vs_post_data = $this->opo_request->getParameter('source', pString)) {
$this->opa_post = json_decode($vs_post_data, true);
if (!is_array($this->opa_post)) {
$this->addError(_t("Data sent via 'source' parameter doesn't seem to be in JSON format"));
}
} else {
$this->opa_post = array();
}
}
$this->opa_valid_tables = array("ca_objects", "ca_object_lots", "ca_entities", "ca_places", "ca_occurrences", "ca_collections", "ca_list_items", "ca_lists", "ca_object_representations", "ca_storage_locations", "ca_movements", "ca_loans", "ca_tours", "ca_tour_stops", "ca_sets");
if (strlen($ps_table) > 0) {
if (!in_array($ps_table, $this->opa_valid_tables)) {
$this->addError(_t("Table does not exist"));
}
}
}
示例2: commandImportOralHistories
/**
* Import oral histories from specified directory into CollectiveAccess database
*/
public function commandImportOralHistories()
{
$o_conf = $this->getToolConfig();
// Get locale from config and translate to numeric code
$t_locale = new ca_locales();
$pn_locale_id = $t_locale->localeCodeToID($o_conf->get('locale'));
$o_log = $this->getLogger();
$o_progress = $this->getProgressBar(0);
$vs_transcript_dir = $this->getSetting("transcript_directory");
if (!is_readable($vs_transcript_dir)) {
if ($o_log) {
$o_log->logError($vs_err_msg = _t("Transcript directory %1 is not readable", $vs_transcript_dir));
}
if ($o_progress) {
$o_progress->setError($vs_err_msg);
$o_progress->finish();
}
return false;
}
$vs_audio_dir = $this->getSetting("audio_directory");
if (!is_readable($vs_audio_dir)) {
if ($o_log) {
$o_log->logError($vs_err_msg = _t("Audio directory %1 is not readable", $vs_audio_dir));
}
if ($o_progress) {
$o_progress->setError($vs_err_msg);
$o_progress->finish();
}
return false;
}
if ($o_progress) {
$o_progress->start("Starting oral history import");
}
// ----------------------------------------------------------------------
// process main data
$r_dir = opendir($vs_transcript_dir);
while (($vs_file = readdir($r_dir)) !== false) {
if ($vs_file[0] == '.') {
continue;
}
// Get markup and fix it up to be valid XML
$vs_markup = file_get_contents($vs_transcript_dir . $vs_file);
$vs_markup = preg_replace('!&!', '&', $vs_markup);
$vs_xml = "<?xml version=\"1.0\" encoding=\"utf-8\"?><transcript>{$vs_markup}</transcript>";
try {
$o_xml = new SimpleXMLElement($vs_xml);
} catch (Exception $e) {
$o_log->logError("Could not parse XML transcript for {$vs_transcript_dir}{$vs_file}: " . $e->getMessage());
continue;
}
$vs_idno = (string) $o_xml->identifier;
if (!file_exists($vs_media_path = "{$vs_audio_dir}{$vs_idno}.mp3")) {
$o_log->logError("No audio file found for {$vs_idno}. File path was {$vs_media_path}");
continue;
}
$vs_title = (string) $o_xml->title;
$vs_date_created = (string) $o_xml->datecreated;
$vs_format = (string) $o_xml->format;
$vs_medium = (string) $o_xml->medium;
$vs_place_recorded = (string) $o_xml->placeRecorded;
$vs_rights = (string) $o_xml->rights;
$vs_extent = (string) $o_xml->extent;
$vs_country = (string) $o_xml->countryOfOrigin;
$va_interviewers = array();
foreach ($o_xml->interviewer as $o_interviewer) {
$va_interviewers[(string) $o_interviewer->attributes()->abbreviation] = (string) $o_interviewer;
}
$va_participants = array();
foreach ($o_xml->participant as $o_participant) {
$va_participants[(string) $o_participant->attributes()->abbreviation] = (string) $o_participant;
}
$va_observers = array();
if ($o_xml->observer) {
foreach ($o_xml->observer as $o_observer) {
$va_observers[] = (string) $o_observer;
}
}
// Create object
$t_object = new ca_objects();
$t_object->setMode(ACCESS_WRITE);
if (!$t_object->load(array('idno' => $vs_idno, 'deleted' => 0))) {
$t_object->set('type_id', 'oral_history');
$t_object->set('idno', $vs_idno);
$t_object->set('status', 0);
$t_object->set('access', 1);
}
$t_object->addAttribute(array('locale_id' => $pn_locale_id, 'dc_format' => $vs_format), 'dc_format');
$t_object->addAttribute(array('locale_id' => $pn_locale_id, 'dates_value' => $vs_date_created, 'dc_dates_types' => 'created'), 'date');
$t_object->addAttribute(array('locale_id' => $pn_locale_id, 'medium' => $vs_medium), 'medium');
$t_object->addAttribute(array('locale_id' => $pn_locale_id, 'interview_location' => $vs_place_recorded), 'interview_location');
$t_object->addAttribute(array('locale_id' => $pn_locale_id, 'rights' => $vs_rights), 'rights');
$t_object->addAttribute(array('locale_id' => $pn_locale_id, 'extent' => $vs_extent), 'extent');
$t_object->addAttribute(array('locale_id' => $pn_locale_id, 'countryOfOrigin' => $vs_country), 'countryOfOrigin');
if (!$t_object->getPrimaryKey()) {
$t_object->insert();
DataMigrationUtils::postError($t_object, 'While inserting object');
if ($t_object->numErrors()) {
//.........这里部分代码省略.........
示例3: editItem
private function editItem()
{
if (!($t_instance = $this->_getTableInstance($this->ops_table, $this->opn_id))) {
return false;
}
$t_locales = new ca_locales();
$va_post = $this->getRequestBodyArray();
// intrinsic fields
if (is_array($va_post["intrinsic_fields"]) && sizeof($va_post["intrinsic_fields"])) {
foreach ($va_post["intrinsic_fields"] as $vs_field_name => $vs_value) {
$t_instance->set($vs_field_name, $vs_value);
}
}
// attributes
if (is_array($va_post["remove_attributes"])) {
foreach ($va_post["remove_attributes"] as $vs_code_to_delete) {
$t_instance->removeAttributes($vs_code_to_delete);
}
} else {
if ($va_post["remove_all_attributes"]) {
$t_instance->removeAttributes();
}
}
if (is_array($va_post["attributes"]) && sizeof($va_post["attributes"])) {
foreach ($va_post["attributes"] as $vs_attribute_name => $va_values) {
foreach ($va_values as $va_value) {
if ($va_value["locale"]) {
$va_value["locale_id"] = $t_locales->localeCodeToID($va_value["locale"]);
unset($va_value["locale"]);
}
$t_instance->addAttribute($va_value, $vs_attribute_name);
}
}
}
$t_instance->setMode(ACCESS_WRITE);
$t_instance->update();
// AFTER UPDATE STUFF
// yank all labels?
if ($va_post["remove_all_labels"]) {
$t_instance->removeAllLabels();
}
// preferred labels
if (is_array($va_post["preferred_labels"]) && sizeof($va_post["preferred_labels"])) {
foreach ($va_post["preferred_labels"] as $va_label) {
if ($va_label["locale"]) {
$vn_locale_id = $t_locales->localeCodeToID($va_label["locale"]);
unset($va_label["locale"]);
}
$t_instance->addLabel($va_label, $vn_locale_id, null, true);
}
}
// nonpreferred labels
if (is_array($va_post["nonpreferred_labels"]) && sizeof($va_post["nonpreferred_labels"])) {
foreach ($va_post["nonpreferred_labels"] as $va_label) {
if ($va_label["locale"]) {
$vn_locale_id = $t_locales->localeCodeToID($va_label["locale"]);
unset($va_label["locale"]);
}
if ($va_label["type_id"]) {
$vn_type_id = $va_label["type_id"];
unset($va_label["type_id"]);
} else {
$vn_type_id = null;
}
$t_instance->addLabel($va_label, $vn_locale_id, $vn_type_id, false);
}
}
// relationships
if (is_array($va_post["remove_relationships"])) {
foreach ($va_post["remove_relationships"] as $vs_table) {
$t_instance->removeRelationships($vs_table);
}
}
if ($va_post["remove_all_relationships"]) {
foreach ($this->opa_valid_tables as $vs_table) {
$t_instance->removeRelationships($vs_table);
}
}
if (is_array($va_post["related"]) && sizeof($va_post["related"]) > 0) {
foreach ($va_post["related"] as $vs_table => $va_relationships) {
foreach ($va_relationships as $va_relationship) {
$vs_source_info = isset($va_relationship["source_info"]) ? $va_relationship["source_info"] : null;
$vs_effective_date = isset($va_relationship["effective_date"]) ? $va_relationship["effective_date"] : null;
$vs_direction = isset($va_relationship["direction"]) ? $va_relationship["direction"] : null;
$t_rel_instance = $this->_getTableInstance($vs_table);
$vs_pk = isset($va_relationship[$t_rel_instance->primaryKey()]) ? $va_relationship[$t_rel_instance->primaryKey()] : null;
$vs_type_id = isset($va_relationship["type_id"]) ? $va_relationship["type_id"] : null;
$t_instance->addRelationship($vs_table, $vs_pk, $vs_type_id, $vs_effective_date, $vs_source_info, $vs_direction);
}
}
}
if ($t_instance->numErrors() > 0) {
foreach ($t_instance->getErrors() as $vs_error) {
$this->addError($vs_error);
}
return false;
} else {
return array($t_instance->primaryKey() => $t_instance->getPrimaryKey());
}
}
示例4: getPreferredUILocaleID
/**
*
*/
public function getPreferredUILocaleID()
{
if (!defined("__CA_DEFAULT_LOCALE__")) {
define("__CA_DEFAULT_LOCALE__", "en_US");
// if all else fails...
}
$t_locale = new ca_locales();
if ($vs_locale = $this->getPreference('ui_locale')) {
if ($vn_locale_id = $t_locale->localeCodeToID($vs_locale)) {
return $vn_locale_id;
}
}
$va_default_locales = $this->getAppConfig()->getList('locale_defaults');
if (sizeof($va_default_locales) && ($vn_locale_id = $t_locale->localeCodeToID($va_default_locales[0]))) {
return $vn_locale_id;
}
return $t_locale->localeCodeToID(__CA_DEFAULT_LOCALE__);
}
示例5: getCaptionFileList
/**
* Returns list of caption/subtitle files attached to a representation
* The return value is an array key'ed on the caption_id; array values are arrays
* with keys set to values for each file returned. They keys are:
* path = The absolute file path to the file
* url = The URL for the file
* caption_id = a unique identifier for each attached caption file
*
* @param int $pn_representation_id The representation_id of the representation to return files for. If omitted the currently loaded representation is used. If no representation_id is specified and no row is loaded null will be returned.
* @param array $pa_locale_ids
* @param array $pa_options
* @return array A list of caption files attached to the representations. If no files are associated an empty array is returned.
*/
public function getCaptionFileList($pn_representation_id = null, $pa_locale_ids = null, $pa_options = null)
{
if (!($vn_representation_id = $pn_representation_id)) {
if (!($vn_representation_id = $this->getPrimaryKey())) {
return null;
}
}
$t_locale = new ca_locales();
$va_locale_ids = array();
if ($pa_locale_ids) {
if (!is_array($pa_locale_ids)) {
$pa_locale_ids = array($pa_locale_ids);
}
foreach ($pa_locale_ids as $vn_i => $vm_locale) {
if (is_numeric($vm_locale) && (int) $vm_locale) {
$va_locale_ids[] = (int) $vm_locale;
} else {
if ($vn_locale_id = $t_locale->localeCodeToID($vm_locale)) {
$va_locale_ids[] = $vn_locale_id;
}
}
}
}
$vs_locale_sql = '';
$va_params = array((int) $vn_representation_id);
if (sizeof($va_locale_ids) > 0) {
$vs_locale_sql = " AND locale_id IN (?)";
$va_params[] = $va_locale_ids;
}
$o_db = $this->getDb();
$qr_res = $o_db->query("\n \t\t\tSELECT *\n \t\t\tFROM ca_object_representation_captions\n \t\t\tWHERE\n \t\t\t\trepresentation_id = ?\n \t\t\t{$vs_locale_sql}\n \t\t", $va_params);
$va_files = array();
while ($qr_res->nextRow()) {
$vn_caption_id = $qr_res->get('caption_id');
$vn_locale_id = $qr_res->get('locale_id');
$va_files[$vn_caption_id] = $qr_res->getRow();
unset($va_files[$vn_caption_id]['caption_file']);
$va_files[$vn_caption_id]['path'] = $qr_res->getFilePath('caption_file');
$va_files[$vn_caption_id]['url'] = $qr_res->getFileUrl('caption_file');
$va_files[$vn_caption_id]['filesize'] = caFormatFileSize(filesize($va_files[$vn_caption_id]['path']));
$va_files[$vn_caption_id]['caption_id'] = $vn_caption_id;
$va_files[$vn_caption_id]['locale_id'] = $vn_locale_id;
$va_files[$vn_caption_id]['locale'] = $t_locale->localeIDToName($vn_locale_id);
$va_files[$vn_caption_id]['locale_code'] = $t_locale->localeIDToCode($vn_locale_id);
}
return $va_files;
}
示例6: array
// TODO: move this into a library so $_, $g_ui_locale_id and $g_ui_locale gets set up automatically
require_once __CA_APP_DIR__ . "/helpers/initializeLocale.php";
$va_ui_locales = $g_request->config->getList('ui_locales');
if ($vs_lang = $g_request->getParameter('lang', pString)) {
if (in_array($vs_lang, $va_ui_locales)) {
$g_request->session->setVar('lang', $vs_lang);
}
}
if (!($g_ui_locale = $g_request->session->getVar('lang'))) {
$g_ui_locale = $va_ui_locales[0];
}
if (!in_array($g_ui_locale, $va_ui_locales)) {
$g_ui_locale = $va_ui_locales[0];
}
$t_locale = new ca_locales();
$g_ui_locale_id = $t_locale->localeCodeToID($g_ui_locale);
// get current UI locale as locale_id (available as global)
$_ = array();
if (file_exists($vs_theme_specific_locale_path = $g_request->getThemeDirectoryPath() . '/locale/' . $g_ui_locale . '/messages.mo')) {
$_[] = new Zend_Translate('gettext', $vs_theme_specific_locale_path, $g_ui_locale);
}
$_[] = new Zend_Translate('gettext', __CA_APP_DIR__ . '/locale/' . $g_ui_locale . '/messages.mo', $g_ui_locale);
if (!initializeLocale($g_ui_locale)) {
die("Error loading locale " . $g_ui_locale);
}
$g_request->reloadAppConfig();
// need to reload app config to reflect current locale
//
// PageFormat plug-in generates header/footer shell around page content
//
if (!$g_request->isAjax() && !$g_request->isDownload()) {
示例7: insert
public function insert($pa_options = null)
{
if (!$this->inTransaction()) {
$this->setTransaction(new Transaction());
}
if ($this->get('is_default')) {
$this->getDb()->query("\n\t\t\t\tUPDATE ca_list_items \n\t\t\t\tSET is_default = 0 \n\t\t\t\tWHERE list_id = ?\n\t\t\t", (int) $this->get('list_id'));
}
$vn_rc = parent::insert($pa_options);
if ($this->getPrimaryKey()) {
$t_list = new ca_lists();
$o_trans = $this->getTransaction();
$t_list->setTransaction($o_trans);
if ($t_list->load($this->get('list_id')) && $t_list->get('list_code') == 'place_hierarchies' && $this->get('parent_id')) {
// insert root or place hierarchy when creating non-root items in 'place_hierarchies' list
$t_locale = new ca_locales();
$va_locales = $this->getAppConfig()->getList('locale_defaults');
$vn_locale_id = $t_locale->localeCodeToID($va_locales[0]);
// create root in ca_places
$t_place = new ca_places();
$t_place->setTransaction($o_trans);
$t_place->setMode(ACCESS_WRITE);
$t_place->set('hierarchy_id', $this->getPrimaryKey());
$t_place->set('locale_id', $vn_locale_id);
$t_place->set('type_id', null);
$t_place->set('parent_id', null);
$t_place->set('idno', 'Root node for ' . $this->get('idno'));
$t_place->insert();
if ($t_place->numErrors()) {
$this->delete();
$this->errors = array_merge($this->errors, $t_place->errors);
return false;
}
$t_place->addLabel(array('name' => 'Root node for ' . $this->get('idno')), $vn_locale_id, null, true);
}
}
if ($this->numErrors()) {
$this->getTransaction()->rollback();
} else {
$this->getTransaction()->commit();
$this->_setSettingsForList();
}
return $vn_rc;
}
示例8: fetchAndImport
//.........这里部分代码省略.........
// TODO: add hook onBeforeInsert()
$t_instance->insert();
// TODO: add hook onInsert()
if ($t_instance->numErrors()) {
print "[ERROR] Could not insert record: " . join('; ', $t_instance->getErrors()) . "\n";
}
}
// add attributes
// TODO: make this configurable
$va_codes = $t_instance->getApplicableElementCodes();
// $va_codes = array(
// 'description',
// 'georeference', 'geonames', 'internal_notes',
// 'oclc_number', 'file_name',
// 'digitized_by', 'digitized_date', 'call_number',
// 'other_call_number', 'collection_title', 'collection_number',
// 'box_number', 'folder_number', 'volume_number', 'page_number', 'shelf',
// 'pulled_digitization', 'pulled_name', 'pulled_date', 'returned_digitization',
// 'returned_name', 'returned_date', 'needs_redigitization', 'donor', 'copyright_holder',
// 'reproduction_restrictions', 'administrative_notes', 'date_view', 'date_item',
// 'view_format', 'item_format', 'dimensions', 'map_scale', 'image_description', 'address',
// 'lcsh_terms', 'inscription'
//
// );
foreach ($va_codes as $vs_code) {
$t_element = $t_instance->_getElementInstance($vs_code);
switch ($t_element->get('datatype')) {
case 0:
// container
$va_elements = $t_element->getElementsInSet();
$o_attr = $o_item->{'ca_attribute_' . $vs_code};
foreach ($o_attr as $va_tag => $o_tags) {
foreach ($o_tags as $vs_locale => $o_values) {
if (!($vn_locale_id = $t_locale->localeCodeToID($vs_locale))) {
$vn_locale_id = null;
}
$va_container_data = array('locale_id' => $vn_locale_id);
foreach ($o_values as $o_value) {
foreach ($va_elements as $vn_i => $va_element_info) {
if ($va_element_info['datatype'] == 0) {
continue;
}
if ($vs_value = trim((string) $o_value->{$va_element_info['element_code']})) {
switch ($va_element_info['datatype']) {
case 3:
//list
$va_tmp = explode(":", $vs_value);
//<item_id>:<item_idno>
//print "CONTAINER LIST CODE=".$va_tmp[1]."/$vs_value/".$va_element_info['list_id']."\n";
$va_container_data[$va_element_info['element_code']] = $t_list->getItemIDFromList($va_element_info['list_id'], $va_tmp[1]);
break;
default:
$va_container_data[$va_element_info['element_code']] = $vs_value;
break;
}
}
}
$t_instance->replaceAttribute($va_container_data, $vs_code);
}
}
}
break;
case 3:
// list
$o_attr = $o_item->{'ca_attribute_' . $vs_code};
foreach ($o_attr as $va_tag => $o_tags) {
示例9: processLocales
public function processLocales()
{
require_once __CA_MODELS_DIR__ . "/ca_locales.php";
$t_locale = new ca_locales();
$t_locale->setMode(ACCESS_WRITE);
// Find any existing locales
$va_locales = $t_locale->getLocaleList(array('index_by_code' => true));
foreach ($va_locales as $vs_code => $va_locale) {
$this->opa_locales[$vs_code] = $va_locale['locale_id'];
}
if ($this->ops_base_name) {
$va_locales = array();
foreach ($this->opo_profile->locales->children() as $vo_locale) {
$va_locales[] = $vo_locale;
}
foreach ($this->opo_base->locales->children() as $vo_locale) {
$va_locales[] = $vo_locale;
}
} else {
$va_locales = $this->opo_profile->locales->children();
}
foreach ($va_locales as $vo_locale) {
$vs_language = self::getAttribute($vo_locale, "lang");
$vs_dialect = self::getAttribute($vo_locale, "dialect");
$vs_country = self::getAttribute($vo_locale, "country");
$vb_dont_use_for_cataloguing = self::getAttribute($vo_locale, "dontUseForCataloguing");
if (isset($this->opa_locales[$vs_language . "_" . $vs_country])) {
// don't insert duplicate locales
continue;
}
$t_locale->set('name', (string) $vo_locale);
$t_locale->set('country', $vs_country);
$t_locale->set('language', $vs_language);
if ($vs_dialect) {
$t_locale->set('dialect', $vs_dialect);
}
$t_locale->set('dont_use_for_cataloguing', (bool) $vb_dont_use_for_cataloguing);
$t_locale->insert();
if ($t_locale->numErrors()) {
$this->addError("There was an error while inserting locale {$vs_language}_{$vs_country}: " . join(" ", $t_locale->getErrors()));
}
$this->opa_locales[$vs_language . "_" . $vs_country] = $t_locale->getPrimaryKey();
}
$va_locales = $t_locale->getAppConfig()->getList('locale_defaults');
$vn_locale_id = $t_locale->localeCodeToID($va_locales[0]);
if (!$vn_locale_id) {
throw new Exception("The locale default is set to a non-existing locale. Try adding '" . $va_locales[0] . "' to your profile.");
}
return true;
}
示例10: commandImportSIPs
/**
* Import SIPs from specified directory into CollectiveAccess Database
*/
public function commandImportSIPs()
{
$o_conf = $this->getToolConfig();
$t = new Timer();
// Get locale from config and translate to numeric code
$t_locale = new ca_locales();
$pn_locale_id = $t_locale->localeCodeToID($o_conf->get('locale'));
$o_log = $this->getLogger();
$o_progress = $this->getProgressBar(0);
if ($o_progress) {
$o_progress->start("Starting import");
}
$vs_import_directory = $this->getSetting("import_directory");
if (!is_readable($vs_import_directory)) {
if ($o_log) {
$o_log->logError($vs_err_msg = _t("Import directory %1 is not readable", $vs_import_directory));
}
if ($o_progress) {
$o_progress->setError($vs_err_msg);
$o_progress->finish();
}
return false;
}
if ($o_log) {
$o_log->logDebug(_t("Started SIP import"));
}
//print "[1] ".$t->getTime(4)."\n";
// Look for ZIP files or directories
$va_files = caGetDirectoryContentsAsList($vs_import_directory, false, false, false, true);
//print "[2] ".$t->getTime(4)."\n";
$vn_count = 0;
foreach ($va_files as $vs_file) {
if (!preg_match("!\\.zip\$!i", $vs_file) && !is_dir($vs_file)) {
continue;
}
$vn_count++;
}
$o_progress->setTotal($vn_count);
//print "[3] ".$t->getTime(4)."\n";
foreach ($va_files as $vs_file) {
// Top level zips or directories
$vb_is_dir = is_dir($vs_file);
if (!preg_match("!\\.zip\$!i", $vs_file) && !$vb_is_dir) {
continue;
}
//print "[4] ".$t->getTime(4)."\n";
$o_progress->setMessage(_t('Processing %1', $vs_file));
// unpack ZIP
$va_package_files = caGetDirectoryContentsAsList($vb_is_dir ? $vs_file : 'phar://' . $vs_file . '/', false, false, false, true);
// files in top level of directory or zip
//foreach($va_package_files as $vs_package_path) {
//$va_tmp = explode("/", $vs_package_path);
//$vs_package_dir = array_pop($va_tmp);
$va_archive_files = caGetDirectoryContentsAsList($vb_is_dir ? $vs_file : 'phar://' . $vs_file, true);
// Does it look like a SIP?
$vb_is_sip = false;
$vs_idno = $vs_idno_padded = $vs_zip_path = $vs_category = null;
$va_sides = array();
foreach ($va_archive_files as $vs_archive_file) {
if ($o_log) {
$o_log->logDebug(_t("Testing file %1 for SIP-ness", $vs_archive_file));
}
if (preg_match("!category.txt\$!", $vs_archive_file)) {
$vb_is_sip = true;
$va_tmp = explode("/", $vs_archive_file);
array_pop($va_tmp);
// pop category.txt
$vs_idno = array_pop($va_tmp);
$va_tmp_idno = explode("-", $vs_idno);
$va_tmp_idno[2] = str_pad($va_tmp_idno[2], 6, "0", STR_PAD_LEFT);
$vs_idno_padded = join("-", $va_tmp_idno);
$vs_category = strtolower(preg_replace("![^A-Z \\-a-z0-9]!", "", file_get_contents($vs_archive_file)));
// Translate categories
switch ($vs_category) {
case 'mixed':
$vs_category = 'unclassified';
break;
}
$vs_zip_path = join("/", $va_tmp);
if ($o_log) {
$o_log->logInfo(_t("Found SIP %1 with category %2", $vs_archive_dir, $vs_category));
}
continue;
}
}
if (!$vb_is_sip) {
if ($o_progress) {
$o_progress->setError(_t('File %1 is not a valid SIP', $vs_file));
}
if ($o_log) {
$o_log->logWarn(_t('File %1 is not a valid SIP', $vs_file));
}
continue;
}
//print "[5] ".$t->getTime(4)."\n";
$va_track_audio_by_side = $va_track_xml_by_side = $va_side_audio = $va_side_xml = $va_artifacts = array();
// Reset total # of SIPS with contents of ZIP
//.........这里部分代码省略.........