translator->addDomain("fitness", 'i18n'); $TeKe->translator->useDomain("fitness"); //$TeKe->template->setTemplateRepository(dirname(__FILE__).'/views/templates'); //$TeKe->template->setTemplateRepository(dirname(__FILE__).'/views/macros'); $TeKe->template->setTemplateRepository(dirname(__FILE__).'/views/trainings'); $TeKe->template->setTemplateRepository(dirname(__FILE__).'/views/trainingplans'); $TeKe->template->setTemplateRepository(dirname(__FILE__).'/views/traininggoals'); if (count($page)>0) { $this->loadContext($page); } } function setNavigation($teke) { $teke->navigation['home'] = array('title'=>_('Home'), 'url'=>"", 'current'=>$teke->handler==NULL, 'level'=>0); $teke->navigation['training_calendar'] = array('title'=>_('Training calendar'), 'url'=>"trainings/view", 'current'=>$teke->is_current_main('trainings'), 'level'=>0); $teke->navigation['training_plans'] = array('title'=>_('Training plans'), 'url'=>"trainingplans/view", 'current'=>$teke->is_current_main('trainingplans'), 'level'=>0); $teke->navigation['training_goals'] = array('title'=>_('Goals'), 'url'=>"traininggoals/view", 'current'=>$teke->is_current_main('traininggoals'), 'level'=>0); } function loadType($type, $id = false) { /*if (!$type && is_numeric($id) && $id > 0) { $type_q = query_row("SELECT type FROM " . DB_PREFIX . "base_object WHERE id=".$id); $type = $type_q->type; }*/ if ($type) { if (is_file(dirname(__FILE__)."/objects/".$type.".php")) { require_once(dirname(__FILE__)."/objects/".$type.".php"); $classname = ucfirst($type); return new $classname($id); } } return false; } function deleteType($type, $id) { if (!$type && is_numeric($id) && $id > 0) { $type_q = query_row("SELECT type FROM " . DB_PREFIX . "base_object WHERE id=".$id); $type = $type_q->type; } if ($type) { if (is_file(dirname(__FILE__)."/objects/".$type.".php")) { require_once(dirname(__FILE__)."/objects/".$type.".php"); $obj = new $type($id); return $obj->delete(); } } return false; } function loadContext($page) { if (count($page)>=2 && is_numeric($page[1])) { $this->context = $this->loadType($page[0], $page[1]); } else if (count($page)>1) { $this->context = $this->loadType($page[0], false); } } function getLatestUserTrainings() { $limit = 10; $user_id = get_logged_in_user()->getId(); $res = query_rows("SELECT * FROM ". DB_PREFIX . "user_trainings WHERE creator=". $user_id ." AND training_date<=NOW() ORDER BY training_date DESC LIMIT ". $limit); return $res; } function getAllUserTrainings() { $user_id = get_logged_in_user()->getId(); $res = query_rows("SELECT * FROM ". DB_PREFIX . "user_trainings WHERE creator=". $user_id ." ORDER BY training_date DESC"); return $res; } function getUserTrainingPlans() { $user_id = get_logged_in_user()->getId(); $res = query_rows("SELECT * FROM ". DB_PREFIX . "training_plans WHERE creator=". $user_id ." AND type!='mf' ORDER BY created DESC"); return $res; } function getMuscleAndFitnessTrainingPlans() { global $TeKe; $user_id = get_logged_in_user()->getId(); $query = "SELECT * FROM ". DB_PREFIX . "training_plans WHERE type='mf'"; if (!$TeKe->is_admin()) { $query .= " AND status='final' AND security='public'"; } $query .= " ORDER BY created DESC"; $res = query_rows($query); return $res; } function getUserActiveTrainingplans() { $user = get_logged_in_user()->getId(); $query = "SELECT * FROM ". DB_PREFIX . "activated_training_plans WHERE CURDATE() >= beginning AND CURDATE() <= ending AND creator=" . $user . " ORDER BY beginning"; $active_trainingplans = query_rows($query); return $active_trainingplans; } function getMuscleGroups() { $muscle_groups = array( 1 => array("name"=>"Calves"), 2 => array("name"=>"Thighs"), 3 => array("name"=>"Buttocks"), 4 => array("name"=>"Back"), 5 => array("name"=>"Abs"), 6 => array("name"=>"Chest"), 7 => array("name"=>"Shoulders"), 8 => array("name"=>"Biceps"), 9 => array("name"=>"Triceps"), ); return $muscle_groups; } function getBodyParts() { $body_parts = array( 1 => array("name"=>"weight", "unit"=>"kg"), 2 => array("name"=>"neck", "unit"=>"cm"), 3 => array("name"=>"shoulders", "unit"=>"cm"), 4 => array("name"=>"bust", "unit"=>"cm"), 5 => array("name"=>"waist", "unit"=>"cm"), 6 => array("name"=>"biceps", "unit"=>"cm"), 7 => array("name"=>"wrist", "unit"=>"cm"), 8 => array("name"=>"hips/buttocks", "unit"=>"cm"), 9 => array("name"=>"thighs", "unit"=>"cm"), 10 => array("name"=>"calves", "unit"=>"cm"), 11 => array("name"=>"body fat %", "unit"=>"%"), ); return $body_parts; } function formatDate($date, $format="d.m.Y") { $time = strtotime($date); return date($format, $time); } function getUserTrainingGoals() { $user_id = get_logged_in_user()->getId(); $res = query_rows("SELECT * FROM ". DB_PREFIX . "training_goals WHERE creator=". $user_id ." ORDER BY created DESC"); return $res; } } ?>