Example #1
0
 /**
  * Add the page title and toolbar.
  *
  * @return void
  *
  * @throws Exception
  */
 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 = AkrecipesHelper::getActions();
     JToolBarHelper::title(JText::_('COM_AKRECIPES_TITLE_INGREDIENT997479'), 'ingredient997479.png');
     // If not checked out, can save the item.
     if (!$checkedOut && ($canDo->get('core.edit') || $canDo->get('core.create'))) {
         JToolBarHelper::apply('ingredient997479.apply', 'JTOOLBAR_APPLY');
         JToolBarHelper::save('ingredient997479.save', 'JTOOLBAR_SAVE');
     }
     if (!$checkedOut && $canDo->get('core.create')) {
         JToolBarHelper::custom('ingredient997479.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('ingredient997479.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false);
     }
     if (empty($this->item->id)) {
         JToolBarHelper::cancel('ingredient997479.cancel', 'JTOOLBAR_CANCEL');
     } else {
         JToolBarHelper::cancel('ingredient997479.cancel', 'JTOOLBAR_CLOSE');
     }
 }
Example #2
0
 /**
  * Add the page title and toolbar.
  *
  * @return void
  *
  * @throws Exception
  */
 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 = AkrecipesHelper::getActions();
     JToolBarHelper::title(JText::_('COM_AKUNITS_TITLE_UNIT'), 'unit.png');
     // If not checked out, can save the item.
     if (!$checkedOut && ($canDo->get('core.edit') || $canDo->get('core.create'))) {
         JToolBarHelper::apply('unit.apply', 'JTOOLBAR_APPLY');
         JToolBarHelper::save('unit.save', 'JTOOLBAR_SAVE');
     }
     if (!$checkedOut && $canDo->get('core.create')) {
         JToolBarHelper::custom('unit.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('unit.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false);
     }
     // Button for version control
     if ($this->state->params->get('save_history', 1) && $user->authorise('core.edit')) {
         JToolbarHelper::versions('com_akrecipes.unit', $this->item->id);
     }
     if (empty($this->item->id)) {
         JToolBarHelper::cancel('unit.cancel', 'JTOOLBAR_CANCEL');
     } else {
         JToolBarHelper::cancel('unit.cancel', 'JTOOLBAR_CLOSE');
     }
 }
Example #3
0
 /**
  * Retrieve component items
  *
  * @param   Joomla\Registry\Registry &$params module parameters
  *
  * @return array Array with all the elements
  */
 public static function getList(&$params)
 {
     //error_log("ModAkrecipesfeaturedusersHelper::getList params = " . print_r($params,true));
     $featured_user_ids = $params->get('featured_userids');
     //error_log("ModAkrecipesfeaturedusersHelper::getList featured_user_ids = " . print_r($featured_user_ids,true));
     $selected_userids = '';
     foreach ($featured_user_ids as $key => $featured_user) {
         //error_log("Key = " . $key);
         if ($key == 'featured_userids1') {
             $selected_userids = $featured_user->user_id;
         } else {
             $selected_userids = $selected_userids . ',' . $featured_user->user_id;
         }
     }
     //error_log("selected_userids = " . $selected_userids);
     $db = JFactory::getDbo();
     $query = $db->getQuery(true);
     //$contact = "CONCAT('{',group_concat(CONCAT('\"',REPLACE(p.profile_key,'akprofile.',''),'\"',':\"',p.profile_value,'\"' ) ),'}') as profile" ;
     $query->select('a.*');
     //$query->select($contact);
     $query->from('`#__users` AS a');
     $query->where('a.id IN (' . $selected_userids . ')');
     $db->setQuery($query);
     //error_log("ModAkrecipesusersHelper query : " . $query->__toString());
     $rows = $db->loadObjectList();
     foreach ($rows as $key => $row) {
         $row->userprofile = AkrecipesHelper::getUserObject($row->id);
     }
     return $rows;
 }
