Ejemplo n.º 1
0
 /**
  * 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);
 }
Ejemplo n.º 2
0
    ?>
	<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 
Ejemplo n.º 3
0
	

	<?php 
if (count($this->link_items) > 0) {
    ?>
		<div id="blog_link_items" class="list-group">
		<?php 
    foreach ($this->link_items as $i => $item) {
        ?>
 
			<?php 
        $image = $item->image;
        if (strpos($image, '/') === 0) {
            $image = substr($image, 1);
        }
        $recipe_url = JRoute::_(AkrecipesHelperRoute::getRecipeRoute((int) $item->id, $item->catid));
        ?>

			<a href="<?php 
        echo $recipe_url;
        ?>
	" class="list-group-item">
				<h4 class="list-group-item-heading"><?php 
        echo $item->recipe_name;
        ?>
</h4>
				<p><?php 
        echo AkrecipesFrontendHelper::truncate_text($item->recipe_description, 100, true);
        ?>
</p>
			</a>
Ejemplo n.º 4
0
// No direct access
defined('_JEXEC') or die;
require_once JPATH_COMPONENT_SITE . '/helpers/akrecipes.php';
require_once JPATH_COMPONENT_SITE . '/helpers/route.php';
$item = $this->recipe;
?>


<!-- get recipe image -->
<?php 
$imagesize = array();
$imagesize['width'] = 140;
$imagesize['height'] = 112;
// 112 = 140/1.25
$image = AkrecipesFrontendHelper::resizeImageToCache($item->image, $imagesize);
$item_url = AkrecipesHelperRoute::getRecipeRoute($item->id, $item->catid);
// JRoute::_('index.php?option=com_akrecipes&view=recipe&id='.(int) $item->id);
$published = $item->state;
$unpublished = AkrecipesFrontendHelper::getRecipeUnpublishedText($item);
$canEdit = AkrecipesFrontendHelper::canEdit($item);
?>

<div class="media brandRecipe mobile">

	<div class="pull-left">
		<a href="<?php 
echo $item_url;
?>
">
			<img class="img-thumbnail" src="<?php 
echo $image;
Ejemplo n.º 5
0
 /**
  * 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);
     }
 }
Ejemplo n.º 6
0
 /**
  * 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);
 }
Ejemplo n.º 7
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);
 }
Ejemplo n.º 8
0
 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;
 }
Ejemplo n.º 9
0
 /**
  * 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;
 }