本文整理汇总了PHP中FabrikString::clean方法的典型用法代码示例。如果您正苦于以下问题:PHP FabrikString::clean方法的具体用法?PHP FabrikString::clean怎么用?PHP FabrikString::clean使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FabrikString
的用法示例。
在下文中一共展示了FabrikString::clean方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _loadTmplBottom
//.........这里部分代码省略.........
}
}
$fields[] = JHTML::_('form.token');
$resetLabel = FText::_($params->get('reset_button_label'));
$resetIcon = $params->get('reset_icon', '');
$copyLabel = FText::_($params->get('copy_button_label'));
$copyIcon = $params->get('copy_icon', '');
$applyLabel = FText::_($params->get('apply_button_label'));
$applyIcon = $params->get('apply_icon', '');
$deleteLabel = FText::_($params->get('delete_button_label', 'Delete'));
$deleteIcon = $params->get('delete_icon', '');
$goBackLabel = FText::_($params->get('goback_button_label'));
$goBackIcon = $params->get('goback_icon', '');
$btnLayout = FabrikHelperHTML::getLayout('fabrik-button');
if ($resetIcon !== '') {
$resetIcon = FabrikHelperHTML::icon($resetIcon);
$before = $params->get('reset_icon_location', 'before') == 'before';
$resetLabel = $before ? $resetIcon . ' ' . $resetLabel : $resetLabel . ' ' . $resetIcon;
}
$layoutData = (object) array('type' => 'reset', 'class' => 'btn-warning button', 'name' => 'Reset', 'label' => $resetLabel);
$form->resetButton = $params->get('reset_button', 0) && $this->editable == '1' ? $btnLayout->render($layoutData) : '';
if ($copyIcon !== '') {
$copyIcon = FabrikHelperHTML::icon($copyIcon);
$copyLabel = $params->get('copy_icon_location', 'before') == 'before' ? $copyIcon . ' ' . $copyLabel : $copyLabel . ' ' . $copyIcon;
}
$layoutData = (object) array('type' => 'submit', 'class' => 'button', 'name' => 'Copy', 'label' => $copyLabel);
$form->copyButton = $params->get('copy_button', 0) && $this->editable && $model->getRowId() != '' ? $btnLayout->render($layoutData) : '';
if ($applyIcon !== '') {
$applyIcon = FabrikHelperHTML::icon($applyIcon);
$before = $params->get('apply_icon_location', 'before') == 'before';
$applyLabel = $before ? $applyIcon . ' ' . $applyLabel : $applyLabel . ' ' . $applyIcon;
}
$layoutData = (object) array('type' => $model->isAjax() ? 'button' : 'submit', 'class' => 'button', 'name' => 'apply', 'label' => $applyLabel);
$form->applyButton = $params->get('apply_button', 0) && $this->editable ? $btnLayout->render($layoutData) : '';
if ($deleteIcon !== '') {
$deleteIcon = FabrikHelperHTML::icon($deleteIcon);
$before = $params->get('delete_icon_location', 'before') == 'before';
$deleteLabel = $before ? $deleteIcon . ' ' . $deleteLabel : $deleteLabel . ' ' . $deleteIcon;
}
$layoutData = (object) array('type' => 'submit', 'class' => 'btn-danger button', 'name' => 'delete', 'label' => $deleteLabel);
$form->deleteButton = $params->get('delete_button', 0) && $canDelete && $this->editable && $thisRowId != '' ? $btnLayout->render($layoutData) : '';
if ($goBackIcon !== '') {
$goBackIcon = FabrikHelperHTML::icon($goBackIcon);
$before = $params->get('goback_icon_location', 'before') == 'before';
$goBackLabel = $before ? $goBackIcon . ' ' . $goBackLabel : $goBackLabel . ' ' . $goBackIcon;
}
$layoutData = (object) array('type' => 'button', 'class' => 'button', 'name' => 'Goback', 'label' => $goBackLabel, 'attributes' => $model->isAjax() ? '' : FabrikWorker::goBackAction());
$form->gobackButton = $params->get('goback_button', 0) ? $btnLayout->render($layoutData) : '';
if ($model->isEditable() && $params->get('submit_button', 1)) {
$submitClass = FabrikString::clean($form->submit_button_label);
$submitIcon = $params->get('save_icon', '');
$submitLabel = FText::_($form->submit_button_label);
if ($submitIcon !== '') {
$submitIcon = FabrikHelperHTML::icon($submitIcon);
$before = $params->get('save_icon_location', 'before') == 'before';
$submitLabel = $before ? $submitIcon . ' ' . $submitLabel : $submitLabel . ' ' . $submitIcon;
}
$layoutData = (object) array('type' => $model->isAjax() ? 'button' : 'submit', 'class' => 'btn-primary button ' . $submitClass, 'name' => 'Submit', 'label' => $submitLabel);
$form->submitButton = $btnLayout->render($layoutData);
} else {
$form->submitButton = '';
}
if ($this->isMultiPage) {
$layoutData = (object) array('type' => 'button', 'class' => 'fabrikPagePrevious button', 'name' => 'fabrikPagePrevious', 'label' => FabrikHelperHTML::icon('icon-previous', FText::_('COM_FABRIK_PREV')));
$form->prevButton = $btnLayout->render($layoutData);
$layoutData = (object) array('type' => 'button', 'class' => 'fabrikPageNext button', 'name' => 'fabrikPageNext', 'label' => FText::_('COM_FABRIK_NEXT') . ' ' . FabrikHelperHTML::icon('icon-next'));
$form->nextButton = $btnLayout->render($layoutData);
} else {
$form->nextButton = '';
$form->prevButton = '';
}
// $$$ hugh - hide actions section is we're printing, or if not actions selected
$noButtons = empty($form->nextButton) && empty($form->prevButton) && empty($form->submitButton) && empty($form->gobackButton) && empty($form->deleteButton) && empty($form->applyButton) && empty($form->copyButton) && empty($form->resetButton);
$this->hasActions = $input->get('print', '0') == '1' || $noButtons ? false : true;
$format = $model->isAjax() ? 'raw' : 'html';
$fields[] = '<input type="hidden" name="format" value="' . $format . '" />';
$groups = $model->getGroupsHiarachy();
foreach ($groups as $groupModel) {
if ($groupModel->isJoin()) {
$groupPk = $groupModel->getJoinModel()->getForeignId();
// Use raw otherwise we inject the actual <input> into the hidden field's value
$groupPk .= '_raw';
$groupRowIds = (array) FArrayHelper::getValue($this->data, $groupPk, array());
$groupRowIds = htmlentities(json_encode($groupRowIds));
// Used to check against in group process(), when deleting removed repeat groups
$fields[] = '<input type="hidden" name="fabrik_group_rowids[' . $groupModel->getId() . ']" value="' . $groupRowIds . '" />';
}
$group = $groupModel->getGroup();
$c = $groupModel->repeatTotal;
// Used for validations
$fields[] = '<input type="hidden" name="fabrik_repeat_group[' . $group->id . ']" value="' . $c . '" id="fabrik_repeat_group_' . $group->id . '_counter" />';
}
// $$$ hugh - testing social_profile_hash stuff
if ($input->get('fabrik_social_profile_hash', '') != '') {
$fields[] = '<input type="hidden" name="fabrik_social_profile_hash" value="' . $input->get('fabrik_social_profile_hash', '') . '" id="fabrik_social_profile_hash" />';
}
$this->_cryptQueryString($fields);
$this->_cryptViewOnlyElements($fields);
$this->hiddenFields = implode("\n", $fields);
}
示例2: save
/**
* Save the form
*
* @param array $data the jForm part of the request data
*
* @return bool
*/
public function save($data)
{
$this->populateState();
$input = $this->app->input;
$jForm = $input->get('jform', array(), 'array');
$date = JFactory::getDate();
$row = $this->getTable();
$id = FArrayHelper::getValue($data, 'id');
$row->load($id);
$params = new Registry($row->get('params'));
$isView = $this->setIsView($params);
$data['params']['isView'] = (string) $isView;
$this->setState('list.id', $id);
$this->setState('list.form_id', $row->get('form_id'));
$feModel = $this->getFEModel();
/** @var $contentTypeModel FabrikAdminModelContentTypeImport */
$contentTypeModel = JModelLegacy::getInstance('ContentTypeImport', 'FabrikAdminModel', array('listModel' => $this));
$contentType = ArrayHelper::getValue($jForm, 'contenttype', '');
if ($contentType !== '') {
$contentTypeModel->check($contentType);
}
// Get original collation
$db = $feModel->getDb();
$origCollation = $this->getOriginalCollation($params, $db, FArrayHelper::getValue($data, 'db_table_name', ''));
$row->bind($data);
$row->set('order_by', json_encode($input->get('order_by', array(), 'array')));
$row->set('order_dir', json_encode($input->get('order_dir', array(), 'array')));
$row->check();
$isNew = true;
if ($row->id != 0) {
$this->collation($feModel, $origCollation, $row);
$dateNow = JFactory::getDate();
$row->set('modified', $dateNow->toSql());
$row->set('modified_by', $this->user->get('id'));
}
if ($id == 0) {
if ($row->get('created', '') == '') {
$row->set('created', $date->toSql());
}
$isNew = false;
$existingTable = ArrayHelper::getValue($data, 'db_table_name', '');
$newTable = $existingTable === '' ? trim(FArrayHelper::getValue($data, '_database_name')) : '';
// Mysql will force db table names to lower case even if you set the db name to upper case - so use clean()
$newTable = FabrikString::clean($newTable);
// Check the entered database table doesn't already exist
if ($newTable != '' && $this->databaseTableExists($newTable)) {
throw new RuntimeException(FText::_('COM_FABRIK_DATABASE_TABLE_ALREADY_EXISTS'));
}
if (!$this->canCreateDbTable()) {
throw new RuntimeException(FText::_('COM_FABRIK_INSUFFICIENT_RIGHTS_TO_CREATE_TABLE'));
}
// Save the row now
$row->store();
// Create fabrik form
$this->createLinkedForm();
$row->set('form_id', $this->getState('list.form_id'));
$groupData = FabrikWorker::formDefaults('group');
$groupData['name'] = $row->label;
$groupData['label'] = $row->label;
if ($newTable == '') {
// Create fabrik group
$input->set('_createGroup', 1);
$groupId = $this->createLinkedGroup($groupData, false);
// New fabrik list but existing db table
$this->createLinkedElements($groupId);
} else {
$row->set('db_table_name', $newTable);
$row->set('auto_inc', 1);
$dbOpts = array();
$params = new Registry($row->get('params'));
$dbOpts['COLLATE'] = $params->get('collation', '');
$fields = $contentTypeModel->import($contentType, $row->get('db_table_name'), $groupData);
$res = $this->createDBTable($newTable, $fields, $dbOpts);
if (is_array($res)) {
$row->set('db_primary_key', $newTable . '.' . $res[0]);
}
}
}
$row->set('publish_down', FabrikAdminHelper::prepareSaveDate($row->get('publish_down')));
$row->set('created', FabrikAdminHelper::prepareSaveDate($row->get('created')));
$row->set('publish_up', FabrikAdminHelper::prepareSaveDate($row->get('publish_up')));
$pk = FArrayHelper::getValue($data, 'db_primary_key');
if ($pk == '') {
$pk = $feModel->getPrimaryKeyAndExtra($row->get('db_table_name'));
$key = $pk[0]['colname'];
$extra = $pk[0]['extra'];
// Store without qns as that's db specific
$row->set('db_primary_key', $row->get('db_primary_key', '') == '' ? $row->get('db_table_name') . '.' . $key : $row->get('db_primary_key'));
$row->set('auto_inc', JString::stristr($extra, 'auto_increment') ? true : false);
}
$row->store();
$this->updateJoins($data);
// Needed to ensure pk field is not quoted
//.........这里部分代码省略.........
示例3: importChooseElements
function importChooseElements($fields, $lists)
{
$addkey = JRequest::getVar('addkey', array(), 'default', 'array');
$addkey = $addkey[0];
FabrikViewTable::setImportChooseElementsToolbar();
?>
<form id="adminForm" name="adminForm" method="post" action="index.php">
<table class="adminlist">
<thead>
<tr>
<th><?php
echo JText::_('FIELD');
?>
</th>
<th><?php
echo JText::_('ELEMENT TYPE');
?>
</th>
<th><?php
echo JText::_('LABEL');
?>
</th>
<?php
if ($addkey == 0) {
?>
<th><?php
echo JText::_('PRIMARY KEY');
?>
</th>
<th><?php
echo JText::_('AUTO INCREMENT');
?>
</th>
<?php
}
?>
</tr>
</thead>
<tbody>
<?php
foreach ($fields as $field) {
$field = strtolower($field);
$cleaned = FabrikString::clean($field, "UTF-8", "ASCII//TRANSLIT//IGNORE");
?>
<tr>
<td><label for="userfile"><?php
echo $cleaned;
?>
</label></td>
<td><?php
echo $lists['elementtype'];
?>
</td>
<td>
<input name="label[]" value="<?php
echo str_replace("_", " ", $cleaned);
?>
" />
<input type="hidden" name="field[]" value="<?php
echo $cleaned;
?>
" />
</td>
<?php
if ($addkey == 0) {
?>
<td>
<label>
<input type="radio" checked="checked" name="primarykey[<?php
echo $cleaned;
?>
][]" value="0" /><?php
echo JText::_('NO');
?>
</label>
<label>
<input type="radio" name="primarykey[<?php
echo $cleaned;
?>
][]" value="1" /><?php
echo JText::_('YES');
?>
</label>
</td>
<td>
<label>
<input type="radio" checked="checked" name="autoinc[<?php
echo $cleaned;
?>
][]" value="0" /><?php
echo JText::_('NO');
?>
</label>
<label>
<input type="radio" name="autoinc[<?php
echo $cleaned;
?>
][]" value="1" /><?php
echo JText::_('YES');
?>
//.........这里部分代码省略.........
示例4: safeTableName
/**
* Create a safe table name from the input
*
* @param bool $isNew
* @param array $data
* @param FabrikTableList $item
*
* @return string
*/
private function safeTableName($isNew, $data, $item)
{
if ($isNew) {
$dbTableName = $data['db_table_name'] !== '' ? $data['db_table_name'] : $data['label'];
// Mysql will force db table names to lower case even if you set the db name to upper case - so use clean()
$dbTableName = FabrikString::clean($dbTableName);
// Otherwise part of the table name is taken for element names
$dbTableName = str_replace('___', '_', $dbTableName);
} else {
$dbTableName = $item->get('db_table_name', '') == '' ? $data['database_name'] : $item->get('db_table_name');
}
return preg_replace('#[^0-9a-zA-Z_]#', '', $dbTableName);
}
示例5: saveFormGroups
/**
* After having saved the form we
* 1) Create a new group if none selected in edit form list
* 2) Delete all old form_group records
* 3) Recreate the form group records
* 4) Make a table view if needed
*
* @param array $data jform data
*
* @return bool True if you should display the form list, False if you're
* redirected elsewhere
*/
public function saveFormGroups($data)
{
// These are set in parent::save() and contain the updated form id and if the form is a new form
$formid = $this->getState($this->getName() . '.id');
$isnew = $this->getState($this->getName() . '.new');
$db = FabrikWorker::getDbo(true);
$currentGroups = (array) JArrayHelper::getValue($data, 'current_groups');
$record_in_database = $data['record_in_database'];
$createGroup = $data['_createGroup'];
$form = $this->getForm();
$fields = array('id' => 'internalid', 'date_time' => 'date');
// If new and record in db and group selected then we want to get those groups elements to create fields for in the db table
if ($isnew && $record_in_database) {
$groups = JArrayHelper::getValue($data, 'current_groups');
if (!empty($groups)) {
$query = $db->getQuery(true);
$query->select('plugin, name')->from('#__fabrik_elements')->where('group_id IN (' . implode(',', $groups) . ')');
$db->setQuery($query);
$rows = $db->loadObjectList();
foreach ($rows as $row) {
$fields[$row->name] = $row->plugin;
}
}
}
if ($createGroup) {
$group = FabTable::getInstance('Group', 'FabrikTable');
$group->name = $data['label'];
$group->published = 1;
$group->store();
$currentGroups[] = $db->insertid();
}
$this->_makeFormGroups($data, $currentGroups);
if ($record_in_database == '1') {
$listModel = JModel::getInstance('List', 'FabrikModel');
$item = $listModel->loadFromFormId($formid);
if ($isnew) {
$dbTableName = $data['db_table_name'] !== '' ? $data['db_table_name'] : $data['label'];
// Mysql will force db table names to lower case even if you set the db name to upper case - so use clean()
$dbTableName = FabrikString::clean($dbTableName);
// Otherwise part of the table name is taken for element names
$dbTableName = str_replace('___', '_', $dbTableName);
} else {
$dbTableName = $item->db_table_name == '' ? $data['database_name'] : $item->db_table_name;
}
$dbTableExists = $listModel->databaseTableExists($dbTableName);
if (!$dbTableExists) {
/**
* @TODO - need to sanitize table name (get rid of non alphanumeirc or _),
* just not sure whether to do it here, or above (before we test for existinance)
* $$$ hugh - for now, just do it here, after we test for the 'unsanitized', as
* need to do some more testing on MySQL table name case sensitivity
* BUT ... as we're potentially changing the table name after testing for existance
* we need to test again.
* $$$ rob - was replacing with '_' but if your form name was 'x - y' then this was
* converted to x___y which then blows up element name code due to '___' being presumed to be the element splitter.
*/
$dbTableName = preg_replace('#[^0-9a-zA-Z_]#', '', $dbTableName);
if ($listModel->databaseTableExists($dbTableName)) {
return JError::raiseWarning(500, JText::_("COM_FABRIK_DB_TABLE_ALREADY_EXISTS"));
}
$listModel->set('form.id', $formid);
$listModel->createDBTable($dbTableName, $fields);
}
if (!$dbTableExists || $isnew) {
$connection = FabrikWorker::getConnection(-1);
$item->id = null;
$item->label = $data['label'];
$item->form_id = $formid;
$item->connection_id = $connection->getConnection()->id;
$item->db_table_name = $dbTableName;
// Store key without quoteNames as thats db specific *which we no longer want
$item->db_primary_key = $dbTableName . '.id';
$item->auto_inc = 1;
$item->published = $data['published'];
$item->created = $data['created'];
$item->created_by = $data['created_by'];
$item->access = 1;
$item->params = $listModel->getDefaultParams();
$res = $item->store();
} else {
// Update existing table (seems to need to reload here to ensure that _table is set
$item = $listModel->loadFromFormId($formid);
$listModel->ammendTable();
}
}
}
示例6: save
/**
* Save the form
*
* @param array $data the jform part of the request data
*
* @return bool
*/
public function save($data)
{
$this->populateState();
$app = JFactory::getApplication();
$input = $app->input;
$user = JFactory::getUser();
$config = JFactory::getConfig();
$date = JFactory::getDate();
$row = $this->getTable();
$id = JArrayHelper::getValue($data, 'id');
$row->load($id);
$params = new JRegistry($row->params);
$this->setState('list.id', $id);
$this->setState('list.form_id', $row->form_id);
$feModel = $this->getFEModel();
$formModel = $this->getFormModel();
// Get original collation
$db = $feModel->getDb();
if (!empty($data['db_table_name'])) {
$db->setQuery('SHOW TABLE STATUS LIKE ' . $db->quote($data['db_table_name']));
$info = $db->loadObject();
$origCollation = is_object($info) ? $info->Collation : $params->get('collation', 'none');
} else {
$origCollation = $params->get('collation', 'none');
}
$row->bind($data);
$row->order_by = json_encode($input->get('order_by', array(), 'array'));
$row->order_dir = json_encode($input->get('order_dir', array(), 'array'));
$row->check();
$this->collation($feModel, $origCollation, $row);
$isNew = true;
if ($row->id != 0) {
$datenow = JFactory::getDate();
$row->modified = $datenow->toSql();
$row->modified_by = $user->get('id');
}
if ($id == 0) {
if ($row->created == '') {
$row->created = $date->toSql();
}
// Save the row now
$row->store();
$isNew = false;
$newtable = trim(JArrayHelper::getValue($data, '_database_name'));
// Mysql will force db table names to lower case even if you set the db name to upper case - so use clean()
$newtable = FabrikString::clean($newtable);
// Check the entered database table doesnt already exist
if ($newtable != '' && $this->databaseTableExists($newtable)) {
throw new RuntimeException(JText::_('COM_FABRIK_DATABASE_TABLE_ALREADY_EXISTS'));
return false;
}
if (!$this->canCreateDbTable()) {
throw new RuntimeException(Jtext::_('COM_FABRIK_INSUFFICIENT_RIGHTS_TO_CREATE_TABLE'));
return false;
}
// Create fabrik form
$formModel = $this->createLinkedForm();
$row->form_id = $this->getState('list.form_id');
// Create fabrik group
$groupData = FabrikWorker::formDefaults('group');
$groupData['name'] = $row->label;
$groupData['label'] = $row->label;
$input->set('_createGroup', 1, 'post');
$groupId = $this->createLinkedGroup($groupData, false);
if ($newtable == '') {
// New fabrik list but existing db table
$this->createLinkedElements($groupId);
} else {
$row->db_table_name = $newtable;
$row->auto_inc = 1;
$dbOpts = array();
$params = new JRegistry($row->params);
$dbOpts['COLLATE'] = $params->get('collation', '');
$res = $this->createDBTable($newtable, $input->get('defaultfields', array('id' => 'internalid', 'date_time' => 'date'), 'array'), $dbOpts);
if (is_array($res)) {
$row->db_primary_key = $newtable . '.' . $res[0];
}
}
}
$params = new JRegistry($row->params);
$params->set('isview', $feModel->isView());
$row->params = (string) $params;
FabrikAdminHelper::prepareSaveDate($row->publish_down);
FabrikAdminHelper::prepareSaveDate($row->created);
FabrikAdminHelper::prepareSaveDate($row->publish_up);
$pk = JArrayHelper::getValue($data, 'db_primary_key');
if ($pk == '') {
$pk = $feModel->getPrimaryKeyAndExtra($row->db_table_name);
$key = $pk[0]['colname'];
$extra = $pk[0]['extra'];
// Store without quoteNames as thats db specific
$row->db_primary_key = $row->db_primary_key == '' ? $row->db_table_name . "." . $key : $row->db_primary_key;
$row->auto_inc = JString::stristr($extra, 'auto_increment') ? true : false;
//.........这里部分代码省略.........
示例7: save
/**
* Save the form
*
* @param array $data the jform part of the request data
*
* @return bool
*/
public function save($data)
{
$this->populateState();
$app = JFactory::getApplication();
$user = JFactory::getUser();
$config = JFactory::getConfig();
$date = JFactory::getDate();
$row = $this->getTable();
$id = $data['id'];
$row->load($id);
$this->setState('list.id', $id);
$this->setState('list.form_id', $row->form_id);
$feModel = $this->getFEModel();
$formModel = $this->getFormModel();
if (!$row->bind($data)) {
$this->setError($row->getError());
return false;
}
$filter = new JFilterInput(null, null, 1, 1);
$introduction = JArrayHelper::getValue(JRequest::getVar('jform', array(), 'post', 'array', JREQUEST_ALLOWRAW), 'introduction');
$row->introduction = $filter->clean($introduction);
$row->order_by = json_encode(JRequest::getVar('order_by', array(), 'post', 'array'));
$row->order_dir = json_encode(JRequest::getVar('order_dir', array(), 'post', 'array'));
if (!$row->check()) {
$this->setError($row->getError());
return false;
}
$isNew = true;
if ($id == 0) {
if ($row->created == '') {
$row->created = $date->toSql();
}
// Save the row now
$row->store();
$isNew = false;
$newtable = trim(JArrayHelper::getValue($data, '_database_name'));
// Mysql will force db table names to lower case even if you set the db name to upper case - so use clean()
$newtable = FabrikString::clean($newtable);
// Check the entered database table doesnt already exist
if ($newtable != '' && $this->databaseTableExists($newtable)) {
$this->setError(JText::_('COM_FABRIK_DATABASE_TABLE_ALREADY_EXISTS'));
return false;
}
if (!$this->canCreateDbTable()) {
$this->setError(Jtext::_('COM_FABRIK_INSUFFICIENT_RIGHTS_TO_CREATE_TABLE'));
return false;
}
// Create fabrik form
$formModel = $this->createLinkedForm();
$row->form_id = $this->getState('list.form_id');
// Create fabrik group
$groupData = FabrikWorker::formDefaults('group');
$groupData['name'] = $row->label;
$groupData['label'] = $row->label;
JRequest::setVar('_createGroup', 1, 'post');
$groupId = $this->createLinkedGroup($groupData, false);
if ($newtable == '') {
// New fabrik list but existing db table
$this->createLinkedElements($groupId);
} else {
$row->db_table_name = $newtable;
$row->auto_inc = 1;
$res = $this->createDBTable($newtable, JRequest::getVar('defaultfields', array('id' => 'internalid', 'date_time' => 'date')));
if (is_array($res)) {
$row->db_primary_key = $newtable . '.' . $res[0];
}
}
}
$params = new JRegistry($row->params);
if ($row->id != 0) {
$datenow = JFactory::getDate();
$row->modified = $datenow->toSql();
$row->modified_by = $user->get('id');
}
FabrikAdminHelper::prepareSaveDate($row->publish_down);
FabrikAdminHelper::prepareSaveDate($row->created);
FabrikAdminHelper::prepareSaveDate($row->publish_up);
$pk = JArrayHelper::getValue($data, 'db_primary_key');
if ($pk == '') {
$fields = $row->getFields();
$key = $row->getKeyName();
// Store without quoteNames as thats db specific
$row->db_primary_key = $row->db_primary_key == '' ? $row->db_table_name . "." . $key : $row->db_primary_key;
$row->auto_inc = JString::stristr($fields[$key]->Extra, 'auto_increment') ? true : false;
}
if (!$row->store()) {
$this->setError($row->getError());
return false;
}
$pk = $row->db_primary_key;
$this->updateJoins($data);
// Needed to ensure pk field is not quoted
$feModel->setTable($row);
//.........这里部分代码省略.........
示例8: _replaceWithIcons
/**
* replace labels shown in table view with icons (if found)
* @since 3.0 - icon_folder is a bool - search through template folders for icons
* @param string data
* @return string data
*/
function _replaceWithIcons($data)
{
if ($data == '') {
$this->iconsSet = false;
return $data;
}
$params = $this->getParams();
if ($params->get('icon_folder', 0) == 0) {
$this->iconsSet = false;
return $data;
}
$iconfile = $params->get('icon_file');
//Jaanus added this and following if/else; sometimes we need permanent image (e.g logo of the website where the link always points, like Wikipedia's W)
$cleanData = $iconfile == '' ? FabrikString::clean($data) : $iconfile;
foreach ($this->_imageExtensions as $ex) {
$f = JPath::clean($cleanData . '.' . $ex);
$img = FabrikHelperHTML::image($cleanData . '.' . $ex);
if ($img !== '') {
$this->iconsSet = true;
$img = '<a class="fabrikTip" href="#" title="' . $data . '">' . $img . '</a>';
return $img;
}
}
$this->iconsSet = false;
return $data;
}
示例9: _replaceWithIcons
/**
* replace labels shown in table view with icons (if found)
* @since 3.0 - icon_folder is a bool - search through template folders for icons
* @param string data
* @return string data
*/
function _replaceWithIcons($data)
{
if ($data == '') {
$this->iconsSet = false;
return $data;
}
$params =& $this->getParams();
if ($params->get('icon_folder', 0) == 0) {
$this->iconsSet = false;
return $data;
}
$cleanData = FabrikString::clean($data);
foreach ($this->_imageExtensions as $ex) {
$f = JPath::clean($cleanData . '.' . $ex);
$img = FabrikHelperHTML::image($cleanData . '.' . $ex);
if ($img !== '') {
$this->iconsSet = true;
return $img;
}
}
$this->iconsSet = false;
return $data;
}
示例10: _replaceWithIcons
/**
* Replace labels shown in table view with icons (if found)
*
* @param string $data data
* @param string $view list/details
* @param string $tmpl template
*
* @since 3.0 - icon_folder is a bool - search through template folders for icons
*
* @return string data
*/
protected function _replaceWithIcons($data, $view = 'list', $tmpl = null)
{
if ($data == '') {
$this->iconsSet = false;
return $data;
}
$params = $this->getParams();
if ((int) $params->get('icon_folder', 0) === 0) {
$this->iconsSet = false;
return $data;
}
$listModel = $this->getListModel();
if (in_array($listModel->getOutPutFormat(), array('csv', 'rss'))) {
$this->iconsSet = false;
return $data;
}
/**
* Jaanus added this and following if/else; sometimes we need permanent image
* (e.g logo of the website where the link always points, like Wikipedia's W)
*/
$iconfile = $params->get('icon_file', '');
$cleanData = $iconfile === '' ? FabrikString::clean(strip_tags($data)) : $iconfile;
foreach ($this->_imageExtensions as $ex) {
$f = JPath::clean($cleanData . '.' . $ex);
$img = FabrikHelperHTML::image($cleanData . '.' . $ex, $view, $tmpl);
if ($img !== '') {
$this->iconsSet = true;
$opts = new stdClass();
$opts->position = 'top';
$opts = json_encode($opts);
$data = '<span>' . $data . '</span>';
if ($params->get('icon_hovertext', true)) {
$data = htmlspecialchars($data, ENT_QUOTES);
$img = '<a class="fabrikTip" href="#" opts=\'' . $opts . '\' title="' . $data . '">' . $img . '</a>';
} elseif (!empty($iconfile)) {
/**
* $$$ hugh - kind of a hack, but ... if this is an upload element, it may already be a link, and
* we'll need to replace the text in the link with the image
* After ages dicking around with a regex to do this, decided to use DOMDocument instead!
*/
$html = new DOMDocument();
$html->loadXML($data);
$as = $html->getElementsBytagName('a');
if ($as->length) {
$img = $html->createElement('img');
$img->setAttribute('src', FabrikHelperHTML::image($cleanData . '.' . $ex, $view, $tmpl, array(), true));
$as->item(0)->nodeValue = '';
$as->item(0)->appendChild($img);
return $html->saveHTML();
}
}
return $img;
}
}
$this->iconsSet = false;
return $data;
}
示例11: replaceWithIcons
/**
* Replace labels shown in list view with icons (if found)
*
* @param string $data Data
* @param string $view List/details
* @param string $tmpl Template
*
* @since 3.0 - icon_folder is a bool - search through template folders for icons
*
* @return string data
*/
protected function replaceWithIcons($data, $view = 'list', $tmpl = null)
{
if ($data == '') {
$this->iconsSet = false;
return $data;
}
$params = $this->getParams();
$listModel = $this->getListModel();
$iconFile = (string) $params->get('icon_file', '');
if ((int) $params->get('icon_folder', 0) === 0 && $iconFile === '') {
$this->iconsSet = false;
return $data;
}
if (in_array($listModel->getOutPutFormat(), array('csv', 'rss'))) {
$this->iconsSet = false;
return $data;
}
$cleanData = empty($iconFile) ? FabrikString::clean(strip_tags($data)) : $iconFile;
$cleanDatas = array($this->getElement()->name . '_' . $cleanData, $cleanData);
$opts = array('forceImage' => true);
//If subdir is set prepend file name with subdirectory (so first search through [template folders]/subdir for icons, e.g. images/subdir)
$iconSubDir = $params->get('icon_subdir', '');
if ($iconSubDir != '') {
$iconSubDir = rtrim($iconSubDir, '/') . '/';
$iconSubDir = ltrim($iconSubDir, '/');
array_unshift($cleanDatas, $iconSubDir . $cleanData);
//search subdir first
}
foreach ($cleanDatas as $cleanData) {
foreach ($this->imageExtensions as $ex) {
$img = FabrikHelperHTML::image($cleanData . '.' . $ex, $view, $tmpl, array(), false, $opts);
if ($img !== '') {
$this->iconsSet = true;
$opts = new stdClass();
$opts->position = 'top';
$opts = json_encode($opts);
$data = '<span>' . $data . '</span>';
// See if data has an <a> tag
if (class_exists('DOMDocument')) {
$html = new DOMDocument();
/**
* The loadXML() chokes if data has & in it. But we can't htmlspecialchar() it, as that removes
* the HTML markup we're looking for. So we need to ONLY change &'s which aren't already part of
* any HTML entities which may be in the data. So use a negative lookahead regex, which finds & followed
* by anything except non-space the ;. Then after doing the loadXML, we have to turn the &s back in
* to &, to avoid double encoding 'cos we're going to do an htmpsepecialchars() on $data in a few lines.
*/
$data = preg_replace('/&(?!\\S+;)/', '&', $data);
$html->loadXML($data);
$data = str_replace('&', '&', $data);
$as = $html->getElementsBytagName('a');
}
if ($params->get('icon_hovertext', true)) {
$aHref = '#';
$target = '';
if (class_exists('DOMDocument') && $as->length) {
// Data already has an <a href="foo"> lets get that for use in hover text
$a = $as->item(0);
$aHref = $a->getAttribute('href');
$target = $a->getAttribute('target');
$target = 'target="' . $target . '"';
}
$data = htmlspecialchars($data, ENT_QUOTES);
$img = '<a class="fabrikTip" ' . $target . ' href="' . $aHref . '" opts=\'' . $opts . '\' title="' . $data . '">' . $img . '</a>';
} elseif (!empty($iconFile)) {
/**
* $$$ hugh - kind of a hack, but ... if this is an upload element, it may already be a link, and
* we'll need to replace the text in the link with the image
* After ages dicking around with a regex to do this, decided to use DOMDocument instead!
*/
if (class_exists('DOMDocument') && $as->length) {
$img = $html->createElement('img');
$src = FabrikHelperHTML::image($cleanData . '.' . $ex, $view, $tmpl, array(), true, array('forceImage' => true));
$img->setAttribute('src', $src);
$as->item(0)->nodeValue = '';
$as->item(0)->appendChild($img);
return $html->saveHTML();
}
}
return $img;
}
}
}
return $data;
}
示例12: _loadTmplBottom
/**
* Create the fom bottom hidden fields
*
* @param object &$form object containg form view properties
*
* @return void
*/
protected function _loadTmplBottom(&$form)
{
$app = JFactory::getApplication();
$menuItem = $app->getMenu('site')->getActive();
$Itemid = $menuItem ? $menuItem->id : 0;
$model = $this->getModel();
$listModel = $model->getListModel();
$canDelete = $listModel->canDelete($model->_data);
$params = $model->getParams();
$task = 'form.process';
$reffer = JRequest::getVar('HTTP_REFERER', '', 'server');
// $$$rob - if returning from a failed validation then we should use the fabrik_referrer post var
$reffer = str_replace('&', '&', JRequest::getVar('fabrik_referrer', $reffer));
$this_rowid = is_array($model->_rowId) ? implode('|', $model->_rowId) : $model->_rowId;
$fields = array('<input type="hidden" name="listid" value="' . $listModel->getId() . '" />', '<input type="hidden" name="listref" value="' . $listModel->getId() . '" />', '<input type="hidden" name="rowid" value="' . $this_rowid . '" />', '<input type="hidden" name="Itemid" value="' . $Itemid . '" />', '<input type="hidden" name="option" value="com_fabrik" />', '<input type="hidden" name="task" value="' . $task . '" />', '<input type="hidden" name="isMambot" value="' . $this->isMambot . '" />', '<input type="hidden" name="formid" value="' . $model->get('id') . '" />', '<input type="hidden" name="returntoform" value="0" />', '<input type="hidden" name="fabrik_referrer" value="' . $reffer . '" />', '<input type="hidden" name="fabrik_ajax" value="' . (int) $model->isAjax() . '" />');
$fields[] = '<input type="hidden" name="_packageId" value="' . $model->packageId . '" />';
if ($usekey = FabrikWorker::getMenuOrRequestVar('usekey', '')) {
// $$$rob v's been set from -1 to the actual row id - so ignore usekyey not sure if we should comment this out
// see http://fabrikar.com/forums/showthread.php?t=10297&page=5
$fields[] = '<input type="hidden" name="usekey" value="' . $usekey . '" />';
$pk_val = JArrayHelper::getValue($model->_data, FabrikString::safeColNameToArrayKey($listModel->getTable()->db_primary_key));
if (empty($pk_val)) {
$fields[] = '<input type="hidden" name="usekey_newrecord" value="1" />';
}
}
/* $$$ hugh - testing a fix for pagination issue when submitting a 'search form'.
* If this is a search form, we need to clear 'limitstart', otherwise ... say we
* were last on page 4 of the (unfiltered) target table, and the search yields less than 4 pages,
* we end up with a blank table 'cos the wrong LIMIT's are applied to the query
*/
$save_insessions = $params->get('save_insession', '');
if (is_array($save_insessions)) {
foreach ($save_insessions as $save_insession) {
if ($save_insession == '1') {
$fields[] = '<input type="hidden" name="limitstart" value="0" />';
break;
}
}
}
$fields[] = JHTML::_('form.token');
$form->resetButton = $params->get('reset_button', 0) && $this->editable == "1" ? '<input type="reset" class="button btn" name="Reset" value="' . $params->get('reset_button_label') . '" />' : '';
$form->copyButton = $params->get('copy_button', 0) && $this->editable && $model->_rowId != '' ? '<input type="submit" class="button btn" name="Copy" value="' . $params->get('copy_button_label') . '" />' : '';
$applyButtonType = $model->isAjax() ? 'button' : 'submit';
$form->applyButton = $params->get('apply_button', 0) && $this->editable ? '<input type="' . $applyButtonType . '" class="button btn" name="apply" value="' . $params->get('apply_button_label') . '" />' : '';
$form->deleteButton = $params->get('delete_button', 0) && $canDelete && $this->editable && $this_rowid != 0 ? '<input type="submit" value="' . $params->get('delete_button_label', 'Delete') . '" class="button btn" name="delete" />' : '';
$form->gobackButton = $params->get('goback_button', 0) == "1" ? '<input type="button" class="button btn" name="Goback" ' . FabrikWorker::goBackAction() . ' value="' . $params->get('goback_button_label') . '" />' : '';
if ($model->isEditable() && $params->get('submit_button', 1)) {
$button = $model->isAjax() ? "button" : "submit";
$submitClass = FabrikString::clean($form->submit_button_label);
$form->submitButton = '<input type="' . $button . '" class="button ' . $submitClass . ' btn" name="submit" value="' . $form->submit_button_label . '" />';
} else {
$form->submitButton = '';
}
if ($this->isMultiPage) {
$form->prevButton = '<input type="button" class="fabrikPagePrevious button" name="fabrikPagePrevious" value="' . JText::_('COM_FABRIK_PREVIOUS') . '" />';
$form->nextButton = '<input type="button" class="fabrikPageNext button" name="fabrikPageNext" value="' . JText::_('COM_FABRIK_NEXT') . '" />';
} else {
$form->nextButton = '';
$form->prevButton = '';
}
// $$$ hugh - hide actions section is we're printing, or if not actions selected
$noButtons = empty($form->nextButton) && empty($form->prevButton) && empty($form->submitButton) && empty($form->gobackButton) && empty($form->deleteButton) && empty($form->applyButton) && empty($form->copyButton) && empty($form->resetButton);
if (JRequest::getVar('print', '0') == '1' || $noButtons) {
$this->hasActions = false;
} else {
$this->hasActions = true;
}
$format = $model->isAjax() ? 'raw' : 'html';
$fields[] = '<input type="hidden" name="format" value="' . $format . '" />';
$groups = $model->getGroupsHiarachy();
foreach ($groups as $groupModel) {
$group = $groupModel->getGroup();
$c = $groupModel->repeatTotal;
// Used for validations
$fields[] = '<input type="hidden" name="fabrik_repeat_group[' . $group->id . ']" value="' . $c . '" id="fabrik_repeat_group_' . $group->id . '_counter" />';
}
// $$$ hugh - testing social_profile_hash stuff
if (JRequest::getVar('fabrik_social_profile_hash', '') != '') {
$fields[] = '<input type="hidden" name="fabrik_social_profile_hash" value="' . JRequest::getCmd('fabrik_social_profile_hash', '') . '" id="fabrik_social_profile_hash" />';
}
$this->_cryptQueryString($fields);
$this->_cryptViewOnlyElements($fields);
$this->hiddenFields = implode("\n", $fields);
}
示例13: _replaceWithIcons
/**
* replace labels shown in table view with icons (if found)
* @param string data
* @return string data
*/
function _replaceWithIcons($data)
{
if ($data == '') {
$this->iconsSet = false;
return $data;
}
$params =& $this->getParams();
$folder = $params->get('icon_folder');
if ($folder == -1 || $folder == '') {
$this->iconsSet = false;
return $data;
}
$cleanData = FabrikString::clean($data);
foreach ($this->_imageExtensions as $ex) {
$f = JPath::clean($folder . DS . $cleanData . '.' . $ex);
if (JFile::exists(COM_FABRIK_BASE . DS . $f)) {
$f = COM_FABRIK_LIVESITE . DS . $f;
$f = str_replace(DS, "/", $f);
$this->iconsSet = true;
return "<img src=\"{$f}\" alt=\"{$data}\" title=\"{$data}\" />";
}
}
$this->iconsSet = false;
return $data;
}
示例14: doImport
/**
* now we have the uploaded csv file in the session and the results of what the
* user wants to do with each field, lets process this thing!
* Creates a db table
* Creates fabrik table/form/group/elements as per selected choices
*
*/
function doImport()
{
// Check for request forgeries
JRequest::checkToken() or die('Invalid Token');
$cnn = JModel::getInstance('Connection', 'FabrikModel');
#
$cnnid = JRequest::getInt('connection_id');
$cnn->setId($cnnid);
$db =& $cnn->getDb();
$db_table_name = JRequest::getVar('db_table_name');
$keys = JRequest::getVar('primarykey', array());
$autoinc = JRequest::getVar('autoinc', array());
$fields = JRequest::getVar('field');
JRequest::setVar('elementlabels', JRequest::getVar('label'));
$addkey = JRequest::getInt('addkey');
if ($addkey == 1) {
foreach ($fields as $key => $val) {
$keys[$val][0] = 0;
}
$newkey = 'id';
if (in_array($newkey, $fields)) {
$newkey .= rand(0, 20);
}
$keys[$newkey][0] = 1;
$fields[] = $newkey;
$autoinc[$newkey][0] = 1;
}
// $$$ hugh - testing
// normalize the names
$safe_fields = array();
//$$$rob already normalized in form, but lets do it here as well just in case
foreach ($fields as $key => $val) {
$safe_fields[$key] = FabrikString::clean($val);
}
$pluginManager =& JModel::getInstance('Pluginmanager', 'FabrikModel');
$elementtypes = JRequest::getVar('elementtype', array());
if ($addkey == 1) {
$elementtypes[] = 'fabrikinternalid';
}
$pkey = '';
$query = "CREATE TABLE IF NOT EXISTS `{$db_table_name}` (";
for ($i = 0; $i < count($fields); $i++) {
//sanitize field names
$fields[$i] = strtolower(str_replace(' ', '', $fields[$i]));
$plugin =& $pluginManager->getPlugIn($elementtypes[$i], 'element');
if ($safe_fields[$i] !== '') {
if ($keys[$fields[$i]][0] == 1) {
$inc = $autoinc[$fields[$i]][0];
$k = $fields[$i];
$query .= " " . $db->nameQuote($safe_fields[$i]) . " INT(6) ";
if ($inc == 1) {
$query .= "NOT NULL AUTO_INCREMENT";
}
$pkey = ", PRIMARY KEY ( " . $db->nameQuote($k) . " )";
} else {
$query .= " `{$safe_fields[$i]}` " . $plugin->getFieldDescription() . " NOT NULL";
}
$query .= ",\n";
}
}
// no pkey select so make one
if ($pkey == '') {
$query .= " `id` INT(6) NOT NULL AUTO_INCREMENT";
$pkey = ", PRIMARY KEY ( `id` )";
}
$query = FabrikString::rtrimword($query, ",\n");
$query .= $pkey;
$query .= ");";
$db->setQuery($query);
if (!$db->query()) {
return JError::raiseWarning(500, $db->getErrorMsg());
}
$user =& JFactory::getUser();
$tableModel =& $this->getModel('Table');
//set up some default data for the table to use when saving itself
JRequest::setVar('id', 0);
JRequest::setVar('state', 1);
JRequest::setVar('filter_action', 'onchange');
JRequest::setVar('created_by', $user->get('id'));
JRequest::setVar('created_by_alias', $user->get('username'));
JRequest::setVar('label', JRequest::getVar('db_table_label'));
JRequest::setVar('attribs', $tableModel->getDefaultAttribs());
$tableModel->save();
//insert the date
$session =& JFactory::getSession();
$csvdata = $session->get('com_fabrik.csvdata');
foreach ($csvdata as $data) {
$aRow = array();
for ($i = 0; $i < count($data); $i++) {
//$$$rob if there is a trailing comma in the CSV line a blank piece of data could be
//added causing an error/warning
if (array_key_exists($i, $fields)) {
$aRow[$fields[$i]] = $data[$i];
//.........这里部分代码省略.........
示例15: replaceWithIcons
/**
* Replace labels shown in list view with icons (if found)
*
* @param string $data Data
* @param string $view List/details
* @param string $tmpl Template
*
* @since 3.0 - icon_folder is a bool - search through template folders for icons
*
* @return string data
*/
protected function replaceWithIcons($data, $view = 'list', $tmpl = null)
{
if ($data == '') {
$this->iconsSet = false;
return $data;
}
$params = $this->getParams();
$listModel = $this->getListModel();
$iconFile = (string) $params->get('icon_file', '');
if ((int) $params->get('icon_folder', 0) === 0 && $iconFile === '') {
$this->iconsSet = false;
return $data;
}
if (in_array($listModel->getOutPutFormat(), array('csv', 'rss'))) {
$this->iconsSet = false;
return $data;
}
$cleanData = empty($iconFile) ? FabrikString::clean(strip_tags($data)) : $iconFile;
$cleanDatas = array($this->getElement()->name . '_' . $cleanData, $cleanData);
$opts = array('forceImage' => true);
foreach ($cleanDatas as $cleanData) {
foreach ($this->imageExtensions as $ex) {
$f = JPath::clean($cleanData . '.' . $ex);
$img = FabrikHelperHTML::image($cleanData . '.' . $ex, $view, $tmpl, array(), false, $opts);
if ($img !== '') {
$this->iconsSet = true;
$opts = new stdClass();
$opts->position = 'top';
$opts = json_encode($opts);
$data = '<span>' . $data . '</span>';
// See if data has an <a> tag
if (class_exists('DOMDocument')) {
$html = new DOMDocument();
$html->loadXML($data);
$as = $html->getElementsBytagName('a');
}
if ($params->get('icon_hovertext', true)) {
$ahref = '#';
$target = '';
if (class_exists('DOMDocument') && $as->length) {
// Data already has an <a href="foo"> lets get that for use in hover text
$a = $as->item(0);
$ahref = $a->getAttribute('href');
$target = $a->getAttribute('target');
$target = 'target="' . $target . '"';
}
$data = htmlspecialchars($data, ENT_QUOTES);
$img = '<a class="fabrikTip" ' . $target . ' href="' . $ahref . '" opts=\'' . $opts . '\' title="' . $data . '">' . $img . '</a>';
} elseif (!empty($iconFile)) {
/**
* $$$ hugh - kind of a hack, but ... if this is an upload element, it may already be a link, and
* we'll need to replace the text in the link with the image
* After ages dicking around with a regex to do this, decided to use DOMDocument instead!
*/
if (class_exists('DOMDocument') && $as->length) {
$img = $html->createElement('img');
$img->setAttribute('src', FabrikHelperHTML::image($cleanData . '.' . $ex, $view, $tmpl, array(), true));
$as->item(0)->nodeValue = '';
$as->item(0)->appendChild($img);
return $html->saveHTML();
}
}
return $img;
}
}
}
return $data;
}