本文整理汇总了PHP中Gdn::Regarding方法的典型用法代码示例。如果您正苦于以下问题:PHP Gdn::Regarding方法的具体用法?PHP Gdn::Regarding怎么用?PHP Gdn::Regarding使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gdn
的用法示例。
在下文中一共展示了Gdn::Regarding方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Controller_Awesome
/**
* Handle awesome actions
*
* @param mixed $Sender
*/
public function Controller_Awesome($Sender)
{
if (!($UserID = Gdn::Session()->UserID)) {
throw new Exception(T('Cannot report content while not logged in.'));
}
$UserName = Gdn::Session()->User->Name;
$Arguments = $Sender->RequestArgs;
if (sizeof($Arguments) != 4) {
throw new Exception(sprintf(T("Incorrect arg-count. Doesn't look like a legit request. Got %s arguments, expected 4."), sizeof($Arguments)));
}
list($EventType, $Context, $ElementID, $EncodedURL) = $Arguments;
$URL = base64_decode(str_replace('-', '=', $EncodedURL));
$ReportElementModelName = ucfirst($Context) . 'Model';
if (!class_exists($ReportElementModelName)) {
throw new Exception(T('Cannot report on an entity with no model.'));
}
// Ok we're good to go for sure now
$ReportElementModel = new $ReportElementModelName();
$ReportElement = $ReportElementModel->GetID($ElementID);
$ElementTitle = Gdn_Format::Text(GetValue('Name', $ReportElement, NULL), FALSE);
$ElementExcerpt = Gdn_Format::Text(GetValue('Body', $ReportElement, NULL), FALSE);
if (!is_null($ElementExcerpt)) {
$Original = strlen($ElementExcerpt);
$ElementExcerpt = substr($ElementExcerpt, 0, 140);
if ($Original > strlen($ElementExcerpt)) {
$ElementExcerpt .= "...";
}
}
if (is_null($ElementTitle)) {
$ElementTitle = $ElementExcerpt;
}
$ElementShortTitle = strlen($ElementTitle) <= 143 ? $ElementTitle : substr($ElementTitle, 0, 140) . '...';
$ElementAuthorID = GetValue('InsertUserID', $ReportElement);
$ElementAuthor = Gdn::UserModel()->GetID($ElementAuthorID);
$ElementAuthorName = GetValue('Name', $ElementAuthor);
$ReportingData = array('Context' => $Context, 'ElementID' => $ElementID, 'ElementTitle' => $ElementTitle, 'ElementExcerpt' => $ElementExcerpt, 'ElementAuthor' => $ElementAuthor, 'URL' => $URL, 'UserID' => $UserID, 'UserName' => $UserName);
$RegardingAction = C('Plugins.Reporting.AwesomeAction', FALSE);
$RegardingActionSupplement = C('Plugins.Reporting.AwesomeActionSupplement', FALSE);
if ($Sender->Form->AuthenticatedPostBack()) {
$RegardingTitle = sprintf(T("Awesome: '{RegardingTitle}' by %s"), $ElementAuthorName);
$Regarding = Gdn::Regarding()->That($Context, $ElementID, $ReportElement)->ItsAwesome()->ForCollaboration($RegardingAction, $RegardingActionSupplement)->Entitled($RegardingTitle)->From(Gdn::Session()->UserID)->Because($Sender->Form->GetValue('Plugin.Reporting.Reason'))->Located(TRUE)->Commit();
$Sender->InformMessage('<span class="InformSprite Heart"></span>' . T('Your suggestion has been registered. Thankyou!'), 'HasSprite Dismissable AutoDismiss');
}
$Sender->SetData('Plugin.Reporting.Data', $ReportingData);
$Sender->Render($this->GetView('awesome.php'));
}
示例2:
Gdn::FactoryInstall(Gdn::AliasSession, 'Gdn_Session');
Gdn::FactoryInstall(Gdn::AliasAuthenticator, 'Gdn_Auth');
// Dispatcher.
Gdn::FactoryInstall(Gdn::AliasRouter, 'Gdn_Router');
Gdn::FactoryInstall(Gdn::AliasDispatcher, 'Gdn_Dispatcher');
// Smarty Templating Engine
Gdn::FactoryInstall('Smarty', 'Smarty', PATH_LIBRARY . '/vendors/Smarty-2.6.25/libs/Smarty.class.php');
Gdn::FactoryInstall('ViewHandler.tpl', 'Gdn_Smarty');
// Slice handler
Gdn::FactoryInstall(Gdn::AliasSlice, 'Gdn_Slice');
// Remote Statistics
Gdn::FactoryInstall('Statistics', 'Gdn_Statistics', NULL, Gdn::FactorySingleton);
Gdn::Statistics();
// Regarding
Gdn::FactoryInstall('Regarding', 'Gdn_Regarding', NULL, Gdn::FactorySingleton);
Gdn::Regarding();
// Other objects.
Gdn::FactoryInstall('Dummy', 'Gdn_Dummy');
/**
* Extension Startup
*
* Allow installed Extensions (Applications, Themes, Plugins) to execute startup
* and bootstrap procedures that they may have, here.
*/
// Applications startup
foreach (Gdn::ApplicationManager()->EnabledApplicationFolders() as $ApplicationName => $ApplicationFolder) {
// Include the application's bootstrap.
$Gdn_Path = PATH_APPLICATIONS . "/{$ApplicationFolder}/settings/bootstrap.php";
if (file_exists($Gdn_Path)) {
include_once $Gdn_Path;
}