Example #1
0
 /**
  * Метод для отображения формы вопроса
  * @param unknown_type $tpl
  */
 public function display($tpl = null)
 {
     $catid = JRequest::getInt('catid', null, 'GET');
     if (!$catid) {
         throw new Exception('Category id not set');
     }
     JForm::addFormPath('components/com_smfaq/models/forms');
     JForm::addFieldPath('components/com_smfaq/models/fields');
     $form = JForm::getInstance('question', 'question');
     $categories = JCategories::getInstance('SmFaq');
     $category = $categories->get($catid);
     $params = $category->getParams();
     if ($layout = $params->get('category_layout')) {
         $this->setLayout($layout);
     }
     JPluginHelper::importPlugin('smfaq');
     $dispatcher = JDispatcher::getInstance();
     $results = $dispatcher->trigger('onPrepareForm', array($form));
     // Check for errors encountered while preparing the form.
     if (count($results) && in_array(false, $results, true)) {
         // Get the last error.
         $error = $dispatcher->getError();
         if (!$error instanceof Exception) {
             throw new Exception($error);
         }
     }
     $this->assignRef('form', $form);
     $this->assignRef('params', $params);
     $this->assignRef('category', $category);
     parent::display($tpl);
 }
Example #2
0
 /**
  * Method to get the row form.
  *
  * @return  mixed  JForm object on success, false on failure.
  */
 public function getForm()
 {
     // Initialise variables.
     $app = JFactory::getApplication();
     // Get the form.
     jimport('joomla.form.form');
     JForm::addFormPath(JPATH_COMPONENT . '/models/forms');
     JForm::addFieldPath(JPATH_COMPONENT . '/models/fields');
     $form = JForm::getInstance('com_localise.languages', 'languages', array('control' => 'filters', 'event' => 'onPrepareForm'));
     // Check for an error.
     if (JError::isError($form)) {
         $this->setError($form->getMessage());
         return false;
     }
     // Check the session for previously entered form data.
     $data = $app->getUserState('com_localise.select', array());
     // Bind the form data if present.
     if (!empty($data)) {
         $form->bind(array('select' => $data));
     }
     // Check the session for previously entered form data.
     $data = $app->getUserState('com_localise.languages.search', array());
     // Bind the form data if present.
     if (!empty($data)) {
         $form->bind(array('search' => $data));
     }
     return $form;
 }
Example #3
0
 public function onContentPrepareForm($form, $data)
 {
     $app = JFactory::getApplication();
     if (!$app->isAdmin()) {
         return;
     }
     $option = JFactory::getApplication()->input->getWord('option');
     $layout = JFactory::getApplication()->input->getWord('layout');
     $view = JFactory::getApplication()->input->getWord('view');
     $task = JFactory::getApplication()->input->getWord('task');
     $id = JFactory::getApplication()->input->getInt('id');
     $module = $this->getModuleType($data);
     if (in_array($option, array('com_modules', 'com_advancedmodules')) && $layout == 'edit' && $module == 'mod_rokminievents3') {
         JForm::addFieldPath(JPATH_ROOT . '/modules/mod_rokminievents3/fields');
         //Find Sources
         $sources = RokMiniEvents3_SourceLoader::getAvailableSources(self::$SOURCE_DIR);
         foreach ($sources as $source_name => $source) {
             if (file_exists($source->paramspath) && is_readable($source->paramspath)) {
                 $form->loadFile($source->paramspath, false);
                 JForm::addFieldPath(dirname($source->paramspath) . "/" . $source->name);
                 //$this->element_dirs[] = dirname($source->paramspath) . "/" . $source->name;
                 $language = JFactory::getLanguage();
                 $language->load('com_' . $source->name, JPATH_ADMINISTRATOR);
                 $language->load($source->name, dirname($source->paramspath), $language->getTag(), true);
             }
         }
         $subfieldform = RokSubfieldForm::getInstanceFromForm($form);
         if (!empty($data) && isset($data->params)) {
             $subfieldform->setOriginalParams($data->params);
         }
         if ($task == 'save' || $task == 'apply') {
             $subfieldform->makeSubfieldsVisable();
         }
     }
 }
