예제 #1
0
 public function get()
 {
     $user = ClientUser::getInstance();
     $template = Template::getInstance();
     $request = Request::getLocation();
     $content_locator = empty($request) ? 'index' : Request::getFromURL('/(.*)\\.html$/') ?: '404';
     // Determine if the user can edit this page.
     $template->set('editable', $user->isAdmin());
     // Set the page template.
     $template->set('content', 'page');
     // LOAD PAGE DETAILS
     if ($full_page = $this->loadPage($content_locator)) {
         header('HTTP/1.0 200 OK');
         if (Configuration::get('page.modification_date') && $full_page['last_update'] > 0) {
             header("Last-Modified: " . gmdate("D, d M Y H:i:s", $full_page['last_update']) . " GMT");
         }
     } elseif ($this->new) {
         $full_page['title'] = '';
         $full_page['keywords'] = '';
         $full_page['description'] = '';
         $full_page['url'] = '';
         $full_page['body'] = 'This is your new page.';
         $full_page['layout'] = 0;
         $full_page['site_map'] = 1;
         CKEditor::init();
         JS::startup('lightning.page.edit();');
     } elseif ($full_page = $this->loadPage('404')) {
         header('HTTP/1.0 404 NOT FOUND');
         $full_page['url'] = Request::get('page');
         $template->set('page_blank', true);
     } else {
         header('HTTP/1.0 404 NOT FOUND');
         $full_page['title'] = 'Lightning';
         $full_page['keywords'] = 'Lightning';
         $full_page['description'] = 'Lightning';
         $full_page['url'] = '';
         $full_page['body'] = 'Your site has not been set up.';
         $full_page['layout'] = 0;
         $full_page['site_map'] = 1;
         $template->set('page_blank', true);
     }
     // Replace special tags.
     if (!$user->isAdmin()) {
         $matches = array();
         preg_match_all('|{{.*}}|', $full_page['body'], $matches);
         foreach ($matches as $match) {
             if (!empty($match)) {
                 $match_clean = trim($match[0], '{} ');
                 $match_clean = explode('=', $match_clean);
                 switch ($match_clean[0]) {
                     case 'template':
                         $sub_template = new Template();
                         $full_page['body'] = str_replace($match[0], $sub_template->render($match_clean[1], true), $full_page['body']);
                         break;
                 }
             }
         }
     }
     // PREPARE FORM DATA CONTENTS
     foreach (array('title', 'keywords', 'description') as $meta_data) {
         $full_page[$meta_data] = Scrub::toHTML($full_page[$meta_data]);
         if (!empty($full_page[$meta_data])) {
             Configuration::set('page_' . $meta_data, str_replace("*", Configuration::get('page_' . $meta_data), $full_page[$meta_data]));
         }
     }
     if ($full_page['url'] == "" && isset($_GET['page'])) {
         $full_page['url'] = $_GET['page'];
     } else {
         $full_page['url'] = Scrub::toHTML($full_page['url'], ENT_QUOTES);
     }
     $template->set('page_header', $full_page['title']);
     $template->set('full_page', $full_page);
     $template->set('full_width', $full_page['layout'] == 1);
 }
예제 #2
0
 /**
  * Renders an 'upload image' button and a list of selected current images.
  *
  * @param $link_settings
  *
  * @return string
  */
 protected function render_linked_table_editable_image(&$link_settings)
 {
     CKEditor::init(true);
     JS::startup('lightning.table.init()');
     $link_settings['web_location'] = $this->getImageLocationWeb($link_settings, '');
     JS::set('table.links.' . $link_settings['table'], $link_settings);
     $output = '<span class="button add_image" id="add_image_' . $link_settings['table'] . '">Add Image</span>';
     $output .= '<span class="linked_images" id="linked_images_' . $link_settings['table'] . '">';
     foreach ($link_settings['active_list'] as $image) {
         $output .= '<span class="selected_image_container">
             <input type="hidden" name="linked_images_' . $link_settings['table'] . '[]" value="' . $image['image'] . '">
             <span class="remove">X</span>
             <img src="' . $this->getImageLocationWeb($link_settings, $image['image']) . '"></span>';
     }
     $output .= '</span>';
     return $output;
 }