Beispiel #1
1
 /**
  * Display the view.
  *
  * @param   string  $tpl  The name of the template file to parse; automatically searches through the template paths.
  *
  * @return  mixed  A string if successful, otherwise an Error object.
  */
 public function display($tpl = null)
 {
     $this->form = $this->get('Form');
     $this->item = $this->get('Item');
     $this->state = $this->get('State');
     $section = $this->state->get('category.section') ? $this->state->get('category.section') . '.' : '';
     $this->canDo = JHelperContent::getActions($this->state->get('category.component'), $section . 'category', $this->item->id);
     $this->assoc = $this->get('Assoc');
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JError::raiseError(500, implode("\n", $errors));
         return false;
     }
     // Check for tag type
     $this->checkTags = JHelperTags::getTypes('objectList', array($this->state->get('category.extension') . '.category'), true);
     JFactory::getApplication()->input->set('hidemainmenu', true);
     if ($this->getLayout() == 'modal') {
         // If we are forcing a language in modal (used for associations).
         if ($forcedLanguage = JFactory::getApplication()->input->get('forcedLanguage', '', 'cmd')) {
             // Set the language field to the forcedLanguage and disable changing it.
             $this->form->setValue('language', null, $forcedLanguage);
             $this->form->setFieldAttribute('language', 'readonly', 'true');
             // Only allow to select categories with All language or with the forced language.
             $this->form->setFieldAttribute('parent_id', 'language', '*,' . $forcedLanguage);
             // Only allow to select tags with All language or with the forced language.
             $this->form->setFieldAttribute('tags', 'language', '*,' . $forcedLanguage);
         }
     } elseif ($this->item->id && $this->form->getValue('language', null, '*') != '*' && JLanguageAssociations::isEnabled() && count($this->item->associations) > 0) {
         $this->form->setFieldAttribute('language', 'readonly', 'true');
     }
     $this->addToolbar();
     return parent::display($tpl);
 }
Beispiel #2
0
 /**
  * Display the view.
  *
  * @param   string  $tpl  The name of the template file to parse; automatically searches through the template paths.
  *
  * @return  mixed  A string if successful, otherwise an Error object.
  */
 public function display($tpl = null)
 {
     // Initialise 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;
     }
     if ($this->getLayout() == 'modal') {
         // If we are forcing a language in modal (used for associations).
         if ($forcedLanguage = JFactory::getApplication()->input->get('forcedLanguage', '', 'cmd')) {
             // Set the language field to the forcedLanguage and disable changing it.
             $this->form->setValue('language', null, $forcedLanguage);
             $this->form->setFieldAttribute('language', 'readonly', 'true');
             // Only allow to select categories with All language or with the forced language.
             $this->form->setFieldAttribute('catid', 'language', '*,' . $forcedLanguage);
             // Only allow to select tags with All language or with the forced language.
             $this->form->setFieldAttribute('tags', 'language', '*,' . $forcedLanguage);
         }
     } elseif ($this->item->id && $this->form->getValue('language', null, '*') != '*' && JLanguageAssociations::isEnabled() && count($this->item->associations) > 0) {
         $this->form->setFieldAttribute('language', 'readonly', 'true');
     }
     $this->addToolbar();
     return parent::display($tpl);
 }
Beispiel #3
0
 /**
  * Display the view
  *
  * @param   string  $tpl  The name of the template file to parse; automatically searches through the template paths.
  *
  * @return  void
  *
  * @since   1.6
  */
 public function display($tpl = null)
 {
     $user = JFactory::getUser();
     $this->form = $this->get('Form');
     $this->item = $this->get('Item');
     $this->modules = $this->get('Modules');
     $this->levels = $this->get('ViewLevels');
     $this->state = $this->get('State');
     $this->canDo = JHelperContent::getActions('com_menus', 'menu', (int) $this->state->get('item.menutypeid'));
     // Check if we're allowed to edit this item
     // No need to check for create, because then the moduletype select is empty
     if (!empty($this->item->id) && !$this->canDo->get('core.edit')) {
         throw new Exception(JText::_('JERROR_ALERTNOAUTHOR'), 403);
     }
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JError::raiseError(500, implode("\n", $errors));
         return false;
     }
     if ($this->getLayout() == 'modal') {
         // If we are forcing a language in modal (used for associations).
         if ($forcedLanguage = JFactory::getApplication()->input->get('forcedLanguage', '', 'cmd')) {
             // Set the language field to the forcedLanguage and disable changing it.
             $this->form->setValue('language', null, $forcedLanguage);
             $this->form->setFieldAttribute('language', 'readonly', 'true');
             // Only allow to select categories with All language or with the forced language.
             $this->form->setFieldAttribute('parent_id', 'language', '*,' . $forcedLanguage);
         }
     } elseif ($this->item->id && $this->form->getValue('language', null, '*') != '*' && JLanguageAssociations::isEnabled() && count($this->item->associations) > 0) {
         $this->form->setFieldAttribute('language', 'readonly', 'true');
     }
     parent::display($tpl);
     $this->addToolbar();
 }
Beispiel #4
0
 /**
  * Execute and display a template script.
  *
  * @param   string  $tpl  The name of the template file to parse; automatically searches through the template paths.
  *
  * @return  mixed  A string if successful, otherwise an Error object.
  *
  * @since   1.6
  */
 public function display($tpl = null)
 {
     $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;
     }
     $this->form->setValue('password', null);
     $this->form->setValue('password2', null);
     $this->addToolbar();
     return parent::display($tpl);
 }
Beispiel #5
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);
 }