Example #4
0
 function display($tpl = null)
 {
     // Load the helper(s)
     $this->addHelperPath(VMPATH_ADMIN . DS . 'helpers');
     if (!class_exists('vmPSPlugin')) {
         require VMPATH_PLUGINLIBS . DS . 'vmpsplugin.php';
     }
     if (!class_exists('VmHTML')) {
         require VMPATH_ADMIN . DS . 'helpers' . DS . 'html.php';
     }
     $model = VmModel::getModel();
     $layoutName = vRequest::getCmd('layout', 'default');
     $this->SetViewTitle();
     $layoutName = vRequest::getCmd('layout', 'default');
     if ($layoutName == 'edit') {
         VmConfig::loadJLang('plg_vmpsplugin', false);
         JForm::addFieldPath(VMPATH_ADMIN . DS . 'fields');
         $shipment = $model->getShipment();
         // Get the payment XML.
         $formFile = vRequest::filterPath(VMPATH_ROOT . DS . 'plugins' . DS . 'vmshipment' . DS . $shipment->shipment_element . DS . $shipment->shipment_element . '.xml');
         if (file_exists($formFile)) {
             $shipment->form = JForm::getInstance($shipment->shipment_element, $formFile, array(), false, '//vmconfig | //config[not(//vmconfig)]');
             $shipment->params = new stdClass();
             $varsToPush = vmPlugin::getVarsToPushFromForm($shipment->form);
             VmTable::bindParameterableToSubField($shipment, $varsToPush);
             $shipment->form->bind($shipment->getProperties());
         } else {
             $shipment->form = null;
         }
         if (!class_exists('VmImage')) {
             require VMPATH_ADMIN . DS . 'helpers' . DS . 'image.php';
         }
         if (!class_exists('VirtueMartModelVendor')) {
             require VMPATH_ADMIN . DS . 'models' . DS . 'vendor.php';
         }
         $vendor_id = 1;
         $currency = VirtueMartModelVendor::getVendorCurrency($vendor_id);
         $this->assignRef('vendor_currency', $currency->currency_symbol);
         if ($this->showVendors()) {
             $vendorList = ShopFunctions::renderVendorList($shipment->virtuemart_vendor_id);
             $this->assignRef('vendorList', $vendorList);
         }
         $this->pluginList = self::renderInstalledShipmentPlugins($shipment->shipment_jplugin_id);
         $this->assignRef('shipment', $shipment);
         $this->shopperGroupList = ShopFunctions::renderShopperGroupList($shipment->virtuemart_shoppergroup_ids, true);
         $this->addStandardEditViewCommands($shipment->virtuemart_shipmentmethod_id);
     } else {
         JToolBarHelper::custom('cloneshipment', 'copy', 'copy', vmText::_('COM_VIRTUEMART_SHIPMENT_CLONE'), true);
         $this->addStandardDefaultViewCommands();
         $this->addStandardDefaultViewLists($model);
         $this->shipments = $model->getShipments();
         VmConfig::loadJLang('com_virtuemart_shoppers', TRUE);
         foreach ($this->shipments as &$data) {
             // Write the first 5 shoppergroups in the list
             $data->shipmentShoppersList = shopfunctions::renderGuiList($data->virtuemart_shoppergroup_ids, 'shoppergroups', 'shopper_group_name', 'shopper');
         }
         $this->pagination = $model->getPagination();
     }
     parent::display($tpl);
 }
Example #5
0
 /**
  * Method to get the record form.
  *
  * @param   array    $data      Data for the form.
  * @param   boolean  $loadData  True if the form is to load its own data (default case), false if not.
  *
  * @return  JForm    A JForm object on success, false on failure.
  *
  * @since   1.6
  */
 public function getForm($data = array(), $loadData = true)
 {
     // The folder and element vars are passed when saving the form.
     if (empty($data)) {
         $item = $this->getItem();
         $folder = $item->folder;
         $element = $item->element;
     } else {
         $folder = ArrayHelper::getValue($data, 'folder', '', 'cmd');
         $element = ArrayHelper::getValue($data, 'element', '', 'cmd');
     }
     // Add the default fields directory
     JForm::addFieldPath(JPATH_PLUGINS . '/' . $folder . '/' . $element . '/field');
     // These variables are used to add data from the plugin XML files.
     $this->setState('item.folder', $folder);
     $this->setState('item.element', $element);
     // Get the form.
     $form = $this->loadForm('com_plugins.plugin', 'plugin', array('control' => 'jform', 'load_data' => $loadData));
     if (empty($form)) {
         return false;
     }
     // Modify the form based on access controls.
     if (!$this->canEditState((object) $data)) {
         // Disable fields for display.
         $form->setFieldAttribute('ordering', 'disabled', 'true');
         $form->setFieldAttribute('enabled', 'disabled', 'true');
         // Disable fields while saving.
         // The controller has already verified this is a record you can edit.
         $form->setFieldAttribute('ordering', 'filter', 'unset');
         $form->setFieldAttribute('enabled', 'filter', 'unset');
     }
     return $form;
 }
Example #6
0
 /**
  * This method prepares a payment gateway - buttons, forms,...
  * That gateway will be displayed on the summary page as a payment option.
  *
  * @param string    $context This string gives information about that where it has been executed the trigger.
  * @param object    $item    A project data.
  * @param Joomla\Registry\Registry $params  The parameters of the component
  *
  * @return null|string
  */
 public function onPaymentExtras($context, &$item, &$params)
 {
     if (strcmp("com_crowdfunding.payment.step2", $context) != 0) {
         return null;
     }
     if ($this->app->isAdmin()) {
         return null;
     }
     $doc = JFactory::getDocument();
     /**  @var $doc JDocumentHtml */
     // Check document type
     $docType = $doc->getType();
     if (strcmp("html", $docType) != 0) {
         return null;
     }
     // Load language file of the component.
     $language = JFactory::getLanguage();
     $language->load('com_crowdfundingdata', CROWDFUNDINGDATA_PATH_COMPONENT_SITE);
     $componentParams = JComponentHelper::getParams("com_crowdfunding");
     /** @var  $componentParams Joomla\Registry\Registry */
     // Get payment session.
     $paymentSessionContext = Crowdfunding\Constants::PAYMENT_SESSION_CONTEXT . $item->id;
     $paymentSession = $this->app->getUserState($paymentSessionContext);
     if (!isset($paymentSession->step1)) {
         $path = JPath::clean(JPluginHelper::getLayoutPath('crowdfundingpayment', 'data', 'error'));
         // Render error layout.
         ob_start();
         include $path;
         return ob_get_clean();
     }
     // Get the value of therms and conditions.
     $this->terms = $paymentSession->terms;
     // Check for duplication of session ID.
     $this->prepareSessionId($item);
     // Load the form.
     JForm::addFormPath(CROWDFUNDINGDATA_PATH_COMPONENT_SITE . '/models/forms');
     JForm::addFieldPath(CROWDFUNDINGDATA_PATH_COMPONENT_SITE . '/models/fields');
     $form = JForm::getInstance('com_crowdfundingdata.record', 'record', array('control' => "jform", 'load_data' => false));
     // Prepare default name of a user.
     $user = JFactory::getUser();
     if ($user->get("id")) {
         $form->setValue("name", null, $user->get("name"));
     }
     // Set item id to the form.
     $form->setValue("project_id", null, $item->id);
     $this->form = $form;
     // Load jQuery
     JHtml::_("jquery.framework");
     // Include Chosen
     if ($this->params->get("enable_chosen", 0)) {
         JHtml::_('formbehavior.chosen', '#jform_country_id');
     }
     // Get the path for the layout file
     $path = JPath::clean(JPluginHelper::getLayoutPath('crowdfundingpayment', 'data'));
     // Render the form.
     ob_start();
     include $path;
     $html = ob_get_clean();
     return $html;
 }
