コード例 #1
0
ファイル: view.json.php プロジェクト: rutvikd/ak-recipes
 /**
  * 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)
 {
     // Parameters
     $app = JFactory::getApplication();
     $doc = JFactory::getDocument();
     $params = $app->getParams();
     //error_log("AkrecipesViewRecipes View.feed --> params = " . print_r($params,true));
     $feed_limit = $app->input->get('feed_limit');
     if (!isset($feed_limit)) {
         $feed_limit = $params->get('feed_limit', 24);
     }
     $feed_show_author_email = $app->input->get('feed_show_author_email');
     if (!isset($feed_show_author_email)) {
         $feed_show_author_email = $params->get('feed_show_author_email');
     }
     $feed_bogus_author_email = $app->input->get('feed_bogus_author_email');
     if (!isset($feed_bogus_author_email)) {
         $feed_bogus_author_email = $params->get('feed_bogus_author_email');
     }
     $jsonObject = new stdClass();
     $jsonObject->category = 'Frontpage';
     $jsonObject->items = array();
     // Get some data from the model
     $app->input->set('limit', $feed_limit);
     $this->items = $this->get('Items');
     foreach ($this->items as $i => $item) {
         // Strip html from feed item title
         $title = $this->escape($item->title);
         $title = html_entity_decode($title, ENT_COMPAT, 'UTF-8');
         $jsonObject->title = $title;
         switch ($item->type_alias) {
             case 'com_akrecipes.recipe':
                 $item_link = JRoute::_(AkrecipesHelperRoute::getRecipeRoute($item->id, $item->catid));
                 $jsonObject->image = $item->image;
                 break;
             case 'com_content.article':
                 $item_link = JRoute::_(ContentHelperRoute::getArticleRoute($item->id, $item->catid));
                 $images = json_decode($item->image);
                 if ($images) {
                     $jsonObject->image = $images->image_intro;
                 }
                 break;
             default:
                 break;
         }
         $item->link = $item_link;
         $jsonObject->description = $item->intro_text;
         $jsonObject->author = $item->author;
         if ($feed_show_author_email != 1) {
             $item->author_email = $feed_bogus_author_email;
         }
         // Loads item info into rss array
         $jsonObject->items[] = $item;
     }
     echo json_encode($jsonObject);
 }
コード例 #2
0
ファイル: recipe.php プロジェクト: rutvikd/ak-recipes
 /**
  * Method to check out an item for editing and redirect to the edit form.
  *
  * @return void
  *
  * @since    1.6
  */
 public function edit()
 {
     $app = JFactory::getApplication();
     // Get the previous edit id (if any) and the current edit id.
     $previousId = (int) $app->getUserState('com_akrecipes.edit.recipe.id');
     $editId = $app->input->getInt('id', 0);
     // Set the user id for the user to edit in the session.
     $app->setUserState('com_akrecipes.edit.recipe.id', $editId);
     // Get the model.
     $model = $this->getModel('Recipe', 'AkrecipesModel');
     // Check out the item
     if ($editId) {
         $model->checkout($editId);
     }
     // Check in the previous user.
     if ($previousId && $previousId !== $editId) {
         $model->checkin($previousId);
     }
     // Redirect to the edit screen.
     $edit_url = AkrecipesHelperRoute::getFormRoute($editId);
     error_log("AkrecipesControllerRecipe::edit Redirecting to -> " . $edit_url);
     //$this->setRedirect($edit_url,false);
 }
コード例 #3
0
ファイル: default_recipe.php プロジェクト: rutvikd/ak-recipes
				
				<div class="recipedate">
					<?php 
echo JHTML::_('date', $recipe->publish_up, JText::_('DATE_FORMAT_LC2'));
?>
 </div>
				<div class="recipedescription">
					<p><?php 
echo AkrecipesFrontendHelper::truncate_text($recipe->recipe_description, 300, true);
?>
 </p>
				</div>

				<div class="col-md-12 catBlock">
					<?php 
$caturl = AkrecipesHelperRoute::getCategoryRoute($recipe->catid);
?>
 					<span><i class="fa fa-folder"></i> Published in <a href="<?php 
echo $caturl;
?>
" title="View more recipes in <?php 
echo $recipe->catid_title;
?>
"><?php 
echo $recipe->catid_title;
?>
</a></span>					
				</div>

				<?php 
