本文整理汇总了PHP中JForm::getFieldsets方法的典型用法代码示例。如果您正苦于以下问题:PHP JForm::getFieldsets方法的具体用法?PHP JForm::getFieldsets怎么用?PHP JForm::getFieldsets使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JForm
的用法示例。
在下文中一共展示了JForm::getFieldsets方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getInput
protected function getInput()
{
if (!defined('VERTEX_LOADED')) {
$vertex_admin_path = JURI::root() . 'templates/' . VERTEX_TEMPLATE_NAME . '/vertex/admin';
$template_path = JURI::root(true) . '/templates/' . VERTEX_TEMPLATE_NAME;
$document = JFactory::getDocument();
$cmsversion = new JVersion();
$document->addStyleSheet(JURI::root(true) . '/templates/' . VERTEX_TEMPLATE_NAME . '/vertex/admin/vertex.css');
$document->addScript($vertex_admin_path . '/js/vertexAdmin.Loader.js');
$document->setMetaData('meta', 'IE=EmulateIE7', 'X-UA-Compatible');
$session = JFactory::getSession();
$main_path = dirname(dirname(dirname(dirname(__FILE__))));
$lang_dir = dirname(dirname($main_path)) . '/language/';
$Vertex = new vertexAdmin($main_path . '/xml/Vertex.xml', 'sienna', $main_path . '/xml/Specific.xml', $lang_dir, $vertex_admin_path . '/df-images', $cmsversion->RELEASE);
$Vertex->loadTD();
vertex_fix('joomla3', $document);
if ($cmsversion->RELEASE <= 2.5) {
require_once dirname(dirname(__FILE__)) . '/spec/JLegacy.php';
} else {
require_once dirname(dirname(__FILE__)) . '/spec/JCurrent.php';
}
$script = "\n";
$script .= "var vertex_ajax_url = '{$vertex_admin_path}';";
$script .= "var img_path = '{$vertex_admin_path}/df-images';";
$script .= "var json_path = '{$template_path}/vertex.json';";
$script .= "var vertex_version = '2.1';";
$script .= "var vertex_cmsversion = '{$cmsversion->RELEASE}';";
$script .= "var vertexNoAdd = " . json_encode($Vertex->noAdd) . ";\n";
$script .= $sjs;
$document->addScriptDeclaration($script);
$table = JForm::getFieldsets('adminform');
$data = null;
foreach ((array) $this->form as $key => $val) {
if ($val instanceof JRegistry) {
$data =& $val;
break;
}
}
$title = $data->toArray();
$title = $title['title'];
$html = $Vertex->vertexLoadAdmin($title);
define('VERTEX_LOADED', true);
// Output
return $html;
}
}
示例2: 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;
}
示例3: renderFromNavTabHeadings
/**
* Create bootstrap horizontal tab headings from fieldset labels
* Used for rendering viz plugin options
*
* @param JForm $form Plugin form
* @param array &$output Plugin render output
* @param int $repeatCounter Repeat count for plugin
*
* @since 3.1
*
* @return void
*/
protected function renderFromNavTabHeadings($form, &$output, $repeatCounter = 0)
{
$fieldsets = $form->getFieldsets();
if (count($fieldsets) <= 1) {
return;
}
$output[] = '<div class="row-fluid">';
$output[] = '<ul class="nav nav-tabs">';
$i = 0;
foreach ($fieldsets as $fieldset) {
if (isset($fieldset->modal) && $fieldset->modal) {
continue;
}
$class = $i === 0 ? ' class="active"' : '';
$id = 'tab-' . $fieldset->name;
$id .= '-' . $repeatCounter;
$output[] = '<li' . $class . '>
<a data-toggle="tab" href="#' . $id . '">
' . JText::_($fieldset->label) . '
</a>
</li>';
$i++;
}
$output[] = '</ul>';
$output[] = '</div>';
}
示例4: 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) : '';
//.........这里部分代码省略.........
示例5: 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) {
//.........这里部分代码省略.........
示例6: updateConfiguration
/**
* Updates the component configuration.
* It first fetches the config.xml file & reads all entries there.
* Then we load the current component parameters from the db
* and merge them with the .xml file. This way we ensure that
* the db has all the current values for each setting even if the
* user doesn't edit his config.
*
* @return array - the parameters
*/
public function updateConfiguration()
{
$settings = JPATH_ADMINISTRATOR . '/components/' . $this->component . '/config.xml';
$json = array();
$form = new JForm('config');
$form->loadFile($settings, true, '/config');
$params = JComponentHelper::getParams($this->component)->toArray();
$fieldsets = $form->getFieldsets();
foreach ($fieldsets as $fieldsetkey => $fieldset) {
$fields = $form->getFieldset($fieldsetkey);
foreach ($fields as $fieldkey => $field) {
// If we have a group for this field, use it!
if ($field->group) {
$json[$field->group][$field->fieldname] = $field->value;
} else {
$json[$field->fieldname] = $field->value;
}
}
}
$merged = array_merge($json, $params);
$this->updateParams($merged);
return $merged;
}
示例7: storeLessConf
/**
* Method to store parameters as LESS variables
*
* @access public
* @return boolean True on success
* @since 1.5
*/
function storeLessConf($folder, $cfgname, $layout, $attribs)
{
// Load the XML file into a JForm object
$jform = new JForm('com_flexicontent.template.category', array('control' => 'jform', 'load_data' => true));
$jform->load($this->_getLayout()->params);
// params is the XML file contents as a string
$layout_type = $layout == 'items' ? 'item' : 'category';
$tmpldir = JPath::clean(JPATH_ROOT . DS . 'components' . DS . 'com_flexicontent' . DS . 'templates');
$less_path = JPath::clean($tmpldir . DS . $folder . DS . 'less/include/config_auto_' . $layout_type . '.less');
//echo "<pre>".$less_path."<br/>";
$var_pfx = '@FC' . ($layout == 'items' ? 'I' : 'C') . '_';
// Get 'attribs' fieldset
$fieldSets = $jform->getFieldsets($groupname = 'attribs');
// Iterate though the form elements and only use parameters with cssprep="less"
$less_data = "/* This is created automatically, do NOT edit this manually! \nThis is used by " . $layout_type . " layout to save parameters as less variables. \nNOTE: Make sure that this is imported by 'config.less' \n to make a parameter be a LESS variable, edit parameter in " . $layout_type . ".xml and add cssprep=\"less\" \n created parameters will be like: @FC" . ($layout == 'items' ? 'I' : 'C') . "_parameter_name: value; */\n\n";
foreach ($jform->getFieldsets($groupname) as $fsname => $fieldSet) {
foreach ($jform->getFieldset($fsname) as $field) {
if ($field->getAttribute('cssprep') != 'less') {
continue;
}
// Only add parameters meant to be less variables
if (is_array($attribs[$field->fieldname])) {
continue;
}
// array parameters not supported
$v = trim($attribs[$field->fieldname]);
if (!strlen($v)) {
$v = $field->getAttribute('default');
if (!strlen($v)) {
continue;
}
// do not add empty parameters
}
$less_data .= $var_pfx . $field->fieldname . ': ' . $v . ";\n";
}
}
file_put_contents($less_path, $less_data);
return true;
}
示例8: getDisplayRegistration
/**
* Display our CMC fields at the registration
*
* @param object $tab - The tab
* @param JUser $user - The user
* @param object $ui - The UI
* @param object $postdata - The postdata
*
* @return string
*/
public function getDisplayRegistration($tab, $user, $ui, $postdata)
{
JHtml::_('stylesheet', JURI::root() . 'media/mod_cmc/css/cmc.css');
CompojoomHtmlBehavior::jquery();
$plugin = GetCmcTab::getPlugin();
$listid = $plugin->params->get('listid', "");
$interests = $plugin->params->get('interests', '');
$fields = $plugin->params->get('fields', '');
// Create the xml for JForm
$builder = CmcHelperXmlbuilder::getInstance($plugin->params);
// Load JS & Co
JFactory::getDocument()->addScriptDeclaration("\n\t\t\tjQuery(document).ready(function(){\n\t\t\t\tvar \$ = jQuery;\n\n\t\t\t\t\$('#cmc_check_newsletter').on('click', function() {\n\t\t\t\t\tif(\$(this).prop('checked'))\n\t\t\t\t\t{\n\t\t\t\t\t\t\$('input.cmc_req').addClass('required');\n\t\t\t\t\t\t\$('#cmc_newsletter').show();\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\t\$('input.cmc_req').removeClass('required');\n\t\t\t\t\t\t\$('#cmc_newsletter').hide();\n\t\t\t\t\t}\n\t\t\t\t});\n\n\t\t\t\t\$('#cmc_newsletter').hide();\n\t\t\t});\n\t\t");
// We have to set the fields / interests manually for cb because they are no array! See explode
if (!empty($fields)) {
$fields = explode("|*|", $plugin->params->get('fields', ''));
$builder->fields = $fields;
}
if (!empty($interests)) {
$interests = explode("|*|", $plugin->params->get('interests', ''));
$builder->interests = $interests;
}
$xml = $builder->build();
$form = new JForm('myform');
$form->addFieldPath(JPATH_ADMINISTRATOR . '/components/com_cmc/models/fields');
$form->load($xml);
$fieldsets = $form->getFieldsets();
$ret = '<div class="cbFieldsContentsTab">';
$ret .= '<div class="sectiontableentry1 cbft_predefined cbtt_input form-group cb_form_line clearfix">';
$ret .= '<label for="name" id="cblabname" class="control-label col-sm-3">' . JText::_('PLG_CMCCB_SUBSCRIPTION') . '</label>';
$ret .= '<div class="cb_field col-sm-9">';
$ret .= '<input type="checkbox" name="cmc[newsletter]" id="cmc_check_newsletter" value="1" /> ';
$ret .= '<label for="cmc_check_newsletter" id="cmc_newsletter_lbl">' . JText::_('PLG_CMCCB_NEWSLETTER') . '</label>';
$ret .= "</div>\n";
$ret .= "</div>";
$ret .= "<div id='cmc_td_newsletter' style='' class=\"cbFieldsContentsTab\">\n";
$ret .= "<div id=\"cmc_newsletter\" style=\"display: block;\">\n";
// Render Content
foreach ($fieldsets as $key => $value) {
if ($key != "cmc") {
$ret .= '<div class="sectiontableentry1 cbft_predefined cbtt_input form-group cb_form_line clearfix">';
$ret .= '<label class="col-sm-12">' . JText::_($value->label) . '</label>';
$ret .= '</div>';
$fields = $form->getFieldset($key);
foreach ($fields as $field) {
$ret .= '<div class="sectiontableentry1 cbft_predefined cbtt_input form-group cb_form_line clearfix">';
$ret .= '<div class="control-label col-sm-3">' . $field->label . '</div>';
$ret .= '<div class="cb_field col-sm-9">';
$ret .= $field->input;
$ret .= '</div>';
$ret .= '</div>';
}
}
}
$ret .= '<input type="hidden" name="cmc[listid]" id="cmc_listid" value="' . $listid . '" />';
// End open tables / divs
$ret .= "</div>\n";
$ret .= "</div>\n";
return $ret;
}
示例9: 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
foreach ($form->getFieldset($name) as $field) {
示例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: getInput
/**
* Method to get the field input markup.
*
* @return string The field input markup.
*/
function getInput()
{
$jdoc = JFactory::getDocument();
if (version_compare(JVERSION, '3.0', 'lt')) {
$jdoc->addScript('http://code.jquery.com/jquery-latest.js');
// add bootstrap for Joomla 2.5
if (defined('T3_ADMIN_URL')) {
$jdoc->addStyleSheet(T3_ADMIN_URL . '/admin/bootstrap/css/bootstrap.min.css');
$jdoc->addScript(T3_ADMIN_URL . '/admin/bootstrap/js/bootstrap.min.js');
}
}
// add font awesome 4
if (defined('T3_ADMIN_URL')) {
$jdoc->addStyleSheet(T3_ADMIN_URL . '/admin/fonts/fa4/css/font-awesome.min.css');
}
$jdoc->addStyleSheet(JUri::root(true) . '/modules/mod_ja_acm/admin/assets/style.css');
$jdoc->addStyleSheet('//code.jquery.com/ui/1.11.1/themes/smoothness/jquery-ui.css');
$jdoc->addScript('//code.jquery.com/ui/1.11.1/jquery-ui.js');
$jdoc->addScript(JUri::root(true) . '/modules/mod_ja_acm/admin/assets/script.js');
// load all xml
$paths = array();
$paths['_'] = JPATH_ROOT . '/modules/mod_ja_acm/acm/';
// template folders
$tpls = JFolder::folders(JPATH_ROOT . '/templates/');
foreach ($tpls as $tpl) {
$paths[$tpl] = JPATH_ROOT . '/templates/' . $tpl . '/acm/';
}
$fields = array();
$group_types = array();
$group_layouts = array();
foreach ($paths as $template => $path) {
if (!is_dir($path)) {
continue;
}
$types = JFolder::folders($path);
if (!is_array($types)) {
continue;
}
$group_types[$template] = array();
// get layout for each type
foreach ($types as $type) {
if (!isset($group_layouts[$type])) {
$group_layouts[$type] = array();
}
if (!is_dir($path . $type . '/tmpl')) {
continue;
}
$layouts = JFolder::files($path . $type . '/tmpl', '.php');
if (is_array($layouts)) {
foreach ($layouts as $layout) {
$layout = JFile::stripExt($layout);
$group_layouts[$type][] = $layout;
}
}
}
foreach ($types as $type) {
$lname = $type;
if (is_file($path . $type . '/config.xml')) {
$form = new JForm($lname);
// $form->loadFile ($path . $type . '/config.xml', false);
$xml = JFactory::getXML($path . $type . '/config.xml', true);
$form->load($xml, false);
$fieldsets = $form->getFieldsets();
/*
$fieldsets_html = array();
if (!is_array($fieldsets)) continue;
foreach ($fieldsets as $fsname => $fieldset) {
$fieldsets_html[$fsname] = $this->renderFieldSet ($form, $fsname);
} */
$title = isset($xml->title) ? $xml->title : $lname;
$description = isset($xml->description) ? $xml->description : '';
$sampledata = isset($xml->sampledata) ? $xml->sampledata : '';
$group_types[$template][$lname] = $title;
$fields[$lname] = $this->renderLayout('jaacm-type', array('form' => $form, 'fieldsets' => $fieldsets, 'type' => $type, 'layouts' => $group_layouts[$type], 'description' => $description, 'sample-data' => $sampledata));
/*
$fields[$lname] = $this->renderConfig('layout-config',
array('form' => $form, 'fieldsets' => $fieldsets, 'type' => $type,
'layouts' => $group_layouts[$type], 'description' => $description, 'sample-data' => $sampledata),
JPATH_ROOT); */
}
}
}
$html = '';
$html .= "\n<input type=\"hidden\" name=\"{$this->name}\" id=\"jatools-config\" value=\"" . htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8') . "\" />";
$html .= $this->renderLayout('jaacm', array('group_types' => $group_types, 'fields' => $fields));
// $html .= $this->renderConfig('layouts-config', array('group_types' => $group_types, 'fields' => $fields), JPATH_ROOT);
return $html;
}
示例12: renderFromNavTabHeadings
/**
* Create bootstrap horizontal tab headings from fieldset labels
* Used for rendering viz plugin options
*
* @param JForm $form Plugin form
* @param array &$output Plugin render output
* @param int $repeatCounter Repeat count for plugin
*
* @since 3.1
*
* @return void
*/
protected function renderFromNavTabHeadings($form, &$output, $repeatCounter = 0)
{
$fieldsets = $form->getFieldsets();
if (count($fieldsets) <= 1) {
return;
}
$tabs = array();
$i = 0;
foreach ($fieldsets as $fieldset) {
if (isset($fieldset->modal) && $fieldset->modal) {
continue;
}
$tab = new stdClass();
$tab->href = 'tab-' . $fieldset->name . '-' . $repeatCounter;
$tab->id = 'tab-' . $fieldset->name;
$tab->class = $i === 0 ? 'active' : '';
$tab->label = $fieldset->label;
$tabs[] = $tab;
$i++;
}
$displayData = new stdClass();
$displayData->tabs = $tabs;
$layout = FabrikHelperHTML::getLayout('fabrik-tabs');
$output[] = $layout->render($displayData);
}
示例13: getInput
protected function getInput()
{
jimport('joomla.html.parameter');
jimport('joomla.html.pane');
$id = JRequest::getInt('id');
$live_site = JURI::root();
$template = basename(dirname(dirname(dirname(__FILE__))));
$path = JPATH_ROOT . '/templates/' . $template;
$document = JFactory::getDocument();
$document->addStyleSheet($live_site . "templates/{$template}/XTC/XTC.css", 'text/css');
$xmlFile = JPATH_ROOT . '/templates/' . $template . '/XTC/XTC_config.xml';
if (!is_readable($xmlFile)) {
return "No parameters found.";
} else {
if (is_readable($xmlFile)) {
$xml = simplexml_load_file($xmlFile);
$name = isset($xml->name) ? $xml->name : '';
$description = isset($xml->description) ? trim($xml->description) : '';
} else {
$name = '';
$description = '';
}
}
$form = new JForm('jxtc');
$form->addFieldPath(JPATH_ROOT . '/templates/' . $template . '/XTC/elements');
$form->loadFile($xmlFile);
$getFieldsets = $form->getFieldsets();
require_once $path . '/XTC/XTC_library.php';
$templateParameters = xtcLoadParams($id);
$html = '';
$html .= '<div class="xtc row-fluid">';
$html .= '<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) {
// Split in xtc fieldsets
$html .= '<fieldset>';
if ($label) {
$html .= '<legend>' . $label . '</legend>';
}
if ($fieldsetDescription) {
$html .= '<div>' . $fieldsetDescription . '</div>';
}
}
foreach ($form->getFieldset($fieldset->name) as $field) {
$xtcName = substr($field->name, 7, -1);
if (isset($templateParameters->{$xtcName})) {
$field->value = $templateParameters->{$xtcName};
}
$field->name = str_replace('params[', 'jform[params][', $field->name);
$html .= '<div class="control-group">';
$html .= '<div class="control-label">' . $field->getLabel() . '</div>';
$html .= '<div class="controls">' . $field->getInput() . '</div>';
$html .= '</div>';
}
if (count($getFieldsets) > 1) {
$html .= '</fieldset>';
}
}
$html .= '</div>';
//span
if ($description) {
$html .= '<div class="span1"></div>';
$html .= '<div class="span4">';
$html .= '<h3>' . $name . '</h3>';
$html .= '<div class="well">' . $description . '</div></div>';
}
$html .= '</div>';
// row-fluid
$html .= '<script type="text/javascript">
original = Joomla.submitbutton;
Joomla.submitbutton = function(task) {
if (task == "style.apply" || task == "style.save" || task == "style.save2copy") {
form = document.getElementById("style-form");
form.action="index.php?option=com_jxtc&id=' . JRequest::getInt('id') . '"
form.task.value = task.substr(6);
form.submit();
}
else {
original(task);
}
}
function switchpane(name) {
pane = document.getElementById(name);
if (pane.className == "xtcPane") {
pane.setAttribute("class", "xtcPane open");
}
else {
pane.setAttribute("class", "xtcPane");
}
}
</script>';
return $html;
}
示例14: getInput
//.........这里部分代码省略.........
if (!$activelayout && isset($value[$activetypename]) && isset($value[$activetypename]['jatools-layout-' . $activetypename])) {
$activelayout = $value[$activetypename]['jatools-layout-' . $activetypename];
if (is_array($activelayout)) {
$activelayout = $activelayout[0];
}
}
// clear value if not the right layout
$savedlayout = isset($value[$activetypename]) && isset($value[$activetypename]['jatools-layout-' . $activetypename]) ? $value[$activetypename]['jatools-layout-' . $activetypename] : '';
if (is_array($savedlayout)) {
$savedlayout = $savedlayout[0];
}
if ($savedlayout != $activelayout) {
$this->value = null;
}
}
// load all xml
$paths = array();
$paths['_'] = JPATH_ROOT . '/modules/mod_ja_acm/acm/';
// template folders
$tpls = JFolder::folders(JPATH_ROOT . '/templates/');
foreach ($tpls as $tpl) {
$paths[$tpl] = JPATH_ROOT . '/templates/' . $tpl . '/acm/';
}
$fields = array();
$group_types = array();
$group_layouts = array();
foreach ($paths as $template => $path) {
if (!is_dir($path)) {
continue;
}
$types = JFolder::folders($path);
if (!is_array($types)) {
continue;
}
$group_types[$template] = array();
// get layout for each type
foreach ($types as $type) {
if (!isset($group_layouts[$type])) {
$group_layouts[$type] = array();
}
if (!is_dir($path . $type . '/tmpl')) {
continue;
}
$layouts = JFolder::files($path . $type . '/tmpl', '.php');
if (is_array($layouts)) {
foreach ($layouts as $layout) {
$layout = JFile::stripExt($layout);
$group_layouts[$type][] = $layout;
}
}
}
foreach ($types as $type) {
$lname = $type;
if (is_file($path . $type . '/config.xml')) {
$xml = JFactory::getXML($path . $type . '/config.xml', true);
$title = isset($xml->title) ? $xml->title : $lname;
$group_types[$template][$lname] = $title;
}
}
}
$description = $sampledata = $configform = '';
$activetypetitle = $activetypename;
// load activetype xml
if ($activetype && $activelayout) {
$type = $activetypename;
$tpl = $activetpl;
$path = $paths[$tpl];
// load template language
if ($tpl != '_') {
JFactory::getLanguage()->load('tpl_' . $tpl . '.sys', JPATH_SITE);
}
if (is_file($path . $type . '/config.xml')) {
$xml = JFactory::getXML($path . $type . '/config.xml', true);
$description = isset($xml->description) ? $xml->description : '';
if ($xml->title) {
$activetypetitle = (string) $xml->title;
}
$sampledata = isset($xml->sampledata) ? $xml->sampledata : '';
// load xml for selected layout
$lname = $activelayout;
$lform = new JForm($lname);
$lform->load($xml, false);
if (is_file($path . $type . '/tmpl/' . $activelayout . '.xml')) {
$lxml = JFactory::getXML($path . $type . '/tmpl/' . $activelayout . '.xml', true);
if (isset($lxml->sampledata)) {
$sampledata = $lxml->sampledata;
}
$lform->load($lxml, false);
}
$fieldsets = $lform->getFieldsets();
$configform = $this->renderLayout('jaacm-type', array('form' => $lform, 'fieldsets' => $fieldsets, 'sample-data' => $sampledata, 'helper' => $helper));
}
}
$layoutform = $this->renderLayout('jaacm-select-layout', array('group_types' => $group_types, 'group_layouts' => $group_layouts, 'activetype' => $activetype, 'activetypename' => $activetypename, 'activelayout' => $activelayout, 'activetypetitle' => $activetypetitle, 'activelayouttitle' => $activelayout));
$html = '';
$html .= "\n<input type=\"hidden\" name=\"{$this->name}\" id=\"jatools-config\" value=\"" . htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8') . "\" />";
$html .= $this->renderLayout('jaacm', array('config-form' => $configform, 'layout-form' => $layoutform, 'activetype' => $activetype, 'activetypename' => $activetypename, 'activelayout' => $activelayout, 'description' => $description));
// $html .= $this->renderConfig('layouts-config', array('group_types' => $group_types, 'fields' => $fields), JPATH_ROOT);
return $html;
}
示例15: 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})) {
//.........这里部分代码省略.........