本文整理汇总了PHP中FabrikString::safeColNameToArrayKey方法的典型用法代码示例。如果您正苦于以下问题:PHP FabrikString::safeColNameToArrayKey方法的具体用法?PHP FabrikString::safeColNameToArrayKey怎么用?PHP FabrikString::safeColNameToArrayKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FabrikString
的用法示例。
在下文中一共展示了FabrikString::safeColNameToArrayKey方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validate
/**
* validate the elements data against the rule
* @param string data to check
* @param object element Model
* @param int plugin sequence ref
* @return bol true if validation passes, false if fails
*/
function validate($data, &$elementModel, $c)
{
//could be a dropdown with multivalues
if (is_array($data)) {
$data = implode('', $data);
}
$params = $this->getParams();
$element = $elementModel->getElement();
$listModel = $elementModel->getlistModel();
$table = $listModel->getTable();
$db = $listModel->getDb();
$lookuptable = $db->NameQuote($table->db_table_name);
$data = $db->Quote($data);
$query = $db->getQuery(true);
$cond = $params->get('isuniquevalue-caseinsensitive') == 1 ? 'LIKE' : '=';
$query->select('COUNT(*)')->from($lookuptable)->where($element->name . ' ' . $cond . ' ' . $data);
// $$$ hugh - need to check to see if we're editing a record, otherwise
// will fail 'cos it finds the original record (assuming this element hasn't changed)
// @TODO - is there a better way getting the rowid? What if this is form a joined table?
// $rowid = JRequest::getVar('rowid');
// Have to do it by grabbing PK from request, 'cos rowid isn't set on AJAX validation
$pk = FabrikString::safeColNameToArrayKey($table->db_primary_key);
$rowid = JRequest::getVar($pk, '');
if (!empty($rowid)) {
$query->where($table->db_primary_key . ' != ' . $db->Quote($rowid));
}
$db->setQuery($query);
$c = $db->loadResult();
return $c == 0 ? true : false;
}
示例2: onLoadJavascriptInstance
/**
* return the javascript to create an instance of the class defined in formJavascriptClass
* @param object parameters
* @param list table model
* @param array [0] => string table's form id to contain plugin
* @return bool
*/
function onLoadJavascriptInstance($params, $model, $args)
{
parent::onLoadJavascriptInstance($params, $model, $args);
FabrikHelperHTML::script('media/com_fabrik/js/element.js');
$listModel = JModel::getInstance('list', 'FabrikFEModel');
$listModel->setId(JRequest::getVar('listid'));
$elements = $model->getElements('safecolname');
$pels = $params->get('inline_editable_elements');
$use = json_decode($pels);
if (!is_object($use)) {
$aEls = trim($pels) == '' ? array() : explode(",", $pels);
$use = new stdClass();
foreach ($aEls as $e) {
$use->{$e} = array($e);
}
}
$els = array();
$srcs = array();
$test = (array) $use;
if (!empty($test)) {
foreach ($use as $key => $fields) {
$trigger = $elements[$key];
$els[$key] = new stdClass();
$els[$key]->elid = $trigger->_id;
$els[$key]->plugins = array();
foreach ($fields as $field) {
$val = $elements[$field];
//load in all element js classes
if (is_object($val)) {
$val->formJavascriptClass($srcs);
$els[$key]->plugins[$field] = $val->getElement()->id;
}
}
}
} else {
foreach ($elements as $key => $val) {
$key = FabrikString::safeColNameToArrayKey($key);
$els[$key] = new stdClass();
$els[$key]->elid = $val->_id;
$els[$key]->plugins = array();
$els[$key]->plugins[$key] = $val->getElement()->id;
//load in all element js classes
$val->formJavascriptClass($srcs);
}
}
FabrikHelperHTML::script($srcs);
$opts = $this->getElementJSOptions($model);
$opts->elements = $els;
$opts->formid = $model->getFormModel()->getId();
$opts->focusClass = 'focusClass';
$opts->editEvent = $params->get('inline_edit_event', 'dblclick');
$opts->tabSave = $params->get('inline_tab_save', false);
$opts->showCancel = $params->get('inline_show_cancel', true);
$opts->showSave = (bool) $params->get('inline_show_save', true);
$opts->loadFirst = (bool) $params->get('inline_load_first', false);
$opts = json_encode($opts);
$formid = 'list_' + $model->getFormModel()->getForm()->id;
$this->jsInstance = "new FbListInlineEdit({$opts})";
return true;
}
示例3: loadJavascriptInstance
/**
* return the javascript to create an instance of the class defined in formJavascriptClass
* @param object parameters
* @param object table model
* @param array [0] => string table's form id to contain plugin
* @return bool
*/
function loadJavascriptInstance($params, $model, $args)
{
if (!$this->canUse()) {
return;
}
$form_id = $args[0];
FabrikHelperHTML::script('element.js', 'media/com_fabrik/js/');
$orderEl = $model->getForm()->getElement($params->get('order_element'), true);
$opts = new stdClass();
$opts->enabled = count($model->orderEls) === 1 && FabrikString::safeColNameToArrayKey($model->orderEls[0]) == FabrikString::safeColNameToArrayKey($orderEl->getOrderByName()) ? true : false;
$opts->liveSite = COM_FABRIK_LIVESITE;
$opts->tableid = $model->_id;
$opts->orderElementId = $params->get('order_element');
$opts->handle = $params->get('order_element_as_handle', 1) == 1 ? '.fabrik_row___' . $orderEl->getOrderByName() : false;
$opts->direction = $opts->enabled ? $model->orderDirs[0] : '';
$opts->transition = '';
$opts->duration = '';
$opts->constrain = '';
$opts->clone = '';
$opts->revert = '';
$opts->container = 'table_' . $model->getTable()->id;
$opts = json_encode($opts);
$lang = $this->_getLang();
$lang = json_encode($lang);
$this->jsInstance = "new FbTableOrder('{$form_id}', {$opts}, {$lang})";
return true;
}
示例4: onLoadJavascriptInstance
/**
* Return the javascript to create an instance of the class defined in formJavascriptClass
*
* @param array $args Array [0] => string table's form id to contain plugin
*
* @return bool
*/
public function onLoadJavascriptInstance($args)
{
if (!$this->canUse()) {
return;
}
/** @var FabrikFEModelList $model */
$model = $this->getModel();
$params = $this->getParams();
$orderEl = $model->getFormModel()->getElement($params->get('order_element'), true);
$opts = $this->getElementJSOptions();
$orderElName = FabrikString::safeColNameToArrayKey(FArrayHelper::getValue($model->orderEls, 0, ''));
$opts->enabled = $orderElName == FabrikString::safeColNameToArrayKey($orderEl->getOrderByName()) ? true : false;
$opts->listid = $model->getId();
$opts->orderElementId = $params->get('order_element');
$opts->handle = $params->get('order_element_as_handle', 1) == 1 ? '.' . $orderEl->getOrderByName() : false;
$opts->direction = $opts->enabled ? $model->orderDirs[0] : '';
$opts->transition = '';
$opts->duration = '';
$opts->constrain = '';
$opts->clone = '';
$opts->revert = '';
$opts = json_encode($opts);
$this->jsInstance = "new FbListOrder({$opts})";
return true;
}
示例5: tagify
/**
* Tagify a string
*
* @param string $data Tagify
*
* @return string Tagified string
*/
protected function tagify($data)
{
$name = $this->getFullName(true, false);
$params = $this->getParams();
$listModel = $this->getlistModel();
$filters = $listModel->getFilterArray();
$fkeys = JArrayHelper::getValue($filters, 'key', array());
$data = explode(",", strip_tags($data));
$tags = array();
$url = $params->get('textarea_tagifyurl');
if ($url == '') {
$url = $_SERVER['REQUEST_URI'];
$bits = explode('?', $url);
$root = JArrayHelper::getValue($bits, 0, '', 'string');
$bits = JArrayHelper::getValue($bits, 1, '', 'string');
$bits = explode("&", $bits);
$fullName = $this->getFullName(true, false);
for ($b = count($bits) - 1; $b >= 0; $b--) {
$parts = explode("=", $bits[$b]);
if (count($parts) > 1) {
$key = FabrikString::ltrimword(FabrikString::safeColNameToArrayKey($parts[0]), '&');
if ($key == $fullName) {
unset($bits[$b]);
}
if ($key == $fullName . '[value]') {
unset($bits[$b]);
}
if ($key == $fullName . '[condition]') {
unset($bits[$b]);
}
}
}
}
$url = $root . '?' . implode('&', $bits);
// $$$ rob 24/02/2011 remove duplicates from tags
$data = array_unique($data);
$img = FabrikWorker::j3() ? 'bookmark.png' : 'tag.png';
$icon = FabrikHelperHTML::image($img, 'form', @$this->tmpl, array('alt' => 'tag'));
foreach ($data as $d) {
$d = trim($d);
if ($d != '') {
if (trim($params->get('textarea_tagifyurl')) == '') {
$qs = strstr($url, '?');
if (substr($url, -1) === '?') {
$thisurl = $url . $name . '[value]=' . $d;
} else {
$thisurl = strstr($url, '?') ? $url . '&' . $name . '[value]=' . urlencode($d) : $url . '?' . $name . '[value]=' . urlencode($d);
}
$thisurl .= '&' . $name . '[condition]=CONTAINS';
$thisurl .= '&resetfilters=1';
} else {
$thisurl = str_replace('{tag}', urlencode($d), $url);
}
$tags[] = '<a href="' . $thisurl . '" class="fabrikTag">' . $icon . $d . '</a>';
}
}
return implode(' ', $tags);
}
示例6: tagify
/**
* tagify a string
* @param string to tagify
* @return string tagified string
*/
protected function tagify($data)
{
$name = $this->getFullName(false, true, false);
$params = $this->getParams();
$listModel = $this->getlistModel();
$filters = $listModel->getFilterArray();
$fkeys = JArrayHelper::getValue($filters, 'key', array());
$data = explode(",", strip_tags($data));
$tags = array();
$url = $params->get('textarea_tagifyurl');
if ($url == '') {
$url = $_SERVER['REQUEST_URI'];
$bits = explode('?', $url);
$bits = JArrayHelper::getValue($bits, 1, '', 'string');
$bits = explode("&", $bits);
foreach ($bits as $bit) {
$parts = explode("=", $bit);
if (count($parts) > 1) {
$key = FabrikString::ltrimword(FabrikString::safeColNameToArrayKey($parts[0]), '&');
if ($key == $this->getFullName(false, true, false)) {
$url = str_replace($key . '=' . $parts[1], '', $url);
}
}
}
}
// $$$ rbo 24/02/2011 remove duplicates from tags
$data = array_unique($data);
$icon = FabrikHelperHTML::image('tag.png', 'form', @$this->tmpl, array('alt' => 'tag'));
foreach ($data as $d) {
$d = trim($d);
if ($d != '') {
if (trim($params->get('textarea_tagifyurl')) == '') {
$qs = strstr($url, '?');
if (substr($url, -1) === '?') {
$thisurl = "{$url}{$name}={$d}";
} else {
$thisurl = strstr($url, '?') ? "{$url}&{$name}=" . urlencode($d) : "{$url}?{$name}=" . urlencode($d);
}
} else {
$thisurl = str_replace('{tag}', urlencode($d), $url);
}
$tags[] = '<a href="' . $thisurl . '" class="fabrikTag">' . $icon . $d . '</a>';
}
}
return implode(" ", $tags);
}
示例7: validate
/**
* validate the elements data against the rule
* @param string data to check
* @param object element Model
* @param int plugin sequence ref
* @param int repeat group count
* @return bol true if validation passes, false if fails
*/
function validate($data, &$elementModel, $c, $repeat_count = 0)
{
//could be a dropdown with multivalues
if (is_array($data)) {
$data = implode('', $data);
}
$params =& $this->getParams();
$element =& $elementModel->getElement();
$tableModel =& $elementModel->getTableModel();
$table =& $tableModel->getTable();
$db =& $tableModel->getDb();
$lookuptable = $db->nameQuote($table->db_table_name);
$data = $db->Quote($data);
if ($params->get('isuniquevalue-caseinsensitive') == 1) {
$sql = "SELECT COUNT(*) FROM {$lookuptable} WHERE {$element->name} LIKE {$data}";
} else {
$sql = "SELECT COUNT(*) FROM {$lookuptable} WHERE {$element->name} = {$data}";
}
// $$$ hugh - need to check to see if we're editing a record, otherwise
// will fail 'cos it finds the original record (assuming this element hasn't changed)
// @TODO - is there a better way getting the rowid? What if this is form a joined table?
// $rowid = JRequest::getVar('rowid');
// Have to do it by grabbing PK from request, 'cos rowid isn't set on AJAX validation
$pk = FabrikString::safeColNameToArrayKey($table->db_primary_key);
$rowid = JRequest::getVar($pk, '');
if (!empty($rowid)) {
//if main key is in repeat group!
if (is_array($rowid)) {
foreach ($rowid as &$i) {
$i = $db->Quote($i);
}
$s = implode(',', $rowid);
if ($s !== "''") {
$sql .= " AND {$table->db_primary_key} NOT IN (" . $s . ")";
}
} else {
$sql .= " AND {$table->db_primary_key} != " . $db->Quote($rowid);
}
}
$db->setQuery($sql);
$c = $db->loadResult();
return $c == 0 ? true : false;
}
示例8: onLoadJavascriptInstance
/**
* Return the javascript to create an instance of the class defined in formJavascriptClass
*
* @param object $params plugin parameters
* @param object $model list model
* @param array $args array [0] => string table's form id to contain plugin
*
* @return bool
*/
public function onLoadJavascriptInstance($params, $model, $args)
{
if (!$this->canUse()) {
return;
}
$orderEl = $model->getFormModel()->getElement($params->get('order_element'), true);
$form_id = $model->getFormModel()->getId();
$opts = $this->getElementJSOptions($model);
$opts->enabled = count($model->orderEls) === 1 && FabrikString::safeColNameToArrayKey($model->orderEls[0]) == FabrikString::safeColNameToArrayKey($orderEl->getOrderByName()) ? true : false;
$opts->listid = $model->getId();
$opts->orderElementId = $params->get('order_element');
$opts->handle = $params->get('order_element_as_handle', 1) == 1 ? '.' . $orderEl->getOrderByName() : false;
$opts->direction = $opts->enabled ? $model->orderDirs[0] : '';
$opts->transition = '';
$opts->duration = '';
$opts->constrain = '';
$opts->clone = '';
$opts->revert = '';
$opts = json_encode($opts);
$this->jsInstance = "new FbListOrder({$opts})";
return true;
}
示例9: onLoadJavascriptInstance
/**
* return the javascript to create an instance of the class defined in formJavascriptClass
* @param object parameters
* @param list table model
* @param array [0] => string table's form id to contain plugin
* @return bool
*/
function onLoadJavascriptInstance($params, $model, $args)
{
parent::onLoadJavascriptInstance($params, $model, $args);
FabrikHelperHTML::addStyleDeclaration('.focusClass{border:1px solid red !important;}');
FabrikHelperHTML::script('media/com_fabrik/js/element.js');
$listModel = JModel::getInstance('list', 'FabrikFEModel');
$listModel->setId(JRequest::getVar('listid'));
$elements = $model->getElements('filtername');
$pels = $params->get('inline_editable_elements');
$use = trim($pels) == '' ? array() : explode(",", $pels);
$els = array();
$srcs = array();
foreach ($elements as $key => $val) {
$key = FabrikString::safeColNameToArrayKey($key);
if (empty($use) || in_array($key, $use)) {
$els[$key] = new stdClass();
$els[$key]->elid = $val->_id;
$els[$key]->plugin = $val->getElement()->plugin;
//load in all element js classes
$val->formJavascriptClass($src);
}
}
FabrikHelperHTML::script($srcs, true);
$opts = new stdClass();
$opts->elements = $els;
$opts->listid = $model->getId();
$opts->focusClass = 'focusClass';
$opts->editEvent = $params->get('inline_edit_event', 'dblclick');
$opts->tabSave = $params->get('inline_tab_save', false);
$opts->showCancel = $params->get('inline_show_cancel', true);
$opts->showSave = $params->get('inline_show_save', true);
$opts->loadFirst = (bool)$params->get('inline_load_first', false);
$opts = json_encode($opts);
$formid = 'list_'+$model->getFormModel()->getForm()->id;
$this->jsInstance = "new FbListInlineEdit($opts)";
return true;
}
示例10: loadJavascriptInstance
/**
* return the javascript to create an instance of the class defined in formJavascriptClass
* @param object parameters
* @param object table model
* @param array [0] => string table's form id to contain plugin
* @return bool
*/
function loadJavascriptInstance($params, $model, $args)
{
$form_id = $args[0];
FabrikHelperHTML::script('element.js', 'media/com_fabrik/js/');
$tableModel =& JModel::getInstance('table', 'FabrikModel');
$tableModel->setId(JRequest::getVar('tableid'));
$elements =& $tableModel->getElements('filtername');
$pels = $params->get('inline_editable_elements');
$use = trim($pels) == '' ? array() : explode(",", $pels);
$els = array();
foreach ($elements as $key => $val) {
$key = FabrikString::safeColNameToArrayKey($key);
if (empty($use) || in_array($key, $use)) {
$els[$key] = new stdClass();
$els[$key]->elid = $val->_id;
$els[$key]->plugin = $val->getElement()->plugin;
//load in all element js classes
$val->formJavascriptClass();
}
}
$opts = new stdClass();
$opts->mooversion = FabrikWorker::getMooVersion() == 1 ? 1.2 : 1.1;
$opts->elements = $els;
$opts->tableid = $tableModel->_id;
$opts->focusClass = 'focusClass';
$opts->liveSite = COM_FABRIK_LIVESITE;
$opts->editEvent = $params->get('inline_edit_event', 'dblclick');
$opts->tabSave = $params->get('inline_tab_save', false);
$opts->showCancel = $params->get('inline_show_cancel', true);
$opts->showSave = $params->get('inline_show_save', true);
$opts->loadFirst = (bool) $params->get('inline_load_first', false);
$opts = json_encode($opts);
$lang = $this->_getLang();
$lang = json_encode($lang);
$this->jsInstance = "new FbTableInlineEdit('{$form_id}', {$opts}, {$lang})";
return true;
}
示例11: getFilterQuery
/**
* 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, $value, $originalValue, $type = 'normal')
{
# $$$ rob $this->_rawFilter set in tableModel::getFilterArray()
# used in prefilter dropdown in admin to allow users to prefilter on raw db join value
$params =& $this->getParams();
if ($type == 'querystring') {
$key2 = FabrikString::safeColNameToArrayKey($key);
// $$$ rob no matter whether you use elementname_raw or elementname in the querystring filter
// by the time it gets here we have normalized to elementname. So we check if the original qs filter was looking at the raw
// value if it was then we want to filter on the key and not the label
if (!array_key_exists($key2, JRequest::get('get'))) {
if (!$this->_rawFilter) {
$k = FabrikString::safeColName($params->get('join_db_name') . "." . $params->get('join_key_column'));
} else {
$k = $key;
}
$this->encryptFieldName($k);
return "{$k} {$condition} {$value}";
}
}
if (!$this->_rawFilter && ($type == 'searchall' || $type == 'prefilter')) {
$key = FabrikString::safeColName($params->get('cascadingdropdown_label'));
}
$this->encryptFieldName($key);
$str = "{$key} {$condition} {$value}";
return $str;
}
示例12: getEmailData
//.........这里部分代码省略.........
$elementModels = $groupModel->getPublishedElements();
reset($elementModels);
$tmpElement = current($elementModels);
$smallerElHTMLName = $tmpElement->getFullName(false, true, false);
//$repeatGroup = count($model->_data['join'][$joinTable->id][$smallerElHTMLName]);
$repeatGroup = count($model->_formDataWithTableName['join'][$joinTable->id][$smallerElHTMLName]);
} else {
if (!$groupParams->get('repeat_group_show_first')) {
continue;
}
}
}
} else {
// $$$ rob 19/03/2012 - deprecated?
// repeat groups which arent joins
/* $elementModels = $groupModel->getPublishedElements();
foreach ($elementModels as $tmpElement) {
$smallerElHTMLName = $tmpElement->getFullName(false, true, false);
if (is_array($model->_formDataWithTableName)) {
if (array_key_exists($smallerElHTMLName."_raw", $model->_formDataWithTableName)) {
$d = $model->_formDataWithTableName[$smallerElHTMLName."_raw"];
} else {
$d = @$model->_formDataWithTableName[$smallerElHTMLName];
}
$d = FabrikWorker::JSONtoData($d, true);
$c = count($d);
if ($c > $repeatGroup) { $repeatGroup = $c;}
}
} */
}
}
$groupModel->repeatTotal = $repeatGroup;
$group = $groupModel->getGroup();
$aSubGroups = array();
for ($c = 0; $c < $repeatGroup; $c++) {
$aSubGroupElements = array();
$elementModels = $groupModel->getPublishedElements();
foreach ($elementModels as $elementModel) {
//force reload?
$elementModel->defaults = null;
$elementModel->_repeatGroupTotal = $repeatGroup - 1;
$element = $elementModel->getElement();
$k = $elementModel->getFullName(false, true, false);
$key = $elementModel->getFullName(true, true, false);
//used for working out if the element should behave as if it was
//in a new form (joined grouped) even when editing a record
$elementModel->_inRepeatGroup = $groupModel->canRepeat();
$elementModel->_inJoin = $groupModel->isJoin();
$elementModel->_editable = false;
if ($elementModel->_inJoin) {
if ($elementModel->_inRepeatGroup) {
if (!array_key_exists($k . "_raw", $this->emailData)) {
$this->emailData[$k . '_raw'] = array();
}
$this->emailData[$k . '_raw'][] = JArrayHelper::getValue($model->_formDataWithTableName['join'][$group->join_id][$k], $c);
} else {
$this->emailData[$k . '_raw'] = $model->_formDataWithTableName['join'][$group->join_id][$k];
}
} else {
//@TODO do we need to check if none -joined repeat groups have their data set out correctly?
if (array_key_exists($key, $model->_formDataWithTableName)) {
$rawval = JArrayHelper::getValue($model->_formDataWithTableName, $k . '_raw', '');
if ($rawval == '') {
$this->emailData[$k . '_raw'] = $model->_formDataWithTableName[$key];
} else {
// things like the user element only have their raw value filled in at this point
// so don't overwrite that with the blank none-raw value
// the none-raw value is add in getEmailValue()
$this->emailData[$k . '_raw'] = $rawval;
}
}
}
// $$$ hugh - need to poke data into $elementModel->_form->_data as it is needed
// by CDD getOptions when building the query, to constrain the WHERE clause with
// selected FK value.
// $$$ rob in repeat join groups this isnt really efficient as you end up reformatting the data $c times
$elementModel->_form->_data = $model->_formDataWithTableName;
// $$$ hugh - for some reason, CDD keys themselves are missing form emailData, if no selection was made?
// (may only be on AJAX submit)
$email_value = '';
if (array_key_exists($k . '_raw', $this->emailData)) {
$email_value = $this->emailData[$k . '_raw'];
} else {
if (array_key_exists($k, $this->emailData)) {
$email_value = $this->emailData[$k];
}
}
$this->emailData[$k] = $elementModel->getEmailValue($email_value, $model->_formDataWithTableName, $c);
if ($elementModel->_inRepeatGroup && $elementModel->_inJoin) {
$this->emailData['join'][$groupModel->getGroup()->join_id][$k . '_raw'] = $this->emailData[$k . '_raw'];
$this->emailData['join'][$groupModel->getGroup()->join_id][$k] = $this->emailData[$k];
}
}
}
}
$pk = FabrikString::safeColNameToArrayKey($listModel->getTable()->db_primary_key);
$this->emailData[$pk] = $listModel->lastInsertId;
$this->emailData[$pk . '_raw'] = $listModel->lastInsertId;
return $this->emailData;
}
示例13: getRecords
/**
* get the selected records
* @param string $key
* @param bool $allData
* @return array rows:
*/
public function getRecords($key = 'ids', $allData = false)
{
$ids = (array) JRequest::getVar($key, array());
JArrayHelper::toInteger($ids);
if (empty($ids)) {
JError::raiseError(400, JText::_('PLG_LIST_EMAIL_ERR_NO_RECORDS_SELECTED'));
jexit();
}
$renderOrder = JRequest::getInt('renderOrder');
$params = $this->getParams();
$model = $this->listModel;
$pk = $model->getTable()->db_primary_key;
$pk2 = FabrikString::safeColNameToArrayKey($pk) . '_raw';
$whereClause = "({$pk} IN (" . implode(",", $ids) . "))";
$cond = $params->get('emailtable_condition');
$cond = JArrayHelper::getValue($cond, $renderOrder);
if (trim($cond) !== '') {
$whereClause .= " AND ({$cond})";
}
$model->setPluginQueryWhere($this->buttonPrefix, $whereClause);
$data = $model->getData();
if ($allData) {
return $data;
}
$return = array();
foreach ($data as $gdata) {
foreach ($gdata as $row) {
$return[] = $row->{$pk2};
}
}
return $return;
}
示例14: canUserDo
/**
* Access control function for determining if the user can perform
* a designated function on a specific row
*
* @param object $params Item params to test
* @param object $row Data
* @param string $col Access control setting to compare against
*
* @return mixed - if ACL setting defined here return bool, otherwise return -1 to continue with default acl setting
*/
public static function canUserDo($params, $row, $col)
{
if (!is_null($row)) {
$app = JFactory::getApplication();
$input = $app->input;
$user = JFactory::getUser();
$usercol = $params->get($col, '');
if ($usercol != '') {
$usercol = FabrikString::safeColNameToArrayKey($usercol);
if (!array_key_exists($usercol, $row)) {
return false;
} else {
if (array_key_exists($usercol . '_raw', $row)) {
$usercol .= '_raw';
}
$myid = $user->get('id');
// -1 for menu items that link to their own records
$usercol_val = is_array($row) ? $row[$usercol] : $row->{$usercol};
// User element stores as object
if (is_object($usercol_val)) {
$usercol_val = JArrayHelper::fromObject($usercol_val);
}
// Could be coming back from a failed validation in which case val might be an array
if (is_array($usercol_val)) {
$usercol_val = array_shift($usercol_val);
}
if (empty($usercol_val) && empty($myid)) {
return false;
}
if (intVal($usercol_val) === intVal($myid) || $input->get('rowid') == -1) {
return true;
}
}
}
}
return -1;
}
示例15: getNavIds
/**
* Get the first last, prev and next record ids
*
* @return object
*/
protected function getNavIds()
{
if (isset($this->navIds)) {
return $this->navIds;
}
$formModel = $this->getModel();
$listModel = $formModel->getListModel();
$listModel->filters = null;
$filterModel = $listModel->getFilterModel();
$filterModel->destroyRequest();
$this->app->input->set('view', 'list');
$listref = $listModel->getId() . '_com_' . $this->package . '_' . $listModel->getId();
$this->app->input->set('listref', $listref);
$table = $listModel->getTable();
$db = $listModel->getDb();
$query = $db->getQuery(true);
// As we are selecting on primary key we can select all rows - 3000 records load in 0.014 seconds
$query->select($table->db_primary_key)->from($table->db_table_name);
$query = $listModel->buildQueryJoin($query);
$query = $listModel->buildQueryWhere(true, $query);
$query = $listModel->buildQueryOrder($query);
foreach ($listModel->orderEls as $orderName) {
$orderName = FabrikString::safeColNameToArrayKey($orderName);
$query->select(FabrikString::safeColName($orderName) . ' AS ' . $orderName);
}
$db->setQuery($query);
$rows = $db->loadColumn();
$keys = array_flip($rows);
$o = new stdClass();
$o->index = FArrayHelper::getValue($keys, $formModel->getRowId(), 0);
$o->first = $rows[0];
$o->lastKey = count($rows) - 1;
$o->last = $rows[$o->lastKey];
$o->next = $o->index + 1 > $o->lastKey ? $o->lastKey : $rows[$o->index + 1];
$o->prev = $o->index - 1 < 0 ? 0 : $rows[$o->index - 1];
$this->navIds = $o;
$this->app->input->set('view', 'form');
return $this->navIds;
}