Skip to content
Snippets Groups Projects
Commit af035cb8 authored by Jared Hancock's avatar Jared Hancock
Browse files

oops: Fix crash rendering attachments for FAQ articles

Also, show sidebar on "Other Resources" pages, and fix a problem displaying
the correct Other Resource page.
parent 65e94ed7
No related branches found
No related tags found
No related merge requests found
......@@ -413,7 +413,7 @@ body {
}
.front-page-button {
}
#landing_page .welcome {
.main-content {
width: 560px;
}
#landing_page #new_ticket {
......@@ -984,7 +984,7 @@ img.sign-in-image {
margin-bottom: 20px;
margin-left: 20px;
}
#landing_page .sidebar {
.sidebar {
width: 220px;
}
.rtl .sidebar {
......
......@@ -316,8 +316,8 @@ class FAQ extends VerySimpleModel {
function getVisibleAttachments() {
return array_merge(
$this->attachments->getSeparates() ?: array(),
$this->getLocalAttachments());
$this->attachments->getSeparates()->all() ?: array(),
$this->getLocalAttachments()->all());
}
function getAttachmentsLinks($separator=' ',$target='') {
......
<?php
$BUTTONS = isset($BUTTONS) ? $BUTTONS : true;
?>
<div class="sidebar pull-right">
<?php if ($BUTTONS) { ?>
<div class="front-page-button flush-right">
<p>
<a href="open.php" style="display:block" class="blue button"><?php
echo __('Open a New Ticket');?></a>
</p>
<?php if ($cfg && !$cfg->isKnowledgebaseEnabled()) { ?>
<p>
<a href="view.php" style="display:block" class="green button"><?php
echo __('Check Ticket Status');?></a>
</p>
<?php } ?>
</div>
<?php } ?>
<div class="content"><?php
$faqs = FAQ::getFeatured()->select_related('category')->limit(5);
if ($faqs->all()) { ?>
<section><div class="header"><?php echo __('Featured Questions'); ?></div>
<?php foreach ($faqs as $F) { ?>
<div><a href="<?php echo ROOT_PATH; ?>/kb/faq.php?id=<?php
echo urlencode($F->getId());
?>"><?php echo $F->getLocalQuestion(); ?></a></div>
<?php } ?>
</section>
<?php
}
$resources = Page::getActivePages()->filter(array('type'=>'other'));
if ($resources->all()) { ?>
<section><div class="header"><?php echo __('Other Resources'); ?></div>
<?php foreach ($resources as $page) { ?>
<div><a href="<?php echo ROOT_PATH; ?>pages/<?php echo $page->getNameAsSlug();
?>"><?php echo $page->getLocalName(); ?></a></div>
<?php } ?>
</section>
<?php
}
?></div>
</div>
......@@ -21,44 +21,8 @@ $section = 'home';
require(CLIENTINC_DIR.'header.inc.php');
?>
<div id="landing_page">
<div class="sidebar pull-right">
<div class="front-page-button flush-right">
<p>
<a href="open.php" style="display:block" class="blue button"><?php
echo __('Open a New Ticket');?></a>
</p>
<?php if ($cfg && !$cfg->isKnowledgebaseEnabled()) { ?>
<p>
<a href="view.php" style="display:block" class="green button"><?php
echo __('Check Ticket Status');?></a>
</p>
<?php } ?>
</div>
<div class="content"><?php
$faqs = FAQ::getFeatured()->select_related('category')->limit(5);
if ($faqs->all()) { ?>
<section><div class="header"><?php echo __('Featured Questions'); ?></div>
<?php foreach ($faqs as $F) { ?>
<div><a href="<?php echo ROOT_PATH; ?>/kb/faq.php?id=<?php
echo urlencode($F->getId());
?>"><?php echo $F->getLocalQuestion(); ?></a></div>
<?php } ?>
</section>
<?php
}
$resources = Page::getActivePages()->filter(array('type'=>'other'));
if ($resources->all()) { ?>
<section><div class="header"><?php echo __('Other Resources'); ?></div>
<?php foreach ($resources as $page) { ?>
<a href="<?php echo ROOT_PATH; ?>pages/<?php echo $page->getNameAsSlug();
?>"><?php echo $page->getLocalName(); ?></a>
<?php } ?>
</section>
<?php
}
?></div>
</div>
<div class="welcome">
<?php include CLIENTINC_DIR.'templates/sidebar.tmpl.php'; ?>
<div class="main-content">
<?php
if ($cfg && $cfg->isKnowledgebaseEnabled()) { ?>
<div class="search-form">
......
......@@ -28,27 +28,35 @@ $slug = Format::slugify($ost->get_path_info());
$first_word = explode('-', $slug);
$first_word = $first_word[0];
$sql = 'SELECT id, name FROM '.PAGE_TABLE
.' WHERE name LIKE '.db_input("$first_word%");
$page_id = null;
$res = db_query($sql);
while (list($id, $name) = db_fetch_row($res)) {
if (Format::slugify($name) == $slug) {
$page_id = $id;
$pages = Page::objects()->filter(array(
'name__like' => "$first_word%"
));
$selected_page = null;
foreach ($pages as $P) {
if (Format::slugify($P->name) == $slug) {
$selected_page = $P;
break;
}
}
if (!$page_id || !($page = Page::lookup($page_id)))
if (!$selected_page)
Http::response(404, __('Page Not Found'));
if (!$page->isActive() || $page->getType() != 'other')
if (!$selected_page->isActive() || $selected_page->getType() != 'other')
Http::response(404, __('Page Not Found'));
require(CLIENTINC_DIR.'header.inc.php');
print $page->getBodyWithImages();
$BUTTONS = false;
include CLIENTINC_DIR.'templates/sidebar.tmpl.php';
?>
<div class="main-content">
<?php
print $selected_page->getBodyWithImages();
?>
</div>
<?php
require(CLIENTINC_DIR.'footer.inc.php');
?>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment