Exemple #1
0
 protected static function checkOptions(&$options)
 {
     TIP::arrayDefault($options, 'extension', '.rcbt');
     return parent::checkOptions($options);
 }
Exemple #2
0
 /**
  * Perform a delete action
  *
  * Generates and executes a TIP_Form instance to delete a row.
  *
  * If no $options are specified, the default behaviour is to render both
  * valid and invalid form in the page.
  *
  * Notice also that $options['on_process'], if not specified, will be set
  * to the _onDelete() default callback.
  *
  * @param  mixed $id      The identifier of the row to delete
  * @param  array $options Options to pass to the form() call
  * @return bool           true on success or false on errors
  */
 protected function actionDelete($id, $options = array())
 {
     if (@is_array($this->form_options['delete'])) {
         $options = array_merge($this->form_options['delete'], $options);
     }
     TIP::arrayDefault($options, 'on_process', array(&$this, '_onDelete'));
     return !is_null($this->form(TIP_FORM_ACTION_DELETE, $id, $options));
 }
Exemple #3
0
 protected static function checkOptions(&$options)
 {
     if (@is_string($options['data'])) {
         $options['data'] = array('path' => $options['data']);
     }
     // The data path is a required option
     if (!@is_array($options['data']) || !isset($options['data']['path'])) {
         return false;
     }
     TIP::arrayDefault($options, 'id_type', 'string');
     TIP::arrayDefault($options['data'], 'data_engine', array('id' => 'picasa2', 'type' => array('data_engine', 'xml'), 'fields_xpath' => array('id' => 'link[contains(@rel,"#canonical")]/@href', 'title' => 'media:group/media:title[@type="plain"]', 'description' => 'media:group/media:description[@type="plain"]', 'imageurl' => 'media:group/media:content[@medium="image"]/@url', 'thumbnail' => 'media:group/media:thumbnail[3]/@url', 'thumbnail_width' => 'media:group/media:thumbnail[3]/@width', 'thumbnail_height' => 'media:group/media:thumbnail[3]/@height', 'date' => 'published', 'author' => '../author/name', 'uploader' => 'media:group/media:credit')));
     return parent::checkOptions($options);
 }
Exemple #4
0
 protected static function checkOptions(&$options)
 {
     if (@is_string($options['data'])) {
         $options['data'] = array('path' => $options['data']);
     }
     // The data path is a required option
     if (!@is_array($options['data']) || !isset($options['data']['path'])) {
         return false;
     }
     TIP::arrayDefault($options, 'id_type', 'string');
     TIP::arrayDefault($options['data'], 'primary_key', 'link');
     TIP::arrayDefault($options['data'], 'data_engine', array('id' => 'devhelp2', 'type' => array('data_engine', 'xml'), 'parent_field' => 'parent', 'base_xpath' => '/book/chapters', 'row_xpath' => 'sub', 'fields_xpath' => array('link' => '@link', 'title' => '@name')));
     return parent::checkOptions($options);
 }
Exemple #5
0
 protected static function checkOptions(&$options)
 {
     if (!parent::checkOptions($options) || !isset($options['master'], $options['action'])) {
         return false;
     }
     // Force the current form id to the binded module id
     // (the "master" module)
     $options['id'] = $options['master']->getProperty('id');
     // Default values
     TIP::arrayDefault($options, 'locale_prefix', 'form');
     TIP::arrayDefault($options, 'action_id', $options['action']);
     isset($options['referer']) || ($options['referer'] = TIP::getRefererUri());
     isset($options['follower']) || ($options['follower'] = $options['referer']);
     isset($options['json']) || ($options['json'] = TIP_Application::getGlobal('json'));
     if (!isset($options['buttons'])) {
         switch ($options['action']) {
             case TIP_FORM_ACTION_ADD:
             case TIP_FORM_ACTION_EDIT:
                 $options['buttons'] = TIP_FORM_BUTTON_SUBMIT | TIP_FORM_BUTTON_CANCEL;
                 break;
             case TIP_FORM_ACTION_VIEW:
                 $options['buttons'] = TIP_FORM_BUTTON_CLOSE;
                 break;
             case TIP_FORM_ACTION_DELETE:
                 $options['buttons'] = TIP_FORM_BUTTON_DELETE | TIP_FORM_BUTTON_CANCEL;
                 break;
             default:
                 $options['buttons'] = TIP_FORM_BUTTON_CLOSE;
         }
     }
     return true;
 }
