/**
  * 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 #2
0
File: setup.php Project: cwcw/cms
 /**
  * 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.
     JForm::addFormPath(JPATH_COMPONENT . '/models/forms');
     JForm::addFieldPath(JPATH_COMPONENT . '/models/fields');
     JForm::addRulePath(JPATH_COMPONENT . '/models/rules');
     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;
 }
Example #3
0
 /**
  * Method for getting the form from the model.
  *
  * @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  mixed  A JForm object on success, false on failure
  */
 public function getForm($data = array(), $loadData = true)
 {
     JForm::addRulePath(JPATH_COMPONENT_ADMINISTRATOR . "/models/rules");
     $options = array('control' => 'jform', 'load_data' => $loadData);
     $form = $this->loadForm($this->typeAlias, $this->name, $options);
     if (empty($form)) {
         return false;
     }
     return $form;
 }
Example #4
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 #5
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 #6
0
	/**
	 * Include the optional profile language and return the XML profile fields.
	 *
	 * @param   string  $domain  Optional domain to use.
	 *
	 * @return  SimpleXMLElement  Required XML profile fields
	 *
	 * @since   2.0
	 * @throws  RuntimeException
	 */
	protected function getXMLFields($domain = null)
	{
		// Get the File and Path for the Profile XML
		$file 		= $this->getXMLFileName($domain);
		$xmlPath 	= $this->profile_base . '/' . $file . '.xml';

		if (isset($this->xml[$file]))
		{
			// Xml has already been loaded
			return $this->xml[$file];
		}

		$fields = self::FORM_FIELDS_NAME;

		// Disable libxml errors and allow to fetch error information as needed
		libxml_use_internal_errors(true);

		// Attempt to load the XML file.
		if ($xml = simplexml_load_file($xmlPath))
		{
			// Get only the required header - i.e. ldap_profile
			if ($xml = $xml->xpath("/form/fields[@name='{$fields}']"))
			{
				SHLog::add(JText::_('PLG_LDAP_PROFILE_DEBUG_12202'), 12202, JLog::DEBUG, 'ldap');

				// Register the JForm rules classes
				if (file_exists($this->profile_base . '/rules'))
				{
					JForm::addRulePath($this->profile_base . '/rules');
				}

				// Register the JForm fields classes
				if (file_exists($this->profile_base . '/fields'))
				{
					JForm::addFieldPath($this->profile_base . '/fields');
				}

				// Attempt to load profile language
				$lang = JFactory::getLanguage();
				$lang->load($file, $this->lang_base);

				$this->xml[$file] = $xml[0];

				return $this->xml[$file];
			}
		}

		// Cannot load the XML file
		throw new RuntimeException(JText::sprintf('PLG_LDAP_PROFILE_ERR_12203', $xmlPath), 12203);
	}
Example #7
0
 /**
  * Method to get the form for the image
  *
  * @param   array Holds the data of the image (if available)
  * @return  mixed A JForm object on success, false on failure
  * @since   2.0
  */
 public function getForm($data = array())
 {
     JForm::addFormPath(JPATH_COMPONENT . '/models/forms');
     JForm::addFieldPath(JPATH_COMPONENT . '/models/fields');
     JForm::addRulePath(JPATH_COMPONENT . '/models/rules');
     $form = JForm::getInstance(_JOOM_OPTION . '.image', 'image');
     if (empty($form)) {
         return false;
     }
     // Allow plugins to preprocess the form
     $this->preprocessForm($form, $data);
     if (!$this->canEditState($data)) {
         // Disable fields for display
         $form->setFieldAttribute('published', 'disabled', 'true');
         $form->setFieldAttribute('approved', 'disabled', 'true');
         $form->setFieldAttribute('hidden', 'disabled', 'true');
         // Unset the data of fields which we aren't allowed to change
         $form->setFieldAttribute('ordering', 'filter', 'unset');
         $form->setFieldAttribute('published', 'filter', 'unset');
         $form->setFieldAttribute('approved', 'filter', 'unset');
         $form->setFieldAttribute('hidden', 'filter', 'unset');
     }
     return $form;
 }
