Skip to content
Snippets Groups Projects
Commit 8fdc08b7 authored by Peter Rotich's avatar Peter Rotich
Browse files

Merge pull request #146 from greezybacon/issue/131


Fix a few things related to site pages

Reviewed-By: default avatarPeter Rotich <peter@osticket.com>
parents 4fa8fa11 17e78ba9
No related branches found
No related tags found
No related merge requests found
......@@ -256,7 +256,7 @@ class DraftAjaxAPI extends AjaxController {
$sql = 'SELECT distinct f.id, COALESCE(a.type, f.ft) FROM '.FILE_TABLE
.' f LEFT JOIN '.ATTACHMENT_TABLE.' a ON (a.file_id = f.id)
WHERE (a.`type` IN (\'C\', \'F\', \'T\') OR f.ft = \'L\')
WHERE (a.`type` IN (\'C\', \'F\', \'T\', \'P\') OR f.ft = \'L\')
AND f.`type` LIKE \'image/%\'';
if (!($res = db_query($sql)))
Http::response(500, 'Unable to lookup files');
......@@ -267,6 +267,7 @@ class DraftAjaxAPI extends AjaxController {
'F' => 'FAQ Articles',
'T' => 'Email Templates',
'L' => 'Logos',
'P' => 'Pages',
);
while (list($id, $type) = db_fetch_row($res)) {
$f = AttachmentFile::lookup($id);
......
......@@ -70,7 +70,7 @@ class Page {
return $this->ht['body'];
}
function getBodyWithImages() {
return Format::viewableImages($this->getBody());
return Format::viewableImages($this->getBody(), ROOT_PATH.'image.php');
}
function getNotes() {
......
......@@ -9,7 +9,8 @@ $sql='SELECT page.id, page.isactive, page.name, page.created, page.updated, '
.' WHERE 1 ';
$sortOptions=array(
'name'=>'page.name', 'status'=>'page.isactive',
'created'=>'page.created', 'updated'=>'page.updated');
'created'=>'page.created', 'updated'=>'page.updated',
'type'=>'page.type');
$orderWays=array('DESC'=>'DESC','ASC'=>'ASC');
$sort=($_REQUEST['sort'] && $sortOptions[strtolower($_REQUEST['sort'])])?strtolower($_REQUEST['sort']):'name';
......@@ -62,8 +63,9 @@ else
<thead>
<tr>
<th width="7">&nbsp;</th>
<th width="380"><a <?php echo $name_sort; ?> href="pages.php?<?php echo $qstr; ?>&sort=name">Name</a></th>
<th width="120"><a <?php echo $status_sort; ?> href="pages.php?<?php echo $qstr; ?>&sort=status">Status</a></th>
<th width="300"><a <?php echo $name_sort; ?> href="pages.php?<?php echo $qstr; ?>&sort=name">Name</a></th>
<th width="90"><a <?php echo $type_sort; ?> href="pages.php?<?php echo $qstr; ?>&sort=type">Type</a></th>
<th width="110"><a <?php echo $status_sort; ?> href="pages.php?<?php echo $qstr; ?>&sort=status">Status</a></th>
<th width="150" nowrap><a <?php echo $created_sort; ?>href="pages.php?<?php echo $qstr; ?>&sort=created">Date Added</a></th>
<th width="150" nowrap><a <?php echo $updated_sort; ?>href="pages.php?<?php echo $qstr; ?>&sort=updated">Last Updated</a></th>
</tr>
......@@ -86,6 +88,7 @@ else
<?php echo $sel?'checked="checked"':''; ?>>
</td>
<td>&nbsp;<a href="pages.php?id=<?php echo $row['id']; ?>"><?php echo Format::htmlchars($row['name']); ?></a></td>
<td class="faded"><?php echo $row['type']; ?></td>
<td>
&nbsp;<?php echo $row['isactive']?'Active':'<b>Disabled</b>'; ?>
&nbsp;&nbsp;<?php echo $inuse?'<em>(in-use)</em>':''; ?>
......
......@@ -28,8 +28,9 @@ if($_POST) {
$msg='Page added successfully';
// Attach inline attachments from the editor
if (isset($_POST['draft_id'])
&& ($draft = Draft::lookup($_POST['draft_id'])))
$c->attachments->upload(
&& ($draft = Draft::lookup($_POST['draft_id']))
&& ($page = Page::lookup($pageId)))
$page->attachments->upload(
$draft->getAttachmentIds($_POST['response']), true);
Draft::deleteForNamespace('page');
} elseif(!$errors['err'])
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment