コード例 #1
0
ファイル: CMS.php プロジェクト: kemosabhay/Lightning
 public static function embed($name, $settings = array())
 {
     $content = self::loadCMS($name);
     $content = !empty($content) ? $content['content'] : (!empty($settings['default']) ? $settings : '');
     if (ClientUser::getInstance()->isAdmin()) {
         JS::set('token', Session::getInstance()->getToken());
         return '<a href="javascript:lightning.cms.edit(\'cms_' . $name . '\')" class="button" id="cms_edit_' . $name . '">Edit</a>' . '<a href="javascript:lightning.cms.save(\'cms_' . $name . '\')" class="button hide" id="cms_save_' . $name . '">Save</a>' . CKEditor::editableDiv('cms_' . $name, array('spellcheck' => true, 'content' => $content, 'finder' => true, 'edit_border' => !empty($settings['edit_border'])));
     } else {
         return '<div>' . $content . '</div>';
     }
 }
コード例 #2
0
ファイル: page.tpl.php プロジェクト: kemosabhay/Lightning
?>
" /></td></tr>
                    <tr><td>Description:</td><td><input type="text" name="description" id='page_description' value="<?php 
echo $full_page['description'];
?>
" /></td></tr>
                    <tr><td>Keywords:</td><td><input type="text" name="keywords" id='page_keywords' value="<?php 
echo $full_page['keywords'];
?>
" /></td></tr>
                    <tr><td>Include in site map:</td><td><input type="checkbox" name="sitemap" id='page_sitemap' value="1" <? if ( $full_page['site_map'] == 1):?>checked="true"<? endif; ?> /></td></tr>
                    <tr><td>Hide Side Bar:</td><td><?php 
echo Page::layoutOptions($full_page['layout']);
?>
</td></tr>
                </table>
            </div>
        <? endif; ?>
        <?php 
echo \Lightning\Tools\CKEditor::editableDiv('page_display', array('spellcheck' => true, 'content' => $full_page['body'], 'finder' => true));
?>
        <? if ($editable):?>
            <input type="button" name="submit" class='button page_edit' onclick="lightning.page.save();" value="Save" <? if (empty($action) || $action != 'new'):?>style="display:none;"<? endif; ?> /><br />
        <? endif; ?>

        <?php 
echo $this->build('social_links');
?>
    </div>
</div>
コード例 #3
0
ファイル: Page.php プロジェクト: kemosabhay/Lightning
 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);
 }