Exemple #6
0
 /**
  * Perform an add action
  *
  * Overrides the default add action, assuring the 'browse_field' has a
  * valid value.
  *
  * @param  mixed $id      The identifier of the row to duplicate
  * @param  array $options Options to pass to the form() call
  * @return bool           true on success or false on errors
  */
 protected function actionAdd($id, $options = array())
 {
     // Merge the argument before the parent actionAdd(), so also
     // the defaults here defined can be overriden in configuration
     if (isset($this->form_options['add'])) {
         $options = array_merge($this->form_options['add'], $options);
     }
     // Check for the default value of 'browse_field' (the parent id)
     if (!isset($options['defaults'], $options['defaults'][$this->browse_field])) {
         // Try to get the parent id from GET or POST
         if (is_null($parent_id = $this->fromGetOrPost($this->browse_field))) {
             return false;
         }
         $options['defaults'][$this->browse_field] = $parent_id;
     } else {
         $parent_id = $options['defaults'][$this->browse_field];
     }
     TIP::arrayDefault($options, 'follower', TIP::buildActionUri($this->master, 'view', $parent_id));
     return parent::actionAdd($id, $options);
 }
Exemple #7
0
 protected static function checkOptions(&$options)
 {
     if (@is_string($options['data'])) {
         $options['data'] = array('path' => $options['data']);
     }
     // The data path is a required option
     if (!@is_array($options['data']) || !isset($options['data']['path'])) {
         return false;
     }
     // If the 'data' option does not start with "http://", it is
     // supposed to be a BOSS developer API and treated as such
     if (strncmp($options['data']['path'], 'http://', 7) != 0) {
         $options['data']['path'] = 'http://boss.yahooapis.com/ysearch/web/v1/{terms}' . '?format=xml&abstract=long&appid=' . $options['data']['path'];
     }
     // The TIP_XML engine used to access TIP_Boss1 modules
     // is non-reentrant and shared among multiple instances
     // (this is obtained by using the same id, 'boss1').
     TIP::arrayDefault($options['data'], 'data_engine', array('id' => 'boss1', 'type' => array('data_engine', 'xml'), 'base_xpath' => 'resultset_web', 'row_xpath' => 'result', 'fields_xpath' => array('title' => 'title', 'summary' => 'abstract', 'displayurl' => 'dispurl', 'url' => 'url', 'clickurl' => 'clickurl')));
     // Allows queries for everyone
     TIP::arrayDefault($options, 'browsable_fields', array(TIP_PRIVILEGE_NONE => array('__ALL__')));
     return parent::checkOptions($options);
 }
Exemple #8
0
 /**
  * Perform an update action
  *
  * Generates and executes a TIP_Form instance to update a new row,
  * that is duplicating a row and adding history management so the
  * new row will be a considered as a new version of the duplicated one.
  *
  * @param  mixed $id      The identifier of the row to update
  * @param  array $options Options to pass to the form() call
  * @return bool           true on success or false on errors
  */
 protected function actionUpdate($id, $options = array())
 {
     // Enable the history
     $this->_row_id = $id;
     TIP::arrayDefault($options, 'action_id', 'update');
     $done = $this->master->actionAdd($id, $options);
     // Disable the history
     unset($this->_row_id);
     return $done;
 }