Example #7
0
 protected function getInput()
 {
     $html = '';
     if ($this->form->getValue('params.provider_type') && $this->form->getValue('params.widget_type') != 'widget') {
         SCStringUtilities::loadLanguage('com_jfbconnect', JPATH_ADMINISTRATOR);
         JForm::addFieldPath(JPATH_ROOT . '/components/com_jfbconnect/libraries/provider/' . $this->form->getValue('params.provider_type') . '/widget');
         $xmlFile = JPATH_ROOT . '/components/com_jfbconnect/libraries/provider/' . $this->form->getValue('params.provider_type') . '/widget/' . $this->form->getValue('params.widget_type') . '.xml';
         if (JFile::exists($xmlFile)) {
             $options = array('control' => 'jform');
             $form = JForm::getInstance('com_jfbconnect_' . $this->form->getValue('params.widget_type'), $xmlFile, $options);
             $registry = $this->form->getValue('params');
             $settings = new JRegistry();
             $settings->set('params.widget_settings', $registry->widget_settings);
             $form->bind($settings);
             ob_start();
             foreach ($form->getFieldsets() as $fieldsets => $fieldset) {
                 foreach ($form->getFieldset($fieldset->name) as $field) {
                     $this->formShowField($field);
                 }
             }
             $html = ob_get_clean();
         }
     }
     return '<div id="widget_settings">' . $html . '</div>';
 }
 /**
  * Method to display the view.
  *
  * @param	string	The template file to include
  * @since	1.6
  */
 public function display($tpl = null)
 {
     //load required files
     JForm::addFormPath(JPATH_SITE . '/components/com_users/models/forms');
     JForm::addFieldPath(JPATH_SITE . '/components/com_users/models/fields');
     require_once JPATH_SITE . '/components/com_users/models/registration.php';
     //load com_users language
     $lang = JFactory::getLanguage();
     $lang->load('com_users');
     $model = JModelLegacy::getInstance('Registration', 'UsersModel');
     $app = JFactory::getApplication();
     // Get the view data.
     $this->data = $model->getData();
     $this->form = $model->getForm();
     //$this->state	= $model->get('State');
     $this->params = $app->getParams('com_hs_users');
     // Check for errors.
     if (count($errors = $model->get('Errors'))) {
         JError::raiseError(500, implode('<br />', $errors));
         return false;
     }
     // Check for layout override
     $active = JFactory::getApplication()->getMenu()->getActive();
     if (isset($active->query['layout'])) {
         $this->setLayout($active->query['layout']);
     }
     //Escape strings for HTML output
     $this->pageclass_sfx = htmlspecialchars($this->params->get('pageclass_sfx'));
     $this->prepareDocument();
     parent::display($tpl);
 }
Example #9
0
 /**
  * Method to get the link form.
  *
  * @return	mixed	JForm object on success, false on failure.
  * @since	1.6
  */
 public function getForm($view = null)
 {
     // Initialise variables.
     $false = false;
     if (!$view) {
         $view = JRequest::getWord('view', 'language');
     }
     // Get the form.
     jimport('joomla.form.form');
     JForm::addFormPath(JPATH_COMPONENT . '/models/forms');
     JForm::addFieldPath(JPATH_COMPONENT . '/models/fields');
     try {
         $form = JForm::getInstance('jform', $view, array('control' => 'jform'));
     } catch (Exception $e) {
         $this->setError($e->getMessage());
         return false;
     }
     // Check the session for previously entered form data.
     $data = (array) $this->getOptions();
     // Bind the form data if present.
     if (!empty($data)) {
         $form->bind($data);
     }
     return $form;
 }
 /**
  * Method to get the form.
  *
  * @param   string  $view  The view being processed
  *
  * @return  mixed  JForm object on success, false on failure.
  *
  * @since   3.1
  */
 public function getForm($view = null)
 {
     /* @var InstallationApplicationWeb $app */
     $app = JFactory::getApplication();
     if (!$view) {
         $view = $app->input->getWord('view', 'site');
     }
     // Get the form.
     JForm::addFormPath(JPATH_COMPONENT . '/model/forms');
     JForm::addFieldPath(JPATH_COMPONENT . '/model/fields');
     JForm::addRulePath(JPATH_COMPONENT . '/model/rules');
     try {
         $form = JForm::getInstance('jform', $view, array('control' => 'jform'));
     } catch (Exception $e) {
         $app->enqueueMessage($e->getMessage(), 'error');
         return false;
     }
     // Check the session for previously entered form data.
     $data = (array) $this->getOptions();
     // Bind the form data if present.
     if (!empty($data)) {
         $form->bind($data);
     }
     return $form;
 }
Example #11
0
 public function getForm($data = array(), $loadData = true)
 {
     JForm::addFormPath(JPATH_COMPONENT_ADMINISTRATOR . '/models/forms');
     JForm::addFieldPath(JPATH_COMPONENT_ADMINISTRATOR . '/models/fields');
     $form = parent::getForm($data, $loadData);
     return $form;
 }
