/** * 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; }
/** * 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); }
/** * 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; }
* @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
/** * 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; }
/** * 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; }