Example #8
0
 /**
  * Method to get the form for the category
  *
  * @param   array   Holds the data of the category (if available)
  * @return  mixed   A JForm object on success, false on failure
  * @since   2.0
  */
 public function getForm($data = array())
 {
     // Don't change the order of the foolowing pathes
     JForm::addFormPath(JPATH_COMPONENT . '/models/forms');
     JForm::addFieldPath(JPATH_COMPONENT_ADMINISTRATOR . '/models/fields');
     JForm::addFieldPath(JPATH_COMPONENT . '/models/fields');
     JForm::addRulePath(JPATH_COMPONENT_ADMINISTRATOR . '/models/rules');
     $form = JForm::getInstance(_JOOM_OPTION . '.editcategory', 'editcategory');
     if (empty($form)) {
         return false;
     }
     if (empty($data)) {
         $data = (array) $this->getCategory();
     }
     // Allow plugins to preprocess the form
     JPluginHelper::importPlugin('joomgallery');
     $this->preprocessForm($form, $data);
     if (!$this->canEditState($data)) {
         // Disable fields for display
         $form->setFieldAttribute('ordering', 'disabled', 'true');
         $form->setFieldAttribute('published', 'disabled', 'true');
         // Unset the data of fields which we aren't allowed to change
         $form->setFieldAttribute('ordering', 'filter', 'unset');
         $form->setFieldAttribute('published', 'filter', 'unset');
     }
     if (!$this->_config->get('jg_usercatacc')) {
         $form->setFieldAttribute('access', 'disabled', 'true');
         $form->setFieldAttribute('access', 'filter', 'unset');
     }
     return $form;
 }
Example #9
0
 /**
  * Test for JForm::syncPaths method.
  *
  * @return void
  */
 public function testSyncPaths()
 {
     $form = new JFormInspector('testSyncPaths');
     $this->assertThat($form->load(JFormDataHelper::$syncPathsDocument), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.');
     $fieldPaths = JForm::addFieldPath();
     $formPaths = JForm::addFormPath();
     $rulePaths = JForm::addRulePath();
     $this->assertThat(in_array(JPATH_ROOT . '/field1', $fieldPaths), $this->isTrue(), 'Line:' . __LINE__ . ' The field path from the XML file should be present.');
     $this->assertThat(in_array(JPATH_ROOT . '/field2', $fieldPaths), $this->isTrue(), 'Line:' . __LINE__ . ' The field path from the XML file should be present.');
     $this->assertThat(in_array(JPATH_ROOT . '/field3', $fieldPaths), $this->isTrue(), 'Line:' . __LINE__ . ' The field path from the XML file should be present.');
     $this->assertThat(in_array(JPATH_ROOT . '/form1', $formPaths), $this->isTrue(), 'Line:' . __LINE__ . ' The form path from the XML file should be present.');
     $this->assertThat(in_array(JPATH_ROOT . '/form2', $formPaths), $this->isTrue(), 'Line:' . __LINE__ . ' The form path from the XML file should be present.');
     $this->assertThat(in_array(JPATH_ROOT . '/form3', $formPaths), $this->isTrue(), 'Line:' . __LINE__ . ' The form path from the XML file should be present.');
     $this->assertThat(in_array(JPATH_ROOT . '/rule1', $rulePaths), $this->isTrue(), 'Line:' . __LINE__ . ' The rule path from the XML file should be present.');
     $this->assertThat(in_array(JPATH_ROOT . '/rule2', $rulePaths), $this->isTrue(), 'Line:' . __LINE__ . ' The rule path from the XML file should be present.');
     $this->assertThat(in_array(JPATH_ROOT . '/rule3', $rulePaths), $this->isTrue(), 'Line:' . __LINE__ . ' The rule path from the XML file should be present.');
 }
Example #10
0
// Execute updates
$folder = JPATH_COMPONENT_ADMINISTRATOR . "/updates";
if (JFolder::exists($folder)) {
    $updates = JFolder::files($folder, "\\.php\$");
    if (is_array($updates)) {
        foreach ($updates as $update) {
            require_once JPATH_COMPONENT_ADMINISTRATOR . "/updates/" . $update;
            $classname = "com_jdeveloper_update_" . str_replace(".", "_", basename($update));
            $classname = str_replace("_php", "", $classname);
            $class = new $classname();
            $class->update();
            JFile::delete(JPATH_COMPONENT_ADMINISTRATOR . "/updates/" . $update);
        }
    }
}
// Check if JCMS library is installed
if (!JFolder::exists(JPATH_ROOT . "/libraries/jcms")) {
    $controller->setRedirect(JRoute::_("index.php", false), JText::_("COM_JDEVELOPER_ERROR_JCMS_LIBRARY_NOT_INSTALLED"), "error");
    $controller->redirect();
}
// Set include paths
JHtml::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR . "/helpers/html");
JForm::addFieldPath(JPATH_ROOT . "/libraries/jcms/form/fields");
JForm::addRulePath(JPATH_COMPONENT_ADMINISTRATOR . "/models/rules");
// Execute task
try {
    $controller->execute(JFactory::getApplication()->input->get("task"));
} catch (Exception $e) {
    $controller->setRedirect(JRoute::_("index.php?option=com_jdeveloper&view=cpanel", false), $e->getMessage(), "error");
}
$controller->redirect();
 /**
  * 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'] = ArrayHelper::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::addRulePath(JPATH_COMPONENT . '/models/rules');
         \JForm::addFormPath(JPATH_COMPONENT . '/model/form');
         \JForm::addFieldPath(JPATH_COMPONENT . '/model/field');
         \JForm::addRulePath(JPATH_COMPONENT . '/model/rule');
         // Set Form paths for Windwalker
         \JForm::addFormPath(JPATH_COMPONENT . '/model/form/' . strtolower($this->getName()));
         \JForm::addFieldPath(JPATH_COMPONENT . '/model/field/' . strtolower($this->getName()));
         \JForm::addRulePath(JPATH_COMPONENT . '/model/rule/' . 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;
 }
 * @package      pkg_projectfork
 *
 * @author       Tobias Kuhn (eaxs)
 * @copyright    Copyright (C) 2006-2013 Tobias Kuhn. All rights reserved.
 * @license      http://www.gnu.org/licenses/gpl.html GNU/GPL, see LICENSE.txt
 */
