Exemple #1
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);
     $nullDate = $db->quote($db->getNullDate());
     $nowDate = $db->quote(JFactory::getDate()->toSql());
     //error_log("PArams are --> " . print_r($params,true));
     $source = $params->get('source', 'filter');
     $query->select('DISTINCT a.*');
     $query->from('`#__akrecipes_recipe` AS a');
     // Join over the category 'catid'
     $query->select('catid.title AS catid_title');
     $query->join('LEFT', '#__categories AS catid ON catid.id = a.catid');
     // Join over the foreign key 'cuisines_id'
     $query->select('#__akrecipes_cuisines_2186828.name AS cuisines_name_2186828');
     $query->join('LEFT', '#__akrecipes_cuisines AS #__akrecipes_cuisines_2186828 ON #__akrecipes_cuisines_2186828.id = a.cuisines_id');
     // Join over the foreign key 'meal_course_id'
     $query->select('#__akrecipes_meal_course_2186829.name AS courses_name_2186829');
     $query->join('LEFT', '#__akrecipes_meal_course AS #__akrecipes_meal_course_2186829 ON #__akrecipes_meal_course_2186829.id = a.meal_course_id');
     // Join over the created by field 'created_by'
     $query->select('`created_by`.name AS `author`, `created_by`.email as `author_email`');
     $query->join('LEFT', '#__users AS created_by ON created_by.id = a.created_by');
     // join the stats
     $query->select('stats.all_time_stats as `all_time_stats`, stats.30_day_stats as `30_day_stats`, stats.7_day_stats as `7_day_stats`, stats.1_day_stats as `1_day_stats`');
     $query->join('LEFT', '#__akrecipes_stats as stats ON stats.content_id = a.id');
     // Join over the created by field 'modified_by'
     $query->join('LEFT', '#__users AS modified_by ON modified_by.id = a.modified_by');
     if ($source == 'filter') {
         if ($params->get('tagid')) {
             $query->join('INNER', '#__contentitem_tag_map AS tags_map ON `tags_map`.`content_item_id` = a.`id`');
         }
         // only published recipes
         $query->where('a.state = 1 ');
         $query->where('(a.publish_up = ' . $nullDate . ' OR a.publish_up <= ' . $nowDate . ')');
         if ($params->get('categories')) {
             $categories = $params->get('categories');
             if ($params->get('show_child_categories', 1) == 1) {
                 foreach ($categories as $key => $category) {
                     $childids = ModAkrecipesrecipesHelper::getChildrenIds($category);
                     $categories = array_merge($categories, $childids);
                 }
             }
             $query->where("a.catid IN ( " . $db->escape(implode(',', $categories)) . " )");
         }
         if ($params->get('user')) {
             $query->where(' a.created_by = ' . $db->quote($params->get('user')));
         }
         if ($params->get('tagid')) {
             $query->where("tags_map.tag_id IN ( " . $db->escape(implode(',', $params->get('tagid'))) . " )");
         }
         if ($params->get('show_video_recipes', 0) == 1) {
             $query->where(" TRIM(a.video_link) <> '' ");
         }
         $recipes_sort_by = '';
         switch ($params->get('recipes_sort_by', 'published')) {
             case 'published':
                 $recipes_sort_by = 'a.publish_up';
                 break;
             case 'name':
                 $recipes_sort_by = 'a.recipe_name';
                 break;
             case 'created':
                 $recipes_sort_by = ' a.created ';
                 break;
             case 'created':
                 $recipes_sort_by = ' a.created ';
                 break;
             case 'popular':
                 $recipes_sort_by = ' all_time_stats ';
                 break;
             case '30day':
                 $recipes_sort_by = ' 30_day_stats ';
                 break;
             case '7day':
                 $recipes_sort_by = ' 7_day_stats ';
                 break;
             case '1day':
                 $recipes_sort_by = ' 1_day_stats ';
                 break;
             default:
                 $recipes_sort_by = 'a.publish_up';
                 break;
         }
         $query->order($recipes_sort_by . ' ' . $params->get('recipes_order_by', 'desc'));
         $recipe_count = $params->get('recipe_count', 10);
     } else {
         $recipe_ids = $params->get('recipe_ids');
         $query->where(' a.id in ( ' . $db->escape(implode(',', $recipe_ids)) . ' )');
         $query->order(" FIELD (a.id , " . $db->escape(implode(',', $recipe_ids)) . " )");
         $recipe_count = count($recipe_ids);
     }
     error_log("Mod query -> " . $query->__toString());
     $db->setQuery($query, 0, $recipe_count);
     $rows = $db->loadObjectList();
     // foreach ($rows as $key => $row) {
     // 	error_log($row->id . ' -- ' . $row->recipe_name ) ;
     // }
     return $rows;
 }
Exemple #2
0
<?php

/**
 * @version     CVS: 1.0.1
 * @package     com_akrecipes
 * @subpackage  mod_akrecipes
 * @author      Rutvik Doshi <*****@*****.**>
 * @copyright   Copyright (C) 2015. All rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */
defined('_JEXEC') or die;
require_once JPATH_SITE . '/components/com_akrecipes/helpers/route.php';
require_once JPATH_SITE . '/components/com_akrecipes/helpers/akrecipes.php';
$recipes = ModAkrecipesrecipesHelper::getList($params);
?>

<?php 
if (!empty($recipes)) {
    ?>
	<div class="container-fluid mod_akrecipes_recipe horizontal_4">
		<?php 
    $recipe_count = count($recipes);
    ?>
		<?php 
    foreach ($recipes as $key => $recipe) {
        ?>
			<?php 
        $image_size = $params->get('image_size', 'Small');
        $image = AkrecipesFrontendHelper::resizeImageToCache($recipe->image, $image_size);
        // $image = $recipe->image ;
        // if (strpos($image, '/') === 0 ) {
Exemple #3
0
<?php

/**
 * @version     CVS: 1.0.1
 * @package     com_akrecipes
 * @subpackage  mod_akrecipes
 * @author      Rutvik Doshi <*****@*****.**>
 * @copyright   Copyright (C) 2015. All rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */
defined('_JEXEC') or die;
$elements = ModAkrecipesrecipesHelper::getList($params);
?>

<?php 
if (!empty($elements)) {
    ?>
	<table class="table">
		<?php 
    foreach ($elements as $element) {
        ?>
			<tr>
				<td><?php 
        echo $element->recipe_name;
        ?>
</td>
			</tr>
		<?php 
    }
    ?>
	</table>