本文整理汇总了PHP中FabrikString::safeColName方法的典型用法代码示例。如果您正苦于以下问题:PHP FabrikString::safeColName方法的具体用法?PHP FabrikString::safeColName怎么用?PHP FabrikString::safeColName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FabrikString
的用法示例。
在下文中一共展示了FabrikString::safeColName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getPivot
/**
* create the pivot data
* @return array of objects - first being the headings, subsequent the data
*/
public function getPivot()
{
$model = $this->formModel->getTableModel();
$params =& $model->getParams();
$val = FabrikString::safeColName($params->get('pivot_value', ''));
$xCol = FabrikString::safeColName($params->get('pivot_xcol', ''));
$yCol = FabrikString::safeColName($params->get('pivot_ycol', ''));
$db =& $model->getDb();
$table =& $model->getTable();
$join = $model->_buildQueryJoin();
$where = $model->_buildQueryWhere();
$db->setQuery("SELECT DISTINCT {$yCol} FROM {$table->db_table_name}");
$yCols = $db->loadResultArray();
$query = "select name,\n";
$data = array();
foreach ($yCols as $c) {
$data[] = "SUM({$val}*(1-abs(sign(" . $yCol . "-" . $c . ")))) as exam" . $c . "\n";
}
$query .= implode(",", $data);
$query .= "\nFROM " . $table->db_table_name . " {$join} {$where} group by {$xCol}";
$db->setQuery($query);
$data = $db->loadObjectList();
$headings = JArrayHelper::toObject(array_keys(JArrayHelper::fromObject($data[0])));
array_unshift($data, $headings);
return $data;
}
示例2: ajax_loadTableDropDown
/**
* Ajax load drop down of all columns in a given table
*
* @return null
*/
public function ajax_loadTableDropDown()
{
$app = JFactory::getApplication();
$input = $app->input;
$conn = $input->getInt('conn', 1);
$oCnn = JModelLegacy::getInstance('Connection', 'FabrikFEModel');
$oCnn->setId($conn);
$oCnn->getConnection();
$db = $oCnn->getDb();
$table = $input->get('table', '');
$fieldNames = array();
$name = $input->get('name', 'jform[params][table_key][]', '', 'string');
if ($table != '') {
$table = FabrikString::safeColName($table);
$sql = 'DESCRIBE ' . $table;
$db->setQuery($sql);
$aFields = $db->loadObjectList();
if (is_array($aFields)) {
foreach ($aFields as $oField) {
$fieldNames[] = JHTML::_('select.option', $oField->Field);
}
}
}
$fieldDropDown = JHTML::_('select.genericlist', $fieldNames, $name, "class=\"inputbox\" size=\"1\" ", 'value', 'text', '');
echo $fieldDropDown;
}
示例3: render
/**
* Internally render the plugin, and add required script declarations
* to the document
*
* @return void
*/
public function render()
{
$params = $this->getParams();
$document = JFactory::getDocument();
$document->addScript("http://api.simile-widgets.org/runway/1.0/runway-api.js");
$c = 0;
$images = (array) $params->get('coverflow_image');
$titles = (array) $params->get('coverflow_title');
$subtitles = (array) $params->get('coverflow_subtitle');
$listIds = (array) $params->get('coverflow_table');
$eventData = array();
foreach ($listIds as $listId) {
$listModel = JModelLegacy::getInstance('List', 'FabrikFEModel');
$listModel->setId($listId);
$list = $listModel->getTable();
$listModel->getPagination(0, 0, 0);
$image = $images[$c];
$title = $titles[$c];
$subtitle = $subtitles[$c];
$data = $listModel->getData();
if ($listModel->canView() || $listModel->canEdit()) {
$elements = $listModel->getElements();
$imageElement = FArrayHelper::getValue($elements, FabrikString::safeColName($image));
foreach ($data as $group) {
if (is_array($group)) {
foreach ($group as $row) {
$event = new stdClass();
if (!method_exists($imageElement, 'getStorage')) {
switch (get_class($imageElement)) {
case 'FabrikModelFabrikImage':
$rootFolder = $imageElement->getParams()->get('selectImage_root_folder');
$rootFolder = JString::ltrim($rootFolder, '/');
$rootFolder = JString::rtrim($rootFolder, '/');
$event->image = COM_FABRIK_LIVESITE . 'images/stories/' . $rootFolder . '/' . $row->{$image . '_raw'};
break;
default:
$event->image = isset($row->{$image . '_raw'}) ? $row->{$image . '_raw'} : '';
break;
}
} else {
$event->image = $imageElement->getStorage()->pathToURL($row->{$image . '_raw'});
}
$event->title = $title === '' ? '' : (string) strip_tags($row->{$title});
$event->subtitle = $subtitle === '' ? '' : (string) strip_tags($row->{$subtitle});
$eventData[] = $event;
}
}
}
}
$c++;
}
$json = json_encode($eventData);
$str = "var coverflow = new FbVisCoverflow({$json});";
$srcs = FabrikHelperHTML::framework();
$srcs['Coverflow'] = $this->srcBase . 'coverflow/coverflow.js';
FabrikHelperHTML::script($srcs, $str);
}
示例4: getOptions
function getOptions()
{
$db = FabrikWorker::getDbo(true);
$query = $db->getQuery(true);
$query->select("id AS value, label AS " . FabrikString::safeColName('text'));
$query->from("#__{package}_forms");
$query->order("value DESC");
$db->setQuery($query);
$rows = $db->loadObjectList();
return $rows;
}
示例5: filterValueList_Exact
/**
* (non-PHPdoc)
* @see components/com_fabrik/models/FabrikModelElement::_buildFilterJoin()
*/
protected function filterValueList_Exact($normal, $tableName = '', $label = '', $id = '', $incjoin = true)
{
$tableModel = $this->getTableModel();
$fabrikDb =& $tableModel->getDb();
$table =& $tableModel->getTable();
$elName2 = $this->getFullName(false, false, false);
$ids = $tableModel->getColumnData($elName2);
$elName = FabrikString::safeColName($this->getFullName(false, true, false));
$sql = 'SELECT name AS ' . $fabrikDb->nameQuote('text') . ', id AS ' . $fabrikDb->nameQuote('value') . ' from #__core_acl_aro_groups ' . "WHERE id IN ('" . implode("','", $ids) . "')";
$fabrikDb->setQuery($sql);
$rows = $fabrikDb->loadObjectList();
$this->nameMap($rows);
return $rows;
}
示例6: getOptions
/**
* Get list options
*
* @return array
*/
protected function getOptions()
{
$db = FabrikWorker::getDbo();
$query = $db->getQuery(true);
$query->select("id AS value, CONCAT(label, '(', version , ')') AS " . FabrikString::safeColName(text));
$query->from('#__{package}_packages');
$query->order('value DESC');
$db->setQuery($query);
$rows = $db->loadObjectList();
$o = new stdClass();
$o->value = 0;
$o->text = JText::_('COM_FABRIK_NO_PACKAGE');
array_unshift($rows, $o);
return $rows;
}
示例7: getGroupList
/**
* get a list of unused groups
* @return array list of groups, html list of groups
*/
public function getGroupList()
{
$db = FabrikWorker::getDbo(true);
$query = $db->getQuery(true);
$query->select('DISTINCT(group_id)')->from('#__{package}_formgroup');
$db->setQuery($query);
$usedgroups = $db->loadResultArray();
$query = $db->getQuery(true);
$query->select('id AS value, name AS text')->from('#__{package}_groups');
if (!empty($usedgroups)) {
$query->where('id NOT IN(' . implode(",", $usedgroups) . ')');
}
$query->where('published <> -2');
$query->order(FabrikString::safeColName('text'));
$db->setQuery($query);
$groups = $db->loadObjectList();
$list = JHTML::_('select.genericlist', $groups, 'jform[groups]', "class=\"inputbox\" size=\"10\" style=\"width:100%;\" ", 'value', 'text', null, $this->id . '-from');
return array($groups, $list);
}
示例8: decide
protected function decide($v)
{
$params =& $this->getParams();
$ids = (array) $params->get('approvals_table');
$approveEls = (array) $params->get('approvals_approve_element');
foreach ($ids as $key => $listid) {
if ($listid == JRequest::getInt('listid')) {
$listModel = JModel::getInstance('List', 'FabrikFEModel');
$listModel->setId(JRequest::getInt('listid'));
$item = $listModel->getTable();
$db = $listModel->getDbo();
$query = $db->getQuery(true);
$el = FabrikString::safeColName($approveEls[$key]);
try {
$query->update($db->nameQuote($item->db_table_name))->set($el . ' = ' . $db->quote($v))->where($item->db_primary_key . ' = ' . $db->quote(JRequest::getVar('rowid')));
$db->setQuery($query);
$db->query();
} catch (JException $e) {
JError::raiseError(500, $e->getMessage());
}
}
}
}
示例9: getFilter
/**
* Get the table filter for the element
* @param bol do we render as a normal filter or as an advanced searc filter
* if normal include the hidden fields as well (default true, use false for advanced filter rendering)
* @return string filter html
*/
function getFilter($counter = 0, $normal = true)
{
$table =& $this->getTableModel()->getTable();
$elName = $this->getFullName(false, true, false);
$htmlid = $this->getHTMLId() . 'value';
$elName = FabrikString::safeColName($elName);
$v = 'fabrik___filter[table_' . $table->id . '][value]';
$v .= $normal ? '[' . $counter . ']' : '[]';
$default = $this->getDefaultFilterVal($normal, $counter);
$rows = $this->filterValueList($normal);
$return = JHTML::_('select.genericlist', $rows, $v, 'class="inputbox fabrik_filter" size="1" ', 'value', 'text', $default, $htmlid);
if ($normal) {
$return .= $this->getFilterHiddenFields($counter, $elName);
} else {
$return .= $this->getAdvancedFilterHiddenFields();
}
return $return;
}
示例10: getQuery
/**
* Build the sql query to filter the data
*
* @param object $params plugin params
*
* @return string query's where statement
*/
protected function getQuery($params)
{
$input = $this->app->input;
$lookUps = $input->get('radius_lookup' . $this->renderOrder, array(), 'array');
$lookUps = array_filter($lookUps, function ($v) {
return (string) $v === '1';
});
$ids = array_keys($lookUps);
$ids = ArrayHelper::toInteger($ids);
$listModel = new FabrikFEModelList();
$listModel->setId($params->get('radius_lookup_list'));
$listModel->setLimits(0, -1);
$key = $listModel->getPrimaryKey();
$listModel->setPluginQueryWhere('list.radius_lookup', $key . ' IN (' . implode(',', $ids) . ')');
$data = $listModel->getData();
$distanceField = $params->get('distance_field') . '_raw';
$data = $listModel->getData();
list($latitude, $longitude) = $this->getSearchLatLon();
if (trim($latitude) === '' && trim($longitude) === '') {
$input->set('radius_search_active' . $this->renderOrder, array(0));
return;
}
// Need to unset for multiple radius searches to work
unset($this->mapElement);
$el = $this->getMapElement();
$el = FabrikString::safeColName($el->getFullName(false, false));
// Crazy sql to get the lat/lon from google map element
$latField = "SUBSTRING_INDEX(TRIM(LEADING '(' FROM {$el}), ',', 1)";
$lonField = "SUBSTRING_INDEX(SUBSTRING_INDEX({$el}, ',', -1), ')', 1)";
$query = array();
$unit = $params->get('radius_lookup_unit', 'km');
foreach ($data as $group) {
foreach ($group as $row) {
$v = $row->{$distanceField};
if ($unit == 'km') {
$query[] = "((((acos(sin((" . $latitude . "*pi()/180)) * sin(({$latField} *pi()/180))+cos((" . $latitude . "*pi()/180)) * cos(({$latField} *pi()/180)) * cos(((" . $longitude . "- {$lonField})*pi()/180))))*180/pi())*60*1.1515*1.609344) <= " . $v . ')';
} else {
$query[] = "((((acos(sin((" . $latitude . "*pi()/180)) * sin(({$latField} *pi()/180))+cos((" . $latitude . "*pi()/180)) * cos(({$latField} *pi()/180)) * cos(((" . $longitude . "- {$lonField})*pi()/180))))*180/pi())*60*1.1515) <= " . $v . ')';
}
}
}
$query = '(' . implode(' OR ', $query) . ')';
return $query;
}
示例11: deleteEvent
/**
* delete an event
*/
function deleteEvent()
{
$id = (int)JRequest::getVar('id');
$listid = JRequest::getInt('listid');
$listModel = JModel::getInstance('list', 'FabrikFEModel');
$listModel->setId($listid);
$list = $listModel->getTable();
$tableDb = $listModel->getDb();
$db = FabrikWorker::getDbo();
$db->setQuery("SELECT db_table_name FROM #__{package}_lists WHERE id = $listid");
$tablename = $db->loadResult();
$tableDb->setQuery("DELETE FROM ".FabrikString::safeColName($tablename)." WHERE $list->db_primary_key = $id");
$tableDb->query();
}
示例12: getToField
function getToField()
{
$this->_type = 'table';
$this->_id = JRequest::getInt('id');
$params =& $this->getParams();
$renderOrder = JRequest::getInt('renderOrder');
$toType = $params->get('emailtable_to_type');
$toType = is_array($toType) ? JArrayHelper::getValue($toType, $renderOrder, 'list') : $toType;
if ($toType == 'field') {
$to = $params->get('emailtable_to');
$to = is_array($to) ? JArrayHelper::getValue($to, $renderOrder) : $to;
return "<input name=\"email_to\" id=\"email_to\" value=\"" . $to . "\" readonly=\"true\" />";
} else {
if ($toType == 'list') {
return $this->formModel->getElementList('email_to');
} else {
if ($toType == 'table' || $toType == 'table_picklist') {
$emailtable_to_table_table = $params->get('emailtable_to_table_table');
if (is_array($emailtable_to_table_table)) {
$emailtable_to_table_table = $emailtable_to_table_table[$renderOrder];
}
$emailtable_to_table_email = $params->get('emailtable_to_table_email');
if (is_array($emailtable_to_table_email)) {
$emailtable_to_table_email = $emailtable_to_table_email[$renderOrder];
}
$emailtable_to_table_name = $params->get('emailtable_to_table_name');
if (is_array($emailtable_to_table_name)) {
$emailtable_to_table_name = $emailtable_to_table_name[$renderOrder];
}
if (empty($emailtable_to_table_name)) {
$emailtable_to_table_name = $emailtable_to_table_email;
}
$toTableModel =& JModel::getInstance('table', 'FabrikModel');
$toTableModel->setId($emailtable_to_table_table);
//$toFormModel =& $toTableModel->getFormModel();
$toDb = $toTableModel->getDb();
$emailtable_to_table_name = FabrikString::safeColName($emailtable_to_table_name);
$emailtable_to_table_email = FabrikString::safeColName($emailtable_to_table_email);
$emailtable_to_table = $toDb->nameQuote($toTableModel->getTable()->db_table_name);
$toDb->setQuery("SELECT {$emailtable_to_table_email} AS email, {$emailtable_to_table_name} AS name FROM {$emailtable_to_table} ORDER BY name ASC");
$results = $toDb->loadObjectList();
$empty = new stdClass();
if ($toType == 'table_picklist') {
// $$$ hugh - yeah yeah, I'll move these into assets when I get a spare minute or three.
$html = '
<style type="text/css">
.fabrik_email_holder { width:200px; float:left; }
#email_add,#email_remove { display:block; width:150px; text-align:center; border:1px solid #ccc; background:#eee; }
.fabrik_email_holder select { margin:0 0 10px 0; width:150px; padding:5px; height:200px; }
</style>
<script type="text/javascript">
window.addEvent(\'domready\', function() {
$(\'email_add\').addEvent(\'click\', function() {
$(\'email_to_selectfrom\').getSelected().each(function(el) {
el.inject($(\'email_to\'));
});
});
$(\'email_remove\').addEvent(\'click\', function() {
$(\'email_to\').getSelected().each(function(el) {
el.inject($(\'email_to_selectfrom\'));
});
});
});
</script>
';
$html .= '<div class="fabrik_email_holder">';
$html .= JHTML::_('select.genericlist', $results, 'email_to_selectfrom[]', 'class="fabrikinput inputbox" multiple="multiple" size="5"', 'email', 'name', '', 'email_to_selectfrom');
$html .= '<a href="javascript:;" id="email_add">add >></a>';
$html .= '</div>';
$html .= '<div class="fabrik_email_holder">';
$html .= JHTML::_('select.genericlist', $empty, 'email_to[]', 'class="fabrikinput inputbox" multiple="multiple" size="5"', 'email', 'name', '', 'email_to');
$html .= '<a href="javascript:;" id="email_remove"><< remove</a>';
$html .= '</div>';
$html .= '<div style="clear:both;"></div>';
} else {
$html = JHTML::_('select.genericlist', $results, 'email_to[]', 'class="fabrikinput inputbox" multiple="multiple" size="5"', 'email', 'name', '', 'email_to');
}
return $html;
}
}
}
}
示例13: dochown
function dochown()
{
$app =& JFactory::getApplication();
$tableModel =& $this->getModel('Table');
$tableModel->setId(JRequest::getVar('id', 0));
$db = $tableModel->getDb();
$params =& $tableModel->getParams();
$renderOrder = JRequest::getInt('renderOrder', 0);
$recordids = explode(',', JRequest::getVar('recordids'));
$lang =& JFactory::getLanguage();
$lang->load('com_fabrik.plg.table.chown');
$chown_to_val = JRequest::getInt('chown_to_val', 0);
if (empty($chown_to_val)) {
echo '<div class="chown_result">' . JText::_('PLG_TABLE_CHOWN_NO_SELECTION') . '</div>';
return;
}
$chowns = array();
$chown_field_to_change_1 = $params->get('chown_field_to_change_1');
if (is_array($chown_field_to_change_1)) {
$chown_field_to_change_1 = JArrayHelper::getValue($chown_field_to_change_1, $renderOrder, '');
}
if (!empty($chown_field_to_change_1)) {
$chowns[] = "{$chown_field_to_change_1} = " . $db->Quote($chown_to_val);
}
$chown_field_to_change_2 = $params->get('chown_field_to_change_2');
if (is_array($chown_field_to_change_2)) {
$chown_field_to_change_2 = JArrayHelper::getValue($chown_field_to_change_2, $renderOrder, '');
}
if (!empty($chown_field_to_change_2)) {
$chowns[] = "{$chown_field_to_change_2} = " . $db->Quote($chown_to_val);
}
$chown_field_to_change_3 = $params->get('chown_field_to_change_3');
if (is_array($chown_field_to_change_3)) {
$chown_field_to_change_3 = JArrayHelper::getValue($chown_field_to_change_3, $renderOrder, '');
}
if (!empty($chown_field_to_change_3)) {
$chowns[] = "{$chown_field_to_change_3} = " . $db->Quote($chown_to_val);
}
if (empty($chowns)) {
echo '<div class="chown_result">' . JText::_('PLG_TABLE_CHOWN_NO_SELECTION') . '</div>';
return;
}
$table_name = $db->nameQuote($tableModel->getTable()->db_table_name);
$pk_field = FabrikString::safeColName($tableModel->getTable()->db_primary_key);
$query = "UPDATE {$table_name} SET " . implode(',', $chowns) . " WHERE {$pk_field} IN (" . implode(',', $recordids) . ")";
$db->setQuery($query);
if (!$db->query()) {
echo '<div class="chown_result">' . JText::sprintf('PLG_TABLE_CHOWN_X_ERRORS', $db->getErrorMsg()) . '</div>';
} else {
echo '<div class="chown_result">' . JText::sprintf('PLG_TABLE_CHOWN_X_CHANGED', count($recordids)) . '</div>';
}
echo '<div class="chown_result"><button onclick="window.parent.location.reload()">OK</button></div>';
/*
$addmany_to_fk_val = JRequest::getInt('addmany_to_fk_val');
$tableModel =& $this->getModel('Table');
$tableModel->setId(JRequest::getVar('id', 0));
//$formModel =& $tableModel->getForm();
//$this->formModel =& $formModel;
$params =& $tableModel->getParams();
$addmany_to_table = $params->get('addmany_to_table');
if (is_array($addmany_to_table)) {
$addmany_to_table = $addmany_to_table[$renderOrder];
}
$addmany_to_fk = $params->get('addmany_to_fk');
if (is_array($addmany_to_fk)) {
$addmany_to_fk = $addmany_to_fk[$renderOrder];
}
$addmany_from_fk = $params->get('addmany_from_fk');
if (is_array($addmany_from_fk)) {
$addmany_from_fk = $addmany_from_fk[$renderOrder];
}
$toTableModel =& $this->getModel( 'Table' );
$toTableModel->setId($addmany_to_table);
$toFormModel =& $toTableModel->getFormModel();
$addmany_to_date = '';
$date_elementModel =& $toFormModel->getElement('date_time');
if (!empty($date_elementModel)) {
$addmany_to_date = FabrikString::safeColName($date_elementModel->getFullName(false, true, false));
}
$addmany_to_fk = FabrikString::safeColName($addmany_to_fk);
$addmany_to_fk_short = FabrikString::shortColName($addmany_to_fk);
$addmany_from_fk = FabrikString::safeColName($addmany_from_fk);
$toDb = $toTableModel->getDb();
$addmany_to_db_table_name = $toDb->nameQuote($toTableModel->getTable()->db_table_name);
$addmany_from_db_table_name = $toDb->nameQuote($tableModel->getTable()->db_table_name);
$addmany_to_fk_val = $toDb->Quote($addmany_to_fk_val);
$addmany_added = 0;
$addmany_already_exist = 0;
$addmany_add_errors = 0;
$addmany_additional_child_fields = $params->get('addmany_additional_child_fields', '');
if (is_array($addmany_additional_child_fields)) {
$addmany_additional_child_fields = JArrayHelper::getValue($addmany_additional_child_fields, $renderOrder, '');
}
$addmany_additional_child_from_fields = array();
$addmany_additional_child_to_fields = array();
//.........这里部分代码省略.........
示例14: onAutocomplete_options
/**
* ajax method to get a json array of value/text pairs of options for the
* auto-complete rendering of the element.
*/
public function onAutocomplete_options()
{
//needed for ajax update (since we are calling this method via dispatcher element is not set
$this->_id = JRequest::getInt('element_id');
$this->getElement(true);
$db =& FabrikWorker::getDbo();
$c = $this->_getValColumn();
if (!strstr($c, 'CONCAT')) {
$c = FabrikString::safeColName($c);
}
$this->_autocomplete_where = $c . ' LIKE ' . $db->Quote('%' . JRequest::getVar('value') . '%');
$tmp =& $this->_getOptions(array(), 0, false);
echo json_encode($tmp);
}
示例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;
}