Skip to content
43 changes: 22 additions & 21 deletions assets/documenter.admin.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* A Symphony extension enabling addition of documentation
* to any page in the back end, including user-defined
* A Symphony extension enabling addition of documentation
* to any page in the back end, including user-defined
* section indexes and entry editors.
*/

Expand All @@ -9,28 +9,29 @@
}

#drawer-documenter {
background: #282828;
background: #fff;
}

#documenter-drawer .documenter-content {
color: rgba(255,255,255,.85);
color: #3B3D40;
padding: 0 3rem 3rem;
}

/* Headings */

#documenter-drawer h2 {
margin: 0 0 1em -0.39em;
padding: 0 0 0.39em 0.39em;
border-bottom: 1px solid #d1d1cc;
color: rgba(255,255,255,.85);
color: #2f77eb;
font-size: 2.4rem;
padding: 3rem;
}

#documenter-drawer .documenter-content + h2 {
padding-top: 3em;
padding-top: 3rem;
border-top: 1px solid #d3dce2;
}

#documenter-drawer .documenter-content h1,
#documenter-drawer .documenter-content h2,
#documenter-drawer .documenter-content h1,
#documenter-drawer .documenter-content h2,
#documenter-drawer .documenter-content h3 {
border-bottom: 1px solid #e7e7e7;
margin: 0 0 0 -0.5em;
Expand All @@ -42,8 +43,8 @@
color: rgba(255,255,255,.85);
}

#documenter-drawer .documenter-content h1:after,
#documenter-drawer .documenter-content h2:after,
#documenter-drawer .documenter-content h1:after,
#documenter-drawer .documenter-content h2:after,
#documenter-drawer .documenter-content h3:after {
content: attr(data-show);
position: absolute;
Expand All @@ -52,20 +53,20 @@
color: rgba(255,255,255,.85);
}

#documenter-drawer .documenter-content h1.open,
#documenter-drawer .documenter-content h2.open,
#documenter-drawer .documenter-content h1.open,
#documenter-drawer .documenter-content h2.open,
#documenter-drawer .documenter-content h3.open {
background: rgba(255, 255, 255, 0.6);
}

#documenter-drawer .documenter-content h1.open:after,
#documenter-drawer .documenter-content h2.open:after,
#documenter-drawer .documenter-content h1.open:after,
#documenter-drawer .documenter-content h2.open:after,
#documenter-drawer .documenter-content h3.open:after {
content: attr(data-hide);
}

#documenter-drawer .documenter-content .block.open + h1,
#documenter-drawer .documenter-content .block.open + h2,
#documenter-drawer .documenter-content .block.open + h1,
#documenter-drawer .documenter-content .block.open + h2,
#documenter-drawer .documenter-content .block.open + h3 {
border-top: 1px solid #e7e7e7;
}
Expand Down Expand Up @@ -110,13 +111,13 @@
content: counters(section, ".") ". ";
}

#documenter-drawer ul,
#documenter-drawer ul,
#documenter-drawer ol {
margin: 0 0 1.5em 0;
list-style-position: inside;
}

#documenter-drawer ul li li,
#documenter-drawer ul li li,
#documenter-drawer ol li li {
margin-left: 1.5em;
}
Expand Down
56 changes: 37 additions & 19 deletions content/content.edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

require_once(TOOLKIT . '/class.administrationpage.php');
require_once(EXTENSIONS . '/documenter/lib/class.form.php');

