Skip to content
Snippets Groups Projects
page.inc.php 8.04 KiB
Newer Older
Peter Rotich's avatar
Peter Rotich committed
<?php
if(!defined('OSTADMININC') || !$thisstaff || !$thisstaff->isAdmin()) die('Access Denied');
$pageTypes = array(
        'landing' => __('Landing page'),
        'offline' => __('Offline page'),
        'thank-you' => __('Thank you page'),
        'other' => __('Other'),
Peter Rotich's avatar
Peter Rotich committed
        );
Peter Rotich's avatar
Peter Rotich committed
$info = $qs = array();
Peter Rotich's avatar
Peter Rotich committed
if($page && $_REQUEST['a']!='add'){
Peter Rotich's avatar
Peter Rotich committed
    $action='update';
    $submit_text=__('Save Changes');
Peter Rotich's avatar
Peter Rotich committed
    $info=$page->getHashtable();
    $info['body'] = Format::viewableImages($page->getBody());
    $info['notes'] = Format::viewableImages($info['notes']);
    $trans['name'] = $page->getTranslateTag('name');
    $slug = Format::slugify($info['name']);
Peter Rotich's avatar
Peter Rotich committed
    $qs += array('id' => $page->getId());
    $translations = CustomDataTranslation::allTranslations(
        $page->getTranslateTag('name:body'), 'article');
    foreach ($cfg->getSecondaryLanguages() as $tag) {
        foreach ($translations as $t) {
            if (strcasecmp($t->lang, $tag) === 0) {
                $C = $t->getComplex();
                $info['trans'][$tag] = Format::viewableImages($C['body']);
Peter Rotich's avatar
Peter Rotich committed
}else {
    $title=__('Add New Page');
Peter Rotich's avatar
Peter Rotich committed
    $action='add';
    $submit_text=__('Add Page');
Peter Rotich's avatar
Peter Rotich committed
    $info['isactive']=isset($info['isactive'])?$info['isactive']:0;
Peter Rotich's avatar
Peter Rotich committed
    $qs += array('a' => $_REQUEST['a']);
Peter Rotich's avatar
Peter Rotich committed
}
$info=Format::htmlchars(($errors && $_POST)?$_POST:$info);
?>
Peter Rotich's avatar
Peter Rotich committed
<form action="pages.php?<?php echo Http::build_query($qs); ?>" method="post" id="save">
Peter Rotich's avatar
Peter Rotich committed
 <?php csrf_token(); ?>
 <input type="hidden" name="do" value="<?php echo $action; ?>">
 <input type="hidden" name="a" value="<?php echo Format::htmlchars($_REQUEST['a']); ?>">
 <input type="hidden" name="id" value="<?php echo $info['id']; ?>">
    <?php if (isset($info['name'])) { ?><small>
<?php echo $info['name']; ?></small>
    <i class="help-tip icon-question-sign" href="#site_pages"></i>
    </h2>
 <table class="form_table fixed" width="940" border="0" cellspacing="0" cellpadding="2">
Peter Rotich's avatar
Peter Rotich committed
    <thead>
        <tr><td style="padding:0"></td><td style="padding:0;"></td></tr> <!-- For fixed table layout -->
Peter Rotich's avatar
Peter Rotich committed
        <tr>
            <th colspan="2">
                <em><?php echo __('Page information'); ?></em>
Peter Rotich's avatar
Peter Rotich committed
            </th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td width="180" class="required">
              <?php echo __('Name'); ?>:
Peter Rotich's avatar
Peter Rotich committed
            </td>
            <td>
                <input type="text" size="40" name="name" value="<?php echo $info['name']; ?>"
                    autofocus data-translate-tag="<?php echo $trans['name']; ?>"/>
Peter Rotich's avatar
Peter Rotich committed
                &nbsp;<span class="error">*&nbsp;<?php echo $errors['name']; ?></span>
            </td>
        </tr>
        <tr>
            <td width="180" class="required">
                <?php echo __('Type'); ?>:
Peter Rotich's avatar
Peter Rotich committed
            </td>
            <td>
                <span>
Peter Rotich's avatar
Peter Rotich committed
                <select name="type">
                    <option value="" selected="selected">&mdash; <?php
                    echo __('Select Page Type'); ?> &mdash;</option>
Peter Rotich's avatar
Peter Rotich committed
                    <?php
                    foreach($pageTypes as $k => $v)
                        echo sprintf('<option value="%s" %s>%s</option>',
                                $k, (($info['type']==$k)?'selected="selected"':''), $v);
                    ?>
                </select>
                &nbsp;<span class="error">*&nbsp;<?php echo $errors['type']; ?></span>
                &nbsp;<i class="help-tip icon-question-sign" href="#type"></i>
                </span>
Peter Rotich's avatar
Peter Rotich committed
            </td>
        </tr>
        <?php if ($info['name'] && $info['type'] == 'other') { ?>
        <tr>
            <td width="180" class="required">
                <?php echo __('Public URL'); ?>:
            </td>
            <td><a href="<?php echo sprintf("%s/pages/%s",
                    $ost->getConfig()->getBaseUrl(), urlencode($slug));
                ?>">pages/<?php echo $slug; ?></a>
            </td>
        </tr>
        <?php } ?>
Peter Rotich's avatar
Peter Rotich committed
        <tr>
            <td width="180" class="required">
                <?php echo __('Status'); ?>:
Peter Rotich's avatar
Peter Rotich committed
            </td>
            <td>
                <input type="radio" name="isactive" value="1" <?php echo $info['isactive']?'checked="checked"':''; ?>>
                <strong><?php echo __('Active'); ?></strong>
                <input type="radio" name="isactive" value="0" <?php echo !$info['isactive']?'checked="checked"':''; ?>>
                <?php echo __('Disabled'); ?>
Peter Rotich's avatar
Peter Rotich committed
                &nbsp;<span class="error">*&nbsp;<?php echo $errors['isactive']; ?></span>
            </td>
        </tr>
        <tr>
            <td colspan="2">
                <ul class="tabs clean">
Jared Hancock's avatar
Jared Hancock committed
                    <li class="active"><a href="#content"><?php echo __('Page Content'); ?></a></li>
                    <li><a href="#notes"><?php echo __('Internal Notes'); ?></a></li>
                </ul>
    <div class="tab_content active" id="content">
<table class="full-width"><tbody><tr><td style="vertical-align:top">
<?php
$langs = Internationalization::getConfiguredSystemLanguages();
if ($page && count($langs) > 1) { ?>
    <ul class="vertical tabs" id="translations">
        <li class="empty"><i class="icon-globe" title="This content is translatable"></i></li>
<?php foreach ($langs as $tag=>$nfo) { ?>
    <li class="<?php if ($tag == $cfg->getPrimaryLanguage()) echo "active";
        ?>"><a href="#translation-<?php echo $tag; ?>" title="<?php
        echo Internationalization::getLanguageDescription($tag);
    ?>"><span class="flag flag-<?php echo strtolower($nfo['flag']); ?>"></span>
    </a></li>
<?php } ?>
}

// For landing page, constrain to the diplayed width of 565px;
if ($info['type'] == 'landing')
    $width = '565px';
else
    $width = '100%';
?>
</td>
<td id="translations_container" style="padding-left: 10px">
    <div id="msg_info">
    <em><i class="icon-info-sign"></i> <?php
        echo __(
            'Ticket variables are only supported in thank-you pages.'
        ); ?></em>
    </div>
        <div id="translation-<?php echo $cfg->getPrimaryLanguage(); ?>" class="tab_content"
            lang="<?php echo $cfg->getPrimaryLanguage(); ?>">
        <textarea name="body" cols="21" rows="12" class="richtext draft"
            data-width="<?php echo $width; ?>"
    if (!$info['type'] || $info['type'] == 'thank-you') echo 'data-root-context="thank-you"';
    list($draft, $attrs) = Draft::getDraftAndDataAttrs('page', $info['id'], $info['body']);
    echo $attrs; ?>><?php echo $draft ?: $info['body']; ?></textarea>
        </div>

<?php if ($langs && $page) {
    foreach ($langs as $tag=>$nfo) {
        if ($tag == $cfg->getPrimaryLanguage())
            continue; ?>
        <div id="translation-<?php echo $tag; ?>" class="tab_content hidden"
            lang="<?php echo $tag; ?>">
        <textarea name="trans[<?php echo $tag; ?>][body]" cols="21" rows="12"
<?php if ($info['type'] == 'thank-you') echo 'data-root-context="thank-you"'; ?>
            style="width:100%" class="richtext draft" data-width="<?php echo $width; ?>"
<?php
    list($draft, $attrs) = Draft::getDraftAndDataAttrs('page', $info['id'].'.'.$tag, $info['trans'][$tag]);
    echo $attrs; ?>><?php echo $draft ?: $info['trans'][$tag]; ?></textarea>
        </div>
<?php }
} ?>
</td></tr></tbody></table>
        <div class="error" style="margin: 5px 0"><?php echo $errors['body']; ?></div>
        <div class="clear"></div>
    </div>
    <div class="tab_content" style="display:none" id="notes">
        <em><strong><?php echo __('Internal Notes'); ?></strong>:
        <?php echo __("be liberal, they're internal"); ?></em>
        <textarea class="richtext no-bar" name="notes" cols="21"
            rows="8" style="width: 80%;"><?php echo $info['notes']; ?></textarea>
    </div>
Peter Rotich's avatar
Peter Rotich committed
            </td>
        </tr>
    </tbody>
</table>
<p style="text-align:center">
Peter Rotich's avatar
Peter Rotich committed
    <input type="submit" name="submit" value="<?php echo $submit_text; ?>">
    <input type="reset"  name="reset"  value="<?php echo __('Reset'); ?>">
    <input type="button" name="cancel" value="<?php echo __('Cancel'); ?>" onclick='window.location.href="pages.php"'>
Peter Rotich's avatar
Peter Rotich committed
</p>
</form>