作者:elpu
项目:TgaForumBundl
/**
* Grabs all new notifications and adds them to the sender's inform queue.
*
* This method gets called by dashboard's hooks file to display new
* notifications on every pageload.
*
* @since 2.0.18
* @access public
*
* @param Gdn_Controller $Sender The object calling this method.
*/
public static function InformNotifications($Sender)
{
$Session = Gdn::Session();
if (!$Session->IsValid()) {
return;
}
$ActivityModel = new ActivityModel();
// Get five pending notifications.
$Where = array('NotifyUserID' => Gdn::Session()->UserID, 'Notified' => ActivityModel::SENT_PENDING);
// If we're in the middle of a visit only get very recent notifications.
$Where['DateUpdated >'] = Gdn_Format::ToDateTime(strtotime('-5 minutes'));
$Activities = $ActivityModel->GetWhere($Where, 0, 5)->ResultArray();
$ActivityIDs = ConsolidateArrayValuesByKey($Activities, 'ActivityID');
$ActivityModel->SetNotified($ActivityIDs);
foreach ($Activities as $Activity) {
if ($Activity['Photo']) {
$UserPhoto = Anchor(Img($Activity['Photo'], array('class' => 'ProfilePhotoMedium')), $Activity['Url'], 'Icon');
} else {
$UserPhoto = '';
}
$Excerpt = Gdn_Format::Display($Activity['Story']);
$ActivityClass = ' Activity-' . $Activity['ActivityType'];
$Sender->InformMessage($UserPhoto . Wrap($Activity['Headline'], 'div', array('class' => 'Title')) . Wrap($Excerpt, 'div', array('class' => 'Excerpt')), 'Dismissable AutoDismiss' . $ActivityClass . ($UserPhoto == '' ? '' : ' HasIcon'));
}
}
作者:tautomer
项目:knoopvszombie
function WriteDiscussion($Discussion, &$Sender, &$Session, $Alt)
{
$CssClass = 'Item';
$CssClass .= $Discussion->Bookmarked == '1' ? ' Bookmarked' : '';
$CssClass .= $Alt . ' ';
$CssClass .= $Discussion->Announce == '1' ? ' Announcement' : '';
$CssClass .= $Discussion->Closed == '1' ? ' Closed' : '';
$CssClass .= $Discussion->InsertUserID == $Session->UserID ? ' Mine' : '';
$CssClass .= $Discussion->CountUnreadComments > 0 && $Session->IsValid() ? ' New' : '';
$Sender->EventArguments['Discussion'] =& $Discussion;
$Sender->FireEvent('BeforeDiscussionName');
$DiscussionName = Gdn_Format::Text($Discussion->Name);
if ($DiscussionName == '') {
$DiscussionName = T('Blank Discussion Topic');
}
static $FirstDiscussion = TRUE;
if (!$FirstDiscussion) {
$Sender->FireEvent('BetweenDiscussion');
} else {
$FirstDiscussion = FALSE;
}
?>
<li class="<?php
echo $CssClass;
?>
">
<?php
if ($Discussion->FirstPhoto != '') {
if (strtolower(substr($Discussion->FirstPhoto, 0, 7)) == 'http://' || strtolower(substr($Discussion->FirstPhoto, 0, 8)) == 'https://') {
$PhotoUrl = $Discussion->FirstPhoto;
} else {
$PhotoUrl = 'uploads/' . ChangeBasename($Discussion->FirstPhoto, 'n%s');
}
echo Img($PhotoUrl, array('alt' => $Discussion->FirstName));
}
?>
<div class="ItemContent Discussion">
<?php
echo Anchor($DiscussionName, '/discussion/' . $Discussion->DiscussionID . '/' . Gdn_Format::Url($Discussion->Name) . ($Discussion->CountCommentWatch > 0 && C('Vanilla.Comments.AutoOffset') ? '/#Item_' . $Discussion->CountCommentWatch : ''), 'Title');
?>
<?php
$Sender->FireEvent('AfterDiscussionTitle');
?>
<div class="Meta">
<span class="Author"><?php
echo $Discussion->FirstName;
?>
</span>
<?php
echo '<span class="Counts' . ($Discussion->CountUnreadComments > 0 ? ' NewCounts' : '') . '">' . ($Discussion->CountUnreadComments > 0 ? $Discussion->CountUnreadComments . '/' : '') . $Discussion->CountComments . '</span>';
if ($Discussion->LastCommentID != '') {
echo '<span class="LastCommentBy">' . sprintf(T('Latest %1$s'), $Discussion->LastName) . '</span> ';
}
echo '<span class="LastCommentDate">' . Gdn_Format::Date($Discussion->FirstDate) . '</span> ';
?>
</div>
</div>
</li>
<?php
}
作者:jeastwoo
项目:Garde
function UserPhoto($User, $CssClass = '')
{
$CssClass = $CssClass == '' ? '' : ' class="' . $CssClass . '"';
if ($User->Photo != '') {
$PhotoUrl = strtolower(substr($User->Photo, 0, 7)) == 'http://' ? $User->Photo : 'uploads/n' . $User->Photo;
return '<a href="' . Url('/profile/' . $User->UserID . '/' . urlencode($User->Name)) . '"' . $CssClass . '>' . Img($PhotoUrl, array('alt' => urlencode($User->Name))) . '</a>';
} else {
return '';
}
}
作者:Nordic-
项目:vanilla-plugin
public function PluginController_MembersListEnh_Create($Sender)
{
$Session = Gdn::Session();
if ($Sender->Menu && (CheckPermission('Plugins.MembersListEnh.GenView') || CheckPermission('Plugins.MembersListEnh.IPEmailView'))) {
$Sender->ClearCssFiles();
$Sender->AddCssFile('style.css');
$Sender->MasterView = 'default';
$Sender->Render('memtable', '', 'plugins/MembersListEnh');
} else {
echo Wrap(Anchor(Img('/plugins/MembersListEnh/design/AccessDenied.png', array('width' => '100%'), array('title' => T('You Have No Permission To View This Page Go Back'))), '/discussions', array('target' => '_self')), 'h1');
}
}
作者:SatiricMa
项目:addon
public static function connectButton($Provider, $Options = array())
{
if (!is_array($Provider)) {
$Provider = self::getProvider($Provider);
}
$Url = htmlspecialchars(self::connectUrl($Provider));
$Data = $Provider;
$Target = Gdn::Request()->Get('Target');
if (!$Target) {
$Target = '/' . ltrim(Gdn::Request()->Path());
}
if (StringBeginsWith($Target, '/entry/signin')) {
$Target = '/';
}
$ConnectQuery = array('client_id' => $Provider['AuthenticationKey'], 'Target' => $Target);
$Data['Target'] = urlencode(Url('entry/jsconnect', TRUE) . '?' . http_build_query($ConnectQuery));
$Data['Redirect'] = $Data['target'] = $Data['redirect'] = $Data['Target'];
$SignInUrl = FormatString(GetValue('SignInUrl', $Provider, ''), $Data);
$RegisterUrl = FormatString(GetValue('RegisterUrl', $Provider, ''), $Data);
if ($RegisterUrl && !GetValue('NoRegister', $Options)) {
$RegisterLink = ' ' . Anchor(sprintf(T('Register with %s', 'Register'), $Provider['Name']), $RegisterUrl, 'Button RegisterLink');
} else {
$RegisterLink = '';
}
if (IsMobile()) {
$PopupWindow = '';
} else {
$PopupWindow = 'PopupWindow';
}
if (GetValue('NoConnectLabel', $Options)) {
$ConnectLabel = '';
} else {
$ConnectLabel = '<span class="Username"></span><div class="ConnectLabel TextColor">' . sprintf(T('Sign In with %s'), $Provider['Name']) . '</div>';
}
if (!C('Plugins.JsConnect.NoGuestCheck')) {
$Result = '<div style="display: none" class="JsConnect-Container ConnectButton Small UserInfo" rel="' . $Url . '">';
if (!GetValue('IsDefault', $Provider)) {
$Result .= '<div class="JsConnect-Guest">' . Anchor(sprintf(T('Sign In with %s'), $Provider['Name']), $SignInUrl, 'Button Primary SignInLink') . $RegisterLink . '</div>';
}
$Result .= '<div class="JsConnect-Connect"><a class="ConnectLink">' . Img('https://cd8ba0b44a15c10065fd-24461f391e20b7336331d5789078af53.ssl.cf1.rackcdn.com/images/usericon_50.png', array('class' => 'ProfilePhotoSmall UserPhoto')) . $ConnectLabel . '</a></div>';
$Result .= '</div>';
} else {
if (!GetValue('IsDefault', $Provider)) {
$Result = '<div class="JsConnect-Guest">' . Anchor(sprintf(T('Sign In with %s'), $Provider['Name']), $SignInUrl, 'Button Primary SignInLink') . $RegisterLink . '</div>';
}
}
return $Result;
}
作者:vanill
项目:vanill
function writeConnection($Row)
{
$c = Gdn::controller();
$Connected = val('Connected', $Row);
?>
<li id="<?php
echo "Provider_{$Row['ProviderKey']}";
?>
" class="Item">
<div class="Connection-Header">
<span class="IconWrap">
<?php
echo img(val('Icon', $Row, Asset('/applications/dashboard/design/images/connection-64.png')));
?>
</span>
<span class="Connection-Name">
<?php
echo val('Name', $Row, t('Unknown'));
if ($Connected) {
echo ' <span class="Gloss Connected">';
if ($Photo = valr('Profile.Photo', $Row)) {
echo ' ' . Img($Photo, array('class' => 'ProfilePhoto ProfilePhotoSmall'));
}
echo ' ' . htmlspecialchars(GetValueR('Profile.Name', $Row)) . '</span>';
}
?>
</span>
<span class="Connection-Connect">
<?php
echo ConnectButton($Row);
?>
</span>
</div>
<!-- <div class="Connection-Body">
<?php
// if (Debug()) {
// decho(val($Row['ProviderKey'], $c->User->Attributes), 'Attributes');
// }
?>
</div>-->
</li>
<?php
}
作者:karanjitsing
项目:iecse-foru
echo anchor($Name, userUrl($Session->User), 'Profile');
echo anchor(t('Sign Out'), SignOutUrl(), 'Leave');
}
?>
</div>
</div>
<div id="Body">
<div id="Panel">
<?php
$this->RenderAsset('Panel');
?>
</div>
<div id="Content"><?php
$this->RenderAsset('Content');
?>
</div>
</div>
<div id="Foot">
<?php
$this->RenderAsset('Foot');
echo '<div class="Version">Version ', APPLICATION_VERSION, '</div>';
echo wrap(Anchor(Img('/applications/dashboard/design/images/logo_footer.png', array('alt' => 'Vanilla Forums')), c('Garden.VanillaUrl')), 'div');
?>
</div>
</div>
<?php
$this->fireEvent('AfterBody');
?>
</body>
</html>
作者:edward-tsa
项目:vanilla4chin
?>
</td>
<td><?php
echo T('Thumbnail');
?>
</td>
</tr>
</thead>
<tbody>
<tr>
<td>
<?php
echo Img(Gdn_Upload::Url(ChangeBasename($this->User->Photo, 'p%s')), array('id' => 'cropbox'));
?>
</td>
<td>
<div style="<?php
echo 'width:' . $this->ThumbSize . 'px;height:' . $this->ThumbSize . 'px;';
?>
overflow:hidden;">
<?php
echo Img(Gdn_Upload::Url(ChangeBasename($this->User->Photo, 'p%s')), array('id' => 'preview'));
?>
</div>
</td>
</tr>
</tbody>
</table>
<?php
echo $this->Form->Close('Save', '', array('class' => 'Button Primary'));
作者:sheldo
项目:Garde
<td class="<?php
echo $ColClass;
?>
">
<?php
echo '<h4>';
echo $ThemeUrl != '' ? Url($ThemeName, $ThemeUrl) : $ThemeName;
if ($Version != '') {
$Info = sprintf(T('Version %s'), $Version);
}
if ($Author != '') {
$Info .= sprintf('by %s', $AuthorUrl != '' ? Anchor($Author, $AuthorUrl) : $Author);
}
echo '</h4>';
if ($PreviewImage) {
echo Anchor(Img('/themes/' . $ThemeFolder . '/' . $PreviewImage, array('alt' => $ThemeName, 'height' => '112', 'width' => '150')), 'dashboard/settings/previewtheme/' . $ThemeFolder, '', array('target' => '_top'));
}
echo '<div class="Buttons">';
echo Anchor('Apply', 'dashboard/settings/themes/' . $ThemeFolder . '/' . $Session->TransientKey(), 'SmallButton', array('target' => '_top'));
echo Anchor('Preview', 'dashboard/settings/previewtheme/' . $ThemeFolder, 'SmallButton', array('target' => '_top'));
echo '</div>';
$Description = ArrayValue('Description', $ThemeInfo);
if ($Description) {
echo '<em>' . $Description . '</em>';
}
$RequiredApplications = ArrayValue('RequiredApplications', $ThemeInfo, FALSE);
if (is_array($RequiredApplications)) {
echo '<dl>
<dt>' . T('Requires') . '</dt>
<dd>';
$i = 0;
作者:nerdgir
项目:Forums-ILoveBadT
function UserPhoto($User, $Options = array()) {
$User = (object)$User;
if (is_string($Options))
$Options = array('LinkClass' => $Options);
$LinkClass = GetValue('LinkClass', $Options, 'ProfileLink');
$ImgClass = GetValue('ImageClass', $Options, 'ProfilePhotoBig');
$LinkClass = $LinkClass == '' ? '' : ' class="'.$LinkClass.'"';
if ($User->Photo) {
if (!preg_match('`^https?://`i', $User->Photo)) {
$PhotoUrl = Gdn_Upload::Url(ChangeBasename($User->Photo, 'n%s'));
} else {
$PhotoUrl = $User->Photo;
}
return '<a title="'.htmlspecialchars($User->Name).'" href="'.Url('/profile/'.$User->UserID.'/'.rawurlencode($User->Name)).'"'.$LinkClass.'>'
.Img($PhotoUrl, array('alt' => htmlspecialchars($User->Name), 'class' => $ImgClass))
.'</a>';
} else {
return '';
}
}
作者:dimassri
项目:vanill
/**
* Takes a user object, and writes out an anchor of the user's icon to the user's profile.
*
* @param object|array $User A user object or array.
* @param array $Options
*/
function userPhoto($User, $Options = array())
{
if (is_string($Options)) {
$Options = array('LinkClass' => $Options);
}
if ($Px = GetValue('Px', $Options)) {
$User = UserBuilder($User, $Px);
} else {
$User = (object) $User;
}
$LinkClass = ConcatSep(' ', GetValue('LinkClass', $Options, ''), 'PhotoWrap');
$ImgClass = GetValue('ImageClass', $Options, 'ProfilePhoto');
$Size = GetValue('Size', $Options);
if ($Size) {
$LinkClass .= " PhotoWrap{$Size}";
$ImgClass .= " {$ImgClass}{$Size}";
} else {
$ImgClass .= " {$ImgClass}Medium";
// backwards compat
}
$FullUser = Gdn::UserModel()->GetID(GetValue('UserID', $User), DATASET_TYPE_ARRAY);
$UserCssClass = GetValue('_CssClass', $FullUser);
if ($UserCssClass) {
$LinkClass .= ' ' . $UserCssClass;
}
$LinkClass = $LinkClass == '' ? '' : ' class="' . $LinkClass . '"';
$Photo = GetValue('Photo', $User);
$Name = GetValue('Name', $User);
$Title = htmlspecialchars(GetValue('Title', $Options, $Name));
if ($FullUser && $FullUser['Banned']) {
$Photo = C('Garden.BannedPhoto', 'http://cdn.vanillaforums.com/images/banned_large.png');
$Title .= ' (' . T('Banned') . ')';
}
if (!$Photo && function_exists('UserPhotoDefaultUrl')) {
$Photo = UserPhotoDefaultUrl($User, $ImgClass);
}
if ($Photo) {
if (!isUrl($Photo)) {
$PhotoUrl = Gdn_Upload::Url(ChangeBasename($Photo, 'n%s'));
} else {
$PhotoUrl = $Photo;
}
$Href = Url(UserUrl($User));
return '<a title="' . $Title . '" href="' . $Href . '"' . $LinkClass . '>' . Img($PhotoUrl, array('alt' => $Name, 'class' => $ImgClass)) . '</a>';
} else {
return '';
}
}
作者:rnovin
项目:Garde
?>
<div class="Connect">
<h1><?php
echo StringIsNullOrEmpty($ConnectSource) ? T("Sign in") : sprintf(T('%s Connect'), $ConnectSource);
?>
</h1>
<div>
<?php
echo $this->Form->Open();
echo $this->Form->Errors();
if ($ConnectName || $ConnectPhoto) {
?>
<div class="MeBox">
<?php
if ($ConnectPhoto) {
echo '<span class="PhotoWrap">', Img($ConnectPhoto, array('alt' => T('Profile Picture'), 'class' => 'ProfilePhoto')), '</span>';
}
echo '<div class="WhoIs">';
if ($ConnectName && $ConnectSource) {
$NameFormat = T('You are connected as %s through %s.');
} elseif ($ConnectName) {
$NameFormat = T('You are connected as %s.');
} elseif ($ConnectSource) {
$NameFormat = T('You are connected through %2$s.');
} else {
$NameFormat = '';
}
$NameFormat = '%1$s';
echo sprintf($NameFormat, '<span class="Name">' . htmlspecialchars($ConnectName) . '</span>', '<span class="Source">' . htmlspecialchars($ConnectSource) . '</span>');
echo Wrap(T('ConnectCreateAccount', 'Add Info & Create Account'), 'h3');
echo '</div>';
作者:3marproo
项目:vanill
$Col = 0;
foreach ($this->Data('AvailableThemes') as $ThemeName => $ThemeInfo) {
$ScreenName = GetValue('Name', $ThemeInfo, $ThemeName);
$ThemeFolder = GetValue('Folder', $ThemeInfo, '');
$Active = $ThemeFolder == $this->Data('EnabledThemeFolder');
$Version = GetValue('Version', $ThemeInfo, '');
$ThemeUrl = GetValue('Url', $ThemeInfo, '');
$Author = GetValue('Author', $ThemeInfo, '');
$AuthorUrl = GetValue('AuthorUrl', $ThemeInfo, '');
$NewVersion = GetValue('NewVersion', $ThemeInfo, '');
$Upgrade = $NewVersion != '' && version_compare($NewVersion, $Version, '>');
$PreviewUrl = GetValue('MobileScreenshotUrl', $ThemeInfo, FALSE);
$Description = GetValue('Description', $ThemeInfo);
$RequiredApplications = GetValue('RequiredApplications', $ThemeInfo, FALSE);
$ClassCurrentTheme = $EnabledThemeInfo['Index'] == $ThemeInfo['Index'] ? 'current-theme' : '';
$PreviewImageHtml = $PreviewUrl !== FALSE ? Anchor(Img($PreviewUrl, array('alt' => $ScreenName)), $PreviewUrl, '', array('class' => 'theme-image mfp-image')) : '<div class="theme-image"></div>';
$DescriptionHtml = $Description ? '<em class="theme-description">' . $Description . '</em>' : '';
$Col++;
if ($Col == 1) {
$ColClass = 'FirstCol';
echo '<tr>';
} elseif ($Col == 2) {
$ColClass = 'MiddleCol';
} else {
$ColClass = 'LastCol';
$Col = 0;
}
?>
<td class="themeblock <?php
echo $ClassCurrentTheme;
作者:3marproo
项目:vanill
echo Wrap(T('FaviconDescription', "Your site's favicon appears in your browser's title bar. It will be scaled to 16x16 pixels."), 'div', array('class' => 'Info'));
$Favicon = $this->Data('Favicon');
if ($Favicon) {
echo Wrap(Img(Gdn_Upload::Url($Favicon)), 'div');
echo Wrap(Anchor(T('Remove Favicon'), '/dashboard/settings/removefavicon/' . $Session->TransientKey(), 'SmallButton'), 'div', array('style' => 'padding: 10px 0;'));
echo Wrap(T('FaviconBrowse', 'Browse for a new favicon if you would like to change it:'), 'div', array('class' => 'Info'));
} else {
echo Wrap(T('FaviconDescription', "The shortcut icon that shows up in your browser's bookmark menu (16x16 px)."), 'div', array('class' => 'Info'));
}
echo $this->Form->Input('Favicon', 'file');
?>
</li>
<li>
<?php
echo $this->Form->Label('Share Image', 'ShareImage');
echo Wrap(T('ShareImageDescription', "When someone shares a link from your site we try and grab an image from the page. If there isn't an image on the page then we'll use this image instead. The image should be at least 50×50, but we recommend 200×200."), 'div', array('class' => 'Info'));
$ShareImage = $this->Data('ShareImage');
if ($ShareImage) {
echo Wrap(Img(Gdn_Upload::Url($ShareImage), array('style' => 'max-width: 300px')), 'div');
echo Wrap(Anchor(T('Remove Image'), '/dashboard/settings/removeshareimage', 'SmallButton Hijack'), 'div', array('style' => 'padding: 10px 0;'));
echo Wrap(T('FaviconBrowse', 'Browse for a new favicon if you would like to change it:'), 'div', array('class' => 'Info'));
}
echo $this->Form->Input('ShareImage', 'file');
?>
</li>
</ul>
</div>
</div>
<?php
echo '<div class="Buttons">' . $this->Form->Button('Save') . '</div>';
echo $this->Form->Close();
作者:3marproo
项目:vanill
/**
* Format a serialized string of image properties as html.
* @param string $Body a serialized array of image properties (Image, Thumbnail, Caption)
*/
public static function Image($Body)
{
if (is_string($Body)) {
$Image = @unserialize($Body);
if (!$Image) {
return Gdn_Format::Html($Body);
}
}
$Url = GetValue('Image', $Image);
$Caption = Gdn_Format::PlainText(GetValue('Caption', $Image));
return '<div class="ImageWrap">' . '<div class="Image">' . Img($Url, array('alt' => $Caption, 'title' => $Caption)) . '</div>' . '<div class="Caption">' . $Caption . '</div>' . '</div>';
}
作者:embo-h
项目:vanill
/**
* Create or update a comment.
*
* @since 2.0.0
* @access public
*
* @param int $DiscussionID Unique ID to add the comment to. If blank, this method will throw an error.
*/
public function Comment($DiscussionID = '')
{
// Get $DiscussionID from RequestArgs if valid
if ($DiscussionID == '' && count($this->RequestArgs)) {
if (is_numeric($this->RequestArgs[0])) {
$DiscussionID = $this->RequestArgs[0];
}
}
// If invalid $DiscussionID, get from form.
$this->Form->SetModel($this->CommentModel);
$DiscussionID = is_numeric($DiscussionID) ? $DiscussionID : $this->Form->GetFormValue('DiscussionID', 0);
// Set discussion data
$this->DiscussionID = $DiscussionID;
$this->Discussion = $Discussion = $this->DiscussionModel->GetID($DiscussionID);
// Is this an embedded comment being posted to a discussion that doesn't exist yet?
$vanilla_type = $this->Form->GetFormValue('vanilla_type', '');
$vanilla_url = $this->Form->GetFormValue('vanilla_url', '');
$vanilla_category_id = $this->Form->GetFormValue('vanilla_category_id', '');
$Attributes = array('ForeignUrl' => $vanilla_url);
$vanilla_identifier = $this->Form->GetFormValue('vanilla_identifier', '');
// Only allow vanilla identifiers of 32 chars or less - md5 if larger
if (strlen($vanilla_identifier) > 32) {
$Attributes['vanilla_identifier'] = $vanilla_identifier;
$vanilla_identifier = md5($vanilla_identifier);
}
if (!$Discussion && $vanilla_url != '' && $vanilla_identifier != '') {
$Discussion = $Discussion = $this->DiscussionModel->GetForeignID($vanilla_identifier, $vanilla_type);
if ($Discussion) {
$this->DiscussionID = $DiscussionID = $Discussion->DiscussionID;
$this->Form->SetValue('DiscussionID', $DiscussionID);
}
}
// If so, create it!
if (!$Discussion && $vanilla_url != '' && $vanilla_identifier != '') {
// Add these values back to the form if they exist!
$this->Form->AddHidden('vanilla_identifier', $vanilla_identifier);
$this->Form->AddHidden('vanilla_type', $vanilla_type);
$this->Form->AddHidden('vanilla_url', $vanilla_url);
$this->Form->AddHidden('vanilla_category_id', $vanilla_category_id);
$PageInfo = FetchPageInfo($vanilla_url);
if (!($Title = $this->Form->GetFormValue('Name'))) {
$Title = GetValue('Title', $PageInfo, '');
if ($Title == '') {
$Title = T('Undefined discussion subject.');
}
}
$Description = GetValue('Description', $PageInfo, '');
$Images = GetValue('Images', $PageInfo, array());
$LinkText = T('EmbededDiscussionLinkText', 'Read the full story here');
if (!$Description && count($Images) == 0) {
$Body = FormatString('<p><a href="{Url}">{LinkText}</a></p>', array('Url' => $vanilla_url, 'LinkText' => $LinkText));
} else {
$Body = FormatString('
<div class="EmbeddedContent">{Image}<strong>{Title}</strong>
<p>{Excerpt}</p>
<p><a href="{Url}">{LinkText}</a></p>
<div class="ClearFix"></div>
</div>', array('Title' => $Title, 'Excerpt' => $Description, 'Image' => count($Images) > 0 ? Img(GetValue(0, $Images), array('class' => 'LeftAlign')) : '', 'Url' => $vanilla_url, 'LinkText' => $LinkText));
}
if ($Body == '') {
$Body = $vanilla_url;
}
if ($Body == '') {
$Body = T('Undefined discussion body.');
}
// Validate the CategoryID for inserting.
$Category = CategoryModel::Categories($vanilla_category_id);
if (!$Category) {
$vanilla_category_id = C('Vanilla.Embed.DefaultCategoryID', 0);
if ($vanilla_category_id <= 0) {
// No default category defined, so grab the first non-root category and use that.
$vanilla_category_id = $this->DiscussionModel->SQL->Select('CategoryID')->From('Category')->Where('CategoryID >', 0)->Get()->FirstRow()->CategoryID;
// No categories in the db? default to 0
if (!$vanilla_category_id) {
$vanilla_category_id = 0;
}
}
} else {
$vanilla_category_id = $Category['CategoryID'];
}
$EmbedUserID = C('Garden.Embed.UserID');
if ($EmbedUserID) {
$EmbedUser = Gdn::UserModel()->GetID($EmbedUserID);
}
if (!$EmbedUserID || !$EmbedUser) {
$EmbedUserID = Gdn::UserModel()->GetSystemUserID();
}
$EmbeddedDiscussionData = array('InsertUserID' => $EmbedUserID, 'DateInserted' => Gdn_Format::ToDateTime(), 'DateUpdated' => Gdn_Format::ToDateTime(), 'CategoryID' => $vanilla_category_id, 'ForeignID' => $vanilla_identifier, 'Type' => $vanilla_type, 'Name' => $Title, 'Body' => $Body, 'Format' => 'Html', 'Attributes' => serialize($Attributes));
$this->EventArguments['Discussion'] = $EmbeddedDiscussionData;
$this->FireEvent('BeforeEmbedDiscussion');
$DiscussionID = $this->DiscussionModel->SQL->Insert('Discussion', $EmbeddedDiscussionData);
$ValidationResults = $this->DiscussionModel->ValidationResults();
//.........这里部分代码省略.........
作者:seedban
项目:old-rep
?>
</h1>
<?php
echo $this->Form->Open(array('enctype' => 'multipart/form-data'));
echo $this->Form->Errors();
?>
<ul>
<li>
<?php
echo $this->Form->Label('Banner Title', 'Garden.Title');
echo Wrap(T('The banner title appears on the top-left of every page. If a banner logo is uploaded, it will replace the banner title on user-facing forum pages.'), 'div', array('class' => 'Info'));
echo $this->Form->TextBox('Garden.Title');
?>
</li>
<li>
<?php
echo $this->Form->Label('Banner Logo', 'Garden.Logo');
$Logo = $this->Data('Logo');
if ($Logo) {
echo Wrap(Img(Gdn_Upload::Url($Logo)), 'div');
echo Wrap(Anchor(T('Remove Banner Logo'), '/dashboard/settings/removelogo/' . $Session->TransientKey(), 'SmallButton'), 'div', array('style' => 'padding: 10px 0;'));
echo Wrap(T('Browse for a new banner logo if you would like to change it:'), 'div', array('class' => 'Info'));
} else {
echo Wrap(T('The banner logo appears at the top of your forum.'), 'div', array('class' => 'Info'));
}
echo $this->Form->Input('Logo', 'file');
?>
</li>
</ul>
<?php
echo $this->Form->Close('Save');
作者:ru
项目:arabbnot
function ThumbnailImage($Data, $Attributes = False)
{
if (function_exists('Debug') && Debug()) {
Deprecated(__FUNCTION__, 'Thumbnail');
}
$Width = ArrayValue('width', $Attributes, '');
$Height = ArrayValue('height', $Attributes, '');
if (Is_Array($Data)) {
// group, todo
// <ul><li><a></a></li>
}
$Prefix = substr($Data, 0, 7);
//if(In_Array($Prefix, array('http://', 'https:/'))) {}
//$bLocalImage = False;
if ($Prefix != 'http://') {
//$bLocalImage = True;
$IncomingImage = $Data;
$ImageFindPaths[] = 'uploads' . DS . $Data;
$ImageFindPaths[] = $Data;
foreach ($ImageFindPaths as $File) {
if (file_exists($File) && is_file($File)) {
$IncomingImage = $File;
break;
}
}
} else {
$IncomingImage = $Data;
}
$CacheDirectory = 'uploads/cached';
if (!is_writable($CacheDirectory)) {
mkdir($CacheDirectory, 0777, True);
if (!is_writable($CacheDirectory)) {
$ErrorMessage = ErrorMessage(sprintf(T('Directory (%s) is not writable.'), $CacheDirectory), 'PHP', __FUNCTION__);
trigger_error($ErrorMessage, E_USER_ERROR);
return '';
}
}
$Name = CleanupString(pathinfo($IncomingImage, PATHINFO_FILENAME) . ' ' . $Width . ' ' . $Height);
$Extension = FileExtension($IncomingImage);
$Target = $CacheDirectory . DS . $Name . '.' . $Extension;
if (!file_exists($Target)) {
Gdn_UploadImage::SaveImageAs($IncomingImage, $Target, $Height, $Width);
}
$Target = str_replace(DS, '/', $Target);
if (!array_key_exists('alt', $Attributes)) {
$Attributes['alt'] = pathinfo($Name, PATHINFO_FILENAME);
}
list($Width, $Height, $Type) = GetImageSize($IncomingImage);
$Attributes['alt'] .= sprintf(' (%d×%d)', $Width, $Height);
$Image = Img($Target, $Attributes);
return Anchor($Image, Url($IncomingImage), '', '', True);
}
作者:bishop
项目:vanill
public function FetchPageInfo($Url, $ThrowError = FALSE)
{
$PageInfo = FetchPageInfo($Url, 3, $ThrowError);
$Title = GetValue('Title', $PageInfo, '');
if ($Title == '') {
if ($ThrowError) {
throw new Gdn_UserException(T("The page didn't contain any information."));
}
$Title = FormatString(T('Undefined discussion subject.'), array('Url' => $Url));
} else {
if ($Strip = C('Vanilla.Embed.StripPrefix')) {
$Title = StringBeginsWith($Title, $Strip, TRUE, TRUE);
}
if ($Strip = C('Vanilla.Embed.StripSuffix')) {
$Title = StringEndsWith($Title, $Strip, TRUE, TRUE);
}
}
$Title = trim($Title);
$Description = GetValue('Description', $PageInfo, '');
$Images = GetValue('Images', $PageInfo, array());
$Body = FormatString(T('EmbeddedDiscussionFormat'), array('Title' => $Title, 'Excerpt' => $Description, 'Image' => count($Images) > 0 ? Img(GetValue(0, $Images), array('class' => 'LeftAlign')) : '', 'Url' => $Url));
if ($Body == '') {
$Body = $ForeignUrl;
}
if ($Body == '') {
$Body = FormatString(T('EmbeddedNoBodyFormat.'), array('Url' => $Url));
}
$Result = array('Name' => $Title, 'Body' => $Body, 'Format' => 'Html');
return $Result;
}
作者:unligh
项目:UsefulFunction
function FlashObject($Movie, $Attributes = array(), $FlashVars = False)
{
//static $Defaults = array('allowfullscreen' => 'true', 'allowscriptaccess' => 'always', 'quality' => 'best', 'menu' => 'false');
//$Attributes = array_merge($Defaults, $Attributes);
$ScriptRender = GetValue('ScriptRender', $Attributes, False, True);
$FlashVars = GetValue('FlashVars', $Attributes, $FlashVars, True);
$Params = GetValue('Params', $Attributes, array(), True);
$Movie = Asset($Movie, True);
$AltContent = GetValue('AltContent', $Attributes, Anchor(Img('http://wwwimages.adobe.com/www.adobe.com/images/shared/download_buttons/get_flash_player.gif', array('alt' => 'Get Adobe Flash player')), 'http://www.adobe.com/go/getflashplayer', '', array('rel' => 'nofollow'), True), True);
foreach (array('wmode', 'allowfullscreen', 'allowscriptaccess', 'quality', 'menu') as $Name) {
$Value = GetValue($Name, $Attributes, False, True);
if ($Value !== False) {
$Params[$Name] = $Value;
}
}
if (!array_key_exists('width', $Attributes) || !array_key_exists('height', $Attributes)) {
$ImageInfo = GetImageSize($Movie);
TouchValue('width', $Attributes, $ImageInfo[0]);
TouchValue('height', $Attributes, $ImageInfo[1]);
}
$Attributes['type'] = 'application/x-shockwave-flash';
$Attributes['data'] = $Movie;
$HtmlParams = Wrap('', 'param', array('name' => 'movie', 'value' => $Movie));
foreach ($Params as $Name => $Value) {
$HtmlParams .= Wrap('', 'param', array('name' => $Name, 'value' => $Value));
}
if (is_array($FlashVars)) {
foreach ($FlashVars as $Name => $Value) {
$Variables[] = $Name . '=' . urlencode($Value);
}
}
if (isset($Variables)) {
$HtmlParams .= Wrap('', 'param', array('name' => 'flashvars', 'value' => implode('&', $Variables)));
}
/* $Agent = ArrayValue('HTTP_USER_AGENT', $_SERVER);
if ($Agent != False && stripos($Agent, 'MSIE ') > 0) {
$Attributes['classid'] = 'clsid:d27cdb6e-ae6d-11cf-96b8-444553540000';
}*/
$Return = Wrap($HtmlParams . $AltContent, 'object', $Attributes);
//d($Return);
if ($ScriptRender) {
$Return = JavaScript($Return, True);
}
return $Return;
}