本文整理汇总了PHP中Gdn_Format::url方法的典型用法代码示例。如果您正苦于以下问题:PHP Gdn_Format::url方法的具体用法?PHP Gdn_Format::url怎么用?PHP Gdn_Format::url使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gdn_Format
的用法示例。
在下文中一共展示了Gdn_Format::url方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addLabel
/**
*
*
* @param $Name
* @param string $Code
* @param string $Url
*/
public function addLabel($Name, $Code = '', $Url = '')
{
if ($Code == '') {
$Code = Gdn_Format::url(ucwords(trim(Gdn_Format::plainText($Name))));
}
$this->_Labels[] = array('Name' => $Name, 'Code' => $Code, 'Url' => $Url);
}
示例2: index
/**
*
*
* @param string $ID
* @param string $ServeFile
*/
public function index($ID = '', $ServeFile = '0')
{
$this->addJsFile('jquery.js');
// Define the item being downloaded
if (strtolower($ID) == 'vanilla') {
$ID = 'vanilla-core';
}
$UrlFilename = Gdn::request()->filename();
$PathInfo = pathinfo($UrlFilename);
$Ext = val('extension', $PathInfo);
if ($Ext == 'zip') {
$ServeFile = '1';
$ID = $Ext = val('filename', $PathInfo);
}
// Find the requested addon
$this->Addon = $this->AddonModel->getSlug($ID, true);
$this->setData('Addon', $this->Addon);
if (!is_array($this->Addon) || !val('File', $this->Addon)) {
$this->Addon = array('Name' => 'Not Found', 'Version' => 'undefined', 'File' => '');
} else {
$AddonID = $this->Addon['AddonID'];
if ($ServeFile != '1') {
$this->addJsFile('get.js');
}
if ($ServeFile == '1') {
// Record this download
$this->Database->sql()->insert('Download', array('AddonID' => $AddonID, 'DateInserted' => Gdn_Format::toDateTime(), 'RemoteIp' => @$_SERVER['REMOTE_ADDR']));
$this->AddonModel->setProperty($AddonID, 'CountDownloads', $this->Addon['CountDownloads'] + 1);
if (val('Slug', $this->Addon)) {
$Filename = $this->Addon['Slug'];
} else {
$Filename = "{$this->Addon['Name']}-{$this->Addon['Version']}";
}
$Filename = Gdn_Format::url($Filename) . '.zip';
$File = $this->Addon['File'];
$Url = Gdn_Upload::url($File);
Gdn_FileSystem::serveFile($Url, $Filename);
}
}
$this->addModule('AddonHelpModule');
$this->render();
}
示例3: addFlagButton
/**
* Output Flag link.
*/
protected function addFlagButton($Sender, $Args, $Context = 'comment')
{
$ElementID = $Context == 'comment' ? $Args['Comment']->CommentID : $Args['Discussion']->DiscussionID;
if (!is_object($Args['Author']) || !isset($Args['Author']->UserID)) {
$ElementAuthorID = 0;
$ElementAuthor = 'Unknown';
} else {
$ElementAuthorID = $Args['Author']->UserID;
$ElementAuthor = $Args['Author']->Name;
}
switch ($Context) {
case 'comment':
$URL = "/discussion/comment/{$ElementID}/#Comment_{$ElementID}";
break;
case 'discussion':
$URL = "/discussion/{$ElementID}/" . Gdn_Format::url($Args['Discussion']->Name);
break;
default:
return;
}
$EncodedURL = str_replace('=', '-', base64_encode($URL));
$FlagLink = anchor(t('Flag'), "discussion/flag/{$Context}/{$ElementID}/{$ElementAuthorID}/" . Gdn_Format::url($ElementAuthor) . "/{$EncodedURL}", 'FlagContent Popup');
echo wrap($FlagLink, 'span', array('class' => 'MItem CommentFlag'));
}
示例4: index
/**
* Default search functionality.
*
* @since 2.0.0
* @access public
* @param int $Page Page number.
*/
public function index($Page = '')
{
$this->addJsFile('search.js');
$this->title(t('Search'));
saveToConfig('Garden.Format.EmbedSize', '160x90', false);
Gdn_Theme::section('SearchResults');
list($Offset, $Limit) = offsetLimit($Page, c('Garden.Search.PerPage', 20));
$this->setData('_Limit', $Limit);
$Search = $this->Form->getFormValue('Search');
$Mode = $this->Form->getFormValue('Mode');
if ($Mode) {
$this->SearchModel->ForceSearchMode = $Mode;
}
try {
$ResultSet = $this->SearchModel->Search($Search, $Offset, $Limit);
} catch (Gdn_UserException $Ex) {
$this->Form->addError($Ex);
$ResultSet = array();
} catch (Exception $Ex) {
LogException($Ex);
$this->Form->addError($Ex);
$ResultSet = array();
}
Gdn::userModel()->joinUsers($ResultSet, array('UserID'));
// Fix up the summaries.
$SearchTerms = explode(' ', Gdn_Format::text($Search));
foreach ($ResultSet as &$Row) {
$Row['Summary'] = SearchExcerpt(Gdn_Format::plainText($Row['Summary'], $Row['Format']), $SearchTerms);
$Row['Summary'] = Emoji::instance()->translateToHtml($Row['Summary']);
$Row['Format'] = 'Html';
}
$this->setData('SearchResults', $ResultSet, true);
$this->setData('SearchTerm', Gdn_Format::text($Search), true);
if ($ResultSet) {
$NumResults = count($ResultSet);
} else {
$NumResults = 0;
}
if ($NumResults == $Offset + $Limit) {
$NumResults++;
}
// Build a pager
$PagerFactory = new Gdn_PagerFactory();
$this->Pager = $PagerFactory->GetPager('MorePager', $this);
$this->Pager->MoreCode = 'More Results';
$this->Pager->LessCode = 'Previous Results';
$this->Pager->ClientID = 'Pager';
$this->Pager->configure($Offset, $Limit, $NumResults, 'dashboard/search/%1$s/%2$s/?Search=' . Gdn_Format::url($Search));
// if ($this->_DeliveryType != DELIVERY_TYPE_ALL) {
// $this->setJson('LessRow', $this->Pager->toString('less'));
// $this->setJson('MoreRow', $this->Pager->toString('more'));
// $this->View = 'results';
// }
$this->canonicalUrl(url('search', true));
$this->render();
}
示例5: handleAddonToggle
private function handleAddonToggle($addonName, $addonInfo, $type, $isEnabled, $filter = '', $action = '')
{
require_once $this->fetchViewLocation('helper_functions');
if ($this->Form->errorCount() > 0) {
$this->informMessage($this->Form->errors());
} else {
if ($action === 'SlideUp') {
$this->jsonTarget('#' . Gdn_Format::url($addonName) . '-addon', '', 'SlideUp');
} else {
ob_start();
writeAddonMedia($addonName, $addonInfo, $isEnabled, $type, $filter);
$row = ob_get_clean();
$this->jsonTarget('#' . Gdn_Format::url($addonName) . '-addon', $row, 'ReplaceWith');
}
}
$this->render('blank', 'utility', 'dashboard');
}
示例6: join
if (!$LastCommentIDExists || !$LastCommentUserIDExists) {
$Construct->query("update {$Prefix}Discussion d\n inner join {$Prefix}Comment c\n on c.DiscussionID = d.DiscussionID\n inner join (\n select max(c2.CommentID) as CommentID\n from {$Prefix}Comment c2\n group by c2.DiscussionID\n ) c2\n on c.CommentID = c2.CommentID\n set d.LastCommentID = c.CommentID,\n d.LastCommentUserID = c.InsertUserID\nwhere d.LastCommentUserID is null");
}
if (!$CountBookmarksExists) {
$Construct->query("update {$Prefix}Discussion d\n set CountBookmarks = (\n select count(ud.DiscussionID)\n from {$Prefix}UserDiscussion ud\n where ud.Bookmarked = 1\n and ud.DiscussionID = d.DiscussionID\n )");
}
$Construct->table('TagDiscussion');
$DateInsertedExists = $Construct->columnExists('DateInserted');
$Construct->column('TagID', 'int', false, 'primary')->column('DiscussionID', 'int', false, 'primary')->column('CategoryID', 'int', false, 'index')->column('DateInserted', 'datetime', !$DateInsertedExists)->Engine('InnoDB')->set($Explicit, $Drop);
if (!$DateInsertedExists) {
$SQL->update('TagDiscussion td')->join('Discussion d', 'td.DiscussionID = d.DiscussionID')->set('td.DateInserted', 'd.DateInserted', false, false)->put();
}
$Construct->table('Tag')->column('CountDiscussions', 'int', 0)->set();
$Categories = Gdn::sql()->where("coalesce(UrlCode, '') =", "''", false, false)->get('Category')->resultArray();
foreach ($Categories as $Category) {
$UrlCode = Gdn_Format::url($Category['Name']);
if (strlen($UrlCode) > 50) {
$UrlCode = $Category['CategoryID'];
}
Gdn::sql()->put('Category', array('UrlCode' => $UrlCode), array('CategoryID' => $Category['CategoryID']));
}
// Moved this down here because it needs to run after GDN_Comment is created
if (!$LastDiscussionIDExists) {
$SQL->update('Category c')->join('Comment cm', 'c.LastCommentID = cm.CommentID')->set('c.LastDiscussionID', 'cm.DiscussionID', false, false)->put();
}
// Add stub content
include PATH_APPLICATIONS . DS . 'vanilla' . DS . 'settings' . DS . 'stub.php';
// Set current Vanilla.Version
$ApplicationInfo = array();
include CombinePaths(array(PATH_APPLICATIONS . DS . 'vanilla' . DS . 'settings' . DS . 'about.php'));
$Version = val('Version', val('Vanilla', $ApplicationInfo, array()), 'Undefined');
示例7: find
/**
* Find the requested plugin and redirect to it.
*
* @param string $PluginName
*/
public function find($PluginName = '')
{
$Data = $this->Database->sql()->select('AddonID, Name')->from('Addon')->where('Name', $PluginName)->get()->firstRow();
if ($Data) {
safeRedirect('/addon/' . $Data->AddonID . '/' . Gdn_Format::url($Data->Name));
} else {
safeRedirect('/addon/notfound/');
}
}
示例8: arrayValue
$ScreenName = Gdn_Format::Display(val('Name', $PluginInfo, $PluginName));
$SettingsUrl = $State == 'enabled' ? arrayValue('SettingsUrl', $PluginInfo, '') : '';
$PluginUrl = arrayValue('PluginUrl', $PluginInfo, '');
$Author = arrayValue('Author', $PluginInfo, '');
$AuthorUrl = arrayValue('AuthorUrl', $PluginInfo, '');
$NewVersion = arrayValue('NewVersion', $PluginInfo, '');
$Upgrade = $NewVersion != '' && version_compare($NewVersion, $Version, '>');
$RowClass = $Css;
if ($Alt) {
$RowClass .= ' Alt';
}
$IconPath = '/plugins/' . GetValue('Folder', $PluginInfo, '') . '/icon.png';
$IconPath = file_exists(PATH_ROOT . $IconPath) ? $IconPath : 'applications/dashboard/design/images/plugin-icon.png';
?>
<tr <?php
echo 'id="' . Gdn_Format::url(strtolower($PluginName)) . '-plugin"', ' class="More ' . $RowClass . '"';
?>
>
<td rowspan="2" class="Less"><?php
echo img($IconPath, array('class' => 'PluginIcon'));
?>
</td>
<th><?php
echo $ScreenName;
?>
</th>
<td class="Alt"><?php
echo Gdn_Format::Html(t(val('Name', $PluginInfo, $PluginName) . ' Description', val('Description', $PluginInfo, '')));
?>
</td>
</tr>
示例9: updateCounts
//.........这里部分代码省略.........
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\n set LastMessageID = (\n select max(MessageID)\n from :_ConversationMessage m\n where m.ConversationID = uc.ConversationID\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\n join :_Conversation c\n on c.ConversationID = uc.ConversationID\n set uc.CountReadMessages = c.CountMessages,\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\n join :_ConversationMessage m\n on m.ConversationID = uc.ConversationID\n and m.MessageID = uc.LastMessageID\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\n set CountBookmarks = (\n select count(ud.DiscussionID)\n from :_UserDiscussion ud\n where ud.Bookmarked = 1\n and ud.UserID = u.UserID\n )";
}
// if (!$this->importExists('User', 'CountUnreadConversations')) {
// $Sqls['User.CountUnreadConversations'] =
// 'update :_User u
// set u.CountUnreadConversations = (
// select count(c.ConversationID)
// from :_Conversation c
// inner join :_UserConversation uc
// on c.ConversationID = uc.ConversationID
// where uc.UserID = u.UserID
// and uc.CountReadMessages < c.CountMessages
// )';
// }
// The updates start here.
$CurrentSubstep = val('CurrentSubstep', $this->Data, 0);
// $Sqls2 = array();
// $i = 1;
// foreach ($Sqls as $Name => $Sql) {
// $Sqls2[] = "/* $i. $Name */\n"
// .str_replace(':_', $this->Database->DatabasePrefix, $Sql)
// .";\n";
// $i++;
// }
// throw new Exception(implode("\n", $Sqls2));
// Execute the SQL.
$Keys = array_keys($Sqls);
for ($i = $CurrentSubstep; $i < count($Keys); $i++) {
$this->Data['CurrentStepMessage'] = sprintf(t('%s of %s'), $CurrentSubstep + 1, count($Keys));
$Sql = $Sqls[$Keys[$i]];
$this->query($Sql);
if ($this->Timer->ElapsedTime() > $this->MaxStepTime) {
$this->Data['CurrentSubstep'] = $i + 1;
return false;
}
}
if (isset($this->Data['CurrentSubstep'])) {
unset($this->Data['CurrentSubstep']);
}
$this->Data['CurrentStepMessage'] = '';
// Update the url codes of categories.
if (!$this->importExists('Category', 'UrlCode')) {
$Categories = CategoryModel::categories();
$TakenCodes = array();
foreach ($Categories as $Category) {
$UrlCode = urldecode(Gdn_Format::url($Category['Name']));
if (strlen($UrlCode) > 50) {
$UrlCode = 'c' . $Category['CategoryID'];
} elseif (is_numeric($UrlCode)) {
$UrlCode = 'c' . $UrlCode;
}
if (in_array($UrlCode, $TakenCodes)) {
$ParentCategory = CategoryModel::categories($Category['ParentCategoryID']);
if ($ParentCategory && $ParentCategory['CategoryID'] != -1) {
$UrlCode = Gdn_Format::url($ParentCategory['Name']) . '-' . $UrlCode;
}
if (in_array($UrlCode, $TakenCodes)) {
$UrlCode = $Category['CategoryID'];
}
}
$TakenCodes[] = $UrlCode;
Gdn::sql()->put('Category', array('UrlCode' => $UrlCode), array('CategoryID' => $Category['CategoryID']));
}
}
// Rebuild the category tree.
$CategoryModel = new CategoryModel();
$CategoryModel->RebuildTree();
$this->SetCategoryPermissionIDs();
return true;
}
示例10: renderDiscussionAddonWarning
/**
* Show a message when the discussion is related to an addon.
*
* @param $AddonID
* @param $AddonName
* @param $AttachID
* @return string
*/
function renderDiscussionAddonWarning($AddonID, $AddonName, $AttachID)
{
$DeleteOption = '';
if (Gdn::session()->checkPermission('Addons.Addon.Manage')) {
$DeleteOption = anchor('x', 'addon/detachfromdiscussion/' . $AttachID, array('class' => 'Dismiss'));
}
$String = wrap($DeleteOption . sprintf(t('This discussion is related to the %s addon.'), anchor($AddonName, 'addon/' . $AddonID . '/' . Gdn_Format::url($AddonName))), 'div', array('class' => 'Warning AddonAttachment DismissMessage'));
return $String;
}
示例11: activity
/**
* Show activity feed for this user.
*
* @since 2.0.0
* @access public
* @param mixed $UserReference Unique identifier, possible ID or username.
* @param string $Username Username.
* @param int $UserID Unique ID.
* @param int $Offset How many to skip (for paging).
*/
public function activity($UserReference = '', $Username = '', $UserID = '', $Page = '')
{
$this->permission('Garden.Profiles.View');
$this->editMode(false);
// Object setup
$Session = Gdn::session();
$this->ActivityModel = new ActivityModel();
// Calculate offset.
list($Offset, $Limit) = offsetLimit($Page, 30);
// Get user, tab, and comment
$this->getUserInfo($UserReference, $Username, $UserID);
$UserID = $this->User->UserID;
$Username = $this->User->Name;
$this->_setBreadcrumbs(t('Activity'), userUrl($this->User, '', 'activity'));
$this->setTabView('Activity');
$Comment = $this->Form->getFormValue('Comment');
// Load data to display
$this->ProfileUserID = $this->User->UserID;
$Limit = 30;
$NotifyUserIDs = array(ActivityModel::NOTIFY_PUBLIC);
if (Gdn::session()->checkPermission('Garden.Moderation.Manage')) {
$NotifyUserIDs[] = ActivityModel::NOTIFY_MODS;
}
$Activities = $this->ActivityModel->getWhere(array('ActivityUserID' => $UserID, 'NotifyUserID' => $NotifyUserIDs), $Offset, $Limit)->resultArray();
$this->ActivityModel->joinComments($Activities);
$this->setData('Activities', $Activities);
if (count($Activities) > 0) {
$LastActivity = reset($Activities);
$LastModifiedDate = Gdn_Format::toTimestamp($this->User->DateUpdated);
$LastActivityDate = Gdn_Format::toTimestamp($LastActivity['DateInserted']);
if ($LastModifiedDate < $LastActivityDate) {
$LastModifiedDate = $LastActivityDate;
}
// Make sure to only query this page if the user has no new activity since the requesting browser last saw it.
$this->SetLastModified($LastModifiedDate);
}
// Set the canonical Url.
if (is_numeric($this->User->Name) || Gdn_Format::url($this->User->Name) != strtolower($this->User->Name)) {
$this->canonicalUrl(url('profile/' . $this->User->UserID . '/' . Gdn_Format::url($this->User->Name), true));
} else {
$this->canonicalUrl(url('profile/' . strtolower($this->User->Name), true));
}
$this->render();
}
示例12: t
echo t('Comments');
?>
</td>
<!-- <td><?php
echo t('PageViews');
?>
</td> -->
</tr>
</thead>
<tbody>
<?php
foreach ($this->Data['UserData'] as $User) {
?>
<tr>
<th><?php
echo anchor($User->Name, 'profile/' . $User->UserID . '/' . Gdn_Format::url($User->Name));
?>
</th>
<td><?php
echo number_format($User->CountComments);
?>
</td>
<!-- <td><?php
// echo number_format($Discussion->CountViews);
?>
</td> -->
</tr>
<?php
}
?>
</tbody>
示例13: slug
/**
*
*
* @param $Addon
* @param bool|true $IncludeVersion
* @return string
*/
public static function slug($Addon, $IncludeVersion = true)
{
if (val('AddonKey', $Addon) && (val('Version', $Addon) || !$IncludeVersion)) {
$Key = val('AddonKey', $Addon);
$Type = val('Type', $Addon);
if (!$Type) {
$Type = val(val('AddonTypeID', $Addon), array_flip(self::$Types));
}
//$Slug = strtolower(val('AddonKey', $Data).'-'.val('Type', $Data).'-'.val('Version', $Data));
$Slug = strtolower($Key) . '-' . strtolower($Type);
if ($IncludeVersion === true) {
$Slug .= '-' . val('Version', $Addon, '');
} elseif (is_string($IncludeVersion)) {
$Slug .= '-' . $IncludeVersion;
} elseif (is_array($IncludeVersion)) {
$Slug .= '-' . $IncludeVersion['Version'];
}
return urlencode($Slug);
} else {
return val('AddonID', $Addon) . '-' . Gdn_Format::url(val('Name', $Addon));
}
}
示例14: tagSlug
/**
*
*
* @param $Str
* @return string
*/
public static function tagSlug($Str)
{
return rawurldecode(Gdn_Format::url($Str));
}
示例15: fixUrlCodes
public function fixUrlCodes($Table, $Column)
{
$Model = $this->createModel($Table);
// Get the data to decode.
$Data = $this->SQL->select($Model->PrimaryKey)->select($Column)->from($Table)->get()->resultArray();
foreach ($Data as $Row) {
$Value = $Row[$Column];
$Encoded = Gdn_Format::url($Value);
if (!$Value || $Value != $Encoded) {
$Model->setField($Row[$Model->PrimaryKey], $Column, $Encoded);
Gdn::controller()->Data['Encoded'][$Row[$Model->PrimaryKey]] = $Encoded;
}
}
return array('Complete' => true);
}