class contentExtensionDocumenterEdit extends AdministrationPage {

private $form;

public function __construct() {
Expand All @@ -15,49 +15,67 @@ public function __construct() {
public function view() {
$this->form->render();
}

public function action() {
$doc_id = $this->_context[0];

// Delete action
if (@array_key_exists('delete', $_POST['action'])) {
$page = Symphony::Database()->fetchRow(0, "SELECT * FROM tbl_documentation WHERE `id` = '$doc_id'");
Symphony::Database()->delete('tbl_documentation', " `id` = '$doc_id'");
$page = Symphony::Database()
->select(['*'])
->from('tbl_documentation')
->where(['id' => $doc_id])
->execute()
->next();

Symphony::Database()
->delete('tbl_documentation')
->where(['id' => $doc_id])
->execute()
->success();

redirect(URL . '/symphony/extension/documenter/');
}

// Save action
if(@array_key_exists('save', $_POST['action'])){

$this->_errors = array();

// Polish up some field content
$fields = $_POST['fields'];

if(isset($fields['pages'])) {
$fields['pages'] = implode(',',$fields['pages']);
}

$fields['content_formatted'] = $this->form->applyFormatting($fields['content'], true, $this->_errors);

if($fields['content_formatted'] === false){
$fields['content_formatted'] = General::sanitize($this->form->applyFormatting($fields['content']));
$fields['content_formatted'] = General::sanitize($this->form->applyFormatting($fields['content']));
}

if(!isset($fields['content']) || trim($fields['content']) == '') $this->_errors['content'] = __('Content is a required field');

if(!isset($fields['pages']) || trim($fields['pages']) == '') $this->_errors['pages'] = __('Pages is a required field');

if(empty($this->_errors)){
if(!Symphony::Database()->update($fields, 'tbl_documentation', "`id` = '$doc_id'")) $this->pageAlert(__('Unknown errors occurred while attempting to save. Please check your <a href="%s">activity log</a>.', array(URL.'/symphony/system/log/')), Alert::ERROR);
if(!isset($fields['pages']) || trim($fields['pages']) == '') $this->_errors['pages'] = __('Pages is a required field');

else{
if(empty($this->_errors)){
if (!Symphony::Database()
->update('tbl_documentation')
->set($fields)
->where(['id' => $doc_id])
->execute()
->success()
) {
$this->pageAlert(__('Unknown errors occurred while attempting to save. Please check your <a href="%s">activity log</a>.', array(URL.'/symphony/system/log/')), Alert::ERROR);
}
else {
redirect(URL . "/symphony/extension/documenter/edit/$doc_id/saved/");
}
}
}
if(is_array($this->_errors) && !empty($this->_errors)) $this->pageAlert(__('An error occurred while processing this form. <a href="#error">See below for details.</a>'), Alert::ERROR);

if(is_array($this->_errors) && !empty($this->_errors)) $this->pageAlert(__('An error occurred while processing this form. <a href="#error">See below for details.</a>'), Alert::ERROR);
}

}
80 changes: 44 additions & 36 deletions content/content.index.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,92 +3,95 @@
require_once(CONTENT . '/content.blueprintspages.php');

class contentExtensionDocumenterIndex extends contentBlueprintsPages {

public function view() {

// Start building the page
$this->setPageType('table');
$this->setTitle(__('%1$s &ndash; %2$s', array(__('Symphony'), __('Documentation'))));

$this->appendSubheading(
__('Documentation'),
Widget::Anchor(
__('Create New'), URL . '/symphony/extension/documenter/new/',
__('Create a new documentation item'), 'create button'
Widget::SVGIcon('add') . '<span><span>' . __('Create New') . '</span></span>',
URL . '/symphony/extension/documenter/new/',
__('Create a new documentation item'),
'create button'
)
);

// Grab all the documentation items
$docs = Symphony::Database()->fetch("
SELECT
d.*
FROM
`tbl_documentation` AS d
ORDER BY
d.pages ASC
");

$docs = Symphony::Database()
->select(['d.*'])
->from('tbl_documentation', 'd')
->orderBy('d.pages')
->execute()
->rows();

// Build the table
$thead = array(
array(__('Title'), 'col'),
array(__('Pages'), 'col')
);

$tbody = array();

// If there are no records, display default message
if (!is_array($docs) or empty($docs)) {
$tbody = array(Widget::TableRow(array(
Widget::TableData(__('None found.'), 'inactive', null, count($thead))
), 'odd'));

}

// Otherwise, build table rows
else{
$bOdd = true;

foreach ($docs as $doc) {
$doc_edit_url = URL . '/symphony/extension/documenter/edit/' . $doc['id'] . '/';

$col_title = Widget::TableData(Widget::Anchor(
$doc['title'], $doc_edit_url
));
$col_title->appendChild(Widget::Input("items[{$doc['id']}]", null, 'checkbox'));

$col_title->setAttribute('data-title', __('Title'));

$pages = $doc['pages'];
$pages = explode(',', $pages);
$pages = join(', ', $pages);
$col_pages = Widget::TableData($pages);

$tbody[] = Widget::TableRow(array($col_title, $col_pages), ($bOdd ? 'odd' : NULL));

$col_pages->setAttribute('data-title', __('Pages'));

$tbody[] = Widget::TableRow(array($col_title, $col_pages), ($bOdd ? 'odd' : null));

$bOdd = !$bOdd;
}
}

$table = Widget::Table(
Widget::TableHead($thead), null,
Widget::TableBody($tbody), null
);
$table->setAttribute('class','selectable');

$table->setAttribute('data-interactive', 'data-interactive');

$this->Form->appendChild($table);

$actions = new XMLElement('div');
$actions->setAttribute('class', 'actions');

$options = array(
array(null, false, __('With Selected...')),
array('delete', false, __('Delete')),
);

$actions->appendChild(Widget::Apply($options));

$this->Form->appendChild($actions);

}

function __actionIndex(){

$checked = @array_keys($_POST['items']);
Expand All @@ -100,11 +103,16 @@ function __actionIndex(){

$doc_items = $checked;

Symphony::Database()->delete('tbl_documentation', " `id` IN('".implode("','",$checked)."')");
Symphony::Database()
->delete('tbl_documentation')
->where(['id' => ['in' => $checked]])
->execute()
->success();

redirect(Administration::instance()->getCurrentPageURL());
break;
}
}
}
}
}

}
Loading