Exemple #9
0
 /**
  * Perform a delete action
  *
  * Overrides the default delete action by showing a merged form
  * between master and child data.
  *
  * @param  mixed $id      The identifier of the row to delete
  * @param  array $options Options to pass to the form() call
  * @return bool           true on success or false on errors
  */
 protected function actionDelete($id, $options = array())
 {
     // Merge the argument options with the configuration options, if found
     // The argument options have higher priority...
     if (@is_array($this->form_options['delete'])) {
         $options = array_merge($this->form_options['delete'], $options);
     }
     TIP::arrayDefault($options, 'on_process', array(&$this, '_onDelete'));
     // Populate "defaults" with master and child values
     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;
     }
     $options['type'] = array('module', 'form');
     $options['master'] =& $this;
     $options['action'] = TIP_FORM_ACTION_DELETE;
     $form =& TIP_Type::singleton($options);
     $valid = $form->validate();
     // On delete, the child form is chained-up also if $valid==false:
     // this module was already retrieved by fromRow()
     $child =& $this->_getChildModule();
     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);
 }
Exemple #10
0
 /**
  * Perform a login action
  *
  * Presents a login form and process the submitted fields according.
  *
  * @param  array $options Options to pass to the form() call
  * @return bool           true on success or false on errors
  */
 protected function actionLogin($options = array())
 {
     // Merge the argument options with the configuration options, if found
     // The argument options have higher priority...
     if (@is_array($this->form_options['login'])) {
         $options = array_merge($this->form_options['login'], $options);
     }
     if (!array_key_exists('fields', $options)) {
         $fields =& $this->data->getFields();
         $options['fields'] = array('user' => &$fields['user'], 'password' => &$fields['password']);
     }
     TIP::arrayDefault($options, 'action_id', 'login');
     TIP::arrayDefault($options, 'validator', array(&$this, '_checkLogin'));
     TIP::arrayDefault($options, 'on_process', array(&$this, '_onLogin'));
     TIP::arrayDefault($options, 'valid_render', TIP_FORM_RENDER_NOTHING);
     return !is_null($this->form(TIP_FORM_ACTION_ADD, null, $options));
 }
Exemple #11
0
 protected static function checkOptions(&$options)
 {
     if (@is_string($options['data'])) {
         $options['data'] = array('path' => $options['data']);
     }
     // The data path is a required option
     if (!@is_array($options['data']) || !isset($options['data']['path'])) {
         return false;
     }
     TIP::arrayDefault($options, 'id_type', 'string');
     TIP::arrayDefault($options['data'], 'data_engine', array('id' => 'youtube2', 'type' => array('data_engine', 'xml'), 'fields_xpath' => array('id' => 'media:group/yt:videoid', 'title' => 'media:group/media:title[@type="plain"]', 'description' => 'media:group/media:description[@type="plain"]', 'swfurl' => 'media:group/media:content[@yt:format="5"]/@url', 'thumbnail120x90' => 'media:group/media:thumbnail[@width="120" and @height="90"]/@url', 'thumbnail480x360' => 'media:group/media:thumbnail[@width="480" and @height="360"]/@url', 'date' => 'media:group/yt:uploaded', 'uploader' => 'media:group/media:credit[@role="uploader"]', 'author' => 'author/name', 'duration' => 'media:group/yt:duration/@seconds', 'hits' => 'yt:statistics/@viewCount', 'favorites' => 'yt:statistics/@favoriteCount', 'rating' => 'gd:rating/@average', 'raters' => 'gd:rating/@numRaters')));
     return parent::checkOptions($options);
 }
Exemple #12
0
 /**
  * 'add' callback
  *
  * Overrides the default callback setting the initial expiration value.
  *
  * @param  array &$row The data row to add
  * @return bool        true on success, false on errors
  */
 public function _onAdd(&$row)
 {
     if (isset($this->expiration_field)) {
         TIP::arrayDefault($row, $this->expiration_field, TIP::formatDate('datetime_sql', strtotime($this->expiration)));
     }
     return parent::_onAdd($row);
 }