$ingress = get_post_meta($mypost->ID, "ingress", true); $content = $mypost->post_content; if ($lang != "FI") { $title = get_post_meta($mypost->ID, "title_" . strtolower($lang), true); $ingress = get_post_meta($mypost->ID, "ingress_" . strtolower($lang), true); $content = get_post_meta($mypost->ID, "content_" . strtolower($lang), true); } switch ($post_type) { case "program": $jsonItem = getJsonItemDetailsProgram($jsonItem, $mypost); break; case "agegroup": $jsonItem = getJsonItemDetailsAgegroup($jsonItem, $mypost, strtolower($lang)); break; case "taskgroup": $jsonItem = getJsonItemDetailsTaskgroup($jsonItem, $mypost, strtolower($lang)); $mandatory_tasks = getMandatoryTasksForTaskGroup($mypost->ID); $jsonItem->mandatory_task_hashes = implode(",", $mandatory_tasks->hashes); $subtask_term = getJsonTaskTerm(get_post_meta($mypost->ID, "taskgroup_subtask_term", true), strtolower($lang)); if (empty($subtask_term)) { foreach ($tree_array_orig as $tree_item) { $subtask_term = getJsonTaskTerm(get_post_meta($tree_item->ID, "taskgroup_subtask_term", true), strtolower($lang)); if ($subtask_term) { $jsonItem->subtask_term = $subtask_term; break; } } } else { $jsonItem->subtask_term = $subtask_term; } $subtaskgroup_term = getJsonSubtaskgroupTerm(get_post_meta($mypost->ID, "taskgroup_subtaskgroup_term", true), strtolower($lang));
function getJsonTaskGroupsForTaskGroup($parent_id) { global $mandatory_task_guids; $classTaskGroup = "POFTREE\\taskgroup"; $childs = array(); $args = array('numberposts' => -1, 'posts_per_page' => -1, 'post_type' => 'pof_post_taskgroup', 'orderby' => 'title', 'order' => 'ASC', 'meta_key' => 'suoritepaketti', 'meta_value' => $parent_id); $the_querysub = new WP_Query($args); if ($the_querysub->have_posts()) { while ($the_querysub->have_posts()) { $the_querysub->the_post(); // try to avoid infinite loops if ($the_querysub->post->ID == $parent_id) { continue; } $child = new $classTaskGroup(); $child = getJsonItemBaseDetails($child, $the_querysub->post); $child = getJsonItemDetailsTaskgroup($child, $the_querysub->post, 'fi'); $child->title = $the_querysub->post->post_title; $child->taskgroups = getJsonTaskGroupsForTaskGroup($the_querysub->post->ID, 'fi'); $mandatory_task_guids = array(); $child->tasks = getJsonTasks($the_querysub->post->ID); $child->mandatory_tasks = implode(",", $mandatory_task_guids); $mandatory_task_guids = array(); array_push($childs, $child); } } return $childs; }