示例#1
0
 /**
  * Method to set the element id
  *
  * @param   int  $id  element ID number
  *
  * @return  void
  */
 public function setId($id)
 {
     parent::setId($id);
     $params = $this->getParams();
     // Set elementlist params from dropdown params
     $params->set('allow_frontend_addto', (bool) $params->get('allow_frontend_addtodropdown', false));
     $params->set('allowadd-onlylabel', (bool) $params->get('dd-allowadd-onlylabel', true));
     $params->set('savenewadditions', (bool) $params->get('dd-savenewadditions', false));
     $params->set('options_populate', $params->get('dropdown_populate', ''));
 }
示例#2
0
 /**
  * Set the element id
  * and maps parameter names for common ElementList options
  *
  * @param   int $id element id
  *
  * @return  void
  */
 public function setId($id)
 {
     parent::setId($id);
     $params = $this->getParams();
     // Set elementlist params from checkbox params
     $params->set('options_per_row', $params->get('ck_options_per_row'));
     $params->set('allow_frontend_addto', (bool) $params->get('allow_frontend_addtocheckbox', false));
     $params->set('allowadd-onlylabel', (bool) $params->get('chk-allowadd-onlylabel', true));
     $params->set('savenewadditions', (bool) $params->get('chk-savenewadditions', false));
 }
示例#3
0
 /**
  * Get the class to manage the form element
  * to ensure that the file is loaded only once
  *
  * @param   array   &$srcs   Scripts previously loaded
  * @param   string  $script  Script to load once class has loaded
  * @param   array   &$shim   Dependant class names to load before loading the class - put in requirejs.config shim
  *
  * @return void
  */
 public function formJavascriptClass(&$srcs, $script = '', &$shim = array())
 {
     $s = new stdClass();
     $s->deps = array('fab/element', 'fab/elementlist');
     $shim['element/checkbox/checkbox'] = $s;
     parent::formJavascriptClass($srcs, $script, $shim);
 }
示例#4
0
 /**
  * Determines the value for the element in the form view
  *
  * @param   array  $data           Form data
  * @param   int    $repeatCounter  When repeating joined groups we need to know what part of the array to access
  * @param   array  $opts           Options
  *
  * @return  string	value
  */
 public function getValue($data, $repeatCounter = 0, $opts = array())
 {
     $v = parent::getValue($data, $repeatCounter, $opts);
     // $$$ rob see http://fabrikar.com/forums/showthread.php?t=25965
     if (is_array($v) && count($v) == 1) {
         $v = $v[0];
     }
     return $v;
 }
示例#5
0
 /**
  * Builds an array containing the filters value and condition
  *
  * @param   string $value     Initial value
  * @param   string $condition Intial $condition
  * @param   string $eval      How the value should be handled
  *
  * @return  array    (value condition)
  */
 public function getFilterValue($value, $condition, $eval)
 {
     $value = $this->prepareFilterVal($value);
     $return = parent::getFilterValue($value, $condition, $eval);
     return $return;
 }
示例#6
0
文件: date.php 项目: glauberm/cinevi
 /**
  * Get the Front end JS default date
  *
  * @param   array $data Form data
  *
  * @return string
  */
 public function getFrontDefaultValue($data = array())
 {
     $params = $this->getParams();
     $db = JFactory::getDbo();
     $alwaysToday = $params->get('date_alwaystoday', false);
     $defaultToday = $params->get('date_defaulttotoday', false);
     if ($alwaysToday || $defaultToday) {
         $this->default = JHtml::_('date', 'now', $db->getDateFormat());
     } else {
         $this->default = parent::getDefaultValue($data);
     }
     return $this->default;
 }
示例#7
0
 /**
  * Determines the value for the element in the form view
  *
  * @param   array  $data           Form data
  * @param   int    $repeatCounter  When repeating joined groups we need to know what part of the array to access
  * @param   array  $opts           Options
  *
  * @return  string	value
  */
 public function getValue($data, $repeatCounter = 0, $opts = array())
 {
     $value = parent::getValue($data, $repeatCounter, $opts);
     $value = FabrikWorker::JSONtoData($value);
     if (is_string($value)) {
         // New record or failed validation
         $value = trim($value);
         $value = $value === '' ? array() : explode(',', $value);
     }
     return $value;
 }
