예제 #1
0
 public function __construct()
 {
     parent::__construct();
     $action = Request::get('action');
     if ($action == 'edit' || $action == 'new') {
         JS::startup('
             lightning.admin.messageEditor.checkVars();
             $("#add_message_criteria_button").click(lightning.admin.messageEditor.checkVars);
         ');
     }
     $this->post_actions['after_post'] = function () {
         $db = Database::getInstance();
         // Find all the criteria added to this message
         $criteria_list = $db->select(array('from' => 'message_message_criteria', 'join' => array('JOIN', 'message_criteria', 'USING (message_criteria_id)')), array('message_id' => $this->id));
         // See if any variables have been set.
         foreach ($criteria_list as $c) {
             // If the criteria requires variables.
             if (!empty($c['variables'])) {
                 // See what variables are required.
                 $vars = explode(',', $c['variables']);
                 $var_data = array();
                 foreach ($vars as $v) {
                     $var_data[$v] = Request::post('var_' . $c['message_criteria_id'] . '_' . $v);
                 }
                 $db->update('message_message_criteria', array('field_values' => json_encode($var_data)), array('message_id' => Request::post('id', 'int'), 'message_criteria_id' => $c['message_criteria_id']));
             }
         }
     };
 }
예제 #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
 public function get()
 {
     $message_id = Request::get('message_id', 'int');
     if (empty($message_id)) {
         Output::error('Message Not Found');
     }
     JS::set('chart.' . $this->id . '.params.message_id', ['value' => $message_id]);
     parent::get();
 }
예제 #4
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>';
 }
예제 #5
0
 /**
  * The main page with options to send emails or tests.
  */
 public function get()
 {
     $message_id = Request::get('id', 'int');
     if (!$message_id || !($message = Database::getInstance()->selectRow('message', array('message_id' => $message_id)))) {
         Messenger::error('Message not found.');
         return;
     }
     $template = Template::getInstance();
     $template->set('content', 'mailing_send');
     $template->set('message', $message);
     JS::set('message_id', $message['message_id']);
     JS::addSessionToken();
 }
예제 #6
0
 /**
  * Render the like and share links.
  */
 public static function renderLinks()
 {
     $settings = Configuration::get('social.facebook');
     if (!empty($settings['share']) || !empty($settings['like'])) {
         JS::startup("!function(d, s, id) {\n  var js, fjs = d.getElementsByTagName(s)[0];\n  if (d.getElementById(id)) return;\n  js = d.createElement(s); js.id = id;\n  js.src = '//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.3';\n  fjs.parentNode.insertBefore(js, fjs);\n}(document, 'script', 'facebook-jssdk');");
         Template::getInstance()->addFooter('<div id="fb-root"></div>');
         $output = '';
         if (!empty($settings['share'])) {
             $output .= '<div class="fb-share-button" data-layout="button"></div>';
         }
         if (!empty($settings['like']) && !empty($settings['page'])) {
             $output .= '<div class="fb-like" data-href="https://facebook.com/' . $settings['page'] . '" data-layout="button" data-action="like" data-show-faces="false" data-share="false"></div>';
         }
         return $output;
     }
 }
예제 #7
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);
 }
예제 #8
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']);
         }
     }
 }
예제 #9
0
 public static function date($name, $settings = array())
 {
     $content = Database::getInstance()->selectRow($settings['table'], array($settings['key'] => $settings['id']), array($settings['column']));
     if ($content) {
         $value = $content[$settings['column']];
     } else {
         $value = '';
     }
     if (ClientUser::getInstance()->isAdmin()) {
         JS::startup('lightning.cms.initDate()');
         JS::set('token', Session::getInstance()->getToken());
         return '<img src="/images/lightning/pencil.png" class="cms_edit_date icon-16" id="cms_edit_' . $settings['id'] . '">' . '<img src="/images/lightning/save.png" class="cms_save_date icon-16" id="cms_save_' . $settings['id'] . '" style="display:none">' . '<span id="cms_' . $settings['id'] . '" style="display:none">' . Time::datePop('cms_' . $settings['id'], $value, 'true', 0) . '</span>' . '<input type="hidden" id="cms_key_' . $settings['id'] . '" value="' . $settings['key'] . '" />' . '<input type="hidden" id="cms_column_' . $settings['id'] . '" value="' . $settings['column'] . '" />' . '<input type="hidden" id="cms_table_' . $settings['id'] . '" value="' . $settings['table'] . '" />';
     } else {
         return $value;
     }
 }
예제 #10
0
    /**
     * Prepare the output and tell the template to render.
     */
    public function output() {
        // Send globals to the template.
        $template = Template::getInstance();

        if (!empty($this->page)) {
            $template->set('content', $this->page);
        }

        $template->set('google_analytics_id', Configuration::get('google_analytics_id'));

        // TODO: These should be called directly from the template.
        $template->set('errors', Messenger::getErrors());
        $template->set('messages', Messenger::getMessages());

        $template->set('site_name', Configuration::get('site.name'));
        $template->set('blog', Blog::getInstance());
        JS::set('active_nav', $this->nav);
        $template->render($this->template);
    }
예제 #11
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);
 }
예제 #12
0
 /**
  * Render the follow and tweet links.
  */
 public static function renderLinks()
 {
     $settings = Configuration::get('social.twitter');
     if (!empty($settings['follow']) || !empty($settings['share'])) {
         // Add the initialization script.
         JS::startup("!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');");
         $return = '';
         if (!empty($settings['share'])) {
             $via = !empty($settings['account']) ? ' data-via="' . $settings['account'] . '"' : '';
             $related = !empty($settings['share-hashtag']) ? ' data-related="' . $settings['share-hashtag'] . '"' : '';
             $return .= '<a href="https://twitter.com/share" class="twitter-share-button" data-count="none"' . $via . $related . ' >Tweet</a>';
         }
         if (!empty($settings['follow']) && !empty($settings['account'])) {
             $return .= '<a href="https://twitter.com/' . $settings['account'] . '" class="twitter-follow-button" data-show-count="false">Follow @' . $settings['account'] . '</a>';
         }
     }
     return $return;
 }
예제 #13
0
 function js_init_data()
 {
     $table_data = array();
     if ($this->rowClick) {
         $table_data['rowClick'] = $this->rowClick;
         if (isset($this->table_url)) {
             $table_data['table'] = $this->table;
         }
         if ($this->parentLink) {
             $table_data['parentLink'] = $this->parentLink;
         }
         if ($this->parentId) {
             $table_data['parentId'] = $this->parentId;
         }
         $table_data['action_file'] = $this->action_file;
         if (count($this->additional_action_vars) > 0) {
             $table_data['vars'] = $this->additional_action_vars;
         }
     }
     $js_startup = '';
     foreach ($this->fields as $f => $field) {
         if (!empty($field['autocomplete'])) {
             $js_startup .= '$(".table_autocomplete").keyup(lightning.table.autocomplete);';
             $use_autocomplete = true;
         }
         if (!empty($field['default_reset'])) {
             $table_data['defaults'][$f] = $field['default'];
         }
         if (!empty($field['type']) && $field['type'] == "div") {
             $include_ck = true;
             $js_startup .= '$("#' . $f . '_div").attr("contentEditable", "true");
             table_div_editors["' . $f . '"]=CKEDITOR.inline("' . $f . '_div",CKEDITOR.config.toolbar_Full);';
         }
     }
     foreach ($this->links as $link => $link_settings) {
         if (!empty($link_settings['include_blank']) && ($link_settings['include_blank'] == "if_empty" && $link_settings['row_count'] == 0 || $link_settings['include_blank'] == "always")) {
             $js_startup .= 'new_subtable("' . $link . '");';
         }
     }
     if (count($table_data) > 0 || !empty($use_autocomplete) || $js_startup) {
         if (count($table_data) > 0 || !empty($use_autocomplete)) {
             JS::inline('var table_data = ' . json_encode($table_data));
         }
         if ($js_startup) {
             JS::startup($js_startup);
         }
     }
 }
예제 #14
0
 /**
  * Add a video's JS and CSS components.
  * This does not create the video's required HTML components.
  *
  * @param string $video_id
  *   The ID for the video.
  *
  * @return string
  *   The rendered HTML.
  */
 public static function render($video_id)
 {
     return '<div class="youtube" id="' . $video_id . '" ></div>';
     JS::startup('lightning.video.init()');
 }
예제 #15
0
 /**
  * Add a video's JS and CSS components.
  * This does not create the video's required HTML components.
  *
  * @param string $video_id
  *   The ID for the video.
  * @param array $settings
  *   The settings for the video.
  */
 public static function add($video_id, $settings)
 {
     self::initDisplay();
     JS::set('videos.' . $video_id, $settings);
     JS::startup('lightning.video.init()');
 }
예제 #16
0
?>
</li><? endforeach; ?></ul>
                            </div>
                        <?
                        endif;
                        if (!empty($content)) :
                            $this->build($content);
                        endif; ?>
                    </div>
                <? endif; ?>
            </div>
            <pre>
            <?
            if (ClientUser::getInstance()->isAdmin()) {
                $database = Database::getInstance();
                print_r($database->getQueries());
                print_r($database->timeReport());
            }
            ?>
            </pre>
        </section>
    </div>
</div>
<?php 
echo JS::render();
echo CSS::render();
echo $this->renderFooter();
?>
</body>
</html>