예제 #1
0
 public static function image($name, $settings = array())
 {
     self::initSettings();
     $settings += self::$settings;
     $content = self::loadCMS($name);
     if (empty($content)) {
         $content = array('class' => '', 'content' => !empty($settings['default']) ? $settings['default'] : '', 'url' => !empty($settings['defaultUrl']) ? $settings['defaultUrl'] : '');
     }
     if (!empty($content['content']) && empty($content['url'])) {
         // Needs a file prefix for rendering.
         $handler = FileManager::getFileHandler(!empty($settings['file_handler']) ? $settings['file_handler'] : '', $settings['location']);
         $content['url'] = $handler->getWebURL($content['content']);
     }
     $forced_classes = !empty($settings['class']) ? $settings['class'] : '';
     $added_classes = !empty($content['class']) ? $content['class'] : '';
     if (!empty($settings['class'])) {
         $content['class'] .= ' ' . $settings['class'];
     }
     if (ClientUser::getInstance()->isAdmin()) {
         JS::add('/js/ckfinder/ckfinder.js', false);
         JS::set('token', Session::getInstance()->getToken());
         // TODO: This will need extra slashes if using the File handler.
         JS::set('cms.basepath', $settings['location']);
         $fh = FileManager::getFileHandler($settings['file_handler'], $settings['location']);
         JS::set('cms.baseUrl', $fh->getWebURL(''));
         JS::startup('lightning.cms.initImage();');
         return '<a href="" class="button" onclick="javascript:lightning.cms.editImage(\'' . $name . '\'); return false;">Change</a>' . '<a href="" class="button" onclick="javascript:lightning.cms.saveImage(\'' . $name . '\'); return false;">Save</a>' . '<input type="text" id="cms_' . $name . '_class" class="imagesCSS" name="' . $forced_classes . '" value="' . $added_classes . '" />' . '<img src="' . $content['url'] . '" id="cms_' . $name . '" class="' . $content['class'] . '" />';
     } else {
         return '<img src="' . $content['url'] . '" class="' . $content['class'] . '" />';
     }
 }
예제 #2
0
 public static function renderLinks()
 {
     $settings = Configuration::get('social.google');
     if (!empty($settings['like'])) {
         JS::add('https://apis.google.com/js/platform.js', true);
         $output = '<g:plusone size="medium" annotation="none"></g:plusone>';
         return $output;
     }
 }
예제 #3
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>';
 }
예제 #4
0
 /**
  * Initialize requires CSS and JS files.
  */
 public static function initDisplay()
 {
     static $inited = false;
     if (!$inited) {
         JS::add('/js/video-js.min.js', false);
         JS::startup('videojs.options.flash.swf = "/swf/video-js.swf"');
         CSS::add('/css/video-js.min.css');
         $inited = true;
     }
 }
예제 #5
0
 public function __construct()
 {
     parent::__construct();
     JS::add('/js/Chart.min.js', false);
     JS::startup('lightning.stats.init()');
     // Prepare the JS.
     JS::set('chart.' . $this->id . '.renderer', $this->renderer);
     JS::set('chart.' . $this->id . '.url', '/' . Request::getLocation());
     JS::set('chart.' . $this->id . '.params.start', ['source' => 'start']);
     JS::set('chart.' . $this->id . '.params.number_format', $this->numberFormat);
     JS::set('chart.' . $this->id . '.params.diff', !empty($this->diff));
     if (!empty($this->data)) {
         JS::set('chart.' . $this->id . '.data', $this->data);
     }
     JS::set('chart.' . $this->id . '.ajax', $this->ajax);
 }
예제 #6
0
 public function get()
 {
     $page = Request::getLocation();
     $template_page = Configuration::get('splash.pages.' . $page);
     // No template found.
     if (empty($template_page) || is_array($template_page) && empty($template_page['template'])) {
         Output::error('Page not found.');
     } else {
         $this->page = is_array($template_page) ? $template_page['template'] : $template_page;
     }
     // Add any CSS or JS files.
     if (is_array($template_page)) {
         if (!empty($template_page['css'])) {
             CSS::add($template_page['css']);
         }
         if (!empty($template_page['js'])) {
             JS::add($template_page['js']);
         }
     }
 }
예제 #7
0
 /**
  * Run any global initialization functions.
  */
 public function __construct() {
     // Load messages and errors from the query string.
     Messenger::loadFromQuery();
     Messenger::loadFromSession();
     JS::add('/js/fastclick.min.js');
     JS::add('/js/jquery.min.js', false);
     JS::add('/js/jquery.cookie.min.js');
     JS::add('/js/modernizr.min.js');
     JS::add('/js/placeholder.min.js');
     JS::add('/js/foundation.min.js', false);
     JS::add('/js/lightning.min.js', false);
     JS::add('/js/jquery.validate.min.js', false);
     JS::startup('lightning.startup.init()');
     JS::startup('$(document).foundation()');
     CSS::add('/css/lightning.css');
     CSS::add('/css/site.css');
     if (!empty($this->css)) {
         CSS::add($this->css);
     }
     if (!empty($this->js)) {
         JS::add($this->js);
     }
 }