Example #12
0
 /**
  * Render HTML Markup for administrator UI
  *
  * @return  string
  */
 public function render()
 {
     $adminFormXml = $this->_generateFormXML();
     // Create form instance
     $this->adminForm = new JForm('template-setting');
     $this->adminForm->addFieldPath(JSN_PATH_TPLFRAMEWORK . '/libraries/joomlashine/form/fields');
     $this->adminForm->load($adminFormXml->asXML());
     $params = $this->helper->loadParams($this->data->params, $this->data->template);
     // Bind value of parameters to form
     foreach ($params as $key => $value) {
         $this->adminForm->setValue($key, 'jsn', $value);
     }
     // Get Joomla application object
     $app = JFactory::getApplication();
     // Store current compression parameters
     $app->setUserState('jsn.template.maxCompressionSize', $params['maxCompressionSize']);
     $app->setUserState('jsn.template.cacheDirectory', $params['cacheDirectory']);
     // Start rendering
     ob_start();
     include JSN_PATH_TPLFRAMEWORK_LIBRARIES . '/template/tmpl/default.php';
     $body = ob_get_clean();
     // Detect method to use for getting and setting response body
     if (version_compare(JVERSION, '3.2.0', 'ge')) {
         $get = array($app, 'getBody');
         $set = array($app, 'setBody');
     } else {
         $get = array('JResponse', 'getBody');
         $set = array('JResponse', 'setBody');
     }
     // Parse current response body
     list($head, $tmp) = preg_split('/<form[^>]+name="adminForm"[^>]*>/', call_user_func($get), 2);
     list($tmp, $foot) = explode('</form>', $tmp, 2);
     // Replace current response body
     call_user_func($set, $head . $body . $foot);
 }
Example #13
0
	/**
	 * Load user form.
	 *
	 * @return void
	 */
	protected function before()
	{
		parent::before();

		$userParams = JComponentHelper::getParams('com_users');

		// Check if user is allowed to change his name.
		$this->changeUsername = $userParams->get('change_login_name', 1);

		// Check to see if Frontend User Params have been enabled.
		if ($userParams->get('frontend_userparams', 0))
		{
			JFactory::getLanguage()->load('com_users', JPATH_ADMINISTRATOR);

			JForm::addFormPath(JPATH_ROOT . '/components/com_users/models/forms');
			JForm::addFieldPath(JPATH_ROOT . '/components/com_users/models/fields');

			JPluginHelper::importPlugin('user');

			$registry = new JRegistry($this->user->params);
			$form = JForm::getInstance('com_users.profile', 'frontend');
			$data = new StdClass;
			$data->params = $registry->toArray();
			$dispatcher = JDispatcher::getInstance();
			$dispatcher->trigger('onContentPrepareForm', array($form, $data));

			$form->bind($data);
			$this->frontendForm = $form->getFieldset('params');
		}

		$this->headerText = JText::_('COM_KUNENA_PROFILE_EDIT_USER_TITLE');
	}
Example #14
0
 function display($tpl = null)
 {
     // Load the helper(s)
     if (!class_exists('VmHTML')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'html.php';
     }
     if (!class_exists('vmCustomPlugin')) {
         require JPATH_VM_PLUGINS . DS . 'vmcustomplugin.php';
     }
     $model = VmModel::getModel('custom');
     // TODO Make an Icon for custom
     $this->SetViewTitle('PRODUCT_CUSTOM_FIELD');
     $layoutName = vRequest::getCmd('layout', 'default');
     if ($layoutName == 'edit') {
         $this->addStandardEditViewCommands();
         $customPlugin = '';
         $this->custom = $model->getCustom();
         $customfields = VmModel::getModel('customfields');
         //vmdebug('VirtuemartViewCustom',$this->custom);
         JPluginHelper::importPlugin('vmcustom');
         $dispatcher = JDispatcher::getInstance();
         $retValue = $dispatcher->trigger('plgVmOnDisplayEdit', array($this->custom->virtuemart_custom_id, &$customPlugin));
         $this->SetViewTitle('PRODUCT_CUSTOM_FIELD', $this->custom->custom_title);
         $selected = 0;
         if (!empty($this->custom->custom_jplugin_id)) {
             VmConfig::loadJLang('plg_vmpsplugin', false);
             JForm::addFieldPath(JPATH_VM_ADMINISTRATOR . DS . 'fields');
             $selected = $this->custom->custom_jplugin_id;
             // Get the payment XML.
             $formFile = JPath::clean(JPATH_ROOT . DS . 'plugins' . DS . 'vmcustom' . DS . $this->custom->custom_element . DS . $this->custom->custom_element . '.xml');
             if (file_exists($formFile)) {
                 $this->custom->form = JForm::getInstance($this->custom->custom_element, $formFile, array(), false, '//vmconfig | //config[not(//vmconfig)]');
                 $this->custom->params = new stdClass();
                 $varsToPush = vmPlugin::getVarsToPushByXML($formFile, 'customForm');
                 $this->custom->params->custom_params = $this->custom->custom_params;
                 VmTable::bindParameterable($this->custom->params, 'custom_params', $varsToPush);
                 $this->custom->form->bind($this->custom);
             } else {
                 $this->custom->form = null;
             }
         }
         $this->pluginList = self::renderInstalledCustomPlugins($selected);
         $this->assignRef('customPlugin', $customPlugin);
         $this->assignRef('customfields', $customfields);
     } else {
         JToolBarHelper::custom('createClone', 'copy', 'copy', vmText::_('COM_VIRTUEMART_CLONE'), true);
         JToolBarHelper::custom('toggle.admin_only.1', 'publish', '', vmText::_('COM_VIRTUEMART_TOGGLE_ADMIN'), true);
         JToolBarHelper::custom('toggle.admin_only.0', 'unpublish', '', vmText::_('COM_VIRTUEMART_TOGGLE_ADMIN'), true);
         JToolBarHelper::custom('toggle.is_hidden.1', 'publish', '', vmText::_('COM_VIRTUEMART_TOGGLE_HIDDEN'), true);
         JToolBarHelper::custom('toggle.is_hidden.0', 'unpublish', '', vmText::_('COM_VIRTUEMART_TOGGLE_HIDDEN'), true);
         $this->addStandardDefaultViewCommands();
         $this->addStandardDefaultViewLists($model);
         $customs = $model->getCustoms(vRequest::getInt('custom_parent_id'), vRequest::getCmd('keyword'));
         $this->assignRef('customs', $customs);
         $pagination = $model->getPagination();
         $this->assignRef('pagination', $pagination);
     }
     parent::display($tpl);
 }