Example #4
0
 /**
  * Add the page title and toolbar.
  *
  * @return void
  *
  * @since    1.6
  */
 protected function addToolbar()
 {
     require_once JPATH_COMPONENT . '/helpers/akrecipes.php';
     $state = $this->get('State');
     $canDo = AkrecipesHelper::getActions($state->get('filter.category_id'));
     JToolBarHelper::title(JText::_('COM_AKRECIPES_TITLE_CUISINES'), 'cuisines.png');
     // Check if the form exists before showing the add/edit buttons
     $formPath = JPATH_COMPONENT_ADMINISTRATOR . '/views/cuisine';
     if (file_exists($formPath)) {
         if ($canDo->get('core.create')) {
             JToolBarHelper::addNew('cuisine.add', 'JTOOLBAR_NEW');
             JToolbarHelper::custom('cuisines.duplicate', 'copy.png', 'copy_f2.png', 'JTOOLBAR_DUPLICATE', true);
         }
         if ($canDo->get('core.edit') && isset($this->items[0])) {
             JToolBarHelper::editList('cuisine.edit', 'JTOOLBAR_EDIT');
         }
     }
     if ($canDo->get('core.edit.state')) {
         if (isset($this->items[0]->state)) {
             JToolBarHelper::divider();
             JToolBarHelper::custom('cuisines.publish', 'publish.png', 'publish_f2.png', 'JTOOLBAR_PUBLISH', true);
             JToolBarHelper::custom('cuisines.unpublish', 'unpublish.png', 'unpublish_f2.png', 'JTOOLBAR_UNPUBLISH', true);
         } elseif (isset($this->items[0])) {
             // If this component does not use state then show a direct delete button as we can not trash
             JToolBarHelper::deleteList('', 'cuisines.delete', 'JTOOLBAR_DELETE');
         }
         if (isset($this->items[0]->state)) {
             JToolBarHelper::divider();
             JToolBarHelper::archiveList('cuisines.archive', 'JTOOLBAR_ARCHIVE');
         }
         if (isset($this->items[0]->checked_out)) {
             JToolBarHelper::custom('cuisines.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('', 'cuisines.delete', 'JTOOLBAR_EMPTY_TRASH');
             JToolBarHelper::divider();
         } elseif ($canDo->get('core.edit.state')) {
             JToolBarHelper::trash('cuisines.trash', 'JTOOLBAR_TRASH');
             JToolBarHelper::divider();
         }
     }
     if ($canDo->get('core.admin')) {
         JToolBarHelper::preferences('com_akrecipes');
     }
     // Set sidebar action - New in 3.0
     JHtmlSidebar::setAction('index.php?option=com_akrecipes&view=cuisines');
     $this->extra_sidebar = '';
     JHtmlSidebar::addFilter(JText::_('JOPTION_SELECT_PUBLISHED'), 'filter_published', JHtml::_('select.options', JHtml::_('jgrid.publishedOptions'), "value", "text", $this->state->get('filter.state'), true));
 }
Example #5
0
 /**
  * Display the view
  *
  * @param   string  $tpl  Template name
  *
  * @return void
  *
  * @throws Exception
  */
 public function display($tpl = null)
 {
     $app = JFactory::getApplication();
     $this->state = $this->get('State');
     $this->items = $this->get('Items');
     $this->pagination = $this->get('Pagination');
     $this->params = $app->getParams('com_akrecipes');
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         throw new Exception(implode("\n", $errors));
     }
     foreach ($this->items as $key => $item) {
         $item->user = AkrecipesHelper::getUserObject($item->created_by);
     }
     $this->_prepareDocument();
     parent::display($tpl);
 }
Example #6
0
 /**
  * Retrieve component items
  *
  * @param   Joomla\Registry\Registry &$params module parameters
  *
  * @return array Array with all the elements
  */
 public static function getList(&$params)
 {
     $db = JFactory::getDbo();
     $query = $db->getQuery(true);
     //$contact = "CONCAT('{',group_concat(CONCAT('\"',REPLACE(p.profile_key,'akprofile.',''),'\"',':\"',p.profile_value,'\"' ) ),'}') as profile" ;
     $query->select('DISTINCT a.created_by, u.username, u.name');
     //$query->select($contact);
     $query->from('`#__akrecipes_recipe` AS a');
     // Join over the category '__users'
     $query->join('LEFT', '#__users AS u ON u.id = a.created_by');
     //$query->join('LEFT', '#__user_profiles p on p.user_id = a.created_by');
     $query->where('a.state <> -2');
     $query->group($db->quoteName('a.created_by'));
     $query->order('a.id asc');
     $db->setQuery($query);
     //error_log("ModAkrecipesusersHelper query : " . $query->__toString());
     $rows = $db->loadObjectList();
     foreach ($rows as $key => $row) {
         $row->userprofile = AkrecipesHelper::getUserObject($row->created_by);
     }
     return $rows;
 }
