本文整理汇总了PHP中JForm::loadFile方法的典型用法代码示例。如果您正苦于以下问题:PHP JForm::loadFile方法的具体用法?PHP JForm::loadFile怎么用?PHP JForm::loadFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JForm
的用法示例。
在下文中一共展示了JForm::loadFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onContentPrepareForm
/**
* Injects several fields into specific forms.
*
* @param JForm $form The form to be altered.
* @param array $data The associated data for the form.
*
* @return boolean
*
* @since 2.0
*/
public function onContentPrepareForm($form, $data)
{
// Check we are manipulating a valid form
if (!$form instanceof JForm) {
$this->_subject->setError('JERROR_NOT_A_FORM');
return false;
}
// Check if the password field needs injecting
if ($this->params->get('use_ldap_password', false) && in_array($form->getName(), $this->passwordForms)) {
// Check if this user should have a profile
if (SHLdapHelper::isUserLdap(isset($data->id) ? $data->id : 0)) {
if ($this->params->get('ldap_password_layout_edit', true)) {
// Check if this is in the 'edit' layout or in the save state
if (strtolower(JFactory::getApplication()->input->get('layout')) === 'edit' || strtolower(JFactory::getApplication()->input->get('task')) === 'save') {
$form->loadFile(realpath(__DIR__) . '/forms/ldap_password.xml', false, false);
}
} else {
$form->loadFile(realpath(__DIR__) . '/forms/ldap_password.xml', false, false);
}
}
}
// Check if the domain field needs injecting
if ($this->params->get('use_ldap_domain', false) && in_array($form->getName(), $this->domainForms)) {
$form->loadFile(realpath(__DIR__) . '/forms/ldap_domain.xml', false, false);
}
return true;
}
示例2: preprocessForm
protected function preprocessForm(\JForm $form, $data, $group = 'content')
{
// if no data, grab the posted form data.
if (!$data instanceof JObject) {
$data = JFactory::getApplication()->input->get('jform', $data, 'array');
$data = JArrayHelper::toObject($data);
}
$params = new JRegistry();
$params->loadArray($data->params);
if ($params->get('discovery.url')) {
$plugin = $params->get('discovery.type');
$language = JFactory::getLanguage();
$language->load('plg_harvest_' . $plugin);
$path = JPATH_ROOT . '/plugins/harvest/' . $plugin . '/forms/harvest.xml';
$form->loadFile($path, false);
foreach (JPluginHelper::getPlugin('ingest') as $plugin) {
$language->load('plg_ingest_' . $plugin->name);
$path = JPATH_ROOT . '/plugins/ingest/' . $plugin->name . '/forms/ingest.xml';
$form->loadFile($path, false);
}
$form->removeField('originating_url');
$form->removeField('harvester');
// hide the run_once value (users cannot set it after discovery)
$form->setFieldAttribute("run_once", 'type', 'hidden');
$form->setFieldAttribute("run_once", 'class', '');
} else {
$form->removeField('state');
$form->removeField('harvested');
$form->removeField('url', 'params.discovery');
$form->removeField('type', 'params.discovery');
}
parent::preprocessForm($form, $data, $group);
}
示例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: 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;
}
示例5: onContentPrepareForm
/**
* Event method that runs on content preparation
*
* @param JForm $form The form object
* @param integer $data The form data
*
* @return bool
*/
public function onContentPrepareForm($form, $data)
{
if (!$form instanceof JForm) {
$this->_subject->setError('JERROR_NOT_A_FORM');
return false;
}
$name = $form->getName();
if (!in_array($name, array('com_content.article'))) {
return true;
}
$include_categories = $this->params->get('include_categories');
if (empty($include_categories)) {
return true;
}
if (empty($data)) {
$input = JFactory::getApplication()->input;
$data = (object) $input->post->get('jform', array(), 'array');
}
if (is_array($data)) {
jimport('joomla.utilities.arrayhelper');
$data = JArrayHelper::toObject($data);
}
if (empty($data->catid)) {
return true;
}
if (!in_array($data->catid, $include_categories)) {
return true;
}
JForm::addFormPath(__DIR__ . '/form');
$form->loadFile('form');
if (!empty($data->id)) {
$data = $this->loadTest($data);
}
return true;
}
示例6: preprocessForm
/**
* Method to preprocess the form
*
* @param JForm $form A form 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
*
* @since 3.2
* @throws Exception if there is an error loading the form.
*/
protected function preprocessForm(JForm $form, $data, $group = 'content')
{
jimport('joomla.filesystem.path');
$lang = JFactory::getLanguage();
$module = $this->getState()->get('module.name');
$basePath = JPATH_BASE;
$formFile = JPath::clean($basePath . '/modules/' . $module . '/' . $module . '.xml');
// Load the core and/or local language file(s).
$lang->load($module, $basePath, null, false, true) || $lang->load($module, $basePath . '/modules/' . $module, null, false, true);
if (file_exists($formFile)) {
// Get the module form.
if (!$form->loadFile($formFile, false, '//config')) {
throw new Exception(JText::_('JERROR_LOADFILE_FAILED'));
}
// Attempt to load the xml file.
if (!($xml = simplexml_load_file($formFile))) {
throw new Exception(JText::_('JERROR_LOADFILE_FAILED'));
}
}
// Load the default advanced params
JForm::addFormPath(JPATH_BASE . '/components/com_config/model/form');
$form->loadFile('modules_advanced', false);
// Trigger the default form events.
parent::preprocessForm($form, $data, $group);
}
示例7: preprocessForm
/**
* Override preprocessForm to load the user plugin group instead of content.
*
* @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
*
* @since 1.6
* @throws Exception if there is an error in the form event.
*/
protected function preprocessForm(JForm $form, $data, $group = 'user')
{
$userParams = JComponentHelper::getParams('com_users');
//Add the choice for site language at registration time
if ($userParams->get('site_language') == 1 && $userParams->get('frontend_userparams') == 1) {
$form->loadFile('sitelang', false);
}
}
示例8: getForm
public static function getForm()
{
$myForm = new JForm('callback');
// Добавили путь где лежит форма здесь form.xml лежит в корне модуля
$myForm->addFormPath(__DIR__);
// Прочитали и вернули
$myForm->loadFile('form', false);
return $myForm;
}
示例9: 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;
}
示例10: onContentPrepareForm
/**
* Event onContentPrepareForm
*
* @param JForm $form
* @param array $data
*
* @return bool
*/
public function onContentPrepareForm($form, $data)
{
if (!$form instanceof JForm) {
$this->_subject->setError('JERROR_NOT_A_FORM');
return false;
}
$context = $form->getName();
if (!in_array($context, $this->allowedContext)) {
return true;
}
JForm::addFormPath(__DIR__ . '/form');
$form->loadFile('form', false);
return true;
}
示例11: 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();
}
示例12: onContentPrepareForm
/**
* @param JForm $form The form to be altered.
* @param array $data The associated data for the form.
*
* @return boolean
*/
public function onContentPrepareForm($form, $data)
{
if (!$form instanceof JForm) {
$this->_subject->setError('JERROR_NOT_A_FORM');
return false;
}
// Check we are manipulating a valid form.
if (!in_array($form->getName(), array('com_admin.profile', 'com_users.user', 'com_users.registration', 'com_users.profile'))) {
return true;
}
// Add the registration fields to the form.
JForm::addFormPath(dirname(__FILE__) . '/form');
$form->loadFile('socialmetatags', false);
return true;
}
示例13: onContentPrepareForm
/**
* @param JForm $form The form to be altered.
* @param array $data The associated data for the form.
*
* @return boolean
* @since 1.6
*/
function onContentPrepareForm($form, $data)
{
if (!$form instanceof JForm) {
$this->_subject->setError('JERROR_NOT_A_FORM');
return false;
}
// Check we are manipulating a valid form.
$name = $form->getName();
if (!in_array($name, array('com_users.registration'))) {
return true;
}
// Add the registration fields to the form.
JForm::addFormPath(dirname(__FILE__) . '/forms');
$form->loadFile('hprecaptcha', false);
return true;
}
示例14: onContentPrepareForm
/**
* Event method that runs on content preparation
*
* @param JForm $form The form object
* @param integer $data The form data
*
* @return bool
*/
public function onContentPrepareForm($form, $data)
{
if (!$form instanceof JForm) {
$this->_subject->setError('JERROR_NOT_A_FORM');
return false;
}
$name = $form->getName();
if (!in_array($name, array('com_content.article'))) {
return true;
}
JForm::addFormPath(__DIR__ . '/form');
$form->loadFile('form');
if (!empty($data->id)) {
$data = $this->loadTest($data);
}
return true;
}
示例15: onContentPrepareForm
function onContentPrepareForm(JForm $form, $data)
{
$name = $form->getName();
if (!in_array($name, array('com_admin.profile', 'com_users.user', 'com_users.profile', 'com_users.registration'))) {
return true;
}
// Add the extra fields
JForm::addFormPath(dirname(__FILE__) . '/profiles');
$form->loadFile('profile', false);
// If we're admin we can do some extra things
if ($name != "com_users.user") {
$form->setFieldAttribute("programmename", "readonly", true, "swg_extras");
// $form->setFieldAttrib("leaderid", "readonly", )
$form->removeField("leaderid", "swg_extras");
$form->removeField("leadersetup", "swg_extras");
}
return true;
}