本文整理汇总了PHP中Gdn_Controller::AddSideMenu方法的典型用法代码示例。如果您正苦于以下问题:PHP Gdn_Controller::AddSideMenu方法的具体用法?PHP Gdn_Controller::AddSideMenu怎么用?PHP Gdn_Controller::AddSideMenu使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gdn_Controller
的用法示例。
在下文中一共展示了Gdn_Controller::AddSideMenu方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: SettingsController_CustomizeText_Create
/**
* Add the customize text page to the dashboard.
*
* @param Gdn_Controller $Sender
*/
public function SettingsController_CustomizeText_Create($Sender)
{
$Sender->Permission('Garden.Settings.Manage');
$Sender->AddSideMenu('settings/customizetext');
$Sender->AddJsFile('jquery.autogrow.js');
$Sender->Title('Customize Text');
$Directive = GetValue(0, $Sender->RequestArgs, '');
$View = 'customizetext';
if ($Directive == 'rebuild') {
$View = 'rebuild';
} elseif ($Directive == 'rebuildcomplete') {
$View = 'rebuildcomplete';
}
$Method = 'none';
if ($Sender->Form->IsPostback()) {
$Method = 'search';
if ($Sender->Form->GetValue('Save_All')) {
$Method = 'save';
}
}
$Matches = array();
$Keywords = NULL;
switch ($Method) {
case 'none':
break;
case 'search':
case 'save':
$Keywords = strtolower($Sender->Form->GetValue('Keywords'));
if ($Method == 'search') {
$Sender->Form->ClearInputs();
$Sender->Form->SetFormValue('Keywords', $Keywords);
}
$Definitions = Gdn::Locale()->GetDeveloperDefinitions();
$CountDefinitions = sizeof($Definitions);
$Sender->SetData('CountDefinitions', $CountDefinitions);
$Changed = FALSE;
foreach ($Definitions as $Key => $BaseDefinition) {
$KeyHash = md5($Key);
$ElementName = "def_{$KeyHash}";
// Look for matches
$k = strtolower($Key);
$d = strtolower($BaseDefinition);
// If this key doesn't match, skip it
if ($Keywords != '*' && !(strlen($Keywords) > 0 && (strpos($k, $Keywords) !== FALSE || strpos($d, $Keywords) !== FALSE))) {
continue;
}
$Modified = FALSE;
// Found a definition, look it up in the real locale first, to see if it has been overridden
$CurrentDefinition = Gdn::Locale()->Translate($Key, FALSE);
if ($CurrentDefinition !== FALSE && $CurrentDefinition != $BaseDefinition) {
$Modified = TRUE;
} else {
$CurrentDefinition = $BaseDefinition;
}
$Matches[$Key] = array('def' => $CurrentDefinition, 'mod' => $Modified);
if ($CurrentDefinition[0] == "\r\n") {
$CurrentDefinition = "\r\n{$CurrentDefinition}";
} else {
if ($CurrentDefinition[0] == "\r") {
$CurrentDefinition = "\r{$CurrentDefinition}";
} else {
if ($CurrentDefinition[0] == "\n") {
$CurrentDefinition = "\n{$CurrentDefinition}";
}
}
}
if ($Method == 'save') {
$SuppliedDefinition = $Sender->Form->GetValue($ElementName);
// Has this field been changed?
if ($SuppliedDefinition != FALSE && $SuppliedDefinition != $CurrentDefinition) {
// Changed from what it was, but is it a change from the *base* value?
$SaveDefinition = $SuppliedDefinition != $BaseDefinition ? $SuppliedDefinition : NULL;
if (!is_null($SaveDefinition)) {
$CurrentDefinition = $SaveDefinition;
$SaveDefinition = str_replace("\r\n", "\n", $SaveDefinition);
}
Gdn::Locale()->SetTranslation($Key, $SaveDefinition, array('Save' => TRUE, 'RemoveEmpty' => TRUE));
$Matches[$Key] = array('def' => $SuppliedDefinition, 'mod' => !is_null($SaveDefinition));
$Changed = TRUE;
}
}
$Sender->Form->SetFormValue($ElementName, $CurrentDefinition);
}
if ($Changed) {
$Sender->InformMessage("Locale changes have been saved!");
}
break;
}
$Sender->SetData('Matches', $Matches);
$CountMatches = sizeof($Matches);
$Sender->SetData('CountMatches', $CountMatches);
$Sender->Render($View, '', 'plugins/CustomizeText');
}
示例2: Controller_Edit
/**
* Edit a Tag
*
* @param Gdn_Controller $Sender
*/
public function Controller_Edit($Sender)
{
$Sender->AddSideMenu('settings/tagging');
$Sender->Title(T('Edit Tag'));
$TagID = GetValue(1, $Sender->RequestArgs);
// Set the model on the form.
$TagModel = new TagModel();
$Sender->Form->SetModel($TagModel);
$Tag = $TagModel->GetID($TagID);
$Sender->Form->SetData($Tag);
// Make sure the form knows which item we are editing.
$Sender->Form->AddHidden('TagID', $TagID);
if ($Sender->Form->AuthenticatedPostBack()) {
// Make sure the tag is valid
$TagData = $Sender->Form->GetFormValue('Name');
if (!TagModel::ValidateTag($TagData)) {
$Sender->Form->AddError('@' . T('ValidateTag', 'Tags cannot contain commas.'));
}
// Make sure that the tag name is not already in use.
if ($TagModel->GetWhere(array('TagID <>' => $TagID, 'Name' => $TagData))->NumRows() > 0) {
$Sender->SetData('MergeTagVisible', TRUE);
if (!$Sender->Form->GetFormValue('MergeTag')) {
$Sender->Form->AddError('The specified tag name is already in use.');
}
}
if ($Sender->Form->Save()) {
$Sender->InformMessage(T('Your changes have been saved.'));
}
}
$Sender->Render('addedit', '', 'plugins/Tagging');
}
示例3: SettingsController_Tagging_Create
/**
* Tag management (let admins rename tags, remove tags, etc).
* TODO: manage the Plugins.Tagging.Required boolean setting that makes tagging required or not.
* @param Gdn_Controller $Sender
*/
public function SettingsController_Tagging_Create($Sender, $Args) {
$Sender->Permission('Garden.Settings.Manage');
$Sender->Title('Tagging');
$Sender->AddSideMenu('settings/tagging');
$Sender->AddCSSFile('plugins/Tagging/design/tagadmin.css');
$Sender->AddJSFile('plugins/Tagging/admin.js');
$SQL = Gdn::SQL();
list($Offset, $Limit) = OffsetLimit($Sender->Request->Get('Page'), 100);
$Sender->SetData('_Limit', $Limit);
$Sender->SetData('Tags', $SQL
->Select('t.*')
->From('Tag t')
->OrderBy('t.Name', 'asc')
->OrderBy('t.CountDiscussions', 'desc')
->Limit($Limit, $Offset)
->Get()->ResultArray());
$Sender->SetData('RecordCount', $SQL->GetCount('Tag'));
$Sender->Render('Tagging', '', 'plugins/Tagging');
}