Exemplo n.º 1
0
 public static function hook_output($toPrint)
 {
     if ($toPrint) {
         $toPrint = Render::file('atom.tpl.php');
         $toPrint = HtmlView::replace($toPrint);
         return trim($toPrint);
     }
     return '';
 }
Exemplo n.º 2
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.º 3
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.º 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
 public function render($controller, $action)
 {
     if ($action == null || $action == '') {
         $action = 'index';
     }
     $view_template = $this->view_template;
     if ($view_template == '') {
         $view_template = 'views/' . $controller . '/' . $action . '.php';
     }
     if ($this->layout) {
         $content = Render::file_with_obj($view_template, $this);
         $head_template = 'views/' . $controller . '/' . $action . '.head.php';
         $head = "";
         if (file_exists($head_template)) {
             $head = Render::file_with_obj($head_template, $this);
         }
         return Render::file_with_arr($this->layout_template, array('content' => $content, 'head' => $head));
     } else {
         return Render::file($view_template);
     }
 }
Exemplo n.º 6
0
<?php

if ($db_object) {
    if (!empty($db_object->array['description'])) {
        ?>
		<div>
			<?php 
        echo $db_object->array['description'];
        ?>
		</div>
		<hr/>
	<?php 
    }
}
echo Render::file($tag_list_template, array('db_object' => $db_object));
Exemplo n.º 7
0
 public function html_search($result)
 {
     foreach ($result as $name => $value) {
         Backend::add($name, $value);
     }
     Backend::addContent(Render::file('backend_search.tpl.php'));
 }
Exemplo n.º 8
0
 public static function install_check()
 {
     //Check the cache folder
     if (!Backend::checkConfigFile()) {
         if (function_exists('posix_getgrgid') && function_exists('posix_getegid')) {
             if ($group = posix_getgrgid(posix_getegid())) {
                 $group = $group['name'];
             }
         }
         $values = array('file' => Backend::getConfigFileLocation(), 'group' => isset($group) ? $group : false);
         Backend::addContent(Render::file('config_value.fix_config.tpl.php', $values));
         return false;
     }
     if (self::get('settings.ConfigValueSet')) {
         return true;
     }
     if (is_post()) {
         $result = true;
         foreach ($_POST as $name => $value) {
             $name = str_replace('_', '.', $name);
             if (in_array($name, array('application.Title', 'application.Moto', 'application.HelpBoxContent', 'application.Description', 'author.Name', 'author.Email', 'author.Website'))) {
                 if (!self::set($name, $value)) {
                     Backend::addError('Could not set ' . $name);
                     $result = false;
                 }
             } else {
                 var_dump('Rejected:', $name);
             }
         }
         self::set('settings.ConfigValueSet', $result);
         Controller::redirect();
     }
     Backend::addContent(Render::file('config_value.values.tpl.php'));
     return false;
 }
Exemplo n.º 9
0
 public function html_signup($result)
 {
     Backend::add('Sub Title', 'Signup to ' . ConfigValue::get('Title'));
     switch (true) {
         case $result instanceof DBObject:
             //Successful signup, redirect
             if (!empty($_SESSION['bookmark'])) {
                 $bookmark = $_SESSION['bookmark'];
                 unset($_SESSION['bookmark']);
             } else {
                 //TODO Make this configurable
                 $bookmark = '?q=';
             }
             Controller::redirect($bookmark);
             break;
         case $result:
         default:
             Backend::add('Object', $result);
             Backend::addContent(Render::file('backend_user.signup.tpl.php'));
             break;
     }
     return $result;
 }
Exemplo n.º 10
0
 public function html_scaffold($result)
 {
     if (is_post() && $result) {
         Backend::addSuccess('Scaffolds created for ' . class_name(Controller::$parameters[0]));
         Controller::redirect();
     } else {
         if (!$result) {
             Controller::redirect();
         }
     }
     Backend::addContent(Render::file('admin.scaffold.tpl.php', $result));
     return $result;
 }
