本文整理汇总了PHP中JForm::getName方法的典型用法代码示例。如果您正苦于以下问题:PHP JForm::getName方法的具体用法?PHP JForm::getName怎么用?PHP JForm::getName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JForm
的用法示例。
在下文中一共展示了JForm::getName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;}');
}
}
}
示例2: getInstance
public static function getInstance(JForm $form)
{
if (!array_key_exists($form->getName(), self::$instances)) {
self::$instances[$form->getName()] = new RokSubfieldForm($form);
}
self::$instances[$form->getName()]->updateDataParams();
return self::$instances[$form->getName()];
}
示例3: test
/**
* Method to test if the Captcha is correct.
*
* @param SimpleXMLElement $element The SimpleXMLElement object representing the `<field>` tag for the form field object.
* @param mixed $value The form field value to validate.
* @param string $group The field name group control value. This acts as as an array container for the field.
* For example if the field has name="foo" and the group value is set to "bar" then the
* full field name would end up being "bar[foo]".
* @param Registry $input An optional Registry object with the entire data set to validate against the entire form.
* @param JForm $form The form object for which the field is being tested.
*
* @return boolean True if the value is valid, false otherwise.
*
* @since 2.5
*/
public function test(SimpleXMLElement $element, $value, $group = null, Registry $input = null, JForm $form = null)
{
$app = JFactory::getApplication();
$plugin = $app->get('captcha');
if ($app->isSite()) {
$plugin = $app->getParams()->get('captcha', $plugin);
}
$namespace = $element['namespace'] ?: $form->getName();
// Use 0 for none
if ($plugin === 0 || $plugin === '0') {
return true;
} else {
$captcha = JCaptcha::getInstance((string) $plugin, array('namespace' => (string) $namespace));
}
// Test the value.
if (!$captcha->checkAnswer($value)) {
$error = $captcha->getError();
if ($error instanceof Exception) {
return $error;
} else {
return new JException($error);
}
}
return true;
}
示例4: 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;
}
示例5: 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;
}
示例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;
}
$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;
}
示例7: 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;
}
示例8: 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;
}
示例9: 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;
}
示例10: 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;
}
示例11: 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;
}
示例12: onContentPrepareForm
/**
* @param JForm $form The form to be altered.
* @param array $data The associated data for the form.
*
* @return boolean
* @since 2.5
*/
public function onContentPrepareForm($form, $data)
{
// Ensure that data is an object
$data = (object) $data;
// Check we have a form
if (!$form instanceof JForm) {
$this->_subject->setError('JERROR_NOT_A_FORM');
return false;
}
// Check we are manipulating a valid form.
$app = JFactory::getApplication();
if ($form->getName() != 'com_plugins.plugin' || isset($data->name) && $data->name != 'plg_system_languagecode' || empty($data) && !$app->getUserState('plg_system_language_code.edit')) {
return true;
}
// Mark the plugin as being edited
$app->setUserState('plg_system_language_code.edit', $data->name == 'plg_system_languagecode');
// Get site languages
if ($languages = JLanguage::getKnownLanguages(JPATH_SITE)) {
// Inject fields into the form
foreach ($languages as $tag => $language) {
$form->load('
<form>
<fields name="params">
<fieldset
name="languagecode"
label="PLG_SYSTEM_LANGUAGECODE_FIELDSET_LABEL"
description="PLG_SYSTEM_LANGUAGECODE_FIELDSET_DESC"
>
<field
name="' . strtolower($tag) . '"
type="text"
description="' . htmlspecialchars(JText::sprintf('PLG_SYSTEM_LANGUAGECODE_FIELD_DESC', $language['name']), ENT_COMPAT, 'UTF-8') . '"
translate_description="false"
label="' . $tag . '"
translate_label="false"
size="7"
filter="cmd"
/>
</fieldset>
</fields>
</form>
');
}
}
return true;
}
示例13: 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;
}
示例14: onContentPrepareForm
/**
* @param JForm $form The form to be altered.
* @param array $data The associated data for the form.
*
* @return boolean
* @since 1.6
*/
public function onContentPrepareForm($form, $data)
{
// Get application
$application = JFactory::getApplication();
// Get settings
$params = JComponentHelper::getParams('com_k2');
// Get form name
$name = $form->getName();
// Valid forms
$forms = array('com_admin.profile', 'com_users.user', 'com_users.profile', 'com_users.registration');
// Rendering condition
if ($application->isSite() && $params->get('K2UserProfile') == 'native' && in_array($name, $forms)) {
// Add K2 profile fields to the form
JForm::addFormPath(__DIR__ . '/forms');
$form->loadFile('profile', false);
}
// Return
return true;
}
示例15: 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
*/
public function onContentPrepareForm($form, $data)
{
if (!$form instanceof JForm) {
$this->_subject->setError('JERROR_NOT_A_FORM');
return false;
}
// We only work with com_users.* and com_admin.profile:
$form_name = $form->getName();
if (!in_array($form_name, array('com_admin.profile', 'com_users.user', 'com_users.profile', 'com_users.registration'))) {
return true;
}
//JLog::add("onContentPrepareForm ".htmlentities($form_name));
$app = JFactory::getApplication();
if ($app->isSite() && $form_name == 'com_users.registration') {
$lang = JFactory::getLanguage()->getTag();
$form->removeField("email2");
$grpoptions = "";
foreach (explode(",", $this->params->get('altgroups')) as $grp) {
$grp = htmlentities(trim($grp));
$grpoptions .= " <option value=\"{$grp}\">" . ($lang == "ru-RU" ? "Я -" : "I'm") . " {$grp}</option>\n";
}
/* Append "altgroup.groupname" field to "default" fieldset
* so that it would be rendered in the same "block" as
* core user fields like "username/email/password": */
$form->load('<form>' . ' <fields name="altgroup">' . ' <fieldset name="default">' . ' <field name="groupname" type="radio"' . ' label=' . ($lang == "ru-RU" ? '"Кто вы?"' : '"Who are you?"') . ' required="true">' . $grpoptions . ' </field>' . ' </fieldset>' . ' </fields>' . '</form>');
/* JLog::add("input=".self::_str(
$form->getInput("groupname", "altgroup")));
JLog::add("form=".self::_str($form));*/
} elseif ($form_name == 'com_users.profile') {
$lang = JFactory::getLanguage()->getTag();
$form->removeField("email2");
$group_names = array();
if (isset($data->altgroup['groups'])) {
foreach ($data->altgroup['groups'] as $g) {
$group_names[] = $g[1];
}
}
/* Append "altgroup.groupnames" field to "core"
* fieldset: */
$form->load('<form>' . ' <fields name="altgroup">' . ' <fieldset name="core">' . ' <field name="groupnames" type="text"' . ' disabled="true"' . ' label=' . ($lang == "ru-RU" ? '"Вы:"' : '"You are:"') . ' default="' . htmlentities(implode(", ", $group_names)) . '"' . ' />' . ' </fieldset>' . ' </fields>' . '</form>');
}
return true;
}