本文整理汇总了PHP中JForm::bind方法的典型用法代码示例。如果您正苦于以下问题:PHP JForm::bind方法的具体用法?PHP JForm::bind怎么用?PHP JForm::bind使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JForm
的用法示例。
在下文中一共展示了JForm::bind方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: display
/**
* Display the view
*
* @param string $tpl template
*
* @return void
*/
public function display($tpl = null)
{
// Initialiase variables.
$model = $this->getModel();
$this->item = $this->get('Item');
$model->checkDefault($this->item);
$this->form = $this->get('Form');
$this->form->bind($this->item);
$this->state = $this->get('State');
// Check for errors.
if (count($errors = $this->get('Errors'))) {
JError::raiseError(500, implode("\n", $errors));
return false;
}
$this->addToolbar();
parent::display($tpl);
}
示例2: getAssignments
/**
* Function that gets the config settings
*
* @return Object
*/
protected function getAssignments()
{
if (!isset($this->assignments)) {
$xmlfile = JPATH_ADMINISTRATOR . '/components/com_advancedmodules/assignments.xml';
$assignments = new JForm('assignments', array('control' => 'advancedparams'));
$assignments->loadFile($xmlfile, 1, '//config');
$assignments->bind($this->item->advancedparams);
$this->assignments = $assignments;
}
return $this->assignments;
}
示例3: display
/**
* Display the view
*
* @param string $tpl template
*
* @return void
*/
public function display($tpl = null)
{
// Initialiase variables.
$model = $this->getModel();
$this->item = $this->get('Item');
$model->checkDefault($this->item);
$this->form = $this->get('Form');
$this->form->bind($this->item);
$this->state = $this->get('State');
// Check for errors.
if (count($errors = $this->get('Errors'))) {
throw new RuntimeException(implode("\n", $errors), 500);
}
$this->addToolbar();
FabrikAdminHelper::setViewLayout($this);
$srcs = FabrikHelperHTML::framework();
$srcs[] = 'media/com_fabrik/js/fabrik.js';
FabrikHelperHTML::iniRequireJS();
FabrikHelperHTML::script($srcs);
parent::display($tpl);
}
示例4: displayTask
/**
* Display configurations for registration
*
* @return void
*/
public function displayTask()
{
$config = new \JForm('com_members.registration');
$config->loadFile(dirname(dirname(__DIR__)) . DS . 'config' . DS . 'config.xml', true, '/config');
$config->bind($this->config->toArray());
$this->config = $config;
$this->view->params = $config->getFieldset('registration');
// Set any errors
if ($this->getError()) {
$this->view->setError($this->getError());
}
// Output the HTML
$this->view->display();
}
示例5: edit
/**
* This function displays the newsletter form on the user profile
*
* @param JForm $form - the user form
* @param array $data - the user data
*
* @return bool
*/
public function edit($form, $data)
{
$appl = JFactory::getApplication();
$subscriptionData = CmcHelperUsers::getSubscription($data->email, $this->params->get('listid'));
$renderer = CmcHelperXmlbuilder::getInstance($this->params);
// Render Content
$html = $renderer->build();
if ($appl->isSite()) {
CompojoomHtmlBehavior::jquery();
JHtml::script('media/plg_user_cmc/js/cmc.js');
}
// Inject fields into the form
$form->load($html, false);
if ($subscriptionData) {
$form->setFieldAttribute('newsletter', 'checked', 'checked', 'cmc');
$form->bind(CmcHelperSubscription::convertMergesToFormData($subscriptionData->merges));
}
}
示例6: onMageBridgeProductPrepareForm
/**
* Method to manipulate the MageBridge Product Relation backend-form
*
* @param JForm $form The form to be altered
* @param JForm $data The associated data for the form
* @return boolean
*/
public function onMageBridgeProductPrepareForm($form, $data)
{
// Check if this plugin can be used
if ($this->isEnabled() == false) {
return false;
}
// Add the plugin-form to main form
$formFile = JPATH_SITE . '/plugins/magebridgeproduct/' . $this->_name . '/form/form.xml';
if (file_exists($formFile)) {
$form->loadFile($formFile, false);
}
// Load the original values from the deprecated connector-architecture
if (!empty($this->connector_field)) {
$pluginName = $this->_name;
if (!empty($data['connector']) && !empty($data['connector_value']) && $pluginName == $data['connector']) {
$form->bind(array('actions' => array($this->connector_field => $data['connector_value'])));
}
}
}
示例7: preprocessForm
/**
* Method to allow derived classes to preprocess the form.
*
* @param JForm $form A JForm object.
* @param mixed $data The data expected for the form.
* @param string $group The name of the plugin group to import (defaults to "content").
*
* @return void
*
* @see JFormField
* @since 11.1
* @throws Exception if there is an error in the form event.
*/
protected function preprocessForm(JForm $form, $data, $group = 'content')
{
if (!$data) {
parent::preprocessForm($form, $data, $group);
return;
}
$blogXML = JPATH_ROOT . '/components/com_content/views/category/tmpl/blog.xml';
$listXML = JPATH_ROOT . '/components/com_content/views/category/tmpl/default.xml';
$articleXML = JPATH_ROOT . '/components/com_content/views/article/tmpl/default.xml';
$menuXML = JPATH_BASE . '/components/com_menus/models/forms/item_component.xml';
// set list params
$listParams = simplexml_load_file($listXML);
$listParams->fields[1]['name'] = 'list';
// set blog params
$blogParams = simplexml_load_file($blogXML);
$blogParams->fields[1]['name'] = 'blog';
// set article params
$articleParams = simplexml_load_file($articleXML);
$articleParams->fields[1]['name'] = 'article';
// create Form
$this->listForm = JForm::getInstance('list', $listParams->asXML(), array('control' => 'jform'), true, '/metadata');
$this->blogForm = JForm::getInstance('blog', $blogParams->asXML(), array('control' => 'jform'), true, '/metadata');
$this->articleForm = JForm::getInstance('article', $articleParams->asXML(), array('control' => 'jform'), true, '/metadata');
// set menu xml
$menuParams = simplexml_load_file($menuXML);
$menuParams->fields[0]['name'] = 'list';
$this->listForm->load($menuParams->asXML(), true, '/form');
$menuParams->fields[0]['name'] = 'blog';
$this->blogForm->load($menuParams->asXML(), true, '/form');
$menuParams->fields[0]['name'] = 'article';
$this->articleForm->load($menuParams->asXML(), true, '/form');
// bind data
$data->list = json_decode($data->list);
$data->blog = json_decode($data->blog);
$data->article = json_decode($data->article);
$this->listForm->bind($data);
$this->blogForm->bind($data);
$this->articleForm->bind($data);
parent::preprocessForm($form, $data, $group);
}
示例8: getContactQuery
//.........这里部分代码省略.........
$case_when1 = ' CASE WHEN ';
$case_when1 .= $query->charLength('cc.alias');
$case_when1 .= ' THEN ';
$c_id = $query->castAsChar('cc.id');
$case_when1 .= $query->concatenate(array($c_id, 'cc.alias'), ':');
$case_when1 .= ' ELSE ';
$case_when1 .= $c_id . ' END as catslug';
$query->select('a.*, cc.access as category_access, cc.title as category_name, ' . $case_when . ',' . $case_when1);
$query->from('#__contact_details AS a');
$query->join('INNER', '#__categories AS cc on cc.id = a.catid');
$query->where('a.id = ' . (int) $pk);
$published = $this->getState('filter.published');
$archived = $this->getState('filter.archived');
if (is_numeric($published)) {
$query->where('a.published IN (1,2)');
$query->where('cc.published IN (1,2)');
}
$groups = implode(',', $user->getAuthorisedViewLevels());
$query->where('a.access IN (' . $groups . ')');
try {
$db->setQuery($query);
$result = $db->loadObject();
if ($error = $db->getErrorMsg()) {
throw new Exception($error);
}
if (empty($result)) {
throw new JException(JText::_('COM_CONTACT_ERROR_CONTACT_NOT_FOUND'), 404);
}
// If we are showing a contact list, then the contact parameters take priority
// So merge the contact parameters with the merged parameters
if ($this->getState('params')->get('show_contact_list')) {
$registry = new JRegistry();
$registry->loadString($result->params);
$this->getState('params')->merge($registry);
}
} catch (Exception $e) {
$this->setError($e);
return false;
}
if ($result) {
$user = JFactory::getUser();
$groups = implode(',', $user->getAuthorisedViewLevels());
//get the content by the linked user
$query = $db->getQuery(true);
$query->select('a.id');
$query->select('a.title');
$query->select('a.state');
$query->select('a.access');
$query->select('a.created');
// SQL Server changes
$case_when = ' CASE WHEN ';
$case_when .= $query->charLength('a.alias');
$case_when .= ' THEN ';
$a_id = $query->castAsChar('a.id');
$case_when .= $query->concatenate(array($a_id, 'a.alias'), ':');
$case_when .= ' ELSE ';
$case_when .= $a_id . ' END as slug';
$case_when1 = ' CASE WHEN ';
$case_when1 .= $query->charLength('c.alias');
$case_when1 .= ' THEN ';
$c_id = $query->castAsChar('c.id');
$case_when1 .= $query->concatenate(array($c_id, 'c.alias'), ':');
$case_when1 .= ' ELSE ';
$case_when1 .= $c_id . ' END as catslug';
$query->select($case_when1 . ',' . $case_when);
$query->from('#__content as a');
$query->leftJoin('#__categories as c on a.catid=c.id');
$query->where('a.created_by = ' . (int) $result->user_id);
$query->where('a.access IN (' . $groups . ')');
$query->order('a.state DESC, a.created DESC');
// filter per language if plugin published
if (JLanguageMultilang::isEnabled()) {
$query->where('a.created_by = ' . (int) $result->user_id . ' AND ' . ('a.language=' . $db->quote(JFactory::getLanguage()->getTag()) . ' OR a.language=' . $db->quote('*')));
}
if (is_numeric($published)) {
$query->where('a.state IN (1,2)');
}
$db->setQuery($query, 0, 10);
$articles = $db->loadObjectList();
$result->articles = $articles;
//get the profile information for the linked user
require_once JPATH_ADMINISTRATOR . '/components/com_users/models/user.php';
$userModel = JModelLegacy::getInstance('User', 'UsersModel', array('ignore_request' => true));
$data = $userModel->getItem((int) $result->user_id);
JPluginHelper::importPlugin('user');
$form = new JForm('com_users.profile');
// Get the dispatcher.
$dispatcher = JDispatcher::getInstance();
// Trigger the form preparation event.
$dispatcher->trigger('onContentPrepareForm', array($form, $data));
// Trigger the data preparation event.
$dispatcher->trigger('onContentPrepareData', array('com_users.profile', $data));
// Load the data into the form after the plugins have operated.
$form->bind($data);
$result->profile = $form;
$this->contact = $result;
return $result;
}
}
}
示例9: render
function render()
{
$config = JComponentHelper::getParams(WBADVERT_NAME);
$form = new JForm('jform');
$form->loadFile(WBADVERT_PATH . 'config.xml', false, '//config');
$form->bind($config->toArray());
$fieldSets = $form->getFieldsets();
$html[] = '<div class="control-fieldset">';
foreach ($form->getFieldset('component') as $field) {
$field->name = 'params[' . $field->name . ']';
$html[] = $field->renderField();
}
$html[] = '</div>';
return implode(PHP_EOL, $html);
}
示例10: top
/**
* Render the initial plugin options, such as the plugin selector, and whether its rendered in front/back/both etc
*
* @return string
*/
public function top()
{
$data = $this->getData();
$c = $this->getState('c') + 1;
$str = array();
$str[] = '<div class="pane-slider content pane-down">';
$str[] = '<fieldset class="adminform pluginContanier" id="formAction_' . $c . '"><ul>';
$formName = 'com_fabrik.' . $this->getState('type') . '-plugin';
$topForm = new JForm($formName, array('control' => 'jform'));
$topForm->repeatCounter = $c;
$xmlFile = JPATH_SITE . '/administrator/components/com_fabrik/models/forms/' . $this->getState('type') . '-plugin.xml';
// Add the plugin specific fields to the form.
$topForm->loadFile($xmlFile, false);
$topForm->bind($data);
// Filer the forms fieldsets for those starting with the correct $serachName prefix
foreach ($topForm->getFieldsets() as $fieldset) {
if ($fieldset->label != '') {
$str[] = '<legend>' . $fieldset->label . '</legend>';
}
foreach ($topForm->getFieldset($fieldset->name) as $field) {
$str[] = '<li>' . $field->label . $field->input . '</li>';
}
}
$str[] = '</ul>';
$str[] = '<div class="pluginOpts" style="clear:left"></div>';
$str[] = '<a href="#" class="delete removeButton">' . JText::_('COM_FABRIK_DELETE') . '</a>';
$str[] = '</fieldset>';
$str[] = '</div>';
return implode("\n", $str);
}
示例11: getContactQuery
//.........这里部分代码省略.........
$case_when .= ' THEN ';
$a_id = $query->castAsChar('a.id');
$case_when .= $query->concatenate(array($a_id, 'a.alias'), ':');
$case_when .= ' ELSE ';
$case_when .= $a_id . ' END as slug';
$case_when1 = ' CASE WHEN ';
$case_when1 .= $query->charLength('cc.alias', '!=', '0');
$case_when1 .= ' THEN ';
$c_id = $query->castAsChar('cc.id');
$case_when1 .= $query->concatenate(array($c_id, 'cc.alias'), ':');
$case_when1 .= ' ELSE ';
$case_when1 .= $c_id . ' END as catslug';
$query->select('a.*, cc.access as category_access, cc.title as category_name, ' . $case_when . ',' . $case_when1)->from('#__contact_details AS a')->join('INNER', '#__categories AS cc on cc.id = a.catid')->where('a.id = ' . (int) $pk);
$published = $this->getState('filter.published');
if (is_numeric($published)) {
$query->where('a.published IN (1,2)')->where('cc.published IN (1,2)');
}
$groups = implode(',', $user->getAuthorisedViewLevels());
$query->where('a.access IN (' . $groups . ')');
try {
$db->setQuery($query);
$result = $db->loadObject();
if (empty($result)) {
return false;
}
} catch (Exception $e) {
$this->setError($e->getMessage());
return false;
}
if ($result) {
$contactParams = new Registry();
$contactParams->loadString($result->params);
// If we are showing a contact list, then the contact parameters take priority
// So merge the contact parameters with the merged parameters
if ($this->getState('params')->get('show_contact_list')) {
$this->getState('params')->merge($contactParams);
}
// Get the com_content articles by the linked user
if ((int) $result->user_id && $this->getState('params')->get('show_articles')) {
$query = $db->getQuery(true)->select('a.id')->select('a.title')->select('a.state')->select('a.access')->select('a.catid')->select('a.created')->select('a.language');
// SQL Server changes
$case_when = ' CASE WHEN ';
$case_when .= $query->charLength('a.alias', '!=', '0');
$case_when .= ' THEN ';
$a_id = $query->castAsChar('a.id');
$case_when .= $query->concatenate(array($a_id, 'a.alias'), ':');
$case_when .= ' ELSE ';
$case_when .= $a_id . ' END as slug';
$case_when1 = ' CASE WHEN ';
$case_when1 .= $query->charLength('c.alias', '!=', '0');
$case_when1 .= ' THEN ';
$c_id = $query->castAsChar('c.id');
$case_when1 .= $query->concatenate(array($c_id, 'c.alias'), ':');
$case_when1 .= ' ELSE ';
$case_when1 .= $c_id . ' END as catslug';
$query->select($case_when1 . ',' . $case_when)->from('#__content as a')->join('LEFT', '#__categories as c on a.catid=c.id')->where('a.created_by = ' . (int) $result->user_id)->where('a.access IN (' . $groups . ')')->order('a.state DESC, a.created DESC');
// Filter per language if plugin published
if (JLanguageMultilang::isEnabled()) {
$query->where('a.created_by = ' . (int) $result->user_id . ' AND ' . ('a.language=' . $db->quote(JFactory::getLanguage()->getTag()) . ' OR a.language=' . $db->quote('*')));
}
if (is_numeric($published)) {
$query->where('a.state IN (1,2)')->where('(a.publish_up = ' . $nullDate . ' OR a.publish_up <= ' . $nowDate . ')')->where('(a.publish_down = ' . $nullDate . ' OR a.publish_down >= ' . $nowDate . ')');
}
// Number of articles to display from config/menu params
$articles_display_num = $this->getState('params')->get('articles_display_num', 10);
// Use contact setting?
if ($articles_display_num === 'use_contact') {
$articles_display_num = $contactParams->get('articles_display_num', 10);
// Use global?
if ((string) $articles_display_num === '') {
$articles_display_num = JComponentHelper::getParams('com_contact')->get('articles_display_num', 10);
}
}
$db->setQuery($query, 0, (int) $articles_display_num);
$articles = $db->loadObjectList();
$result->articles = $articles;
} else {
$result->articles = null;
}
// Get the profile information for the linked user
require_once JPATH_ADMINISTRATOR . '/components/com_users/models/user.php';
$userModel = JModelLegacy::getInstance('User', 'UsersModel', array('ignore_request' => true));
$data = $userModel->getItem((int) $result->user_id);
JPluginHelper::importPlugin('user');
$form = new JForm('com_users.profile');
// Get the dispatcher.
$dispatcher = JEventDispatcher::getInstance();
// Trigger the form preparation event.
$dispatcher->trigger('onContentPrepareForm', array($form, $data));
// Trigger the data preparation event.
$dispatcher->trigger('onContentPrepareData', array('com_users.profile', $data));
// Load the data into the form after the plugins have operated.
$form->bind($data);
$result->profile = $form;
$this->contact = $result;
return $result;
}
}
return false;
}
示例12: getContactQuery
protected function getContactQuery($pk = null)
{
// TODO: Cache on the fingerprint of the arguments
$db = $this->getDbo();
$user = JFactory::getUser();
$pk = !empty($pk) ? $pk : (int) $this->getState('contact.id');
$query = $db->getQuery(true);
if ($pk) {
$query->select('a.*, cc.access as category_access, cc.title as category_name, ' . ' CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(\':\', a.id, a.alias) ELSE a.id END as slug, ' . ' CASE WHEN CHAR_LENGTH(cc.alias) THEN CONCAT_WS(\':\', cc.id, cc.alias) ELSE cc.id END AS catslug ');
$query->from('#__contact_details AS a');
$query->join('INNER', '#__categories AS cc on cc.id = a.catid');
$query->where('a.id = ' . (int) $pk);
$published = $this->getState('filter.published');
$archived = $this->getState('filter.archived');
if (is_numeric($published)) {
$query->where('a.published IN (1,2)');
$query->where('cc.published IN (1,2)');
}
$groups = implode(',', $user->getAuthorisedViewLevels());
$query->where('a.access IN (' . $groups . ')');
try {
$db->setQuery($query);
$result = $db->loadObject();
if ($error = $db->getErrorMsg()) {
throw new Exception($error);
}
if (empty($result)) {
throw new JException(JText::_('COM_CONTACT_ERROR_CONTACT_NOT_FOUND'), 404);
}
// If we are showing a contact list, then the contact parameters take priority
// So merge the contact parameters with the merged parameters
if ($this->getState('params')->get('show_contact_list')) {
$registry = new JRegistry();
$registry->loadJSON($result->params);
$this->getState('params')->merge($registry);
}
} catch (Exception $e) {
$this->setError($e);
return false;
}
if ($result) {
$user = JFactory::getUser();
$groups = implode(',', $user->getAuthorisedViewLevels());
//get the content by the linked user
$query = $db->getQuery(true);
$query->select('id, title, state, access, created');
$query->from('#__content');
$query->where('created_by = ' . (int) $result->user_id);
$query->where('access IN (' . $groups . ')');
$query->order('state DESC, created DESC');
if (is_numeric($published)) {
$query->where('state IN (1,2)');
}
$db->setQuery($query, 0, 10);
$articles = $db->loadObjectList();
$result->articles = $articles;
//get the profile information for the linked user
if ($result) {
require_once JPATH_ADMINISTRATOR . '/components/com_users/models/user.php';
$userModel = JModel::getInstance('User', 'UsersModel', array('ignore_request' => true));
$data = $userModel->getItem((int) $result->user_id);
JPluginHelper::importPlugin('user');
$form = new JForm('com_users.profile');
// Get the dispatcher.
$dispatcher = JDispatcher::getInstance();
// Trigger the form preparation event.
$dispatcher->trigger('onContentPrepareForm', array($form, $data));
// Trigger the data preparation event.
$dispatcher->trigger('onContentPrepareData', array('com_users.profile', $data));
// Load the data into the form after the plugins have operated.
$form->bind($data);
$result->profile = $form;
}
$this->contact = $result;
return $result;
}
}
}
示例13: bindFormData
/**
* Method to inject data into the form.
*
* @param JForm $form Form headers without data.
*
* @return void
*
* @since 2.0
*/
protected function bindFormData($form)
{
// Check the session for previously entered form data.
$data = JFactory::getApplication()->getUserState('com_shconfig.edit.settings.data', array());
if (empty($data)) {
// We need to get the items from the database
$db = $this->getDbo();
$query = $db->getQuery(true);
// Select the required fields from the table.
$query->select($db->quoteName('name'))->select($db->quoteName('value'))->from($db->quoteName('#__sh_config'));
// Build the where clause for specifying only required settings from the table
$whereClause = array();
foreach ($form->getFieldset() as $field) {
$whereClause[] = $db->quoteName('name') . ' = ' . $db->quote($field->fieldname);
}
$query->where($whereClause, 'OR');
$data = $db->setQuery($query)->loadAssocList('name', 'value');
}
$form->bind($data);
}
示例14: JForm
<?php
JHtml::_('behavior.formvalidation');
JHtml::_('behavior.keepalive');
JHtml::_('formbehavior.chosen', 'select');
jimport('joomla.form.form');
$session = JFactory::getSession();
$modid = $module->id;
$defaultparams = JPath::clean(JPATH_ADMINISTRATOR . '/modules/mod_quickpublish/form/comcontent.xml');
$data = '';
if (JFile::exists($defaultparams)) {
JForm::addFormPath(JPath::clean(JPATH_ADMINISTRATOR . '/modules/mod_quickpublish/form'));
$form = new JForm('quickpublishcomponents');
$form->loadFile('comcontent', false);
$form->bind($data);
$fieldSets = $form->getFieldsets('quickpublishcomponents');
foreach ($fieldSets as $name => $fieldSet) {
//var_dump($name);
?>
<div class="row-fluid">
<div class="span12">
<form id="modquickpublish<?php
echo $name;
?>
" name="modquickpublish<?php
echo $name;
?>
" action="index.php">
<?php
示例15: RenderAMM
$juri_base = preg_replace("/administrator\$/", "", JURI::base(true));
RokCommon_Header::addStyle($juri_base . 'components/com_roksprocket/lib/RokSprocket/Addon/AdvancedModuleManager/assets/styles/amm-fixes.css');
$renderer = new RenderAMM();
$renderer->item = $that->item;
$renderer->form = $that->form;
if (!isset($renderer->config)) {
require_once JPATH_PLUGINS . '/system/nnframework/helpers/parameters.php';
$parameters = NNParameters::getInstance();
$config = JComponentHelper::getParams('com_advancedmodules');
$renderer->config = $parameters->getParams($config->toObject(), JPATH_ADMINISTRATOR . '/components/com_advancedmodules/config.xml');
}
if (!isset($renderer->assignments)) {
$xmlfile = JPATH_ADMINISTRATOR . '/components/com_advancedmodules/assignments.xml';
$assignments = new JForm('assignments', array('control' => 'advancedparams'));
$assignments->loadFile($xmlfile, 1, '//config');
$assignments->bind($renderer->item->advancedparams);
$renderer->assignments = $assignments;
}
if ($renderer->config->show_color) {
$colors = explode(',', $renderer->config->main_colors);
foreach ($colors as $i => $c) {
$colors[$i] = strtoupper('#' . preg_replace('#[^a-z0-9]#i', '', $c));
}
$script = "\n\t\tmainColors = new Array( '" . implode("', '", $colors) . "' );";
RokCommon_Header::addInlineScript($script);
}
?>
<fieldset class="adminform">
<div class="advanced-module-manager">
<!-- opening divs twice for fixing joomla accordions -->
<?php