当前位置: 首页>>代码示例>>PHP>>正文


PHP Topic::find_by_id方法代码示例

本文整理汇总了PHP中Topic::find_by_id方法的典型用法代码示例。如果您正苦于以下问题:PHP Topic::find_by_id方法的具体用法?PHP Topic::find_by_id怎么用?PHP Topic::find_by_id使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Topic的用法示例。


在下文中一共展示了Topic::find_by_id方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: tab_content

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)) {
//.........这里部分代码省略.........
开发者ID:kamalrazalatif,项目名称:razaweb,代码行数:101,代码来源:display_functions.php

示例2: bookmark

 /**
  * Добавление в закладки
  */
 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']));
 }
开发者ID:visavi,项目名称:rotorcms,代码行数:31,代码来源:ForumController.php


注:本文中的Topic::find_by_id方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。