Beispiel #6
0
 /**
  * Document edit page.
  *
  * @param string $tpl used template name
  * @return void
  */
 public function display($tpl = null)
 {
     $mainframe = JFactory::getApplication();
     /* @var $mainframe JAdministrator */
     $config = JoomDOCConfig::getInstance();
     /* @var $config JoomDOCConfig */
     $model = $this->getModel();
     /* @var $model JoomDOCModelDocument */
     $this->form = $model->getForm();
     $this->document = $model->getItem();
     $this->state = $model->getState();
     $this->access = new JoomDOCAccessHelper($this->document);
     if (!isset($this->document->id) || empty($this->document->id)) {
         $this->form->setValue('path', null, $mainframe->getUserState('path'));
         $this->form->setValue('title', null, JFile::getName($mainframe->getUserState('path')));
     }
     $this->addToolbar();
     parent::display($tpl);
 }
Beispiel #7
0
 /**
  * Display date form field. If field value equal database null date reset to empty string.
  *
  * @param string $field form field name
  * @return string field form html
  */
 public function date($field)
 {
     static $nullDate;
     if (empty($nullDate)) {
         $db = JFactory::getDbo();
         /* @var $db JDatabaseMySQL */
         $nullDate = $db->getNullDate();
     }
     if ($this->form->getValue($field) == $nullDate) {
         $this->form->setValue($field, null, '');
     }
     return $this->form->getInput($field);
 }
Beispiel #8
0
 /**
  * Execute and display a template script.
  *
  * @param   string  $tpl  The name of the template file to parse; automatically searches through the template paths.
  *
  * @return  mixed  A string if successful, otherwise an Error object.
  *
  * @since   1.6
  */
 public function display($tpl = null)
 {
     if ($this->getLayout() == 'pagebreak') {
         // TODO: This is really dogy - should change this one day.
         $eName = JFactory::getApplication()->input->getCmd('e_name');
         $eName = preg_replace('#[^A-Z0-9\\-\\_\\[\\]]#i', '', $eName);
         $this->document->setTitle(JText::_('COM_CONTENT_PAGEBREAK_DOC_TITLE'));
         $this->eName =& $eName;
         return parent::display($tpl);
     }
     $this->form = $this->get('Form');
     $this->item = $this->get('Item');
     $this->state = $this->get('State');
     $this->canDo = JHelperContent::getActions('com_content', 'article', $this->item->id);
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JError::raiseError(500, implode("\n", $errors));
         return false;
     }
     if ($this->getLayout() == 'modal') {
         // If we are forcing a language in modal (used for associations).
         if ($forcedLanguage = JFactory::getApplication()->input->get('forcedLanguage', '', 'cmd')) {
             // Set the language field to the forcedLanguage and disable changing it.
             $this->form->setValue('language', null, $forcedLanguage);
             $this->form->setFieldAttribute('language', 'readonly', 'true');
             // Only allow to select categories with All language or with the forced language.
             $this->form->setFieldAttribute('catid', 'language', '*,' . $forcedLanguage);
             // Only allow to select tags with All language or with the forced language.
             $this->form->setFieldAttribute('tags', 'language', '*,' . $forcedLanguage);
         }
     } elseif ($this->item->id && $this->form->getValue('language', null, '*') != '*' && JLanguageAssociations::isEnabled() && count($this->item->associations) > 0) {
         $this->form->setFieldAttribute('language', 'readonly', 'true');
     }
     $this->addToolbar();
     return parent::display($tpl);
 }
 /**
  * Default view function
  *
  * @return void
  */
 public function displayTask()
 {
     // Get scope
     $this->view->scope = Request::getWord('scope', 'Hub');
     $this->view->scope_id = Request::getInt('scope_id', 0);
     // Get permissions
     $access = new \JForm('permissions');
     $access->loadFile(dirname(dirname(__DIR__)) . DS . 'models' . DS . 'forms' . DS . 'permissions.xml');
     // Bind existing rules if applicable
     $asset = new \JTableAsset($this->database);
     $name = 'com_time.' . strtolower($this->view->scope) . '.' . $this->view->scope_id;
     $asset->loadByName($name);
     if ($asset->get('id')) {
         $access->setValue('asset_id', null, $asset->get('id'));
     }
     $this->view->permissions = $access->getField(strtolower($this->view->scope));
     // Display
     $this->view->display();
 }