Exemplo n.º 11
0
 public function html_home($methods)
 {
     Backend::addContent(Render::file('std_home.tpl.php', array('methods' => $methods)));
 }
Exemplo n.º 12
0
 function html_manage($result)
 {
     Backend::add('Sub Title', 'Manage Components');
     Backend::add('result', $result);
     Links::add('Admin', '?q=admin/index', 'secondary');
     Backend::addScript(SITE_LINK . 'js/jquery.js');
     Backend::addScript(SITE_LINK . 'js/component.manage.js');
     Backend::addContent(Render::file('component.manage.tpl.php'));
 }
Exemplo n.º 13
0
 private function generateSitemap($component)
 {
     if (!method_exists($component, 'getSitemap')) {
         return false;
     }
     if (!Component::isActive($component)) {
         Backend::addError('Could not generate sitemap: Component inactive. (' . $component . ')');
         return false;
     }
     $controller = new $component();
     $object = $component::retrieve();
     if (!$controller instanceof TableCtl) {
         Backend::addError('Could not generate sitemap: Invalid Area. (' . $component . ')');
         return false;
     }
     $filename = WEB_FOLDER . '/sitemap_' . $component . '.xml';
     if (file_exists($filename) && !is_writable($filename)) {
         Backend::addError('Could not generate sitemap: Cannot open sitemap file. (' . $filename . ')');
         return false;
     }
     $fp = fopen($filename, 'w');
     if (!$fp) {
         Backend::addError('Could not generate sitemap: Could not open sitemap file. (' . $component . ')');
         return false;
     }
     $sitemap = $controller->getSitemap();
     if (count($sitemap) == 2 && array_key_exists('list', $sitemap) && array_key_exists('options', $sitemap)) {
         $list = $sitemap['list'];
         $options = $sitemap['options'];
     } else {
         $list = $sitemap;
         $options = array();
     }
     if (!$list) {
         Backend::addError('Could not generate sitemap: Could not generate list. (' . $component . ')');
         return false;
     }
     if (Controller::$debug) {
         Backend::addNotice('Generating sitemap for ' . $component . ' at ' . WEB_FOLDER . '/sitemap_' . $component . '.xml found at ' . SITE_LINK . basename($filename));
     }
     $last_date = 0;
     $links = array();
     //Compile Links
     foreach ($list as $row) {
         $last_date = strtotime($row['modified']) > $last_date ? strtotime($row['modified']) : $last_date;
         if (empty($options['id_field'])) {
             $id = !empty($row['name']) ? $row['name'] : $row[$object->getMeta('id_field')];
         } else {
             $id = $row[$options['id_field']];
         }
         if (empty($id)) {
             var_dump($id, $row, $object->getMeta('id_field'), $object->getMeta('id'));
             die;
         }
         if (ConfigValue::get('CleanURLs', false)) {
             $url = SITE_LINK . '/' . class_for_url($component) . '/' . $id;
         } else {
             $url = SITE_LINK . '/?q=' . class_for_url($component) . '/' . $id;
         }
         $row['url'] = $url;
         $row = array_merge($row, $options);
         $links[] = $row;
     }
     //Add link to area
     //TODO Make this configurable
     if (ConfigValue::get('CleanURLs', false)) {
         $url = SITE_LINK . '/' . class_for_url($component);
     } else {
         $url = SITE_LINK . '/?q=' . class_for_url($component);
     }
     $link = array('url' => $url, 'modified' => date('Y-m-d H:i:s', $last_date));
     $link['priority'] = array_key_exists('area_priority', $options) ? $options['area_priority'] : 0.8;
     $link['frequency'] = array_key_exists('frequency', $options) ? $options['frequency'] : 'daily';
     $links[] = $link;
     fwrite($fp, Render::file('backend_sitemap/sitemap.tpl.php', array('links' => $links)));
     return $filename;
 }