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


PHP CategoryModel::instance方法代码示例

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


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

示例1: instance

 /**
  * The shared instance of this object.
  *
  * @return CategoryModel Returns the instance.
  */
 public static function instance()
 {
     if (self::$instance === null) {
         self::$instance = new CategoryModel();
     }
     return self::$instance;
 }
开发者ID:R-J,项目名称:vanilla,代码行数:12,代码来源:class.categorymodel.php

示例2: isWelcomePostActive

 /**
  * Check whether all condition are met for this plugin to do its magic.
  *
  * @param Gdn_Request $request
  * @param int|bool $categoryID Category ID of the welcome category if it exists and this function return true
  * @return bool
  */
 protected function isWelcomePostActive($request, &$categoryID)
 {
     static $cachedCategoryID = null;
     if ($cachedCategoryID === null) {
         $isWelcomePost = true;
         if ($request->get('welcomepost', false) !== "true") {
             $cachedCategoryID = false;
             return false;
         }
         if (!Gdn::session()->isValid()) {
             $cachedCategoryID = false;
             return false;
         }
         $category = (array) CategoryModel::instance()->getByCode('welcome');
         $cachedCategoryID = val('CategoryID', $category, false);
         if (!$cachedCategoryID) {
             return false;
         }
         $categoryID = $cachedCategoryID;
     } else {
         $isWelcomePost = (bool) $cachedCategoryID;
         $categoryID = $cachedCategoryID;
     }
     return $isWelcomePost;
 }
开发者ID:vanilla,项目名称:addons,代码行数:32,代码来源:class.welcomepost.plugin.php

示例3: array

if ($SQL->getWhere('Category', array('CategoryID' => -1))->numRows() == 0) {
    $SQL->insert('Category', ['CategoryID' => -1, 'TreeLeft' => 1, 'TreeRight' => 4, 'InsertUserID' => 1, 'UpdateUserID' => 1, 'DateInserted' => Gdn_Format::toDateTime(), 'DateUpdated' => Gdn_Format::toDateTime(), 'Name' => 'Root', 'UrlCode' => '', 'Description' => 'Root of category tree. Users should never see this.', 'PermissionCategoryID' => -1, 'DisplayAs' => 'Categories']);
    $RootCategoryInserted = true;
}
if ($Drop || !$CategoryExists) {
    $SQL->insert('Category', array('ParentCategoryID' => -1, 'TreeLeft' => 2, 'TreeRight' => 3, 'Depth' => 1, 'InsertUserID' => 1, 'UpdateUserID' => 1, 'DateInserted' => Gdn_Format::toDateTime(), 'DateUpdated' => Gdn_Format::toDateTime(), 'Name' => 'General', 'UrlCode' => 'general', 'Description' => 'General discussions', 'PermissionCategoryID' => -1));
} elseif ($CategoryExists && !$PermissionCategoryIDExists) {
    if (!c('Garden.Permissions.Disabled.Category')) {
        // Existing installations need to be set up with per/category permissions.
        $SQL->update('Category')->set('PermissionCategoryID', 'CategoryID', false)->put();
        $SQL->update('Permission')->set('JunctionColumn', 'PermissionCategoryID')->where('JunctionColumn', 'CategoryID')->put();
    }
}
if ($CategoryExists) {
    CategoryModel::instance()->rebuildTree();
    CategoryModel::instance()->recalculateTree();
    unset($CategoryModel);
}
// Construct the discussion table.
$Construct->table('Discussion');
$DiscussionExists = $Construct->TableExists();
$FirstCommentIDExists = $Construct->columnExists('FirstCommentID');
$BodyExists = $Construct->columnExists('Body');
$LastCommentIDExists = $Construct->columnExists('LastCommentID');
$LastCommentUserIDExists = $Construct->columnExists('LastCommentUserID');
$CountBookmarksExists = $Construct->columnExists('CountBookmarks');
$Construct->PrimaryKey('DiscussionID')->column('Type', 'varchar(10)', true, 'index')->column('ForeignID', 'varchar(32)', true, 'index')->column('CategoryID', 'int', false, array('index.CategoryPages', 'index.CategoryInserted'))->column('InsertUserID', 'int', false, 'key')->column('UpdateUserID', 'int', true)->column('FirstCommentID', 'int', true)->column('LastCommentID', 'int', true)->column('Name', 'varchar(100)', false, 'fulltext')->column('Body', 'text', false, 'fulltext')->column('Format', 'varchar(20)', true)->column('Tags', 'text', null)->column('CountComments', 'int', '0')->column('CountBookmarks', 'int', null)->column('CountViews', 'int', '1')->column('Closed', 'tinyint(1)', '0')->column('Announce', 'tinyint(1)', '0')->column('Sink', 'tinyint(1)', '0')->column('DateInserted', 'datetime', false, array('index', 'index.CategoryInserted'))->column('DateUpdated', 'datetime', true)->column('InsertIPAddress', 'ipaddress', true)->column('UpdateIPAddress', 'ipaddress', true)->column('DateLastComment', 'datetime', null, array('index', 'index.CategoryPages'))->column('LastCommentUserID', 'int', true)->column('Score', 'float', null)->column('Attributes', 'text', true)->column('RegardingID', 'int(11)', true, 'index');
//->column('Source', 'varchar(20)', true)
if (c('Vanilla.QueueNotifications')) {
    $Construct->column('Notified', 'tinyint', ActivityModel::SENT_ARCHIVE);
}
开发者ID:vanilla,项目名称:vanilla,代码行数:31,代码来源:structure.php