Example #15
0
 public function __construct($config = array())
 {
     JForm::addFieldPath(JPATH_ROOT . '/administrator/components/com_azurapagebuilder/models/fields');
     //JForm::addFormPath(JPATH_ROOT.'/templates/protostar/html/com_azurapagebuilder/forms');
     JForm::addFormPath(JPATH_ROOT . '/administrator/components/com_azurapagebuilder/models/forms');
     JForm::addFormPath(JPATH_THEMES . '/' . JFactory::getApplication()->getTemplate() . '/html/com_azurapagebuilder/forms');
     parent::__construct();
 }
Example #16
0
 /**
  * Registers the service provider with a DI container.
  *
  * @param   Container $container The DI container.
  *
  * @return  Container  Returns itself to support chaining.
  *
  * @since   1.0
  */
 public function register(Container $container)
 {
     $container->share('cck', function ($container) {
         return new CCKEngine($container->get('app'), $container->get('event.dispatcher'), $container);
     });
     \JForm::addFieldPath(__DIR__ . '/Fields');
     \JForm::addFormPath(__DIR__ . '/Resource/Form');
 }
 public function getForm($data = array(), $loadData = true)
 {
     JForm::addFieldPath(IG_ADMINISTRATOR_COMPONENT . '/models/fields');
     $form = $this->loadForm('com_igallery.editorbutton', IG_ADMINISTRATOR_COMPONENT . '/models/forms/editorbutton.xml', array('control' => 'jform', 'load_data' => $loadData));
     if (empty($form)) {
         return false;
     }
     return $form;
 }
Example #18
0
 public function onContentPrepareForm($form, $data)
 {
     $app = JFactory::getApplication();
     if (!$app->isAdmin()) {
         return;
     }
     $option = JRequest::getWord('option');
     $layout = JRequest::getWord('layout');
     $task = JRequest::getWord('task');
     $module = $this->getModuleType($data);
     if ($option == 'com_modules' && $layout == 'edit' && $module == 'mod_roknavmenu') {
         require_once JPATH_ROOT . '/modules/mod_roknavmenu/lib/RokNavMenu.php';
         require_once JPATH_ROOT . '/modules/mod_roknavmenu/lib/RokSubfieldForm.php';
         JForm::addFieldPath(JPATH_ROOT . '/modules/mod_roknavmenu/fields');
         RokNavMenu::loadCatalogs();
         foreach (RokNavMenu::$themes as $theme_name => $theme_info) {
             $params_file = $theme_info['path'] . "/parameters.xml";
             if (JFile::exists($params_file)) {
                 $form->loadFile($params_file, false);
             }
             $fields_folder = $theme_info['path'] . "/fields";
             if (JFolder::exists($fields_folder)) {
                 JForm::addFieldPath($fields_folder);
             }
             $language_path = $theme_info['path'] . "/language";
             if (JFolder::exists($language_path)) {
                 $language =& JFactory::getLanguage();
                 $language->load($theme_name, $theme_info['path'], $language->getTag(), true);
             }
         }
         $subfieldform = RokSubfieldForm::getInstance($form);
         if (!empty($data) && isset($data->params)) {
             $subfieldform->setOriginalParams($data->params);
         }
         if ($task == 'save' || $task == 'apply') {
             $subfieldform->makeSubfieldsVisable();
         }
     } else {
         if ($option == 'com_menus' && $layout == 'edit') {
             JForm::addFieldPath(JPATH_ROOT . '/modules/mod_roknavmenu/fields');
             // Load 2x Catalog Themes
             require_once JPATH_ROOT . "/modules/mod_roknavmenu/lib/RokNavMenu.php";
             RokNavMenu::loadCatalogs();
             foreach (RokNavMenu::$themes as $theme_name => $theme_info) {
                 $item_file = $theme_info['path'] . "/item.xml";
                 if (JFile::exists($item_file)) {
                     $form->loadFile($item_file, true);
                 }
                 $fields_folder = $theme_info['path'] . "/fields";
                 if (JFolder::exists($fields_folder)) {
                     JForm::addFieldPath($fields_folder);
                 }
             }
         }
     }
 }
Example #19
0
 public function getForm($data = array(), $loadData = true)
 {
     JForm::addFormPath(JPATH_COMPONENT_ADMINISTRATOR . '/models/forms');
     JForm::addFieldPath(JPATH_COMPONENT_ADMINISTRATOR . '/models/fields');
     $form = $this->loadForm('com_bookpro.tour', 'tour', array('control' => 'jform', 'load_data' => $loadData));
     if (empty($form)) {
         return false;
     }
     return $form;
 }
