Example #1
0
 /**
  * Display the view
  *
  * @param   string  $tpl  template
  *
  * @return  void
  */
 public function display($tpl = null)
 {
     // Initialiase variables.
     $model = $this->getModel();
     $this->item = $this->get('Item');
     $model->checkDefault($this->item);
     $this->form = $this->get('Form');
     $this->form->bind($this->item);
     $this->state = $this->get('State');
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JError::raiseError(500, implode("\n", $errors));
         return false;
     }
     $this->addToolbar();
     parent::display($tpl);
 }
Example #2
0
 /**
  * Function that gets the config settings
  *
  * @return    Object
  */
 protected function getAssignments()
 {
     if (!isset($this->assignments)) {
         $xmlfile = JPATH_ADMINISTRATOR . '/components/com_advancedmodules/assignments.xml';
         $assignments = new JForm('assignments', array('control' => 'advancedparams'));
         $assignments->loadFile($xmlfile, 1, '//config');
         $assignments->bind($this->item->advancedparams);
         $this->assignments = $assignments;
     }
     return $this->assignments;
 }
Example #3
0
 /**
  * Display the view
  *
  * @param   string  $tpl  template
  *
  * @return  void
  */
 public function display($tpl = null)
 {
     // Initialiase variables.
     $model = $this->getModel();
     $this->item = $this->get('Item');
     $model->checkDefault($this->item);
     $this->form = $this->get('Form');
     $this->form->bind($this->item);
     $this->state = $this->get('State');
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         throw new RuntimeException(implode("\n", $errors), 500);
     }
     $this->addToolbar();
     FabrikAdminHelper::setViewLayout($this);
     $srcs = FabrikHelperHTML::framework();
     $srcs[] = 'media/com_fabrik/js/fabrik.js';
     FabrikHelperHTML::iniRequireJS();
     FabrikHelperHTML::script($srcs);
     parent::display($tpl);
 }
 /**
  * Display configurations for registration
  *
  * @return  void
  */
 public function displayTask()
 {
     $config = new \JForm('com_members.registration');
     $config->loadFile(dirname(dirname(__DIR__)) . DS . 'config' . DS . 'config.xml', true, '/config');
     $config->bind($this->config->toArray());
     $this->config = $config;
     $this->view->params = $config->getFieldset('registration');
     // Set any errors
     if ($this->getError()) {
         $this->view->setError($this->getError());
     }
     // Output the HTML
     $this->view->display();
 }
Example #5
0
File: cmc.php Project: fracting/cmc
 /**
  * This function displays the newsletter form on the user profile
  *
  * @param   JForm  $form  - the user form
  * @param   array  $data  - the user data
  *
  * @return bool
  */
 public function edit($form, $data)
 {
     $appl = JFactory::getApplication();
     $subscriptionData = CmcHelperUsers::getSubscription($data->email, $this->params->get('listid'));
     $renderer = CmcHelperXmlbuilder::getInstance($this->params);
     // Render Content
     $html = $renderer->build();
     if ($appl->isSite()) {
         CompojoomHtmlBehavior::jquery();
         JHtml::script('media/plg_user_cmc/js/cmc.js');
     }
     // Inject fields into the form
     $form->load($html, false);
     if ($subscriptionData) {
         $form->setFieldAttribute('newsletter', 'checked', 'checked', 'cmc');
         $form->bind(CmcHelperSubscription::convertMergesToFormData($subscriptionData->merges));
     }
 }
Example #6
0
 /**
  * Method to manipulate the MageBridge Product Relation backend-form
  *
  * @param JForm $form The form to be altered
  * @param JForm $data The associated data for the form
  * @return boolean
  */
 public function onMageBridgeProductPrepareForm($form, $data)
 {
     // Check if this plugin can be used
     if ($this->isEnabled() == false) {
         return false;
     }
     // Add the plugin-form to main form
     $formFile = JPATH_SITE . '/plugins/magebridgeproduct/' . $this->_name . '/form/form.xml';
     if (file_exists($formFile)) {
         $form->loadFile($formFile, false);
     }
     // Load the original values from the deprecated connector-architecture
     if (!empty($this->connector_field)) {
         $pluginName = $this->_name;
         if (!empty($data['connector']) && !empty($data['connector_value']) && $pluginName == $data['connector']) {
             $form->bind(array('actions' => array($this->connector_field => $data['connector_value'])));
         }
     }
 }
