/** * @param array already loaded plugin scripts * load the javascript class that manages interaction with the form element * should only be called once * @since 3.0 */ function formJavascriptClass(&$srcs) { plgFabrik_Element::formJavascriptClass($srcs, 'media/com_fabrik/js/window.js'); parent::formJavascriptClass($srcs); }
/** * this builds an array containing the filters value and condition * @param string initial $value * @param string intial $condition * @param string eval - how the value should be handled * @return array (value condition) */ function getFilterValue($value, $condition, $eval) { $value = $this->prepareFilterVal($value); $return = parent::getFilterValue($value, $condition, $eval); return $return; }
/** * build the filter query for the given element. * @param $key element name in format `tablename`.`elementname` * @param $condition =/like etc * @param $value search string - already quoted if specified in filter array options * @param $originalValue - original filter value without quotes or %'s applied * @param string filter type advanced/normal/prefilter/search/querystring/searchall * @return string sql query part e,g, "key = value" */ function getFilterQuery($key, $condition, $label, $originalValue, $type = 'normal') { $value = $label; if ($type == 'searchall') { // $$$ hugh - (sometimes?) $label is already quoted, which is causing havoc ... $db = JFactory::getDbo(); $values = $this->replaceLabelWithValue(trim($label, "'")); if (empty($values)) { $value = ''; } else { $value = $values[0]; } if ($value == '') { $value = $label; } if (!preg_match('#^\'.*\'$#', $value)) { $value = $db->Quote($value); } } $this->encryptFieldName($key); $params =& $this->getParams(); if ($params->get('multiple')) { $originalValue = trim($value, "'"); return " ({$key} {$condition} {$value} OR {$key} LIKE \"{$originalValue}',%\"" . " OR {$key} LIKE \"%:'{$originalValue}',%\"" . " OR {$key} LIKE \"%:'{$originalValue}'\"" . " )"; } else { return parent::getFilterQuery($key, $condition, $value, $originalValue, $type); } }
/** * When the element is a repeatble join (e.g. db join checkbox) then figure out how many * records have been selected * * @param array $data data * @param object $oJoin join model * * @since 3.0rc1 * * @return int number of records selected */ public function getJoinRepeatCount($data, $oJoin) { $displayType = $this->getParams()->get('database_join_display_type', 'dropdown'); if ($displayType === 'multilist') { $join = $this->getJoinModel()->getJoin(); $repeatName = $join->table_join . '___' . $this->getElement()->name; return count(JArrayHelper::getValue($data, $repeatName, array())); } else { return parent::getJoinRepeatCount($data, $oJoin); } }
/** * 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 $label 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, $label, $originalValue, $type = 'normal') { $value = $label; $db = JFactory::getDbo(); if ($type == 'searchall') { // $$$ hugh - (sometimes?) $label is already quoted, which is causing havoc ... $values = $this->replaceLabelWithValue(trim($label, "'")); if (empty($values)) { $value = ''; } else { $value = $values[0]; } if ($value == '') { $value = $label; } if (!preg_match('#^\'.*\'$#', $value)) { $value = $db->quote($value); } } $this->encryptFieldName($key); $params = $this->getParams(); if ($params->get('multiple')) { $originalValue = trim($value, "'"); /* * JSON stored values will back slash "/". So wwe need to add "\\\\" * before it to escape it for the query. */ $originalValue = str_replace("/", "\\\\/", $originalValue); $where1 = '["' . $originalValue . '",%'; $where2 = '%,"' . $originalValue . '",%'; $where3 = '%,"' . $originalValue . '"]'; $str = "({$key} {$condition} {$value} " . " OR {$key} LIKE " . $db->quote('["' . $originalValue . '"%') . " OR {$key} LIKE " . $db->quote('%"' . $originalValue . '"%') . " OR {$key} LIKE " . $db->quote('%"' . $originalValue . '"]') . ")"; return $str; } else { return parent::getFilterQuery($key, $condition, $value, $originalValue, $type); } }
/** * build the filter query for the given element. * @param $key element name in format `tablename`.`elementname` * @param $condition =/like etc * @param $value search string - already quoted if specified in filter array options * @param $originalValue - original filter value without quotes or %'s applied * @param string filter type advanced/normal/prefilter/search/querystring/searchall * @return string sql query part e,g, "key = value" */ function getFilterQuery($key, $condition, $label, $originalValue, $type = 'normal') { $value = $label; if ($type == 'searchall') { // $$$ hugh - (sometimes?) $label is already quoted, which is causing havoc ... $db = JFactory::getDbo(); $values = $this->replaceLabelWithValue(trim($label, "'")); if (empty($values)) { $value = ''; } else { $value = $values[0]; } if ($value == '') { $value = $label; } if (!preg_match('#^\'.*\'$#', $value)) { $value = $db->Quote($value); } } $this->encryptFieldName($key); $params = $this->getParams(); if ($params->get('multiple')) { $originalValue = trim($value, "'"); $where1 = '["' . $originalValue . '",%'; $where2 = '%,"' . $originalValue . '",%'; $where3 = '%,"' . $originalValue . '"]'; return ' (' . $key . ' ' . $condition . ' ' . $value . ' OR ' . $key . ' LIKE \'' . $where1 . '\' OR ' . $key . ' LIKE \'' . $where2 . '\' OR ' . $key . ' LIKE \'' . $where3 . '\' )'; } else { return parent::getFilterQuery($key, $condition, $value, $originalValue, $type); } }
/** * Determines the value for the element in the form view * * @param array $data form data * @param int $repeatCounter when repeating joinded 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; }