public function Edit($Reference = '') { //$this->AddJsFile('jquery.autocomplete.pack.js'); $this->AddJsFile('jquery.textpandable.js'); $this->AddJsFile('editform.js'); $this->Form->SetModel($this->PageModel); $Session = Gdn::Session(); $SectionModel = new SectionModel(); $this->Tree = $SectionModel->DropDownArray('Name', $SectionModel->GetNodes(array('Depth >' => 0))); $this->FormatOptions = LocalizedOptions(array('Text', 'xHtml', 'Html', 'Markdown', 'Raw')); if (!$Session->CheckPermission('Candy.Pages.Raw')) { unset($this->FormatOptions['Raw']); } $this->EventArguments['FormatOptions'] =& $this->FormatOptions; $this->FireEvent('FormatOptions'); $Content = False; if ($Reference != '') { $Content = $this->PageModel->GetID($Reference); if (!IsContentOwner($Content, 'Candy.Pages.Edit')) { $Content = False; } if ($Content) { $this->Form->AddHidden('PageID', $Content->PageID); $this->Form->SetData($Content); $this->Editing = True; } } if (!$Content) { $this->Permission('Candy.Pages.Add'); } if ($this->Form->AuthenticatedPostBack()) { if ($this->Form->ButtonExists('Delete')) { $this->PageModel->Delete($Content->PageID); $this->InformMessage(T('Page deleted'), array('Sprite' => 'SkullBones', 'CssClass' => 'Dismissable AutoDismiss')); } else { $SavedID = $this->Form->Save($Content); if ($SavedID) { $Message = LocalizedMessage('Saved. You can check it here: %s', Anchor($this->Form->GetFormValue('Title'), 'content/page/' . $SavedID)); $this->InformMessage($Message, array('Sprite' => 'Check', 'CssClass' => 'Dismissable')); } } } else { $URI = trim(GetIncomingValue('URI'), '/'); if ($URI) { $this->Form->SetValue('URI', $URI); } } $this->SetData('Content', $Content, True); $this->Title(ConcatSep(' - ', T('Page'), GetValue('Title', $Content))); $this->Render(); }
<h1><?php echo $this->Data('Title'); ?> </h1> <?php include $this->FetchViewLocation('menu', 'candy'); ?> <?php echo $this->Form->Open(); echo $this->Form->Errors(); ?> <ul class="EditForm"> <li> <?php echo Wrap($this->Form->Label('Name', 'Name') . $this->Form->TextBox('Name'), 'li'); echo Wrap($this->Form->Label('@URL', 'Url') . $this->Form->TextBox('Url'), 'li'); $FormatOptions = LocalizedOptions(array('Text', 'xHtml', 'Html', 'Markdown', 'Raw')); $this->EventArguments['FormatOptions'] =& $FormatOptions; $this->FireEvent('FormatOptions'); echo Wrap($this->Form->Label('Format', 'Format') . $this->Form->DropDown('Format', $FormatOptions), 'li'); echo Wrap($this->Form->TextBox('Body', array('Multiline' => True, 'class' => 'TextBox CodeBox', 'placeholder' => T('Body'))), 'li'); ?> </li> </ul> <?php echo $this->Form->Button('Save'); $this->Form->Close();