public function getParametersForDisplay($pa_rec) { $va_parameters = caUnserializeForDatabase($pa_rec["parameters"]); $va_params = array(); $t_set = new ca_sets($va_parameters['set_id']); $va_params['importing_from'] = array('label' => _t("Applying batch edits to set"), 'value' => $t_set->getLabelForDisplay()); $va_params['number_of_records'] = array('label' => _t("Records to edit"), 'value' => (int) $t_set->getItemCount(array('user_id' => $va_parameters['user_id']))); $t_ui = new ca_editor_uis($va_parameters['ui_id']); $t_screen = new ca_editor_ui_screens(); if ($t_screen->load(array('ui_id' => $t_ui->getPrimaryKey(), 'screen_id' => str_ireplace("screen", "", $va_parameters['screen'])))) { $va_params['ui'] = array('label' => _t("Using interface"), 'value' => $t_ui->getLabelForDisplay() . " ➜ " . $t_screen->getLabelForDisplay()); } return $va_params; }
/** * Initializes editor view with core set of values, loads model with record to be edited and selects user interface to use. * * @param $pa_options Array of options. Supported options are: * ui = The ui_id or editor_code value for the user interface to use. If omitted the default user interface is used. */ protected function _initView($pa_options = null) { // load required javascript JavascriptLoadManager::register('bundleableEditor'); JavascriptLoadManager::register('imageScroller'); JavascriptLoadManager::register('ckeditor'); if (!($t_subject = $this->opo_datamodel->getInstanceByTableName($this->ops_table_name))) { return null; } if (is_array($pa_options) && isset($pa_options['loadSubject']) && (bool) $pa_options['loadSubject'] && ($vn_subject_id = (int) $this->request->getParameter($t_subject->primaryKey(), pInteger))) { $t_subject->load($vn_subject_id); } if (is_array($pa_options) && isset($pa_options['forceSubjectValues']) && is_array($pa_options['forceSubjectValues'])) { foreach ($pa_options['forceSubjectValues'] as $vs_f => $vs_v) { $t_subject->set($vs_f, $vs_v); } } // then reload the definitions (which includes bundle specs) $t_subject->reloadLabelDefinitions(); $t_ui = new ca_editor_uis(); if (isset($pa_options['ui']) && $pa_options['ui']) { if (is_numeric($pa_options['ui'])) { $t_ui->load((int) $pa_options['ui']); } if (!$t_ui->getPrimaryKey()) { $t_ui->load(array('editor_code' => $pa_options['ui'])); } } if (!$t_ui->getPrimaryKey()) { $t_ui = ca_editor_uis::loadDefaultUI($this->ops_table_name, $this->request, $t_subject->getTypeID(), array('editorPref' => 'quickadd')); } $this->view->setVar($t_subject->primaryKey(), $t_subject->getPrimaryKey()); $this->view->setVar('subject_id', $t_subject->getPrimaryKey()); $this->view->setVar('t_subject', $t_subject); if ($vs_parent_id_fld = $t_subject->getProperty('HIERARCHY_PARENT_ID_FLD')) { $this->view->setVar('parent_id', $vn_parent_id = $this->request->getParameter($vs_parent_id_fld, pInteger)); return array($t_subject, $t_ui, $vn_parent_id, $vn_above_id); } return array($t_subject, $t_ui); }
/** * Initializes editor view with core set of values, loads model with record to be edited and selects user interface to use. * * @param $pa_options Array of options. Supported options are: * ui = The ui_id or editor_code value for the user interface to use. If omitted the default user interface is used. */ protected function _initView($pa_options = null) { // load required javascript AssetLoadManager::register('bundleableEditor'); AssetLoadManager::register('imageScroller'); AssetLoadManager::register('ckeditor'); $t_subject = $this->opo_datamodel->getInstanceByTableName($this->ops_table_name); if (is_array($pa_options) && isset($pa_options['loadSubject']) && (bool) $pa_options['loadSubject'] && ($vn_subject_id = (int) $this->request->getParameter($t_subject->primaryKey(), pInteger))) { $t_subject->load($vn_subject_id); } if (is_array($pa_options) && isset($pa_options['forceSubjectValues']) && is_array($pa_options['forceSubjectValues'])) { foreach ($pa_options['forceSubjectValues'] as $vs_f => $vs_v) { $t_subject->set($vs_f, $vs_v); } } // empty (ie. new) rows don't have a type_id set, which means we'll have no idea which attributes to display // so we get the type_id off of the request if (!($vn_type_id = $this->request->getParameter($t_subject->getTypeFieldName(), pString))) { $vn_type_id = null; } // then set the empty row's type_id $t_subject->set($t_subject->getTypeFieldName(), $vn_type_id); // then reload the definitions (which includes bundle specs) $t_subject->reloadLabelDefinitions(); $t_ui = new ca_editor_uis(); if (isset($pa_options['ui']) && $pa_options['ui']) { if (is_numeric($pa_options['ui'])) { $t_ui->load((int) $pa_options['ui']); } if (!$t_ui->getPrimaryKey()) { $t_ui->load(array('editor_code' => $pa_options['ui'])); } } if (!$t_ui->getPrimaryKey()) { $t_ui = ca_editor_uis::loadDefaultUI($this->ops_table_name, $this->request, $t_subject->getTypeID()); } $this->view->setVar($t_subject->primaryKey(), $t_subject->getPrimaryKey()); $this->view->setVar('subject_id', $t_subject->getPrimaryKey()); $this->view->setVar('t_subject', $t_subject); if ($vs_parent_id_fld = $t_subject->getProperty('HIERARCHY_PARENT_ID_FLD')) { $this->view->setVar('parent_id', $vn_parent_id = $this->request->getParameter($vs_parent_id_fld, pInteger)); return array($t_subject, $t_ui, $vn_parent_id, $vn_above_id); } return array($t_subject, $t_ui); }
/** * Generates display summary of record data based upon a bundle display for screen * * @param array $pa_options Array of options passed through to _initView */ protected function _initView($pa_options = null) { // load required javascript JavascriptLoadManager::register('bundleableEditor'); JavascriptLoadManager::register('imageScroller'); $t_subject = $this->opo_datamodel->getInstanceByTableName($this->ops_table_name); $t_subject->purify(true); // filter HTML for bad things like <script> tags and malformed markup // empty (ie. new) rows don't have a type_id set, which means we'll have no idea which attributes to display // so we get the type_id off of the request if (!($vn_type_id = $this->request->getParameter($t_subject->getTypeFieldName(), pInteger))) { $vn_type_id = null; } // then set the empty row's type_id $t_subject->set($t_subject->getTypeFieldName(), $vn_type_id); // then reload the definitions (which includes bundle specs) $t_subject->reloadLabelDefinitions(); $t_ui = new ca_editor_uis(); if (isset($pa_options['ui']) && $pa_options['ui']) { if (is_numeric($pa_options['ui'])) { $t_ui->load((int) $pa_options['ui']); } if (!$t_ui->getPrimaryKey()) { $t_ui->load(array('editor_code' => $pa_options['ui'])); } } if (!$t_ui->getPrimaryKey()) { $t_ui->loadDefaultUI($this->ops_table_name, $this->request); } $this->view->setVar('t_subject', $t_subject); return array(null, $t_subject, $t_ui); }
/** * Sets restrictions for currently loaded screen * * @param array $pa_type_ids list of types to restrict to * @return bool True on success, false on error, null if no screen is loaded * */ public function setTypeRestrictions($pa_type_ids) { if (!($vn_screen_id = $this->getPrimaryKey())) { return null; } // screen must be loaded if (!is_array($pa_type_ids)) { if (is_numeric($pa_type_ids)) { $pa_type_ids = array($pa_type_ids); } else { $pa_type_ids = array(); } } $t_ui = new ca_editor_uis($this->get('ui_id')); if (!$t_ui->getPrimaryKey()) { return false; } if (!($t_instance = $this->_DATAMODEL->getInstanceByTableNum($this->getTableNum()))) { return false; } if ($t_instance instanceof BaseRelationshipModel) { // interstitial type restrictions $va_type_list = $t_instance->getRelationshipTypes(); } else { // "normal" (list-based) type restrictions $va_type_list = $t_instance->getTypeList(); } $va_current_restrictions = $this->getTypeRestrictions(); $va_current_type_ids = array(); foreach ($va_current_restrictions as $vn_i => $va_restriction) { $va_current_type_ids[$va_restriction['type_id']] = true; } foreach ($va_type_list as $vn_type_id => $va_type_info) { if (in_array($vn_type_id, $pa_type_ids)) { // need to set if (!isset($va_current_type_ids[$vn_type_id])) { $this->addTypeRestriction($vn_type_id); } } else { // need to unset if (isset($va_current_type_ids[$vn_type_id])) { $this->removeTypeRestriction($vn_type_id); } } } return true; }
/** * Checks for presence of configuration for ca_editor_uis and ca_editor_ui_screens editors, and if not * present, loads a default configuration. Since these editors are used to configure themselves, lack of * configuration (the case with all pre-version 1.1 installations), will effectively make it impossible to * change the setup for any editor in the installation. * * @return bool Returns true on success (either UI already exists or was created successfully), false on error (UI does not exist and could not be created) * */ public function checkConfiguration() { global $g_ui_locale_id; $t_ui = new ca_editor_uis(); if (!$t_ui->load(array('editor_type' => 101))) { $t_ui->setMode(ACCESS_WRITE); $t_ui->set('user_id', null); $t_ui->set('is_system_ui', 1); $t_ui->set('editor_type', 101); $t_ui->set('editor_code', 'ui_editor'); $t_ui->set('color', '000000'); $t_ui->insert(); if ($t_ui->numErrors()) { return false; } $t_ui->addLabel(array('name' => 'UI Editor'), $g_ui_locale_id, null, true); if ($t_ui->numErrors()) { return false; } $vn_ui_id = $t_ui->getPrimaryKey(); $t_screen = new ca_editor_ui_screens(); $t_screen->setMode(ACCESS_WRITE); $t_screen->set('ui_id', $vn_ui_id); $t_screen->set('idno', 'basic_' . $vn_ui_id); $t_screen->set('rank', 1); $t_screen->set('default', 1); $t_screen->insert(); if ($t_screen->numErrors()) { return false; } $t_screen->addLabel(array('name' => 'Basic'), $g_ui_locale_id, null, true); if ($t_screen->numErrors()) { return false; } $vn_i = 1; foreach (array('preferred_labels', 'editor_code', 'color', 'editor_type', 'ca_editor_ui_type_restrictions', 'ca_editor_ui_screens', 'is_system_ui', 'ca_users', 'ca_user_groups', 'ca_user_roles') as $vs_bundle_name) { $t_screen->addPlacement($vs_bundle_name, $vs_bundle_name, array(), $vn_i); $vn_i++; } } if (!$t_ui->load(array('editor_type' => 100))) { $t_ui->setMode(ACCESS_WRITE); $t_ui->set('user_id', null); $t_ui->set('is_system_ui', 1); $t_ui->set('editor_type', 100); $t_ui->set('color', 'CC0000'); $t_ui->set('editor_code', 'ui_screen_editor'); $t_ui->insert(); if ($t_ui->numErrors()) { return false; } $t_ui->addLabel(array('name' => 'UI Screen Editor'), $g_ui_locale_id, null, true); if ($t_ui->numErrors()) { return false; } $vn_ui_id = $t_ui->getPrimaryKey(); $t_screen = new ca_editor_ui_screens(); $t_screen->setMode(ACCESS_WRITE); $t_screen->set('ui_id', $vn_ui_id); $t_screen->set('idno', 'basic_' . $vn_ui_id); $t_screen->set('rank', 1); $t_screen->set('default', 1); $t_screen->insert(); if ($t_screen->numErrors()) { return false; } $t_screen->addLabel(array('name' => 'Basic'), $g_ui_locale_id, null, true); if ($t_screen->numErrors()) { return false; } $vn_i = 1; foreach (array('preferred_labels', 'idno', 'color', 'is_default', 'ca_editor_ui_screen_type_restrictions', 'ca_editor_ui_bundle_placements', 'ca_users', 'ca_user_groups', 'ca_user_roles') as $vs_bundle_name) { $t_screen->addPlacement($vs_bundle_name, $vs_bundle_name, array(), $vn_i); $vn_i++; } } return true; }
/** * Initializes editor view with core set of values, loads model with record to be edited and selects user interface to use. * * @param $pa_options Array of options. Supported options are: * ui = The ui_id or editor_code value for the user interface to use. If omitted the default user interface is used. */ protected function _initView($pa_options = null) { // load required javascript AssetLoadManager::register('bundleableEditor'); AssetLoadManager::register('imageScroller'); AssetLoadManager::register('datePickerUI'); $vn_set_id = $this->request->getParameter('set_id', pInteger); $t_set = new ca_sets(); if (!$vn_set_id || !$t_set->load($vn_set_id)) { // Bad set id return array(null, null, null, null); } // Does user have access to set? if (!$t_set->haveAccessToSet($this->request->getUserID(), __CA_SET_READ_ACCESS__)) { return array(null, null, null, null); } $t_subject = $this->opo_datamodel->getInstanceByTableNum($t_set->get('table_num')); $t_ui = new ca_editor_uis(); if (!isset($pa_options['ui']) && !$pa_options['ui']) { $t_ui->load($this->request->user->getPreference("batch_" . $t_subject->tableName() . "_editor_ui")); } if (!$t_ui->getPrimaryKey() && isset($pa_options['ui']['__all__']) && $pa_options['ui']['__all__']) { if (is_numeric($pa_options['ui']['__all__'])) { $t_ui->load((int) $pa_options['ui']['__all__']); } if (!$t_ui->getPrimaryKey()) { $t_ui->load(array('editor_code' => $pa_options['ui']['__all__'])); } } if (!$t_ui->getPrimaryKey()) { $t_ui = ca_editor_uis::loadDefaultUI($t_subject->tableName(), $this->request, $t_subject->getTypeID()); } $this->view->setVar('set_id', $vn_set_id); $this->view->setVar('t_set', $t_set); $this->view->setVar('t_subject', $t_subject); $vn_item_count = $t_set->getItemCount(array('user_id' => $this->request->getUserID())); $vs_item_name = $vn_item_count == 1 ? $t_subject->getProperty("NAME_SINGULAR") : $t_subject->getProperty("NAME_PLURAL"); MetaTagManager::setWindowTitle(_t("Batch editing %1 %2 with set %3", $vn_item_count, $vs_item_name, $t_set->getLabelForDisplay(true))); return array($vn_set_id, $t_set, $t_subject, $t_ui); }
/** * */ protected function _getUI($pn_type_id = null, $pa_options = null) { $t_ui = new ca_editor_uis(); if (isset($pa_options['ui']) && $pa_options['ui']) { if (is_numeric($pa_options['ui'])) { $t_ui->load((int) $pa_options['ui']); } if (!$t_ui->getPrimaryKey()) { $t_ui->load(array('editor_code' => $pa_options['ui'])); } } if (!$t_ui->getPrimaryKey()) { $t_ui = ca_editor_uis::loadDefaultUI($this->ops_table_name, $this->request, $pn_type_id); } return $t_ui; }
/** * Initializes editor view with core set of values, loads model with record to be edited and selects user interface to use. * * @param $pa_options Array of options. Supported options are: * ui = The ui_id or editor_code value for the user interface to use. If omitted the default user interface is used. */ protected function _initView($pa_options = null) { // load required javascript JavascriptLoadManager::register('bundleableEditor'); JavascriptLoadManager::register('imageScroller'); JavascriptLoadManager::register('datePickerUI'); $t_subject = $this->opo_datamodel->getInstanceByTableName($this->ops_table_name); $vn_subject_id = $this->request->getParameter($t_subject->primaryKey(), pInteger); if (!$vn_subject_id || !$t_subject->load($vn_subject_id)) { // empty (ie. new) rows don't have a type_id set, which means we'll have no idea which attributes to display // so we get the type_id off of the request if (!($vn_type_id = $this->request->getParameter($t_subject->getTypeFieldName(), pInteger))) { $vn_type_id = null; } // then set the empty row's type_id $t_subject->set($t_subject->getTypeFieldName(), $vn_type_id); // then reload the definitions (which includes bundle specs) $t_subject->reloadLabelDefinitions(); } $t_ui = new ca_editor_uis(); if (isset($pa_options['ui']) && $pa_options['ui']) { if (is_numeric($pa_options['ui'])) { $t_ui->load((int) $pa_options['ui']); } if (!$t_ui->getPrimaryKey()) { $t_ui->load(array('editor_code' => $pa_options['ui'])); } } if (!$t_ui->getPrimaryKey()) { $t_ui = ca_editor_uis::loadDefaultUI($this->ops_table_name, $this->request, $t_subject->getTypeID()); } $this->view->setVar($t_subject->primaryKey(), $vn_subject_id); $this->view->setVar('subject_id', $vn_subject_id); $this->view->setVar('t_subject', $t_subject); MetaTagManager::setWindowTitle(_t("Editing %1 : %2", ($vs_type = $t_subject->getTypeName()) ? $vs_type : $t_subject->getProperty('NAME_SINGULAR'), $vn_subject_id ? $t_subject->getLabelForDisplay(true) : _t('new %1', $t_subject->getTypeName()))); if ($vs_parent_id_fld = $t_subject->getProperty('HIERARCHY_PARENT_ID_FLD')) { $this->view->setVar('parent_id', $vn_parent_id = $this->request->getParameter($vs_parent_id_fld, pInteger)); // The "above_id" is set when the new record we're creating is to be inserted *above* an existing record (eg. made // the parent of another record). It will be set to the record we're inserting above. We ignore it if set when editing // an existing record since it is only relevant for newly created records. if (!$vn_subject_id) { $this->view->setVar('above_id', $vn_above_id = $this->request->getParameter('above_id', pInteger)); $t_subject->set($vs_parent_id_fld, $vn_parent_id); $t_parent = $this->opo_datamodel->getInstanceByTableName($this->ops_table_name); if ($t_parent->load($vn_parent_id)) { $t_subject->set('idno', $t_parent->get('idno')); } } return array($vn_subject_id, $t_subject, $t_ui, $vn_parent_id, $vn_above_id); } return array($vn_subject_id, $t_subject, $t_ui); }
/** * Returns a list of ui id, screen id and placement id for a given setting key (editor_code/screen_idno/placement_code) * @param string $ps_key * @return array|bool */ public static function resolveHideIfSelectedKey($ps_key) { if (CompositeCache::contains($ps_key, 'ListAttrHideIfSelected')) { return CompositeCache::fetch($ps_key, 'ListAttrHideIfSelected'); } $va_tmp = explode('/', $ps_key); if (!sizeof($va_tmp) == 3) { return false; } // ui $t_ui = new ca_editor_uis(); if (!$t_ui->load(array('editor_code' => $va_tmp[0]))) { return false; } // screen $t_screen = new ca_editor_ui_screens(); if (!$t_screen->load(array('ui_id' => $t_ui->getPrimaryKey(), 'idno' => $va_tmp[1]))) { return false; } // placement $t_placement = new ca_editor_ui_bundle_placements(); if (!$t_placement->load(array('screen_id' => $t_screen->getPrimaryKey(), 'placement_code' => $va_tmp[2]))) { return false; } $va_ret = array($t_screen->getPrimaryKey(), $t_placement->getPrimaryKey()); CompositeCache::save($ps_key, $va_ret, 'ListAttrHideIfSelected'); return $va_ret; }
/** * Initializes editor view with core set of values, loads model with record to be edited and selects user interface to use. * * @param $pa_options Array of options. Supported options are: * ui = The ui_id or editor_code value for the user interface to use. If omitted the default user interface is used. */ protected function _initView($pa_options = null) { // load required javascript AssetLoadManager::register('bundleableEditor'); AssetLoadManager::register('imageScroller'); AssetLoadManager::register('datePickerUI'); $t_ui = new ca_editor_uis(); if (!isset($pa_options['ui']) && !$pa_options['ui']) { $pa_options['ui'] = $this->request->user->getPreference("batch_ca_object_media_import_ui"); } if (isset($pa_options['ui']) && $pa_options['ui']) { if (is_numeric($pa_options['ui'])) { $t_ui->load((int) $pa_options['ui']); } if (!$t_ui->getPrimaryKey()) { $t_ui->load(array('editor_code' => $pa_options['ui'])); } } if (!$t_ui->getPrimaryKey()) { $t_ui = ca_editor_uis::loadDefaultUI('ca_objects', $this->request, null); } MetaTagManager::setWindowTitle(_t("Batch import media")); return array($t_ui); }