本文整理汇总了PHP中JForm::getFieldset方法的典型用法代码示例。如果您正苦于以下问题:PHP JForm::getFieldset方法的具体用法?PHP JForm::getFieldset怎么用?PHP JForm::getFieldset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JForm
的用法示例。
在下文中一共展示了JForm::getFieldset方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getInput
/**
* Method to get the field input markup.
*
* @return string The field input markup.
*
* @since 3.2
*/
protected function getInput()
{
// Initialize variables.
$subForm = new JForm($this->name, array('control' => 'jform'));
$xml = $this->element->children()->asXML();
$subForm->load($xml);
// Needed for repeating modals in gmaps
$subForm->repeatCounter = (int) @$this->form->repeatCounter;
$children = $this->element->children();
$subForm->setFields($children);
$modalid = $this->id . '_modal';
$str = array();
$str[] = '<div id="' . $modalid . '" style="display:none">';
$str[] = '<table id="' . $modalid . '_table" class="adminlist ' . $this->element['class'] . ' table table-striped">';
$str[] = '<thead><tr>';
$names = array();
$attributes = $this->element->attributes();
foreach ($subForm->getFieldset($attributes->name . '_modal') as $field) {
$names[] = (string) $field->element->attributes()->name;
$str[] = '<th>' . strip_tags($field->getLabel($field->name));
$str[] = '<br /><small style="font-weight:normal">' . JText::_($field->description) . '</small>';
$str[] = '</th>';
}
$str[] = '<th><a href="#" class="add btn button btn-success"><span class="fa fa-plus"></span> </a></th>';
$str[] = '</tr></thead>';
$str[] = '<tbody><tr>';
foreach ($subForm->getFieldset($attributes->name . '_modal') as $field) {
$str[] = '<td>' . $field->getInput() . '</td>';
}
$str[] = '<td>';
$str[] = '<div class="btn-group"><a class="add btn button btn-success"><span class="fa fa-plus"></span> </a>';
$str[] = '<a class="remove btn button btn-danger"><span class="fa fa-minus"></span> </a></div>';
$str[] = '</td>';
$str[] = '</tr></tbody>';
$str[] = '</table>';
$str[] = '</div>';
$names = json_encode($names);
JHtml::_('script', 'system/repeatable.js', true, true);
// If a maximum value isn't set then we'll make the maximum amount of cells a large number
$maximum = $this->element['maximum'] ? (int) $this->element['maximum'] : '999';
$script = "(function (\$){\r\n\t\t\t\$(document).ready(function (){\r\n\t\t\t\tvar repeatable = new \$.JRepeatable('{$modalid}', {$names}, '{$this->id}', '{$maximum}');\r\n\t\t\t});\r\n\t\t})(jQuery);";
$document = JFactory::getDocument();
$document->addScriptDeclaration($script);
$select = (string) $this->element['select'] ? JText::_((string) $this->element['select']) : JText::_('JLIB_FORM_BUTTON_SELECT');
$icon = $this->element['icon'] ? '<i class="icon-' . $this->element['icon'] . '"></i> ' : '';
$str[] = '<button class="btn" id="' . $modalid . '_button" data-modal="' . $modalid . '">' . $icon . $select . '</button>';
if (is_array($this->value)) {
$this->value = array_shift($this->value);
}
$value = htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8');
$str[] = '<input type="hidden" name="' . $this->name . '" id="' . $this->id . '" value="' . $value . '" />';
JText::script('JAPPLY');
JText::script('JCANCEL');
return implode("\n", $str);
}
示例2: getInput
protected function getInput()
{
$end = $this->element['end'];
$styles = $this->element['styles'];
$background = $this->element['background'] ? 'background-image: url(' . $this->getPathToImages() . '/images/' . $this->element['background'] . ');' : '';
$tag = $this->element['tag'];
if ($end == '1') {
// $html = '</li></'.$tag.'><li>';
$html = '</' . $tag . '><div><div>';
} else {
// $html = '</li><'.$tag.' style="'.$background.$styles.'" ><li>';
$html = '</div></div><' . $tag . ' style="' . $background . $styles . '" >';
}
// var_dump($html);
$identifier = 'menustyles';
$form = new JForm($identifier);
JForm::addFormPath(JPATH_SITE . '/modules/mod_slideshowck/elements/test');
if (!($formexists = $form->loadFile($identifier, false))) {
echo '<p style="color:red">' . JText::_('Problem loading the file : ' . $identifier . '.xml') . '</p>';
return '';
}
$fields = $form->getFieldset();
foreach ($fields as $key => $field) {
// echo '<div class="ckpopup_row">';
$html .= $form->getLabel(str_replace($identifier . "_", "", $key), $identifier);
$html .= $form->getInput(str_replace($identifier . "_", "", $key), $identifier);
// echo '</div>';
}
return $html;
}
示例3: onContentPrepareForm
/**
*
* Enter description here ...
* @param JForm $form
* @param unknown $data
*/
function onContentPrepareForm($form, $data)
{
$app = JFactory::getApplication();
$doc = JFactory::getDocument();
$this->template = $this->getTemplateName();
if ($this->template && ($app->isAdmin() && $form->getName() == 'com_templates.style' || $app->isSite() && ($form->getName() == 'com_config.templates' || $form->getName() == 'com_templates.style'))) {
jimport('joomla.filesystem.path');
//JForm::addFormPath( dirname(__FILE__) . DS. 'includes' . DS .'assets' . DS . 'admin' . DS . 'params');
$plg_file = JPath::find(dirname(__FILE__) . DS . 'includes' . DS . 'assets' . DS . 'admin' . DS . 'params', 'template.xml');
$tpl_file = JPath::find(JPATH_ROOT . DS . 'templates' . DS . $this->template, 'templateDetails.xml');
if (!$plg_file) {
return false;
}
if ($tpl_file) {
$form->loadFile($plg_file, false, '//form');
$form->loadFile($tpl_file, false, '//config');
} else {
$form->loadFile($plg_file, false, '//form');
}
if ($app->isSite()) {
$jmstorage_fields = $form->getFieldset('jmstorage');
foreach ($jmstorage_fields as $name => $field) {
$form->removeField($name, 'params');
}
$form->removeField('config', 'params');
}
if ($app->isAdmin()) {
$doc->addStyleDeclaration('#jm-ef3plugin-info, .jm-row > .jm-notice {display: none !important;}');
}
}
}
示例4: onContentPrepareForm
/**
* adds additional fields to the user editing form
*
* @param JForm $form The form to be altered.
* @param mixed $data The associated data for the form.
*
* @return boolean
*
* @since 1.6
*/
public function onContentPrepareForm($form, $data)
{
$version = new JVersion();
if (!$version->isCompatible('3.4')) {
return true;
}
if (!$form instanceof JForm) {
$this->_subject->setError('JERROR_NOT_A_FORM');
return false;
}
$params = JComponentHelper::getParams('com_jce');
if ((bool) $params->get('replace_media_manager', 1) === false) {
return;
}
// get form name.
$name = $form->getName();
$valid = array('com_akrecipes.recipe', 'com_categories.categorycom_akrecipes', 'com_akrecipes.ingredient', 'com_akrecipes.brand', 'com_akrecipes.cuisine', 'com_akrecipes.brand', 'com_akrecipes.product');
// only allow some forms, see - https://github.com/joomla/joomla-cms/pull/8657
if (!in_array($name, $valid)) {
return true;
}
$config = JFactory::getConfig();
$user = JFactory::getUser();
if ($user->getParam('editor', $config->get('editor')) !== "jce") {
return true;
}
if (!JPluginHelper::getPlugin('editors', 'jce')) {
return true;
}
$hasMedia = false;
$fields = $form->getFieldset();
foreach ($fields as $field) {
$type = $field->getAttribute('type');
if (strtolower($type) === "media") {
// get filter value for field, eg: images, media, files
$filter = $field->getAttribute('filter', 'images');
// get file browser link
$link = $this->getLink($filter);
// link not available for environment
if (empty($link)) {
continue;
}
$name = $field->getAttribute('name');
$group = (string) $field->group;
$form->setFieldAttribute($name, 'link', $link, $group);
$form->setFieldAttribute($name, 'class', 'input-large wf-media-input', $group);
$hasMedia = true;
}
}
if ($hasMedia) {
// Include jQuery
JHtml::_('jquery.framework');
$document = JFactory::getDocument();
$document->addScriptDeclaration('jQuery(document).ready(function($){$(".wf-media-input").removeAttr("readonly");});');
}
return true;
}
示例5: 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();
}
示例6: onContentPrepareForm
/**
* adds additional fields to the user editing form
*
* @param JForm $form The form to be altered.
* @param mixed $data The associated data for the form.
*
* @return boolean
*
* @since 1.6
*/
public function onContentPrepareForm($form, $data)
{
$version = new JVersion();
if (!$version->isCompatible('3.4')) {
return true;
}
if (!$form instanceof JForm) {
$this->_subject->setError('JERROR_NOT_A_FORM');
return false;
}
// get form name.
$name = $form->getName();
$valid = array('com_content.article', 'com_categories.categorycom_content', 'com_templates.style', 'com_tags.tag', 'com_banners.banner', 'com_contact.contact', 'com_newsfeeds.newsfeed');
// only allow some forms :(
if (!in_array($name, $valid)) {
return true;
}
$config = JFactory::getConfig();
$user = JFactory::getUser();
if ($user->getParam('editor', $config->get('editor')) !== "jce") {
return true;
}
if (!JPluginHelper::getPlugin('editors', 'jce')) {
return true;
}
$link = $this->getLink();
$hasMedia = false;
if ($link) {
$fields = $form->getFieldset();
foreach ($fields as $field) {
$type = $field->getAttribute('type');
if (strtolower($type) === "media") {
$name = $field->getAttribute('name');
$group = (string) $field->group;
$form->setFieldAttribute($name, 'link', $link, $group);
$form->setFieldAttribute($name, 'class', 'input-large wf-media-input', $group);
$hasMedia = true;
}
}
if ($hasMedia) {
// Include jQuery
JHtml::_('jquery.framework');
$document = JFactory::getDocument();
$document->addScriptDeclaration('jQuery(document).ready(function($){$(".wf-media-input").removeAttr("readonly");});');
}
}
return true;
}
示例7: getControlsFromForm
/**
*
* get controls array from form
* get all groups on the way
* @param JForm $form
*/
private static function getControlsFromForm(JForm $form)
{
$fieldsets = $form->getFieldsets();
self::$arrGroupsAssoc = array();
$arrControls = array();
foreach ($fieldsets as $key => $fieldsetObj) {
$fieldset = $form->getFieldset($key);
foreach ($fieldset as $fieldName => $field) {
$group = (string) $field->group;
if (!empty($group)) {
self::$arrGroupsAssoc[$field->group] = "";
}
if ($field->type == "control") {
//get controls array from the control (can be multiple children)
$controls = $field->getControlFields();
foreach ($controls as $control) {
$arrControls[] = $control;
}
//end control foreach
}
}
}
return $arrControls;
}
示例8: getInput
protected function getInput()
{
if (!function_exists('xtcsortfn')) {
function xtcsortfn($a, $b)
{
return strnatcmp($a[0], $b[0]);
}
}
jimport('joomla.filesystem.folder');
JHTML::_('behavior.modal', 'a.modal');
$live_site = JURI::root();
$template = basename(dirname(dirname(dirname(__FILE__))));
$document = JFactory::getDocument();
$id = JRequest::getInt('id');
$document->addStyleSheet($live_site . "templates/{$template}/XTC/XTC.css", 'text/css');
$path = JPATH_ROOT . '/templates/' . $template;
$files = JFolder::files($path . '/parameters', 'xml');
$onopen = "var iSize;\n var iFrame = this.asset;\n iFrame.addEvent('load', function(){\n var iBody = (iFrame.contentDocument) ? iFrame.contentDocument.getElementsByTagName('body')[0] : iFrame.contentWindow.document.getElementsByTagName('body')[0];\n\n\t iSize = {x:this.size.x, y:iBody.offsetHeight};\n var per = (window.innerHeight * 0.9).toInt();\n iSize.y = (iSize.y > per) ? per : iSize.y ;\n iFrame.setStyles({'height':'100%'});\n\n this.resize(iSize, false);\n }.bind(this));";
$parmsfound = false;
$prefix = trim($this->element['group']);
$label = trim($this->element['label']);
$parameters = array();
foreach ($files as $file) {
@(list($filename, $extension) = explode('.', $file, 2));
if ($extension != 'xml') {
continue;
}
// Not an XML
if (strpos($filename, $prefix) !== 0) {
continue;
}
// Not the right prefix
$xmlFile = $path . '/parameters/' . $file;
if (is_readable($xmlFile)) {
$xml = simplexml_load_file($xmlFile);
$name = isset($xml->name) ? $xml->name : $filename;
$description = isset($xml->description) ? trim($xml->description) : '';
} else {
$name = $filename;
$description = '';
}
$thumbnail = '';
if (file_exists($path . '/parameters/' . $filename . '.gif')) {
$thumbnail = $filename . '.gif';
} elseif (file_exists($path . '/parameters/' . $filename . '.jpg')) {
$thumbnail = $filename . '.jpg';
} elseif (file_exists($path . '/parameters/' . $filename . '.png')) {
$thumbnail = $filename . '.png';
}
$fullimage = '';
if (file_exists($path . '/parameters/' . $filename . '_full.gif')) {
$fullimage = $filename . '_full.gif';
} elseif (file_exists($path . '/parameters/' . $filename . '_full.jpg')) {
$fullimage = $filename . '_full.jpg';
} elseif (file_exists($path . '/parameters/' . $filename . '_full.png')) {
$fullimage = $filename . '_full.png';
}
$parameters[] = array($name, $filename, $description, $thumbnail, $fullimage);
}
usort($parameters, "xtcsortfn");
$stringFilter = JFilterInput::getInstance();
require_once $path . '/XTC/XTC_library.php';
$templateParameters = xtcLoadParams($id);
$html = '';
$navHtml = '';
$tabHtml = '';
$count = count($parameters);
$openClass = $count == 1 ? ' open' : '';
foreach ($parameters as $i => $parameter) {
// Draw parameters
list($name, $filename, $description, $thumbnail, $fullimage) = $parameter;
$params = isset($templateParameters->group->{$filename}) ? $templateParameters->group->{$filename} : new stdClass();
$tabid = $filename . $i;
// Parameter Tab
$active = $i == 0 ? ' class="active"' : '';
$navHtml .= '<li' . $active . '>';
$navHtml .= '<a href="#' . $tabid . '" data-toggle="tab">';
if ($thumbnail) {
$thumbnailURL = $live_site . 'templates/' . $template . '/parameters/' . $thumbnail;
$navHtml .= '<img class="img-rounded" src="' . $thumbnailURL . '" alt="" /><br/>';
}
$navHtml .= '<center>' . $name . '</center>';
$navHtml .= '</a>';
$navHtml .= '</li>';
// Parameter Tab contents
$form = new JForm('jxtc');
$form->addFieldPath(JPATH_ROOT . '/templates/' . $template . '/XTC/elements');
$xmlFile = $path . '/parameters/' . $filename . '.xml';
$form->loadFile($xmlFile);
$getFieldsets = $form->getFieldsets();
$active = $i == 0 ? ' active' : '';
$tabHtml .= '<div class="tab-pane' . $active . '" id="' . $tabid . '">';
$tabHtml .= '<div class="xtc row-fluid">';
$tabHtml .= '<div class="span5">';
foreach ($getFieldsets as $fieldsets => $fieldset) {
$label = trim($fieldset->label);
if (empty($label)) {
$label = trim($fieldset->name);
}
$fieldsetDescription = isset($fieldset->description) ? trim($fieldset->description) : '';
//.........这里部分代码省略.........
示例9: onContentPrepareData
/**
* Runs on content preparation.
* Called after the data for a JForm has been retrieved.
*
* @param string $context The context for the data
* @param object $data An object containing the data for the form.
*
* @return boolean
*/
public function onContentPrepareData($context, $data)
{
if (is_object($data)) {
$articleId = isset($data->id) ? $data->id : 0;
if ($articleId > 0) {
// Load the data from the database
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('data');
$query->from('#__content_ksextras');
$query->where('article_id = ' . $db->Quote($articleId));
$db->setQuery($query);
$results = $db->loadObject();
// Check for a database error
if ($db->getErrorNum()) {
$this->_subject->setError($db->getErrorMsg());
return false;
}
$ksdata = count($results) ? json_decode(json_decode($results->data)) : new stdClass();
// Merge the data
$data->attribs = array();
foreach ($this->ksfields as $ksfield) {
$data->attribs[$ksfield] = isset($ksdata->{$ksfield}) ? $ksdata->{$ksfield} : '';
}
} else {
// Load the form
JForm::addFormPath(dirname(__FILE__) . '/extras');
$form = new JForm('com_content.article');
$form->loadFile('testimonial', false);
// Merge the default values
$data->attribs = array();
foreach ($form->getFieldset('attribs') as $field) {
$data->attribs[] = array($field->fieldname, $field->value);
}
}
}
return true;
}
示例10: getInput
function getInput()
{
$formRegistration = new JForm('com_users.registration');
$formProfile = new JForm('com_users.registration');
$plugin = JPluginHelper::getPlugin('user', 'profile');
//load language com_user and plugin profile
$language = JFactory::getLanguage();
$language_tag = $language->getTag();
JFactory::getLanguage()->load('lib_joomla', JPATH_SITE, $language_tag, true);
JFactory::getLanguage()->load('com_users', JPATH_SITE, $language_tag, true);
JFactory::getLanguage()->load('plg_user_profile', JPATH_ADMINISTRATOR, $language_tag, true);
// Add the registration fields to the form.
$formRegistration->loadFile(JPATH_ROOT . '/components/com_users/models/forms/registration.xml', false);
// remove unused fiels of registrer form
$formRegistration->removeField('captcha');
$formRegistration->removeField('spacer');
$formRegistration->removeField('password1');
$formRegistration->removeField('password2');
$formRegistration->removeField('email2');
//setting list box
$class = $this->element['class'] ? (string) $this->element['class'] : '';
$social = $this->element['social'] ? (string) $this->element['social'] : '';
$html = '<ul class="profile-fields ' . $class . '" id="' . $this->id . '" version="' . JVERSION . '">';
$options = array();
switch ($social) {
case 'facebook':
$options[] = JHtml::_('select.option', '', JText::_('JNONE'));
$options[] = JHtml::_('select.option', 'id', JText::_('ID'));
$options[] = JHtml::_('select.option', 'name', 'Name');
$options[] = JHtml::_('select.option', 'username', 'Username');
$options[] = JHtml::_('select.option', 'email', 'Email');
$options[] = JHtml::_('select.option', 'link', 'Profile link');
//$options[] = JHtml::_('select.option', 'picture', 'Profile Picture');
$options[] = JHtml::_('select.option', 'birthday', 'Date of birth');
$options[] = JHtml::_('select.option', 'location', 'Location');
$options[] = JHtml::_('select.option', 'hometown', 'Hometown');
$options[] = JHtml::_('select.option', 'website', 'Website');
$options[] = JHtml::_('select.option', 'bio', 'About me');
$options[] = JHtml::_('select.option', 'quotes', 'Favorite Quotes');
break;
case 'google':
$options[] = JHtml::_('select.option', '', JText::_('JNONE'));
$options[] = JHtml::_('select.option', 'id', JText::_('ID'));
$options[] = JHtml::_('select.option', 'name', 'Name');
$options[] = JHtml::_('select.option', 'username', 'Username');
$options[] = JHtml::_('select.option', 'email', 'Email');
$options[] = JHtml::_('select.option', 'link', 'Profile link');
//$options[] = JHtml::_('select.option', 'picture', 'Profile Picture');
$options[] = JHtml::_('select.option', 'birthday', 'Date of birth');
break;
case 'twitter':
$options[] = JHtml::_('select.option', '', JText::_('JNONE'));
$options[] = JHtml::_('select.option', 'id', JText::_('ID'));
$options[] = JHtml::_('select.option', 'name', 'Name');
$options[] = JHtml::_('select.option', 'username', 'Screen Name');
$options[] = JHtml::_('select.option', 'link', 'Profile link');
//$options[] = JHtml::_('select.option', 'picture', 'Profile Picture');
$options[] = JHtml::_('select.option', 'birthday', 'Date of birth');
$options[] = JHtml::_('select.option', 'location', 'Location');
$options[] = JHtml::_('select.option', 'website', 'Website');
$options[] = JHtml::_('select.option', 'bio', 'Description');
$options[] = JHtml::_('select.option', 'status', 'Status');
break;
}
//add field from register form
foreach ($formRegistration->getFieldsets() as $fieldset) {
$fields = $formRegistration->getFieldset($fieldset->name);
if (count($fields)) {
foreach ($fields as $field) {
$html .= '<li class="control-group">' . $field->getLabel();
if ($field->fieldname == 'name') {
$html .= JHtml::_('select.genericlist', $options, '', 'class="name control-group"', 'value', 'text', 'name');
} elseif ($field->fieldname == 'username') {
$html .= JHtml::_('select.genericlist', $options, '', 'class="username control-group"', 'value', 'text', $social == 'google' ? 'email' : 'username');
} elseif ($field->fieldname == 'email1') {
$html .= JHtml::_('select.genericlist', $options, '', 'class="email1 control-group" disabled="disabled"', 'value', 'text', 'email');
if ($social == 'twitter') {
$html .= '<br /><span style="color:red;line-height:200%">The Twitter API does not provide the user\'s email address. So if you turn off "editing email" the twitter users will have email type: screen_name@twitter.com</span>';
}
}
}
}
}
//load fields of plugin profile
if ($plugin != null) {
$params = new JRegistry();
$params->loadString($plugin->params);
$formProfile->loadFile(JPATH_ROOT . '/plugins/user/profile/profiles/profile.xml', false);
$fields = array('address1', 'address2', 'city', 'region', 'country', 'postal_code', 'website', 'favoritebook', 'aboutme', 'dob');
//remove field unused
$formProfile->removeField('tos', 'profile');
//$formProfile->removeField('city','profile');
//$formProfile->removeField('region','profile');
//$formProfile->removeField('country','profile');
$formProfile->removeField('postal_code', 'profile');
$formProfile->removeField('favoritebook', 'profile');
$formProfile->removeField('phone', 'profile');
//remove field disable in profile form
foreach ($fields as $field) {
if ($params->get('register-require_' . $field, 1) > 0) {
//.........这里部分代码省略.........
示例11: foreach
$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
foreach ($form->getFieldset($name) as $field) {
?>
<div class="control-group">
<?php
if (!in_array($field->type, array('Text', 'Textarea'))) {
?>
<label class="control-label" for="inputEmail">
<?php
echo $field->label;
?>
</label>
<?php
}
?>
<div class="controls">
<?php
示例12: 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;
$version = new JVersion();
$j3 = version_compare($version->RELEASE, '3.0') >= 0 ? true : false;
$class = $j3 ? 'form-horizontal ' : 'adminform ';
$str = array();
$str[] = '<div class="pane-slider content pane-down accordion-inner">';
$str[] = '<fieldset class="' . $class . 'pluginContainer" 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);
// Filter the forms fieldsets for those starting with the correct $searchName prefix
foreach ($topForm->getFieldsets() as $fieldset) {
if ($fieldset->label != '') {
$str[] = '<legend>' . $fieldset->label . '</legend>';
}
foreach ($topForm->getFieldset($fieldset->name) as $field) {
if (!$j3) {
$str[] = '<li>' . $field->label . $field->input . '</li>';
} else {
$str[] = '<div class="control-group"><div class="control-label">' . $field->label;
$str[] = '</div><div class="controls">' . $field->input . '</div></div>';
}
}
}
$str[] = '</ul>';
$str[] = '<div class="pluginOpts" style="clear:left"></div>';
if ($j3) {
$str[] = '<div class="form-actions"><a href="#" class="btn btn-danger" data-button="removeButton">';
$str[] = '<i class="icon-delete"></i> ' . FText::_('COM_FABRIK_DELETE') . '</a></div>';
} else {
$str[] = '<a href="#" class="delete removeButton">' . FText::_('COM_FABRIK_DELETE') . '</a>';
}
$str[] = '</fieldset>';
$str[] = '</div>';
return implode("\n", $str);
}
示例13: getInput
protected function getInput()
{
if (!function_exists('xtcsortfn')) {
function xtcsortfn($a, $b)
{
return strnatcmp($a[0], $b[0]);
}
}
jimport('joomla.filesystem.folder');
JHTML::_('behavior.modal', 'a.modal');
$template = basename(dirname(dirname(dirname(__FILE__))));
$live_site = JURI::root();
$document = JFactory::getDocument();
$id = JRequest::getInt('id');
$document->addStyleSheet($live_site . "templates/{$template}/XTC/XTC.css", 'text/css');
$path = JPATH_ROOT . '/templates/' . $template;
$folders = JFolder::folders($path . '/layouts');
$layouts = array();
foreach ($folders as $folder) {
// Parse parameter files
$xmlFile = $path . '/layouts/' . $folder . '/config.xml';
if (is_readable($xmlFile)) {
$xml = simplexml_load_file($xmlFile);
$name = isset($xml->name) ? $xml->name : $folder;
$description = isset($xml->description) ? trim($xml->description) : '';
} else {
$name = $folder;
$description = '';
}
$thumbnail = '';
if (file_exists($path . '/layouts/' . $folder . '/thumbnail.gif')) {
$thumbnail = 'thumbnail.gif';
} elseif (file_exists($path . '/layouts/' . $folder . '/thumbnail.jpg')) {
$thumbnail = 'thumbnail.jpg';
} elseif (file_exists($path . '/layouts/' . $folder . '/thumbnail.png')) {
$thumbnail = 'thumbnail.png';
}
$fullimage = '';
if (file_exists($path . '/layouts/' . $folder . '/layout.gif')) {
$fullimage = 'layout.gif';
} elseif (file_exists($path . '/layouts/' . $folder . '/layout.jpg')) {
$fullimage = 'layout.jpg';
} elseif (file_exists($path . '/layouts/' . $folder . '/layout.png')) {
$fullimage = 'layout.png';
}
$layouts[] = array($name, $folder, $description, $thumbnail, $fullimage);
}
usort($layouts, "xtcsortfn");
$stringFilter = JFilterInput::getInstance();
require_once $path . '/XTC/XTC_library.php';
$templateParameters = xtcLoadParams($id);
$html = '';
$navHtml = '';
$tabHtml = '';
$count = count($layouts);
$openClass = $count == 1 ? ' open' : '';
foreach ($layouts as $i => $layout) {
// Draw layouts
list($name, $folder, $description, $thumbnail, $fullimage) = $layout;
$params = isset($templateParameters->group->{$folder}) ? $templateParameters->group->{$folder} : new stdClass();
$tabid = $folder . $i;
// Parameter Tab
$active = $i == 0 ? ' class="active"' : '';
$navHtml .= '<li' . $active . '>';
$navHtml .= '<a href="#' . $tabid . '" data-toggle="tab">';
if ($thumbnail) {
$thumbnailURL = $live_site . 'templates/' . $template . '/layouts/' . $folder . '/' . $thumbnail;
$navHtml .= '<img class="img-rounded" src="' . $thumbnailURL . '" alt="" /><br/>';
}
$navHtml .= '<center>' . $name . '</center>';
$navHtml .= '</a>';
$navHtml .= '</li>';
// Parameter Tab contents
$form = new JForm('jxtc');
$form->addFieldPath(JPATH_ROOT . '/templates/' . $template . '/XTC/elements');
$xmlFile = $path . '/layouts/' . $folder . '/config.xml';
$form->loadFile($xmlFile);
$getFieldsets = $form->getFieldsets();
$active = $i == 0 ? ' active' : '';
$tabHtml .= '<div class="tab-pane' . $active . '" id="' . $tabid . '">';
$tabHtml .= '<div class="xtc row-fluid">';
$tabHtml .= '<div class="span5">';
foreach ($getFieldsets as $fieldsets => $fieldset) {
$label = trim($fieldset->label);
if (empty($label)) {
$label = trim($fieldset->name);
}
$fieldsetDescription = isset($fieldset->description) ? trim($fieldset->description) : '';
if (count($getFieldsets) > 1) {
$tabHtml .= '<fieldset>';
if ($label) {
$tabHtml .= '<legend>' . $label . '</legend>';
}
if ($fieldsetDescription) {
$tabHtml .= '<div class="well">' . $fieldsetDescription . '</div>';
}
}
foreach ($form->getFieldset($fieldset->name) as $field) {
$xtcName = substr($field->name, 7, -1);
if (isset($params->{$xtcName})) {
//.........这里部分代码省略.........
示例14: getQuickaddForm
/**
* getQuickaddForm
*/
public static function getQuickaddForm($id, $path, $extension = null)
{
$content = '';
//JForm::addFormPath(AKHelper::_('path.get', null, $extension).'/models/forms');
//JForm::addFieldPath(AKHelper::_('path.get', null, $extension).'/models/fields');
try {
$form = new JForm($id . '.quickaddform', array('control' => $id));
$form->loadFile(JPATH_ROOT . '/' . $path);
} catch (Exception $e) {
Jerror::raiseWarning(404, $e->getMessage());
return false;
}
// Set Category Extension
if ($extension) {
$form->setValue('extension', null, $extension);
}
$fieldset = $form->getFieldset('quickadd');
foreach ($fieldset as $field) {
$content .= "<div class=\"control-group\" id=\"jform_basic_alias-wrap\">\n <div class=\"control-label\">\n {$field->label}\n </div>\n <div class=\"controls\">\n {$field->input}\n </div>\n </div>";
}
if (JVERSION < 3) {
$content = "<fieldset class=\"adminform form-horizontal\">{$content}</fieldset>";
}
return $content;
}
示例15: 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);
}