本文整理汇总了PHP中Gdn::Structure方法的典型用法代码示例。如果您正苦于以下问题:PHP Gdn::Structure方法的具体用法?PHP Gdn::Structure怎么用?PHP Gdn::Structure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gdn
的用法示例。
在下文中一共展示了Gdn::Structure方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _GenerateConfContent
private function _GenerateConfContent($Template)
{
$SQLSock = '';
if ('' != trim(ini_get('mysql.default_socket'))) {
$SQLSock = 'sql_sock = ' . ini_get('mysql.default_socket');
}
//Check to see if grabing any of the tags
///@todo fix this stopgap solution with something more robust
//Get list of tags
$SQL = Gdn::SQL();
if (Gdn::Structure()->TableExists('TagDiscussion')) {
$Tags = TRUE;
} else {
$Tags = FALSE;
}
$DBPrefix = C('Database.Name') . '.' . C('Database.DatabasePrefix', 'GDN_');
//join these 2
$Search = array('{sql_sock}' => $SQLSock, '{sql_host}' => $this->Settings['Install']->Host, '{sql_user}' => C('Database.User'), '{sql_pass}' => C('Database.Password'), '{sql_db}' => C('Database.Name'), '{charset_type}' => C('Garden.Charset', 'utf-8'), '{charset_type_mysql}' => C('Database.CharacterEncoding', 'utf8'), '{install_path}' => $this->Settings['Install']->InstallPath, '{assests_path}' => PATH_PLUGINS . DS . 'SphinxSearchLite' . DS . 'assests' . DS, '{searchd_port}' => $this->Settings['Install']->Port, '{log_path}' => $this->Settings['Install']->LogPath, '{query_path}' => $this->Settings['Install']->QueryPath, '{PID_path}' => $this->Settings['Install']->PIDPath, '{data_path}' => $this->Settings['Install']->DataPath, '{db_prefix}' => $DBPrefix, '{ss_prefix}' => $this->Settings['Install']->Prefix);
/* '{tag_select}' => $Tags == TRUE ? '(SELECT td.TagID as TagName\
FROM '.$DBPrefix.'TagDiscussion td\
WHERE pic.GDN_Comment.DiscussionID = td.DiscussionID),\\' : '\\',*/
$ReWritedContent = str_replace(array_keys($Search), $Search, $Template);
//echo nl2br($ReWritedContent); die;
return $ReWritedContent;
}
示例2: Setup
/**
* First time setup of CountriesOnline plugin.
*/
public function Setup()
{
// Time threshold, in seconds, for signed in users grouped by country.
SaveToConfig('Plugin.CountriesOnline.TimeThreshold', $this->default_time_threshold);
$Structure = Gdn::Structure();
$Structure->Table('CountriesOnline')->Column('UserID', 'int(11)', false, 'primary')->Column('CountryCode', 'char(2)', 'VF')->Column('Timestamp', 'int(10)', false, 'key')->Set(false, false);
}
示例3: DefineTables
public function DefineTables()
{
$St = Gdn::Structure();
foreach ($this->Structures as $Table => $Columns) {
$St->Table(self::TABLE_PREFIX . $Table);
foreach ($Columns as $Name => $Type) {
$St->Column($Name, $Type, NULL);
}
$St->Set();
}
}
示例4: Structure
/**
* Database changes needed for this plugin.
*/
public function Structure()
{
$Structure = Gdn::Structure();
$Structure->Table('Flag')->Column('DiscussionID', 'int(11)', TRUE)->Column('InsertUserID', 'int(11)', FALSE, 'key')->Column('InsertName', 'varchar(64)')->Column('AuthorID', 'int(11)')->Column('AuthorName', 'varchar(64)')->Column('ForeignURL', 'varchar(255)', FALSE, 'key')->Column('ForeignID', 'int(11)')->Column('ForeignType', 'varchar(32)')->Column('Comment', 'text')->Column('DateInserted', 'datetime')->Set(FALSE, FALSE);
}
示例5: StructureReactions
/**
* Define all of the structure releated to reactions.
* @return type
*/
public function StructureReactions()
{
// Define 'Accept' reaction
if (!$this->Reactions) {
return;
}
$Rm = new ReactionModel();
if (Gdn::Structure()->Table('ReactionType')->ColumnExists('Hidden')) {
// AcceptAnswer
$Rm->DefineReactionType(array('UrlCode' => 'AcceptAnswer', 'Name' => 'Accept Answer', 'Sort' => 0, 'Class' => 'Good', 'IncrementColumn' => 'Score', 'IncrementValue' => 5, 'Points' => 3, 'Permission' => 'Garden.Curation.Manage', 'Hidden' => 1, 'Description' => "When someone correctly answers a question, they are rewarded with this reaction."));
}
Gdn::Structure()->Reset();
}
示例6: RunStructure
public function RunStructure($AddonCode = NULL, $Explicit = FALSE, $Drop = FALSE)
{
// Get the structure files for all of the enabled applications.
$ApplicationManager = new Gdn_ApplicationManager();
$Apps = $ApplicationManager->EnabledApplications();
$AppNames = ConsolidateArrayValuesByKey($Apps, 'Folder');
$Paths = array();
foreach ($Apps as $Key => $AppInfo) {
$Path = PATH_APPLICATIONS . "/{$AppInfo['Folder']}/settings/structure.php";
if (file_exists($Path)) {
$Paths[] = $Path;
}
Gdn::ApplicationManager()->RegisterPermissions($Key, $this->Validation);
}
// Execute the structures.
$Database = Gdn::Database();
$SQL = Gdn::SQL();
$Structure = Gdn::Structure();
foreach ($Paths as $Path) {
include $Path;
}
// Execute the structures for all of the plugins.
$PluginManager = Gdn::PluginManager();
$Registered = $PluginManager->RegisteredPlugins();
foreach ($Registered as $ClassName => $Enabled) {
if (!$Enabled) {
continue;
}
try {
$Plugin = $PluginManager->GetPluginInstance($ClassName, Gdn_PluginManager::ACCESS_CLASSNAME);
if (method_exists($Plugin, 'Structure')) {
Trace("{$ClassName}->Structure()");
$Plugin->Structure();
}
} catch (Exception $Ex) {
// Do nothing, plugin wouldn't load/structure.
if (Debug()) {
throw $Ex;
}
}
}
}
示例7: UpdateCounts
public function UpdateCounts()
{
// This option could take a while so set the timeout.
set_time_limit(60 * 5);
// Define the necessary SQL.
$Sqls = array();
if (!$this->ImportExists('Discussion', 'LastCommentID')) {
$Sqls['Discussion.LastCommentID'] = $this->GetCountSQL('max', 'Discussion', 'Comment');
}
if (!$this->ImportExists('Discussion', 'DateLastComment')) {
$Sqls['Discussion.DateLastComment'] = "update :_Discussion d\r\n left join :_Comment c\r\n on d.LastCommentID = c.CommentID\r\n set d.DateLastComment = coalesce(c.DateInserted, d.DateInserted)";
}
if (!$this->ImportExists('Discussion', 'CountBookmarks')) {
$Sqls['Discussion.CountBookmarks'] = "update :_Discussion d\r\n set CountBookmarks = (\r\n select count(ud.DiscussionID)\r\n from :_UserDiscussion ud\r\n where ud.Bookmarked = 1\r\n and ud.DiscussionID = d.DiscussionID\r\n )";
}
if (!$this->ImportExists('Discussion', 'LastCommentUserID')) {
$Sqls['Discussion.LastCommentUseID'] = "update :_Discussion d\r\n join :_Comment c\r\n on d.LastCommentID = c.CommentID\r\n set d.LastCommentUserID = c.InsertUserID";
}
if (!$this->ImportExists('Discussion', 'Body')) {
// Update the body of the discussion if it isn't there.
if (!$this->ImportExists('Discussion', 'FirstCommentID')) {
$Sqls['Discussion.FirstCommentID'] = $this->GetCountSQL('min', 'Discussion', 'Comment', 'FirstCommentID', 'CommentID');
}
$Sqls['Discussion.Body'] = "update :_Discussion d\r\n join :_Comment c\r\n on d.FirstCommentID = c.CommentID\r\n set d.Body = c.Body, d.Format = c.Format";
if ($this->ImportExists('Media') && Gdn::Structure()->TableExists('Media')) {
// Comment Media has to go onto the discussion.
$Sqls['Media.Foreign'] = "update :_Media m\r\n join :_Discussion d\r\n on d.FirstCommentID = m.ForeignID and m.ForeignTable = 'comment'\r\n set m.ForeignID = d.DiscussionID, m.ForeignTable = 'discussion'";
}
$Sqls['Comment.FirstComment.Delete'] = "delete c.*\r\n from :_Comment c\r\n inner join :_Discussion d\r\n on d.FirstCommentID = c.CommentID";
}
if (!$this->ImportExists('Discussion', 'CountComments')) {
$Sqls['Discussion.CountComments'] = $this->GetCountSQL('count', 'Discussion', 'Comment');
}
if ($this->ImportExists('UserDiscussion') && !$this->ImportExists('UserDiscussion', 'CountComments') && $this->ImportExists('UserDiscussion', 'DateLastViewed')) {
$Sqls['UserDiscussuion.CountComments'] = "update :_UserDiscussion ud\r\n set CountComments = (\r\n select count(c.CommentID)\r\n from :_Comment c\r\n where c.DiscussionID = ud.DiscussionID\r\n and c.DateInserted <= ud.DateLastViewed)";
}
if ($this->ImportExists('Tag') && $this->ImportExists('TagDiscussion')) {
$Sqls['Tag.CoundDiscussions'] = $this->GetCountSQL('count', 'Tag', 'TagDiscussion', 'CountDiscussions', 'TagID');
}
if ($this->ImportExists('Poll') && Gdn::Structure()->TableExists('Poll')) {
$Sqls['PollOption.CountVotes'] = $this->GetCountSQL('count', 'PollOption', 'PollVote', 'CountVotes', 'PollOptionID');
$Sqls['Poll.CountOptions'] = $this->GetCountSQL('count', 'Poll', 'PollOption', 'CountOptions', 'PollID');
$Sqls['Poll.CountVotes'] = $this->GetCountSQL('sum', 'Poll', 'PollOption', 'CountVotes', 'CountVotes', 'PollID');
}
if ($this->ImportExists('Activity', 'ActivityType')) {
$Sqls['Activity.ActivityTypeID'] = "\r\n update :_Activity a\r\n join :_ActivityType t\r\n on a.ActivityType = t.Name\r\n set a.ActivityTypeID = t.ActivityTypeID";
}
if ($this->ImportExists('Tag') && $this->ImportExists('TagDiscussion')) {
$Sqls['Tag.CoundDiscussions'] = $this->GetCountSQL('count', 'Tag', 'TagDiscussion', 'CountDiscussions', 'TagID');
}
$Sqls['Category.CountDiscussions'] = $this->GetCountSQL('count', 'Category', 'Discussion');
$Sqls['Category.CountComments'] = $this->GetCountSQL('sum', 'Category', 'Discussion', 'CountComments', 'CountComments');
if (!$this->ImportExists('Category', 'PermissionCategoryID')) {
$Sqls['Category.PermissionCategoryID'] = "update :_Category set PermissionCategoryID = -1";
}
if ($this->ImportExists('Conversation') && $this->ImportExists('ConversationMessage')) {
$Sqls['Conversation.FirstMessageID'] = $this->GetCountSQL('min', 'Conversation', 'ConversationMessage', 'FirstMessageID', 'MessageID');
if (!$this->ImportExists('Conversation', 'CountMessages')) {
$Sqls['Conversation.CountMessages'] = $this->GetCountSQL('count', 'Conversation', 'ConversationMessage', 'CountMessages', 'MessageID');
}
if (!$this->ImportExists('Conversation', 'LastMessageID')) {
$Sqls['Conversation.LastMessageID'] = $this->GetCountSQL('max', 'Conversation', 'ConversationMessage', 'LastMessageID', 'MessageID');
}
if (!$this->ImportExists('Conversation', 'DateUpdated')) {
$Sqls['Converstation.DateUpdated'] = "update :_Conversation c join :_ConversationMessage m on c.LastMessageID = m.MessageID set c.DateUpdated = m.DateInserted";
}
if ($this->ImportExists('UserConversation')) {
if (!$this->ImportExists('UserConversation', 'LastMessageID')) {
if ($this->ImportExists('UserConversation', 'DateLastViewed')) {
// Get the value from the DateLastViewed.
$Sqls['UserConversation.LastMessageID'] = "update :_UserConversation uc\r\n set LastMessageID = (\r\n select max(MessageID)\r\n from :_ConversationMessage m\r\n where m.ConversationID = uc.ConversationID\r\n and m.DateInserted >= uc.DateLastViewed)";
} else {
// Get the value from the conversation.
// In this case just mark all of the messages read.
$Sqls['UserConversation.LastMessageID'] = "update :_UserConversation uc\r\n join :_Conversation c\r\n on c.ConversationID = uc.ConversationID\r\n set uc.CountReadMessages = c.CountMessages,\r\n uc.LastMessageID = c.LastMessageID";
}
} elseif (!$this->ImportExists('UserConversation', 'DateLastViewed')) {
// We have the last message so grab the date from that.
$Sqls['UserConversation.DateLastViewed'] = "update :_UserConversation uc\r\n join :_ConversationMessage m\r\n on m.ConversationID = uc.ConversationID\r\n and m.MessageID = uc.LastMessageID\r\n set uc.DateLastViewed = m.DateInserted";
}
}
}
// User counts.
if (!$this->ImportExists('User', 'DateFirstVisit')) {
$Sqls['User.DateFirstVisit'] = 'update :_User set DateFirstVisit = DateInserted';
}
if (!$this->ImportExists('User', 'CountDiscussions')) {
$Sqls['User.CountDiscussions'] = $this->GetCountSQL('count', 'User', 'Discussion', 'CountDiscussions', 'DiscussionID', 'UserID', 'InsertUserID');
}
if (!$this->ImportExists('User', 'CountComments')) {
$Sqls['User.CountComments'] = $this->GetCountSQL('count', 'User', 'Comment', 'CountComments', 'CommentID', 'UserID', 'InsertUserID');
}
if (!$this->ImportExists('User', 'CountBookmarks')) {
$Sqls['User.CountBookmarks'] = "update :_User u\r\n set CountBookmarks = (\r\n select count(ud.DiscussionID)\r\n from :_UserDiscussion ud\r\n where ud.Bookmarked = 1\r\n and ud.UserID = u.UserID\r\n )";
}
// if (!$this->ImportExists('User', 'CountUnreadConversations')) {
// $Sqls['User.CountUnreadConversations'] =
// 'update :_User u
// set u.CountUnreadConversations = (
// select count(c.ConversationID)
//.........这里部分代码省略.........
示例8: Setup
public function Setup()
{
$Structure = Gdn::Structure();
// Construct the user comment table.
$Structure->Table('UserComment')->Column('CommentID', 'int', 4, FALSE, NULL, 'primary', FALSE)->Column('UserID', 'int', 4, FALSE, NULL, 'primary', FALSE)->Column('Score', 'int', 4, TRUE)->Column('InsertUserID', 'int', 10, FALSE, NULL, 'key')->Column('UpdateUserID', 'int', 10, TRUE)->Column('DateInserted', 'datetime')->Column('DateUpdated', 'datetime')->Set(FALSE, FALSE);
// Add the total score to the comment table.
$Structure->Table('Comment')->Column('SumScore', 'int', 4, TRUE)->Set(FALSE, FALSE);
}
示例9: Structure
/**
* Commits the required updates to the structure of the database
*/
public function Structure()
{
// Loading up our structure object to enable the ability to modify the database
$Structure = Gdn::Structure();
// Adding a table to cache all of the retrieved Steam profile information
$Structure->Table('SteamProfileCache')->PrimaryKey('ProfileCacheID')->Column('SteamID64', 'varchar(20)', FALSE)->Column('ProfileXML', 'text', FALSE)->Column('DateRetrieved', 'datetime', FALSE)->Set(FALSE, FALSE);
}
示例10: Setup
public function Setup()
{
if (!file_exists(PATH_CACHE . DS . 'css')) {
mkdir(PATH_CACHE . DS . 'css');
}
// Setup the theme table.
$St = Gdn::Structure();
$St->Table('ThemeSetting')->Column('Name', 'varchar', '50', FALSE, NULL, 'primary')->Column('Setting', 'varchar', '50')->Set(FALSE, FALSE);
}
示例11: Setup
public function Setup()
{
$Structure = Gdn::Structure();
$Structure->Table('Whosonline')->Column('UserID', 'int(11)', FALSE, 'primary')->Column('Timestamp', 'datetime')->Column('Invisible', 'int(1)', 0)->Set(FALSE, FALSE);
}
示例12: Structure
public function Structure()
{
/* Gdn::Structure()
->Table('Comment')
->Column('ThankCount', 'usmallint', 0)
->Set();
Gdn::Structure()
->Table('Discussion')
->Column('ThankCount', 'usmallint', 0)
->Set();*/
Gdn::Structure()->Table('User')->Column('ReceivedThankCount', 'usmallint', 0)->Set();
Gdn::Structure()->Table('ThanksLog')->Column('UserID', 'umediumint', False, 'key')->Column('CommentID', 'umediumint', 0)->Column('DiscussionID', 'umediumint', 0)->Column('DateInserted', 'datetime')->Column('InsertUserID', 'umediumint', False, 'key')->Engine('MyISAM')->Set();
$RequestArgs = Gdn::Controller()->RequestArgs;
if (ArrayHasValue($RequestArgs, 'vanilla')) {
ThanksLogModel::RecalculateUserReceivedThankCount();
}
//ThanksLogModel::RecalculateCommentThankCount();
//ThanksLogModel::RecalculateDiscussionThankCount();
}
示例13: Setup
/**
* Add a field to the db for storing the "State" of a question.
*/
public function Setup()
{
// Add some fields to the database
$Structure = Gdn::Structure();
// "Unanswered" or "Answered"
$Structure->Table('Discussion')->Column('State', 'varchar(30)', TRUE)->Set(FALSE, FALSE);
// SaveToConfig('Vanilla.Categories.Use', FALSE);
// SaveToConfig('Vanilla.Comments.AutoOffset', FALSE);
}
示例14: Structure
/**
* Database changes needed for this plugin.
*/
public function Structure()
{
$Structure = Gdn::Structure();
$Structure->Table('Flag')->Column('DiscussionID', 'int(11)', TRUE)->Column('InsertUserID', 'int(11)', FALSE, 'key')->Column('InsertName', 'varchar(64)')->Column('AuthorID', 'int(11)')->Column('AuthorName', 'varchar(64)')->Column('ForeignURL', 'varchar(255)', FALSE, 'key')->Column('ForeignID', 'int(11)')->Column('ForeignType', 'varchar(32)')->Column('Comment', 'text')->Column('DateInserted', 'datetime')->Set(FALSE, FALSE);
// Turn off disabled Flagging plugin (deprecated)
if (C('Plugins.Flagging.Enabled', NULL) === FALSE) {
RemoveFromConfig('EnabledPlugins.Flagging');
}
}
示例15: Search
private function Search($Sanitized)
{
$this->SphinxClient->ResetFilters();
$this->SphinxClient->ResetGroupBy();
$MainSearch = "";
$Limit = $this->Settings['Admin']->LimitResultsPage;
$Offset = ($Sanitized['Offset'] - 1) * $Limit;
//limit per page
if ($Offset < 0) {
$Offset = 0;
}
//Make sure results respect category permissions depending on user performing search
$Permissions = Gdn::Session()->GetPermissions();
// Get user permissions
$Permissions = $Permissions['Vanilla.Discussions.View'];
// Only care about 'viewing' permissions
$this->SphinxClient->SetFilter(SS_ATTR_CATPERMID, $Permissions);
if (!empty($Sanitized['ForumList'])) {
//filter Forum categories
$Categories = $Sanitized['ForumList'];
if (!in_array(0, $Categories)) {
//If this is TRUE, than user selected to search in "All" categories...no filtering then requried
if ($Sanitized['SearchChildren']) {
$Categories = $this->GetCategories($Categories);
}
//get children IDs
$this->SphinxClient->SetFilter(SS_ATTR_CATID, $Categories);
//no children required, just get whatever was posted
}
}
if (!empty($Sanitized['TagList'])) {
if (Gdn::Structure()->TableExists('TagDiscussion')) {
//check to see if tagging plugin is enabled
$TagIDs = $this->GetTagIDs($Sanitized['TagList']);
if (sizeof($TagIDs) > 0) {
//maybe someone input an invalid tag string that does not match any in the database...
$this->SphinxClient->SetFilter('TagID', $TagIDs);
}
}
}
if (!empty($Sanitized['User'])) {
// Place quotes around user to support usernames with spaces
$MainSearch .= $this->FieldSearch('"' . $Sanitized['User'] . '"', array(SS_FIELD_USERNAME)) . " ";
// Return documents with this user
}
if (!empty($Sanitized['MemberList'])) {
//filter by member
// $String = $this->OperatorOrSearch($Sanitized['MemberList']);
// $SubQuery .= $this->FieldSearch($String, array(SS_FIELD_USERNAME));
}
if (!empty($Sanitized['WithReplies'])) {
//only return threads that have comments
$this->SphinxClient->SetFilterRange(SS_ATTR_COUNTCOMENTS, 1, 1, TRUE);
//exclude documents with exactly 0 comments (the first topic post counts as 1)
}
if (isset($Sanitized['Date']) && $Sanitized['Date'] != 'All') {
//don't filter by date if the whole query string is gone
$Time = $this->SetTime($Sanitized['Date']);
$this->SphinxClient->SetFilterRange(SS_ATTR_DOCDATEINSERTED, $Time, now());
}
$Query = $this->SetRankAndQuery($Sanitized['Match'], $Sanitized['Query']);
//depending on selected match, need to format the query string to comply with the extended syntax
$this->SetSortMode($Sanitized['Order']);
$this->SphinxClient->SetLimits($Offset, $this->Settings['Admin']->LimitResultsPage, $MaxMatches = 0);
//limit the results pageination
// if ($Sanitized['Match'] != 'Extended') { //extended query do not add these
if (true) {
//extended query DO ADD THESE FOR EXTENDED!
if ($Sanitized['TitlesOnly'] == 1) {
// If this is checked, user is NOT manually constructing query (with @ symbol)
$Query = $this->SphinxClient->EscapeString($Query);
//Escapes characters that are treated as special operators by the query language parser (i.e @title => /@/title). Returns an escaped string.
$MainSearch .= $this->FieldSearch($Query, array(SS_FIELD_TITLE));
// Search only titles
} else {
if (strpos($Sanitized['Query'], "@") === false) {
// If the query DOES contain an '@' symbol, then do not construct the query since user is doing manually
$MainSearch .= $this->FieldSearch($Query, array(SS_FIELD_TITLE, SS_FIELD_BODY));
} else {
$MainSearch .= $Sanitized['Query'];
}
// User is manually constructing the query (i.e query = @title DVD)
}
} else {
$MainSearch = $Query;
}
$Query = ' ' . $MainSearch;
$QueryIndex = $this->SphinxClient->AddQuery($Query . ' ', SS_INDEX_DIST, $this->Name);
$this->Queries[] = array('Name' => $this->Name, 'Index' => $QueryIndex);
}