Example #7
0
 /**
  * Method to allow derived classes to preprocess the form.
  *
  * @param   JForm   $form   A JForm object.
  * @param   mixed   $data   The data expected for the form.
  * @param   string  $group  The name of the plugin group to import (defaults to "content").
  *
  * @return  void
  *
  * @see     JFormField
  * @since   11.1
  * @throws  Exception if there is an error in the form event.
  */
 protected function preprocessForm(JForm $form, $data, $group = 'content')
 {
     if (!$data) {
         parent::preprocessForm($form, $data, $group);
         return;
     }
     $blogXML = JPATH_ROOT . '/components/com_content/views/category/tmpl/blog.xml';
     $listXML = JPATH_ROOT . '/components/com_content/views/category/tmpl/default.xml';
     $articleXML = JPATH_ROOT . '/components/com_content/views/article/tmpl/default.xml';
     $menuXML = JPATH_BASE . '/components/com_menus/models/forms/item_component.xml';
     // set list params
     $listParams = simplexml_load_file($listXML);
     $listParams->fields[1]['name'] = 'list';
     // set blog params
     $blogParams = simplexml_load_file($blogXML);
     $blogParams->fields[1]['name'] = 'blog';
     // set article params
     $articleParams = simplexml_load_file($articleXML);
     $articleParams->fields[1]['name'] = 'article';
     // create Form
     $this->listForm = JForm::getInstance('list', $listParams->asXML(), array('control' => 'jform'), true, '/metadata');
     $this->blogForm = JForm::getInstance('blog', $blogParams->asXML(), array('control' => 'jform'), true, '/metadata');
     $this->articleForm = JForm::getInstance('article', $articleParams->asXML(), array('control' => 'jform'), true, '/metadata');
     // set menu xml
     $menuParams = simplexml_load_file($menuXML);
     $menuParams->fields[0]['name'] = 'list';
     $this->listForm->load($menuParams->asXML(), true, '/form');
     $menuParams->fields[0]['name'] = 'blog';
     $this->blogForm->load($menuParams->asXML(), true, '/form');
     $menuParams->fields[0]['name'] = 'article';
     $this->articleForm->load($menuParams->asXML(), true, '/form');
     // bind data
     $data->list = json_decode($data->list);
     $data->blog = json_decode($data->blog);
     $data->article = json_decode($data->article);
     $this->listForm->bind($data);
     $this->blogForm->bind($data);
     $this->articleForm->bind($data);
     parent::preprocessForm($form, $data, $group);
 }
