Exemplo n.º 1
0
 function html_index($result)
 {
     if (Render::checkTemplateFile('home.index.tpl.php')) {
         Backend::addContent(Render::file('home.index.tpl.php'));
     } else {
         Backend::add('Sub Title', 'Welcome');
         Backend::addContent('<h3>Welcome to #Title#</h3><p>The code for this URL is in the Home Controller</p>');
     }
     return true;
 }
Exemplo n.º 2
0
 public static function hook_output($to_print)
 {
     Backend::add('BackendErrors', Backend::getError());
     Backend::add('BackendSuccess', Backend::getSuccess());
     Backend::add('BackendNotices', Backend::getNotice());
     Backend::add('BackendInfo', Backend::getInfo());
     Backend::setError();
     Backend::setSuccess();
     Backend::setNotice();
     Backend::setInfo();
     $content = Backend::getContent();
     if (empty($content)) {
         ob_start();
         var_dump($to_print);
         $content = ob_get_clean();
         if (substr($content, 0, 4) != '<pre') {
             $content = '<pre>' . $content . '</pre>';
         }
         Backend::addContent($content);
     }
     $layout = Backend::get('HTMLLayout', 'index');
     if (!Render::checkTemplateFile($layout . '.tpl.php')) {
         if (SITE_STATE != 'production') {
             Backend::addError('Missing Layout ' . $layout);
         }
         $layout = 'index';
     }
     $to_print = Render::file($layout . '.tpl.php');
     $to_print = self::addLastContent($to_print);
     $to_print = self::replace($to_print);
     $to_print = self::rewriteLinks($to_print);
     $to_print = self::addLinks($to_print);
     $to_print = self::formsAcceptCharset($to_print);
     //TODO fix this
     if (Component::isActive('BackendFilter')) {
         $BEFilter = new BEFilterObj();
         $BEFilter->read();
         $filters = $BEFilter->list ? $BEFilter->list : array();
         foreach ($filters as $row) {
             if (class_exists($row['class'], true) && is_callable(array($row['class'], $row['function']))) {
                 $to_print = call_user_func(array($row['class'], $row['function']), $to_print);
             }
         }
     }
     //TODO Make this configurable
     if (ConfigValue::get('html_view.TidyHTML') && function_exists('tidy_repair_string')) {
         $to_print = tidy_repair_string($to_print);
     }
     return $to_print;
 }
Exemplo n.º 3
0
 public function html_display($result)
 {
     if (!$result instanceof DBObject) {
         return parent::html_display($result);
     }
     Backend::add('Sub Title', $result->array['name']);
     $foreign_template = 'tag.' . class_for_url($result->array['foreign_table']);
     $foreign_template .= '.list.tpl.php';
     if (!Render::checkTemplateFile($foreign_template)) {
         $foreign_template = 'tag.display.list.tpl.php';
     }
     Backend::add('tag_list_template', $foreign_template);
     return parent::html_display($result);
 }
Exemplo n.º 4
0
 public function html_import($result)
 {
     switch (true) {
         case $result instanceof DBObject:
             if (!Backend::get('Sub Title')) {
                 Backend::add('Sub Title', 'Import');
                 Backend::add('Sub Title', 'Import ' . $result->getMeta('name'));
             }
             $template_file = array($result->getArea() . '.import.tpl.php', $result->getArea() . '/import.tpl.php');
             if (!Render::checkTemplateFile($template_file[0]) && !Render::checkTemplateFile($template_file[1])) {
                 $template_file = 'std_import.tpl.php';
             }
             Backend::addContent(Render::file($template_file, array('db_object' => $result)));
             break;
         case is_numeric($result) && $result >= 0:
             Backend::addSuccess($result . ' records imported');
             Controller::redirect('?q=' . Controller::$area . '/list');
             break;
         default:
             Controller::redirect();
             break;
     }
     return $result;
 }
Exemplo n.º 5
0
 function html_display($content)
 {
     if ($content instanceof DBObject) {
         Backend::add('Sub Title', $content->array['title']);
         if ($content->array['from_file']) {
             //Move this to the object ??
             $filename = 'content/static/' . $content->array['name'] . '.html';
             $template = 'content/' . $content->array['name'] . '.tpl.php';
             if (Render::checkTemplateFile($template)) {
                 $content->object->body = Render::file($template);
             } else {
                 if (file_exists(SITE_FOLDER . '/' . $filename)) {
                     $content->object->body = file_get_contents(APP_FOLDER . '/' . $filename);
                 } else {
                     if (file_exists(APP_FOLDER . '/' . $filename)) {
                         $content->object->body = file_get_contents(APP_FOLDER . '/' . $filename);
                     } else {
                         if (file_exists(BACKEND_FOLDER . '/' . $filename)) {
                             $content->object->body = file_get_contents(BACKEND_FOLDER . '/' . $filename);
                             //SITE FOLDER too?
                         }
                     }
                 }
             }
         }
         $meta_desc = Backend::get('meta_description');
         if (empty($meta_desc)) {
             Backend::add('meta_description', plain(self::createPreview($content->object->body, false)));
         }
         $http_equiv = Backend::get('meta_http_equiv', array());
         $http_equiv['Last-Modified'] = $content->object->modified;
         Backend::add('meta_http_equiv', $http_equiv);
         if (!headers_sent()) {
             $max_age = ConfigValue::get('content.MaxAge', 86400);
             header('Last-Modified: ' . $content->object->modified);
             header('Expires: ' . gmdate('r', strtotime('+1 day')));
             header('Cache-Control: max-age=' . $max_age . ', must-revalidate');
             header('Pragma: cache');
         }
     }
     if (Backend::getDB('default')) {
         //TODO Make some of the content values (such as added and lastmodified) available
         //So you can add Last Modified on #lastmodified# to the content.
         $content = parent::html_display($content);
     }
     return $content;
 }
Exemplo n.º 6
0
<?php

$list_start = !isset($list_start) ? Controller::$parameters[1] : $list_start;
$list_length = !isset($list_length) ? Controller::$parameters[2] : $list_length;
?>
{tpl:std_search.tpl.php}
<?php 
if (!empty($term)) {
    ?>
	<p class="large">Showing results for the search for <strong>#term#</strong></p>
	<?php 
    if (Render::checkTemplateFile($db_object->getArea() . '.list.tpl.php')) {
        ?>
		<?php 
        echo Render::renderFile($db_object->getArea() . '.list.tpl.php', array('list_start' => $list_start, 'list_length' => $list_length));
        ?>
	<?php 
    } else {
        ?>
		{tpl:std_list.tpl.php}
	<?php 
    }
}