Example #20
0
 function display($tpl = null)
 {
     $db = JFactory::getDBO();
     if ($field = vRequest::getVar('field')) {
         if (strpos($field, 'plugin') !== false) {
             JForm::addFieldPath(JPATH_VM_ADMINISTRATOR . DS . 'fields');
             $table = '#__extensions';
             $field = substr($field, 6);
             $q = 'SELECT `params`,`element`,`type` FROM `' . $table . '` WHERE `element` = "' . $field . '"';
             $db->setQuery($q);
             $this->userField = $db->loadObject();
             //$this->userField->element = substr($this->userField->type, 6);
             if (!class_exists('vmPlugin')) {
                 require JPATH_VM_PLUGINS . DS . 'vmplugin.php';
             }
             vmPlugin::loadJLang('plg_vmuserfield_' . $this->userField->element, 'vmuserfield', $this->userField->element);
             $path = JPATH_ROOT . DS . 'plugins' . DS . 'vmuserfield' . DS . $this->userField->element . DS . $this->userField->element . '.xml';
             // Get the payment XML.
             $formFile = JPath::clean($path);
             if (file_exists($formFile)) {
                 if (!class_exists('VmConfig')) {
                     require JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'helpers' . DS . 'config.php';
                 }
                 if (!class_exists('VmTable')) {
                     require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'vmtable.php';
                 }
                 $this->userField->form = JForm::getInstance($this->userField->element, $formFile, array(), false, '//vmconfig | //config[not(//vmconfig)]');
                 $this->userField->params = new stdClass();
                 $varsToPush = vmPlugin::getVarsToPushByXML($formFile, 'customForm');
                 /*
                 					$this->userField->params->userfield_params = $this->userField->params;
                 					VmTable::bindParameterable($this->userField->params,'userfield_params',$varsToPush);*/
                 if (empty($this->userField->userfield_params)) {
                     $this->userField->userfield_params = '';
                 }
                 $this->userField->params->userfield_params = $this->userField->userfield_params;
                 VmTable::bindParameterable($this->userField->params, 'userfield_params', $varsToPush);
                 $this->userField->form->bind($this->userField);
             } else {
                 $this->userField->form = false;
                 vmdebug('renderUserfieldPlugin could not find xml for ' . $this->userField->type . ' at ' . $path);
             }
             //vmdebug('renderUserfieldPlugin ',$this->userField->form);
             if ($this->userField->form) {
                 $form = $this->userField->form;
                 ob_start();
                 include JPATH_VM_ADMINISTRATOR . DS . 'fields' . DS . 'formrenderer.php';
                 $body = ob_get_contents();
                 ob_end_clean();
                 echo $body;
             }
         }
     }
     jExit();
 }
Example #21
0
 /**
  * Method to get the 'editimages' form
  *
  * @return  mixed   A JForm object on success, false on failure
  * @since 2.0
  */
 public function getForm()
 {
     JForm::addFormPath(JPATH_COMPONENT . '/models/forms');
     JForm::addFieldPath(JPATH_COMPONENT . '/models/fields');
     JForm::addRulePath(JPATH_COMPONENT . '/models/rules');
     $form = JForm::getInstance(_JOOM_OPTION . '.editimages', 'editimages');
     if (empty($form)) {
         return false;
     }
     return $form;
 }
Example #22
0
 public function getForm($data = array(), $loadData = true)
 {
     if ($data) {
         $data = (object) $data;
     } else {
         $data = $this->getItem();
     }
     JForm::addFormPath(JPATH_COMPONENT . '/models/forms');
     JForm::addFieldPath(JPATH_COMPONENT . '/models/fields');
     $style_xml_path = JPath::find(JForm::addFormPath(), strtolower('style') . '.xml');
     $style_xml = JFactory::getXML($style_xml_path, true);
     if (isset($data->template_id) && $data->template_id) {
         $styleObject = JUDownloadFrontHelperTemplate::getTemplateStyleObject($data->id);
         $folder = $styleObject->folder;
         $folder = strtolower(str_replace(' ', '', $folder));
         if ($folder) {
             $xml_file = JPath::clean(JPATH_SITE . "/components/com_judownload/templates/" . $folder . "/" . $folder . '.xml');
             if (JFile::exists($xml_file)) {
                 $xml = JFactory::getXML($xml_file);
                 if ($xml->config) {
                     foreach ($xml->config->children() as $child) {
                         $style_params_xpath = $style_xml->xpath('//fieldset[@name="params"]');
                         JUDownloadHelper::appendXML($style_params_xpath[0], $child);
                     }
                     if ($xml->languages->count()) {
                         foreach ($xml->languages->children() as $language) {
                             $languageFile = (string) $language;
                             $first_pos = strpos($languageFile, '.');
                             $last_pos = strrpos($languageFile, '.');
                             $languageExtName = substr($languageFile, $first_pos + 1, $last_pos - $first_pos - 1);
                             $client = JApplicationHelper::getClientInfo((string) $language->attributes()->client, true);
                             $path = isset($client->path) ? $client->path : JPATH_BASE;
                             JUDownloadFrontHelperLanguage::loadLanguageFile($languageExtName, $path);
                         }
                     }
                 }
             }
         }
     }
     $form = $this->loadForm('com_judownload.style', $style_xml->asXML(), array('control' => 'jform', 'load_data' => $loadData));
     if (empty($form)) {
         return false;
     }
     $app = JFactory::getApplication();
     $id = $app->input->get('id', 0);
     if ($id) {
         $form->setFieldAttribute('template_id', 'disabled', 'true');
         $form->setFieldAttribute('template_id', 'filter', 'unset');
         if (isset($data->home) && $data->home == 1) {
             $form->setFieldAttribute('home', 'disabled', 'true');
         }
     }
     return $form;
 }
Example #23
0
 public function __construct($config = array())
 {
     JForm::addFieldPath(JPATH_COMPONENT_ADMINISTRATOR . '/models/fields');
     JForm::addRulePath(JPATH_COMPONENT_ADMINISTRATOR . '/models/rules');
     require_once JPATH_COMPONENT . DS . 'helpers' . DS . 'itemevents.php';
     $dispatcher = JDispatcher::getInstance();
     $itemevent = new Djcatalog2Itemevents($dispatcher);
     //$config['event_after_save'] = 'onItemAfterSave';
     //$config['event_after_delete'] = 'onItemAfterDelete';
     parent::__construct($config);
 }