Beispiel #10
0
 /**
  * Method to allow derived classes to preprocess the form.
  *
  * @param  object  A form object.
  * @param  mixed  The data expected for the form.
  * @param  string  The name of the plugin group to import (defaults to "content").
  * @throws  Exception if there is an error in the form event.
  * @since  1.6
  */
 protected function preprocessForm(JForm $form, $item, $group = 'content')
 {
     // Initialize variables.
     $filename = $this->getState('translation.filename');
     $client = $this->getState('translation.client');
     $tag = $this->getState('translation.tag');
     $origin = LocaliseHelper::getOrigin($filename, $client);
     $app = JFactory::getApplication();
     $false = false;
     // Compute all known languages
     static $languages = array();
     jimport('joomla.language.language');
     if (!array_key_exists($client, $languages)) {
         $languages[$client] = JLanguage::getKnownLanguages(constant('LOCALISEPATH_' . strtoupper($client)));
     }
     if (is_object($item)) {
         $form->setFieldAttribute('legend', 'unchanged', $item->unchanged, 'legend');
         $form->setFieldAttribute('legend', 'translated', $item->translated, 'legend');
         $form->setFieldAttribute('legend', 'untranslated', $item->total - $item->translated - $item->unchanged, 'legend');
         $form->setFieldAttribute('legend', 'extra', $item->extra, 'legend');
     }
     if ($this->getState('translation.layout') != 'raw') {
         $path = $this->getState('translation.path');
         $refpath = $this->getState('translation.refpath');
         $sections = LocaliseHelper::parseSections($path);
         $refsections = LocaliseHelper::parseSections($refpath);
         $addform = new JXMLElement('<form />');
         $group = $addform->addChild('fields');
         $group->addAttribute('name', 'strings');
         $fieldset = $group->addChild('fieldset');
         $fieldset->addAttribute('name', 'Default');
         $fieldset->addAttribute('label', 'Default');
         if (JFile::exists($refpath)) {
             $stream = new JStream();
             $stream->open($refpath);
             $header = true;
             $lineNumber = 0;
             while (!$stream->eof()) {
                 $line = $stream->gets();
                 $lineNumber++;
                 // Blank lines
                 if (preg_match('/^\\s*$/', $line)) {
                     $header = true;
                     $field = $fieldset->addChild('field');
                     $field->addAttribute('label', '');
                     $field->addAttribute('type', 'spacer');
                     $field->addAttribute('class', 'text');
                     continue;
                 } elseif (preg_match('/^\\[([^\\]]*)\\]\\s*$/', $line, $matches)) {
                     $header = false;
                     $form->load($addform, false);
                     $section = $matches[1];
                     $addform = new JXMLElement('<form />');
                     $group = $addform->addChild('fields');
                     $group->addAttribute('name', 'strings');
                     $fieldset = $group->addChild('fieldset');
                     $fieldset->addAttribute('name', $section);
                     $fieldset->addAttribute('label', $section);
                     continue;
                 } elseif (!$header && preg_match('/^;(.*)$/', $line, $matches)) {
                     $key = $matches[1];
                     $field = $fieldset->addChild('field');
                     $field->addAttribute('label', $key);
                     $field->addAttribute('type', 'spacer');
                     $field->addAttribute('class', 'text');
                     continue;
                 } elseif (preg_match('/^([A-Z][A-Z0-9_\\-\\.]*)\\s*=/', $line, $matches)) {
                     $header = false;
                     $key = $matches[1];
                     $field = $fieldset->addChild('field');
                     $string = $refsections['keys'][$key];
                     $translated = isset($sections['keys'][$key]);
                     $modified = $translated && $sections['keys'][$key] != $refsections['keys'][$key];
                     $status = $modified ? 'translated' : ($translated ? 'unchanged' : 'untranslated');
                     $default = $translated ? $sections['keys'][$key] : '';
                     $label = '<b>' . $key . '</b><br />' . htmlspecialchars($string, ENT_COMPAT, 'UTF-8');
                     $field->addAttribute('status', $status);
                     $field->addAttribute('description', $string);
                     if ($default) {
                         $field->addAttribute('default', $default);
                     } else {
                         $field->addAttribute('default', $string);
                     }
                     $field->addAttribute('label', $label);
                     $field->addAttribute('name', $key);
                     $field->addAttribute('type', 'key');
                     $field->addAttribute('filter', 'raw');
                     continue;
                 } elseif (!preg_match('/^(|(\\[[^\\]]*\\])|([A-Z][A-Z0-9_\\-\\.]*\\s*=(\\s*(("[^"]*")|(_QQ_)))+))\\s*(;.*)?$/', $line)) {
                     $this->item->error[] = $lineNumber;
                 }
             }
             $stream->close();
             $newstrings = false;
             if (!empty($sections['keys'])) {
                 foreach ($sections['keys'] as $key => $string) {
                     if (!isset($refsections['keys'][$key])) {
                         if (!$newstrings) {
                             $newstrings = true;
                             $form->load($addform, false);
                             $section = 'New Strings';
                             $addform = new JXMLElement('<form />');
                             $group = $addform->addChild('fields');
                             $group->addAttribute('name', 'strings');
                             $fieldset = $group->addChild('fieldset');
                             $fieldset->addAttribute('name', $section);
                             $fieldset->addAttribute('label', $section);
                         }
                         $field = $fieldset->addChild('field');
                         $status = 'extra';
                         $default = $string;
                         $label = '<b>' . $key . '</b>';
                         $field->addAttribute('status', $status);
                         $field->addAttribute('description', $string);
                         if ($default) {
                             $field->addAttribute('default', $default);
                         } else {
                             $field->addAttribute('default', $string);
                         }
                         $field->addAttribute('label', $label);
                         $field->addAttribute('name', $key);
                         $field->addAttribute('type', 'key');
                         $field->addAttribute('filter', 'raw');
                     }
                 }
             }
         }
         $form->load($addform, false);
     }
     // Check the session for previously entered form data.
     $data = $app->getUserState('com_localise.edit.translation.data', array());
     // Bind the form data if present.
     if (!empty($data)) {
         $form->bind($data);
     }
     if ($origin != '_thirdparty' && $origin != '_override') {
         $packages = LocaliseHelper::getPackages();
         $package = $packages[$origin];
         if (!empty($package->author)) {
             $form->setValue('author', $package->author);
             $form->setFieldAttribute('author', 'readonly', 'true');
         }
         if (!empty($package->copyright)) {
             $form->setValue('maincopyright', $package->copyright);
             $form->setFieldAttribute('maincopyright', 'readonly', 'true');
         }
         if (!empty($package->license)) {
             $form->setValue('license', $package->license);
             $form->setFieldAttribute('license', 'readonly', 'true');
         }
     }
     if ($form->getValue('description') == '' && array_key_exists($tag, $languages[$client])) {
         $form->setValue('description', $filename . ' ' . $languages[$client][$tag]['name']);
     }
     return $form;
 }
