/** * Add the page title and toolbar. */ protected function addToolbar() { JFactory::getApplication()->input->set('hidemainmenu', true); $user = JFactory::getUser(); $isNew = $this->item->id == 0; $checkedOut = !($this->item->checked_out == 0 || $this->item->checked_out == $user->get('id')); $canDo = SibdietHelper::getActions(); JToolBarHelper::title(JText::_('COM_SIBDIET_MANAGER_ERRAND'), 'database errands'); // If not checked out, can save the item. if (!$checkedOut && ($canDo->get('core.edit') || $canDo->get('core.create'))) { JToolBarHelper::apply('errand.apply'); JToolBarHelper::save('errand.save'); } if (!$checkedOut && $canDo->get('core.create')) { JToolbarHelper::save2new('errand.save2new'); } // If an existing item, can save to a copy. if (!$isNew && $canDo->get('core.create')) { JToolbarHelper::save2copy('errand.save2copy'); } if (empty($this->item->id)) { JToolBarHelper::cancel('errand.cancel'); } else { JToolBarHelper::cancel('errand.cancel', 'JTOOLBAR_CLOSE'); } }
/** * Method to get the field input markup for check boxes. * * @return string The field input markup. * * @since 11.1 */ protected function getInput() { $html = array(); // Get default id $this->defaults_id = $this->form->getValue('defaults_id') ? $this->form->getValue('defaults_id') : 0; // Set days $days = $this->element['days'] ? $this->element['days'] : '1-2-3-4-5-6-7'; $days = $this->form->getValue('days') ? $this->form->getValue('days') : $days; $days = explode('-', $days); // Set meals $meals = $this->element['meals'] ? $this->element['meals'] : '1,2,3'; $meals = $this->form->getValue('meal') ? $this->form->getValue('meal') : $meals; $meals = explode(',', $meals); // Temp value $value_array = $this->value; foreach ($meals as $meal) { $this->meal = $meal; $options = (array) $this->getOptions(); $html[] = '<div class="span4">'; $html[] = '<div class="control-group center">' . SibdietHelper::convertMeals($meal) . '</div>'; foreach ($days as $day) { $this->value = isset($value_array[$meal][$day]) ? $value_array[$meal][$day] : ''; $this->name = 'jform[' . $this->fieldname . '][' . $meal . '][' . $day . ']'; $this->id = $this->id . 'meal' . $meal . 'day' . $day; $this->hint = SibdietHelper::dayToString($day); $html[] = '<div class="control-group center">'; $html[] = parent::getInput(); $html[] = '</div>'; } $html[] = '</div>'; } return implode($html); }
/** * Display the view * * @param string $tpl The name of the template file to parse; automatically searches through the template paths. * * @return void */ public function display($tpl = null) { if ($this->getLayout() !== 'modal') { SibdietHelper::addSubmenu('profiles'); } $this->items = $this->get('Items'); $this->pagination = $this->get('Pagination'); $this->state = $this->get('State'); $this->filterForm = $this->get('FilterForm'); $this->activeFilters = $this->get('ActiveFilters'); // Check for errors. if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode("\n", $errors)); return false; } $this->permissions = SibdietHelper::getUserPermissions(); if ($this->getLayout() !== 'modal') { // Calculate profile refer No. foreach ($this->items as $item) { $item->referNo = SibdietHelper::getReferNo($item->id); } $this->addToolbar(); $this->sidebar = JHtmlSidebar::render(); } if (in_array('profiles', $this->permissions) || $this->getLayout() == 'modal') { parent::display($tpl); } }
/** * Method override to check if you can edit an existing record. * * @param array $data An array of input data. * @param string $key The name of the key for the primary key. * * @return boolean * * @since 1.6 */ protected function allowEdit($data = array(), $key = 'id') { $permissions = SibdietHelper::getUserPermissions(); $recordId = (int) isset($data[$key]) ? $data[$key] : 0; $user = JFactory::getUser(); $userId = $user->get('id'); // Check requests manage permission first. if ($this->input->get('return') == 'requestschecks') { if (in_array('requestschecks', $permissions)) { return parent::allowEdit($data, $key); } } elseif (in_array('requests', $permissions)) { // Check that diet not started if ($recordId) { // Need to do a lookup from the model. $record = $this->getModel()->getItem($recordId); if ($record->room1 || $record->room2 || $record->room3 || $record->room4 || $record->room5 || $record->room6) { return false; } // Now test the owner is the user. $ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0; if (empty($ownerId)) { if (empty($record)) { return false; } $ownerId = $record->created_by; } // If the owner matches 'me' then do the test. if ($ownerId == $userId) { return true; } } } return false; }
/** * 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 a Error object. */ public function display($tpl = null) { $app = JFactory::getApplication(); $user = JFactory::getUser(); $this->item = $this->get('Item'); $this->print = $app->input->getBool('print'); $this->secretkey = $app->input->getString('secretkey'); $this->state = $this->get('State'); $this->user = $user; $this->params = $this->state->get('params'); // Check for errors. if (count($errors = $this->get('Errors'))) { JError::raiseWarning(500, implode("\n", $errors)); return false; } // Check the view access to the request print. if ($user->get('guest')) { if (!empty($this->secretkey) && $this->secretkey == $this->item->secretkey) { // User requested diet print by secret key } else { JError::raiseWarning(403, JText::_('JERROR_ALERTNOAUTHOR')); return; } } // Convert body field to array. $registry = new JRegistry(); $registry->loadString($this->item->body); $this->item->body = $registry->toArray(); $this->item = (object) array_merge((array) $this->item, $this->item->body); $this->item = SibdietHelper::calculate($this->item); //Escape strings for HTML output $this->pageclass_sfx = htmlspecialchars($this->params->get('pageclass_sfx')); $this->_prepareDocument(); parent::display($tpl); }
/** * Method to toggle the featured setting of a list of articles. * * @return void * * @since 1.6 */ public function featured() { // Check for request forgeries JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); $user = JFactory::getUser(); $ids = $this->input->get('cid', array(), 'array'); $values = array('featured' => 1, 'unfeatured' => 0); $task = $this->getTask(); $value = JArrayHelper::getValue($values, $task, 0, 'int'); // Access checks. foreach ($ids as $i => $id) { $permissions = SibdietHelper::getUserPermissions(); if (!in_array('nutrients', $permissions) || !$user->authorise('core.edit.state', 'com_sibdiet.nutrient.' . (int) $id)) { // Prune items that you can't change. unset($ids[$i]); JError::raiseNotice(403, JText::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED')); } } if (empty($ids)) { JError::raiseWarning(500, JText::_('JERROR_NO_ITEMS_SELECTED')); } else { // Get the model. $model = $this->getModel(); // Publish the items. if (!$model->featured($ids, $value)) { JError::raiseWarning(500, $model->getError()); } if ($value == 1) { $message = JText::plural('COM_SIBDIET_N_ITEMS_FEATURED', count($ids)); } else { $message = JText::plural('COM_SIBDIET_N_ITEMS_UNFEATURED', count($ids)); } } $this->setRedirect('index.php?option=com_sibdiet&view=nutrients', false, $message); }
/** * Display the view * * @param string $tpl The name of the template file to parse; automatically searches through the template paths. * * @return void */ public function display($tpl = null) { SibdietHelper::addSubmenu('requestschecks'); $this->items = $this->get('Items'); $this->pagination = $this->get('Pagination'); $this->state = $this->get('State'); $this->filterForm = $this->get('FilterForm'); $this->activeFilters = $this->get('ActiveFilters'); // Check for errors. if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode("\n", $errors)); return false; } $this->permissions = SibdietHelper::getUserPermissions(); // Calculate profile refer No. foreach ($this->items as $item) { $item->referNo = SibdietHelper::getReferNo($item->profiles_id); // Convert the payment field to an array. $registry = new JRegistry(); $registry->loadString($item->payment); $item->payment = $registry->toArray(); } $this->addToolbar(); $this->sidebar = JHtmlSidebar::render(); if (in_array('requestschecks', $this->permissions)) { parent::display($tpl); } }
/** * 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 a 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'); $this->canDo = JHelperContent::getActions('com_sibdiet'); $this->return = JFactory::getApplication()->input->getCmd('return'); // Check for errors. if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode("\n", $errors)); return false; } // Check second time $this->second_time = false; if ($this->item->profiles_id) { $db = JFactory::getDbo(); $query = $db->getQuery(true)->select('COUNT(id)')->from('#__sibdiet_setdiets')->where('profiles_id = ' . $this->item->profiles_id)->where('id <> ' . (int) $this->item->id); $db->setQuery($query); $this->second_time = $db->loadResult(); } $this->permissions = SibdietHelper::getUserPermissions(); $this->addToolbar(); if (in_array('requests', $this->permissions) || in_array('requestschecks', $this->permissions)) { parent::display($tpl); } }
/** * Add the page title and toolbar. * * @since 1.6 */ protected function addToolbar() { require_once JPATH_COMPONENT . '/helpers/sibdiet.php'; $state = $this->get('State'); $canDo = SibdietHelper::getActions(); // Get the toolbar object instance $bar = JToolBar::getInstance('toolbar'); JToolBarHelper::title(JText::_('COM_SIBDIET_MANAGER_ACTIVITIES'), 'database activities'); if ($canDo->get('core.create')) { JToolBarHelper::addNew('activity.add'); } if ($canDo->get('core.edit') && isset($this->items[0])) { JToolBarHelper::editList('activity.edit'); } if ($canDo->get('core.edit.state')) { JToolbarHelper::checkin('activities.checkin'); } if ($state->get('filter.state') == -2 && $canDo->get('core.delete')) { JToolbarHelper::publish('activities.publish', 'JTOOLBAR_PUBLISH', true); JToolbarHelper::deleteList('', 'activities.delete', 'JTOOLBAR_EMPTY_TRASH'); } elseif ($canDo->get('core.edit.state')) { JToolbarHelper::trash('activities.trash'); } if ($canDo->get('core.admin')) { JToolBarHelper::preferences('com_sibdiet'); } JHtmlSidebar::setAction('index.php?option=com_sibdiet&view=activities'); }
/** * Add the page title and toolbar. * * @return void * * @since 1.6 */ protected function addToolbar() { $canDo = SibdietHelper::getActions('com_sibdiet'); // Get the toolbar object instance $bar = JToolBar::getInstance('toolbar'); JToolBarHelper::title(JText::_('COM_SIBDIET_MANAGER_CONTAGS'), 'tags contags'); if (in_array('contags', $this->permissions)) { if ($canDo->get('core.create')) { JToolBarHelper::addNew('contag.add'); } if (isset($this->items[0])) { if ($canDo->get('core.edit')) { JToolBarHelper::editList('contag.edit'); } if ($canDo->get('core.edit.state')) { JToolbarHelper::checkin('contags.checkin'); } if ($this->state->get('filter.state') == -2 && $canDo->get('core.delete')) { JToolbarHelper::publish('contags.publish', 'JTOOLBAR_PUBLISH', true); JToolbarHelper::deleteList('', 'contags.delete', 'JTOOLBAR_EMPTY_TRASH'); } elseif ($canDo->get('core.edit.state')) { JToolbarHelper::trash('contags.trash'); } } } if ($canDo->get('core.admin')) { JToolBarHelper::preferences('com_sibdiet'); } }
/** * Method to get the field input markup. * * @return string The field input markup. * * @since 11.1 */ protected function getInput() { $html = parent::getInput(); $default = SibdietHelper::getDefault((int) $this->value); $class = $this->element['class'] ? ' class="control-label ' . (string) $this->element['class'] . '"' : 'control-label'; $html .= '<div' . $class . '>' . $default . '</div>'; return $html; }
/** * Method override to check if you can edit an existing record. * * @param array $data An array of input data. * @param string $key The name of the key for the primary key. * * @return boolean * * @since 1.6 */ protected function allowEdit($data = array(), $key = 'id') { $permissions = SibdietHelper::getUserPermissions(); if (in_array('sweeteners', $permissions)) { return parent::allowEdit($data, $key); } else { return false; } }
/** * Add the page title and toolbar. */ protected function addToolbar() { JFactory::getApplication()->input->set('hidemainmenu', true); $user = JFactory::getUser(); $isNew = $this->item->id == 0; $canDo = SibdietHelper::getActions(); JToolBarHelper::title(JText::_('COM_SIBDIET_MANAGER_SETTING'), 'database settings'); // If not checked out, can save the item. if ($canDo->get('core.manage')) { JToolBarHelper::apply('setting.apply'); } JToolBarHelper::back('JTOOLBAR_BACK', 'index.php?option=com_sibdiet'); }
/** * Display the view * * @param string $tpl The name of the template file to parse; automatically searches through the template paths. * * @return void */ public function display($tpl = null) { SibdietHelper::addSubmenu('cpanel'); // Check for errors. if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode("\n", $errors)); return false; } // Get list of sibdiet buttons $this->buttons = SibdietHelper::getButtons(); $this->addToolbar(); parent::display($tpl); }
/** * Method to get the field options. * * @return array The field option objects. * * @since 11.1 */ public function getOptions() { $type = NULL; $jinput = JFactory::getApplication()->input; if ($jinput->get('view') == 'request') { if ($jinput->get('return')) { $type = 'con'; } else { $type = 'opt'; } } $options = SibdietHelper::getConTagsOptions($type); return array_merge(parent::getOptions(), $options); }
/** * 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 a 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'); $this->canDo = SibdietHelper::getActions('com_sibdiet'); // Check for errors. if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode("\n", $errors)); return false; } $this->permissions = SibdietHelper::getUserPermissions(); $this->addToolbar(); if (in_array('units', $this->permissions)) { parent::display($tpl); } }
/** * Display the view * * @param string $tpl The name of the template file to parse; automatically searches through the template paths. * * @return void */ public function display($tpl = null) { $this->items = $this->get('Items'); $this->pagination = $this->get('Pagination'); $this->state = $this->get('State'); $this->filterForm = $this->get('FilterForm'); $this->activeFilters = $this->get('ActiveFilters'); // Check for errors. if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode("\n", $errors)); return false; } SibdietHelper::addSubmenu('countries'); $this->addToolbar(); $this->sidebar = JHtmlSidebar::render(); parent::display($tpl); }
/** * Add the page title and toolbar. * * @return void * * @since 1.6 */ protected function addToolbar() { $canDo = SibdietHelper::getActions('com_sibdiet'); // Get the toolbar object instance $bar = JToolBar::getInstance('toolbar'); $bar->addButtonPath(JPATH_COMPONENT . '/toolbar/button/'); JToolBarHelper::title(JText::_('COM_SIBDIET_MANAGER_FOODS'), 'database foods'); if (in_array('foods', $this->permissions)) { if ($canDo->get('core.create')) { JToolBarHelper::addNew('food.add'); } if (isset($this->items[0])) { if ($canDo->get('core.edit')) { JToolBarHelper::editList('food.edit'); } if ($canDo->get('core.edit.state')) { JToolbarHelper::checkin('foods.checkin'); } if ($this->state->get('filter.state') == -2 && $canDo->get('core.delete')) { JToolbarHelper::publish('foods.publish', 'JTOOLBAR_PUBLISH', true); JToolbarHelper::deleteList('', 'foods.delete', 'JTOOLBAR_EMPTY_TRASH'); } elseif ($canDo->get('core.edit.state')) { JToolbarHelper::trash('foods.trash'); } // Copy foods to diet batch button if ($canDo->get('core.create')) { JToolbarHelper::modal('copyFoodsCollapseModal', 'icon-checkbox-partial', JText::_('COM_SIBDIET_COPY_FOODS')); } // Edit foods batch buttons if ($canDo->get('core.edit') && $canDo->get('core.edit.state')) { JToolbarHelper::modal('editCompositionsCollapseModal', 'icon-checkbox-partial', JText::_('COM_SIBDIET_EDIT_COMPOSITIONS')); JToolbarHelper::modal('editPreparationsCollapseModal', 'icon-checkbox-partial', JText::_('COM_SIBDIET_EDIT_PRPARATIONS')); } // Print foods compositions $bar->appendButton('Print', 'index.php?option=com_sibdiet&view=printfoods&tmpl=component', 'COM_SIBDIET_PRINT_FOODS'); // Print foods preparations $bar->appendButton('Print', 'index.php?option=com_sibdiet&view=printfoods&tmpl=component&layout=preparations', 'COM_SIBDIET_PRINT_FOODS_PREPARATIONS', false); } } if ($canDo->get('core.admin')) { JToolBarHelper::preferences('com_sibdiet'); } }
/** * 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 a 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'); $this->canDo = JHelperContent::getActions('com_sibdiet'); // Check for errors. if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode("\n", $errors)); return false; } // Get Bread & Rice & diseases & prescriptions history $profiles_id = $this->item->profiles_id ? $this->item->profiles_id : JFactory::getApplication()->getUserState('com_sibdiet.setdiets.filter.profiles_id'); $this->item->history = $this->getHistories($profiles_id, $this->item->id); $this->permissions = SibdietHelper::getUserPermissions(); $this->addToolbar(); if (in_array('setdiets', $this->permissions)) { parent::display($tpl); } }
/** * Add the page title and toolbar. */ protected function addToolbar() { require_once JPATH_COMPONENT . '/helpers/sibdiet.php'; $state = $this->get('State'); $canDo = SibdietHelper::getActions(); $filterDays = $state->get('filter.days', ''); // Get the toolbar object instance $bar = JToolBar::getInstance('toolbar'); JToolBarHelper::title(JText::_('COM_SIBDIET_MANAGER_DEFAULTS_DAILYS') . ' - ' . SibdietHelper::getDefault((int) $this->state->get('filter.defaults_id')), 'database defaults_dailys'); if ($canDo->get('core.create') && !empty($filterDays)) { JToolBarHelper::addNew('defaults_daily.add'); } if ($canDo->get('core.edit') && isset($this->items[0])) { JToolBarHelper::editList('defaults_daily.edit'); } if ($canDo->get('core.edit.state')) { JToolbarHelper::checkin('defaults_dailys.checkin'); } if ($state->get('filter.state') == -2 && $canDo->get('core.delete')) { JToolbarHelper::publish('defaults_dailys.publish', 'JTOOLBAR_PUBLISH', true); JToolbarHelper::deleteList('', 'defaults_dailys.delete', 'JTOOLBAR_EMPTY_TRASH'); } elseif ($canDo->get('core.edit.state')) { JToolbarHelper::trash('defaults_dailys.trash'); } // Add a batch button if ($canDo->get('core.create') && $canDo->get('core.edit') && $canDo->get('core.edit.state')) { JHtml::_('bootstrap.modal', 'collapseModal'); // Copy Foods to other default $title = JText::_('COM_SIBDIET_COPY_DEFAULTS'); $dhtml = "<button data-toggle=\"modal\" data-target=\"#copyDefaultsCollapseModal\" class=\"btn btn-small\">\r\n\t\t\t\t\t\t<i class=\"icon-checkbox-partial\" title=\"{$title}\"></i>\r\n\t\t\t\t\t\t{$title}</button>"; $bar->appendButton('Custom', $dhtml, 'batch'); } JToolBarHelper::divider(); JToolBarHelper::back('COM_SIBDIET_DEFAULTS', 'index.php?option=com_sibdiet&view=defaults'); JToolBarHelper::back('COM_SIBDIET_DEFAULTS_WEEKLY', 'index.php?option=com_sibdiet&view=defaults_weeklys&filter_defaults_id=' . $this->state->get('filter.defaults_id')); JToolBarHelper::back('COM_SIBDIET_DEFAULTS_MEALLY', 'index.php?option=com_sibdiet&view=defaults_meallys&filter_defaults_id=' . $this->state->get('filter.defaults_id')); if ($canDo->get('core.admin')) { JToolBarHelper::preferences('com_sibdiet'); } JHtmlSidebar::setAction('index.php?option=com_sibdiet&view=defaults_dailys'); }
/** * Get compositions & print */ public function printCompositions($compositions) { echo '<ul>'; $db = JFactory::getDbo(); $compositions = json_decode($compositions, true); foreach ($compositions as $key => $comp) { $query = "\n\t\t\t\tSELECT\n\t\t\t\t c.title,\n\t\t\t\t c.compositions,\n\t\t\t\t c.print_title\n\t\t\t\tFROM\n\t\t\t\t #__sibdiet_compositions c\n\t\t\t\tWHERE\n\t\t\t\t c.id = " . $key; $db->setQuery($query); $composition = $db->loadObject(); if ($composition) { $print_title = SibdietHelper::getLanguagePrint($composition->print_title); $title = $print_title ? $print_title : $composition->title; echo '<li>' . $title . ' (' . $comp . ')'; if ($composition->compositions) { $this->printCompositions($composition->compositions); } echo '</li>'; } } echo '</ul>'; }
/** * Method to get the field options. * * @return array The field option objects. * * @since 11.1 */ protected function getInput() { $html = array(); $document = JFactory::getDocument(); // Get the Units field options. $unitsoptions = SibdietHelper::getUnitsOptions(); $unitsfield = JHtml::_('select.genericlist', $unitsoptions, 'jform[' . $this->fieldname . '][#index#][unit]', 'class="input-medium input-unit required"', 'value', 'text', '', $this->id . 'unit#index#'); $unitsfield = preg_replace("/\\s+/", " ", $unitsfield); $inputhtml = '<div id="' . $this->id . 'div#index#" class="input-prepend input-append row-fluid"><span class="add-on"><label for="' . $this->id . '#index#" title="#name#">#name#</label></span><input type="text" class="validate-numeric input-mini required" value="" required="required" name="jform[' . $this->fieldname . '][#index#][amount]" id="' . $this->id . '#index#">' . $unitsfield . '<input type="text" class="input-mini required" required="required" value="" name="jform[' . $this->fieldname . '][#index#][uamount]" id="' . $this->id . 'uamount#index#"><span class="btn add-on"><i class="icon-delete" onclick="removeComposition(#index#)"></i></span></div>'; $script = "\nfunction removeComposition(cid)\n{\n\tvar compo = '#{$this->id}'+'div'+cid;\n\tjQuery(compo).remove();\n\n\tvar compoopt = '#{$this->id} option[value=\"'+cid+'\"]';\n\tjQuery(compoopt).removeAttr('disabled');\n\tjQuery('#{$this->id}').trigger('liszt:updated');\n}\n\nfunction newComposition()\n{\n\tvar seletedoption = jQuery('#{$this->id}').find(\":selected\");\n\tvar selectedvalue = jQuery(seletedoption).val();\n\tif(selectedvalue){\n\t\tvar selectedtext = jQuery(seletedoption).text();\n\t\tvar inputtext = '{$inputhtml}';\n\t\tinputtext = inputtext.replace(/#index#/g, selectedvalue);\n\t\tinputtext = inputtext.replace(/#name#/g, selectedtext);\n\t\tjQuery('#subcompositions').append(inputtext);\n\t\tjQuery(seletedoption).attr('disabled','disabled');\n\t\tjQuery('#{$this->id} option:first').attr('selected','selected');\n\t\tvar unitsinputid = '#jform_compositionsunit' + selectedvalue;\n\t}\n\tjQuery('#{$this->id}').trigger('liszt:updated');\n}"; $document->addScriptDeclaration($script); $this->onchange = 'newComposition()'; $html[] = parent::getInput(); $html[] = '<br /><br /><div id="subcompositions"><span></span>'; $db = JFactory::getDbo(); foreach ($this->value as $key => $value) { $query = $db->getQuery(true)->select("title, print_title")->from('#__sibdiet_compositions AS a')->where("a.id = " . $key); $db->setQuery($query); $result = $db->loadObject(); if ($result) { $lang_tag = JFactory::getLanguage()->get('tag'); // Convert the print_title field to an array. $registry = new JRegistry(); $registry->loadString($result->print_title); $print_title = $registry->toArray(); $name = array_key_exists($lang_tag, $print_title) ? $result->title . ' { ' . $print_title[$lang_tag] . ' }' : $result->title; $opthtml = str_replace('#index#', $key, $inputhtml); $count = 1; $opthtml = preg_replace('/value=""/', 'value="' . $value['amount'] . '"', $opthtml, 1); $opthtml = str_replace('value=""', 'value="' . $value['uamount'] . '"', $opthtml); $opthtml = str_replace('#name#', $name, $opthtml); $opthtml = str_replace('value="' . $value['unit'] . '"', 'value="' . $value['unit'] . '" selected="selected"', $opthtml); $html[] = $opthtml; } } $html[] = '</div>'; return implode($html); }
/** * Prepare and sanitise the table prior to saving. */ protected function prepareTable($table) { $table->title = SibdietHelper::correctPersianAlphabet(htmlspecialchars_decode($table->title, ENT_QUOTES)); }
/** * Prepare and sanitise the table prior to saving. */ protected function prepareTable($table) { require_once JPATH_COMPONENT . '/helpers/sibdiet.php'; $table->title = SibdietHelper::correctPersianAlphabet(htmlspecialchars_decode($table->title, ENT_QUOTES)); }
<?php /** * @package Sibdiet.Administrator * @subpackage com_sibdiet * * @copyright Copyright (C) Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/html'); JHtml::_('behavior.formvalidation'); SibdietHelper::chosen('select'); // Import CSS $document = JFactory::getDocument(); $document->addStyleSheet('components/com_sibdiet/assets/css/sibdiet.css'); ?> <script type="text/javascript"> Joomla.submitbutton = function(task) { if (task == 'nutrient.cancel' || document.formvalidator.isValid(document.id('nutrient-form'))) { Joomla.submitform(task, document.getElementById('nutrient-form')); } } </script> <form action="<?php echo JRoute::_('index.php?option=com_sibdiet&layout=edit&id=' . (int) $this->item->id); ?> " method="post" name="adminForm" id="nutrient-form" class="form-validate">
<?php /** * @package Sibdiet.Administrator * @subpackage com_sibdiet * * @copyright Copyright (C) Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/html'); JHtml::_('behavior.formvalidation'); SibdietHelper::chosen(); // Import CSS $document = JFactory::getDocument(); $document->addStyleSheet('components/com_sibdiet/assets/css/sibdiet.css'); ?> <script type="text/javascript"> Joomla.submitbutton = function(task) { if (task == 'audio.cancel' || document.formvalidator.isValid(document.id('audio-form'))) { Joomla.submitform(task, document.getElementById('audio-form')); } } </script> <form action="<?php echo JRoute::_('index.php?option=com_sibdiet&layout=edit&id=' . (int) $this->item->id); ?> " method="post" name="adminForm" id="audio-form" class="form-validate"> <div class="form-horizontal">
* @subpackage com_sibdiet * * @copyright Copyright (C) Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt * @author Mohammad Hasani Eghtedar <*****@*****.**> */ // no direct access defined('_JEXEC') or die; if ($this->item->sweeteners_id) { $allFoods++; } // Get Compositions $query = $db->getQuery(true); $query->select('s.compositions'); $query->from('#__sibdiet_sweeteners s'); $query->where('s.id = ' . (int) $this->item->sweeteners_id); $db->setQuery($query); $sweetenerCompositions = $db->loadObject(); $sweetenerNutrients = array(); if ($sweetenerCompositions) { // convert Composition json to array $registry = new JRegistry(); $registry->loadString($sweetenerCompositions->compositions); $sweetenerCompositions = $registry->toArray(); // Count compositions that have ph or gi $phCount = $giCount = 0; // Calculate nutrients $sweetenerNutrients = $sweetenerCompositions ? SibdietHelper::nutrientsCalc($sweetenerCompositions, $phCount, $giCount) : array(); $tempNutrients = $sweetenerNutrients; require 'calculation_html.php'; }
/** * Method to get the field options. * * @return array The field option objects. * * @since 11.1 */ public function getOptions() { $options = SibdietHelper::getDietsOptions(); return array_merge(parent::getOptions(), $options); }
} ?> <div class="small"> <?php echo JText::_('COM_SIBDIET_DIET') . ': ' . $this->escape($item->diets_title); ?> </div> </td> <td class="hidden-phone"> <?php echo SibdietHelper::convertMeals($item->meal); ?> </td> <td class="hidden-phone"> <?php echo SibdietHelper::convertSeasons($item->season); ?> </td> <td class="small nowrap hidden-phone"> <?php if ($item->language == '*') { ?> <?php echo JText::alt('JALL', 'language'); ?> <?php } else { ?> <?php echo $item->language_title ? $this->escape($item->language_title) : JText::_('JUNDEFINED'); ?>
<span class="age hasTooltip" title="<?php echo JText::_('COM_SIBDIET_AGE'); ?> "> <?php if (!empty($this->item->profile->birthday)) { $age = SibdietHelper::age($this->item->profile->birthday, $this->item->created); echo $age->y . '.' . $age->m; } ?> </span> <?php echo $this->form->getInput('email', 'profile'); ?> <?php $canDo = SibdietHelper::getActions(); ?> <?php if ($canDo->get('room.1')) { echo $this->form->getInput('room1'); } ?> <?php if ($canDo->get('room.2')) { echo $this->form->getInput('room2'); } ?> <?php if ($canDo->get('room.3')) { echo $this->form->getInput('room3'); }