当前位置: 首页>>代码示例>>PHP>>正文


PHP AkrecipesFrontendHelper::getModel方法代码示例

本文整理汇总了PHP中AkrecipesFrontendHelper::getModel方法的典型用法代码示例。如果您正苦于以下问题:PHP AkrecipesFrontendHelper::getModel方法的具体用法?PHP AkrecipesFrontendHelper::getModel怎么用?PHP AkrecipesFrontendHelper::getModel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AkrecipesFrontendHelper的用法示例。


在下文中一共展示了AkrecipesFrontendHelper::getModel方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: onContentPrepare

 /**
  * prepare content method, search for string {loadcontest_##} , where ## is the contest id.
  * if found render the contest.
  *
  * Method is called by the view
  *
  * @param   string	The context of the content being passed to the plugin.
  * @param   object	The content object.  Note $article->text is also available
  * @param   object	The content params
  * @param   integer  The 'page' number
  * @since   1.6
  */
 public function onContentPrepare($context, &$article, &$params, $limitstart)
 {
     //error_log("In plgContentAkcontests::onContentPrepare");
     // Don't run this plugin when the content is being indexed
     if ($context == 'com_finder.indexer') {
         return true;
     }
     $app = JFactory::getApplication();
     // Simple performance check to determine whether bot should process further
     if (strpos($article->text, 'loadcontest') === false) {
         return true;
     }
     // Expression to search for (positions)
     $regex = '/{loadcontest\\s(.*?)}/i';
     // Find all instances of plugin and put in $matchesmod for loadmodule
     preg_match_all($regex, $article->text, $matches, PREG_SET_ORDER);
     // If no matches, skip this
     if ($matches) {
         foreach ($matches as $matchedcontest) {
             $contest_id = $matchedcontest[1];
             $contest_model = AkrecipesFrontendHelper::getModel('Contest');
             $contest_item = $contest_model->getData($contest_id);
             $output = $this->renderContest($contest_item);
             // We should replace only first occurrence in order to allow positions with the same name to regenerate their content:
             $article->text = preg_replace("|{$matchedcontest['0']}|", addcslashes($output, '\\$'), $article->text, 1);
         }
     }
 }
开发者ID:rutvikd,项目名称:ak-recipes,代码行数:40,代码来源:akcontests.php

示例2: parse

 /**
  * Parse method for URLs
  * This method is meant to transform the human readable URL back into
  * query parameters. It is only executed when SEF mode is switched on.
  *
  * @param   array  &$segments  The segments of the URL to parse.
  *
  * @return  array  The URL attributes to be used by the application.
  *
  * @since   3.3
  */
 public function parse(&$segments)
 {
     $vars = array();
     // View is always the first element of the array
     $vars['view'] = array_shift($segments);
     $model = AkrecipesFrontendHelper::getModel($vars['view']);
     while (!empty($segments)) {
         $segment = array_pop($segments);
         // If it's the ID, let's put on the request
         if (is_numeric($segment)) {
             $vars['id'] = $segment;
         } else {
             $vars['task'] = $vars['view'] . '.' . $segment;
         }
     }
     return $vars;
 }
开发者ID:rutvikd,项目名称:ak-recipes,代码行数:28,代码来源:router.php