defined('_JEXEC') or die;
// Make sure the cms libraries are loaded
if (!defined('JPATH_PLATFORM')) {
    require_once dirname(__FILE__) . '/../cms.php';
}
if (!defined('PF_LIBRARY')) {
    define('PF_LIBRARY', 1);
} else {
    // Make sure we run the code below only once
    return;
}
// Register the projectfork library
JLoader::registerPrefix('PF', JPATH_PLATFORM . '/projectfork');
JLoader::register('PFQueryHelper', JPATH_PLATFORM . '/projectfork/database/query/helper.php');
// Add include paths
JHtml::addIncludePath(JPATH_PLATFORM . '/projectfork/html');
JModelLegacy::addIncludePath(JPATH_PLATFORM . '/projectfork/model', 'PFModel');
JTable::addIncludePath(JPATH_PLATFORM . '/projectfork/table', 'PFTable');
JForm::addFieldPath(JPATH_PLATFORM . '/projectfork/form/fields');
JForm::addRulePath(JPATH_PLATFORM . '/projectfork/form/rules');
// Define version
if (!defined('PFVERSION')) {
    $pfversion = new PFVersion();
    define('PFVERSION', $pfversion->getShortVersion());
}
Example #13
0
    // Include the autoloader
    require_once SHPATH_PLATFORM . '/loader.php';
}
// Register the autoloader for all shmanic libraries
SHLoader::setup();
if (!class_exists('SHFactory')) {
    // Manually include the factory
    require_once SHPATH_PLATFORM . '/factory.php';
}
// Register the JForm field classes
if (file_exists(SHPATH_PLATFORM . '/form/fields')) {
    JForm::addFieldPath(SHPATH_PLATFORM . '/form/fields');
}
// Register the JForm rule classes
if (file_exists(SHPATH_PLATFORM . '/form/rules')) {
    JForm::addRulePath(SHPATH_PLATFORM . '/form/rules');
}
// Define deprecated class names file paths for the autoloader
SHLoader::register('SHUserAdaptersLdap', SHPATH_PLATFORM . '/user/adapter/ldap.php');
SHLoader::register('SHLdapEventBouncer', SHPATH_PLATFORM . '/adapter/event/bouncer.php');
// We need to check for the legacy folder which indicates Joomla 3+ / Platform
if (file_exists(JPATH_PLATFORM . '/legacy')) {
    // Resolve some legacy classes without importing all legacy classes
    JLoader::register('JDispatcher', JPATH_PLATFORM . '/legacy/dispatcher/dispatcher.php');
    JLoader::register('JApplication', JPATH_PLATFORM . '/legacy/application/application.php');
    JLoader::register('JApplicationHelper', JPATH_PLATFORM . '/legacy/application/helper.php');
    JLoader::register('JComponentHelper', JPATH_PLATFORM . '/legacy/component/helper.php');
} else {
    // Register JComponentHelper in case it is required later
    JLoader::register('JComponentHelper', JPATH_PLATFORM . '/joomla/application/component/helper.php');
}
                JModelLegacy::addIncludePath($admin_path . '/models', $com_name . 'Model');
            }
        }
        // Register backend html classes
        if (JFolder::exists($admin_path . '/helpers/html')) {
            JHtml::addIncludePath($admin_path . '/helpers/html');
        }
        // Register backend forms
        if (JFolder::exists($admin_path . '/models/forms')) {
            JForm::addFormPath($admin_path . '/models/forms');
        }
        // Register backend form fields
        if (JFolder::exists($admin_path . '/models/fields')) {
            JForm::addFieldPath($admin_path . '/models/fields');
        }
        // Register backend form rules
        if (JFolder::exists($admin_path . '/models/rules')) {
            JForm::addRulePath($admin_path . '/models/rules');
        }
    }
    if ($component->element != $current && $is_site) {
        // Register frontend model classes
        if (JFolder::exists($site_path . '/models')) {
            JModelLegacy::addIncludePath($site_path . '/models', $com_name . 'Model');
        }
        // Register frontend html classes
        if (JFolder::exists($site_path . '/helpers/html')) {
            JHtml::addIncludePath($site_path . '/helpers/html');
        }
    }
}