Пример #1
0
 /**
  * Perform a browse action
  *
  * Overrides the "browse" action to substitute {terms} in the query URI.
  *
  * @param  array &$conditions The browse conditions
  * @return bool               true on success or false on errors
  */
 protected function actionBrowse(&$conditions)
 {
     // Prepare the terms: append " site:thisdomain" to limit the query
     // to the current site
     $terms = TIP::getGetOrPost('terms', 'string');
     $terms .= ' site:' . $_SERVER['SERVER_NAME'];
     $query =& $this->data->getProperty('path');
     $query = str_replace('{terms}', urlencode($terms), $query);
     return parent::actionBrowse($conditions);
 }
Пример #2
0
 protected function postConstructor()
 {
     parent::postConstructor();
     // This must be called here (not in checkOptions()) to avoid
     // buildActionUri() call before application instantiation
     isset($this->fatal_uri) || ($this->fatal_uri = TIP::buildActionUri($this->id, 'fatal'));
     $this->keys['TITLE'] =& $this->title;
     $this->keys['DESCRIPTION'] =& $this->description;
     $this->keys['KEYWORDS'] =& $this->keywords;
     $this->keys['ROOT'] = TIP::getRoot();
     $this->keys['HOME'] = TIP::getHome();
     $this->keys['REFERER'] = '';
     // Set $_request
     $module = TIP::getGet('module', 'string');
     $action = TIP::getGet('action', 'string');
     if (!$action) {
         $module = TIP::getPost('module', 'string');
         $action = TIP::getPost('action', 'string');
     }
     $this->_request = array('uri' => @$_SERVER['REQUEST_URI'], 'module' => @strtolower($module), 'action' => @strtolower($action), 'id' => TIP::getGetOrPost('id', 'string'));
     $this->keys['REQUEST'] = $this->_request['uri'];
     $this->keys['MODULE'] = $this->_request['module'];
     $this->keys['ACTION'] = $this->_request['action'];
     // The ID global key will be assigned when the requested module
     // is loaded, so a type casting can be forced (because the id_type
     // of the module is known)
     $this->keys['ID'] = '';
     // Start the session
     TIP_AHAH || $this->_startSession();
 }
Пример #3
0
 /**
  * Perform an add action
  *
  * Overrides the default add action, chaining the child module
  * form if the class form validates.
  *
  * @param  mixed $id      The identifier of the row to duplicate (not used)
  * @param  array $options Options to pass to the form() call
  * @return bool           true on success or false on errors
  */
 protected function actionAdd($id = null, $options = array())
 {
     $primary_key = $this->data->getProperty('primary_key');
     // Merge the argument options with the configuration options, if found
     // The argument options have higher priority...
     if (@is_array($this->form_options['add'])) {
         $options = array_merge($this->form_options['add'], $options);
     }
     // Populate "defaults" if $id is specified (= duplicate row)
     if (isset($id)) {
         if (is_null($row = $this->fromRow($id))) {
             return false;
         }
         if (@is_array($options['defaults'])) {
             $options['defaults'] = array_merge($row, $options['defaults']);
         } else {
             $options['defaults'] =& $row;
         }
         // Unset the primary_key: this is an add action
         unset($options['defaults'][$primary_key]);
     }
     $options['type'] = array('module', 'form');
     $options['master'] =& $this;
     TIP::arrayDefault($options, 'action', TIP_FORM_ACTION_ADD);
     TIP::arrayDefault($options, 'on_process', array(&$this, '_onAdd'));
     TIP::arrayDefault($options, 'follower', TIP::buildActionUri($this->id, 'view', '') . '{' . $primary_key . '}');
     if (!is_null($class = TIP::getGetOrPost($this->class_field, 'string'))) {
         // Class selected: by default, freeze the form element
         TIP::arrayDefault($options, 'readonly', array($this->class_field));
     }
     $form =& TIP_Type::singleton($options);
     $valid = $form->validate();
     if (isset($id)) {
         // If $id is set, the child module is chained-up also on
         // $valid==false: this module was already retrieved by fromRow()
         $child =& $this->_getChildModule();
     } elseif (!is_null($class)) {
         // "class_field" defined: get the specific child module
         $child =& $this->_getChildModule($class);
     } else {
         $child = null;
     }
     if ($child === false) {
         // Errors on child module
         return false;
     } elseif ($child) {
         // Child module found and valid: chain-up the child form
         $valid = $form->validateAlso($child);
     }
     if ($valid) {
         $form->process();
     }
     return $form->render($valid);
 }