Beispiel #11
0
 /**
  * @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)
 {
     $formName = $form->getName();
     // 		var_dump($formName);
     if ($formName == 'com_users.reset_request' || $formName == 'com_users.remind' || $formName == 'com_contact.contact') {
         return 1;
     }
     if (!$form instanceof JForm) {
         $this->_subject->setError('JERROR_NOT_A_FORM');
         return false;
     }
     JForm::addFormPath(JPATH_PLUGIN_HPUSER . DS . 'forms');
     $form->loadFile('hpuser', false);
     $user = JFactory::getUser();
     $userType = JRequest::getInt('type', -1);
     if (is_object($data) && isset($data->user_type)) {
         $userType = $data->user_type;
     }
     $form->setValue('user_type', '', $userType);
     if (@$data->id > 0) {
         if ($userType == 1) {
             $form->loadFile('business_user', false);
         } else {
             $form->loadFile('normal_user', false);
         }
     } elseif (!$user->get('isRoot')) {
         $form->loadFile('business_user', false);
         $form->loadFile('normal_user', false);
     }
     //If not at new user, don't editable user_type field
     if ($formName != 'com_users.registration' && @$data->id != 0) {
         $form->setFieldAttribute('user_type', 'readonly', 'true');
         $form->setFieldAttribute('username', 'readonly', 'true');
         $form->setFieldAttribute('email1', 'readonly', 'true');
         $form->removeField("email2");
         /*if($user->get('isRoot')) {
         			$form->setFieldAttribute('user_type', 'readonly', 'true');
         		} else {
         			$form->setFieldAttribute('user_type', 'type', 'hidden');
         		}*/
     } else {
         $form->removeField("business_logo", "business_profile");
         $form->removeField("business_banner", "business_profile");
     }
     return true;
 }
