本文整理汇总了PHP中JFormHelper类的典型用法代码示例。如果您正苦于以下问题:PHP JFormHelper类的具体用法?PHP JFormHelper怎么用?PHP JFormHelper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了JFormHelper类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: loadField
/**
* Method to load, setup and return a JFormField object based on field data.
*
* @param string $element The XML element object representation of the form field.
* @param string $group The optional dot-separated form group path on which to find the field.
* @param mixed $value The optional value to use as the default for the field.
*
* @return mixed The JFormField object for the field or boolean false on error.
*
* @since 11.1
*/
protected function loadField($element, $group = null, $value = null)
{
// Get the field type.
$type = $element['type'] ? (string) $element['type'] : 'text';
// Load the JFormField object for the field.
/** @var $field JFormField */
$field = JFormHelper::loadFieldType($type, true);
// If the object could not be loaded, get a text field object.
if ($field === false) {
$field = JFormHelper::loadFieldType('text', true);
}
// Get the value for the form field if not set.
// Default to the translated version of the 'default' attribute
// if 'translate_default' attribute if set to 'true' or '1'
// else the value of the 'default' attribute for the field.
if ($value === null) {
$default = (string) $element['default'];
if (($translate = $element['translate_default']) && ((string) $translate == 'true' || (string) $translate == '1')) {
$lang = JFactory::getLanguage();
if ($lang->hasKey($default)) {
$debug = $lang->setDebug(false);
$default = JText::_($default);
$lang->setDebug($debug);
} else {
$default = JText::_($default);
}
}
}
if ($field->setup($element, $value, $group)) {
return $field;
} else {
return false;
}
}
开发者ID:networksoft,项目名称:networksoft.com.co,代码行数:45,代码来源:JoomlaFieldWrapper.php
示例2: renderInput
function renderInput($values = null, $options = array())
{
if (!$this->_isCompatible) {
return '';
}
$tags = array();
if (!empty($values)) {
foreach ($values as $v) {
if (is_object($v)) {
$tags[] = $v->tag_id;
} else {
$tags[] = (int) $v;
}
}
}
if (empty($options['name'])) {
$options['name'] = 'tags';
}
if (empty($options['mode'])) {
$options['mode'] = 'ajax';
}
if (!isset($options['class'])) {
$options['class'] = 'inputbox span12 small';
}
if (!isset($options['multiple'])) {
$options['multiple'] = true;
}
$xmlConf = new SimpleXMLElement('<field name="' . $options['name'] . '" type="tag" mode="' . $options['mode'] . '" label="" class="' . $options['class'] . '" multiple="' . ($options['multiple'] ? 'true' : 'false') . '"></field>');
JFormHelper::loadFieldClass('tag');
$jform = new JForm('hikashop');
$fieldTag = new JFormFieldTag();
$fieldTag->setForm($jform);
$fieldTag->setup($xmlConf, $tags);
return $fieldTag->input;
}
开发者ID:q0821,项目名称:esportshop,代码行数:35,代码来源:tags.php
示例3: getField
public function getField($type, $attributes = array(), $field_value = '')
{
static $types = null;
$defaults = array('name' => '', 'id' => '');
if (!$types) {
jimport('joomla.form.helper');
$types = array();
}
if (!in_array($type, $types)) {
JFormHelper::loadFieldClass($type);
}
try {
$attributes = array_merge($defaults, $attributes);
$xml = new JXMLElement('<?xml version="1.0" encoding="utf-8"?><field />');
foreach ($attributes as $key => $value) {
if ('_options' == $key) {
foreach ($value as $_opt_value) {
$xml->addChild('option', $_opt_value->text)->addAttribute('value', $_opt_value->value);
}
continue;
}
$xml->addAttribute($key, $value);
}
$class = 'JFormField' . $type;
$field = new $class();
$field->setup($xml, $field_value);
return $field;
} catch (Exception $e) {
return false;
}
}
开发者ID:rcorral,项目名称:com_jm,代码行数:31,代码来源:helper.php
示例4: createStatuses
public static function createStatuses()
{
$app = JFactory::getApplication();
$filter_steps = $app->getUserStateFromRequest('com_imc.issues.filter.steps', 'steps', array());
//get issue statuses
JFormHelper::addFieldPath(JPATH_ROOT . '/components/com_imc/models/fields');
$step = JFormHelper::loadFieldType('Step', false);
$statuses = $step->getOptions();
if (empty($filter_steps)) {
$str = '<ul class="imc_ulist imc_ulist_inline">';
foreach ($statuses as $status) {
$str .= '<li>';
$str .= '<input type="checkbox" name="steps[]" value="' . $status->value . '" ' . 'checked="checked"' . '>';
$str .= '<span class="root">' . ' ' . $status->text . '</span>';
$str .= '</li>';
}
$str .= '</ul>';
} else {
$str = '<ul class="imc_ulist imc_ulist_inline">';
foreach ($statuses as $status) {
$str .= '<li>';
$str .= '<input type="checkbox" name="steps[]" value="' . $status->value . '" ' . (in_array($status->value, $filter_steps) ? 'checked="checked"' : '') . '>';
$str .= '<span class="root">' . ' ' . $status->text . '</span>';
$str .= '</li>';
}
$str .= '</ul>';
}
return $str;
}
开发者ID:Ricardolau,项目名称:imc,代码行数:29,代码来源:helper.php
示例5: display
function display($tpl = null)
{
JFormHelper::addFormPath(JPATH_ADMINISTRATOR . '/components/com_j2store/models/forms');
JFormHelper::addFieldPath(JPATH_ADMINISTRATOR . '/components/com_j2store/models/fields');
$this->form = JForm::getInstance('storeprofile', 'storeprofile');
$this->addToolBar();
parent::display();
}
开发者ID:ForAEdesWeb,项目名称:AEW4,代码行数:8,代码来源:view.html.php
示例6: getInput
/**
* Method to get the field input markup.
*
* @return string The field input markup.
* @since 1.6
*/
protected function getInput()
{
// use as type here the default basic data field type (as example: Text/Calendar/Textarea/Editor)
// see http://docs.joomla.org/Standard_form_field_types
$field = JFormHelper::loadFieldType('Calendar');
$field->setForm($this->form);
$field->setup($this->element, $this->value);
return $field->getInput();
}
开发者ID:madcsaba,项目名称:li-de,代码行数:15,代码来源:jdcustomfield11.php
示例7: display
/**
* display method of Cp view
* @return void
**/
function display($tpl = null)
{
// Initialiase variables.
$this->form = $this->get('Form');
$this->item = $this->get('Item');
$this->state = $this->get('State');
// Check for errors.
if (count($errors = $this->get('Errors'))) {
JError::raiseError(500, implode("\n", $errors));
return false;
}
JRequest::setVar('hidemainmenu', true);
$user = JFactory::getUser();
$isNew = empty($this->item->product_id);
$document = JFactory::getDocument();
if (JRequest::getVar('tmpl', '') != 'component') {
$document->addScript(JURI::base(true) . '/components/com_cp/assets/js/jquery-1.10.1.min.js');
$document->addScriptDeclaration('jQuery.noConflict();');
$document->addScript(JURI::base(true) . '/components/com_cp/assets/js/jquery-ui-1.10.3.custom.min.js');
$document->addScript(JURI::base(true) . '/components/com_cp/assets/js/scripts.js');
$document->addStyleSheet(JURI::base(true) . '/components/com_cp/assets/css/style.css');
$document->addStyleSheet(JURI::base(true) . '/components/com_cp/assets/css/smoothness/jquery-ui-1.8.21.custom.css');
$document->addStyleDeclaration('body { min-width: 1170px; }');
}
// Create the form
JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields');
$text = $isNew ? JText::_('COM_CP_NEW') : JText::_('COM_CP_EDIT');
JToolBarHelper::title($text . ' ' . JText::_('COM_CP_PRODUCT_PAGE_TITLE'));
if ($isNew && $user->authorise('core.create', 'com_cp')) {
JToolBarHelper::apply('cpproducts.apply');
JToolBarHelper::save('cpproducts.save');
JToolBarHelper::save2new('cpproducts.save2new');
JToolBarHelper::cancel('cpproducts.cancel');
} else {
if ($user->authorise('core.edit', 'com_cp')) {
JToolBarHelper::apply('cpproducts.apply');
JToolBarHelper::save('cpproducts.save');
if ($user->authorise('core.edit', 'com_cp')) {
JToolBarHelper::save2new('cpproducts.save2new');
}
JToolBarHelper::cancel('cpproducts.cancel', 'COM_CP_CLOSE');
}
}
$helper = new CPHelper();
if ($isNew) {
$countFiles = 0;
} else {
$countFiles = count($this->item->media);
}
// Initialize media files script
$document->addScriptDeclaration('var mediaCount = ' . $countFiles . '; var delText = "' . JText::_('COM_CP_DELETE') . '"; var siteURL = "' . JURI::root() . '";');
$params = JComponentHelper::getParams('com_cp');
$this->assignRef('params', $params);
$this->item->cities = $helper->listCities($this->item->country_code, $this->item->city, 'jform[city]', 'jform_city');
parent::display($tpl);
}
开发者ID:jmangarret,项目名称:webtuagencia24,代码行数:60,代码来源:view.html.php
示例8: __construct
public function __construct(&$subject, $config)
{
if (!class_exists('joomlamailerMCAPI')) {
return;
}
parent::__construct($subject, $config);
JFormHelper::addFieldPath(__DIR__ . '/fields');
$this->api = $this->getApiInstance();
$this->debug = JFactory::getConfig()->get('debug');
$this->listId = $this->params->get('listid');
}
开发者ID:rodhoff,项目名称:MNW,代码行数:11,代码来源:joomlamailer.php
示例9: populateState
protected function populateState($ordering = null, $direction = null)
{
$search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search');
$this->setState('filter.search', $search);
$published = $this->getUserStateFromRequest($this->context . '.filter.state', 'filter_state', '', 'string');
$this->setState('filter.state', $published);
JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields');
$catID = $this->getUserStateFromRequest($this->context . '.filter.category', 'filter_category');
$this->setState('filter.category', $catID);
$visibility = $this->getUserStateFromRequest($this->context . '.filter.visibility', 'filter_visibility');
$this->setState('filter.category', $visibility);
parent::populateState('a.ordering', 'asc');
}
开发者ID:gmansillo,项目名称:simplefilemanager,代码行数:13,代码来源:simplefilemanagers.php
示例10: displayAll
function displayAll($id, $map, $color)
{
if (HIKASHOP_J25) {
$xmlConf = new SimpleXMLElement('<field name="' . $map . '" type="color" label=""></field>');
JFormHelper::loadFieldClass('color');
$jform = new JForm('hikashop');
$fieldTag = new JFormFieldColor();
$fieldTag->setForm($jform);
$fieldTag->setup($xmlConf, $color);
return $fieldTag->input;
}
$code = '<input type="text" name="' . $map . '" id="color' . $id . '" onchange=\'applyColorExample' . $id . '()\' class="inputbox" size="10" value="' . $color . '" />' . ' <input size="10" maxlength="0" style=\'cursor:pointer;background-color:' . $color . '\' onclick="if(document.getElementById(\'colordiv' . $id . '\').style.display == \'block\'){document.getElementById(\'colordiv' . $id . '\').style.display = \'none\';}else{document.getElementById(\'colordiv' . $id . '\').style.display = \'block\';}" id=\'colorexample' . $id . '\' />' . '<div id=\'colordiv' . $id . '\' style=\'display:none;position:absolute;background-color:white;border:1px solid grey;z-index:999\'>' . $this->display($id) . '</div>';
return $code;
}
开发者ID:rodhoff,项目名称:MNW,代码行数:14,代码来源:color.php
示例11: getInput
/**
* Method to get the field input markup.
*
* @return string The field input markup.
* @since 1.6
*/
protected function getInput()
{
global $jlistConfig;
$app = JFactory::getApplication();
JHtml::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR . '/helpers');
JHtml::addIncludePath(JPATH_COMPONENT . '/helpers');
$field = JFormHelper::loadFieldType('Text');
$field->setForm($this->form);
if ($this->value != '') {
$field->setup($this->element, $this->value);
} else {
$field->setup($this->element, htmlspecialchars(trim($jlistConfig['custom.field.10.values']), ENT_COMPAT, 'UTF-8'));
}
return $field->getInput();
}
开发者ID:madcsaba,项目名称:li-de,代码行数:21,代码来源:jdcustomfield10.php
示例12: getField
/**
* Method to get the HTML of a certain field
*
* @param null
* @return string
*/
public static function getField($type, $name, $value = null, $array = 'magebridge')
{
jimport('joomla.form.helper');
jimport('joomla.form.form');
$fileType = preg_replace('/^magebridge\\./', '', $type);
include_once JPATH_ADMINISTRATOR . '/components/com_magebridge/fields/' . $fileType . '.php';
$form = new JForm('magebridge');
$field = JFormHelper::loadFieldType($type);
if (is_object($field) == false) {
$message = JText::sprintf('COM_MAGEBRIDGE_UNKNOWN_FIELD', $type);
JFactory::getApplication()->enqueueMessage($message, 'error');
return null;
}
$field->setName($name);
$field->setValue($value);
return $field->getHtmlInput();
}
开发者ID:apiceweb,项目名称:MageBridgeCore,代码行数:23,代码来源:form.php
示例13: onAfterInitialise
/**
* Method to register custom library.
*
* @return void
*/
public function onAfterInitialise()
{
if (!$this->isRedcoreComponent()) {
return;
}
$redcoreLoader = JPATH_LIBRARIES . '/redcore/bootstrap.php';
if (file_exists($redcoreLoader)) {
require_once $redcoreLoader;
// For Joomla! 2.5 compatibility we add some core functions
if (version_compare(JVERSION, '3.0', '<')) {
RLoader::registerPrefix('J', JPATH_LIBRARIES . '/redcore/joomla', false, true);
}
}
// Make available the fields
JFormHelper::addFieldPath(JPATH_LIBRARIES . '/redcore/form/fields');
// Make available the rules
JFormHelper::addRulePath(JPATH_LIBRARIES . '/redcore/form/rules');
}
开发者ID:prox91,项目名称:joomla-dev,代码行数:23,代码来源:redcore.php
示例14: getItems
function getItems()
{
$items = array();
foreach ($this->element->children() as $element) {
// clone element to make it as field
$fdata = preg_replace('/<(\\/?)item(\\s|>)/mi', '<\\1field\\2', $element->asXML());
$felement = new SimpleXMLElement($fdata);
$field = JFormHelper::loadFieldType((string) $felement['type']);
if ($field === false) {
$field = JFormHelper::loadFieldType('text');
}
// Setup the JFormField object.
$field->setForm($this->form);
if ($field->setup($felement, null, $this->group . '.' . $this->fieldname)) {
$items[] = $field;
}
}
return $items;
}
开发者ID:anawu2006,项目名称:PeerLearning,代码行数:19,代码来源:jaitems.php
示例15: onAfterInitialise
/**
* Method to register custom library.
*
* @return void
*/
public function onAfterInitialise()
{
$isAdmin = JFactory::getApplication()->isAdmin();
if (!$isAdmin || !$this->isRedradComponent()) {
return;
}
$redradLoader = JPATH_LIBRARIES . '/redrad/bootstrap.php';
if (file_exists($redradLoader) && !class_exists('Inflector')) {
require_once $redradLoader;
// For Joomla! 2.5 compatibility we add some core functions
if (version_compare(JVERSION, '3.0', '<')) {
RLoader::registerPrefix('J', JPATH_LIBRARIES . '/redrad/joomla', false, true);
}
}
// Make available the fields
JFormHelper::addFieldPath(JPATH_LIBRARIES . '/redrad/form/fields');
// Make available the rules
JFormHelper::addRulePath(JPATH_LIBRARIES . '/redrad/form/rules');
}
开发者ID:prox91,项目名称:joomla-dev,代码行数:24,代码来源:redrad.php
示例16: testConstruct
/**
* Tests the JForm::__construct method
*/
public function testConstruct()
{
$form = new JForm('form1');
$this->assertThat($form->load(JFormDataHelper::$loadFieldDocument), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.');
$field = new JFormFieldInspector($form);
$this->assertThat($field instanceof JFormField, $this->isTrue(), 'Line:' . __LINE__ . ' The JFormField constuctor should return a JFormField object.');
$this->assertThat($field->getForm(), $this->identicalTo($form), 'Line:' . __LINE__ . ' The internal form should be identical to the variable passed in the contructor.');
// Add custom path.
JForm::addFieldPath(__DIR__ . '/_testfields');
JFormHelper::loadFieldType('foo.bar');
$field = new FooFormFieldBar($form);
$this->assertEquals($field->type, 'FooBar', 'Line:' . __LINE__ . ' The field type should have been guessed by the constructor.');
JFormHelper::loadFieldType('foo');
$field = new JFormFieldFoo($form);
$this->assertEquals($field->type, 'Foo', 'Line:' . __LINE__ . ' The field type should have been guessed by the constructor.');
JFormHelper::loadFieldType('modal_foo');
$field = new JFormFieldModal_Foo($form);
$this->assertEquals($field->type, 'Modal_Foo', 'Line:' . __LINE__ . ' The field type should have been guessed by the constructor.');
}
开发者ID:n3t,项目名称:joomla-platform,代码行数:22,代码来源:JFormFieldTest.php
示例17: getField
public static function getField($type, $name, $value = null, $array = 'magebridge')
{
if (MageBridgeHelper::isJoomla15()) {
require_once JPATH_ADMINISTRATOR . '/components/com_magebridge/elements/' . $type . '.php';
$fake = null;
$class = 'JElement' . ucfirst($type);
$object = new $class();
return call_user_func(array($object, 'fetchElement'), $name, $value, $fake, $array);
} else {
jimport('joomla.form.helper');
jimport('joomla.form.form');
require_once JPATH_ADMINISTRATOR . '/components/com_magebridge/fields/' . $type . '.php';
$form = new JForm('magebridge');
$field = JFormHelper::loadFieldType($type);
$field->setName($name);
$field->setValue($value);
return $field->getHtmlInput();
}
}
开发者ID:traveladviser,项目名称:magebridge-mirror,代码行数:19,代码来源:form.php
示例18: addToolbar
protected function addToolbar()
{
$state = $this->get('State');
$canDo = SimplefilemanagerHelper::getActions($state->get('filter.category_id'));
$user = JFactory::getUser();
$bar = JToolBar::getInstance('toolbar');
JToolbarHelper::title(JText::_('COM_SIMPLEFILEMANAGER_MANAGER_SIMPLEFILEMANAGERS'), 'file-2');
// User should be authorized to publish at least in a category
if ($canDo->get('core.create') && count($user->getAuthorisedCategories('com_simplefilemanager', 'core.create')) > 0) {
JToolbarHelper::addNew('simplefilemanager.add');
}
if ($canDo->get('core.edit')) {
JToolbarHelper::editList('simplefilemanager.edit');
}
if ($canDo->get('core.edit.state')) {
JToolbarHelper::publish('simplefilemanagers.publish', 'JTOOLBAR_PUBLISH', true);
JToolbarHelper::unpublish('simplefilemanagers.unpublish', 'JTOOLBAR_UNPUBLISH', true);
JToolbarHelper::archiveList('simplefilemanagers.archive');
JToolbarHelper::checkin('simplefilemanagers.checkin');
}
$state = $this->get('State');
if ($state->get('filter.state') == -2 && $canDo->get('core.delete')) {
JToolbarHelper::deleteList('', 'simplefilemanagers.delete', 'JTOOLBAR_EMPTY_TRASH');
} elseif ($canDo->get('core.edit.state')) {
JToolbarHelper::trash('simplefilemanagers.trash');
}
if ($canDo->get('core.admin')) {
JToolbarHelper::preferences('com_simplefilemanager');
}
JToolBarHelper::help('COM_SIMPLEFILEMANAGER_HELP_VIEW_SIMPLEFILEMANANGERS', false, 'http://www.simplefilemanager.eu/support');
JHtmlSidebar::setAction('index.php?option=com_simplefilemanager&view=simplefilemanagers');
JHtmlSidebar::addFilter(JText::_('JOPTION_SELECT_PUBLISHED'), 'filter_state', JHtml::_('select.options', JHtml::_('jgrid.publishedOptions'), 'value', 'text', $this->state->get('filter.state'), true));
$this->category = JFormHelper::loadFieldType('catid', false);
$this->categoryOptions = $this->category->getOptions();
JHtmlSidebar::addFilter(JText::_('JOPTION_SELECT_CATEGORY'), 'filter_category', JHtml::_('select.options', $this->categoryOptions, 'value', 'text', $this->state->get('filter.category')));
$this->visibilityOptions = array(1 => JText::_('COM_SIMPLEFILEMANAGER_VISIBILITY_PUBLIC'), 2 => JText::_('COM_SIMPLEFILEMANAGER_VISIBILITY_REGISTRED'), 3 => JText::_('COM_SIMPLEFILEMANAGER_VISIBILITY_USER'), 4 => JText::_('COM_SIMPLEFILEMANAGER_VISIBILITY_GROUP'), 5 => JText::_('COM_SIMPLEFILEMANAGER_VISIBILITY_AUTHOR'));
JHtmlSidebar::addFilter(JText::_('JOPTION_SELECT_VISIBILITY'), 'filter_visibility', JHtml::_('select.options', $this->visibilityOptions, 'value', 'text', $this->state->get('filter.visibility')));
}
开发者ID:gmansillo,项目名称:simplefilemanager,代码行数:38,代码来源:view.html.php
示例19: element
/**
* $type, $domId, $value, $options = array(), $formName = null, $disabled = false
*/
public static function element()
{
list($type, $domId, $value, $options) = func_get_args();
$options = (array) $options;
// Load the JFormField object for the field.
JFormHelper::addFieldPath(JPATH_COMPONENT_ADMINISTRATOR . DS . 'models' . DS . 'fields');
$field = JFormHelper::loadFieldType($type, true);
// If the object could not be loaded, get a text field object.
if ($field === false) {
throw new Exception('Cannot load field type ' . $type);
}
$element = new JXMLElement('<field></field>');
$element->addAttribute('id', $domId);
if (!empty($options)) {
foreach ($options as $name => $val) {
$element->addAttribute($name, $val);
}
}
if (!$field->setup($element, $value, null)) {
throw new Exception('Cannot setup field ' . $type);
}
return $field->input;
}
开发者ID:Rikisha,项目名称:proj,代码行数:26,代码来源:migurform.php
示例20: getItems
function getItems()
{
$items = array();
foreach ($this->element->children() as $element) {
// clone element to make it as field
$fdata = preg_replace('/<(\\/?)item(\\s|>)/mi', '<\\1field\\2', $element->asXML());
// remove cols, rows, size attributes
$fdata = preg_replace('/\\s(cols|rows|size)=(\'|")\\d+(\'|")/mi', '', $fdata);
// change type text to textarea
$fdata = str_replace('type="text"', 'type="textarea"', $fdata);
$felement = new JXMLElement($fdata);
$field = JFormHelper::loadFieldType((string) $felement['type']);
if ($field === false) {
$field = $this->loadFieldType('text');
}
// Setup the JFormField object.
$field->setForm($this->form);
if ($field->setup($felement, null, $this->name)) {
$items[] = $field;
}
}
return $items;
}
开发者ID:brenot,项目名称:forumdesenvolvimento,代码行数:23,代码来源:jafield.php
注:本文中的JFormHelper类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论