Example #8
0
 protected function getContactQuery($pk = null)
 {
     // TODO: Cache on the fingerprint of the arguments
     $db = $this->getDbo();
     $user = JFactory::getUser();
     $pk = !empty($pk) ? $pk : (int) $this->getState('contact.id');
     $query = $db->getQuery(true);
     if ($pk) {
         //sqlsrv changes
         $case_when = ' CASE WHEN ';
         $case_when .= $query->charLength('a.alias');
         $case_when .= ' THEN ';
         $a_id = $query->castAsChar('a.id');
         $case_when .= $query->concatenate(array($a_id, 'a.alias'), ':');
         $case_when .= ' ELSE ';
         $case_when .= $a_id . ' END as slug';
         $case_when1 = ' CASE WHEN ';
         $case_when1 .= $query->charLength('cc.alias');
         $case_when1 .= ' THEN ';
         $c_id = $query->castAsChar('cc.id');
         $case_when1 .= $query->concatenate(array($c_id, 'cc.alias'), ':');
         $case_when1 .= ' ELSE ';
         $case_when1 .= $c_id . ' END as catslug';
         $query->select('a.*, cc.access as category_access, cc.title as category_name, ' . $case_when . ',' . $case_when1);
         $query->from('#__contact_details AS a');
         $query->join('INNER', '#__categories AS cc on cc.id = a.catid');
         $query->where('a.id = ' . (int) $pk);
         $published = $this->getState('filter.published');
         $archived = $this->getState('filter.archived');
         if (is_numeric($published)) {
             $query->where('a.published IN (1,2)');
             $query->where('cc.published IN (1,2)');
         }
         $groups = implode(',', $user->getAuthorisedViewLevels());
         $query->where('a.access IN (' . $groups . ')');
         try {
             $db->setQuery($query);
             $result = $db->loadObject();
             if ($error = $db->getErrorMsg()) {
                 throw new Exception($error);
             }
             if (empty($result)) {
                 throw new JException(JText::_('COM_CONTACT_ERROR_CONTACT_NOT_FOUND'), 404);
             }
             // If we are showing a contact list, then the contact parameters take priority
             // So merge the contact parameters with the merged parameters
             if ($this->getState('params')->get('show_contact_list')) {
                 $registry = new JRegistry();
                 $registry->loadString($result->params);
                 $this->getState('params')->merge($registry);
             }
         } catch (Exception $e) {
             $this->setError($e);
             return false;
         }
         if ($result) {
             $user = JFactory::getUser();
             $groups = implode(',', $user->getAuthorisedViewLevels());
             //get the content by the linked user
             $query = $db->getQuery(true);
             $query->select('a.id');
             $query->select('a.title');
             $query->select('a.state');
             $query->select('a.access');
             $query->select('a.created');
             // SQL Server changes
             $case_when = ' CASE WHEN ';
             $case_when .= $query->charLength('a.alias');
             $case_when .= ' THEN ';
             $a_id = $query->castAsChar('a.id');
             $case_when .= $query->concatenate(array($a_id, 'a.alias'), ':');
             $case_when .= ' ELSE ';
             $case_when .= $a_id . ' END as slug';
             $case_when1 = ' CASE WHEN ';
             $case_when1 .= $query->charLength('c.alias');
             $case_when1 .= ' THEN ';
             $c_id = $query->castAsChar('c.id');
             $case_when1 .= $query->concatenate(array($c_id, 'c.alias'), ':');
             $case_when1 .= ' ELSE ';
             $case_when1 .= $c_id . ' END as catslug';
             $query->select($case_when1 . ',' . $case_when);
             $query->from('#__content as a');
             $query->leftJoin('#__categories as c on a.catid=c.id');
             $query->where('a.created_by = ' . (int) $result->user_id);
             $query->where('a.access IN (' . $groups . ')');
             $query->order('a.state DESC, a.created DESC');
             // filter per language if plugin published
             if (JLanguageMultilang::isEnabled()) {
                 $query->where('a.created_by = ' . (int) $result->user_id . ' AND ' . ('a.language=' . $db->quote(JFactory::getLanguage()->getTag()) . ' OR a.language=' . $db->quote('*')));
             }
             if (is_numeric($published)) {
                 $query->where('a.state IN (1,2)');
             }
             $db->setQuery($query, 0, 10);
             $articles = $db->loadObjectList();
             $result->articles = $articles;
             //get the profile information for the linked user
             require_once JPATH_ADMINISTRATOR . '/components/com_users/models/user.php';
             $userModel = JModelLegacy::getInstance('User', 'UsersModel', array('ignore_request' => true));
             $data = $userModel->getItem((int) $result->user_id);
             JPluginHelper::importPlugin('user');
             $form = new JForm('com_users.profile');
             // Get the dispatcher.
             $dispatcher = JDispatcher::getInstance();
             // Trigger the form preparation event.
             $dispatcher->trigger('onContentPrepareForm', array($form, $data));
             // Trigger the data preparation event.
             $dispatcher->trigger('onContentPrepareData', array('com_users.profile', $data));
             // Load the data into the form after the plugins have operated.
             $form->bind($data);
             $result->profile = $form;
             $this->contact = $result;
             return $result;
         }
     }
 }
 function render()
 {
     $config = JComponentHelper::getParams(WBADVERT_NAME);
     $form = new JForm('jform');
     $form->loadFile(WBADVERT_PATH . 'config.xml', false, '//config');
     $form->bind($config->toArray());
     $fieldSets = $form->getFieldsets();
     $html[] = '<div class="control-fieldset">';
     foreach ($form->getFieldset('component') as $field) {
         $field->name = 'params[' . $field->name . ']';
         $html[] = $field->renderField();
     }
     $html[] = '</div>';
     return implode(PHP_EOL, $html);
 }
Example #10
0
 /**
  * Render the initial plugin options, such as the plugin selector, and whether its rendered in front/back/both etc
  *
  * @return  string
  */
 public function top()
 {
     $data = $this->getData();
     $c = $this->getState('c') + 1;
     $str = array();
     $str[] = '<div class="pane-slider content pane-down">';
     $str[] = '<fieldset class="adminform pluginContanier" id="formAction_' . $c . '"><ul>';
     $formName = 'com_fabrik.' . $this->getState('type') . '-plugin';
     $topForm = new JForm($formName, array('control' => 'jform'));
     $topForm->repeatCounter = $c;
     $xmlFile = JPATH_SITE . '/administrator/components/com_fabrik/models/forms/' . $this->getState('type') . '-plugin.xml';
     // Add the plugin specific fields to the form.
     $topForm->loadFile($xmlFile, false);
     $topForm->bind($data);
     // Filer the forms fieldsets for those starting with the correct $serachName prefix
     foreach ($topForm->getFieldsets() as $fieldset) {
         if ($fieldset->label != '') {
             $str[] = '<legend>' . $fieldset->label . '</legend>';
         }
         foreach ($topForm->getFieldset($fieldset->name) as $field) {
             $str[] = '<li>' . $field->label . $field->input . '</li>';
         }
     }
     $str[] = '</ul>';
     $str[] = '<div class="pluginOpts" style="clear:left"></div>';
     $str[] = '<a href="#" class="delete removeButton">' . JText::_('COM_FABRIK_DELETE') . '</a>';
     $str[] = '</fieldset>';
     $str[] = '</div>';
     return implode("\n", $str);
 }
