本文整理汇总了PHP中ca_metadata_elements::getTypeRestrictions方法的典型用法代码示例。如果您正苦于以下问题:PHP ca_metadata_elements::getTypeRestrictions方法的具体用法?PHP ca_metadata_elements::getTypeRestrictions怎么用?PHP ca_metadata_elements::getTypeRestrictions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ca_metadata_elements
的用法示例。
在下文中一共展示了ca_metadata_elements::getTypeRestrictions方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Get
public function Get($pa_additional_query_params = null, $pa_options = null)
{
$ps_query = $this->request->getParameter('term', pString);
$ps_bundle = $this->request->getParameter('bundle', pString);
$va_tmp = explode('.', $ps_bundle);
$o_dm = Datamodel::load();
if (!($t_table = $o_dm->getInstanceByTableName($va_tmp[0], true))) {
// bad table name
print _t("Invalid table name");
return null;
}
$t_element = new ca_metadata_elements();
if (!$t_element->load(array('element_code' => $va_tmp[1]))) {
print _t("Invalid element code");
return null;
}
if ((int) $t_element->getSetting('suggestExistingValues') !== 1) {
print _t("Value suggestion is not supported for this metadata element");
return null;
}
if ($this->request->user->getBundleAccessLevel($va_tmp[0], $va_tmp[1]) == __CA_BUNDLE_ACCESS_NONE__) {
print _t("You do not have access to this bundle");
return null;
}
$va_type_restrictions = $t_element->getTypeRestrictions($t_table->tableNum());
if (!$va_type_restrictions || !is_array($va_type_restrictions) || !sizeof($va_type_restrictions)) {
print _t("Element code is not bound to the specified table");
return null;
}
$o_db = new Db();
switch ($t_element->getSetting('suggestExistingValueSort')) {
case 'recent':
// date/time entered
$vs_sort_field = 'value_id DESC';
$vn_max_returned_values = 10;
break;
default:
// alphabetically
$vs_sort_field = 'value_longtext1 ASC';
$vn_max_returned_values = 50;
break;
}
$qr_res = $o_db->query("\n\t\t\t\tSELECT DISTINCT value_longtext1\n\t\t\t\tFROM ca_attribute_values\n\t\t\t\tWHERE\n\t\t\t\t\telement_id = ?\n\t\t\t\t\tAND\n\t\t\t\t\t(value_longtext1 LIKE ?)\n\t\t\t\tORDER BY\n\t\t\t\t\t{$vs_sort_field}\n\t\t\t\tLIMIT {$vn_max_returned_values}\n\t\t\t", (int) $t_element->getPrimaryKey(), (string) $ps_query . '%');
$this->view->setVar('attribute_value_list', $qr_res->getAllFieldValues('value_longtext1'));
return $this->render('ajax_attribute_value_list_html.php');
}
示例2: getElementsAsDOM
public function getElementsAsDOM()
{
$t_list = new ca_lists();
$vo_elements = $this->opo_dom->createElement("elementSets");
$qr_elements = $this->opo_db->query("SELECT * FROM ca_metadata_elements WHERE parent_id IS NULL ORDER BY element_id");
$t_element = new ca_metadata_elements();
while ($qr_elements->nextRow()) {
$vo_element = $this->opo_dom->createElement("metadataElement");
$vo_element->setAttribute("code", $this->makeIDNO($qr_elements->get("element_code")));
$vo_element->setAttribute("datatype", ca_metadata_elements::getAttributeNameForTypeCode($qr_elements->get("datatype")));
if ($qr_elements->get("list_id")) {
$t_list->load($qr_elements->get("list_id"));
$vo_element->setAttribute("list", $t_list->get("list_code"));
}
$vo_labels = $this->opo_dom->createElement("labels");
$qr_element_labels = $this->opo_db->query("SELECT * FROM ca_metadata_element_labels WHERE element_id=?", $qr_elements->get("element_id"));
while ($qr_element_labels->nextRow()) {
$vo_label = $this->opo_dom->createElement("label");
$vo_label->setAttribute("locale", $this->opt_locale->localeIDToCode($qr_element_labels->get("locale_id")));
$vo_label->appendChild($this->opo_dom->createElement("name", caEscapeForXML($qr_element_labels->get("name"))));
if (strlen(trim($qr_element_labels->get("description"))) > 0) {
$vo_label->appendChild($this->opo_dom->createElement("description", caEscapeForXML($qr_element_labels->get("description"))));
}
$vo_labels->appendChild($vo_label);
}
$vo_element->appendChild($vo_labels);
$t_element->load($qr_elements->get("element_id"));
$va_settings = $t_element->getSettings();
$va_available_settings = $t_element->getAvailableSettings();
if (is_array($va_settings)) {
$vo_settings = $this->opo_dom->createElement("settings");
$vb_append_settings_element = false;
foreach ($t_element->getSettings() as $vs_setting => $vs_value) {
if ($t_element->isValidSetting($vs_setting) && $vs_value != $va_available_settings[$vs_setting]["default"]) {
$vo_setting = $this->opo_dom->createElement("setting", $vs_value);
$vo_setting->setAttribute("name", $vs_setting);
$vo_settings->appendChild($vo_setting);
$vb_append_settings_element = true;
}
}
if ($vb_append_settings_element) {
$vo_element->appendChild($vo_settings);
}
}
$vo_sub_elements = $this->getElementAsDOM($qr_elements->get("element_id"));
if ($vo_sub_elements) {
$vo_element->appendChild($vo_sub_elements);
}
$vo_restrictions = $this->opo_dom->createElement("typeRestrictions");
foreach ($t_element->getTypeRestrictions() as $va_restriction) {
/** @var ca_metadata_type_restrictions $t_restriction */
$t_restriction = new ca_metadata_type_restrictions($va_restriction["restriction_id"]);
$vs_table_name = $this->opo_dm->getTableName($t_restriction->get("table_num"));
if (!(strlen($vs_table_name) > 0)) {
continue;
}
// there could be lingering restrictions for tables that have since been removed. don't export those.
$vo_restriction = $this->opo_dom->createElement("restriction");
$vo_table = $this->opo_dom->createElement("table", $vs_table_name);
$vo_restriction->appendChild($vo_table);
if ($t_restriction->get("type_id")) {
/** @var BaseRelationshipModel $t_instance */
$t_instance = $this->opo_dm->getInstanceByTableNum($t_restriction->get("table_num"));
$vs_type_code = $t_instance->getTypeListCode();
$va_item = $t_list->getItemFromListByItemID($vs_type_code, $t_restriction->get("type_id"));
$vo_type = $this->opo_dom->createElement("type", $va_item["idno"]);
$vo_restriction->appendChild($vo_type);
}
if (isset($va_restriction['include_subtypes']) && (bool) $va_restriction['include_subtypes']) {
$vo_include_subtypes = $this->opo_dom->createElement('includeSubtypes', '1');
$vo_restriction->appendChild($vo_include_subtypes);
}
if (is_array($va_restriction_settings = $t_restriction->getSettings())) {
$vo_settings = $this->opo_dom->createElement("settings");
foreach ($va_restriction_settings as $vs_setting => $vs_value) {
$vo_setting = $this->opo_dom->createElement("setting", $vs_value);
$vo_setting->setAttribute("name", $vs_setting);
$vo_settings->appendChild($vo_setting);
}
$vo_restriction->appendChild($vo_settings);
}
$vo_restrictions->appendChild($vo_restriction);
}
$vo_element->appendChild($vo_restrictions);
$vo_elements->appendChild($vo_element);
}
return $vo_elements;
}
示例3: getAvailableSettings
public function getAvailableSettings($pa_element_info = null)
{
global $_ca_attribute_settings, $g_request;
$va_element_settings = $_ca_attribute_settings['ListAttributeValue'];
/*
* For the dependent field visibility feature we need to add a select-able list of all applicable
* UI bundle placements here ... for each item in that list!
*/
if (Configuration::load()->get('enable_dependent_field_visibility') && is_array($pa_element_info) && isset($pa_element_info['list_id']) && (!$pa_element_info['settings']['render'] || in_array($pa_element_info['settings']['render'], array('select', 'radio_buttons', 'yes_no_checkboxes'))) && $g_request && $g_request instanceof RequestHTTP) {
$va_options_for_settings = array();
$t_mde = new ca_metadata_elements($pa_element_info['element_id']);
$va_restrictions = $t_mde->getTypeRestrictions();
$va_tables = array();
if (is_array($va_restrictions) && sizeof($va_restrictions)) {
foreach ($va_restrictions as $va_restriction) {
$va_tables[] = $va_restriction['table_num'];
}
}
$t_ui = new ca_editor_uis();
foreach (array_unique($va_tables) as $vn_table_num) {
// get UIs
$va_ui_list = ca_editor_uis::getAvailableUIs($vn_table_num, $g_request);
foreach ($va_ui_list as $vn_ui_id => $vs_ui_name) {
$t_ui->load($vn_ui_id);
// get screens
foreach ($t_ui->getScreens() as $va_screen) {
// get placements
foreach ($t_ui->getScreenBundlePlacements($va_screen['screen_id']) as $va_placement) {
$va_options_for_settings[$t_ui->get('editor_code') . '/' . $va_screen['idno'] . '/' . $va_placement['placement_code']] = $t_ui->get('editor_code') . '/' . $va_screen['idno'] . '/' . $va_placement['placement_code'];
}
}
}
}
$t_list = new ca_lists();
foreach ($t_list->getItemsForList($pa_element_info['list_id']) as $va_items_by_locale) {
foreach ($va_items_by_locale as $vn_locale_id => $va_item) {
$va_element_settings['hideIfSelected_' . $va_item['idno']] = array('formatType' => FT_TEXT, 'displayType' => DT_SELECT, 'options' => $va_options_for_settings, 'takesLocale' => false, 'default' => '', 'width' => "400px", 'height' => 10, 'label' => _t('Hide bundles if "%1" is selected', $va_item['name_singular']), 'description' => _t('Select bundles from the list below'));
}
}
} elseif (defined('__CollectiveAccess_Installer__') && Configuration::load()->get('enable_dependent_field_visibility')) {
// when installing, UIs, screens and placements are not yet available when we process elementSets, so
// we just add the hideIfSelected_* as available settings (without actual settings) so that the validation doesn't fail
$t_list = new ca_lists();
foreach ($t_list->getItemsForList($pa_element_info['list_id']) as $va_items_by_locale) {
foreach ($va_items_by_locale as $vn_locale_id => $va_item) {
$va_element_settings['hideIfSelected_' . $va_item['idno']] = true;
}
}
}
return $va_element_settings;
}