if (!empty($recipe->tags)) {
コード例 #4
0
ファイル: blog_item.php プロジェクト: rutvikd/ak-recipes
			<div class="readmore">
				<a class="btn btn-primary btn-xs" role="button" href="<?php 
echo $recipe_url;
?>
" title="<?php 
echo 'Read ' . $item->recipe_name;
?>
">
												Get Recipe
				</a>
			</div>

			<div class="catBlock">
				<?php 
$caturl = JRoute::_(AkrecipesHelperRoute::getCategoryRoute($item->catid));
?>
					<span><i class="fa fa-folder"></i> Published in <a href="<?php 
echo $caturl;
?>
" title="View more recipes in <?php 
echo $item->catid_title;
?>
"><?php 
echo $item->catid_title;
?>
</a></span>														
			</div>						

			<?php 
if (!empty($item->tags)) {
コード例 #5
0
?>

					</a>
				</h3>
				<?php 
if ($unpublished) {
    ?>
					<span class="label label-warning"><?php 
    echo $unpublished;
    ?>
</span>
					<?php 
    if ($unpublished == JTEXT::_('COM_AKRECIPES_JUNPUBLISHED') && $canEdit) {
        ?>
						<a class="btn btn-primary btn-xs" href=" <?php 
        AkrecipesHelperRoute::getFormRoute($item->id);
        ?>
">Edit</a>
					<?php 
    }
    ?>
				<?php 
}
?>

				<div class="recipedate">
					<?php 
echo JHTML::_('date', $item->publish_up, JText::_('DATE_FORMAT_LC1'));
?>
 
				</div>
コード例 #6
0
 * @package     Joomla.Site
 * @subpackage  com_akrecipes
 *
 * @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;
JHtml::addIncludePath(JPATH_COMPONENT . '/helpers');
require_once JPATH_COMPONENT . '/helpers/route.php';
require_once JPATH_COMPONENT . '/helpers/akrecipes.php';
//JHtml::_('behavior.core');
// Get the user object.
$user = JFactory::getUser();
$item = $this->params->get('my_item', null);
$author_url = JRoute::_('index.php?option=com_akrecipes&view=recipesbyuser&task=recipesbyuser.display&id=' . (int) $item->created_by);
$recipe_url = AkrecipesHelperRoute::getRecipeRoute($item->id, $item->catid);
// $image = $item->image;
// if (strpos($image, '/') === 0 ) {
// 	$image= substr($image, 1);
// }
//$image = AkrecipesFrontendHelper::resizeImageToCache($item->image,'Medium');
$image = AkrecipesFrontendHelper::resizeImageToCache($item->image, 'MediumRectangle');
$unpublished = $item->state == 0;
?>

<a href="<?php 
echo $recipe_url;
?>
" title="<?php 
echo $item->title;
?>
コード例 #7
0
						<?php 
echo $item->recipe_name;
?>
					</h3>
					<?php 
if ($unpublished) {
    ?>
						<span class="label label-warning"><?php 
    echo $unpublished;
    ?>
</span>
						<?php 
    if ($unpublished == JTEXT::_('COM_AKRECIPES_JUNPUBLISHED') && $canEdit) {
        ?>
							<a class="btn btn-primary btn-xs" href="<?php 
        echo JRoute::_(AkrecipesHelperRoute::getFormRoute((int) $item->id), false, 2);
        ?>
">Edit</a>
						<?php 
    }
    ?>
					<?php 
}
?>

					<div class="recipedescription">
						<p itemprop="description"><?php 
echo AkrecipesFrontendHelper::truncate_text($item->recipe_description, 150, true);
?>
</p>
					</div>	
コード例 #8
0
ファイル: com_akrecipes.php プロジェクト: rutvikd/ak-recipes
 static function getTree($xmap, $parent, &$params)
 {
     // error_log("xmap_com_akrecipes::getTree xmap = " . print_r($xmap,true));
     // error_log("xmap_com_akrecipes::getTree parent = " . print_r($parent,true));
     $db = JFactory::getDBO();
     $app = JFactory::getApplication();
     $user = JFactory::getUser();
     $result = null;
     $link_query = parse_url($parent->link);
     if (!isset($link_query['query'])) {
         return;
     }
     parse_str(html_entity_decode($link_query['query']), $link_vars);
     $view = JArrayHelper::getValue($link_vars, 'view', '');
     $id = intval(JArrayHelper::getValue($link_vars, 'id', ''));
     //error_log("xmap_com_akrecipes::getTree view = " . $view . ' id = ' . $id );
     switch ($view) {
         case 'recipes':
             $nullDate = $db->quote($db->getNullDate());
             $nowDate = $db->quote(JFactory::getDate()->toSql());
             $query = $db->getQuery(true);
             $query->select('a.*');
             $query->from('`#__akrecipes_recipe` AS a');
             $query->where("a.catid = '" . $db->escape($id) . "'");
             $query->where('a.state = 1 ');
             $query->where('(a.publish_up = ' . $nullDate . ' OR a.publish_up <= ' . $nowDate . ')');
             // filter expired recipes
             $query->where('(a.publish_down = ' . $nullDate . ' OR a.publish_down >= ' . $nowDate . ')');
             $db->setQuery($query);
             $recipes = $db->loadObjectList();
             if (count($recipes) > 0) {
                 $xmap->changeLevel(1);
                 foreach ($recipes as $key => $recipe) {
                     $node = new stdclass();
                     $node->id = $parent->id;
                     $node->uid = $parent->uid . 'a' . $recipe->id;
                     $node->browserNav = $parent->browserNav;
                     $node->priority = $params['priority'];
                     $node->changefreq = $params['changefreq'];
                     $node->name = $recipe->recipe_name;
                     $node->modified = $recipe->modified;
                     $node->expandible = false;
                     $node->secure = $parent->secure;
                     // TODO: Should we include category name or metakey here?
                     // $node->keywords = $item->metakey;
                     $node->newsItem = 1;
                     $node->language = $recipe->language;
                     // For the google news we should use te publication date instead
                     // the last modification date. See
                     if ($xmap->isNews || !$node->modified) {
                         $node->modified = $recipe->created;
                     }
                     if ($params['add_images'] && $recipe->image) {
                         $node->images = array();
                         $image = new stdClass();
                         $image->src = JURI::base() . $recipe->image;
                         $image->title = $recipe->recipe_name;
                         $node->images[] = $image;
                     }
                     //$node->slug = $item->alias ? ($item->id . ':' . $item->alias) : $item->id;
                     //$node->catslug = $item->category_route ? ($catid . ':' . $item->category_route) : $catid;
                     $node->catslug = $recipe->catid;
                     $node->link = AkrecipesHelperRoute::getRecipeRoute($recipe->id, $recipe->catid);
                     $xmap->printNode($node);
                 }
                 $xmap->changeLevel(-1);
             }
             $result = true;
             break;
         default:
             # code...
             break;
     }
     return $result;
 }
コード例 #9
0
ファイル: horizontal_3.php プロジェクト: rutvikd/ak-recipes
if (!empty($users)) {
    ?>
	<div class="container-fluid mod_akrecipes_featured_users horizontal_3">
		<?php 
    foreach ($users as $key => $user) {
        ?>
			<?php 
        $image_size = $params->get('image_size', 'Medium');
        $showimages = $params->get('showimages', true);
        $image = $user->userprofile->akprofile['image'];
        if ($image) {
            $image = AkrecipesFrontendHelper::resizeImageToCache($image, $image_size);
        } else {
            $image = 'media/com_akrecipes/images/user.png';
        }
        $user_url = AkrecipesHelperRoute::getAuthorRoute($user->id);
        $num_cols = 3;
        ?>

			<?php 
        echo $key % $num_cols == 0 ? '<div class="row">' : '';
        ?>

				 <div class="col-md-4 col-xs-4">
				 	<div class="thumbnail">
				 		<a href="<?php 
        echo $user_url;
        ?>
">				 			
							<img src="<?php 
        echo $image;
コード例 #10
0
    echo $this->item->recipe_name;
    ?>
 Video</span></a>
			</div>
		</div>     	
     </div>
 	<?php 
}
?>
 

 	<?php 
if (isset($this->item->contest)) {
    ?>
 		<?php 
    $contest_url = JRoute::_(AkrecipesHelperRoute::getContestRoute($this->item->contest_id));
    $contest_name = $this->item->contest->contest_name;
    $contest_description = $this->item->contest->contest_name;
    //strip_tags($this->contest->contest_description) ;
    ?>

	 	<div class="row contestBlock">
	 		<div class="col-md-12">
	 			<p>	 				
	 				<?php 
    echo $this->item->recipe_name;
    ?>
 is part of the <a href="<? echo $contest_url ; ?>?" title="<?php 
    echo $contest_description;
    ?>
"><?php 
コード例 #11
0
ファイル: default.php プロジェクト: rutvikd/ak-recipes
echo $this->loadTemplate('core');
?>

	<?php 
//echo $this->loadTemplate('params');
?>

	<?php 
echo $this->loadTemplate('custom');
?>

<!-- <div class="row">
	<div class="col-md-12 col-xs-12">
		<div class="users-profile-button">
			<a class="btn btn-primary active" role="button" href="<?php 
echo JRoute::_(AkrecipesHelperRoute::getAuthorRoute((int) $this->data->id));
?>
">
				<?php 
echo 'View ' . JFactory::getUser()->name . '\'s Recipes & Articles';
?>
</a>
		</div>

	</div>	
</div> -->




</div>
コード例 #12
0
ファイル: recipeform.php プロジェクト: rutvikd/ak-recipes
 /**
  * Method to abort current operation
  *
  * @return void
  *
  * @throws Exception
  */
 public function cancel()
 {
     $app = JFactory::getApplication();
     // Get the current edit id.
     $editId = (int) $app->getUserState('com_akrecipes.edit.recipe.id');
     // Get the model.
     $model = $this->getModel('RecipeForm', 'AkrecipesModel');
     // Check in the item
     if ($editId) {
         $model->checkin($editId);
         $url = AkrecipesHelperRoute::getRecipeRoute($editId);
     } else {
         $menu = JFactory::getApplication()->getMenu();
         $item = $menu->getActive();
         $url_nosef = empty($item->link) ? 'index.php?option=com_akrecipes&view=recipes' : $item->link;
         $url = JRoute::_($url_nosef, false);
     }
     $this->setRedirect($url);
 }
コード例 #13
0
ファイル: default.php プロジェクト: rutvikd/ak-recipes
		<?php 
    $user_count = count($users);
    ?>
		<?php 
    foreach ($users as $key => $user) {
        ?>
			<?php 
        $image_size = $params->get('image_size', 'Small');
        $showimages = $params->get('showimages', true);
        $image = $user->userprofile->akprofile['image'];
        if ($image) {
            $image = AkrecipesFrontendHelper::resizeImageToCache($image, "Small");
        } else {
            $image = 'media/com_akrecipes/images/user.png';
        }
        $user_url = AkrecipesHelperRoute::getAuthorRoute($user->created_by);
        $num_cols = $params->get('num_cols', 4);
        $colspan = 12 / $num_cols;
        ?>

			<?php 
        echo $key % $num_cols == 0 ? '<div class="row">' : '';
        ?>

				 <div class="col-md-<?php 
        echo $colspan;
        ?>
 col-xs-2">
				 	<div class="thumbnail">
				 		<?php 
        if ($showimages && $image) {
コード例 #14
0
 /**
  * Method to index an item. The item must be a FinderIndexerResult object.
  *
  * @param   FinderIndexerResult  $item    The item to index as an FinderIndexerResult object.
  * @param   string               $format  The item format.  Not used.
  *
  * @return  void
  *
  * @since   2.5
  * @throws  Exception on database error.
  */
 protected function index(FinderIndexerResult $item, $format = 'html')
 {
     $item->setLanguage();
     // Check if the extension is enabled.
     if (JComponentHelper::isEnabled($this->extension) == false) {
         return;
     }
     // Initialise the item parameters.
     $registry = new Registry();
     $registry->loadString($item->params);
     $item->params = JComponentHelper::getParams('com_akrecipes', true);
     $item->params->merge($registry);
     $registry = new Registry();
     $registry->loadString($item->metadata);
     $item->metadata = $registry;
     // Trigger the onContentPrepare event.
     $item->summary = FinderIndexerHelper::prepareContent($item->summary, $item->params);
     $item->body = FinderIndexerHelper::prepareContent($item->body, $item->params);
     // Build the necessary route and path information.
     $item->url = $this->getUrl($item->id, $this->extension, $this->layout);
     $item->route = AkrecipesHelperRoute::getRecipeRoute($item->id, $item->catid);
     $item->path = JRoute::_($item->route);
     //FinderIndexerHelper::getContentPath($item->route);
     // Get the menu title if it exists.
     $title = $this->getItemMenuTitle($item->url);
     // Adjust the title if necessary.
     if (!empty($title) && $this->params->get('use_menu_title', true)) {
         $item->title = $title;
     }
     // Add the meta-author.
     $item->metaauthor = $item->metadata->get('author');
     // Add the meta-data processing instructions.
     $item->addInstruction(FinderIndexer::META_CONTEXT, 'metakey');
     $item->addInstruction(FinderIndexer::META_CONTEXT, 'metadesc');
     //$item->addInstruction(FinderIndexer::META_CONTEXT, 'metaauthor');
     $item->addInstruction(FinderIndexer::META_CONTEXT, 'author');
     $item->addInstruction(FinderIndexer::META_CONTEXT, 'created_by_alias');
     // Translate the state. Articles should only be published if the category is published.
     $item->state = $this->translateState($item->state, $item->cat_state);
     // Add the type taxonomy data.
     $item->addTaxonomy('Type', 'AK Recipe');
     // Add the author taxonomy data.
     if (!empty($item->author) || !empty($item->created_by_alias)) {
         $item->addTaxonomy('Author', !empty($item->created_by_alias) ? $item->created_by_alias : $item->author);
     }
     // Add the category taxonomy data.
     $item->addTaxonomy('Category', $item->category, $item->cat_state, $item->cat_access);
     // Add the language taxonomy data.
     $item->addTaxonomy('Language', $item->language);
     // Get content extras.
     FinderIndexerHelper::getContentExtras($item);
     //error_log("Indexing Item -> " . print_r($item,true));
     // Index the item.
     $this->indexer->index($item);
 }
コード例 #15
0
ファイル: blog.php プロジェクト: rutvikd/ak-recipes
		<?php 
    }
    ?>

		</div>

	<?php 
}
?>


<?php 
if ($canCreate) {
    ?>
	<a href="<?php 
    echo JRoute::_(AkrecipesHelperRoute::getFormRoute(), false, 2);
    ?>
"
	   class="btn btn-success btn-small"><i
			class="icon-plus"></i>
		<?php 
    echo JText::_('COM_AKRECIPES_ADD_ITEM');
    ?>
</a>
<?php 
}
?>

<?php 
echo $this->pagination->getListFooter();
?>
コード例 #16
0
ファイル: view.feed.php プロジェクト: rutvikd/ak-recipes
 /**
  * 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)
 {
     // Parameters
     $app = JFactory::getApplication();
     $doc = JFactory::getDocument();
     $params = $app->getParams();
     //error_log("AkrecipesViewRecipes View.feed --> params = " . print_r($params,true));
     $feedEmail = $app->get('feed_email', 'author');
     $siteEmail = $app->get('mailfrom');
     $feed_summary = $app->input->get('feed_summary');
     if (!isset($feed_summary)) {
         $feed_summary = $params->get('feed_summary');
     }
     if ($feed_summary == 1) {
         $doc->link = JRoute::_('index.php?option=com_akrecipes&view=frontpage&task=recipes.display&format=feed');
     }
     $feed_limit = $app->input->get('feed_limit');
     if (!isset($feed_limit)) {
         $feed_limit = $params->get('feed_limit', 24);
     }
     $feed_show_image = $app->input->get('feed_show_image');
     if (!isset($feed_show_image)) {
         $feed_show_image = $params->get('feed_show_image');
     }
     $feed_show_author_email = $app->input->get('feed_show_author_email');
     if (!isset($feed_show_author_email)) {
         $feed_show_author_email = $params->get('feed_show_author_email');
     }
     $feed_bogus_author_email = $app->input->get('feed_bogus_author_email');
     if (!isset($feed_bogus_author_email)) {
         $feed_bogus_author_email = $params->get('feed_bogus_author_email');
     }
     // Get some data from the model
     $app->input->set('limit', $feed_limit);
     $this->items = $this->get('Items');
     foreach ($this->items as $i => $item) {
         // Strip html from feed item title
         $title = $this->escape($item->title);
         $title = html_entity_decode($title, ENT_COMPAT, 'UTF-8');
         switch ($item->type_alias) {
             case 'com_akrecipes.recipe':
                 $item_link = JRoute::_(AkrecipesHelperRoute::getRecipeRoute($item->id, $item->catid));
                 $image = $item->image;
                 break;
             case 'com_content.article':
                 $item_link = JRoute::_(ContentHelperRoute::getArticleRoute($item->id, $item->catid));
                 $images = json_decode($item->image);
                 if ($images) {
                     $image = $images->image_intro;
                 }
                 break;
             default:
                 break;
         }
         $description = $item->intro_text;
         $feed_description = '';
         //error_log("Item link --> " . $item_link);
         // Load individual item creator class
         $feedItem = new JFeedItem();
         $feedItem->title = $title;
         $feedItem->link = $item_link;
         $feedItem->date = $item->publish_up;
         $feedItem->category = $item->catid_title;
         if ($feed_show_image == 1) {
             $feed_description = $feed_description . '<div class="feed-image"><img src="' . $image . '"/></div>';
         }
         $feed_description = $feed_description . '<div class="feed-description">' . $description . '</div>';
         // Add readmore link to description if introtext is shown, show_readmore is true and fulltext exists
         if (!$params->get('feed_show_readmore', 1) && $params->get('feed_summary', 0)) {
             $feed_description .= '<p class="feed-readmore"><a target="_blank" href ="' . $item_link . '">' . JText::_('COM_CONTENT_FEED_READMORE') . '</a></p>';
         }
         $feedItem->description = html_entity_decode($feed_description, ENT_COMPAT, 'UTF-8');
         $feedItem->author = $item->author;
         if ($feed_show_author_email == 1) {
             $feedItem->authorEmail = $item->author_email;
         } else {
             $feedItem->authorEmail = $feed_bogus_author_email;
         }
         // Loads item info into rss array
         $doc->addItem($feedItem);
     }
 }
コード例 #17
0
ファイル: default.php プロジェクト: rutvikd/ak-recipes
    echo $contest_intro_text;
    ?>
				</div>
				<div class="contest-fulltext">
					<?php 
    echo $contest_full_text;
    ?>
				</div>				
			</div>
		</div>

		<?php 
    if (AkrecipesFrontendHelper::isContestLive($this->item) && $this->item->add_recipe == 1) {
        ?>
			<?php 
        $add_recipe_url = JRoute::_(AkrecipesHelperRoute::getAddRecipeRoute());
        ?>

			<div class="row contest-participate">
				<div class="col-md-10 col-md-offset-1">
					<div class="btn-group btn-group-justified">
						<a class="btn btn-primary" role="button" href="<?php 
        echo $add_recipe_url;
        ?>
" title="<?php 
        echo 'Add New Recipe & Participate in  ' . $this->item->contest_name;
        ?>
">
														Participate Now
						</a>
					</div>			
コード例 #18
0
?>

					</a>
				</h3>
				<?php 
if ($unpublished) {
    ?>
					<span class="label label-warning"><?php 
    echo $unpublished;
    ?>
</span>
					<?php 
    if ($unpublished == JTEXT::_('COM_AKRECIPES_JUNPUBLISHED') && $canEdit) {
        ?>
						<a class="btn btn-primary btn-xs" href="<?php 
        echo JRoute::_(AkrecipesHelperRoute::getFormRoute($item->id));
        ?>
">Edit</a>
					<?php 
    }
    ?>
				<?php 
}
?>

				<div class="recipedate">
					<?php 
echo JHTML::_('date', $item->publish_up, JText::_('AKRECIPES_DATE_FORMAT_LC2'));
?>
 
				</div>
コード例 #19
0
ファイル: horizontal_4.php プロジェクト: rutvikd/ak-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 ) {
        // 	$image = substr($image, 1);
        // }
        $recipe_url = JRoute::_(AkrecipesHelperRoute::getRecipeRoute($recipe->id, $recipe->catid));
        $author_url = JRoute::_(AkrecipesHelperRoute::getAuthorRoute($recipe->created_by));
        $num_cols = 4;
        ?>

			<?php 
        echo $key % $num_cols == 0 ? '<div class="row">' : '';
        ?>

				 <div class="col-md-3 col-xs-3">
				 	<div class="thumbnail">
				 		<a href="<?php 
        echo $recipe_url;
        ?>
">
							<?php 
        if (!empty($recipe->video_link)) {
コード例 #20
0
ファイル: akrecipes.php プロジェクト: rutvikd/ak-recipes
 /**
  * Search content (articles).
  * The SQL must return the following fields that are used in a common display
  * routine: href, title, section, created, text, browsernav.
  *
  * @param   string  $text      Target search string.
  * @param   string  $phrase    Matching option (possible values: exact|any|all).  Default is "any".
  * @param   string  $ordering  Ordering option (possible values: newest|oldest|popular|alpha|category).  Default is "newest".
  * @param   mixed   $areas     An array if the search it to be restricted to areas or null to search all areas.
  *
  * @return  array  Search results.
  *
  * @since   1.6
  */
 public function onContentSearch($text, $phrase = '', $ordering = '', $areas = null)
 {
     error_log("onContentSearch -->" . $text . ' , phrase --> ' . $phrase);
     $db = JFactory::getDbo();
     if (is_array($areas)) {
         if (!array_intersect($areas, array_keys($this->onContentSearchAreas()))) {
             return array();
         }
     }
     $limit = $this->params->def('search_limit', 50);
     $text = trim($text);
     if ($text == '') {
         return array();
     }
     $rows = array();
     //error_log("Now searching recipes..");
     //Search Recipes.
     if ($limit > 0) {
         switch ($phrase) {
             case 'exact':
                 $text = $db->quote('%' . $db->escape($text, true) . '%', false);
                 $wheres2 = array();
                 $wheres2[] = 'a.recipe_name LIKE ' . $text;
                 $wheres2[] = 'a.catid LIKE ' . $text;
                 //$wheres2[] = 'akrecipes_cuisines.name LIKE ' . $text;
                 $where = '(' . implode(') OR (', $wheres2) . ')';
                 break;
             case 'all':
             case 'any':
             default:
                 $words = explode(' ', $text);
                 $wheres = array();
                 foreach ($words as $word) {
                     $word = $db->quote('%' . $db->escape($word, true) . '%', false);
                     $wheres2 = array();
                     $wheres2[] = 'LOWER(a.recipe_name) LIKE LOWER(' . $word . ')';
                     $wheres2[] = 'LOWER(a.recipe_description) LIKE LOWER(' . $word . ')';
                     $wheres2[] = 'LOWER(a.pre_ingredient_notes) LIKE LOWER(' . $word . ')';
                     $wheres2[] = 'LOWER(a.ingredients_list) LIKE LOWER(' . $word . ')';
                     $wheres2[] = 'LOWER(a.recipe_instructions) LIKE LOWER(' . $word . ')';
                     $wheres2[] = 'LOWER(a.recipe_footnote) LIKE LOWER(' . $word . ')';
                     $wheres2[] = 'a.catid LIKE ' . $word;
                     //$wheres2[] = 'akrecipes_cuisines.name LIKE ' . $word;
                     $wheres[] = implode(' OR ', $wheres2);
                 }
                 $where = '(' . implode($phrase == 'all' ? ') AND (' : ') OR (', $wheres) . ')';
                 break;
         }
         // switch ($ordering) {
         //     default:
         //         $order = 'a.id DESC';
         //         break;
         // }
         // search relevancy ordering
         $order = ' CASE WHEN LOWER(a.recipe_name) LIKE LOWER(' . $word . ') THEN 0 ';
         $order .= ' WHEN LOWER(a.recipe_description) LIKE LOWER(' . $word . ') THEN 1 ';
         $order .= ' WHEN LOWER(a.pre_ingredient_notes) LIKE LOWER(' . $word . ') THEN 2 ';
         $order .= ' WHEN LOWER(a.ingredients_list) LIKE LOWER(' . $word . ') THEN 3 ';
         $order .= ' WHEN LOWER(a.recipe_instructions) LIKE LOWER(' . $word . ') THEN 4 ';
         $order .= ' WHEN LOWER(a.recipe_footnote) LIKE LOWER(' . $word . ') THEN 5 ';
         $order .= ' ELSE 5 END, a.id ';
         $query = $db->getQuery(true);
         $query->clear()->select(array('a.id', 'a.recipe_name AS title', '"" AS created', 'CONCAT (a.recipe_name, a.recipe_description, a.pre_ingredient_notes,a.ingredients_list, a.recipe_instructions, a.recipe_footnote)  AS text', '"Recipe" AS section', '1 AS browsernav', 'a.catid'))->from('#__akrecipes_recipe AS a')->where('(' . $where . ')')->group('a.id')->order($order);
         //->innerJoin('`#__akrecipes_cuisines` AS akrecipes_cuisines ON akrecipes_cuisines.id = a.cuisines_id')
         //error_log("Search Query --> " . $query->__toString());
         $db->setQuery($query, 0, $limit);
         $list = $db->loadObjectList();
         $limit -= count($list);
         if (isset($list)) {
             foreach ($list as $key => $item) {
                 $list[$key]->href = JRoute::_(AkrecipesHelperRoute::getRecipeRoute($item->id, $item->catid));
             }
         }
         $rows = array_merge($list, $rows);
     }
     return $rows;
 }