Example #7
0
 /**
  * Add the page title and toolbar.
  *
  * @return void
  *
  * @since    1.6
  */
 protected function addToolbar()
 {
     require_once JPATH_COMPONENT . '/helpers/akrecipes.php';
     $state = $this->get('State');
     $canDo = AkrecipesHelper::getActions($state->get('filter.category_id'));
     JToolBarHelper::title(JText::_('COM_AKRECIPES_TITLE_RECIPES'), 'recipes.png');
     // Check if the form exists before showing the add/edit buttons
     $formPath = JPATH_COMPONENT_ADMINISTRATOR . '/views/recipe';
     if (file_exists($formPath)) {
         if ($canDo->get('core.create')) {
             JToolBarHelper::addNew('recipe.add', 'JTOOLBAR_NEW');
             JToolbarHelper::custom('recipes.duplicate', 'copy.png', 'copy_f2.png', 'JTOOLBAR_DUPLICATE', true);
         }
         if ($canDo->get('core.edit') && isset($this->items[0])) {
             JToolBarHelper::editList('recipe.edit', 'JTOOLBAR_EDIT');
         }
     }
     if ($canDo->get('core.edit.state')) {
         if (isset($this->items[0]->state)) {
             JToolBarHelper::divider();
             JToolBarHelper::custom('recipes.publish', 'publish.png', 'publish_f2.png', 'JTOOLBAR_PUBLISH', true);
             JToolBarHelper::custom('recipes.unpublish', 'unpublish.png', 'unpublish_f2.png', 'JTOOLBAR_UNPUBLISH', true);
             JToolbarHelper::custom('recipes.featured', 'featured.png', 'featured_f2.png', 'JFEATURE', true);
             JToolbarHelper::custom('recipes.unfeatured', 'unfeatured.png', 'featured_f2.png', 'JUNFEATURE', true);
         } elseif (isset($this->items[0])) {
             // If this component does not use state then show a direct delete button as we can not trash
             JToolBarHelper::deleteList('', 'recipes.delete', 'JTOOLBAR_DELETE');
         }
         if (isset($this->items[0]->state)) {
             JToolBarHelper::divider();
             JToolBarHelper::archiveList('recipes.archive', 'JTOOLBAR_ARCHIVE');
         }
         if (isset($this->items[0]->checked_out)) {
             JToolBarHelper::custom('recipes.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('', 'recipes.delete', 'JTOOLBAR_EMPTY_TRASH');
             JToolBarHelper::divider();
         } elseif ($canDo->get('core.edit.state')) {
             JToolBarHelper::trash('recipes.trash', 'JTOOLBAR_TRASH');
             JToolBarHelper::divider();
         }
     }
     // Add file browser button
     require_once JPATH_ADMINISTRATOR . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_jce' . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'browser.php';
     $bar =& JToolBar::getInstance('toolbar');
     JToolBarHelper::divider();
     $bar->appendButton('Popup', 'folder', 'File browser', WFBrowserHelper::getBrowserLink(), 800, 500);
     if ($canDo->get('core.admin')) {
         JToolBarHelper::preferences('com_akrecipes');
     }
     // Set sidebar action - New in 3.0
     JHtmlSidebar::setAction('index.php?option=com_akrecipes&view=recipes');
     $this->extra_sidebar = '';
     JHtmlSidebar::addFilter(JText::_("JOPTION_SELECT_CATEGORY"), 'filter_catid', JHtml::_('select.options', JHtml::_('category.options', 'com_akrecipes'), "value", "text", $this->state->get('filter.catid')));
     //Filter for the field cuisines_id;
     jimport('joomla.form.form');
     $options = array();
     JForm::addFormPath(JPATH_COMPONENT . '/models/forms');
     $form = JForm::getInstance('com_akrecipes.recipe', 'recipe');
     $field = $form->getField('cuisines_id');
     $query = $form->getFieldAttribute('filter_cuisines_id', 'query');
     $translate = $form->getFieldAttribute('filter_cuisines_id', 'translate');
     $key = $form->getFieldAttribute('filter_cuisines_id', 'key_field');
     $value = $form->getFieldAttribute('filter_cuisines_id', 'value_field');
     // Get the database object.
     $db = JFactory::getDBO();
     // Set the query and get the result list.
     $db->setQuery($query);
     $items = $db->loadObjectlist();
     // Build the field options.
     if (!empty($items)) {
         foreach ($items as $item) {
             if ($translate == true) {
                 $options[] = JHtml::_('select.option', $item->{$key}, JText::_($item->{$value}));
             } else {
                 $options[] = JHtml::_('select.option', $item->{$key}, $item->{$value});
             }
         }
     }
     JHtmlSidebar::addFilter('$Cuisine', 'filter_cuisines_id', JHtml::_('select.options', $options, "value", "text", $this->state->get('filter.cuisines_id')), true);
     JHtmlSidebar::addFilter(JText::_('JOPTION_SELECT_PUBLISHED'), 'filter_published', JHtml::_('select.options', JHtml::_('jgrid.publishedOptions'), "value", "text", $this->state->get('filter.state'), true));
     // JHtmlSidebar::addFilter(
     // 	JText::_('Select User'),
     // 	'filter_created_by',
     // 	JHtml::_('select.options', "value", "text", $this->state->get('filter.created_by'),true)
     // );
     $db = JFactory::getDbo();
     $query = $db->getQuery(true)->select('u.id AS value, u.name AS text')->from('#__users AS u')->join('LEFT', '#__user_usergroup_map AS m ON m.user_id = u.id')->where('u.block = 0')->order('name')->group('u.id');
     $db->setQuery($query);
     $users[] = JHtml::_('select.option', '0', JText::_('JOPTION_NO_USER'));
     $users = array_merge($users, $db->loadObjectList());
     //		error_log('users arraay -> ' . print_r($users,true));
     JHtmlSidebar::addFilter(JText::_('Select User'), 'filter_created_by', JHtml::_('select.options', $users, "value", "text", $this->state->get('filter.created_by')));
     // filter by tag
     $db = JFactory::getDbo();
     $query = $db->getQuery(true)->select('u.id AS value, u.title AS text')->from('#__tags AS u')->order('u.title');
     $db->setQuery($query);
     $tags[] = JHtml::_('select.option', '0', JText::_('JOPTION_SELECT_TAG'));
     $tags = array_merge($tags, $db->loadObjectList());
     //error_log('users arraay -> ' . print_r($tags,true));
     JHtmlSidebar::addFilter(JText::_('Select Tag'), 'filter_tag', JHtml::_('select.options', $tags, "value", "text", $this->state->get('filter.tag')));
     //Filter for the field contest_id;
     jimport('joomla.form.form');
     $options = array();
     JForm::addFormPath(JPATH_COMPONENT . '/models/forms');
     $form = JForm::getInstance('com_akrecipes.recipe', 'recipe');
     $field = $form->getField('contest_id');
     $query = $form->getFieldAttribute('filter_contest_id', 'query');
     $translate = $form->getFieldAttribute('filter_contest_id', 'translate');
     $key = $form->getFieldAttribute('filter_contest_id', 'key_field');
     $value = $form->getFieldAttribute('filter_contest_id', 'value_field');
     // Get the database object.
     $db = JFactory::getDBO();
     // Set the query and get the result list.
     $db->setQuery($query);
     //error_log("Query == " . $query);
     $items = $db->loadObjectlist();
     // Build the field options.
     if (!empty($items)) {
         foreach ($items as $item) {
             if ($translate == true) {
                 $options[] = JHtml::_('select.option', $item->{$key}, JText::_($item->{$value}));
             } else {
                 $options[] = JHtml::_('select.option', $item->{$key}, $item->{$value});
             }
         }
     }
     JHtmlSidebar::addFilter('$Cuisine', 'filter_contest_id', JHtml::_('select.options', $options, "value", "text", $this->state->get('filter.contest_id')), true);
     JHtmlSidebar::addFilter(JText::_('JOPTION_SELECT_LANGUAGE'), 'filter_language', JHtml::_('select.options', JHtml::_('contentlanguage.existing', true, true), 'value', 'text', $this->state->get('filter.language')));
     //error_log('users select options  -> ' . JHtml::_('select.options', $users, "value", "text", $this->state->get('filter.created_by')));
     //Filter for the field created_by
     // $this->extra_sidebar .= '<div class="other-filters">';
     // $this->extra_sidebar .= '<small><label for="filter_created_by">Created by</label></small>';
     // $this->extra_sidebar .= JHtmlList::users('filter_created_by', $this->state->get('filter.created_by'), 1, 'onchange="this.form.submit();"');
     // $this->extra_sidebar .= '</div>';
     // $this->extra_sidebar .= '<hr class="hr-condensed">';
 }
Example #8
0
 * @package     Joomla.Site
 * @subpackage  Layout
 *
 * @copyright   Copyright (C) 2005 - 2015 Open Source Matters, Inc. All rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */
defined('_JEXEC') or die;
// Create a shortcut for params.
$params = $this->item->params;
JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/html');
$canEdit = $this->item->params->get('access-edit');
$info = $params->get('info_block_position', 0);
require_once JPATH_SITE . '/components/com_akrecipes/helpers/akrecipeshelper.php';
require_once JPATH_SITE . '/components/com_akrecipes/helpers/akrecipes.php';
$author_url = AkrecipesFrontendHelper::getAuthorURL($this->item->created_by);
$author_obj = AkrecipesHelper::getUserObject($this->item->created_by);
$images = json_decode($this->item->images);
if ($params->get('link_titles')) {
    $item_url = JRoute::_(ContentHelperRoute::getArticleRoute($this->item->slug, $this->item->catid, $this->item->language));
} else {
    $item_url = '#';
}
$item = $this->item;
$colspan = $this->colspan;
?>

<div class="col-md-<?php 
echo $colspan;
?>
">
	<div class="blog-intro-item column-<?php 
Example #9
0
    ?>
 
			</div>
			<div class="col-md-6 col-xs-12">
				<span class="contest-ends-label">Contest Ends</span> : <?php 
    echo JHtml::_('date', $this->item->publish_down, JText::_('DATE_FORMAT_LC3'));
    ?>
 
			</div>			
		</div>

		<div class="row contest-description">
			<div class="col-md-12 col-xs-12">
				<?php 
    $contest_intro_text = AkrecipesHelper::splitToIntroAndFullText($this->item->contest_description)->introtext;
    $contest_full_text = AkrecipesHelper::splitToIntroAndFullText($this->item->contest_description)->fulltext;
    ?>
				<div class="contest-introtext">
					<?php 
    echo $contest_intro_text;
    ?>
				</div>
				<div class="contest-fulltext">
					<?php 
    echo $contest_full_text;
    ?>
				</div>				
			</div>
		</div>

		<?php 
Example #10
0
 /**
  * Add the page title and toolbar.
  *
  * @return void
  *
  * @since    1.6
  */
 protected function addToolbar()
 {
     require_once JPATH_COMPONENT . '/helpers/akrecipes.php';
     $state = $this->get('State');
     $canDo = AkrecipesHelper::getActions($state->get('filter.category_id'));
     JToolBarHelper::title(JText::_('COM_AKRECIPES_TITLE_RECIPES'), 'recipes.png');
     // Check if the form exists before showing the add/edit buttons
     $formPath = JPATH_COMPONENT_ADMINISTRATOR . '/views/recipe';
     if (file_exists($formPath)) {
         if ($canDo->get('core.create')) {
             JToolBarHelper::addNew('recipe.add', 'JTOOLBAR_NEW');
             JToolbarHelper::custom('recipes.duplicate', 'copy.png', 'copy_f2.png', 'JTOOLBAR_DUPLICATE', true);
         }
         if ($canDo->get('core.edit') && isset($this->items[0])) {
             JToolBarHelper::editList('recipe.edit', 'JTOOLBAR_EDIT');
         }
     }
     if ($canDo->get('core.edit.state')) {
         if (isset($this->items[0]->state)) {
             JToolBarHelper::divider();
             JToolBarHelper::custom('recipes.publish', 'publish.png', 'publish_f2.png', 'JTOOLBAR_PUBLISH', true);
             JToolBarHelper::custom('recipes.unpublish', 'unpublish.png', 'unpublish_f2.png', 'JTOOLBAR_UNPUBLISH', true);
         } elseif (isset($this->items[0])) {
             // If this component does not use state then show a direct delete button as we can not trash
             JToolBarHelper::deleteList('', 'recipes.delete', 'JTOOLBAR_DELETE');
         }
         if (isset($this->items[0]->state)) {
             JToolBarHelper::divider();
             JToolBarHelper::archiveList('recipes.archive', 'JTOOLBAR_ARCHIVE');
         }
         if (isset($this->items[0]->checked_out)) {
             JToolBarHelper::custom('recipes.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('', 'recipes.delete', 'JTOOLBAR_EMPTY_TRASH');
             JToolBarHelper::divider();
         } elseif ($canDo->get('core.edit.state')) {
             JToolBarHelper::trash('recipes.trash', 'JTOOLBAR_TRASH');
             JToolBarHelper::divider();
         }
     }
     if ($canDo->get('core.admin')) {
         JToolBarHelper::preferences('com_akrecipes');
     }
     // Set sidebar action - New in 3.0
     JHtmlSidebar::setAction('index.php?option=com_akrecipes&view=recipes');
     $this->extra_sidebar = '';
     JHtmlSidebar::addFilter(JText::_("JOPTION_SELECT_CATEGORY"), 'filter_catid', JHtml::_('select.options', JHtml::_('category.options', 'com_akrecipes'), "value", "text", $this->state->get('filter.catid')));
     //Filter for the field cuisines_id;
     jimport('joomla.form.form');
     $options = array();
     JForm::addFormPath(JPATH_COMPONENT . '/models/forms');
     $form = JForm::getInstance('com_akrecipes.recipe', 'recipe');
     $field = $form->getField('cuisines_id');
     $query = $form->getFieldAttribute('filter_cuisines_id', 'query');
     $translate = $form->getFieldAttribute('filter_cuisines_id', 'translate');
     $key = $form->getFieldAttribute('filter_cuisines_id', 'key_field');
     $value = $form->getFieldAttribute('filter_cuisines_id', 'value_field');
     // Get the database object.
     $db = JFactory::getDBO();
     // Set the query and get the result list.
     $db->setQuery($query);
     $items = $db->loadObjectlist();
     // Build the field options.
     if (!empty($items)) {
         foreach ($items as $item) {
             if ($translate == true) {
                 $options[] = JHtml::_('select.option', $item->{$key}, JText::_($item->{$value}));
             } else {
                 $options[] = JHtml::_('select.option', $item->{$key}, $item->{$value});
             }
         }
     }
     JHtmlSidebar::addFilter('$Cuisine', 'filter_cuisines_id', JHtml::_('select.options', $options, "value", "text", $this->state->get('filter.cuisines_id')), true);
     JHtmlSidebar::addFilter(JText::_('JOPTION_SELECT_PUBLISHED'), 'filter_published', JHtml::_('select.options', JHtml::_('jgrid.publishedOptions'), "value", "text", $this->state->get('filter.state'), true));
 }
Example #11
0
    ?>
					<?php 
    $rowcount = (int) $i % (int) $columns + 1;
    ?>
					<?php 
    if ($rowcount == 1) {
        ?>
						<div class="row"><!-- begin row -->
					<?php 
    }
    ?>

					<?php 
    $contest_url = JRoute::_('index.php?option=com_akrecipes&view=contest&id=' . (int) $item->id);
    $contest_image = $item->contest_image;
    $contest_introtext = AkrecipesHelper::splitToIntroAndFullText($item->contest_description)->introtext;
    $add_recipe_url = JRoute::_(AkrecipesHelperRoute::getAddRecipeRoute());
    $contest_start_date = $item->publish_up;
    $contest_close_date = $item->publish_down;
    $contest_state = AkrecipesFrontendHelper::getContestState($item);
    ?>
					<div class="contest col-md-<?php 
    echo $colspan;
    ?>
 col-xs-12">
						<div class="thumbnail">
							<a href="<?php 
    echo $contest_url;
    ?>
" title="<?php 
    echo $item->contest_name;
Example #12
0
 /**
  * Prepares the document
  *
  * @return void
  *
  * @throws Exception
  */
 protected function _prepareDocument()
 {
     $app = JFactory::getApplication();
     $menus = $app->getMenu();
     $title = null;
     //error_log("_prepareDocument params --> " .  print_r($this->params,true));
     // Because the application sets a default page title,
     // We need to get it from the menu item itself
     $menu = $menus->getActive();
     if ($menu) {
         $this->params->def('page_heading', $this->params->get('page_title', $menu->title));
     } else {
         //$this->params->def('page_heading', JText::_('COM_AKBRANDS_DEFAULT_PAGE_TITLE'));
         $this->params->def('page_heading', $this->item->contest_name);
     }
     if ($menu) {
         $menu_page_title = $menu->params->get('page_title');
     }
     if (isset($menu_page_title) && !empty($menu_page_title)) {
         $title = $menu->params->get('page_title');
     } else {
         $title = $this->item->contest_name;
     }
     if ($app->get('sitename_pagetitles', 0) == 1) {
         //$title = JText::sprintf('JPAGETITLE', $app->get('sitename'), $title);
         $title = JText::sprintf('JPAGETITLE', $this->item->contest_name, $title);
     } elseif ($app->get('sitename_pagetitles', 0) == 2) {
         //$title = JText::sprintf('JPAGETITLE', $title, $app->get('sitename'));
         $title = JText::sprintf('JPAGETITLE', $title, $this->item->contest_name);
     }
     $this->document->setTitle($title);
     if ($this->params->get('menu-meta_description')) {
         $this->document->setDescription($this->params->get('menu-meta_description'));
     } else {
         $contest_desc = strip_tags(AkrecipesHelper::splitToIntroAndFullText($this->item->contest_description)->introtext);
         $this->document->setDescription($contest_desc);
     }
     if ($this->params->get('menu-meta_keywords')) {
         $this->document->setMetadata('keywords', $this->params->get('menu-meta_keywords'));
     }
     if ($this->params->get('robots')) {
         $this->document->setMetadata('robots', $this->params->get('robots'));
     }
     //$this->document->addStylesheet('media/com_akrecipes/css/recipe.css');
 }
Example #13
0
 /**
  * Method to get an object.
  *
  * @param   integer  $id  The id of the object to get.
  *
  * @return  mixed    Object on success, false on failure.
  */
 public function &getData($id = null)
 {
     if ($this->_item === null) {
         $this->_item = false;
         if (empty($id)) {
             $id = $this->getState('recipe.id');
         }
         // Get a level row instance.
         $table = $this->getTable();
         // Attempt to load the row.
         if ($table->load($id)) {
             // Check published state.
             if ($published = $this->getState('filter.published')) {
                 if ($table->state != $published) {
                     return $this->_item;
                 }
             }
             // Convert the JTable to a clean JObject.
             $properties = $table->getProperties(1);
             $this->_item = ArrayHelper::toObject($properties, 'JObject');
         }
     }
     // try to get ingredients if it is set
     if (!empty($id)) {
         $db = JFactory::getDbo();
         $query = $db->getQuery(true);
         $query->select('a.*');
         $query->from('`#__akrecipes_recipe_ingredients` as a');
         $query->select('ing.name as ingredient_name, ing.description as ingredient_tooltip, ing.ingredient_url as ingredient_url, ing.image as ingredient_image ');
         $query->join('LEFT', '#__akrecipes_ingredient AS ing ON ing.id = a.ingredients_id');
         $query->where('a.recipe_id = ' . $id);
         $query->order(' a.sequence_no asc ');
         $db->setQuery($query);
         $result = $db->loadObjectList();
         if ($result) {
             $this->_item->qty = array();
             $this->_item->unit = array();
             $this->_item->ingredient = array();
             $this->_item->ingredient_description = array();
             $this->_item->ingredient_tooltip = array();
             $this->_item->ingredient_url = array();
             $this->_item->ingredient_image = array();
             foreach ($result as $key => $row) {
                 $this->_item->qty[] = $row->qty;
                 $this->_item->unit[] = $row->unit;
                 $this->_item->ingredient[] = $row->ingredient_name;
                 $this->_item->ingredient_description[] = $row->ingredient_description;
                 $this->_item->ingredient_tooltip[] = $row->ingredient_tooltip;
                 $this->_item->ingredient_url[] = $row->ingredient_url;
                 $this->_item->ingredient_image[] = $row->ingredient_image;
             }
         }
     }
     if (isset($this->_item->cuisines_id) && $this->_item->cuisines_id != '') {
         if (is_object($this->_item->cuisines_id)) {
             $this->_item->cuisines_id = JArrayHelper::fromObject($this->_item->cuisines_id);
         }
         $values = is_array($this->_item->cuisines_id) ? $this->_item->cuisines_id : explode(',', $this->_item->cuisines_id);
         $textValue = array();
         foreach ($values as $value) {
             $db = JFactory::getDbo();
             $query = $db->getQuery(true);
             $query->select('name')->from('`#__akrecipes_cuisines`')->where('id = ' . $db->quote($db->escape($value)));
             $db->setQuery($query);
             $results = $db->loadObject();
             if ($results) {
                 $textValue[] = $results->name;
             }
         }
         //$this->_item->cuisines_id = !empty($textValue) ? implode(', ', $textValue) : $this->_item->cuisines_id;
         $this->_item->cuisines = !empty($textValue) ? implode(', ', $textValue) : $this->_item->cuisines_id;
     }
     if (isset($this->_item->meal_course_id) && $this->_item->meal_course_id != '') {
         if (is_object($this->_item->meal_course_id)) {
             $this->_item->meal_course_id = JArrayHelper::fromObject($this->_item->meal_course_id);
         }
         $values = is_array($this->_item->meal_course_id) ? $this->_item->meal_course_id : explode(',', $this->_item->meal_course_id);
         $textValue = array();
         foreach ($values as $value) {
             $db = JFactory::getDbo();
             $query = $db->getQuery(true);
             $query->select('name')->from('`#__akrecipes_meal_course`')->where('id = ' . $db->quote($db->escape($value)));
             $db->setQuery($query);
             $results = $db->loadObject();
             if ($results) {
                 $textValue[] = $results->name;
             }
         }
         //$this->_item->meal_course_id = !empty($textValue) ? implode(', ', $textValue) : $this->_item->meal_course_id;
         $this->_item->meal_course = !empty($textValue) ? implode(', ', $textValue) : $this->_item->meal_course_id;
     }
     // get products used
     if (isset($this->_item->product_id) && $this->_item->product_id != '') {
         if (is_object($this->_item->product_id)) {
             $this->_item->product_id = JArrayHelper::fromObject($this->_item->product_id);
         }
         //$values = (is_array($this->_item->product_id)) ? $this->_item->product_id : explode(',',$this->_item->product_id);
         $values = is_array($this->_item->product_id) ? implode(',', $this->_item->product_id) : $this->_item->product_id;
         $textValue = array();
         $db = JFactory::getDbo();
         $query = $db->getQuery(true);
         $query->select('product_name, product_description, product_link, product_image, product_affiliate')->from('`#__akrecipes_products`')->where('id IN ( ' . $values . ' )');
         $db->setQuery($query);
         $results = $db->loadObjectList();
         if ($results) {
             $this->_item->products = $results;
         }
     }
     if (isset($this->_item->diet_id) && $this->_item->diet_id != '') {
         if (is_object($this->_item->diet_id)) {
             $this->_item->diet_id = JArrayHelper::fromObject($this->_item->diet_id);
         }
         $values = is_array($this->_item->diet_id) ? $this->_item->diet_id : explode(',', $this->_item->diet_id);
         $textValue = array();
         foreach ($values as $value) {
             $db = JFactory::getDbo();
             $query = $db->getQuery(true);
             $query->select('name')->from('`#__akrecipes_diets`')->where('id = ' . $db->quote($db->escape($value)));
             $db->setQuery($query);
             $results = $db->loadObject();
             if ($results) {
                 $textValue[] = $results->name;
             }
         }
         //$this->_item->diet_id = !empty($textValue) ? implode(', ', $textValue) : $this->_item->diet_id;
         $this->_item->diet = !empty($textValue) ? implode(', ', $textValue) : $this->_item->diet_id;
     }
     if (isset($this->_item->created_by)) {
         $this->_item->created_by_name = JFactory::getUser($this->_item->created_by)->name;
     }
     if (isset($this->_item->modified_by)) {
         $this->_item->modified_by_name = JFactory::getUser($this->_item->modified_by)->name;
     }
     // add user object to the item
     $this->_item->user = AkrecipesHelper::getUserObject($this->_item->created_by);
     // add brand object
     if (isset($this->_item->brand_id) && $this->_item->brand_id != '') {
         $this->_item->brand = AkrecipesHelper::getBrandObject($this->_item->brand_id);
         //error_log("Got brand object -> " . print_r($this->_item->brand,true));
     }
     // add contest object
     if (isset($this->_item->contest_id) && $this->_item->contest_id != '') {
         $this->_item->contest = AkrecipesHelper::getContestObject($this->_item->contest_id);
     }
     // add ratings data
     $rating = AkrecipesHelper::getRatingObject($this->_item->id);
     //error_log("Got rating object --> " . print_r($rating,true));
     if ($rating) {
         $this->_item->rating = $rating;
     }
     $stats = AkrecipesHelper::getStatsObject($this->_item->id);
     if ($stats) {
         $this->_item->stats = $stats;
     }
     return $this->_item;
 }
Example #14
0
 /**
  * Method to get an array of data items
  *
  * @return  mixed An array of data on success, false on failure.
  */
 public function getItems()
 {
     $items = parent::getItems();
     //error_log("In AkrecipesModelRecipes::getItems Count == " . count($items) ) ;
     foreach ($items as $item) {
         //get the tags
         $item->tags = new JHelperTags();
         $item->tags->getItemTags('com_akrecipes.recipe', $item->id);
         // if (isset($item->tags))
         // {
         // 	// Catch the item tags (string with ',' coma glue)
         // 	$tags = explode(",", $item->tags);
         // 	$db = JFactory::getDbo();
         // 	// Cleaning and initalization of named tags array
         // 	$namedTags = array();
         // 	// Get the tag names of each tag id
         // 	foreach ($tags as $tag)
         // 	{
         // 		$query = $db->getQuery(true);
         // 		$query->select("title");
         // 		$query->from('`#__tags`');
         // 		$query->where("id=" . intval($tag));
         // 		$db->setQuery($query);
         // 		$row = $db->loadObjectList();
         // 		// Read the row and get the tag name (title)
         // 		if (!is_null($row))
         // 		{
         // 			foreach ($row as $value)
         // 			{
         // 				if ( $value && isset($value->title))
         // 				{
         // 					$namedTags[] = trim($value->title);
         // 				}
         // 			}
         // 		}
         // 	}
         // 	// Finally replace the data object with proper information
         // 	$item->tags = !empty($namedTags) ? implode(', ', $namedTags) : $item->tags;
         // }
         // if (isset($item->catid))
         // {
         // 	// Get the title of that particular template
         // 	$title = AkrecipesFrontendHelper::getCategoryNameByCategoryId($item->catid);
         // 	// Finally replace the data object with proper information
         // 	$item->catid = !empty($title) ? $title : $item->catid;
         // }
         if (isset($item->cuisines_id) && $item->cuisines_id != '') {
             if (is_object($item->cuisines_id)) {
                 $item->cuisines_id = ArrayHelper::fromObject($item->cuisines_id);
             }
             $values = is_array($item->cuisines_id) ? $item->cuisines_id : explode(',', $item->cuisines_id);
             $textValue = array();
             foreach ($values as $value) {
                 $db = JFactory::getDbo();
                 $query = $db->getQuery(true);
                 $query->select($db->quoteName('name'))->from('`#__akrecipes_cuisines`')->where($db->quoteName('id') . ' = ' . $db->quote($db->escape($value)));
                 $db->setQuery($query);
                 $results = $db->loadObject();
                 if ($results) {
                     $textValue[] = $results->name;
                 }
             }
             $item->cuisines_id = !empty($textValue) ? implode(', ', $textValue) : $item->cuisines_id;
         }
         if (isset($item->meal_course_id) && $item->meal_course_id != '') {
             if (is_object($item->meal_course_id)) {
                 $item->meal_course_id = ArrayHelper::fromObject($item->meal_course_id);
             }
             $values = is_array($item->meal_course_id) ? $item->meal_course_id : explode(',', $item->meal_course_id);
             $textValue = array();
             foreach ($values as $value) {
                 $db = JFactory::getDbo();
                 $query = $db->getQuery(true);
                 $query->select($db->quoteName('name'))->from('`#__akrecipes_meal_course`')->where($db->quoteName('id') . ' = ' . $db->quote($db->escape($value)));
                 $db->setQuery($query);
                 $results = $db->loadObject();
                 if ($results) {
                     $textValue[] = $results->name;
                 }
             }
             $item->meal_course_id = !empty($textValue) ? implode(', ', $textValue) : $item->meal_course_id;
         }
         if (isset($item->created_by)) {
             $item->user = AkrecipesHelper::getUserObject($item->created_by);
         }
     }
     return $items;
 }
Example #15
0
 /**
  * Add the page title and toolbar.
  *
  * @return void
  *
  * @since    1.6
  */
 protected function addToolbar()
 {
     $state = $this->get('State');
     $canDo = AkrecipesHelper::getActions();
     JToolBarHelper::title(JText::_('COM_AKPRODUCTS_TITLE_PRODUCTS'), 'products.png');
     // Check if the form exists before showing the add/edit buttons
     $formPath = JPATH_COMPONENT_ADMINISTRATOR . '/views/product';
     if (file_exists($formPath)) {
         if ($canDo->get('core.create')) {
             JToolBarHelper::addNew('product.add', 'JTOOLBAR_NEW');
             JToolbarHelper::custom('products.duplicate', 'copy.png', 'copy_f2.png', 'JTOOLBAR_DUPLICATE', true);
         }
         if ($canDo->get('core.edit') && isset($this->items[0])) {
             JToolBarHelper::editList('product.edit', 'JTOOLBAR_EDIT');
         }
     }
     if ($canDo->get('core.edit.state')) {
         if (isset($this->items[0]->state)) {
             JToolBarHelper::divider();
             JToolBarHelper::custom('products.publish', 'publish.png', 'publish_f2.png', 'JTOOLBAR_PUBLISH', true);
             JToolBarHelper::custom('products.unpublish', 'unpublish.png', 'unpublish_f2.png', 'JTOOLBAR_UNPUBLISH', true);
         } elseif (isset($this->items[0])) {
             // If this component does not use state then show a direct delete button as we can not trash
             JToolBarHelper::deleteList('', 'products.delete', 'JTOOLBAR_DELETE');
         }
         if (isset($this->items[0]->state)) {
             JToolBarHelper::divider();
             JToolBarHelper::archiveList('products.archive', 'JTOOLBAR_ARCHIVE');
         }
         if (isset($this->items[0]->checked_out)) {
             JToolBarHelper::custom('products.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('', 'products.delete', 'JTOOLBAR_EMPTY_TRASH');
             JToolBarHelper::divider();
         } elseif ($canDo->get('core.edit.state')) {
             JToolBarHelper::trash('products.trash', 'JTOOLBAR_TRASH');
             JToolBarHelper::divider();
         }
     }
     if ($canDo->get('core.admin')) {
         JToolBarHelper::preferences('com_akrecipes');
     }
     // Set sidebar action - New in 3.0
     JHtmlSidebar::setAction('index.php?option=com_akrecipes&view=products');
     $this->extra_sidebar = '';
     JHtmlSidebar::addFilter(JText::_('JOPTION_SELECT_PUBLISHED'), 'filter_published', JHtml::_('select.options', JHtml::_('jgrid.publishedOptions'), "value", "text", $this->state->get('filter.state'), true));
     //Filter for the field product_affiliate
     $select_label = JText::sprintf('COM_AKPRODUCTS_FILTER_SELECT_LABEL', 'Product_affiliate');
     $options = array();
     $options[0] = new stdClass();
     $options[0]->value = "amazon";
     $options[0]->text = "Amazon";
     $options[1] = new stdClass();
     $options[1]->value = "flipkart";
     $options[1]->text = "Flipkart";
     $options[2] = new stdClass();
     $options[2]->value = "snapdeal";
     $options[2]->text = "Snapdeal";
     $options[3] = new stdClass();
     $options[3]->value = "other";
     $options[3]->text = "Other";
     JHtmlSidebar::addFilter($select_label, 'filter_product_affiliate', JHtml::_('select.options', $options, "value", "text", $this->state->get('filter.product_affiliate'), true));
 }