コード例 #4
0
ファイル: Table.php プロジェクト: kemosabhay/Lightning
 /**
  * Render the edit field component.
  *
  * @param array $field
  *   The field settings.
  * @param array $row
  *   The data row.
  *
  * @return string
  *   The rendered HTML.
  */
 protected function renderEditField($field, &$row = array())
 {
     // Make sure the form_field is set.
     if (!isset($field['form_field'])) {
         $field['form_field'] = $field['field'];
     }
     // Get the default field value.
     if (!empty($_POST)) {
         $v = Request::post($field['form_field']);
     } elseif (empty($row)) {
         $v = isset($field['default']) ? $field['default'] : '';
     } elseif (isset($field['edit_value'])) {
         if (is_callable($field['edit_value'])) {
             $v = $row[] = $field['edit_value']($row);
         } else {
             $v = $row[] = $field['edit_value'];
         }
     } elseif (!empty($row[$field['field']])) {
         $v = $row[$field['field']];
     }
     if (isset($this->preset[$field['field']]['render_' . $this->action . '_field'])) {
         $this->get_row(false);
         return $this->preset[$field['field']]['render_' . $this->action . '_field']($this->list);
     }
     // Prepare value.
     if (!isset($field['Value'])) {
         $field['Value'] = isset($v) ? $v : null;
     }
     if (!empty($field['encrypted'])) {
         $field['Value'] = $this->decrypt($field['Value']);
     }
     // Set the default value if new.
     if ($this->action == "new" && isset($field['default'])) {
         $field['Value'] = $field['default'];
     }
     // Print form input.
     $options = array();
     $return = '';
     switch (preg_replace('/\\([0-9]+\\)/', '', $field['type'])) {
         case 'text':
         case 'mediumtext':
         case 'longtext':
         case 'html':
             $config = array();
             $editor = !empty($field['editor']) ? strtolower($field['editor']) : 'default';
             switch ($editor) {
                 case 'full':
                     $config['toolbar'] = "CKEDITOR.config.toolbar_Full";
                     break;
                 case 'print':
                     $config['toolbar'] = "CKEDITOR.config.toolbar_Print";
                     break;
                 case 'basic_image':
                     $config['toolbar'] = "CKEDITOR.config.toolbar_Basic_Image";
                     break;
                 case 'basic':
                 default:
                     $config['toolbar'] = "CKEDITOR.config.toolbar_Basic";
                     break;
             }
             if (!empty($field['full_page'])) {
                 $config['fullPage'] = true;
                 $config['allowedContent'] = true;
             }
             if (!empty($field['height'])) {
                 $config['height'] = $field['height'];
             }
             if (!empty($field['upload'])) {
                 $config['finder'] = true;
             }
             return CKEditor::iframe($field['form_field'], $field['Value'], $config);
             break;
         case 'div':
             if ($field['Value'] == '') {
                 $field['Value'] = "<p></p>";
             }
             return "<input type='hidden' name='{$field['form_field']}' id='{$field['form_field']}' value='" . $this->convert_quotes($field['Value']) . "' />\n\t\t\t\t\t\t\t<div id='{$field['form_field']}_div' spellcheck='true'>{$field['Value']}</div>";
             break;
         case 'plaintext':
             return "<textarea name='{$field['form_field']}' id='{$field['form_field']}' spellcheck='true' cols='90' rows='10'>{$field['Value']}</textarea>";
             break;
         case 'hidden':
             return "<input type='hidden' name='{$field['form_field']}' id='{$field['form_field']}' value='" . $this->convert_quotes($field['Value']) . "' />";
             break;
         case 'image':
             if (!empty($field['Value'])) {
                 $return .= '<img src="' . $this->getImageLocationWeb($field, $field['Value']) . '" class="table_edit_image" />';
             }
             // Fall through.
         // Fall through.
         case 'file':
             if ($field['Value'] != '' && (!isset($field['replaceable']) || empty($field['replaceable'])) || $field['Value'] == '') {
                 $return .= "<input type='file' name='{$field['form_field']}' id='{$field['form_field']}' />";
             }
             return $return;
             break;
         case 'time':
             return Time::timePop($field['form_field'], $field['Value'], !empty($field['allow_blank']));
             break;
         case 'date':
             $return = Time::datePop($field['form_field'], !empty($field['Value']) ? $field['Value'] : 0, !empty($field['allow_blank']), !empty($field['start_year']) ? $field['start_year'] : 0);
             return $return;
             break;
         case 'datetime':
             return Time::dateTimePop($field['form_field'], $field['Value'], !empty($field['allow_blank']), isset($field['start_year']) ? $field['start_year'] : date('Y') - 10);
             break;
         case 'lookup':
         case 'yesno':
         case 'state':
         case 'country':
         case 'select':
             if ($field['type'] == 'lookup') {
                 $options = Database::getInstance()->selectColumn($field['lookuptable'], $field['display_column'], !empty($field['filter']) ? $field['filter'] : array(), !empty($field['lookupkey']) ? $field['lookupkey'] : $field['field']);
             } elseif ($field['type'] == "yesno") {
                 $options = array(1 => 'No', 2 => 'Yes');
             } elseif ($field['type'] == "state") {
                 $options = Location::getStateOptions();
             } elseif ($field['type'] == "country") {
                 $options = Location::getCountryOptions();
             } else {
                 $options = $field['options'];
             }
             if (!is_array($options)) {
                 return false;
             }
             if (!empty($field['allow_blank'])) {
                 $options = array('' => '') + $options;
             }
             $output = BasicHTML::select($field['form_field'], $options, $field['Value']);
             if (!empty($field['pop_add'])) {
                 if ($field['table_url']) {
                     $location = $field['table_url'];
                 } else {
                     $location = "table.php?table=" . $field['lookuptable'];
                 }
                 $output .= "<a onclick='lightning.table.newPop(\"{$location}\",\"{$field['form_field']}\",\"{$field['display_column']}\")'>Add New Item</a>";
             }
             return $output;
             break;
         case 'range':
             $output = "<select name='{$field['form_field']}' id='{$field['form_field']}'>";
             if ($field['allow_blank']) {
                 $output .= '<option value="0"></option>';
             }
             if ($field['start'] < $field['end']) {
                 for ($k = $field['start']; $k <= $field['end']; $k++) {
                     $output .= "<option value='{$k}'" . ($field['Value'] == $k ? 'selected="selected"' : '') . ">{$k}</option>";
                 }
             }
             $output .= '</select>';
             return $output;
             break;
         case 'checkbox':
             return "<input type='checkbox' name='{$field['form_field']}' id='{$field['form_field']}' value='1' " . ($field['Value'] == 1 ? "checked" : '') . " />";
             break;
         case 'note':
             return $field['note'];
             break;
         case 'checklist':
             $vals = $this->decode_bool_group($field['Value']);
             $output = '';
             foreach ($field['options'] as $i => $opt) {
                 if (is_array($opt)) {
                     $id = $opt[0];
                     $name = $opt[1];
                 } else {
                     $id = $i;
                     $name = $opt;
                 }
                 $output .= "<div class='checlist_item'><input type='checkbox' name='{$field['form_field']}_{$id}' value='1' " . ($vals[$id] == 1 ? "checked" : '') . " />{$name}</div>";
             }
             return $output;
             break;
         case 'varchar':
         case 'char':
             preg_match('/(.+)\\(([0-9]+)\\)/i', $field['type'], $array);
             $options['size'] = $array[2];
         default:
             if (!empty($field['autocomplete'])) {
                 $options['classes'] = array('table_autocomplete');
                 $options['autocomplete'] = false;
             }
             return Text::textfield($field['form_field'], $field['Value'], $options);
             break;
     }
 }