本文整理汇总了PHP中ca_lists::getItemIDFromList方法的典型用法代码示例。如果您正苦于以下问题:PHP ca_lists::getItemIDFromList方法的具体用法?PHP ca_lists::getItemIDFromList怎么用?PHP ca_lists::getItemIDFromList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ca_lists
的用法示例。
在下文中一共展示了ca_lists::getItemIDFromList方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct(&$po_request, &$po_response, $pa_view_paths = null)
{
$this->ops_theme = __CA_THEME__;
// get current theme
if (!is_dir(__CA_APP_DIR__ . '/plugins/NovaMuse/themes/' . $this->ops_theme . '/views')) {
// if theme is not defined for this plugin, try to use "default" theme
$this->ops_theme = 'default';
}
parent::__construct($po_request, $po_response, array(__CA_APP_DIR__ . '/plugins/NovaMuse/themes/' . $this->ops_theme . '/views'));
$this->opo_plugin_config = Configuration::load($this->request->getAppConfig()->get('application_plugins') . '/NovaMuse/conf/NovaMuse.conf');
if (!(bool) $this->opo_plugin_config->get('enabled')) {
die(_t('NovaMuse plugin is not enabled'));
}
MetaTagManager::addLink('stylesheet', $po_request->getBaseUrlPath() . "/app/plugins/NovaMuse/themes/" . $this->ops_theme . "/css/dashboard.css", 'text/css');
$this->opo_result_context = new ResultContext($po_request, 'ca_objects', 'dashboard');
$t_list = new ca_lists();
$this->opn_member_institution_id = $t_list->getItemIDFromList('entity_types', 'member_institution');
$this->opn_individual_id = $t_list->getItemIDFromList('entity_types', 'ind');
$this->opn_family_id = $t_list->getItemIDFromList('entity_types', 'fam');
$this->opn_organization_id = $t_list->getItemIDFromList('entity_types', 'org');
$t_object = new ca_objects();
$this->opn_objectTableNum = $t_object->tableNum();
$va_access_values = caGetUserAccessValues($this->request);
$this->opa_access_values = $va_access_values;
$this->view->setVar('access_values', $va_access_values);
}
示例2: __construct
public function __construct(&$po_request, &$po_response, $pa_view_paths = null)
{
$this->ops_theme = __CA_THEME__;
// get current theme
if (!is_dir(__CA_APP_DIR__ . '/plugins/MetabolicChronology/themes/' . $this->ops_theme . '/views')) {
// if theme is not defined for this plugin, try to use "default" theme
$this->ops_theme = 'default';
}
parent::__construct($po_request, $po_response, array(__CA_APP_DIR__ . '/plugins/MetabolicChronology/themes/' . $this->ops_theme . '/views'));
$this->opo_plugin_config = Configuration::load($this->request->getAppConfig()->get('application_plugins') . '/MetabolicChronology/conf/Chronology.conf');
if (!(bool) $this->opo_plugin_config->get('enabled')) {
die(_t('Metabolic Chronology plugin is not enabled'));
}
$this->_initView($pa_options);
$this->opo_result_context = new ResultContext($po_request, 'ca_objects', 'MetabolicChronology');
MetaTagManager::addLink('stylesheet', $po_request->getBaseUrlPath() . "/app/plugins/MetabolicChronology/themes/" . $this->ops_theme . "/css/chronology.css", 'text/css');
JavascriptLoadManager::register('jcarousel');
JavascriptLoadManager::register('maps');
$t_list = new ca_lists();
$this->opn_silo_type_id = $t_list->getItemIDFromList('collection_types', 'silo');
$this->opn_action_type_id = $t_list->getItemIDFromList('occurrence_types', 'action');
$this->opn_context_type_id = $t_list->getItemIDFromList('occurrence_types', 'context');
$this->opn_yes_list_id = $t_list->getItemIDFromList('yes_no', 'yes');
$t_relationship_types = new ca_relationship_types();
$this->opn_rel_type_action_display_image = $t_relationship_types->getRelationshipTypeID("ca_objects_x_occurrences", "display");
$this->opn_rel_type_action_secondary_images = $t_relationship_types->getRelationshipTypeID("ca_objects_x_occurrences", "secondary");
$va_access_values = caGetUserAccessValues($this->request);
$this->opa_access_values = $va_access_values;
$this->view->setVar('access_values', $va_access_values);
}
示例3: __construct
/**
*
*/
public function __construct(&$po_request, &$po_response, $pa_view_paths = null)
{
$this->ops_theme = __CA_THEME__;
// get current theme
if (!is_dir(__CA_APP_DIR__ . '/plugins/Contribute/themes/' . $this->ops_theme . '/views')) {
// if theme is not defined for this plugin, try to use "default" theme
$this->ops_theme = 'default';
}
parent::__construct($po_request, $po_response, array(__CA_APP_DIR__ . '/plugins/Contribute/themes/' . $this->ops_theme . '/views'));
#$this->opo_plugin_config = Configuration::load($po_request->getAppConfig()->get('application_plugins').'/Contribute/conf/contribute.conf');
if (file_exists($po_request->getAppConfig()->get('application_plugins') . '/Contribute/themes/' . $this->ops_theme . '/conf/contribute.conf')) {
// check if there is a config file in the theme first
$this->opo_plugin_config = Configuration::load($po_request->getAppConfig()->get('application_plugins') . '/Contribute/themes/' . $this->ops_theme . '/conf/contribute.conf');
} else {
$this->opo_plugin_config = Configuration::load($po_request->getAppConfig()->get('application_plugins') . '/Contribute/conf/contribute.conf');
}
if (!(bool) $this->opo_plugin_config->get('enabled')) {
die(_t('Contribute plugin is not enabled'));
}
$vs_default_ui = $this->opo_plugin_config->get('default_ui');
$vs_requested_ui = $this->request->getParameter('ui', pString);
$va_ui_list = $this->opo_plugin_config->getAssoc('uis');
$o_dm = Datamodel::load();
if (isset($va_ui_list[$vs_requested_ui]) && is_array($va_ui_list[$vs_requested_ui])) {
$this->opa_ui_info = $va_ui_list[$vs_requested_ui];
$this->ops_ui_code = $vs_requested_ui;
} else {
if (isset($va_ui_list[$vs_default_ui]) && is_array($va_ui_list[$vs_default_ui])) {
$this->opa_ui_info = $va_ui_list[$vs_default_ui];
} else {
$vs_default_ui = array_shift(array_keys($va_ui_list));
$this->opa_ui_info = $va_ui_list[$vs_default_ui];
}
$this->ops_ui_code = $vs_default_ui;
}
$this->ops_table_name = $this->opa_ui_info['table'];
if (!($this->opo_instance = $o_dm->getInstanceByTableName($this->ops_table_name, true))) {
die(_t('Invalid table "%1" specified in Contribute plugin for form "%2"', $this->ops_table_name, $vs_default_ui));
}
$t_list = new ca_lists();
if (isset($this->opa_ui_info['type']) && $this->opa_ui_info['type']) {
$this->opa_ui_info['type_id'] = $t_list->getItemIDFromList($this->opo_instance->getTypeListCode(), $this->opa_ui_info['type']);
}
if (isset($this->opa_ui_info['representation_type']) && $this->opa_ui_info['representation_type']) {
$this->opa_ui_info['representation_type_id'] = $t_list->getItemIDFromList('object_representation_types', $this->opa_ui_info['representation_type']);
}
ContributePlugin::setUIInfo($this->ops_ui_code, $this->opa_ui_info);
JavascriptLoadManager::register('panel');
MetaTagManager::addLink('stylesheet', $po_request->getBaseUrlPath() . "/app/plugins/Contribute/themes/" . $this->ops_theme . "/css/contribute.css", 'text/css');
$this->request->setParameter('dont_set_pawtucket2_last_page', '1');
// Setting this parameter ensures that the "last page" we (may) redirect to after submission isn't the Contribute form itself
if ($this->opa_ui_info['require_login'] && !$po_request->isLoggedIn()) {
$this->notification->addNotification(_t("You must be logged in to use user contribution features."), __NOTIFICATION_TYPE_ERROR__);
$this->response->setRedirect(caNavUrl($this->request, '', 'LoginReg', 'form'));
return;
}
}
示例4: caGetListItemID
function caGetListItemID($ps_list_code, $ps_idno)
{
global $g_list_item_id_cache;
if (isset($g_list_item_id_cache[$ps_list_code . '/' . $ps_idno])) {
return $g_list_item_id_cache[$ps_list_code . '/' . $ps_idno];
}
$t_list = new ca_lists();
return $g_list_item_id_cache[$ps_list_code . '/' . $ps_idno] = $t_list->getItemIDFromList($ps_list_code, $ps_idno);
}
示例5: __construct
public function __construct(&$po_request, &$po_response, $pa_view_paths = null)
{
$this->ops_theme = __CA_THEME__;
// get current theme
if (!is_dir(__CA_APP_DIR__ . '/plugins/eastend/themes/' . $this->ops_theme . '/views')) {
// if theme is not defined for this plugin, try to use "default" theme
$this->ops_theme = 'default';
}
parent::__construct($po_request, $po_response, array(__CA_APP_DIR__ . '/plugins/eastend/themes/' . $this->ops_theme . '/views'));
MetaTagManager::addLink('stylesheet', $po_request->getBaseUrlPath() . "/app/plugins/eastend/themes/" . $this->ops_theme . "/css/eastend.css", 'text/css');
$this->opo_plugin_config = Configuration::load($this->request->getAppConfig()->get('application_plugins') . '/eastend/conf/eastend.conf');
if (!(bool) $this->opo_plugin_config->get('enabled')) {
die(_t('eastend plugin is not enabled'));
}
// redirect user if not logged in
if ($this->request->config->get('pawtucket_requires_login') && !$this->request->isLoggedIn()) {
$this->response->setRedirect(caNavUrl($this->request, "", "LoginReg", "form"));
}
JavascriptLoadManager::register('cycle');
$t_list = new ca_lists();
$this->view->setVar("user_contributed_source_id", $t_list->getItemIDFromList('object_sources', 'user_contributed'));
$this->view->setVar("user_contributed_other_source_id", $t_list->getItemIDFromList('object_sources', 'user_contributed_other'));
}
示例6: __call
/**
*
*/
public function __call($ps_function, $pa_args)
{
$ps_function = strtolower($ps_function);
# --- which type of set is configured for display in gallery section
$t_list = new ca_lists();
$vn_gallery_set_type_id = $t_list->getItemIDFromList('set_types', $this->config->get('gallery_set_type'));
$t_set = new ca_sets();
if ($ps_function == "index") {
if ($vn_gallery_set_type_id) {
$va_sets = caExtractValuesByUserLocale($t_set->getSets(array('table' => 'ca_objects', 'checkAccess' => $this->opa_access_values, 'setType' => $vn_gallery_set_type_id)));
$va_set_first_items = $t_set->getFirstItemsFromSets(array_keys($va_sets), array("version" => "icon", "checkAccess" => $this->opa_access_values));
$o_front_config = caGetFrontConfig();
$vs_front_page_set = $o_front_config->get('front_page_set_code');
$vb_omit_front_page_set = (bool) $this->config->get('omit_front_page_set_from_gallery');
foreach ($va_sets as $vn_set_id => $va_set) {
if ($vb_omit_front_page_set && $va_set['set_code'] == $vs_front_page_set) {
unset($va_sets[$vn_set_id]);
}
}
$this->view->setVar('sets', $va_sets);
$this->view->setVar('first_items_from_sets', $va_set_first_items);
}
MetaTagManager::setWindowTitle($this->request->config->get("app_display_name") . ": " . ($this->config->get('gallery_section_name') ? $this->config->get('gallery_section_name') : _t("Gallery")));
$this->render("Gallery/index_html.php");
} else {
$ps_set_id = $ps_function;
$this->view->setVar("set_id", $ps_set_id);
$t_set->load($ps_set_id);
$this->view->setVar("set", $t_set);
$this->view->setVar("label", $t_set->getLabelForDisplay());
$this->view->setVar("description", $t_set->get($this->config->get('gallery_set_description_element_code')));
$this->view->setVar("set_items", caExtractValuesByUserLocale($t_set->getItems(array("thumbnailVersions" => array("icon", "iconlarge"), "checkAccess" => $this->opa_access_values))));
$pn_set_item_id = $this->request->getParameter('set_item_id', pInteger);
if (!in_array($pn_set_item_id, array_keys($t_set->getItemIDs()))) {
$pn_set_item_id = "";
}
$this->view->setVar("set_item_id", $pn_set_item_id);
MetaTagManager::setWindowTitle($this->request->config->get("app_display_name") . ": " . ($this->config->get('gallery_section_name') ? $this->config->get('gallery_section_name') : _t("Gallery")) . ": " . $t_set->getLabelForDisplay());
$this->render("Gallery/detail_html.php");
}
}
示例7: Index
public function Index()
{
JavascriptLoadManager::register('imageScroller');
$va_access_values = caGetUserAccessValues($this->request);
// get sets for public display
$t_list = new ca_lists();
$vn_public_set_type_id = $t_list->getItemIDFromList('set_types', $t_list->getAppConfig()->get('features_set_type'));
// get value for public access status value
$va_tmp = $t_list->getItemFromList('access_statuses', 'public_access');
$vn_public_access = $va_tmp['item_value'];
$t_set = new ca_sets();
$va_sets = caExtractValuesByUserLocale($t_set->getSets(array('table' => 'ca_objects', 'checkAccess' => $va_access_values, 'setType' => $vn_public_set_type_id)));
$va_set_ids = array();
foreach ($va_sets as $va_set) {
$va_set_ids[] = $va_set['set_id'];
}
$this->view->setVar('sets', $va_sets);
$this->view->setVar('set_ids', $va_set_ids);
$this->view->setVar('set_display_items', ca_sets::getFirstItemsFromSets($va_set_ids, array("version" => "preview160")));
$this->render('features_landing_html.php');
}
示例8: addNewSet
public function addNewSet()
{
if (!$this->request->isLoggedIn()) {
$this->response->setRedirect(caNavUrl($this->request, '', 'LoginReg', 'form'));
return;
}
global $g_ui_locale_id;
// current locale_id for user
$va_errors_new_set = array();
$t_new_set = new ca_sets();
$pn_set_id = $this->request->getParameter('set_id', pInteger);
$ps_name = $this->request->getParameter('name', pString);
if (!$ps_name) {
$va_errors_new_set["name"] = _t("Please enter the name of your collection");
}
$vs_desc = $this->request->getParameter('description', pString);
$t_list = new ca_lists();
$vn_set_type_user = $t_list->getItemIDFromList('set_types', 'user');
if (sizeof($va_errors_new_set) == 0) {
$t_new_set->setMode(ACCESS_WRITE);
$t_new_set->set('access', $this->request->getParameter('access', pInteger));
$t_new_set->set('table_num', 57);
// 57=ca_objects
$t_new_set->set('type_id', $vn_set_type_user);
// type="user"
$t_new_set->set('user_id', $this->request->getUserID());
$t_new_set->set('set_code', $this->request->getUserID() . '_' . time());
// create new attribute
$t_new_set->addAttribute(array('set_intro' => $vs_desc, 'locale_id' => $g_ui_locale_id), 'set_intro');
$t_new_set->insert();
if ($vn_new_set_id = $t_new_set->getPrimaryKey()) {
$t_new_set->addLabel(array('name' => $ps_name), $g_ui_locale_id, null, true);
// select the current set
$this->request->user->setVar('current_set_id', $vn_new_set_id);
//clear t_new_set object so form appears blank and load t_set so edit form is populated
$t_new_set = new ca_sets();
$t_set = new ca_sets($vn_new_set_id);
}
}
$this->view->setVar('errors_new_set', $va_errors_new_set);
$this->index();
}
示例9: setSourceRestrictions
/**
* When source restrictions are specified, the search will only consider items of the given sources.
* If you specify a source that has hierarchical children then the children will automatically be included
* in the restriction. You may pass numeric source_id and alphanumeric source codes interchangeably.
*
* @param array $pa_source_codes_or_ids List of source_id or code values to filter search by. When set, the search will only consider items of the specified sources. Using a hierarchical parent source will automatically include its children in the restriction.
* @param array $pa_options Options include
* includeSubsources = include any child sources in the restriction. Default is true.
* @return boolean True on success, false on failure
*/
public function setSourceRestrictions($pa_source_codes_or_ids, $pa_options = null)
{
$t_instance = $this->opo_datamodel->getInstanceByTableName($this->ops_tablename, true);
if (!$pa_source_codes_or_ids) {
return false;
}
if (is_array($pa_source_codes_or_ids) && !sizeof($pa_source_codes_or_ids)) {
return false;
}
if (!is_array($pa_source_codes_or_ids)) {
$pa_source_codes_or_ids = array($pa_source_codes_or_ids);
}
$t_list = new ca_lists();
if (!method_exists($t_instance, 'getSourceListCode')) {
return false;
}
if (!($vs_list_name = $t_instance->getSourceListCode())) {
return false;
}
$va_source_list = $t_instance->getSourceList();
$this->opa_search_source_ids = array();
foreach ($pa_source_codes_or_ids as $vs_code_or_id) {
if (!strlen($vs_code_or_id)) {
continue;
}
if (!is_numeric($vs_code_or_id)) {
$vn_source_id = $t_list->getItemIDFromList($vs_list_name, $vs_code_or_id);
} else {
$vn_source_id = (int) $vs_code_or_id;
}
if (!$vn_source_id) {
return false;
}
if (isset($va_source_list[$vn_source_id]) && $va_source_list[$vn_source_id]) {
// is valid source for this subject
if (caGetOption('includeSubsources', $pa_options, true)) {
// See if there are any child sources
$t_item = new ca_list_items($vn_source_id);
$va_ids = $t_item->getHierarchyChildren(null, array('idsOnly' => true));
$va_ids[] = $vn_source_id;
$this->opa_search_source_ids = array_merge($this->opa_search_source_ids, $va_ids);
}
}
}
return true;
}
示例10: _convertSourceCodesToIDs
/**
*
*
* @param array $pa_source_codes_or_ids List of source codes or ids
* @param array $pa_options Options include
* includeSubsources = include any child sources in the restriction. Default is true.
* @return array List of source_ids
*/
private function _convertSourceCodesToIDs($pa_source_codes_or_ids, $pa_options = null)
{
$vs_md5 = caMakeCacheKeyFromOptions($pa_source_codes_or_ids);
if (isset(BrowseEngine::$s_source_id_cache[$vs_md5])) {
return BrowseEngine::$s_source_id_cache[$vs_md5];
}
if (isset($pa_options['instance']) && is_object($pa_options['instance'])) {
$t_instance = $pa_options['instance'];
} else {
$t_instance = $this->getSubjectInstance();
}
$va_source_ids = array();
if (!$pa_source_codes_or_ids) {
return false;
}
if (is_array($pa_source_codes_or_ids) && !sizeof($pa_source_codes_or_ids)) {
return false;
}
if (!is_array($pa_source_codes_or_ids)) {
$pa_source_codes_or_ids = array($pa_source_codes_or_ids);
}
$t_list = new ca_lists();
if (!method_exists($t_instance, 'getSourceListCode')) {
return false;
}
if (!($vs_list_name = $t_instance->getSourceListCode())) {
return false;
}
$va_source_list = $t_instance->getSourceList();
foreach ($pa_source_codes_or_ids as $vs_code_or_id) {
if (!trim($vs_code_or_id)) {
continue;
}
if (!is_numeric($vs_code_or_id)) {
$vn_source_id = $t_list->getItemIDFromList($vs_list_name, $vs_code_or_id);
} else {
$vn_source_id = (int) $vs_code_or_id;
}
if (!$vn_source_id) {
return false;
}
if (isset($va_source_list[$vn_source_id]) && $va_source_list[$vn_source_id]) {
// is valid source for this subject
// See if there are any child sources
if (caGetOption('includeSubsources', $pa_options, true) && $this->opb_dont_expand_source_restrictions) {
$t_item = new ca_list_items($vn_source_id);
$va_ids = $t_item->getHierarchyChildren(null, array('idsOnly' => true));
}
$va_ids[] = $vn_source_id;
$va_source_ids = array_merge($va_source_ids, $va_ids);
}
}
$va_source_ids = array_keys(array_flip($va_source_ids));
BrowseEngine::$s_source_id_cache[$vs_md5] = $va_source_ids;
return $va_source_ids;
}
示例11: fetchAndImport
private function fetchAndImport($pa_item_queue, $po_client, $pa_config, $pa_tables, $ps_code)
{
if (!is_array($pa_tables)) {
$pa_tables = array();
}
$t_rel_type = new ca_relationship_types();
$vs_base_url = $pa_config['baseUrl'];
$o_dm = Datamodel::load();
$t_locale = new ca_locales();
$t_list = new ca_lists();
$vn_source_id = $t_list->getItemIDFromList('object_sources', $pa_config['code']);
$pn_rep_type_id = $t_list->getItemIDFromList('object_representation_types', 'front');
foreach ($pa_item_queue as $vn_i => $va_item) {
$vs_table = $va_item['table'];
$va_import_relationships_from = $pa_config['importRelatedFor'][$va_item['table']];
print "oo";
print_r($va_import_relationships_from);
$vn_id = $va_item['id'];
if (!$vn_id) {
print "[Notice] SKIP CAUSE NO ID ({$ps_code})\n";
continue;
}
if (isset($this->opa_processed_records[$vs_table . '/' . $vn_id])) {
continue;
}
$vs_idno = trim((string) $va_item['idno']);
try {
$o_xml = $po_client->getItem($vs_table, $vn_id)->get();
} catch (exception $e) {
print "[ERROR] While trying to get item information: " . $e->getMessage() . "\n";
continue;
}
$o_item = $o_xml->getItem;
$t_instance = $o_dm->getInstanceByTableName($vs_table, false);
$t_instance_label = $t_instance->getLabelTableInstance();
// Look for existing record
$vb_skip = false;
$vb_update = false;
$vs_label_fld = $t_instance->getLabelDisplayField();
$vs_label = (string) $o_item->preferred_labels->en_US->{$vs_label_fld};
print "[Notice] Processing [{$vs_table}] {$vs_label} [{$vs_idno}] ({$ps_code})\n";
$t_instance_label->clear();
if ($vs_idno && ($vs_table == 'ca_objects' && $t_instance->load(array('idno' => $vs_idno)) || $vs_table != 'ca_objects' && $t_instance->load(array('idno' => $vs_idno)))) {
if ($t_instance->hasField('deleted') && $t_instance->get('deleted') == 1) {
$t_instance->set('deleted', 0);
}
//print "[Notice] Update [{$vs_idno}] for {$vs_table} 'cause it already exists ({$ps_code})\n";
if (!$t_instance->getPrimaryKey()) {
$vb_skip = true;
print "[ERROR] Could not load instance for [{$vs_idno}]\n";
}
$vb_update = true;
$t_instance->setMode(ACCESS_WRITE);
// Clear labels
$t_instance->removeAllLabels();
if ($t_instance->numErrors()) {
print "[ERROR] Could not remove labels for updating: " . join("; ", $t_instance->getErrors()) . "\n";
}
// Clear attributes
$t_instance->removeAttributes(null, array('dontCheckMinMax' => true));
if ($t_instance->numErrors()) {
print "[ERROR] Could not remove attributes for updating: " . join("; ", $t_instance->getErrors()) . "\n";
}
// Clear relationships
if (is_array($va_import_relationships_from)) {
foreach ($va_import_relationships_from as $vs_rel_table => $va_table_info) {
$t_instance->removeRelationships($vs_rel_table);
if ($t_instance->numErrors()) {
print "[ERROR] Could not remove {$vs_rel_table} relationships for updating: " . join("; ", $t_instance->getErrors()) . "\n";
}
}
}
if ($t_instance->tableName() == 'ca_objects') {
//$t_instance->set('source_id', $vn_source_id);
}
$t_instance->update();
if ($t_instance->numErrors()) {
print "[ERROR] Could not clear record for updating: " . join("; ", $t_instance->getErrors()) . "\n";
}
}
// create new one
if (!$vb_update) {
$t_instance->clear();
if ($t_instance->tableName() == 'ca_objects') {
//$t_instance->set('source_id', $vn_source_id);
}
}
$t_instance->setMode(ACCESS_WRITE);
// add intrinsics
switch ($vs_table) {
case 'ca_collections':
$va_intrinsics = array('status', 'access', 'idno');
break;
case 'ca_occurrences':
$va_intrinsics = array('status', 'access', 'idno');
break;
case 'ca_objects':
$va_intrinsics = array('status', 'access', 'idno');
break;
case 'ca_entities':
//.........这里部分代码省略.........
示例12: processUserInterfaces
public function processUserInterfaces()
{
require_once __CA_MODELS_DIR__ . "/ca_editor_uis.php";
require_once __CA_MODELS_DIR__ . "/ca_editor_ui_screens.php";
require_once __CA_MODELS_DIR__ . "/ca_lists.php";
require_once __CA_MODELS_DIR__ . "/ca_list_items.php";
require_once __CA_MODELS_DIR__ . "/ca_relationship_types.php";
$vo_dm = Datamodel::load();
$t_list = new ca_lists();
$t_rel_types = new ca_relationship_types();
$va_uis = array();
if ($this->ops_base_name) {
// "merge" profile and its base
foreach ($this->opo_base->userInterfaces->children() as $vo_ui) {
$va_uis[self::getAttribute($vo_ui, "code")] = $vo_ui;
}
foreach ($this->opo_profile->userInterfaces->children() as $vo_ui) {
$va_uis[self::getAttribute($vo_ui, "code")] = $vo_ui;
}
} else {
foreach ($this->opo_profile->userInterfaces->children() as $vo_ui) {
$va_uis[self::getAttribute($vo_ui, "code")] = $vo_ui;
}
}
foreach ($va_uis as $vs_ui_code => $vo_ui) {
$vs_type = self::getAttribute($vo_ui, "type");
if (!($vn_type = $vo_dm->getTableNum($vs_type))) {
$this->addError("Invalid type {$vs_type} for UI code {$vs_ui_code}");
return false;
}
// model instance of UI type
$t_instance = $vo_dm->getInstanceByTableNum($vn_type);
// create ui row
$t_ui = ca_editor_uis::find(array('editor_code' => $vs_ui_code, 'editor_type' => $vn_type), array('returnAs' => 'firstModelInstance'));
$t_ui = $t_ui ? $t_ui : new ca_editor_uis();
$t_ui->setMode(ACCESS_WRITE);
$t_ui->set('user_id', null);
$t_ui->set('is_system_ui', 1);
$t_ui->set('editor_code', $vs_ui_code);
$t_ui->set('editor_type', $vn_type);
if ($t_ui->getPrimaryKey()) {
$t_ui->update();
} else {
$t_ui->insert();
}
if ($t_ui->numErrors()) {
$this->addError("Errors inserting UI {$vs_ui_code}: " . join("; ", $t_ui->getErrors()));
return false;
}
$vn_ui_id = $t_ui->getPrimaryKey();
self::addLabelsFromXMLElement($t_ui, $vo_ui->labels, $this->opa_locales);
// create ui type restrictions
if ($vo_ui->typeRestrictions) {
foreach ($vo_ui->typeRestrictions->children() as $vo_restriction) {
$vs_restriction_type = self::getAttribute($vo_restriction, "type");
if (strlen($vs_restriction_type) > 0) {
// interstitial with type restriction -> code is relationship type code
if ($t_instance instanceof BaseRelationshipModel) {
$vn_type_id = $t_rel_types->getRelationshipTypeID($t_instance->tableName(), $vs_restriction_type);
} else {
// "normal" type restriction -> code is from actual type list
$vs_type_list_name = $t_instance->getFieldListCode($t_instance->getTypeFieldName());
$vn_type_id = $t_list->getItemIDFromList($vs_type_list_name, $vs_restriction_type);
}
if ($vn_type_id) {
$t_ui->addTypeRestriction($vn_type_id);
}
}
}
}
// create ui screens
foreach ($vo_ui->screens->children() as $vo_screen) {
$vs_screen_idno = self::getAttribute($vo_screen, "idno");
$vn_is_default = self::getAttribute($vo_screen, "default");
$t_ui_screens = ca_editor_ui_screens::find(array('idno' => $vs_screen_idno, 'ui_id' => $vn_ui_id), array('returnAs' => 'firstModelInstance'));
$t_ui_screens = $t_ui_screens ? $t_ui_screens : new ca_editor_ui_screens();
$t_ui_screens->setMode(ACCESS_WRITE);
$t_ui_screens->set('idno', $vs_screen_idno);
$t_ui_screens->set('ui_id', $vn_ui_id);
$t_ui_screens->set('is_default', $vn_is_default);
if ($t_ui_screens->getPrimaryKey()) {
$t_ui_screens->update();
} else {
$t_ui_screens->set('parent_id', null);
$t_ui_screens->insert();
}
if ($t_ui_screens->numErrors()) {
$this->addError("Errors inserting UI screen {$vs_screen_idno} for UI {$vs_ui_code}: " . join("; ", $t_ui_screens->getErrors()));
return false;
}
self::addLabelsFromXMLElement($t_ui_screens, $vo_screen->labels, $this->opa_locales);
$va_available_bundles = $t_ui_screens->getAvailableBundles(null, array('dontCache' => true));
// create ui bundle placements
foreach ($vo_screen->bundlePlacements->children() as $vo_placement) {
$vs_placement_code = self::getAttribute($vo_placement, "code");
$vs_bundle = trim((string) $vo_placement->bundle);
$va_settings = $this->_processSettings(null, $vo_placement->settings);
$t_ui_screens->addPlacement($vs_bundle, $vs_placement_code, $va_settings, null, array('additional_settings' => $va_available_bundles[$vs_bundle]['settings']));
}
// create ui screen type restrictions
//.........这里部分代码省略.........
示例13: join
$t_list->set('is_hierarchical', 1);
$t_list->set('use_as_vocabulary', 1);
$t_list->insert();
if ($t_list->numErrors()) {
print "ERROR: couldn't create ca_list row for AAT: " . join('; ', $t_list->getErrors()) . "\n";
die;
}
$t_list->addLabel(array('name' => 'Art & Architecture Thesaurus [Nederlands]'), $pn_en_locale_id, null, true);
}
$vn_list_id = $t_list->getPrimaryKey();
// get list item types (should be defined by base installation profile [base.profile])
// if your installation didn't use a profile inheriting from base.profile then you should make sure
// that a list with code='list_item_types' is defined and the following four item codes are defined.
// If these are not defined then the AAT will still import, but without any distinction between
// terms, facets and guide terms
$vn_list_item_type_concept = $t_list->getItemIDFromList('list_item_types', 'concept');
$vn_list_item_type_facet = $t_list->getItemIDFromList('list_item_types', 'facet');
$vn_list_item_type_guide_term = $t_list->getItemIDFromList('list_item_types', 'guide_term');
$vn_list_item_type_hierarchy_name = $t_list->getItemIDFromList('list_item_types', 'hierarchy_name');
// get list item label types (should be defined by base installation profile [base.profile])
// if your installation didn't use a profile inheriting from base.profile then you should make sure
// that a list with code='list_item_label_types' is defined and the following four item codes are defined.
// If these are not defined then the AAT will still import, but without any distinction between
// terms, facets and guide terms
$vn_list_item_label_type_uf = $t_list->getItemIDFromList('list_item_label_types', 'uf');
$vn_list_item_label_type_alt = $t_list->getItemIDFromList('list_item_label_types', 'alt');
// get list item-to-item relationship type (should be defined by base installation profile [base.profile])
// if your installation didn't use a profile inheriting from base.profile then you should make sure
// that a ca_list_items_x_list_items relationship type with code='related' is defined. Otherwise import of term-to-term
// relationships will fail.
$t_rel_types = new ca_relationship_types();
示例14: displaySet
public function displaySet()
{
# --- set info
$pn_set_id = $this->request->getParameter('set_id', pInteger);
$t_set = new ca_sets($pn_set_id);
$va_access_values = caGetUserAccessValues($this->request);
# Enforce access control
if (sizeof($va_access_values) && !in_array($t_set->get("access"), $va_access_values)) {
$this->notification->addNotification(_t("This set is not available for view"), "message");
$this->response->setRedirect(caNavUrl($this->request, "", "", "", ""));
return;
}
$this->view->setVar('t_set', $t_set);
$va_items = caExtractValuesByUserLocale($t_set->getItems(array('thumbnailVersions' => array('widepreview', 'medium', 'setimage'), "checkAccess" => $va_access_values)));
$this->view->setVar('items', $va_items);
$va_row_ids = array();
foreach ($va_items as $vn_item_id => $va_item_info) {
$va_row_ids[] = $va_item_info['row_id'];
}
# --- all featured sets - for display in right hand column
// get sets for public display
$t_list = new ca_lists();
$vn_public_set_type_id = $t_list->getItemIDFromList('set_types', $t_list->getAppConfig()->get('simpleGallery_set_type'));
$t_set = new ca_sets($pn_set_id);
$va_sets = caExtractValuesByUserLocale($t_set->getSets(array('table' => 'ca_objects', 'checkAccess' => $va_access_values, 'setType' => $vn_public_set_type_id)));
$va_set_first_items = array();
$va_set_first_items = $t_set->getFirstItemsFromSets(array_keys($va_sets), array("version" => "icon", "checkAccess" => $va_access_values));
$this->view->setVar('sets', $va_sets);
$this->view->setVar('first_items_from_sets', $va_set_first_items);
$this->view->setVar('set_title', $t_set->getLabelForDisplay());
$this->view->setVar('set_description', $t_set->get($this->opo_plugin_config->get('set_description_element_code'), array('convertLinkBreaks' => true)));
// Needed to figure out what result context to use on details
$this->opo_result_context->setParameter('set_id', $pn_set_id);
$this->opo_result_context->setResultList($va_row_ids);
$this->opo_result_context->setAsLastFind();
$this->opo_result_context->saveContext();
$this->render($this->ops_theme . '/set_info_html.php');
}
示例15: getSourceAccessLevel
/**
* Returns the type of access the user has to the specified source.
* Types of access are:
* __CA_BUNDLE_ACCESS_EDIT__ (implies ability to view and change bundle content)
* __CA_BUNDLE_ACCESS_READONLY__ (implies ability to view bundle content only)
* __CA_BUNDLE_ACCESS_NONE__ (indicates that the user has no access to bundle)
*/
public function getSourceAccessLevel($ps_table_name, $pm_source_code_or_id)
{
$vs_cache_key = $ps_table_name . '/' . $pm_source_code_or_id . "/" . $this->getPrimaryKey();
if (isset(ca_users::$s_user_source_access_cache[$vs_cache_key])) {
return ca_users::$s_user_source_access_cache[$vs_cache_key];
}
if (in_array($ps_table_name, ca_users::$s_bundlable_tables)) {
// source-level access control only applies to these tables
$va_roles = array_merge($this->getUserRoles(), $this->getGroupRoles());
if (is_numeric($pm_source_code_or_id)) {
$vn_source_id = (int) $pm_source_code_or_id;
} else {
$t_list = new ca_lists();
$t_instance = $this->getAppDatamodel()->getInstanceByTableName($ps_table_name, true);
$vn_source_id = (int) $t_list->getItemIDFromList($t_instance->getSourceListCode(), $pm_source_code_or_id);
}
$vn_access = -1;
foreach ($va_roles as $vn_role_id => $va_role_info) {
$va_vars = $va_role_info['vars'];
if (is_array($va_vars['source_access_settings'])) {
if (isset($va_vars['source_access_settings'][$ps_table_name . '.' . $vn_source_id]) && (int) $va_vars['source_access_settings'][$ps_table_name . '.' . $vn_source_id] > $vn_access) {
$vn_access = (int) $va_vars['source_access_settings'][$ps_table_name . '.' . $vn_source_id];
if ($vn_access == __CA_BUNDLE_ACCESS_EDIT__) {
break;
}
// already at max
}
} else {
// for roles that don't have 'source_access_settings' set, use default.
// those are most likely roles that came from a profile, didn't have source-level
// access settings set in the profile and haven't been saved through the UI
$vn_access = $this->getAppConfig()->get('default_source_access_level');
if ($vn_access == __CA_BUNDLE_ACCESS_EDIT__) {
break;
}
// already at max
}
}
if ($vn_access < 0) {
$vn_access = (int) $this->getAppConfig()->get('default_source_access_level');
}
ca_users::$s_user_source_access_cache[$ps_table_name . '/' . $vn_source_id . "/" . $this->getPrimaryKey()] = ca_users::$s_user_source_access_cache[$vs_cache_key] = $vn_access;
return $vn_access;
} else {
// no source level access control for tables not explicitly listed in $s_bundlable_tables
ca_users::$s_user_source_access_cache[$ps_table_name . '/' . $vn_source_id . "/" . $this->getPrimaryKey()] = ca_users::$s_user_source_access_cache[$vs_cache_key] = __CA_BUNDLE_ACCESS_EDIT__;
return __CA_BUNDLE_ACCESS_EDIT__;
}
}