예제 #1
0
function tab_content($portal_id, $topic_id, $sub_topic_1_id, $sub_topic_2_id, $sub_topic_3_id, $sub_topic_4_id, $category_id)
{
    global $db;
    echo "<div class=\"tab-content\">";
    if ($portal_id == 156) {
        // Index Home Page - No Portals - - List of PORTALS as Nav Tabs
        $query = "SELECT * FROM portals WHERE tabpanel=1";
        $result = $db->query($query);
        while ($data = $db->fetch_assoc($result)) {
            $tab_portal_id = $data['id'];
            $div_id = $data['portal'];
            $tab = $data['portal'];
            $output = "<div id=\"{$div_id}\" class=\"tab-pane fade in active\"><div class=\"panel-block\"><div class=\"row panel-summary\"><ul>";
            echo $output;
            $query2 = "SELECT * FROM portal_topic_status WHERE portal_id={$tab_portal_id} LIMIT 1";
            $result2 = $db->query($query2);
            $data2 = $db->fetch_assoc($result2);
            $topic_status_id = $data2['topic_status_id'];
            if ($topic_status_id == 0) {
                // List of Portal's Categories if relevant
                $tab_category_query = "SELECT * FROM category,portal_category_relationship WHERE portal_id={$tab_portal_id} AND portal_category_relationship.category_id=category.id";
                $tab_category_result = $db->query($tab_category_query);
                while ($portal_category_data = $db->fetch_assoc($tab_category_result)) {
                    $link_category_id = $portal_category_data['id'];
                    $category_title = $portal_category_data['category_title'];
                    $category_pic = $portal_category_data['category_pic'];
                    $output = "<div class=\"col-lg-2\"><a href=\"index.php?p={$tab_portal_id}&amp;c={$link_category_id}\"><img class=\"img-responsive\" src=\"assets/images/uploads/categories/tabbedpanel/{$category_pic}\" /></a></div>";
                    echo $output;
                }
                // end category while loop
            }
            // end topic status if
            $query = "SELECT * FROM topics WHERE portal_id={$tab_portal_id} AND navbar=1";
            $intro_topic_result = $db->query($query);
            while ($topic_data = $db->fetch_assoc($intro_topic_result)) {
                $link_topic_id = $topic_data['id'];
                $topic_title = $topic_data['topic'];
                $topic_pic = $topic_data['topic_pic'];
                $link_portal_id = $topic_data['portal_id'];
                $output = "<div class=\"col-lg-2\"><a href=\"index.php?p={$link_portal_id}&amp;t={$link_topic_id}\"><img class=\"img-responsive\" src=\"assets/images/homepage/tabbedpanel/{$div_id}/{$topic_pic}\" /></a></div>";
                echo $output;
            }
            // end topic while loop
            echo "<!-- end dynamically generated link list --></ul><!-- end .panel-summary--></div><br class=\"clearfloat\" /><!-- end .panel-block--></div><!-- end TAB #sectionA --></div>";
        }
        // end tab-panel-content for portal while loop
    } elseif ($portal_id != 156 && $topic_id == 156 && $category_id == 156 && $sub_topic_1_id == 156 && $sub_topic_2_id == 156 && $sub_topic_3_id == 156 && $sub_topic_4_id == 156) {
        // PORTAL Home Pages - List of TOPICS and CATEGORIES as Tab Content
        $portal = Portal::find_by_id($portal_id);
        $portal_title = $portal->portal;
        //CATEGORIES Tab Content
        $query = "SELECT * FROM category,portal_category_relationship WHERE portal_id={$portal_id} AND portal_category_relationship.category_id=category.id";
        $category_results = $db->query($query);
        while ($data = $db->fetch_assoc($category_results)) {
            $tab_category_id = $data['id'];
            $str = $data['category_title'];
            $div_id = preg_replace('/\\s+/', '', $str);
            $tab = $data['category_title'];
            $output = "<div id=\"{$div_id}\" class=\"tab-pane fade in active\">";
            $output .= "<div class=\"panel-block\">";
            $output .= "<div class=\"row panel-summary\">";
            $output .= "<ul class=\"list-inline\">";
            echo $output;
            // Display list of 4/5 most recent links for this category in this topic from links_tbl
            $cat_query = "SELECT * FROM links WHERE portal_id={$portal_id} AND category_id={$tab_category_id}";
            $category_result = $db->query($cat_query);
            while ($link = $db->fetch_assoc($category_result)) {
                $href = $link['link_href'];
                $text = htmlentities($link['link_text']);
                $link_pic = $link['link_pic'];
                $output = "<div class=\"col-sm-3 col-md-3\"><a class=\"thumbnail\" href=\"{$href}\" target=\"_blank\"><div class=\"top-link-pic\"><img class=\"img-responsive\" src=\"assets/images/uploads/linkpic/large/{$link_pic}\" /></div><div class=\"tn-link-text\"><p>{$text}</p></div></a></div>";
                echo $output;
            }
            // end while loop
            $output = "<!-- end dynamically generated link list --></ul>";
            $output .= "<!-- end .row panel-summary--></div>";
            $output .= "<br class=\"clearfloat\" />";
            $output .= "<!-- end .panel-block--></div>";
            $output .= "<!-- end TAB #{$div_id} --></div>";
            echo $output;
        }
        // end CATEGORIES while loop
        // TOPICS Tab Content - lIST OF Category and Sub Topic 1 Links header
        $query = "SELECT * FROM topics WHERE portal_id={$portal_id} AND tabpanel=1";
        $result = $db->query($query);
        while ($data = $db->fetch_assoc($result)) {
            $tab_topic_id = $data['id'];
            $div_id = $data['topic'];
            $tab = $data['topic'];
            $output = "<div id=\"{$div_id}\" class=\"tab-pane fade in active\">";
            //$output .= "<div class=\"row panel-block\">";
            //$output .= "<div class=\"col-md-12 panel-summary\">";
            $output .= "<div class=\"row\">";
            $output .= "<div class=\"col-md-12\">";
            $output .= "<ul class=\"list-inline tab-list\">";
            echo $output;
            //List of CATEGORIES for each TOPIC Tab
            $query = "SELECT * FROM category,category_topic_relationship WHERE topic_id={$tab_topic_id} AND category_topic_relationship.category_id=category.id";
            $category_results = $db->query($query);
            while ($data = $db->fetch_assoc($category_results)) {
                $link_category_id = $data['id'];
                $category_title = $data['category_title'];
                $output = "<li><a href=\"index.php?p={$portal_id}&amp;t={$tab_topic_id}&amp;c={$link_category_id}\">{$category_title}</a> |</li>";
                echo $output;
            }
            // end CATEGORIES in Topic while loop
            //List of SUB TOPIC 1s for each TOPIC Tab
            $query = "SELECT * FROM sub_topic_1 WHERE topic_id={$tab_topic_id}";
            $sub_topic_result = $db->query($query);
            while ($sub_topic_data = $db->fetch_assoc($sub_topic_result)) {
                $link_sub_topic_1_id = $sub_topic_data['id'];
                $sub_topic_1_title = $sub_topic_data['sub_topic_1'];
                $link_portal_id = $portal_id;
                $link_topic_id = $sub_topic_data['topic_id'];
                $output = "<li><a href=\"index.php?p={$link_portal_id}&amp;t={$link_topic_id}&amp;st1={$link_sub_topic_1_id}\">{$sub_topic_1_title}</a> |</li>";
                echo $output;
            }
            // end SUB TOPIC 1s in Topic while loop
            $output = "<!-- end dynamically generated link list --></ul>";
            $output .= "<!-- end .col-md-12 tab-list--></div>";
            $output .= "<!-- end .row --></div>";
            echo $output;
            //DISPLAY List of 4 top articles on TOPIC tab
            $output = "<div class=\"row panel-block\">";
            $output .= "<div class=\"col-md-12 panel-summary\">";
            echo $output;
            //Links Loop
            $tab_content_category_id = 1;
            //articles and news
            display_topic_links_in_category($portal_id, $tab_topic_id, $tab_content_category_id);
            $output = "<!-- end .col-md-12 panel-summary--></div>";
            $output .= "<br class=\"clearfloat\" />";
            $output .= "<!-- end .panel-block--></div>";
            $output .= "<!-- end TAB #{$div_id} --></div>";
            echo $output;
        }
        // end TOPICs while loop
    } elseif ($portal_id != 156 && $topic_id != 156 && $category_id == 156 && $sub_topic_1_id == 156 && $sub_topic_2_id == 156 && $sub_topic_3_id == 156 && $sub_topic_4_id == 156) {
        // Topic Home Pages - List of SUB-TOPIC-1S and/or CATEGORIES as Nav Tabs
        // SUB TOPIC 1'S
        $portal = Portal::find_by_id($portal_id);
        $portal_title = $portal->portal;
        $topic = Topic::find_by_id($topic_id);
        $topic_title = $topic->topic;
        $query = "SELECT * FROM sub_topic_1 WHERE topic_id={$topic_id}";
        $result = $db->query($query);
        while ($data = $db->fetch_assoc($result)) {
            $tab_topic_id = $data['id'];
            $str = $data['sub_topic_1'];
            $div_id = preg_replace('/\\s+/', '', $str);
            $tab = $data['sub_topic_1'];
            $output = "<div id=\"{$div_id}\" class=\"tab-pane fade in active\"><div class=\"panel-block\"><div class=\"row panel-summary\"><ul>";
            echo $output;
            $query = "SELECT * FROM sub_topic_2 WHERE sub_topic_1_id={$tab_topic_id}";
            $sub_topic_result = $db->query($query);
            while ($sub_topic_data = $db->fetch_assoc($sub_topic_result)) {
                $link_sub_topic_2_id = $sub_topic_data['id'];
                $sub_topic_2_title = $sub_topic_data['sub_topic_2'];
                $sub_topic_2_pic = $sub_topic_data['sub_topic_2_pic'];
                $link_portal_id = $portal_id;
                $link_sub_topic_1_id = $sub_topic_data['sub_topic_1_id'];
                $output = "<div class=\"col-sm-3\"><a class=\"thumbnail\" href=\"index.php?p={$portal_id}&t={$topic_id}&st1={$link_sub_topic_1_id}&st2={$link_sub_topic_2_id}\" target=\"_blank\"><img class=\"img-responsive\" src=\"assets/images/uploads/topicpic/{$sub_topic_2_pic}\" /><div class=\"tn-link-text\"><p>{$sub_topic_2_title}</p></div></a></div>";
                echo $output;
            }
            // end while loop
            echo "<!-- end dynamically generated link list --></ul><!-- end .panel-summary--></div><br class=\"clearfloat\" /><!-- end .panel-block--></div><!-- end TAB #sectionA --></div>";
        }
        // end while loop
        //CATEGORIES
        $query = "SELECT * FROM category,category_topic_relationship WHERE topic_id={$topic_id} AND category_topic_relationship.category_id=category.id";
        $category_results = $db->query($query);
        while ($data = $db->fetch_assoc($category_results)) {
            $tab_category_id = $data['id'];
            $str = $data['category_title'];
            $div_id = preg_replace('/\\s+/', '', $str);
            $tab = $data['category_title'];
            $output = "<div id=\"{$div_id}\" class=\"tab-pane fade in\"><div class=\"panel-block\"><div class=\"row panel-summary\"><ul>";
            echo $output;
            // Display list of 4/5 most recent links for this category in this topic from links_tbl
            $cat_query = "SELECT * FROM links WHERE portal_id={$portal_id} AND topic_id={$topic_id} AND category_id={$tab_category_id}";
            $category_result = $db->query($cat_query);
            while ($link = $db->fetch_assoc($category_result)) {
                $href = $link['link_href'];
                $text = htmlentities($link['link_text']);
                $link_pic = $link['link_pic'];
                $output = "<div class=\"col-sm-3 col-md-3\"><a class=\"thumbnail\" href=\"{$href}\" target=\"_blank\"><div class=\"top-link-pic\"><img class=\"img-responsive\" src=\"assets/images/uploads/linkpic/large/{$link_pic}\" /></div><div class=\"tn-link-text\"><p>{$text}</p></div></a></div>";
                echo $output;
            }
            // end while loop
            echo "<!-- end dynamically generated link list --></ul><!-- end .panel-summary--></div><br class=\"clearfloat\" /><!-- end .panel-block--></div><!-- end TAB #sectionA --></div>";
        }
        // end while loop
    } elseif ($portal_id != 156 && $topic_id != 156 && $category_id == 156 && $sub_topic_1_id != 156 && $sub_topic_2_id == 156 && $sub_topic_3_id == 156 && $sub_topic_4_id == 156) {
        // SUB TOPIC 1 Home Pages - List of SUB-TOPIC-2S and/or CATEGORIES as Nav Tabs
        // SUB TOPIC 2'S
        $portal = Portal::find_by_id($portal_id);
        $portal_title = $portal->portal;
        $topic = Topic::find_by_id($topic_id);
        $topic_title = $topic->topic;
        $query = "SELECT * FROM sub_topic_2 WHERE sub_topic_1_id={$sub_topic_1_id}";
        $result = $db->query($query);
        while ($data = $db->fetch_assoc($result)) {
            $tab_sub_topic_2_id = $data['id'];
            $str = $data['sub_topic_2'];
            $div_id = preg_replace('/\\s+/', '', $str);
            $tab = $data['sub_topic_2'];
            $output = "<div id=\"{$div_id}\" class=\"tab-pane fade in active\"><div class=\"panel-block\"><div class=\"row panel-summary\"><ul>";
            echo $output;
            $query = "SELECT * FROM sub_topic_3 WHERE sub_topic_2_id={$tab_sub_topic_2_id}";
            $sub_topic_result = $db->query($query);
            while ($sub_topic_data = $db->fetch_assoc($sub_topic_result)) {
                $link_sub_topic_3_id = $sub_topic_data['id'];
                $sub_topic_3_title = $sub_topic_data['sub_topic_2'];
                $sub_topic_3_pic = $sub_topic_data['sub_topic_2_pic'];
                $link_portal_id = $portal_id;
                $link_sub_topic_2_id = $sub_topic_data['sub_topic_2_id'];
                $output = "<div class=\"col-sm-3\"><a class=\"thumbnail\" href=\"index.php?p={$portal_id}&t={$topic_id}&st1={$link_sub_topic_1_id}&st2={$link_sub_topic_2_id}\" target=\"_blank\"><img class=\"img-responsive\" src=\"assets/images/uploads/topicpic/{$sub_topic_2_pic}\" /><div class=\"tn-link-text\"><p>{$sub_topic_2_title}</p></div></a></div>";
                echo $output;
            }
            // end while loop
            echo "<!-- end dynamically generated link list --></ul><!-- end .panel-summary--></div><br class=\"clearfloat\" /><!-- end .panel-block--></div><!-- end TAB #sectionA --></div>";
        }
        // end while loop
        //CATEGORIES
        $query = "SELECT * FROM category,category_sub_topic_1_relationship WHERE sub_topic_1_id={$sub_topic_1_id} AND category_sub_topic_1_relationship.category_id=category.id";
        $category_results = $db->query($query);
        while ($data = $db->fetch_assoc($category_results)) {
            $tab_category_id = $data['id'];
            $str = $data['category_title'];
            $div_id = preg_replace('/\\s+/', '', $str);
            $tab = $data['category_title'];
            $output = "<div id=\"{$div_id}\" class=\"tab-pane fade in\"><div class=\"panel-block\"><div class=\"row panel-summary\"><ul>";
            echo $output;
            // Display list of 4/5 most recent links for this category in this topic from links_tbl
            $cat_query = "SELECT * FROM links WHERE portal_id={$portal_id} AND topic_id={$topic_id} AND sub_topic_1_id={$sub_topic_1_id} AND category_id={$tab_category_id}";
            $category_result = $db->query($cat_query);
            while ($link = $db->fetch_assoc($category_result)) {
                $href = $link['link_href'];
                $text = htmlentities($link['link_text']);
                $link_pic = $link['link_pic'];
                $output = "<div class=\"col-sm-3 col-md-3\"><a class=\"thumbnail\" href=\"{$href}\" target=\"_blank\"><div class=\"top-link-pic\"><img class=\"img-responsive\" src=\"assets/images/uploads/linkpic/large/{$link_pic}\" /></div><div class=\"tn-link-text\"><p>{$text}</p></div></a></div>";
                echo $output;
            }
            // end while loop
            echo "<!-- end dynamically generated link list --></ul><!-- end .panel-summary--></div><br class=\"clearfloat\" /><!-- end .panel-block--></div><!-- end TAB #sectionA --></div>";
        }
        // end while loop
    } elseif ($portal_id != 156 && $topic_id != 156 && $category_id == 156 && $sub_topic_1_id != 156 && $sub_topic_2_id != 156 && $sub_topic_3_id == 156 && $sub_topic_4_id == 156) {
        // SUB TOPIC 2 Home Pages - List of SUB-TOPIC-2S and/or CATEGORIES as Nav Tabs
        // SUB TOPIC 3'S
        /* $portal = Portal::find_by_id($portal_id);
           $portal_title = $portal->portal;
           
           $topic = Topic::find_by_id($topic_id);
           $topic_title = $topic->topic;
           
           $query = "SELECT * FROM sub_topic_2 WHERE sub_topic_1_id={$sub_topic_1_id}";
               $result = $db->query($query);
               while($data = $db->fetch_assoc($result)){
                   $tab_sub_topic_2_id = $data['id'];
                   $str = $data['sub_topic_2'];
                   $div_id = preg_replace('/\s+/', '', $str);
                   $tab = $data['sub_topic_2'];
                   $output = "<div id=\"{$div_id}\" class=\"tab-pane fade in active\"><div class=\"panel-block\"><div class=\"row panel-summary\"><ul>";
                   echo $output;
                   
                       $query = "SELECT * FROM sub_topic_3 WHERE sub_topic_2_id={$tab_sub_topic_2_id}";
                       $sub_topic_result = $db->query($query);
                           while($sub_topic_data = $db->fetch_assoc($sub_topic_result)){
                               $link_sub_topic_3_id = $sub_topic_data['id'];
                               $sub_topic_3_title = $sub_topic_data['sub_topic_2'];
                               $sub_topic_3_pic = $sub_topic_data['sub_topic_2_pic'];
                               $link_portal_id = $portal_id;
                               $link_sub_topic_2_id = $sub_topic_data['sub_topic_2_id'];
                               $output = "<div class=\"col-sm-3\"><a class=\"thumbnail\" href=\"index.php?p={$portal_id}&t={$topic_id}&st1={$link_sub_topic_1_id}&st2={$link_sub_topic_2_id}\" target=\"_blank\"><img class=\"img-responsive\" src=\"assets/images/uploads/topicpic/{$sub_topic_2_pic}\" /><div class=\"tn-link-text\"><p>{$sub_topic_2_title}</p></div></a></div>";
                               echo $output;
                           } // end while loop
               echo "<!-- end dynamically generated link list --></ul><!-- end .panel-summary--></div><br class=\"clearfloat\" /><!-- end .panel-block--></div><!-- end TAB #sectionA --></div>";                  
               } // end while loop*/
        //CATEGORIES
        $query = "SELECT * FROM category,category_sub_topic_2_relationship WHERE sub_topic_2_id={$sub_topic_2_id} AND category_sub_topic_2_relationship.category_id=category.id";
        $category_results = $db->query($query);
        while ($data = $db->fetch_assoc($category_results)) {
            $tab_category_id = $data['id'];
            $str = $data['category_title'];
            $div_id = preg_replace('/\\s+/', '', $str);
            $tab = $data['category_title'];
            $output = "<div id=\"{$div_id}\" class=\"tab-pane fade in\"><div class=\"panel-block\"><div class=\"row panel-summary\"><ul>";
            echo $output;
            // Display list of 4/5 most recent links for this category in this topic from links_tbl
            $cat_query = "SELECT * FROM links WHERE portal_id={$portal_id} AND topic_id={$topic_id} AND sub_topic_1_id={$sub_topic_1_id} AND sub_topic_2_id={$sub_topic_2_id} AND category_id={$tab_category_id}";
            $category_result = $db->query($cat_query);
            while ($link = $db->fetch_assoc($category_result)) {
                $href = $link['link_href'];
                $text = htmlentities($link['link_text']);
                $link_pic = $link['link_pic'];
                $output = "<div class=\"col-sm-3 col-md-3\"><a class=\"thumbnail\" href=\"{$href}\" target=\"_blank\"><div class=\"top-link-pic\"><img class=\"img-responsive\" src=\"assets/images/uploads/linkpic/large/{$link_pic}\" /></div><div class=\"tn-link-text\"><p>{$text}</p></div></a></div>";
                echo $output;
            }
            // end while loop
            echo "<!-- end dynamically generated link list --></ul><!-- end .panel-summary--></div><br class=\"clearfloat\" /><!-- end .panel-block--></div><!-- end TAB #sectionA --></div>";
        }
        // end while loop
    } else {
        echo "work in progress";
    }
    // end if
    $output = "<br class=\"clearfloat\" />";
    $output .= "<!-- end .tab-content--></div>";
    echo $output;
}
예제 #2
0
 /**
  * Добавление в закладки
  */
 public function bookmark()
 {
     if (!Request::ajax()) {
         App::redirect('/');
     }
     $token = Request::input('token', true);
     $topic_id = Request::input('id');
     if (User::check() && $token == $_SESSION['token']) {
         /* Проверка темы на существование */
         if ($topic = Topic::find_by_id($topic_id)) {
             /* Добавление темы в закладки */
             if ($bookmark = Bookmark::find_by_topic_id_and_user_id($topic_id, User::get('id'))) {
                 if ($bookmark->delete()) {
                     exit(json_encode(['status' => 'deleted']));
                 }
             } else {
                 $bookmark = new Bookmark();
                 $bookmark->topic_id = $topic->id;
                 $bookmark->user_id = User::get('id');
                 $bookmark->posts = $topic->postCount();
                 if ($bookmark->save()) {
                     exit(json_encode(['status' => 'added']));
                 }
             }
         }
     }
     exit(json_encode(['status' => 'error']));
 }