Beispiel #12
0
 /**
  * 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)
 {
     $app = JFactory::getApplication();
     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_admin.profile', 'com_users.user', 'com_users.profile', 'com_users.registration'))) {
         return true;
     }
     // Add the registration fields to the form.
     JForm::addFormPath(__DIR__ . '/sibdiets');
     $form->loadFile('sibdiet', false);
     if ($name == 'com_users.registration') {
         $form->setFieldAttribute('id', 'type', 'hidden', 'sibdiet');
         if ($agent = $app->input->get('agent', 0, 'INT')) {
             $form->setValue('created_by', 'sibdiet', $agent);
         }
     }
     // Permissions field will show just in joomla backend and only for super admins.
     if (!JFactory::getUser()->get('isRoot') || !$app->isAdmin()) {
         // We only want the Permissions in the backend just for super user
         $form->removeField('permissions', 'sibdiet');
         // We only want the Created by in the backend just for super user
         $form->setFieldAttribute('created_by', 'type', 'hidden', 'sibdiet');
     }
     // Fix File Number
     if (!empty($data->sibdiet['id'])) {
         $data->sibdiet['id'] += 200000;
     }
     return true;
 }
Beispiel #13
0
 function display($tpl = null)
 {
     global $mainframe;
     //initialise variables
     $document = JFactory::getDocument();
     $db = JFactory::getDBO();
     $me = JFactory::getUser();
     $cid = JRequest::getVar('cid', array(0), '', 'array');
     JArrayHelper::toInteger($cid, array(0));
     $edit = JRequest::getVar('edit', true);
     if (!$cid) {
         $edit = false;
     }
     if (FLEXI_J16GE) {
         $form = $this->get('Form');
         $form->setValue('password', null);
         $form->setValue('password2', null);
     }
     $form_folder = FLEXI_J16GE ? 'forms' . DS : '';
     JHTML::_('behavior.tooltip');
     //add css to document
     $document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/flexicontentbackend.css');
     if (FLEXI_J30GE) {
         $document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/j3x.css');
     } else {
         if (FLEXI_J16GE) {
             $document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/j25.css');
         } else {
             $document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/j15.css');
         }
     }
     //add js function to overload the joomla submitform
     $document->addScript(JURI::root() . 'components/com_flexicontent/assets/js/admin.js');
     $document->addScript(JURI::root() . 'components/com_flexicontent/assets/js/validate.js');
     // load language file for com_users component
     JFactory::getLanguage()->load('com_users', JPATH_ADMINISTRATOR, 'en-GB', true);
     JFactory::getLanguage()->load('com_users', JPATH_ADMINISTRATOR, null, true);
     //create the toolbar
     if ($edit) {
         JToolBarHelper::title(JText::_('FLEXI_EDIT_AUTHOR'), 'authoredit');
     } else {
         JToolBarHelper::title(JText::_('FLEXI_ADD_AUTHOR'), 'authoradd');
     }
     $ctrl = FLEXI_J16GE ? 'users.' : '';
     JToolBarHelper::apply($ctrl . 'apply');
     JToolBarHelper::save($ctrl . 'save');
     JToolBarHelper::custom($ctrl . 'saveandnew', 'savenew.png', 'savenew.png', 'FLEXI_SAVE_AND_NEW', false);
     JToolBarHelper::cancel($ctrl . 'cancel');
     JToolBarHelper::help('screen.users.edit');
     $user = $edit ? JUser::getInstance($cid[0]) : JUser::getInstance();
     $myuser = JFactory::getUser();
     $acl = JFactory::getACL();
     // Check for post data in the event that we are returning
     // from a unsuccessful attempt to save data
     $post = JRequest::get('post');
     if ($post) {
         $user->bind($post);
     }
     if ($user->get('id')) {
         $query = 'SELECT *' . ' FROM #__contact_details' . ' WHERE user_id = ' . (int) $cid[0];
         $db->setQuery($query);
         $contact = $db->loadObjectList();
     } else {
         $contact = NULL;
         // Get the default group id for a new user
         $config = JComponentHelper::getParams('com_users');
         $newGrp = $config->get('new_usertype');
         if (!FLEXI_J16GE) {
             $user->set('gid', $acl->get_group_id($newGrp, null, 'ARO'));
         } else {
             $user->set('gid', $newGrp);
         }
     }
     // **************************************************
     // Include needed files and add needed js / css files
     // **************************************************
     // Load pane behavior
     jimport('joomla.html.pane');
     // Load tooltips
     FLEXI_J30GE ? JHtml::_('behavior.framework', true) : JHTML::_('behavior.mootools');
     JHTML::_('behavior.tooltip');
     // Add css to document
     $document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/flexicontentbackend.css');
     if (FLEXI_J30GE) {
         $document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/j3x.css');
     } else {
         if (FLEXI_J16GE) {
             $document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/j25.css');
         } else {
             $document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/j15.css');
         }
     }
     // Add js function to overload the joomla submitform
     $document->addScript('components/com_flexicontent/assets/js/admin.js');
     $document->addScript('components/com_flexicontent/assets/js/validate.js');
     // ********************
     // Initialise variables
     // ********************
     $cparams = JComponentHelper::getParams('com_flexicontent');
     if (!FLEXI_J16GE) {
         $pane = JPane::getInstance('sliders');
         $tpane = JPane::getInstance('tabs', array('startOffset' => 2, 'allowAllClose' => true, 'opacityTransition' => true, 'duration' => 600));
     }
     // *************************************************************************************************
     // Get author extended data, basic (described in author.xml) and category (described incategory.xml)
     // *************************************************************************************************
     JTable::addIncludePath(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_flexicontent' . DS . 'tables');
     $author_user_id = (int) $cid[0];
     $flexiauthor_extdata = JTable::getInstance('flexicontent_authors_ext', '');
     $flexiauthor_extdata->load($author_user_id);
     //echo "<pre>"; print_r($flexiauthor_extdata); echo "</pre>"; exit;
     // ***********************
     // AUTHOR basic parameters
     // ***********************
     // Load the DB parameter values and the XML description from file,
     // NOTE: this is one step for J1.5 via a JParameter object, but in J1.6+ the use of XML file
     // in JParameter is deprecated, instead we will JForm to load XML description and thus be able to render it
     $auth_xml = JPATH_COMPONENT . DS . 'models' . DS . $form_folder . 'author.xml';
     if (FLEXI_J16GE) {
         $params_authorbasic = new JRegistry($flexiauthor_extdata->author_basicparams);
     } else {
         $params_authorbasic = new JParameter($flexiauthor_extdata->author_basicparams, $auth_xml);
     }
     //echo "<pre>"; print_r($params_authorbasic); echo "</pre>"; exit;
     if (FLEXI_J16GE) {
         // Read XML file
         $xml_string = str_replace('name="params"', 'name="authorbasicparams"', file_get_contents($auth_xml));
         // Load the form description from the XML string
         $jform_authorbasic = new JForm('com_flexicontent.author', array('control' => 'jform', 'load_data' => true));
         $jform_authorbasic->load($xml_string, $isFile = false);
         // Set DB parameter values into the JForm object
         foreach ($jform_authorbasic->getFieldset() as $fsetname => $field) {
             $jform_authorbasic->setValue($field->fieldname, $group = 'authorbasicparams', $value = $params_authorbasic->get($field->fieldname));
         }
     }
     // **************************
     // AUTHOR category parameters
     // **************************
     // Load the DB parameter values and the XML description from file,
     // NOTE: this is one step for J1.5 via a JParameter object, but in J1.6+ the use of XML file
     // in JParameter is deprecated, instead we will JForm to load XML description and thus be able to render it
     $cat_xml = JPATH_COMPONENT . DS . 'models' . DS . $form_folder . 'category.xml';
     if (FLEXI_J16GE) {
         $params_authorcat = new JRegistry($flexiauthor_extdata->author_catparams);
     } else {
         $params_authorcat = new JParameter($flexiauthor_extdata->author_catparams, $cat_xml);
     }
     //echo "<pre>"; print_r($params_authorcat); echo "</pre>"; exit;
     if (FLEXI_J16GE) {
         // Read XML file
         $xml_string = str_replace('name="params"', 'name="authorcatparams"', file_get_contents($cat_xml));
         // Load the form description from the XML string
         $jform_authorcat = new JForm('com_flexicontent.category', array('control' => 'jform', 'load_data' => true));
         $jform_authorcat->load($xml_string, $isFile = false);
         // Set DB parameter values into the JForm object
         foreach ($jform_authorcat->getFieldset() as $fsetname => $field) {
             $jform_authorcat->setValue($field->fieldname, $group = 'authorcatparams', $value = $params_authorcat->get($field->fieldname));
         }
     }
     // **********************************************************************************
     // Get Templates and apply Template Parameters values into the form fields structures
     // **********************************************************************************
     $themes = flexicontent_tmpl::getTemplates();
     $tmpls = $themes->category;
     if (FLEXI_J16GE) {
         $params_author = new JRegistry($user->params);
     }
     foreach ($tmpls as $tmpl) {
         if (FLEXI_J16GE) {
             $jform = new JForm('com_flexicontent.template.category', array('control' => 'jform', 'load_data' => true));
             $jform->load($tmpl->params);
             $tmpl->params = $jform;
             // ... values applied at the template form file
         } else {
             $tmpl->params->loadINI($flexiauthor_extdata->author_catparams);
         }
     }
     //$lists = array();
     //$javascript = "onchange=\"javascript:if (document.forms[0].image.options[selectedIndex].value!='') {document.imagelib.src='../images/stories/' + document.forms[0].image.options[selectedIndex].value} else {document.imagelib.src='../images/blank.png'}\"";
     //$lists['imagelist'] 		= JHTML::_('list.images', 'image', $flexiauthor_extdata->image, $javascript, '/images/stories/' );
     if (!FLEXI_J16GE) {
         $userObjectID = $acl->get_object_id('users', $user->get('id'), 'ARO');
         $userGroups = $acl->get_object_groups($userObjectID, 'ARO');
         $userGroupName = strtolower($acl->get_group_name($userGroups[0], 'ARO'));
         $userIsAdmin = $userGroupName == 'administrator';
         $myObjectID = $acl->get_object_id('users', $myuser->get('id'), 'ARO');
         $myGroups = $acl->get_object_groups($myObjectID, 'ARO');
         $myGroupName = strtolower($acl->get_group_name($myGroups[0], 'ARO'));
         $myIsAdmin = $myGroupName == 'administrator';
     } else {
     }
     // ensure user can't add/edit group higher than themselves
     /* NOTE : This check doesn't work commented out for the time being
     		if ( is_array( $myGroups ) && count( $myGroups ) > 0 )
     		{
     			$excludeGroups = (array) $acl->get_group_children( $myGroups[0], 'ARO', 'RECURSE' );
     		}
     		else
     		{
     			$excludeGroups = array();
     		}
     
     		if ( in_array( $userGroups[0], $excludeGroups ) )
     		{
     			echo 'not auth';
     			$mainframe->redirect( 'index.php?option=com_flexicontent&amp;controller=users&amp;view=users', JText::_('NOT_AUTH') );
     		}
     		*/
     /*
     if ( $userGroupName == 'super administrator' )
     {
     	// super administrators can't change
     	 		$lists['gid'] = '<input type="hidden" name="gid" value="'. $currentUser->gid .'" /><strong>'. JText::_( 'Super Administrator' ) .'</strong>';
     }
     else if ( $userGroupName == $myGroupName && $myGroupName == 'administrator' ) {
     */
     if (FLEXI_ACCESS) {
         // Create the list of all groups except public and registered
         $query = 'SELECT id AS value, name AS text, level, ordering' . ' FROM #__flexiaccess_groups' . ' WHERE level > 1' . ' ORDER BY ordering ASC';
         $db->setQuery($query);
         $allgroups = $db->loadObjectList();
         if ($user->get('id')) {
             // get all the groups from the user
             $query = 'SELECT group_id' . ' FROM #__flexiaccess_members' . ' WHERE member_id = ' . (int) $cid[0];
             $db->setQuery($query);
             $usergroups = FLEXI_J16GE ? $db->loadColumn() : $db->loadResultArray();
         } else {
             $usergroups = array();
         }
         $lists['access'] = JHTML::_('select.genericlist', $allgroups, 'groups[]', 'size="10" multiple="multiple"', 'value', 'text', $usergroups);
     }
     if (!FLEXI_J16GE) {
         if ($userIsAdmin && $myIsAdmin) {
             // administrators can't change each other
             $lists['gid'] = '<input type="hidden" name="gid" value="' . $user->get('gid') . '" /><strong>' . JText::_('Administrator') . '</strong>';
         } else {
             $gtree = $acl->get_group_children_tree(null, 'USERS', false);
             // remove users 'above' me
             //$i = 0;
             //while ($i < count( $gtree )) {
             //	if ( in_array( $gtree[$i]->value, (array)$excludeGroups ) ) {
             //		array_splice( $gtree, $i, 1 );
             //	} else {
             //		$i++;
             //	}
             //}
             $lists['gid'] = JHTML::_('select.genericlist', $gtree, 'gid', 'size="10"', 'value', 'text', $user->get('gid'));
         }
     } else {
         if (!$user->get('id')) {
             $new_usertype = JComponentHelper::getParams('com_users')->get('new_usertype');
             $usergroups = $new_usertype ? array($new_usertype) : array();
         } else {
             $ugrps_qtmpl = 'SELECT group_id FROM #__user_usergroup_map AS ug WHERE ug.user_id = %d';
             $query = sprintf($ugrps_qtmpl, intval($user->get('id')));
             $db->setQuery($query);
             $usergroups = FLEXI_J16GE ? $db->loadColumn() : $db->loadResultArray();
             if ($db->getErrorMsg()) {
                 echo $db->getErrorMsg();
             }
         }
     }
     // build the html select list
     $lists['block'] = JHTML::_('select.booleanlist', 'block', 'class="inputbox" size="1"', $user->get('block'));
     // build the html select list
     $lists['sendEmail'] = JHTML::_('select.booleanlist', 'sendEmail', 'class="inputbox" size="1"', $user->get('sendEmail'));
     $this->assignRef('me', $me);
     $this->assignRef('document', $document);
     $this->assignRef('lists', $lists);
     if (!FLEXI_J16GE) {
         $this->assignRef('pane', $pane);
         $this->assignRef('tpane', $tpane);
     }
     $this->assignRef('user', $user);
     $this->assignRef('usergroups', $usergroups);
     $this->assignRef('contact', $contact);
     $this->assignRef('cparams', $cparams);
     $this->assignRef('params_authorbasic', $params_authorbasic);
     $this->assignRef('params_authorcat', $params_authorcat);
     if (FLEXI_J16GE) {
         $this->assignRef('jform_authorbasic', $jform_authorbasic);
         $this->assignRef('jform_authorcat', $jform_authorcat);
     }
     $this->assignRef('tmpls', $tmpls);
     if (FLEXI_J16GE) {
         $this->assignRef('form', $form);
         $this->assignRef('params_author', $params_author);
     }
     parent::display($tpl);
 }