Example #11
0
 /**
  * Gets the query to load a contact item
  *
  * @param   integer  $pk  The item to be loaded
  *
  * @return  mixed    The contact object on success, false on failure
  *
  * @throws  Exception  On database failure
  */
 protected function getContactQuery($pk = null)
 {
     // @todo Cache on the fingerprint of the arguments
     $db = $this->getDbo();
     $nullDate = $db->quote($db->getNullDate());
     $nowDate = $db->quote(JFactory::getDate()->toSql());
     $user = JFactory::getUser();
     $pk = !empty($pk) ? $pk : (int) $this->getState('contact.id');
     $query = $db->getQuery(true);
     if ($pk) {
         // Sqlsrv changes
         $case_when = ' CASE WHEN ';
         $case_when .= $query->charLength('a.alias', '!=', '0');
         $case_when .= ' THEN ';
         $a_id = $query->castAsChar('a.id');
         $case_when .= $query->concatenate(array($a_id, 'a.alias'), ':');
         $case_when .= ' ELSE ';
         $case_when .= $a_id . ' END as slug';
         $case_when1 = ' CASE WHEN ';
         $case_when1 .= $query->charLength('cc.alias', '!=', '0');
         $case_when1 .= ' THEN ';
         $c_id = $query->castAsChar('cc.id');
         $case_when1 .= $query->concatenate(array($c_id, 'cc.alias'), ':');
         $case_when1 .= ' ELSE ';
         $case_when1 .= $c_id . ' END as catslug';
         $query->select('a.*, cc.access as category_access, cc.title as category_name, ' . $case_when . ',' . $case_when1)->from('#__contact_details AS a')->join('INNER', '#__categories AS cc on cc.id = a.catid')->where('a.id = ' . (int) $pk);
         $published = $this->getState('filter.published');
         if (is_numeric($published)) {
             $query->where('a.published IN (1,2)')->where('cc.published IN (1,2)');
         }
         $groups = implode(',', $user->getAuthorisedViewLevels());
         $query->where('a.access IN (' . $groups . ')');
         try {
             $db->setQuery($query);
             $result = $db->loadObject();
             if (empty($result)) {
                 return false;
             }
         } catch (Exception $e) {
             $this->setError($e->getMessage());
             return false;
         }
         if ($result) {
             $contactParams = new Registry();
             $contactParams->loadString($result->params);
             // If we are showing a contact list, then the contact parameters take priority
             // So merge the contact parameters with the merged parameters
             if ($this->getState('params')->get('show_contact_list')) {
                 $this->getState('params')->merge($contactParams);
             }
             // Get the com_content articles by the linked user
             if ((int) $result->user_id && $this->getState('params')->get('show_articles')) {
                 $query = $db->getQuery(true)->select('a.id')->select('a.title')->select('a.state')->select('a.access')->select('a.catid')->select('a.created')->select('a.language');
                 // SQL Server changes
                 $case_when = ' CASE WHEN ';
                 $case_when .= $query->charLength('a.alias', '!=', '0');
                 $case_when .= ' THEN ';
                 $a_id = $query->castAsChar('a.id');
                 $case_when .= $query->concatenate(array($a_id, 'a.alias'), ':');
                 $case_when .= ' ELSE ';
                 $case_when .= $a_id . ' END as slug';
                 $case_when1 = ' CASE WHEN ';
                 $case_when1 .= $query->charLength('c.alias', '!=', '0');
                 $case_when1 .= ' THEN ';
                 $c_id = $query->castAsChar('c.id');
                 $case_when1 .= $query->concatenate(array($c_id, 'c.alias'), ':');
                 $case_when1 .= ' ELSE ';
                 $case_when1 .= $c_id . ' END as catslug';
                 $query->select($case_when1 . ',' . $case_when)->from('#__content as a')->join('LEFT', '#__categories as c on a.catid=c.id')->where('a.created_by = ' . (int) $result->user_id)->where('a.access IN (' . $groups . ')')->order('a.state DESC, a.created DESC');
                 // Filter per language if plugin published
                 if (JLanguageMultilang::isEnabled()) {
                     $query->where('a.created_by = ' . (int) $result->user_id . ' AND ' . ('a.language=' . $db->quote(JFactory::getLanguage()->getTag()) . ' OR a.language=' . $db->quote('*')));
                 }
                 if (is_numeric($published)) {
                     $query->where('a.state IN (1,2)')->where('(a.publish_up = ' . $nullDate . ' OR a.publish_up <= ' . $nowDate . ')')->where('(a.publish_down = ' . $nullDate . ' OR a.publish_down >= ' . $nowDate . ')');
                 }
                 // Number of articles to display from config/menu params
                 $articles_display_num = $this->getState('params')->get('articles_display_num', 10);
                 // Use contact setting?
                 if ($articles_display_num === 'use_contact') {
                     $articles_display_num = $contactParams->get('articles_display_num', 10);
                     // Use global?
                     if ((string) $articles_display_num === '') {
                         $articles_display_num = JComponentHelper::getParams('com_contact')->get('articles_display_num', 10);
                     }
                 }
                 $db->setQuery($query, 0, (int) $articles_display_num);
                 $articles = $db->loadObjectList();
                 $result->articles = $articles;
             } else {
                 $result->articles = null;
             }
             // Get the profile information for the linked user
             require_once JPATH_ADMINISTRATOR . '/components/com_users/models/user.php';
             $userModel = JModelLegacy::getInstance('User', 'UsersModel', array('ignore_request' => true));
             $data = $userModel->getItem((int) $result->user_id);
             JPluginHelper::importPlugin('user');
             $form = new JForm('com_users.profile');
             // Get the dispatcher.
             $dispatcher = JEventDispatcher::getInstance();
             // Trigger the form preparation event.
             $dispatcher->trigger('onContentPrepareForm', array($form, $data));
             // Trigger the data preparation event.
             $dispatcher->trigger('onContentPrepareData', array('com_users.profile', $data));
             // Load the data into the form after the plugins have operated.
             $form->bind($data);
             $result->profile = $form;
             $this->contact = $result;
             return $result;
         }
     }
     return false;
 }