Example #24
0
 /**
  * saveArticle
  *
  * @return  void
  */
 public function saveArticle()
 {
     // CSRF prevention
     if ($this->csrfProtection) {
         $this->_csrfProtection();
     }
     include_once JPATH_COMPONENT_ADMINISTRATOR . '/models/article.php';
     JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_content/tables');
     $task = 'save';
     $model = JModelLegacy::getInstance('article', 'contentModel', array('ignore_request' => true));
     $this->_model = $model;
     $model->setState('task', $task);
     $table = $model->getTable();
     $data = $this->_getData();
     $checkin = property_exists($table, 'checked_out');
     // Determine the name of the primary key for the data.
     if (empty($key)) {
         $key = $table->getKeyName();
     }
     $recordId = $data['id'];
     // Populate the row id from the session.
     $data[$key] = $recordId;
     // Validate the posted data.
     // Sometimes the form needs some posted data, such as for plugins and modules.
     // Get the form.
     JForm::addFormPath(JPATH_ADMINISTRATOR . '/components/com_content/models/forms');
     JForm::addFieldPath(JPATH_ADMINISTRATOR . '/components/com_content/models/fields');
     JForm::addFormPath(JPATH_ADMINISTRATOR . '/components/com_content/model/form');
     JForm::addFieldPath(JPATH_ADMINISTRATOR . '/components/com_content/model/field');
     $form = $model->getForm($data, false);
     // Test whether the data is valid.
     $validData = $model->validate($form, $data);
     // Not validated, but used in store
     $validData['state'] = $data['state'];
     $validData['featured'] = $data['featured'];
     // Check for validation errors.
     if ($validData === false) {
         // Get the validation messages.
         $errors = $model->getErrors();
         return false;
     }
     if (!isset($validData['tags'])) {
         $validData['tags'] = null;
     }
     // Attempt to save the data.
     if (!$model->save($validData)) {
         return false;
     }
     // Save succeeded, so check-in the record.
     if ($checkin && $model->checkin($validData[$key]) === false) {
         return false;
     }
     return true;
 }
Example #25
0
 /**
  * Method to get a form object.
  *
  * @param   string    $name    The name of the form.
  * @param   string    $source  The form source. Can be XML string if file flag is set to false.
  * @param   array     $options Optional array of options for the form creation.
  * @param   boolean   $clear   Optional argument to force load a new form.
  * @param   string    $xpath   An optional xpath to search for the fields.
  *
  * @throws \Exception
  * @return  mixed  JForm object on success, False on error.
  *
  * @see     JForm
  */
 protected function loadForm($name, $source = null, $options = array(), $clear = false, $xpath = null)
 {
     // Handle the optional arguments.
     $options['control'] = \JArrayHelper::getValue($options, 'control', false);
     // Create a signature hash.
     $hash = sha1($source . serialize($options));
     // Check if we can use a previously loaded form.
     if (isset($this->forms[$hash]) && !$clear) {
         return $this->forms[$hash];
     }
     // Set Form paths
     static $formLoaded;
     if (!$formLoaded) {
         // Get the form.
         // Register the paths for the form
         $paths = new \SplPriorityQueue();
         $paths->insert(JPATH_COMPONENT . '/model/form', 'normal');
         $paths->insert(JPATH_COMPONENT . '/model/field', 'normal');
         $paths->insert(JPATH_COMPONENT . '/model/rule', 'normal');
         // Legacy support to be removed in 4.0.
         $paths->insert(JPATH_COMPONENT . '/models/forms', 'normal');
         $paths->insert(JPATH_COMPONENT . '/models/fields', 'normal');
         $paths->insert(JPATH_COMPONENT . '/models/rules', 'normal');
         \JForm::addFormPath(JPATH_COMPONENT . '/models/forms');
         \JForm::addFieldPath(JPATH_COMPONENT . '/models/fields');
         \JForm::addFormPath(JPATH_COMPONENT . '/model/form');
         \JForm::addFieldPath(JPATH_COMPONENT . '/model/field');
         // Set Form paths for Windwalker
         \JForm::addFormPath(JPATH_COMPONENT . '/model/form/' . strtolower($this->getName()));
         // \JForm::addFieldPath(JPATH_COMPONENT . '/model/field/' . strtolower($this->getName()));
         $formLoaded = true;
     }
     try {
         $form = \JForm::getInstance($name, $source, $options, false, $xpath);
         if (isset($options['load_data']) && $options['load_data']) {
             // Get the data for the form.
             $data = $this->loadFormData();
         } else {
             $data = array();
         }
         // Allow for additional modification of the form, and events to be triggered.
         // We pass the data because plugins may require it.
         $this->preprocessForm($form, $data);
         // Load the data into the form after the plugins have operated.
         $form->bind($data);
     } catch (\Exception $e) {
         throw $e;
     }
     // Store the form for later.
     $this->forms[$hash] = $form;
     return $form;
 }
