/** * Add the page title and toolbar. */ protected function addToolbar() { JFactory::getApplication()->input->set('hidemainmenu', true); $user = JFactory::getUser(); $isNew = $this->item->id == 0; if (isset($this->item->checked_out)) { $checkedOut = !($this->item->checked_out == 0 || $this->item->checked_out == $user->get('id')); } else { $checkedOut = false; } $canDo = TjfieldsHelper::getActions(); JToolBarHelper::title(JText::_('COM_TJFIELDS_TITLE_FIELD'), 'field.png'); // If not checked out, can save the item. if (!$checkedOut && ($canDo->get('core.edit') || $canDo->get('core.create'))) { JToolBarHelper::apply('field.apply', 'JTOOLBAR_APPLY'); JToolBarHelper::save('field.save', 'JTOOLBAR_SAVE'); } if (!$checkedOut && $canDo->get('core.create')) { JToolBarHelper::custom('field.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); } // If an existing item, can save to a copy. if (!$isNew && $canDo->get('core.create')) { JToolBarHelper::custom('field.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); } if (empty($this->item->id)) { JToolBarHelper::cancel('field.cancel', 'JTOOLBAR_CANCEL'); } else { JToolBarHelper::cancel('field.cancel', 'JTOOLBAR_CLOSE'); } }
/** * Add the page title and toolbar. * * @since 1.6 */ protected function addToolbar() { require_once JPATH_COMPONENT . '/helpers/tjfields.php'; $state = $this->get('State'); $canDo = TjfieldsHelper::getActions($state->get('filter.category_id')); JToolBarHelper::title(JText::_('COM_TJFIELDS_TITLE_GROUPS'), 'groups.png'); //Check if the form exists before showing the add/edit buttons $formPath = JPATH_COMPONENT_ADMINISTRATOR . '/views/group'; if (file_exists($formPath)) { if ($canDo->get('core.create')) { JToolBarHelper::addNew('group.add', 'JTOOLBAR_NEW'); } /* if ($canDo->get('core.edit') && isset($this->items[0])) { JToolBarHelper::editList('group.edit','JTOOLBAR_EDIT'); }*/ } if ($canDo->get('core.edit.state')) { if (isset($this->items[0]->state)) { JToolBarHelper::divider(); JToolBarHelper::custom('groups.publish', 'publish.png', 'publish_f2.png', 'JTOOLBAR_PUBLISH', true); JToolBarHelper::custom('groups.unpublish', 'unpublish.png', 'unpublish_f2.png', 'JTOOLBAR_UNPUBLISH', true); } else { if (isset($this->items[0])) { //If this component does not use state then show a direct delete button as we can not trash JToolBarHelper::deleteList('', 'groups.delete', 'JTOOLBAR_DELETE'); } } /* if (isset($this->items[0]->state)) { JToolBarHelper::divider(); JToolBarHelper::archiveList('groups.archive','JTOOLBAR_ARCHIVE'); }*/ if (isset($this->items[0]->checked_out)) { JToolBarHelper::custom('groups.checkin', 'checkin.png', 'checkin_f2.png', 'JTOOLBAR_CHECKIN', true); } } //Show trash and delete for components that uses the state field if (isset($this->items[0]->state)) { if ($state->get('filter.state') == -2 && $canDo->get('core.delete')) { JToolBarHelper::deleteList('', 'groups.delete', 'JTOOLBAR_EMPTY_TRASH'); JToolBarHelper::divider(); } else { if ($canDo->get('core.edit.state')) { JToolBarHelper::trash('groups.trash', 'JTOOLBAR_TRASH'); JToolBarHelper::divider(); } } } if ($canDo->get('core.admin')) { JToolBarHelper::preferences('com_tjfields'); } $this->extra_sidebar = ''; if (JVERSION >= '3.0') { //Set sidebar action - New in 3.0 JHtmlSidebar::setAction('index.php?option=com_tjfields&view=groups'); JHtmlSidebar::addFilter(JText::_('JOPTION_SELECT_PUBLISHED'), 'filter_published', JHtml::_('select.options', JHtml::_('jgrid.publishedOptions'), "value", "text", $this->state->get('filter.state'), true)); } }
/** * Add the page title and toolbar. * * @return void * * @since 1.6 */ protected function addToolbar() { require_once JPATH_COMPONENT . '/helpers/tjfields.php'; $state = $this->get('State'); $canDo = TjfieldsHelper::getActions(); // Let's get the extension name $client = JFactory::getApplication()->input->get('client', '', 'STRING'); $extensionName = strtoupper($client); // Need to load the menu language file as mod_menu hasn't been loaded yet. $lang = JFactory::getLanguage(); $lang->load($client, JPATH_ADMINISTRATOR, null, false, true); if (JVERSION >= '3.0') { JToolBarHelper::title(JText::_($extensionName) . ': ' . JText::_('COM_TJFIELDS_TITLE_COUNTRIES'), 'list'); } else { JToolBarHelper::title(JText::_($extensionName) . ': ' . JText::_('COM_TJFIELDS_TITLE_COUNTRIES'), 'countries.png'); } // Check if the form exists before showing the add/edit buttons $formPath = JPATH_COMPONENT_ADMINISTRATOR . '/views/country'; if (file_exists($formPath)) { if ($canDo->get('core.create')) { JToolBarHelper::addNew('country.add', 'JTOOLBAR_NEW'); } if ($canDo->get('core.edit') && isset($this->items[0])) { JToolBarHelper::editList('country.edit', 'JTOOLBAR_EDIT'); } } if ($canDo->get('core.edit.state')) { if (isset($this->items[0]->state)) { JToolBarHelper::divider(); JToolBarHelper::custom('countries.publish', 'publish.png', 'publish_f2.png', 'JTOOLBAR_PUBLISH', true); JToolBarHelper::custom('countries.unpublish', 'unpublish.png', 'unpublish_f2.png', 'JTOOLBAR_UNPUBLISH', true); } } if ($canDo->get('core.admin')) { JToolBarHelper::preferences('com_tjfields'); } if (JVERSION >= '3.0') { // Set sidebar action JHtmlSidebar::setAction('index.php?option=com_tjfields&view=countries'); } $this->extra_sidebar = ''; }
/** * Add the page title and toolbar. * * @return void * * @since 1.6 */ protected function addToolbar() { JFactory::getApplication()->input->set('hidemainmenu', true); $user = JFactory::getUser(); $isNew = $this->item->id == 0; // Let's get the extension name $client = JFactory::getApplication()->input->get('client', '', 'STRING'); $extensionName = strtoupper($client); // Need to load the menu language file as mod_menu hasn't been loaded yet. $lang = JFactory::getLanguage(); $lang->load($client, JPATH_ADMINISTRATOR, null, false, true); $viewTitle = JText::_($extensionName); if ($isNew) { $viewTitle = $viewTitle . ': ' . JText::_('COM_TJFIELDS_ADD_CITY'); } else { $viewTitle = $viewTitle . ': ' . JText::_('COM_TJFIELDS_EDIT_CITY'); } if (JVERSION >= '3.0') { JToolBarHelper::title($viewTitle, 'pencil-2'); } else { JToolBarHelper::title($viewTitle, 'city.png'); } if (isset($this->item->checked_out)) { $checkedOut = !($this->item->checked_out == 0 || $this->item->checked_out == $user->get('id')); } else { $checkedOut = false; } $canDo = TjfieldsHelper::getActions(); // If not checked out, can save the item. if (!$checkedOut && ($canDo->get('core.edit') || $canDo->get('core.create'))) { JToolBarHelper::apply('city.apply', 'JTOOLBAR_APPLY'); JToolBarHelper::save('city.save', 'JTOOLBAR_SAVE'); } if (empty($this->item->id)) { JToolBarHelper::cancel('city.cancel', 'JTOOLBAR_CANCEL'); } else { JToolBarHelper::cancel('city.cancel', 'JTOOLBAR_CLOSE'); } }
public function delete() { // Check for request forgeries JSession::checkToken() or die(JText::_('JINVALID_TOKEN')); //GET CLIENT AND CLIENT TYPE $input = JFactory::getApplication()->input; $client = $input->get('client', '', 'STRING'); $client_form = explode('.', $client); $client_type = $client_form[1]; // Get items to remove from the request. $cid = JFactory::getApplication()->input->get('cid', array(), 'array'); if (!is_array($cid) || count($cid) < 1) { JLog::add(JText::_($this->text_prefix . '_NO_ITEM_SELECTED'), JLog::WARNING, 'jerror'); } else { // Get the model. $model = $this->getModel('fields'); // Make sure the item ids are integers jimport('joomla.utilities.arrayhelper'); JArrayHelper::toInteger($cid); // Remove the items. if ($model->deletefield($cid)) { $TjfieldsHelper = new TjfieldsHelper(); $data = array(); $data['client'] = $client; $data['client_type'] = $client_type; $TjfieldsHelper->generateXml($data); // $this->setMessage(JText::plural($this->text_prefix . '_N_ITEMS_DELETED', count($cid))); $ntext = $this->text_prefix . '_N_ITEMS_DELETED'; } else { $this->setMessage($model->getError()); } } $this->setMessage(JText::plural($ntext, count($cid))); $this->setRedirect('index.php?option=com_tjfields&view=fields&client=' . $client, false); }
public function save_option($post) { $table = $this->getTable(); $data = $post->get('jform', '', 'ARRAY'); //add clint type in data as it is not present in jform $data['client_type'] = $post->get('client_type', '', 'STRING'); $data['saveOption'] = 0; // use later to store later. //remove extra value which are not needed to save in the fields table $TjfieldsHelper = new TjfieldsHelper(); $data = $TjfieldsHelper->getFieldArrayFormatted($data); if ($table->save($data) === true) { $id = $table->id; } //check if name feild is unique $is_unique = $TjfieldsHelper->checkIfUniqueName($data['name']); //print_r($is_unique); die; if ($is_unique > 1) { //append id to the name $change_name_if_same = $TjfieldsHelper->changeNameIfNotUnique($data['name'], $id); } //save javascript functions. $js = $post->get('tjfieldsJs', '', 'ARRAY'); if (!empty($js)) { $jsfunctionSave = $this->jsfunctionSave($js, $id); } //end // if the field is inserted. if ($id) { //print_r($post); die('asd'); $options = $post->get('tjfields', '', 'ARRAY'); //print_r($options); die('asdasd11111'); if ($data['saveOption'] == 1) { //Firstly Delete Fields Options That are Removed $field_options = $TjfieldsHelper->getOptions($id); foreach ($field_options as $fokey => $fovalue) { if ($fovalue->id) { $fields_in_DB[] = $fovalue->id; } } foreach ($options as $key => $value) { if ($value['hiddenoptionid']) { $options_filled[] = $value['hiddenoptionid']; } } if ($fields_in_DB) { $diff_ids = array_diff($fields_in_DB, $options_filled); if (!empty($diff_ids)) { $this->delete_option($diff_ids); } } if (empty($options)) { $this->delete_option($fields_in_DB); } else { //save option fields. foreach ($options as $option) { if (!isset($option['hiddenoption'])) { $option['hiddenoption'] = 0; } $obj = new stdClass(); $obj->options = $option['optionname']; $obj->value = $option['optionvalue']; $obj->default_option = $option['hiddenoption']; $obj->field_id = $id; //if edit options if (isset($option['hiddenoptionid']) && !empty($option['hiddenoptionid'])) { if ($option['optionname'] != '' && $option['optionvalue'] != '') { $obj->id = $option['hiddenoptionid']; if (!$this->_db->updateObject('#__tjfields_options', $obj, 'id')) { echo $this->_db->stderr(); return false; } } } else { if ($option['optionname'] != '' && $option['optionvalue'] != '') { $obj->id = ''; if (!$this->_db->insertObject('#__tjfields_options', $obj, 'id')) { echo $this->_db->stderr(); return false; } } } } } //return true; } //create XML for the current client. $TjfieldsHelper->generateXml($data); return $id; } else { return false; } }
/** * Add the page title and toolbar. * * @since 1.6 */ protected function addToolbar() { require_once JPATH_COMPONENT . '/helpers/tjfields.php'; $state = $this->get('State'); $canDo = TjfieldsHelper::getActions($state->get('filter.category_id')); JToolBarHelper::title(JText::_('COM_TJFIELDS_TITLE_FIELDS'), 'fields.png'); //Check if the form exists before showing the add/edit buttons $formPath = JPATH_COMPONENT_ADMINISTRATOR . '/views/field'; if (file_exists($formPath)) { if ($canDo->get('core.create')) { JToolBarHelper::addNew('field.add', 'JTOOLBAR_NEW'); } /* if ($canDo->get('core.edit') && isset($this->items[0])) { JToolBarHelper::editList('field.edit','JTOOLBAR_EDIT'); }*/ } if ($canDo->get('core.edit.state')) { if (isset($this->items[0]->state)) { JToolBarHelper::divider(); JToolBarHelper::custom('fields.publish', 'publish.png', 'publish_f2.png', 'JTOOLBAR_PUBLISH', true); JToolBarHelper::custom('fields.unpublish', 'unpublish.png', 'unpublish_f2.png', 'JTOOLBAR_UNPUBLISH', true); } else { if (isset($this->items[0])) { //If this component does not use state then show a direct delete button as we can not trash JToolBarHelper::deleteList('', 'fields.delete', 'JTOOLBAR_DELETE'); } } /* if (isset($this->items[0]->state)) { JToolBarHelper::divider(); JToolBarHelper::archiveList('fields.archive','JTOOLBAR_ARCHIVE'); }*/ if (isset($this->items[0]->checked_out)) { JToolBarHelper::custom('fields.checkin', 'checkin.png', 'checkin_f2.png', 'JTOOLBAR_CHECKIN', true); } } //Show trash and delete for components that uses the state field if (isset($this->items[0]->state)) { if ($state->get('filter.state') == -2 && $canDo->get('core.delete')) { JToolBarHelper::deleteList('', 'fields.delete', 'JTOOLBAR_EMPTY_TRASH'); JToolBarHelper::divider(); } else { if ($canDo->get('core.edit.state')) { JToolBarHelper::trash('fields.trash', 'JTOOLBAR_TRASH'); JToolBarHelper::divider(); } } } if ($canDo->get('core.admin')) { JToolBarHelper::preferences('com_tjfields'); } $input = jFactory::getApplication()->input; $this->extra_sidebar = ''; //Filter for the field field_type $select_label = JText::sprintf('COM_TJFIELDS_FILTER_SELECT_LABEL', 'Field Type'); $options = array(); $options[0] = new stdClass(); $options[0]->value = "text"; $options[0]->text = "Text"; $options[1] = new stdClass(); $options[1]->value = "radio"; $options[1]->text = "Radio"; $options[2] = new stdClass(); $options[2]->value = "single_select"; $options[2]->text = "Single select"; $options[3] = new stdClass(); $options[3]->value = "multi_select"; $options[3]->text = "Multiple select"; $options[4] = new stdClass(); $options[4]->value = "hidden"; $options[4]->text = "Hidden"; $options[5] = new stdClass(); $options[5]->value = "textarea"; $options[5]->text = "Textarea"; $options[6] = new stdClass(); $options[6]->value = "checkbox"; $options[6]->text = "Checkbox"; $options[7] = new stdClass(); $options[7]->value = "calender"; $options[7]->text = "Calender"; $options[8] = new stdClass(); $options[8]->value = "editor"; $options[8]->text = "Editor"; $options[9] = new stdClass(); $options[9]->value = "email_field"; $options[9]->text = "Email"; $options[10] = new stdClass(); $options[10]->value = "password"; $options[10]->text = "Password"; $options[11] = new stdClass(); $options[11]->value = "file"; $options[11]->text = "File"; if (JVERSION >= '3.0') { //Set sidebar action - New in 3.0 JHtmlSidebar::setAction('index.php?option=com_tjfields&view=fields&client="' . $input->get('client', '', 'STRING') . '"'); JHtmlSidebar::addFilter($select_label, 'filter_field_type', JHtml::_('select.options', $options, "value", "text", $this->state->get('filter.type'), true)); JHtmlSidebar::addFilter(JText::_('JOPTION_SELECT_PUBLISHED'), 'filter_published', JHtml::_('select.options', JHtml::_('jgrid.publishedOptions'), "value", "text", $this->state->get('filter.state'), true)); } }