0){ array_unshift($sections, $children); } } if($section['parent_id'] == -1 || $section == '' ){ Renderosity\Facades\DB::execute("SELECT * FROM tutorial_section WHERE parent_id = -1 ORDER BY priority, name;", FALSE); $categories = Renderosity\Facades\DB::getResults(); array_unshift($sections, $categories); return false; } return recursion_section($section['parent_id'], 0); } /////////////////////////////////////////////////// //RETURN PARENT SECTIONS /////////////////////////////////////////////////// function get_parent_sections( $parent_id = -1 ){ global $db; Renderosity\Facades\DB::execute("SELECT * FROM tutorial_section WHERE parent_id = ".$parent_id." ORDER BY priority, name", FALSE); $parent_sections = Renderosity\Facades\DB::getResults(); return $parent_sections; } /////////////////////////////////////////////////// //AJAX SECTION LOAD /////////////////////////////////////////////////// if(isset($_POST['get_sections'])){ $cats = get_parent_sections($_POST['section_id']); exit(json_encode(array( 'success' => true, 'data' => array("sections" => $cats) ))); } /////////////////////////////////////////////////// //DISPLAY CATEGORIES /////////////////////////////////////////////////// function display_categories($parent_id=-1){ global $db; Renderosity\Facades\DB::execute("SELECT * FROM tutorial_section WHERE parent_id = ".$parent_id." ORDER BY priority, name;"); if(Renderosity\Facades\DB::rowCount() > 0){ echo ''; }elseif($parent_id == -1){ echo 'There are no categories yet.'; } } /////////////////////////////////////////////////// //DISPLAY CATEGORIES FOR SELECT /////////////////////////////////////////////////// function display_categories_select($parent_id=-1, $depth=0){ global $db; Renderosity\Facades\DB::execute("SELECT * FROM tutorial_section WHERE parent_id = ".$parent_id." AND section_id <> ".$_GET['delete']." ORDER BY priority, name;"); if(Renderosity\Facades\DB::rowCount() > 0){ foreach(Renderosity\Facades\DB::getResults() as $row){ echo ''; echo display_categories_select($row['section_id'], $depth + 1); } } } ?>get('per_page') == '' || $tutorial->get('per_page') < 10 ? 25 : $tutorial->get('per_page'); Renderosity\Facades\Pager::records_per_page($per_page); if(!isset($_GET['search'])){ $QueryString = (isset($_GET['section_id']) && is_numeric($_GET['section_id']) ? "section_id=".intval($_GET['section_id']) : "" ); }else{ $QueryString = "search=".$_GET['search'].( isset($_GET['expression']) ? "&expression=".$_GET['expression'] : "" ); } if(isset($_GET['pending'])){ require_once root_dir().'secure.php'; if(!$tapp->in_roles($tutorial->get('approve_permission'))){ bw_go('index.php?browse&whatsnew'); } Renderosity\Facades\DB::execute("SELECT count(*) as total FROM tutorial_tutorial WHERE status = 'pending'"); Renderosity\Facades\Pager::records(Renderosity\Facades\DB::getAtIndex(0,'total')); Renderosity\Facades\DB::execute("SELECT * FROM tutorial_tutorial WHERE status = 'pending' ".order_controls()." limit ".Renderosity\Facades\Pager::get_offset().", ".Renderosity\Facades\Pager::get_records_per_page()); $results = Renderosity\Facades\DB::getResults(); }elseif(isset($_GET['archives'])){ require_once root_dir().'secure.php'; if(!$tapp->in_roles($tutorial->get('approve_permission'))){ bw_go('index.php?browse&whatsnew'); } $start_date = $_GET['year'].'-'.$_GET['month'].'-01 00:00:00'; $end_date = $_GET['year'].'-'.$_GET['month'].'-'.date('t', strtotime($start_date)).' 23:59:59'; Renderosity\Facades\DB::execute("SELECT count(*) as total FROM tutorial_tutorial WHERE status = 'active' AND date_create >= '".$start_date."' AND date_create <= '".$end_date."'"); Renderosity\Facades\Pager::records(Renderosity\Facades\DB::getAtIndex(0,'total')); Renderosity\Facades\DB::execute("SELECT * FROM tutorial_tutorial WHERE status = 'active' AND date_create >= '".$start_date."' AND date_create <= '".$end_date."' ORDER BY date_create limit ".Renderosity\Facades\Pager::get_offset().", ".Renderosity\Facades\Pager::get_records_per_page()); $results = Renderosity\Facades\DB::getResults(); }elseif(is_numeric($_GET['section_id'])){ Renderosity\Facades\DB::execute("SELECT * FROM tutorial_section WHERE section_id = ".intval($_GET['section_id']), FALSE); if(Renderosity\Facades\DB::rowCount() == 0){ bw_go(bw_href_prefix().'/mod/tutorial/'); } $section = Renderosity\Facades\DB::getAtIndex(0); $CHILDREN = $section['children'] == '' ? FALSE : explode('.', $section['children']); Renderosity\Facades\DB::execute("SELECT count(*) as total FROM tutorial_tutorial WHERE status='active' AND section_id IN (".intval($section['section_id']).(!is_array($CHILDREN) || sizeof($CHILDREN) == 0 ? "" : ", ".implode(", ", $CHILDREN)).")", FALSE); Renderosity\Facades\Pager::records(Renderosity\Facades\DB::getAtIndex(0,'total')); Renderosity\Facades\DB::execute("SELECT * FROM tutorial_tutorial WHERE status='active' AND section_id IN (".intval($section['section_id']).(!is_array($CHILDREN) || sizeof($CHILDREN) == 0 ? "" : ", ".implode(", ", $CHILDREN)).") ".order_controls()." limit ".Renderosity\Facades\Pager::get_offset().", ".Renderosity\Facades\Pager::get_records_per_page()); $results = Renderosity\Facades\DB::getResults(); }elseif(isset($_GET['under_review'])){ require_once root_dir().'secure.php'; if(!$tapp->in_roles($tutorial->get('approve_permission'))){ bw_go('index.php?browse&whatsnew'); } Renderosity\Facades\DB::execute("SELECT count(*) as total FROM tutorial_tutorial WHERE status = 'deleted'"); Renderosity\Facades\Pager::records(Renderosity\Facades\DB::getAtIndex(0,'total')); Renderosity\Facades\DB::execute("SELECT * FROM tutorial_tutorial WHERE status = 'deleted' ".order_controls()." limit ".Renderosity\Facades\Pager::get_offset().", ".Renderosity\Facades\Pager::get_records_per_page()); $results = Renderosity\Facades\DB::getResults(); }elseif(isset($_GET['most_viewed'])){ Renderosity\Facades\DB::execute("SELECT count(*) as total FROM tutorial_tutorial WHERE status = 'active' AND last_view > DATE_SUB(now(), INTERVAL 45 DAY)"); Renderosity\Facades\Pager::records(Renderosity\Facades\DB::getAtIndex(0,'total')); Renderosity\Facades\DB::execute("SELECT * FROM tutorial_tutorial WHERE status = 'active' AND last_view > DATE_SUB(now(), INTERVAL 45 DAY) ORDER BY view_cnt DESC, last_view ASC limit ".Renderosity\Facades\Pager::get_offset().", ".Renderosity\Facades\Pager::get_records_per_page()); $results = Renderosity\Facades\DB::getResults(); }elseif(isset($_GET['skill_level']) && $_GET['skill_level'] != ''){ Renderosity\Facades\DB::execute("SELECT count(*) as total FROM tutorial_tutorial WHERE skill_level = '".$_GET['skill_level']."' AND status='active'"); Renderosity\Facades\Pager::records(Renderosity\Facades\DB::getAtIndex(0,'total')); Renderosity\Facades\DB::execute("SELECT * FROM tutorial_tutorial WHERE skill_level = '".$_GET['skill_level']."' AND status='active' ".order_controls()." limit ".Renderosity\Facades\Pager::get_offset().", ".Renderosity\Facades\Pager::get_records_per_page()); $results = Renderosity\Facades\DB::getResults(); }elseif(is_numeric($_GET['user_id'])){ Renderosity\Facades\DB::execute("SELECT username FROM bwcore_member WHERE userid = ".intval($_GET['user_id']).";"); if(Renderosity\Facades\DB::rowCount() == 0){ bw_go(bw_href_prefix().'mod/tutorials/'); } if(intval($_SESSION['UserId']) == intval($_GET['user_id'])){ Renderosity\Facades\DB::execute("SELECT count(*) as total FROM tutorial_tutorial WHERE user_id = ".intval($_GET['user_id'])." AND status <> 'deleted'"); Renderosity\Facades\Pager::records(Renderosity\Facades\DB::getAtIndex(0,'total')); Renderosity\Facades\DB::execute("SELECT * FROM tutorial_tutorial WHERE user_id = ".intval($_GET['user_id'])." AND status <> 'deleted' ".order_controls()." limit ".Renderosity\Facades\Pager::get_offset().", ".Renderosity\Facades\Pager::get_records_per_page()); }else{ Renderosity\Facades\DB::execute("SELECT count(*) as total FROM tutorial_tutorial WHERE user_id = ".intval($_GET['user_id'])." AND status='active'"); Renderosity\Facades\Pager::records(Renderosity\Facades\DB::getAtIndex(0,'total')); Renderosity\Facades\DB::execute("SELECT * FROM tutorial_tutorial WHERE user_id = ".intval($_GET['user_id'])." AND status='active' ".order_controls()." limit ".Renderosity\Facades\Pager::get_offset().", ".Renderosity\Facades\Pager::get_records_per_page()); } $results = Renderosity\Facades\DB::getResults(); }elseif(isset($_GET['search'])){ if($_GET['search'] != ''){ /* Weighted Search */ if($_GET['expression'] == 'artist_name'){ $options = array( "username" => 5.35, "name" => 4.22, "description" => 1.98 ); } elseif($_GET['expression'] == 'software_dependencies'){ $options = array( "software_requirements" => 6.49, "username" => 2.22, "description" => 1.83 ); } else{ $options = array( "name" => 6.12, "software_requirements" => 4.46, "username" => 1.4, "description" => 3.08 ); } $query = Renderosity\Facades\CS::buildQuery( array( "size" => Renderosity\Facades\Pager::get_records_per_page(), "start" => Renderosity\Facades\Pager::get_offset(), "options" => $options, "sort" => order_controls() )); $resultsObj = Renderosity\Facades\CS::domain("tutorial")->search($query); if($resultsObj){ Renderosity\Facades\Pager::records($resultsObj->hits->found); if($resultsObj->hits->found > 0){ $hits = $resultsObj->hits->hit; foreach ($hits as $key => $value){ $hits[$key]= substr($value->id, 3); } Renderosity\Facades\DB::execute("SELECT * FROM tutorial_tutorial WHERE tutorial_id in (".implode(",", $hits).") order by FIELD(tutorial_id, ".implode(",", $hits).")"); $results = Renderosity\Facades\DB::getResults(); } } }else{ bw_go(bw_href_prefix().'/mod/tutorial/'); } }else{ Renderosity\Facades\DB::execute("SELECT count(*) as total FROM tutorial_tutorial WHERE status='active'", FALSE); Renderosity\Facades\Pager::records(Renderosity\Facades\DB::getAtIndex(0,'total')); Renderosity\Facades\DB::execute("SELECT * FROM tutorial_tutorial WHERE status='active' ".order_controls()." limit ".Renderosity\Facades\Pager::get_offset().", ".Renderosity\Facades\Pager::get_records_per_page()); $results = Renderosity\Facades\DB::getResults(); } ?> Tutorials | Renderosity Renderosity - 3D Models, 3D Content, 3D Software, and 3D Art