Example #12
0
 protected function getContactQuery($pk = null)
 {
     // TODO: Cache on the fingerprint of the arguments
     $db = $this->getDbo();
     $user = JFactory::getUser();
     $pk = !empty($pk) ? $pk : (int) $this->getState('contact.id');
     $query = $db->getQuery(true);
     if ($pk) {
         $query->select('a.*, cc.access as category_access, cc.title as category_name, ' . ' CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(\':\', a.id, a.alias) ELSE a.id END as slug, ' . ' CASE WHEN CHAR_LENGTH(cc.alias) THEN CONCAT_WS(\':\', cc.id, cc.alias) ELSE cc.id END AS catslug ');
         $query->from('#__contact_details AS a');
         $query->join('INNER', '#__categories AS cc on cc.id = a.catid');
         $query->where('a.id = ' . (int) $pk);
         $published = $this->getState('filter.published');
         $archived = $this->getState('filter.archived');
         if (is_numeric($published)) {
             $query->where('a.published IN (1,2)');
             $query->where('cc.published IN (1,2)');
         }
         $groups = implode(',', $user->getAuthorisedViewLevels());
         $query->where('a.access IN (' . $groups . ')');
         try {
             $db->setQuery($query);
             $result = $db->loadObject();
             if ($error = $db->getErrorMsg()) {
                 throw new Exception($error);
             }
             if (empty($result)) {
                 throw new JException(JText::_('COM_CONTACT_ERROR_CONTACT_NOT_FOUND'), 404);
             }
             // If we are showing a contact list, then the contact parameters take priority
             // So merge the contact parameters with the merged parameters
             if ($this->getState('params')->get('show_contact_list')) {
                 $registry = new JRegistry();
                 $registry->loadJSON($result->params);
                 $this->getState('params')->merge($registry);
             }
         } catch (Exception $e) {
             $this->setError($e);
             return false;
         }
         if ($result) {
             $user = JFactory::getUser();
             $groups = implode(',', $user->getAuthorisedViewLevels());
             //get the content by the linked user
             $query = $db->getQuery(true);
             $query->select('id, title, state, access, created');
             $query->from('#__content');
             $query->where('created_by = ' . (int) $result->user_id);
             $query->where('access IN (' . $groups . ')');
             $query->order('state DESC, created DESC');
             if (is_numeric($published)) {
                 $query->where('state IN (1,2)');
             }
             $db->setQuery($query, 0, 10);
             $articles = $db->loadObjectList();
             $result->articles = $articles;
             //get the profile information for the linked user
             if ($result) {
                 require_once JPATH_ADMINISTRATOR . '/components/com_users/models/user.php';
                 $userModel = JModel::getInstance('User', 'UsersModel', array('ignore_request' => true));
                 $data = $userModel->getItem((int) $result->user_id);
                 JPluginHelper::importPlugin('user');
                 $form = new JForm('com_users.profile');
                 // Get the dispatcher.
                 $dispatcher = JDispatcher::getInstance();
                 // Trigger the form preparation event.
                 $dispatcher->trigger('onContentPrepareForm', array($form, $data));
                 // Trigger the data preparation event.
                 $dispatcher->trigger('onContentPrepareData', array('com_users.profile', $data));
                 // Load the data into the form after the plugins have operated.
                 $form->bind($data);
                 $result->profile = $form;
             }
             $this->contact = $result;
             return $result;
         }
     }
 }