示例3: getFullDescription

 protected function getFullDescription($item)
 {
     $recipe_model = AkrecipesFrontendHelper::getModel('recipe');
     $recipe_item = $recipe_model->getData($item->id);
     $feed_description = '';
     $feed_description = $feed_description . '<div class="recipe-description">' . $recipe_item->recipe_description . $recipe_item->pre_ingredient_notes . '</div>';
     $feed_description = $feed_description . '<div class="recipe_ingredients><h3>Ingredients for ' . $recipe_item->recipe_name . '</h3>';
     $ingredients_list = '';
     if (isset($recipe_item->ingredient) && is_array($recipe_item->ingredient)) {
         $ingredients_list = '<ul>';
         foreach ($recipe_item->ingredient as $key => $ingredient_item) {
             $ingredient_description = trim($recipe_item->ingredient_description[$key]);
             if (strpos($ingredient_description, '*') === 0 || strpos($ingredient_description, '<p>*') === 0) {
                 $ingredients_list = $ingredients_list . '<li><b>' . str_replace('*', '', $ingredient_description) . '</b></li>';
             } else {
                 $qty = trim($recipe_item->qty[$key]);
                 $unit = trim($recipe_item->unit[$key]);
                 $ingredient = trim($recipe_item->ingredient[$key]);
                 $ingredient_tooltip = trim($recipe_item->ingredient_tooltip[$key]);
                 $ingredient_description = trim($recipe_item->ingredient_description[$key]);
                 $ingredient_url = trim($recipe_item->ingredient_url[$key]);
                 $ingredient_qty_unit = (!empty($qty) ? $qty . ' ' : '') . (!empty($unit) ? $unit . ' ' : '');
                 $ingredients_list = $ingredients_list . '<li>';
                 $ingredients_list = $ingredients_list . $ingredient_qty_unit . ' ' . $ingredient;
                 if (!empty($ingredient_description)) {
                     $qty_unit_ing = $qty . $unit . $ingredient;
                     $ingredients_list = $ingredients_list . (!empty($qty_unit_ing) ? ', ' : ' ') . $ingredient_description;
                 }
                 $ingredients_list = $ingredients_list . '</li>';
             }
         }
         $ingredients_list = $ingredients_list . '</ul>';
     } else {
         $ingredients_list = '<ul>';
         $ingredients = explode("\n", $recipe_item->ingredients_list);
         foreach ($ingredients as $key => $ingredient) {
             if (strpos($ingredient, '*') === 0 || strpos($ingredient, "<p>*") === 0) {
                 $ingredient = str_replace('*', "", $ingredient);
                 $ingredients_list = $ingredients_list . '<b class="ingredientssubtitle">' . trim(strip_tags($ingredient)) . '</b>';
             } else {
                 if (trim($ingredient) != '<p>&nbsp;</p>') {
                     $ingredients_list = $ingredients_list . trim(strip_tags($ingredient, '<a>')) . '</li>';
                 }
             }
         }
         $ingredients_list = $ingredients_list . '</ul>';
     }
     $feed_description = $feed_description . $ingredients_list . '</div>';
     $feed_description = $feed_description . '<div class="recipe_instructions">';
     $feed_description = $feed_description . '<h3 class="recipeinstructionstitle">Directions for ' . $recipe_item->recipe_name . '</h3>';
     $recipe_instruction_list = explode("\n", $recipe_item->recipe_instructions);
     $ulopened = false;
     $ulclosed = false;
     foreach ($recipe_instruction_list as $instructions) {
         if (strpos($instructions, '*') === 0 || strpos($instructions, "<p>*") === 0) {
             $instructions = str_replace('*', "", $instructions);
             if ($ulopened) {
                 $feed_description = $feed_description . '</ol>';
                 $ulopened = false;
                 $ulclosed = true;
             }
             $feed_description = $feed_description . '<b class="recipeinstructionssubtitle">' . trim(strip_tags($instructions)) . '</b>';
         } else {
             if (!$ulopened) {
                 $feed_description = $feed_description . '<ol>';
                 $ulopened = true;
                 $ulclosed = false;
             }
             if (trim($instructions) != '<p>&nbsp;</p>') {
                 $feed_description = $feed_description . '<li itemprop="recipeInstructions">' . trim($instructions) . '</li>';
             }
         }
     }
     if (!$ulclosed) {
         $feed_description = $feed_description . '</ol>';
     }
     $feed_description = $feed_description . '</div>';
     $feed_description = $feed_description . '<div class="footnote">' . $recipe_item->recipe_footnote . '</div>';
     return $feed_description;
 }
开发者ID:rutvikd,项目名称:ak-recipes,代码行数:80,代码来源:view.feed.php


注:本文中的AkrecipesFrontendHelper::getModel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。