Ejemplo n.º 1
0
 /**
  * Returns content for a bundle or the inspector. Used to dynamically and selectively
  * reload an editing form.
  */
 public function reload()
 {
     list($vn_subject_id, $t_subject) = $this->_initView();
     if (!$this->_checkAccess($t_subject)) {
         return false;
     }
     $ps_bundle = $this->request->getParameter("bundle", pString);
     $pn_placement_id = $this->request->getParameter("placement_id", pInteger);
     switch ($ps_bundle) {
         case '__inspector__':
             $this->response->addContent($this->info(array($t_subject->primaryKey() => $vn_subject_id, 'type_id' => $this->request->getParameter("type_id", pInteger))));
             break;
         default:
             $t_placement = new ca_editor_ui_bundle_placements($pn_placement_id);
             if (!$t_placement->getPrimaryKey()) {
                 $this->response->setRedirect($this->request->config->get('error_display_url') . '/n/2580?r=' . urlencode($this->request->getFullUrlPath()));
                 return;
             }
             if ($t_placement->get('bundle_name') != $ps_bundle) {
                 $this->response->setRedirect($this->request->config->get('error_display_url') . '/n/2580?r=' . urlencode($this->request->getFullUrlPath()));
                 return;
             }
             $this->response->addContent($t_subject->getBundleFormHTML($ps_bundle, $pn_placement_id, $t_placement->get('settings'), array('request' => $this->request, 'contentOnly' => true), $vs_label));
             break;
     }
 }
Ejemplo n.º 2
0
 /**
  * Removes bundle placement from display
  *
  * @param int $pn_placement_id Placement_id of placement to remove
  * @param array $pa_options Optional array of options. Supports the following options:
  * 		user_id = if specified then remove will fail if specified user does not have edit access for the display
  * @return bool Returns true on success, false on error
  */
 public function removePlacement($pn_placement_id, $pa_options = null)
 {
     if (!($vn_screen_id = $this->getPrimaryKey())) {
         return null;
     }
     $pn_user_id = isset($pa_options['user_id']) ? $pa_options['user_id'] : null;
     //if ($pn_user_id && !$this->haveAccessToDisplay($pn_user_id, __CA_BUNDLE_DISPLAY_EDIT_ACCESS__)) {
     //	return null;
     //}
     $t_placement = new ca_editor_ui_bundle_placements($pn_placement_id);
     if ($t_placement->getPrimaryKey() && $t_placement->get('screen_id') == $vn_screen_id) {
         $t_placement->setMode(ACCESS_WRITE);
         $t_placement->delete(true);
         if ($t_placement->numErrors()) {
             $this->errors = array_merge($this->errors, $t_placement->errors);
             return false;
         }
         unset(ca_editor_ui_screens::$s_placement_list_cache[$vn_screen_id]);
         return true;
     }
     return false;
 }
Ejemplo n.º 3
0
 /**
  * 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;
 }