Example #1
0
 /**
  * Print a question mark with a tool tip.
  *
  * @param $help_string
  * @param string $image
  * @param string $id
  * @param string $class
  * @param null $url
  *
  * @todo this needs JS injection and should be moved to a view.
  */
 public static function render($help_string, $image = '/images/qmark.png', $id = '', $class = '', $url = NULL)
 {
     if ($url) {
         echo '<a href="' . $url . '">';
     }
     echo '<img data-tooltip aria-haspopup="true" class="has-tip" title="' . Scrub::toHTML($help_string) . '" src="' . $image . '" border="0" class="help tooltip ' . $class . '" id="' . $id . '" />';
     if ($url) {
         echo '</a>';
     }
 }
Example #2
0
 /**
  * Build a CK editor in an iframe.
  *
  * @param string $id
  *   The field name / id.
  * @param string $value
  *   The preset value.
  * @param array $options
  *   A list of options.
  *
  * @return string
  *   The output HTML.
  */
 public static function iframe($id, $value, $options = array())
 {
     self::init();
     JS::startup('lightning.ckeditors["' . $id . '"] = CKEDITOR.replace("' . $id . '", ' . json_encode($options) . ');');
     if (!empty($options['finder'])) {
         JS::add('/js/ckfinder/ckfinder.js', false, false);
         JS::startup('CKFinder.setupCKEditor(lightning.ckeditors["' . $id . '"], "/js/ckfinder/")');
     }
     return '<textarea name="' . $id . '" id="' . $id . '">' . Scrub::toHTML($value) . '</textarea>';
 }
Example #3
0
 public static function implodeAttributes($attributes)
 {
     $output = '';
     foreach ($attributes as $name => &$value) {
         if (is_array($value)) {
             $value = implode(' ', $value);
         }
         $output .= $name . '="' . Scrub::toHTML($value) . '" ';
     }
     return $output;
 }
Example #4
0
 /**
  * Get the encoded default value for a form element.
  *
  * @param string $var
  *   The name of the field.
  * @param string $alt_default
  *   A default if nothing was submitted.
  * @param string $type
  *   The type, usually html ot text.
  *
  * @return string
  *   The HTML encoded value.
  */
 public static function defaultValue($var, $alt_default = null, $type = 'text') {
     $default = Request::get($var, $type) !== null ? Request::get($var, $type) : $alt_default;
     return Scrub::toHTML($default);
 }
Example #5
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);
 }
Example #6
0
 public static function XMLSegment($items, $type = null) {
     $output = '';
     foreach ($items as $key => $item) {
         if (is_numeric($key) && $type) {
             $key = $type;
         }
         if (is_array($item)) {
             $output .= "<$key>" . self::XMLSegment($item) . "</$key>";
         } else {
             $output .= "<$key>" . Scrub::toHTML($item) . "</$key>";
         }
     }
     return $output;
 }
Example #7
0
 protected function renderSearchForm()
 {
     // @todo namespace this
     JS::inline('table_search_i=0;table_search_d=0;');
     return 'Search: <input type="text" name="table_search" value="' . Scrub::toHTML(Request::get('ste')) . '" onkeyup="lightning.table.search(this);" />';
 }
Example #8
0
 public function get()
 {
     $blog_id = Request::get('id', 'int') | Request::get('blog_id', 'int');
     $path = explode('/', Request::getLocation());
     $blog = BlogModel::getInstance();
     if (preg_match('/.*\\.htm/', $path[0])) {
         $blog->loadContentByURL($path[0]);
     } elseif ($blog_id) {
         $blog->loadContentById($blog_id);
     } elseif (array_shift($path) == 'blog') {
         if (!empty($path)) {
             $blog->page = is_numeric($path[count($path) - 1]) ? $path[count($path) - 1] : 1;
             if ($path[0] == 'category') {
                 // Load category roll
                 $blog->loadList($blog->page, 'category', $path[1]);
             } elseif ($path[0] == 'author') {
                 // Load an author roll.
                 $blog->loadList($blog->page, 'author', $path[1]);
             } elseif (!empty($blog->page)) {
                 $blog->loadList();
             } else {
                 // Try to load a specific blog.
                 $blog->loadContentByURL($path[0]);
             }
         }
     }
     if (empty($blog->posts)) {
         // Fall back, load blogroll
         $blog->loadList(1);
     }
     $template = Template::getInstance();
     if (count($blog->posts) == 1) {
         $template->set('page_section', 'blog');
     } else {
         // If there is more than one, we show a list with short bodies.
         $blog->shorten_body = true;
     }
     if (count($blog->posts) == 1) {
         foreach (array('title', 'keywords', 'description', 'author') as $meta_data) {
             switch ($meta_data) {
                 case 'title':
                     $value = $blog->posts[0]['title'] . ' | ' . Configuration::get('meta_data.title') . ' | ' . Scrub::toHTML($blog->body($blog->posts[0]['author_name'], true));
                     break;
                 case 'description':
                     $value = Scrub::toHTML($blog->body($blog->posts[0]['body'], true));
                     break;
                 case 'author':
                     $value = Scrub::toHTML($blog->body($blog->posts[0]['author_name'], true));
                     break;
                 default:
                     $value = Scrub::toHTML($blog->body($blog->posts[0][$meta_data], true));
             }
             $template->set('page_' . $meta_data, $value);
         }
     }
     //meta facebook image
     if (count($blog->posts) == 1 && !empty($blog->posts[0]['header_image'])) {
         $template->set('og_image', Configuration::get('web_root') . $blog->posts[0]['header_image']);
     } elseif ($default_image = Configuration::get('blog.default_image')) {
         $template->set('og_image', Configuration::get('web_root') . $default_image);
     }
 }