示例#8
0
 /**
  * Get the class to manage the form element
  * to ensure that the file is loaded only once
  *
  * @param   array   &$srcs   Scripts previously loaded
  * @param   string  $script  Script to load once class has loaded
  * @param   array   &$shim   Dependant class names to load before loading the class - put in requirejs.config shim
  *
  * @return void
  */
 public function formJavascriptClass(&$srcs, $script = '', &$shim = array())
 {
     $key = 'element/date/date';
     // Ensure that we keep advanced dependencies from previous date elements regardless of current elements settings.
     $deps = array_key_exists($key, $shim) ? $shim[$key]->deps : array('fab/element');
     $params = $this->getParams();
     if ($params->get('date_advanced', '0') == '1' && !in_array('fab/lib/datejs/date', $deps)) {
         $deps[] = 'fab/lib/datejs/date';
         $deps[] = 'fab/lib/datejs/core';
         $deps[] = 'fab/lib/datejs/parser';
         $deps[] = 'fab/lib/datejs/extras';
     }
     $s = new stdClass();
     $s->deps = $deps;
     $shim[$key] = $s;
     parent::formJavascriptClass($srcs, $script, $shim);
     // Return false, as we need to be called on per-element (not per-plugin) basis
     return false;
 }
示例#9
0
 /**
  * Is it possible to include the element in the  Search all query?
  * true if basic search
  * true/false if advanced search
  *
  * @param   bool  $advancedMode  Is the list using advanced search
  *
  * @since   3.1b
  *
  * @return boolean
  */
 public function canIncludeInSearchAll($advancedMode)
 {
     if ($advancedMode) {
         $join = $this->getJoinModel();
         $fields = $join->getJoin()->getFields();
         $field = JArrayHelper::fromObject(JArrayHelper::getValue($fields, $this->getLabelParamVal(), array()));
         $type = JArrayHelper::getValue($field, 'Type', '');
         $notAllowed = array('int', 'double', 'decimal', 'date', 'serial', 'bit', 'boolean', 'real');
         foreach ($notAllowed as $test) {
             if (stristr($type, $test)) {
                 return false;
             }
         }
     }
     return parent::canIncludeInSearchAll($advancedMode);
 }
示例#10
0
 /**
  * Build the filter query for the given element.
  * Can be overwritten in plugin - e.g. see checkbox element which checks for partial matches
  *
  * @param   string  $key            Element name in format `tablename`.`elementname`
  * @param   string  $condition      =/like etc.
  * @param   string  $value          Search string - already quoted if specified in filter array options
  * @param   string  $originalValue  Original filter value without quotes or %'s applied
  * @param   string  $type           Filter type advanced/normal/prefilter/search/querystring/searchall
  *
  * @return  string	sql query part e,g, "key = value"
  */
 public function getFilterQuery($key, $condition, $value, $originalValue, $type = 'normal')
 {
     $params = $this->getParams();
     $condition = JString::strtoupper($condition);
     $this->encryptFieldName($key);
     if ((bool) $params->get('multiple', false)) {
         // Multiple select options need to be treated specially (regardless of filter type?)
         // see http://fabrikar.com/forums/index.php?threads/how-filter-a-dropdown-element-in-the-plug-fabrik-content.42089/
         $str = $this->filterQueryMultiValues($key, $condition, $originalValue);
     } else {
         $str = parent::getFilterQuery($key, $condition, $value, $originalValue, $type);
     }
     return $str;
 }
示例#11
0
 /**
  * Called by form model to build an array of values to encrypt
  *
  * @param   array  &$values  Previously encrypted values
  * @param   array  $data     Form data
  * @param   int    $c        Repeat group counter
  *
  * @return  void
  */
 public function getValuesToEncrypt(&$values, $data, $c)
 {
     $displayType = $this->getDisplayType();
     if ($displayType == 'checkbox' || $displayType == 'multilist') {
         $name = $this->getFullName(true, false);
         $group = $this->getGroup();
         if ($group->canRepeat()) {
             if (!array_key_exists($name, $values)) {
                 $values[$name]['data'] = array();
             }
             $values[$name]['data'][$c] = $this->multiOptionTargetIds($data, $c);
         } else {
             $values[$name]['data'] = $this->multiOptionTargetIds($data, $c);
         }
     } else {
         parent::getValuesToEncrypt($values, $data, $c);
     }
 }