Beispiel #14
0
 /**
  * getQuickaddForm
  */
 public static function getQuickaddForm($id, $path, $extension = null)
 {
     $content = '';
     //JForm::addFormPath(AKHelper::_('path.get', null, $extension).'/models/forms');
     //JForm::addFieldPath(AKHelper::_('path.get', null, $extension).'/models/fields');
     try {
         $form = new JForm($id . '.quickaddform', array('control' => $id));
         $form->loadFile(JPATH_ROOT . '/' . $path);
     } catch (Exception $e) {
         Jerror::raiseWarning(404, $e->getMessage());
         return false;
     }
     // Set Category Extension
     if ($extension) {
         $form->setValue('extension', null, $extension);
     }
     $fieldset = $form->getFieldset('quickadd');
     foreach ($fieldset as $field) {
         $content .= "<div class=\"control-group\" id=\"jform_basic_alias-wrap\">\n                            <div class=\"control-label\">\n                                {$field->label}\n                            </div>\n                            <div class=\"controls\">\n                                {$field->input}\n                            </div>\n                        </div>";
     }
     if (JVERSION < 3) {
         $content = "<fieldset class=\"adminform form-horizontal\">{$content}</fieldset>";
     }
     return $content;
 }
Beispiel #15
0
 /**
  * set value into forfield and $this->extraValues
  * note: JForm::setValue($fieldname, $value) check the forfield options list,
  *       and not save value if it is not valid. This function save value into
  *       $this->extraValues ohne check.      
  * @result void
  * @param string $fieldname
  * @param string $value            
  */
 public function setValue($fieldName, $group = null, $value)
 {
     $this->extraValues[$fieldName] = $value;
     parent::setValue($fieldName, $group, $value);
 }
    /**
     * Logic to render an XML file as form parameters
     * NOTE: this does not work with Request Data validation in J2.5+. The validation
     *       must be skipped or the parameters must be re-added after the validation
     *
     * @access public
     * @return void
     * @since 1.5
     */
    function getlayoutparams()
    {
        jimport('joomla.filesystem.file');
        $app = JFactory::getApplication();
        $user = JFactory::getUser();
        //get vars
        $ext_option = JRequest::getVar('ext_option', '');
        $ext_view = JRequest::getVar('ext_view', '');
        $ext_id = JRequest::getInt('ext_id', 0);
        $layout_name = JRequest::getVar('layout_name', 0);
        $directory = JRequest::getVar('directory', 0);
        $path = (!is_dir($directory) ? JPATH_ROOT : '') . $directory;
        $db = JFactory::getDBO();
        if ($ext_view == 'module') {
            $query = 'SELECT params FROM #__modules WHERE id = ' . $ext_id;
            // load english language file for 'mod_flexicontent' module then override with current language file
            $module_name = basename(dirname($directory));
            JFactory::getLanguage()->load($module_name, JPATH_SITE, 'en-GB', true);
            JFactory::getLanguage()->load($module_name, JPATH_SITE, null, true);
        } else {
            if ($ext_view == 'field') {
                $query = 'SELECT attribs FROM #__flexicontent_fields WHERE id = ' . $ext_id;
            } else {
                echo "not supported extension/view: " . $ext_view;
                return;
            }
        }
        if ($ext_option != 'com_flexicontent' && $ext_option != 'com_modules' && $ext_option != 'com_advancedmodules' && $ext_option != 'com_menus') {
            echo '<div class="alert fcpadded fcinlineblock" style="">You are editing module via extension: <span class="label label-warning">' . $ext_option . '</span><br/> - If extension does not call Joomla event <span class="label label-warning">onExtensionBeforeSave</span> then custom layout parameters may not be saved</div>';
        }
        $db->setQuery($query);
        $ext_params_str = $db->loadResult();
        $layout_names = explode(':', $layout_name);
        if (count($layout_names) > 1) {
            $layout_name = $layout_names[1];
            $layoutpath = JPATH_ROOT . DS . 'templates' . DS . $layout_names[0] . DS . 'html' . DS . 'mod_flexicontent/' . $layout_name . '.xml';
        } else {
            $layoutpath = $path . DS . $layout_name . '.xml';
        }
        if (!file_exists($layoutpath)) {
            if (file_exists($path . DS . '_fallback' . DS . '_fallback.xml')) {
                $layoutpath = $path . DS . '_fallback' . DS . '_fallback.xml';
                echo '<div class="alert fcpadded fcinlineblock">Currently selected layout: <b>"' . $layout_name . '"</b> does not have a parameters XML file, using general defaults. if this is an old template then these parameters will allow to continue using it, but we recommend that you create parameter file: ' . $layout_name . '.xml</div><div class="clear"></div>';
            } else {
                echo !FLEXI_J16GE ? '<div style="font-size: 11px; color: gray; background-color: lightyellow; border: 1px solid lightgray; width: auto; padding: 4px 2%; margin: 1px 8px; height: auto;">' : '<p class="tip">';
                echo ' Currently selected layout: <b>"' . $layout_name . '"</b> does not have layout specific parameters';
                echo !FLEXI_J16GE ? '</div>' : '</p>';
                exit;
            }
        }
        //Get data from the model
        if (FLEXI_J16GE) {
            // Load XML file
            if (FLEXI_J30GE) {
                $xml = simplexml_load_file($layoutpath);
                $xmldoc =& $xml;
            } else {
                $xml = JFactory::getXMLParser('Simple');
                $xml->loadFile($layoutpath);
                $xmldoc =& $xml->document;
            }
            // Create form object, (form name seems not to cause any problem)
            $jform = new JForm('com_flexicontent.template.item', array('control' => 'jform', 'load_data' => true));
            $tmpl_params = FLEXI_J30GE ? $xmldoc->asXML() : $xmldoc->toString();
            $jform->load($tmpl_params);
            // Load existing layout values into the object (that we got from DB)
            $ext_params = new JRegistry($ext_params_str);
            // and for J1.5:  new JParameter($ext_params_str);
            $grpname = 'params';
            // this is the name of <fields> container
            foreach ($jform->getGroup($grpname) as $field) {
                $fieldname = $field->__get('fieldname');
                $value = $ext_params->get($fieldname);
                if (strlen($value)) {
                    $jform->setValue($fieldname, $grpname, $value);
                }
            }
        } else {
            // Create a parameters object
            $form = new JParameter('', $layoutpath);
            // Load existing layout values into the object (that we got from DB)
            $form->loadINI($ext_params_str);
        }
        if ($layout_name) {
            if (!FLEXI_J16GE) {
                echo $form->render('params', 'layout');
            } else {
                ?>
				<fieldset class="panelform"><ul class="adminformlist">
					<?php 
                $grpname = 'params';
                // this is the name of <fields> container
                foreach ($jform->getGroup($grpname) as $field) {
                    echo '<li>' . $field->label . $field->input . '</li>';
                }
                ?>
				</ul></fieldset>
				<?php 
            }
        } else {
            echo "<br /><span style=\"padding-left:25px;\"'>" . JText::_('FLEXI_APPLY_TO_SEE_THE_PARAMETERS') . "</span><br /><br />";
        }
        //parent::display($tpl);
    }
    /**
     * Logic to render an XML file as form parameters
     * NOTE: this does not work with Request Data validation in J2.5+. The validation
     *       must be skipped or the parameters must be re-added after the validation
     *
     * @access public
     * @return void
     * @since 1.5
     */
    function getlayoutparams()
    {
        jimport('joomla.filesystem.file');
        $mainframe = JFactory::getApplication();
        $user = JFactory::getUser();
        //get vars
        $ext_view = JRequest::getVar('ext_view', '');
        $ext_id = JRequest::getInt('ext_id', 0);
        $layout_name = JRequest::getVar('layout_name', 0);
        $directory = JRequest::getVar('directory', 0);
        $path = (!is_dir($directory) ? JPATH_ROOT : '') . $directory;
        $db = JFactory::getDBO();
        if ($ext_view == 'module') {
            $query = 'SELECT params FROM #__modules WHERE id = ' . $ext_id;
        } else {
            if ($ext_view == 'field') {
                $query = 'SELECT attribs FROM #__flexicontent_fields WHERE id = ' . $ext_id;
            } else {
                echo "not supported extension/view: " . $ext_view;
                return;
            }
        }
        $db->setQuery($query);
        $ext_params_str = $db->loadResult();
        $layoutpath = $path . DS . $layout_name . '.xml';
        if (!file_exists($layoutpath)) {
            echo !FLEXI_J16GE ? '<div style="font-size: 11px; color: gray; background-color: lightyellow; border: 1px solid lightgray; width: auto; padding: 4px 2%; margin: 1px 8px; height: auto;">' : '<p class="tip">';
            echo ' Currently selected layout: <b>"' . $layout_name . '"</b> does not have layout specific parameters';
            echo !FLEXI_J16GE ? '</div>' : '</p>';
            exit;
        }
        //Get data from the model
        if (FLEXI_J16GE) {
            $grpname = 'params';
            // this name of <fields> container
            if (FLEXI_J30GE) {
                $xml = simplexml_load_file($layoutpath);
                $xmldoc =& $xml;
            } else {
                $xml = JFactory::getXMLParser('Simple');
                $xml->loadFile($layoutpath);
                $xmldoc =& $xml->document;
            }
            $tmpl_params = FLEXI_J30GE ? $xmldoc->asXML() : $xmldoc->toString();
            // Create form object, (form name seems not to cause any problem)
            $jform = new JForm('com_flexicontent.template.item', array('control' => 'jform', 'load_data' => true));
            $jform->load($tmpl_params);
            // Load existing layout values into the object (that we got from DB)
            $ext_params = new JRegistry($ext_params_str);
            // and for J1.5:  new JParameter($ext_params_str);
            foreach ($jform->getGroup($grpname) as $field) {
                $fieldname = $field->__get('fieldname');
                $value = $ext_params->get($fieldname);
                if (strlen($value)) {
                    $jform->setValue($fieldname, $grpname, $value);
                }
            }
        } else {
            // Create a parameters object
            $form = new JParameter('', $layoutpath);
            // Load existing layout values into the object (that we got from DB)
            $form->loadINI($ext_params_str);
        }
        if ($layout_name) {
            if (!FLEXI_J16GE) {
                echo $form->render('params', 'layout');
            } else {
                ?>
				<fieldset class="panelform"><ul class="adminformlist">
					<?php 
                foreach ($jform->getGroup($grpname) as $field) {
                    echo '<li>' . $field->label . $field->input . '</li>';
                }
                ?>
				</ul></fieldset>
				<?php 
            }
        } else {
            echo "<br /><span style=\"padding-left:25px;\"'>" . JText::_('FLEXI_APPLY_TO_SEE_THE_PARAMETERS') . "</span><br /><br />";
        }
        //parent::display($tpl);
    }