Example #13
0
 /**
  * Method to inject data into the form.
  *
  * @param   JForm  $form  Form headers without data.
  *
  * @return  void
  *
  * @since   2.0
  */
 protected function bindFormData($form)
 {
     // Check the session for previously entered form data.
     $data = JFactory::getApplication()->getUserState('com_shconfig.edit.settings.data', array());
     if (empty($data)) {
         // We need to get the items from the database
         $db = $this->getDbo();
         $query = $db->getQuery(true);
         // Select the required fields from the table.
         $query->select($db->quoteName('name'))->select($db->quoteName('value'))->from($db->quoteName('#__sh_config'));
         // Build the where clause for specifying only required settings from the table
         $whereClause = array();
         foreach ($form->getFieldset() as $field) {
             $whereClause[] = $db->quoteName('name') . ' = ' . $db->quote($field->fieldname);
         }
         $query->where($whereClause, 'OR');
         $data = $db->setQuery($query)->loadAssocList('name', 'value');
     }
     $form->bind($data);
 }
Example #14
0

<?php 
JHtml::_('behavior.formvalidation');
JHtml::_('behavior.keepalive');
JHtml::_('formbehavior.chosen', 'select');
jimport('joomla.form.form');
$session = JFactory::getSession();
$modid = $module->id;
$defaultparams = JPath::clean(JPATH_ADMINISTRATOR . '/modules/mod_quickpublish/form/comcontent.xml');
$data = '';
if (JFile::exists($defaultparams)) {
    JForm::addFormPath(JPath::clean(JPATH_ADMINISTRATOR . '/modules/mod_quickpublish/form'));
    $form = new JForm('quickpublishcomponents');
    $form->loadFile('comcontent', false);
    $form->bind($data);
    $fieldSets = $form->getFieldsets('quickpublishcomponents');
    foreach ($fieldSets as $name => $fieldSet) {
        //var_dump($name);
        ?>

        <div class="row-fluid">
            <div class="span12">
                <form id="modquickpublish<?php 
        echo $name;
        ?>
" name="modquickpublish<?php 
        echo $name;
        ?>
" action="index.php">
                    <?php 
$juri_base = preg_replace("/administrator\$/", "", JURI::base(true));
RokCommon_Header::addStyle($juri_base . 'components/com_roksprocket/lib/RokSprocket/Addon/AdvancedModuleManager/assets/styles/amm-fixes.css');
$renderer = new RenderAMM();
$renderer->item = $that->item;
$renderer->form = $that->form;
if (!isset($renderer->config)) {
    require_once JPATH_PLUGINS . '/system/nnframework/helpers/parameters.php';
    $parameters = NNParameters::getInstance();
    $config = JComponentHelper::getParams('com_advancedmodules');
    $renderer->config = $parameters->getParams($config->toObject(), JPATH_ADMINISTRATOR . '/components/com_advancedmodules/config.xml');
}
if (!isset($renderer->assignments)) {
    $xmlfile = JPATH_ADMINISTRATOR . '/components/com_advancedmodules/assignments.xml';
    $assignments = new JForm('assignments', array('control' => 'advancedparams'));
    $assignments->loadFile($xmlfile, 1, '//config');
    $assignments->bind($renderer->item->advancedparams);
    $renderer->assignments = $assignments;
}
if ($renderer->config->show_color) {
    $colors = explode(',', $renderer->config->main_colors);
    foreach ($colors as $i => $c) {
        $colors[$i] = strtoupper('#' . preg_replace('#[^a-z0-9]#i', '', $c));
    }
    $script = "\n\t\tmainColors = new Array( '" . implode("', '", $colors) . "' );";
    RokCommon_Header::addInlineScript($script);
}
?>
<fieldset class="adminform">
	<div class="advanced-module-manager">
		<!-- opening divs twice for fixing joomla accordions -->
		<?php 
 /**
  * @param    object $form A form object.
  * @param    mixed  $data The data expected for the form.
  *
  * @return    void
  * @since       1.1.0
  * @throws    Exception if there is an error in the form event.
  */
 protected function preprocessForm(JForm $form, $data, $group = 'content')
 {
     $contentTypeID = $this->getState($this->getName() . '.content_type_id', 0);
     if ($contentTypeID) {
         $isNew = !(bool) $this->getState($this->getName() . '.id', 0);
         $fieldsForm = new KextensionsForm($form->getName());
         $fieldsData = FieldsandfiltersFieldsHelper::getFieldsByTypeIDColumnFieldType($contentTypeID);
         $fieldsForm->setPath('filters');
         $fieldsetXML = new SimpleXMLElement('<fieldset />');
         $fieldsetXML->addAttribute('name', 'fieldsandfilters');
         JPluginHelper::importPlugin('fieldsandfilterstypes');
         // Trigger the onFieldsandfiltersPrepareFormField event.
         JFactory::getApplication()->triggerEvent('onFieldsandfiltersPrepareFormField', array($fieldsForm, $fieldsData, $isNew));
         if ($fieldsFormXML = $fieldsForm->getFormFields()) {
             // Load the XML Helper
             KextensionsXML::setFields($fieldsetXML, $fieldsFormXML);
             $form->setField($fieldsetXML, 'fields');
             if ($default = $fieldsForm->getData()) {
                 $form->bind($default);
             }
         }
     }
     // Trigger the default form events.
     parent::preprocessForm($form, $data, $group);
 }
Example #17
0
 /**
  * Method to get a single record.
  *
  * @return  mixed    Object on success, false on failure.
  */
 public function getItem($pk = null, $getform = 0, $getdefaults = 0)
 {
     // Initialise variables.
     $pk = !empty($pk) ? $pk : (int) $this->getState($this->getName() . '.id');
     $table = $this->getTable();
     if ($pk > 0) {
         // Attempt to load the row.
         $return = $table->load($pk);
         // Check for a table object error.
         if ($return === false && $table->getError()) {
             $this->setError($table->getError());
             return false;
         }
     }
     // Convert to the JObject before adding other data.
     $properties = $table->getProperties(1);
     $item = JArrayHelper::toObject($properties, 'JObject');
     $isini = substr($item->params, 0, 1) != '{' && substr($item->params, -1, 1) != '}';
     $params = $this->parameters->getParams($item->params, JPATH_ADMINISTRATOR . '/components/com_snippets/item_params.xml');
     foreach ($params as $key => $val) {
         if (!isset($item->{$key}) && !is_object($val)) {
             $item->{$key} = $val;
         }
     }
     unset($item->params);
     if ($isini) {
         foreach ($item as $key => $val) {
             if (is_string($val) && $key != 'content') {
                 $item->{$key} = stripslashes($val);
             }
         }
     }
     if ($getform) {
         $xmlfile = JPATH_ADMINISTRATOR . '/components/com_snippets/item_params.xml';
         $params = new JForm('jform', array('control' => 'jform'));
         $params->loadFile($xmlfile, 1, '//config');
         $params->bind($item);
         $item->form = $params;
     }
     if ($getdefaults) {
         $item->defaults = $this->parameters->getParams('', JPATH_ADMINISTRATOR . '/components/com_snippets/item_params.xml');
     }
     return $item;
 }
 /**
  * @param    JForm $form The form to be altered.
  * @param    array $data The associated data for the form.
  *
  * @return    boolean
  * @since       1.0.0
  */
 public function onFieldsandfiltersPrepareForm(JForm $form, $data)
 {
     $context = $form->getName();
     if (!($context == $this->_context || $context == 'com_fieldsandfilters.elements.filter')) {
         return true;
     }
     $app = JFactory::getApplication();
     if ($context == 'com_fieldsandfilters.elements.filter') {
         $form->addFieldPath(JPATH_ADMINISTRATOR . '/components/com_categories/models/fields');
         $addform = new SimpleXMLElement('<form />');
         $fields = $addform->addChild('fields');
         $fields->addAttribute('name', 'filter');
         $field = $fields->addChild('field');
         $field->addAttribute('name', 'item_category');
         $field->addAttribute('type', 'category');
         $field->addAttribute('label', 'JOPTION_FILTER_CATEGORY');
         $field->addAttribute('description', 'JOPTION_FILTER_CATEGORY_DESC');
         $field->addAttribute('extension', 'com_content');
         $field->addAttribute('onchange', 'this.form.submit();');
         KextensionsXML::addOptionsNode($field, array('JOPTION_SELECT_CATEGORY' => ''));
         $form->load($addform, false);
     } elseif ($context == $this->_context) {
         if ($app->isSite() && !$this->params->get('frontend_edit', false) || !($extension = FieldsandfiltersFactory::getExtensions()->getExtensionsByName($this->_name)->get($this->_name))) {
             return true;
         }
         JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_fieldsandfilters/models', 'FieldsandfiltersModel');
         if (!($elementModel = JModelLegacy::getInstance('element', 'FieldsandfiltersModel', array('ignore_request' => true, 'table_path' => JPATH_ADMINISTRATOR . '/components/com_fieldsandfilters/tables')))) {
             return true;
         }
         // Load Extension Language
         KextensionsLanguage::load('com_fieldsandfilters', JPATH_ADMINISTRATOR);
         $fieldsForm = new KextensionsForm($this->_context . '.' . $this->_name);
         $fieldsData = FieldsandfiltersFieldsHelper::getFieldsByTypeIDColumnFieldType($extension->content_type_id);
         $formPath = $app->isAdmin() ? 'attribs.fieldsandfilters' : 'fieldsandfilters';
         $fieldsForm->setPath($formPath);
         $fieldsetXML = new SimpleXMLElement('<fieldset />');
         $fieldsetXML->addAttribute('name', 'fieldsandfilters');
         $fieldsetXML->addAttribute('label', 'COM_FIELDSANDFILTERS');
         // $fieldsetXML->addAttribute( 'description', 'COM_FIELDSANDFILTERS_FIELDSET_DESC' );
         $fielsXML = $fieldsetXML->addChild('fields');
         $fielsXML->addAttribute('name', 'fieldsandfilters');
         $fieldXML = $fielsXML->addChild('field');
         $fieldXML->addAttribute('name', '_fieldsandfilters');
         $fieldXML->addAttribute('type', 'hidden');
         $fieldXML->addAttribute('fieldset', 'fieldsandfilters');
         if (!empty($data)) {
             $data = (object) $data;
             $elementModel->setState($elementModel->getName() . '.item_id', $data->id);
             $elementModel->setState($elementModel->getName() . '.content_type_id', $extension->content_type_id);
             $elementItem = $elementModel->getItem();
         }
         $isNew = empty($elementItem->id);
         JPluginHelper::importPlugin('fieldsandfilterstypes');
         // Trigger the onFieldsandfiltersPrepareFormField event.
         $app->triggerEvent('onFieldsandfiltersPrepareFormField', array($fieldsForm, $fieldsData, $isNew));
         if ($fieldsFormXML = $fieldsForm->getFormFields()) {
             // Load the XML Helper
             KextensionsXML::setFields($fielsXML, $fieldsFormXML);
             $form->setField($fieldsetXML, $app->isAdmin() ? 'attribs' : null);
             // For joomla 2.5 && Key Reference
             if (!FieldsandfiltersFactory::isVersion()) {
                 $fieldsetXML = new SimpleXMLElement('<fieldset />');
                 $fieldsetXML->addAttribute('name', 'key_reference');
                 $fieldsetXML->addAttribute('label', 'Key Reference');
                 $form->setField($fieldsetXML, 'attribs');
             }
             if ($default = $fieldsForm->getData()) {
                 $form->bind($default);
             }
             if (!$isNew) {
                 $data = new JRegistry();
                 $data->set($formPath, $elementItem->get('fields', new JObject()));
                 $form->bind($data);
             }
         }
         return true;
     }
 }
Example #19
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;
 }
Example #20
0
 /**
  * Render the initial plugin options, such as the plugin selector, and whether its rendered in front/back/both etc
  *
  * @return  string
  */
 public function top()
 {
     $data = $this->getData();
     $c = $this->getState('c') + 1;
     $version = new JVersion();
     $j3 = version_compare($version->RELEASE, '3.0') >= 0 ? true : false;
     $class = $j3 ? 'form-horizontal ' : 'adminform ';
     $str = array();
     $str[] = '<div class="pane-slider content pane-down accordion-inner">';
     $str[] = '<fieldset class="' . $class . 'pluginContainer" id="formAction_' . $c . '"><ul>';
     $formName = 'com_fabrik.' . $this->getState('type') . '-plugin';
     $topForm = new JForm($formName, array('control' => 'jform'));
     $topForm->repeatCounter = $c;
     $xmlFile = JPATH_SITE . '/administrator/components/com_fabrik/models/forms/' . $this->getState('type') . '-plugin.xml';
     // Add the plugin specific fields to the form.
     $topForm->loadFile($xmlFile, false);
     $topForm->bind($data);
     // Filter the forms fieldsets for those starting with the correct $searchName prefix
     foreach ($topForm->getFieldsets() as $fieldset) {
         if ($fieldset->label != '') {
             $str[] = '<legend>' . $fieldset->label . '</legend>';
         }
         foreach ($topForm->getFieldset($fieldset->name) as $field) {
             if (!$j3) {
                 $str[] = '<li>' . $field->label . $field->input . '</li>';
             } else {
                 $str[] = '<div class="control-group"><div class="control-label">' . $field->label;
                 $str[] = '</div><div class="controls">' . $field->input . '</div></div>';
             }
         }
     }
     $str[] = '</ul>';
     $str[] = '<div class="pluginOpts" style="clear:left"></div>';
     if ($j3) {
         $str[] = '<div class="form-actions"><a href="#" class="btn btn-danger" data-button="removeButton">';
         $str[] = '<i class="icon-delete"></i> ' . FText::_('COM_FABRIK_DELETE') . '</a></div>';
     } else {
         $str[] = '<a href="#" class="delete removeButton">' . FText::_('COM_FABRIK_DELETE') . '</a>';
     }
     $str[] = '</fieldset>';
     $str[] = '</div>';
     return implode("\n", $str);
 }