示例4: filenameRedirect

 /**
  *
  *
  * @param $Filename
  * @param $Get
  * @return bool|string
  */
 public function filenameRedirect($Filename, $Get)
 {
     trace(['Filename' => $Filename, 'Get' => $Get], 'Testing');
     $Filename = strtolower($Filename);
     array_change_key_case($Get);
     if (!isset(self::$Files[$Filename])) {
         return false;
     }
     $Row = self::$Files[$Filename];
     if (is_callable($Row)) {
         // Use a callback to determine the translation.
         $Row = call_user_func_array($Row, [&$Get]);
     }
     trace($Get, 'New Get');
     // Translate all of the get parameters into new parameters.
     $Vars = array();
     foreach ($Get as $Key => $Value) {
         if (!isset($Row[$Key])) {
             continue;
         }
         $Opts = (array) $Row[$Key];
         if (isset($Opts['Filter'])) {
             // Call the filter function to change the value.
             $R = call_user_func($Opts['Filter'], $Value, $Opts[0]);
             if (is_array($R)) {
                 if (isset($R[0])) {
                     // The filter can change the column name too.
                     $Opts[0] = $R[0];
                     $Value = $R[1];
                 } else {
                     // The filter can return return other variables too.
                     $Vars = array_merge($Vars, $R);
                     $Value = null;
                 }
             } else {
                 $Value = $R;
             }
         }
         if ($Value !== null) {
             $Vars[$Opts[0]] = $Value;
         }
     }
     trace($Vars, 'Translated Arguments');
     // Now let's see what kind of record we have.
     // We'll check the various primary keys in order of importance.
     $Result = false;
     if (isset($Vars['CommentID'])) {
         trace("Looking up comment {$Vars['CommentID']}.");
         $CommentModel = new CommentModel();
         // If a legacy slug is provided (assigned during a merge), attempt to lookup the comment using it
         if (isset($Get['legacy']) && Gdn::Structure()->Table('Comment')->ColumnExists('ForeignID')) {
             $Comment = $CommentModel->GetWhere(['ForeignID' => $Get['legacy'] . '-' . $Vars['CommentID']])->FirstRow();
         } else {
             $Comment = $CommentModel->GetID($Vars['CommentID']);
         }
         if ($Comment) {
             $Result = CommentUrl($Comment, '//');
         }
     } elseif (isset($Vars['DiscussionID'])) {
         trace("Looking up discussion {$Vars['DiscussionID']}.");
         $DiscussionModel = new DiscussionModel();
         $DiscussionID = $Vars['DiscussionID'];
         $Discussion = false;
         if (is_numeric($DiscussionID)) {
             // If a legacy slug is provided (assigned during a merge), attempt to lookup the discussion using it
             if (isset($Get['legacy']) && Gdn::Structure()->Table('Discussion')->ColumnExists('ForeignID')) {
                 $Discussion = $DiscussionModel->GetWhere(['ForeignID' => $Get['legacy'] . '-' . $DiscussionID])->FirstRow();
             } else {
                 $Discussion = $DiscussionModel->GetID($Vars['DiscussionID']);
             }
         } else {
             // This is a slug style discussion ID. Let's see if there is a UrlCode column in the discussion table.
             $DiscussionModel->DefineSchema();
             if ($DiscussionModel->Schema->FieldExists('Discussion', 'UrlCode')) {
                 $Discussion = $DiscussionModel->GetWhere(['UrlCode' => $DiscussionID])->FirstRow();
             }
         }
         if ($Discussion) {
             $Result = DiscussionUrl($Discussion, self::pageNumber($Vars, 'Vanilla.Comments.PerPage'), '//');
         }
     } elseif (isset($Vars['UserID'])) {
         trace("Looking up user {$Vars['UserID']}.");
         $User = Gdn::UserModel()->GetID($Vars['UserID']);
         if ($User) {
             $Result = Url(UserUrl($User), '//');
         }
     } elseif (isset($Vars['TagID'])) {
         $Tag = TagModel::instance()->GetID($Vars['TagID']);
         if ($Tag) {
             $Result = TagUrl($Tag, self::pageNumber($Vars, 'Vanilla.Discussions.PerPage'), '//');
         }
     } elseif (isset($Vars['CategoryID'])) {
         trace("Looking up category {$Vars['CategoryID']}.");
//.........这里部分代码省略.........
开发者ID:vanilla,项目名称:addons,代码行数:101,代码来源:class.redirector.plugin.php

示例5: tree

 public function tree($category = '')
 {
     $tree = CategoryModel::instance()->getChildTree($category);
     $this->setData('Categories', $tree);
     $this->render('blank', 'utility', 'dashboard');
 }
开发者ID:vanilla,项目名称:vanilla,代码行数:6,代码来源:class.categoriescontroller.php


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