本文整理汇总了PHP中Gdn::Factory方法的典型用法代码示例。如果您正苦于以下问题:PHP Gdn::Factory方法的具体用法?PHP Gdn::Factory怎么用?PHP Gdn::Factory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gdn
的用法示例。
在下文中一共展示了Gdn::Factory方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: delete
/**
* Delete a single draft.
*
* Redirects user back to Index unless DeliveryType is set.
*
* @since 2.0.0
* @access public
*
* @param int $DraftID Unique ID of draft to be deleted.
* @param string $TransientKey Single-use hash to prove intent.
*/
public function delete($DraftID = '', $TransientKey = '')
{
$Form = Gdn::Factory('Form');
$Session = Gdn::session();
if (is_numeric($DraftID) && $DraftID > 0) {
$Draft = $this->DraftModel->getID($DraftID);
}
if ($Draft) {
if ($Session->validateTransientKey($TransientKey) && (val('InsertUserID', $Draft) == $Session->UserID || checkPermission('Garden.Community.Manage'))) {
// Delete the draft
if (!$this->DraftModel->delete($DraftID)) {
$Form->addError('Failed to delete draft');
}
} else {
throw permissionException('Garden.Community.Manage');
}
} else {
throw notFoundException('Draft');
}
// Redirect
if ($this->_DeliveryType === DELIVERY_TYPE_ALL) {
$Target = GetIncomingValue('Target', '/drafts');
redirect($Target);
}
// Return any errors
if ($Form->errorCount() > 0) {
$this->setJson('ErrorMessage', $Form->errors());
}
// Render default view
$this->render();
}
示例2: Set
/**
* Allows the setting of data into one of two serialized data columns on the
* user table: Preferences and Attributes. The method expects "Name" &
* "Value" to be in the $_POST collection. This method always saves to the
* row of the user id performing this action (ie. $Session->UserID). The
* type of property column being saved should be specified in the url:
* ie. /dashboard/utility/set/preference/name/value/transientKey
* or /dashboard/utility/set/attribute/name/value/transientKey
*
* @param string The type of value being saved: preference or attribute.
* @param string The name of the property being saved.
* @param string The value of the property being saved.
* @param string A unique transient key to authenticate that the user intended to perform this action.
*/
public function Set($UserPropertyColumn = '', $Name = '', $Value = '', $TransientKey = '') {
$this->_DeliveryType = DELIVERY_TYPE_BOOL;
$Session = Gdn::Session();
$Success = FALSE;
if (
in_array($UserPropertyColumn, array('preference', 'attribute'))
&& $Name != ''
&& $Value != ''
&& $Session->UserID > 0
&& $Session->ValidateTransientKey($TransientKey)
) {
$UserModel = Gdn::Factory("UserModel");
$Method = $UserPropertyColumn == 'preference' ? 'SavePreference' : 'SaveAttribute';
$Success = $UserModel->$Method($Session->UserID, $Name, $Value) ? 'TRUE' : 'FALSE';
}
if (!$Success)
$this->Form->AddError('ErrorBool');
// Redirect back where the user came from if necessary
if ($this->_DeliveryType == DELIVERY_TYPE_ALL)
Redirect($_SERVER['HTTP_REFERER']);
else
$this->Render();
}
示例3: __construct
public function __construct(&$Sender = '')
{
$Session = Gdn::Session();
if (property_exists($Sender, 'Conversation')) {
$this->Conversation = $Sender->Conversation;
}
$this->Form = Gdn::Factory('Form', 'AddPeople');
// $this->Form->Action = $Sender->SelfUrl;
// If the form was posted back, check for people to add to the conversation
if ($this->Form->AuthenticatedPostBack()) {
$NewRecipientUserIDs = array();
$NewRecipients = explode(',', $this->Form->GetFormValue('AddPeople', ''));
$UserModel = Gdn::Factory("UserModel");
foreach ($NewRecipients as $Name) {
if (trim($Name) != '') {
$User = $UserModel->GetByUsername(trim($Name));
if (is_object($User)) {
$NewRecipientUserIDs[] = $User->UserID;
}
}
}
$Sender->ConversationModel->AddUserToConversation($this->Conversation->ConversationID, $NewRecipientUserIDs);
// if ($Sender->DeliveryType() == DELIVERY_TYPE_ALL)
// Redirect('/messages/'.$this->Conversation->ConversationID);
$Sender->StatusMessage = T('Your changes were saved.');
$Sender->RedirectUrl = Url('/messages/' . $this->Conversation->ConversationID);
}
$this->_ApplicationFolder = $Sender->Application;
$this->_ThemeFolder = $Sender->Theme;
}
示例4: PluginController_LoadUp_Create
public function PluginController_LoadUp_Create(&$Sender)
{
$Sender->AddSideMenu('dashboard/plugin/loadup');
$Sender->Permission('Plugins.Garden.LoadUp.Allow');
if (!property_exists($Sender, 'Form')) {
$Sender->Form = Gdn::Factory('Form');
}
$Sender->AddJsFile('jquery.livequery.js');
$Sender->AddJsFile('jquery.autogrow.js');
$Sender->AddJsFile('plugins/LoadUp/loadup.js');
$Session = Gdn::Session();
if ($Sender->Form->AuthenticatedPostBack() != False) {
$UploadTo = $Sender->Form->GetFormValue('UploadTo');
if (!$UploadTo) {
$UploadTo = 'uploads/i/' . date('Y') . '/' . date('m');
}
$bOverwrite = $Sender->Form->GetFormValue('Overwrite') && $Session->CheckPermission('Plugins.Garden.LoadUp.Overwrite');
$Options = array('Overwrite' => $bOverwrite, 'WebTarget' => True);
$UploadedFiles = UploadFile($UploadTo, 'Files', $Options);
$Sender->Form->SetFormValue('RawData', implode("\n", $UploadedFiles));
$Sender->Form->SetFormValue('AbsoluteURL', 1);
}
$Sender->UploadTo = array('uploads/tmp' => 'uploads/tmp');
$Sender->View = $this->GetView('index.php');
$Sender->Title(T('Upload File'));
$Sender->Render();
}
示例5: SettingsController_AutoExpire_Create
public function SettingsController_AutoExpire_Create($Sender)
{
$Sender->Permission('Garden.Settings.Manage');
$Sender->Form = Gdn::Factory('Form');
if ($Sender->Form->IsPostBack() != False) {
$Minutes = $Sender->Form->GetValue('AutoExpirePeriod_Minutes');
$Hours = $Sender->Form->GetValue('AutoExpirePeriod_Hours');
$Days = $Sender->Form->GetValue('AutoExpirePeriod_Days');
$Months = $Sender->Form->GetValue('AutoExpirePeriod_Months');
$Years = $Sender->Form->GetValue('AutoExpirePeriod_Years');
if (!(empty($Minutes) && empty($Hours) && empty($Days) && empty($Months) && empty($Years))) {
$Sender->Form->SetFormValue('AutoExpirePeriod', "+{$Years} years {$Months} months {$Days} days {$Hours} hours {$Minutes} minutes");
} else {
$Sender->Form->SetFormValue('AutoExpirePeriod', null);
}
$FormValues = $Sender->Form->FormValues();
Gdn::SQL()->Put('Category', array('AutoExpirePeriod' => $FormValues['AutoExpirePeriod']), array('CategoryID' => $FormValues['CategoryID']));
if (strtolower($FormValues['AutoExpireRetro']) == 'yes') {
Gdn::SQL()->Put('Discussion', array('AutoExpire' => 1), array('CategoryID' => $FormValues['CategoryID']));
}
}
$CategoryModel = new CategoryModel();
$CategoryFull = $CategoryModel->GetFull();
$CatsExpire = array();
foreach ($CategoryFull as $Category) {
$CatsExpire[$Category->CategoryID] = $Category->AutoExpirePeriod;
}
$Sender->SetData('CatsExpire', json_encode($CatsExpire));
$Sender->AddSideMenu();
$Sender->SetData('Title', T('AutoExpireDiscussions.Title', 'Auto Expire Discussions'));
$Sender->SetData('Description', $this->PluginInfo['Description']);
$Sender->Render('Settings', '', 'plugins/AutoExpireDiscussions');
}
示例6: Delete
/**
* Delete a single draft.
*
* Redirects user back to Index unless DeliveryType is set.
*
* @since 2.0.0
* @access public
*
* @param int $DraftID Unique ID of draft to be deleted.
* @param string $TransientKey Single-use hash to prove intent.
*/
public function Delete($DraftID = '', $TransientKey = '')
{
$Form = Gdn::Factory('Form');
$Session = Gdn::Session();
if (is_numeric($DraftID) && $DraftID > 0 && $Session->UserID > 0 && $Session->ValidateTransientKey($TransientKey)) {
// Delete the draft
$Draft = $this->DraftModel->GetID($DraftID);
if ($Draft && !$this->DraftModel->Delete($DraftID)) {
$Form->AddError('Failed to delete discussion');
}
} else {
// Log an error
$Form->AddError('ErrPermission');
}
// Redirect
if ($this->_DeliveryType === DELIVERY_TYPE_ALL) {
$Target = GetIncomingValue('Target', '/vanilla/drafts');
Redirect($Target);
}
// Return any errors
if ($Form->ErrorCount() > 0) {
$this->SetJson('ErrorMessage', $Form->Errors());
}
// Render default view
$this->Render();
}
示例7: smarty_function_searchbox
/**
* Writes the search box to the page.
*
* @param array The parameters passed into the function. This currently takes no parameters.
* @param Smarty The smarty object rendering the template.
* @return The url.
*/
function smarty_function_searchbox($Params, &$Smarty)
{
$Form = Gdn::Factory('Form');
$Form->InputPrefix = '';
$Result = $Form->Open(array('action' => Url('/search'), 'method' => 'get')) . $Form->TextBox('Search', array('placeholder' => T('Search'))) . $Form->Button('Go', array('Name' => '')) . $Form->Close();
return $Result;
}
示例8: _AddCLEditor
private function _AddCLEditor($Sender) {
// Turn off safestyles so the inline styles get applied to comments
$Config = Gdn::Factory(Gdn::AliasConfig);
$Config->Set('Garden.Html.SafeStyles', FALSE);
// Add the CLEditor to the form
$Sender->RemoveJsFile('jquery.autogrow.js');
$Sender->AddJsFile('jquery.cleditor.min.js', 'plugins/cleditor');
$Sender->AddCssFile('jquery.cleditor.css', 'plugins/cleditor');
$Sender->Head->AddString('
<style type="text/css">
a.PreviewButton {
display: none !important;
}
</style>
<script type="text/javascript">
jQuery(document).ready(function($) {
// Make sure the removal of autogrow does not break anything
jQuery.fn.autogrow = function(o) { return; }
// Attach the editor to comment boxes
jQuery("#Form_Body").livequery(function() {
var frm = $(this).parents("div.CommentForm");
ed = jQuery(this).cleditor({width:"100%", height:"100%"})[0];
this.editor = ed; // Support other plugins!
jQuery(frm).bind("clearCommentForm", {editor:ed}, function(e) {
frm.find("textarea").hide();
e.data.editor.clear();
});
});
})(jQuery);
</script>');
}
示例9: isRemovable
/**
* Is the application/plugin/theme removable?
*
* @param string $Type self::TYPE_APPLICATION or self::TYPE_PLUGIN or self::TYPE_THEME
* @param string $Name
* @return boolean
*/
public static function isRemovable($Type, $Name)
{
switch ($Type) {
case self::TYPE_APPLICATION:
$ApplicationManager = Gdn::Factory('ApplicationManager');
if ($IsRemovable = !array_key_exists($Name, $ApplicationManager->EnabledApplications())) {
$ApplicationInfo = arrayValue($Name, $ApplicationManager->AvailableApplications(), array());
$ApplicationFolder = arrayValue('Folder', $ApplicationInfo, '');
$IsRemovable = IsWritable(PATH_APPLICATIONS . DS . $ApplicationFolder);
}
break;
case self::TYPE_PLUGIN:
if ($IsRemovable = !array_key_exists($Name, Gdn::pluginManager()->EnabledPlugins())) {
$PluginInfo = arrayValue($Name, Gdn::pluginManager()->AvailablePlugins(), false);
$PluginFolder = arrayValue('Folder', $PluginInfo, false);
$IsRemovable = IsWritable(PATH_PLUGINS . DS . $PluginFolder);
}
break;
case self::TYPE_THEME:
// TODO
$IsRemovable = false;
break;
}
return $IsRemovable;
}
示例10: smarty_function_searchbox
/**
* Writes the search box to the page.
*
* @param array The parameters passed into the function. This currently takes no parameters.
* @param Smarty The smarty object rendering the template.
* @return The url.
*/
function smarty_function_searchbox($Params, &$Smarty)
{
$Placeholder = array_key_exists('placeholder', $Params) ? GetValue('placeholder', $Params, '', TRUE) : T('SearchBoxPlaceHolder', 'Search');
$Form = Gdn::Factory('Form');
$Form->InputPrefix = '';
$Result = $Form->Open(array('action' => Url('/search'), 'method' => 'get')) . $Form->TextBox('Search', array('placeholder' => $Placeholder)) . $Form->Button('Go', array('Name' => '')) . $Form->Close();
return $Result;
}
示例11: __construct
public function __construct()
{
parent::__construct();
$Form = Gdn::Factory('Form');
$Form->Method = 'get';
$Form->InputPrefix = '';
$this->Form = $Form;
}
示例12: CreateSection
protected function CreateSection($RowID, $PostValues)
{
$SectionModel = Gdn::Factory('SectionModel');
$NodeFields = array('Name' => $PostValues['Title'], 'Url' => GetValue('URI', $PostValues, Null), 'RequestUri' => 'candy/content/page/' . $RowID);
$SectionModel->AutoIncrement($RowID);
$ParentSectionID = GetValue('SectionID', $PostValues);
$PageSectionID = $SectionModel->InsertNode($ParentSectionID, $NodeFields);
$this->SQL->Update($this->Name)->Set('SectionID', $PageSectionID)->Where($this->PrimaryKey, $RowID)->Put();
}
示例13: __construct
/**
* Object instantiation & form prep.
*/
public function __construct()
{
parent::__construct();
// Object instantiation
$this->SearchModel = new SearchModel();
$Form = Gdn::Factory('Form');
// Form prep
$Form->Method = 'get';
$this->Form = $Form;
}
示例14: xHtml
function xHtml($String)
{
$HtmlFormatter = Gdn::Factory('HtmlFormatter');
if ($HtmlFormatter) {
$String = $HtmlFormatter->Format($String);
} else {
$String = Gdn_Format::Text($String);
}
return $String;
}
示例15: Refresh
public function Refresh()
{
$LocalName = $this->Current();
$ApplicationManager = Gdn::Factory('ApplicationManager');
$ApplicationWhiteList = $ApplicationManager->EnabledApplicationFolders();
$PluginManager = Gdn::Factory('PluginManager');
$PluginWhiteList = $PluginManager->EnabledPluginFolders();
$ForceRemapping = TRUE;
$this->Set($LocalName, $ApplicationWhiteList, $PluginWhiteList, $ForceRemapping);
}