本文整理汇总了PHP中SibdietHelper::nutrientsCalc方法的典型用法代码示例。如果您正苦于以下问题:PHP SibdietHelper::nutrientsCalc方法的具体用法?PHP SibdietHelper::nutrientsCalc怎么用?PHP SibdietHelper::nutrientsCalc使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SibdietHelper
的用法示例。
在下文中一共展示了SibdietHelper::nutrientsCalc方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: defined
* @subpackage com_sibdiet
*
* @copyright Copyright (C) Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* @author Mohammad Hasani Eghtedar <m.h.eghtedar@gmail.com>
*/
// no direct access
defined('_JEXEC') or die;
if ($this->item->sweeteners_id) {
$allFoods++;
}
// Get Compositions
$query = $db->getQuery(true);
$query->select('s.compositions');
$query->from('#__sibdiet_sweeteners s');
$query->where('s.id = ' . (int) $this->item->sweeteners_id);
$db->setQuery($query);
$sweetenerCompositions = $db->loadObject();
$sweetenerNutrients = array();
if ($sweetenerCompositions) {
// convert Composition json to array
$registry = new JRegistry();
$registry->loadString($sweetenerCompositions->compositions);
$sweetenerCompositions = $registry->toArray();
// Count compositions that have ph or gi
$phCount = $giCount = 0;
// Calculate nutrients
$sweetenerNutrients = $sweetenerCompositions ? SibdietHelper::nutrientsCalc($sweetenerCompositions, $phCount, $giCount) : array();
$tempNutrients = $sweetenerNutrients;
require 'calculation_html.php';
}
示例2: defined
* @subpackage com_sibdiet
*
* @copyright Copyright (C) Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* @author Mohammad Hasani Eghtedar <m.h.eghtedar@gmail.com>
*/
// no direct access
defined('_JEXEC') or die;
if ($this->item->dairies_id) {
$allFoods++;
}
// Get Compositions
$query = $db->getQuery(true);
$query->select('d.compositions');
$query->from('#__sibdiet_dairies d');
$query->where('d.id = ' . (int) $this->item->dairies_id);
$db->setQuery($query);
$dairyCompositions = $db->loadObject();
$dairyNutrients = array();
if ($dairyCompositions) {
// convert Composition json to array
$registry = new JRegistry();
$registry->loadString($dairyCompositions->compositions);
$dairyCompositions = $registry->toArray();
// Count compositions that have ph or gi
$phCount = $giCount = 0;
// Calculate nutrients
$dairyNutrients = $dairyCompositions ? SibdietHelper::nutrientsCalc($dairyCompositions, $phCount, $giCount) : array();
$tempNutrients = $dairyNutrients;
require 'calculation_html.php';
}
示例3: foreach
if (!empty($dayFoods)) {
foreach ($dayFoods as $key => $food) {
// Get Compositions
$query = $db->getQuery(true)->select('f.compositions')->from('#__sibdiet_foods f')->where('f.id = ' . (int) $food);
$db->setQuery($query);
$foodCompositions = $db->loadResult();
// Count compositions that have ph or gi
$phCount = $giCount = 0;
if ($foodCompositions) {
// convert Composition json to array
$registry = new JRegistry();
$registry->loadString($foodCompositions);
$foodCompositions = $registry->toArray();
// Calculate nutrients
if (!empty($foodCompositions)) {
$dayFoodsNutrients[] = SibdietHelper::nutrientsCalc($foodCompositions, $phCount, $giCount);
}
}
}
$dayFoodsNutrients[] = $morningSnackNutrients;
$dayFoodsNutrients[] = $eveningSnackNutrients;
$dayFoodsNutrients[] = $sweetenerNutrients;
$dayFoodsNutrients[] = $fruitNutrients;
$dayFoodsNutrients[] = $dairyNutrients;
$dayFoodsNutrients[] = $prescriptionsNutrients;
$dayNutrients = array_filter($dayFoodsNutrients);
$cold_nutrient = $params->get('cold_nutrient');
$warm_nutrient = $params->get('warm_nutrient');
$wet_nutrient = $params->get('wet_nutrient');
$dry_nutrient = $params->get('dry_nutrient');
$warmCount = $coldCount = $dryCount = $wetCount = 0;
示例4: defined
* @subpackage com_sibdiet
*
* @copyright Copyright (C) Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* @author Mohammad Hasani Eghtedar <m.h.eghtedar@gmail.com>
*/
// no direct access
defined('_JEXEC') or die;
if ($this->item->fruits_id) {
$allFoods++;
}
// Get Compositions
$query = $db->getQuery(true);
$query->select('f.compositions');
$query->from('#__sibdiet_fruits f');
$query->where('f.id = ' . (int) $this->item->fruits_id);
$db->setQuery($query);
$fruitCompositions = $db->loadObject();
$fruitNutrients = array();
if ($fruitCompositions) {
// convert Composition json to array
$registry = new JRegistry();
$registry->loadString($fruitCompositions->compositions);
$fruitCompositions = $registry->toArray();
// Count compositions that have ph or gi
$phCount = $giCount = 0;
// Calculate nutrients
$fruitNutrients = $fruitCompositions ? SibdietHelper::nutrientsCalc($fruitCompositions, $phCount, $giCount) : array();
$tempNutrients = $fruitNutrients;
require 'calculation_html.php';
}
示例5: getItem
/**
* Method to get a single record.
*
* @param integer The id of the primary key.
*
* @return mixed Object on success, false on failure.
* @since 1.6
*/
public function getItem($pk = null)
{
if ($item = parent::getItem($pk)) {
// Convert the print_title field to an array.
$registry = new JRegistry();
$registry->loadString($item->print_title);
$item->print_title = $registry->toArray();
// Convert the compositions field to an array.
$registry = new JRegistry();
$registry->loadString($item->compositions);
$item->compositions = $registry->toArray();
if (empty($item->compositions)) {
// Convert the nutrients field to an array.
$registry = new JRegistry();
$registry->loadString($item->nutrients);
$item->nutrients = $registry->toArray();
} else {
// if composition has sub compositions then we calc nutrients of sub compositions
$item->nutrients = SibdietHelper::nutrientsCalc($item->compositions);
}
}
return $item;
}
示例6: defined
* @subpackage com_sibdiet
*
* @copyright Copyright (C) Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* @author Mohammad Hasani Eghtedar <m.h.eghtedar@gmail.com>
*/
// no direct access
defined('_JEXEC') or die;
if ($this->item->evening_snack_id) {
$allFoods++;
}
// Get Compositions
$query = $db->getQuery(true);
$query->select('f.compositions');
$query->from('#__sibdiet_foods f');
$query->where('f.id = ' . (int) $this->item->evening_snack_id);
$db->setQuery($query);
$eveningSnackCompositions = $db->loadObject();
$eveningSnackNutrients = array();
if ($eveningSnackCompositions) {
// Convert Composition json to array
$registry = new JRegistry();
$registry->loadString($eveningSnackCompositions->compositions);
$eveningSnackCompositions = $registry->toArray();
// Count compositions that have ph or gi
$phCount = $giCount = 0;
// Calculate nutrients
$eveningSnackNutrients = $eveningSnackCompositions ? SibdietHelper::nutrientsCalc($eveningSnackCompositions, $phCount, $giCount) : array();
$tempNutrients = $eveningSnackNutrients;
require 'calculation_html.php';
}
示例7:
case $age < 19:
$standardField = 'st_14_18_years';
break;
case $age < 51:
$standardField = $this->item->profile->gender == 'MALE' ? 'st_19_50_years_male' : 'st_19_50_years_female';
break;
case $age < 71:
$standardField = $this->item->profile->gender == 'MALE' ? 'st_51_70_years_male' : 'st_51_70_years_female';
break;
default:
$standardField = 'st_71_years';
break;
}
$standardComposition = $params->get($standardField);
$phCount = $giCount = $allFoods = 0;
$standardNutrients = SibdietHelper::nutrientsCalc(array($standardComposition => $standardComposition));
?>
<div>
<div class="pull-right">
<input class="btn print" name="print" type="button" onclick="window.print()" value="<?php
echo JText::_('COM_SIBDIET_PRINT');
?>
" />
</div>
<ul class="nav nav-tabs" id="calculationTab">
<li><a data-toggle="tab" href="#breakfast_lunch_dinner"><?php
echo JText::_('COM_SIBDIET_BREAKFAST_LUNCH_DINNER');
?>
</a></li>
<li><a data-toggle="tab" href="#morning_snack"><?php
示例8: foreach
foreach ($prescriptions as $key => $p) {
// Get Compositions
$query = $db->getQuery(true)->select('p.compositions')->from('#__sibdiet_prescriptions p')->where('p.id = ' . $p);
$db->setQuery($query);
$prescriptionCompositions = $db->loadResult();
// Count compositions that have ph or gi
$phCount = $giCount = 0;
if ($prescriptionCompositions) {
// convert Composition json to array
$registry = new JRegistry();
$registry->loadString($prescriptionCompositions);
$prescriptionCompositions = $registry->toArray();
$prescriptionsNutrients = array();
// Calculate nutrients
if (!empty($prescriptionCompositions)) {
$prescriptionsNutrients[] = SibdietHelper::nutrientsCalc($prescriptionCompositions, $phCount, $giCount);
}
}
}
$cold_nutrient = $params->get('cold_nutrient');
$warm_nutrient = $params->get('warm_nutrient');
$wet_nutrient = $params->get('wet_nutrient');
$dry_nutrient = $params->get('dry_nutrient');
$warmCount = $coldCount = $dryCount = $wetCount = 0;
// Sum nutrients of sub compositions
$nutrients = array();
foreach ($prescriptionsNutrients as $item) {
if ($cold_nutrient && array_key_exists($cold_nutrient, $item) && $item[$cold_nutrient]) {
$coldCount++;
}
if ($warm_nutrient && array_key_exists($warm_nutrient, $item) && $item[$warm_nutrient]) {