Example #26
0
 /**
  * An ajax connector for QuickAdd JS.
  */
 public function quickAddAjax()
 {
     // Init Variables
     $input = JFactory::getApplication()->input;
     $data = $input->post->get($input->get('formctrl'), array(), 'array');
     $result = new JRegistry();
     $result->set('Result', false);
     $model_name = $input->get('model_name');
     $component = $input->get('component');
     $extension = $input->get('extension');
     // Include Needed Classes
     JControllerLegacy::addModelPath(JPATH_BASE . "/components/com_{$component}/models");
     JForm::addFormPath(JPATH_BASE . "/components/com_{$component}/models/forms");
     JForm::addFieldPath(JPATH_BASE . "/components/com_{$component}/models/fields");
     JTable::addIncludePath(JPATH_BASE . "/components/com_{$component}/tables");
     AKHelper::_('lang.loadLanguage', $extension, null);
     // Get Model
     $model = $this->getModel(ucfirst($model_name), ucfirst($component) . 'Model', array('ignore_request' => true));
     // For WindWalker Component only
     if (is_callable(array($model, 'getFieldsName'))) {
         $fields_name = $model->getFieldsName();
         $data = AKHelper::_('array.pivotToTwoDimension', $data, $fields_name);
     }
     // Get Form
     $form = $model->getForm($data, false);
     if (!$form) {
         $result->set('errorMsg', $model->getError());
         jexit($result);
     }
     // Test whether the data is valid.
     $validData = $model->validate($form, $data);
     // Check for validation errors.
     if ($validData === false) {
         // Get the validation messages.
         $errors = $model->getErrors();
         $errorMsg = is_string($errors[0]) ? $errors[0] : $errors[0]->getMessage();
         $result->set('errorMsg', $errorMsg);
         jexit($result);
     }
     // Do Save
     if (!$model->save($validData)) {
         // Return Error Message.
         $result->set('errorMsg', JText::sprintf('JLIB_APPLICATION_ERROR_SAVE_FAILED', $model->getError()));
         jexit($result);
     }
     // Set ID
     $data['id'] = $model->getstate($model_name . '.id');
     // Set Result
     $result->set('Result', true);
     $result->set('data', $data);
     jexit($result);
 }
Example #27
0
 public function getForm($data = array(), $loadData = true)
 {
     $option = JRequest::getVar('option');
     $clearName = substr($option, 4);
     $type = str_replace(ucfirst($clearName) . 'Model', '', get_class());
     $option = JRequest::getVar('option');
     JForm::addFieldPath('JPATH_ADMINISTRATOR/components/' . $option . '/models/fields');
     $form = $this->loadForm($option . '.' . strtolower($type), strtolower($type), array('control' => 'jform', 'load_data' => $loadData));
     if (empty($form)) {
         return false;
     }
     return $form;
 }
	/**
	 * Tests the JFormField::__construct method
	 *
	 * @covers JFormField::__construct
	 *
	 * @return void
	 */
	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.'
		);
	}
Example #29
0
 function display($tpl = null)
 {
     $user = JXFactory::getUser();
     $this->assignRef('user', $user);
     JForm::addFieldPath(JPATH_COMPONENT . DS . 'models' . DS . 'fields');
     $form = JForm::getInstance('form', JPATH_ROOT . DS . 'components' . DS . 'com_profile' . DS . 'models' . DS . 'forms' . DS . 'details.xml');
     $detailModel = ProfileFactory::getModel('detail');
     $form->bind(array('params' => $detailModel->getDetails($user->id)));
     $this->assignRef('form', $form);
     $document = JFactory::getDocument();
     $document->addScript(JURI::root() . 'media/jquery/jquery-1.7.min.js');
     $document->setTitle(JText::_('COM_PROFILE_LABEL_EDIT_DETAILS'));
     parent::display($tpl);
 }
Example #30
-1
 public function getForm($data = array(), $loadData = true)
 {
     if ($data) {
         $data = (object) $data;
     } else {
         $data = $this->getItem();
     }
     JForm::addFormPath(JPATH_COMPONENT . '/models/forms');
     JForm::addFieldPath(JPATH_COMPONENT . '/models/fields');
     $field_xml_path = JPath::find(JForm::addFormPath(), 'field.xml');
     $field_xml = JFactory::getXML($field_xml_path, true);
     if ($data->plugin_id) {
         $db = JFactory::getDbo();
         $query = 'SELECT folder, type' . ' FROM #__judirectory_plugins' . ' WHERE (id =' . $data->plugin_id . ')';
         $db->setQuery($query);
         $pluginObj = $db->loadObject();
         if ($pluginObj && $pluginObj->folder) {
             $folder = strtolower(str_replace(' ', '', $pluginObj->folder));
             $xml_file = JPATH_SITE . "/components/com_judirectory/fields/" . $folder . "/" . $folder . '.xml';
             if (JFile::exists($xml_file)) {
                 $field_plugin_xml = JFactory::getXML($xml_file);
                 if ($field_plugin_xml->config) {
                     foreach ($field_plugin_xml->config->children() as $child) {
                         $field_params_xpath = $field_xml->xpath('//fieldset[@name="params"]');
                         JUDirectoryHelper::appendXML($field_params_xpath[0], $child);
                     }
                     if ($field_plugin_xml->languages->count()) {
                         foreach ($field_plugin_xml->languages->children() as $language) {
                             $languageFile = (string) $language;
                             $first_pos = strpos($languageFile, '.');
                             $last_pos = strrpos($languageFile, '.');
                             $languageExtName = substr($languageFile, $first_pos + 1, $last_pos - $first_pos - 1);
                             $client = JApplicationHelper::getClientInfo((string) $language->attributes()->client, true);
                             $path = isset($client->path) ? $client->path : JPATH_BASE;
                             JUDirectoryFrontHelperLanguage::loadLanguageFile($languageExtName, $path);
                         }
                     }
                 }
             }
         }
     }
     $form = $this->loadForm('com_judirectory.field', $field_xml->asXML(), array('control' => 'jform', 'load_data' => $loadData));
     if (empty($form)) {
         return false;
     }
     $ignored_options = explode(",", $data->ignored_options);
     foreach ($ignored_options as $ignored_option) {
         $form->setFieldAttribute($ignored_option, 'disabled', 'true');
         $form->setFieldAttribute($ignored_option, 'filter', 'unset');
     }
     if (!$this->canEditState($data)) {
         $form->setFieldAttribute('ordering', 'disabled', 'true');
         $form->setFieldAttribute('published', 'disabled', 'true');
         $form->setFieldAttribute('ordering', 'filter', 'unset');
         $form->setFieldAttribute('published', 'filter', 'unset');
     }
     return $form;
 }