Example #1
0
 /**
  * Outputs the code and content for the accordion
  * @return string
  */
 public function render()
 {
     global $SITE, $CONFIG;
     JS::loadjQuery();
     JS::raw('$(function() {$(".ui-accordion-container").accordion({ header: "h3" ' . ($this->params ? ',' . $this->params : '') . '});});');
     Head::add($CONFIG->UI->jQuery_theme . '/jquery-ui-*', 'css-lib');
     Head::add('.ui-accordion-container li {width: 100%;}', 'css-raw');
     $r = '<ol class="ui-accordion-container">';
     $mode = 0;
     $title = false;
     $selected = false;
     $i = 0;
     foreach ($this->tabs as $arg) {
         if ($mode == 0) {
             $title = $arg;
             $mode = 1;
         } else {
             $r .= '
                 <li>
                     <h3><a href="#">' . $title . '</a></h3>
                     <div>' . $arg . '</div>
                 </li>';
             $mode = 0;
             $selected = false;
             $title = false;
             $i++;
         }
     }
     return $r . '</ol>';
 }
 function imageEditor()
 {
     JS::loadjQuery();
     JS::lib('jquery/jquery.imgareaselect-*');
     JS::lib('imgTools');
     $size = getimagesize($this->that->path);
     return Form::quick(false, __('Save'), new Input(__('Filename'), 'filename', $_POST['filename'] ? $_POST['filename'] : $this->that->basename), new Hidden('cropimgx', $_POST['cropimgx']), new Hidden('cropimgy', $_POST['cropimgy']), new Hidden('cropimgw', $_POST['cropimgw']), new Hidden('cropimgh', $_POST['cropimgh']), new Tabber('img', new Tab(__('Cropping'), '<div id="imgcropper"><img style="float: left" id="originalImage" src="?id=' . $this->that->ID . '&amp;w=400" /><div style="clear: both;"></div></div>'), new Tab(__('Resize'), '<div id="imgresize"><div id="resval" style="clear: right;"><input name="resimgx" id="resimgx" size="4" value="' . $size[0] . '" />x<input name="resimgy" id="resimgy" size="4" value="' . $size[1] . '" /></div></div>'), new Tab(__('Rotate'), new Select(__('Specify rotation (CCW)'), 'imgrot', array('0' => __('None'), '90' => '90 &deg;', '180' => '180 &deg;', '270' => '270 &deg;'), $_REQUEST['imgrot']))));
 }
 function render()
 {
     JS::loadjQuery();
     JS::lib('viewslider');
     JS::raw('$(function(){$("div.viewslider-view").closest(".formdiv").viewslider();});');
     Head::add('viewslider/viewslider', 'css-lib');
     return '<div class="formsection viewslider-view"><h3>' . $this->header . '</h3>' . implode('', flatten($this->elements)) . '</div>';
 }
Example #4
0
 function render()
 {
     $id = idfy($this->name);
     JS::loadjQuery();
     Head::add('$(function(){$(".sortable_list").sortable({axis:"y"});});', 'js-raw');
     $val = (array) $this->value;
     array_walk($val, array($this, 'addHiddenFormField'));
     return '<span class="formelem">' . ($this->label === false ? '' : '<label for"' . $id . '">' . $this->label . '</label>') . listify($val, 'sortable_list' . ($this->validate ? ' ' . $this->validate : '')) . (strpos($this->validate, 'required') !== false ? '<span class="reqstar">*</span>' : '') . ($this->description ? '<span class="description">' . $this->description . '</span>' : '') . '</span>';
 }
 function render()
 {
     $id = idfy($this->name);
     JS::loadjQuery(false);
     JS::lib('imgPicker');
     JS::raw('setupPreview("' . $id . '");');
     //FIXME: Flytta styling till stylesheet!
     return '<span class="formelem">' . ($this->label === false ? '' : '<label for="' . $id . '">' . $this->label . '</label>') . '<input name="' . $this->name . '" id="' . $id . '" class="text' . ($this->validate ? ' ' . $this->validate : '') . '" value="' . $this->value . '" type="hidden" />' . '<div class="tools">' . icon('small/cross', __('Remove'), "javascript:removePreview('{$id}');", $id . "remicon") . icon('small/folder_picture', __('Browse picture'), "javascript:explore('{$id}', " . ($this->dir ? $this->dir : 'false') . ");") . '</div>' . (strpos($this->validate, 'required') !== false ? '<span class="reqstar">*</span>' : '') . ($this->description ? '<span class="description">' . $this->description . '</span>' : '') . ($this->preview ? '<div id="' . $id . 'prev" style="margin:10px 0 5px 150px;"><img id="' . $id . 'img" src="index.php?id=' . $this->value . '&mw=300" /></div>' : '') . '</span>';
 }
Example #6
0
 function render()
 {
     $id = idfy($this->name);
     if (is_array($this->value)) {
         $value = Short::parseDateAndTime($this->value);
     }
     global $CONFIG;
     JS::loadjQuery(true);
     JS::lib('jquery/jquery.timePicker');
     Head::add('timePicker', 'css-lib');
     Head::add('$(function(){$("input.time").timePicker();});', 'js-raw');
     return '<span class="formelem">' . ($this->label === false ? '' : '<label for="' . $id . '">' . $this->label . '</label>') . '<input name="' . $this->name . '" id="' . $id . '" class="time' . ($this->validate ? ' ' . $this->validate : '') . ($this->class ? ' ' . $this->class : '') . '" value="' . (is_numeric($this->value) ? date('H:i', $this->value) : $this->value) . '" />' . (strpos($this->validate, 'required') !== false ? '<span class="reqstar">*</span>' : '') . ($this->description ? '<span class="description">' . $this->description . '</span>' : '') . '</span>';
 }
Example #7
0
 function render()
 {
     $id = idfy($this->name);
     JS::loadjQuery(false);
     if ($this->available_values) {
         JS::lib('jquery/jquery.bgiframe.min');
         JS::lib('jquery/jquery-plugin-ajaxqueue');
         JS::lib('jquery/jquery.autocomplete.min');
         Head::add('jquery.autocomplete', 'css-lib');
         JS::raw('$(function(){$("#' . $id . '").autocomplete(["' . join('","', $this->available_values) . '"], {width: 320,max: 4,highlight: false,multiple: true,multipleSeparator: " ",scroll: true,scrollHeight: 300})});');
     }
     $r = ($this->label === false ? '' : '<label for="' . $id . '">' . $this->label . '</label>') . '<input name="' . $this->name . '" id="' . $id . '" class="text tags' . ($this->validate ? ' ' . $this->validate : '') . '" value="' . $this->value . '" />' . ($this->description ? '<span class="description">' . $this->description . '</span>' : '');
     return '<span class="formelem">' . $r . '</span>';
 }
Example #8
0
 function popup($URL, $window_name = false, $settings = false)
 {
     if ($settings) {
         $settings_ = $settings;
         $settings = '';
         foreach ($settings_ as $key => $opt) {
             $settings .= $key . '=' . $opt . ',';
         }
     }
     if (!$window_name) {
         $window_name = self::$currentWindowHandle;
     } else {
         self::$currentWindowHandle = $window_name;
     }
     $id = idfy($URL);
     JS::loadjQuery();
     Head::add('$(function(){$("' . $id . '").click(function(){});});', 'js-raw');
     return '<a href="' . url($URL) . '" id="' . $id . '"';
 }
 /**
  * Replaces the emails with a flash text with the email
  * @param $match preg_replace match
  * @return string Flash html-code
  */
 function safeEmailsHelper($match)
 {
     JS::lib('flashurl', false, false);
     JS::loadjQuery(false, false);
     static $i = 0;
     $i++;
     if (count($match) == 2) {
         $url = $match[0];
         $label = false;
     } else {
         $url = $match[1];
         $label = $match[2];
         if (isEmail($label)) {
             $label = false;
         }
     }
     $url = base64_encode($url);
     return '<span class="flashurl"><object id="flashurl' . $i . '" type="application/x-shockwave-flash" data="lib/swf/flashurl.swf"><param name="FlashVars" value="divID=flashurl' . $i . '&amp;encURL=' . urlencode($url) . ($label ? '&amp;urlLabel=' . $label : '') . '" /><param name="movie" value="/lib/swf/flashurl.swf" /><param name="wmode" value="transparent" /></object></span>';
 }
Example #10
0
 function render()
 {
     $id = idfy($this->name);
     JS::loadjQuery();
     /*
             Head::add('3rdParty/tiny_mce/tiny_mce_gzip.js', 'js-url', true, false, false);
     */
     /*
             Head::add('tinyMCEGZinit', 'js-lib', true, false, false);
     */
     //Head::add('3rdParty/tiny_mce/tiny_mce.js', 'js-url', true, false, false);
     /*
             Head::add('tinyMCEinit', 'js-lib', true, false, false);
     */
     //testar ny editor
     Head::add('3rdParty/ckeditor/ckeditor.js', 'js-url', false, false);
     Head::add('3rdParty/ckeditor/adapters/jquery.js', 'js-url', false, false);
     JS::raw('CKEDITOR.replace("' . $id . '",{customConfig : "/3rdParty/ckeditor/config.js"});');
     return '<span class="formelem">' . ($this->label === false ? '' : '<label for="' . $id . '">' . $this->label . '</label>') . '<textarea id="' . $id . '" name="' . $this->name . '" class="textarea mceEditor' . ($this->validate ? ' ' . $this->validate : '') . ($this->validate ? ' ' : '') . $this->class . '" rows="8" cols="70">' . $this->value . '</textarea>' . (strpos($this->validate, 'required') !== false ? '<span class="reqstar">*</span>' : '') . ($this->description ? '<span class="description">' . $this->description . '</span>' : '') . '</span>';
 }
Example #11
0
 /**
  * Display all flashes
  * @return HTML
  */
 static function display()
 {
     if (isset($_SESSION['__FLASHES']) && is_array($_SESSION['__FLASHES'])) {
         self::$__FLASHES = $_SESSION['__FLASHES'] + self::$__FLASHES;
         unset($_SESSION['__FLASHES']);
     }
     if (!empty(self::$__FLASHES)) {
         echo '<div class="flash_container">';
         foreach (self::$__FLASHES as $type => $flashes) {
             echo '<div class="flash flash_type_' . $type . '"><div class="icon"></div><ul>';
             foreach ($flashes as $flash) {
                 echo '<li>' . $flash . '</li>';
             }
             echo '</ul></div>';
         }
         //FIXME: Add function for yes/no buttons
         echo '</div>';
         JS::loadjQuery(true);
         JS::raw('$(function(){' . '$(".flash_container").dialog({modal:true,buttons:{Ok:function(){$(this).dialog("close");}}});' . '});');
     }
 }
Example #12
0
 /**
  * (non-PHPdoc)
  * @see solidbase/lib/__FormField#render()
  */
 function render()
 {
     $id = idfy($this->name);
     if ($this->value === false) {
         $sel = $this->interval;
     } else {
         $sel = (array) $this->value;
         if (count($sel) == 1) {
             $sel[1] = $sel[0];
         }
     }
     Head::add(JQUERY_THEME . '/jquery-ui-1.8.7.custom', 'css-lib');
     if (!$this->nojs) {
         JS::loadjQuery(true);
         JS::raw('$(function(){$("#' . $id . ' .slider").slider({' . 'range:' . ($this->return_interval ? 'true' : 'false') . ',' . 'min:' . $this->interval[0] . ',' . 'max:' . $this->interval[1] . ',' . 'values:[' . ($this->return_interval ? $sel[0] . ',' . $sel[1] : $sel[0]) . '],' . 'slide:function(event,ui){' . '$(event.target).closest(".slidercontainer")' . '
                 .find(".val_low").text(ui.values[0]).end()' . ($this->return_interval ? '
                 .find(".val_high").text(ui.values[1]).end()' : '') . '
                 .find(".sliderfield").val(ui.values[0]' . ($this->return_interval ? '+":"+ui.values[1]' : '') . '
                 );' . '}});});');
     }
     JS::raw('$(".sliderfield").hide();');
     return '<span class="formelem"><div id="' . $id . '" class="slidercontainer">' . ($this->label === false ? '' : '<label for="' . $id . '">' . $this->label . '</label>') . '<input name="' . $this->name . '" id="' . $id . '_value" class="sliderfield' . ($this->validate ? ' ' . $this->validate : '') . ($this->class ? ' ' . $this->class : '') . '" value="' . ($this->return_interval ? $sel[0] . ":" . $sel[1] : $sel[0]) . '" />' . '<div class="slidervalues">' . '<span class="slidertext val_low">' . $sel[0] . '</span>' . ($this->return_interval ? '<span class="slidertext sliderdash">-</span><span class="slidertext val_high">' . $sel[1] . '</span>' : '') . '</div>' . '<div class="slider"></div>' . (strpos($this->validate, 'required') !== false ? '<span class="reqstar">*</span>' : '') . ($this->description ? '<span class="description">' . $this->description . '</span>' : '') . '</div></span>';
 }
Example #13
0
    /**
     * Renders the HTML and loads the libraries needed to view the tabs
     * @return void
     */
    public function render()
    {
        global $SITE, $CONFIG;
        static $tabnames = array();
        JS::loadjQuery();
        JS::raw('$(function() {$(".ui-tabs-dohide").addClass("ui-tabs-hide");$(".ui-tabs").tabs({show:function(event,ui){
        id = $(ui.tab.hash).attr("id");
        obj = $(ui.tab.hash).attr("id", ""); //So the browser doesnt jump to the object
        window.location.hash=ui.tab.hash;
        obj.attr("id", id);

    }});
    //if(window.location.hash) {
        //$(window.location.hash).parent(".ui-tabs").tabs("select", document.location.hash);
    //}
    });');
        Head::add($CONFIG->UI->jQuery_theme . '/jquery-ui-*', 'css-lib');
        $r = '<div class="ui-tabs"><ul class="ui-tabs-nav">';
        foreach ($this->tabs as $id => $tab) {
            $a = $tab->id;
            $i = 0;
            while (in_array($a, $tabnames)) {
                $i++;
                $a = $tab->id . $i;
            }
            $tabnames[] = $tab->id = $a;
            $classes = implode(' ', array_filter(array($tab->selected ? 'ui-tabs-selected' : false, $tab->disabled ? 'ui-tabs-disabled' : false)));
            $r .= '<li class="' . $classes . '">' . '<a href="#tab' . $this->uniqid . (!is_numeric($id) ? $id : ($tab->id ? $tab->id : $id)) . '"><span>' . $tab->name . '</span></a></li>';
        }
        $r .= '</ul>';
        foreach ($this->tabs as $id => $tab) {
            $id = $this->uniqid . (!is_numeric($id) ? $id : ($tab->id ? $tab->id : $id));
            $r .= '<div id="tab' . $id . '" class="ui-tabs-panel' . (!$tab->selected ? ' ui-tabs-dohide' : '') . '">' . str_replace('#::tab-id::#', 'tab' . $id, $tab->render()) . '</div>';
        }
        return $r . '</div>';
    }
Example #14
0
new Menu('main_menu', 1, false, false, false, true);
new Box('newLogin');
/* 		if($PAGE->mayI(EDIT)) echo '<div class="admin"><a href="'.url(array('id' => 'admin_area')).'">Admin<span>av sidan</span></a></div>';  */
?>
    </div>
    <div class="login_test">test</div>

</div>

<?php 
new Box('feedback');
/* $Controller->newObj('Report')->setAlias('Report'); */
?>

<?php 
JS::loadjQuery(false);
JS::lib('jquery/jquery.keynav.1.1');
JS::lib('globalsearch');
/* 	JS::lib('jquery/jquery.backgroundPosition'); */
JS::lib('jquery/jquery.lavalamp-1.3.4b2');
JS::lib('jquery/jquery.easing.1.3');
/* 	Head::add('$(document).ready(function() { $("#username").focus();});','js-raw'); */
/*
    JS::raw('
        $(".topnav li a, .topnav div.admin a")
            .css({backgroundPosition:"0 -50px"})
            .mouseover(function() {
                $(this).stop(true)
                    .animate({backgroundPosition:"0 0"},"fast")
                })
            .mouseout(function() {
 function run()
 {
     global $Templates, $DB, $Controller;
     if (!$this->mayI(READ | EDIT)) {
         errorPage('401');
         return false;
     }
     $_REQUEST->setType('add', 'string');
     $_REQUEST->setType('edit', 'numeric');
     $_REQUEST->setType('del', 'numeric');
     $_REQUEST->setType('module', 'string');
     $_REQUEST->setType('type', 'string');
     $_REQUEST->setType('size', 'string');
     $_REQUEST->setType('content', 'string');
     $_REQUEST->setType('row', 'numeric');
     $_REQUEST->setType('place', 'numeric');
     //FIXME: Tillsvidare: Id pĂĄ sidan som editeras
     $pID = 8;
     if ($_REQUEST['add']) {
         $newModule = $Controller->newObj('PageModule');
         $newModule->addData($pID, $_REQUEST['add']);
     } elseif ($_REQUEST['edit']) {
         $module = $Controller->{$_REQUEST['edit']};
         if ($_REQUEST['module']) {
             $module->module = $_REQUEST['module'];
         } elseif ($_REQUEST['size']) {
             $module->size = $_REQUEST['size'];
         } elseif ($_REQUEST['type']) {
             $module->type = $_REQUEST['type'];
         } elseif ($_REQUEST['row'] !== false && $_REQUEST['place'] !== false) {
             $module->move($_REQUEST['row'], $_REQUEST['place']);
         } elseif ($_REQUEST['content']) {
             $module->content = $_REQUEST['content'];
         }
     } elseif ($_REQUEST['del']) {
         $Controller->{$_REQUEST['del']}->delete();
     }
     /* Get numbers of rows on page*/
     $rowNum = $DB->pagelayout->getCell(array('pid' => $pID), "MAX(ROW)");
     $pagecontent = false;
     /* Get modules from each row */
     for ($row = 0; $row <= $rowNum; $row++) {
         $moduleIDs = $DB->pagelayout->asList(array('pid' => $pID, 'row' => $row), 'id', false, false, 'place');
         $rowContent = array();
         foreach ($moduleIDs as $mID) {
             $moduleObj = $Controller->{$mID};
             $rowContent[] = $moduleObj;
         }
         $pagecontent[$row] = $rowContent;
     }
     JS::loadjQuery();
     JS::lib('pagelayoutedit');
     $this->header = __('Page Layout');
     $this->setContent('main', '<h1>Page Layout</h1>' . $this->displayEditor($pagecontent));
     $Templates->admin->render();
 }
 function viewPeriod($start, $stop)
 {
     JS::loadjQuery();
     Head::add('SB_Calendar', 'js-lib');
     Head::add('$(".cal_viewdate a").not(".cal_obj_links a").click(SB_Calendar.popup);', 'js-raw');
     if (!is_numeric($start)) {
         $start = strtotime($start);
     }
     if (!is_numeric($stop)) {
         $stop = strtotime($stop);
     }
     $result = '';
     $result .= '<div class="nav"><a href="' . url(array('when' => date('Y-m')), array('id')) . '">' . icon('small/arrow_up') . __('Up') . '</a></div>';
     $result .= '<table cellpadding="0" cellspacing="0" border="0">';
     $this->loadBookings($start, $stop);
     $i = 0;
     while (true) {
         $dayStarts = mktime(0, 0, 0, date('m', $start), date('d', $start) + $i, date('Y', $start));
         $dayEnds = mktime(0, 0, 0, date('m', $start), date('d', $start) + ++$i, date('Y', $start));
         if ($dayEnds >= $stop) {
             break;
         }
         if (!$this->isFree($dayStarts, 86400)) {
             $result .= '<tr><th>' . date('Y-m-d', $dayStarts) . '</th><td>';
             $result .= $this->viewDatEmptyTable($dayStarts);
             $result .= '</td></tr>';
         }
     }
     $result .= '</table>';
     return $result;
 }
Example #17
0
 function editForm()
 {
     global $DB, $Controller;
     if (!$this->mayI(EDIT)) {
         return false;
     }
     $this->saveForm();
     if ($_REQUEST['delfield']) {
         $DB->formfields->delete(array('id' => $this->ID, 'field_id' => $_REQUEST['delfield']));
         $DB->formdata->delete(array('id' => $this->ID, 'field_id' => $_REQUEST['delfield']));
         $_REQUEST->clear('delfield');
     }
     $fieldTypes = array('input' => __('Text input'), 'Checkbox' => __('Checkbox'), 'pCheckbox' => __('Checkbox, preselected'), 'select' => __('Select'), 'mselect' => __('Select multiple'), 'textarea' => __('Textarea'), 'htmlfield' => __('HTML'), 'Radio' => __('Radio button'), 'hidden' => __('Hidden'));
     $formFields = array();
     if ($this->page !== 'new') {
         $r = $DB->formfields->get(array('id' => $this->ID), false, false, 'sort');
         while (false !== ($field = Database::fetchAssoc($r))) {
             $formFields[] = new Tablerow(icon('small/arrow_switch', __('Move'), '#', 'fieldhandle'), new select(false, 'form[' . $field['field_id'] . '][type]', $fieldTypes, $field['type'], false, false, false, false, 'medium'), new Input(false, 'form[' . $field['field_id'] . '][lbl]', $field['label'], false, false, 'medium'), new Input(false, 'form[' . $field['field_id'] . '][val]', $field['value'], false, false, 'medium'), icon('small/delete', __('Delete field'), url(array('delfield' => $field['field_id']), true)));
         }
     }
     if ($_REQUEST['newFormField']) {
         $nid = uniqid();
         $formFields[] = new Tablerow(icon('small/arrow_switch', __('Move'), '#', 'fieldhandle'), new Hidden('form[' . $nid . '][new]', 1) . new select(false, 'form[' . $nid . '][type]', $fieldTypes, false, false, false, false, false, 'medium'), new Input(false, 'form[' . $nid . '][lbl]', false, false, false, 'medium'), new Input(false, 'form[' . $nid . '][val]', false, false, false, 'medium'));
     }
     if (!empty($formFields)) {
         $ff = new Table(new Tableheader('', __('Type'), __('Label'), __('Value(s)')), $formFields);
         $ff->id = 'formfields';
         JS::loadjQuery();
         Head::add('$(function(){$("#formfields tr").parent().sortable({handle:".fieldhandle"});$(".fieldhandle").click(function(){return false;}).css("cursor","move");});', 'js-raw');
     } else {
         $ff = null;
     }
     $active = $this->getActive('form');
     return new Set(new input(__('Form title'), 'ftitle', $this->_Form_Title), new Li(new Datepicker(__('Activate'), 'formactivate[date]', isset($active['start']) ? date('Y-m-d', $active['start']) : ''), new Timepickr(false, 'formactivate[time]', isset($active['start']) ? date('H:i', $active['start']) : '')), new Li(new Datepicker(__('Deactivate'), 'formdeactivate[date]', isset($active['stop']) ? date('Y-m-d', $active['stop']) : ''), new Timepickr(false, 'formdeactivate[time]', isset($active['stop']) ? date('H:i', $active['stop']) : '')), new select(__('Public form'), 'formpublic', array(__('Closed'), __('Names disclosed'), __('Full disclosure')), $this->_Public_Form), new input(__('Limit'), 'formlimit', $this->_Limit), $ff, new submit(__('New field'), 'newFormField'));
 }
Example #18
0
 function internal($title, $image, $alt = '', $youtube = false, $youtubetext = false, $comment = false)
 {
     if (!$youtubetext) {
         $youtubetext = 'Dagens videolänk';
     }
     if (is_array($image)) {
         JS::loadjQuery();
         JS::lib('jquery/jquery.cycle.all.2.72');
         JS::raw("\$('.images').cycle({fx:'fade'});");
     } else {
         $image = array($image);
     }
     Head::add('h1 {font-size: 3em; color: #000;} div {text-align: center;} .images {position: relative; left: 600px; margin: 0 0 0 -525px; width: 600px;} .youtube {font-size: 2em;} .wrapper {border: 10px solid red;}', 'css-raw');
     $r = '';
     if ($title) {
         $r .= '<h1>' . $title . '</h1>';
     }
     $r .= '<div class="images">';
     foreach ($image as $img) {
         if ($img[0] == '<') {
             $r .= $img;
         } else {
             $r .= '<img src="' . $img . '" alt="' . $alt . '" title="' . $alt . '" />';
         }
     }
     $r .= '</div>';
     if ($comment) {
         $r .= '<div class="comment">' . nl2br($comment) . '</div>';
     }
     if ($youtube) {
         $youtube = (array) $youtube;
         $youtubetext = (array) $youtubetext;
         foreach ($youtube as $i => $yt) {
             if (isset($youtubetext[$i])) {
                 $r .= '<div class="youtube"><a href="' . $yt . '" target="_blank">' . $youtubetext[$i] . '</a></div>';
             }
         }
     }
     $this->setContent('main', $r);
 }
Example #19
0
 function selectLanguage()
 {
     global $CONFIG;
     JS::loadjQuery(false);
     JS::raw("\$(function(){\$('#" . idfy('user_settings::language') . "').change(function(e){\$(e.target).closest('form').submit();})});");
     echo Form::quick(url(null, true), false, new Select(false, 'user_settings::language', google::languages($CONFIG->Site->languages), @$_COOKIE['user_settings::language'], false, __('Choose language')));
 }
Example #20
0
 /**
  * Render the menu for editing
  * @param array $array
  * @return string
  */
 private function makeMenu($array)
 {
     static $i = 0;
     static $recursion = 0;
     if (count($array) == 0) {
         return;
     }
     ++$recursion;
     global $CONFIG, $USER;
     if ($this->mayI(EDIT)) {
         JS::loadjQuery(false);
         JS::lib('menusort');
     }
     /* $r=''; */
     $r = '<ul class="menulist">';
     $save = array('edit', 'with', 'id');
     while (list(, $obj) = each($array)) {
         $r .= '<li id="m' . $obj['id'] . '" class="' . (++$i % 2 ? 'odd' : 'even') . (is_a($obj['object'], 'MenuSection') ? ' menusection' : '') . '"><span class="fixed-width">' . $obj['object'] . '</span>' . Box::tools($obj['object']) . Box::dropdown('small/add', false, array(icon('small/arrow_right', __('New child page'), url(array('action' => 'newpage', 'where' => 'child', 'to' => $obj['id']), $save), true), icon('small/arrow_down', __('New page below'), url(array('action' => 'newpage', 'where' => 'below', 'to' => $obj['id']), $save), true))) . Box::dropdown('small/arrow_out', false, false, 'pagemove') . (isset($obj['children']) ? $this->makeMenu($obj['children']) : '') . '</li>';
     }
     $r .= '</ul>';
     --$recursion;
     if ($recursion == 0) {
         $i = 0;
     }
     return $r;
 }
Example #21
0
 function getSearchbar($resultNum = false)
 {
     JS::loadjQuery(false);
     Head::add('templates/yweb/js/search.js', 'js-url');
     $r = '<h1>' . __('Search Results') . '</h1>
                 <div id="searchbar">
                     <form id="sb-form" action="." method="get" class="search">
                         <fieldset>
                             <input type="hidden" name="id" value="search" />
                             <label for="sb-searchtext"></label>
                             <input type="text" name="q" id="sb-searchtext" placeholder="' . __('Search') . '" value="' . $_REQUEST['q'] . '" />
                             <span id="sb-action" class="search-clear"></span>
                         </fieldset>
                     </form>
                     <p>';
     if ($resultNum) {
         if ($resultNum == -1) {
             $r .= __('To many search terms. Remove some words and try again.');
         } else {
             $r .= $resultNum . ' ' . __('results found for') . ' <b>' . $_REQUEST['q'] . '</b>';
         }
     }
     $r .= '</p></div>';
     return $r;
 }
Example #22
0
 function run()
 {
     global $DB, $Templates, $Controller, $CONFIG;
     $_REQUEST->setType('lfrom', '#\\d\\d-\\d\\d-\\d\\d#');
     $_REQUEST->setType('lto', '#\\d\\d-\\d\\d-\\d\\d#');
     $_REQUEST->setType('lrh', 'string');
     $_REQUEST->setType('luser', 'string');
     $_REQUEST->setType('lsource', 'string');
     $_REQUEST->setType('llevel', 'numeric');
     $ENTRIES = array();
     $from = false;
     $to = false;
     if ($_REQUEST['lfrom']) {
         $from = strtotime($_REQUEST['lfrom']);
     }
     if (!$from) {
         $from = mktime(0, 0, 0, date('m') - 1, date('d'), date('Y'));
     }
     if ($_REQUEST['lto']) {
         $to = strtotime($_REQUEST['lto']) + 86400;
     }
     if (!$to) {
         $to = time();
     }
     $ENTRIES = $DB->log->asArray(array('time>=' => date('Y-m-d H:i:s', $from), 'time<=' => date('Y-m-d H:i:s', $to)));
     if (file_exists(PRIV_PATH . '/log')) {
         $logfile = file(PRIV_PATH . '/log');
         foreach ($logfile as $row => $entryRow) {
             if (empty($entryRow) || $entryRow == "\n") {
                 continue;
             }
             $entry = array();
             list($entry['time'], $entry['remote_addr'], $entry['user'], $entry['source'], $entry['level'], $entry['message']) = explode("\t", $entryRow);
             $t = strtotime($entry['time']);
             if ($t >= $from && $t <= $to) {
                 $ENTRIES[] = $entry;
             }
         }
     }
     usort($ENTRIES, create_function('$a,$b', 'return -strcmp($a["time"], $b["time"]);'));
     $perpage = 250;
     $total = count($ENTRIES);
     $pager = Pagination::getRange($perpage, $total);
     $ENTRIES = array_slice($ENTRIES, $pager['range']['start'], $perpage);
     $TEXT = '';
     $i = 0;
     foreach ($ENTRIES as $entry) {
         if ($a = $Controller->{$entry['user']}('User')) {
             $entry['user'] = $a->link();
         }
         if ($entry['level'] < $_REQUEST['llevel'] || $_REQUEST['luser'] && stristr($entry['user'], $_REQUEST['luser']) === false || $_REQUEST['lrh'] && stristr($entry['remote_addr'], $_REQUEST['lrh']) === false || $_REQUEST['lsource'] && stristr($entry['source'], $_REQUEST['lsource']) === false) {
             continue;
         }
         $entry['message'] = preg_replace_callback('/id=([0-9]+)/', create_function('$matches', 'global $Controller; if ($obj = $Controller->retrieve($matches[1], ANYTHING, false, false)) return $obj->link(); return $matches[0];'), $entry['message']);
         $entry['source'] = preg_replace_callback('/([0-9]+)/', create_function('$matches', 'global $Controller; if ($obj = $Controller->retrieve($matches[1], ANYTHING, false, false)) return $obj->link(); return $matches[0];'), $entry['source']);
         $TEXT .= '<tr class="' . (++$i % 2 ? 'even' : 'odd') . '"><td>' . join("</td><td>", $entry) . '</td></tr>';
     }
     $this->setContent('header', __('View log'));
     JS::loadjQuery();
     Head::add('$(function(){$(".Datepicker").Datepicker({ dateFormat: "yy-mm-dd" });});', 'js-raw');
     Head::add($CONFIG->UI->jQuery_theme . '/jquery-ui-*', 'css-lib');
     $this->setContent('main', '<form action="' . url(null, 'id') . '" method="post"><input type="submit" value="' . __('Filter') . '" /><table class="log">' . '<tr><th>' . __('Time') . "</th><th>" . __('Remote address') . "</th><th>" . __('User') . "</th><th>" . __('Source') . "</th><th>" . __('Level') . "</th><th>" . __('Message') . '</th></tr>' . '<tr><td><input name="lfrom" class="small Datepicker" value="' . $_REQUEST['lfrom'] . '" />-<input name="lto" class="small Datepicker" value="' . $_REQUEST['lto'] . '" /></td><td><input name="lrh" class="small" value="' . $_REQUEST['lrh'] . '" /></td><td><input name="luser" class="small" value="' . $_REQUEST['luser'] . '" /></td><td><input name="lsource" class="small" value="' . $_REQUEST['lsource'] . '" /></td><td><input name="llevel" class="small" value="' . $_REQUEST['llevel'] . '" /></td><td></td></tr>' . $TEXT . '</table></form>' . ($total > $perpage ? $pager['links'] : ''));
     $Templates->render();
 }
Example #23
0
 function run()
 {
     if (!$this->mayI(READ | EDIT)) {
         return false;
     }
     global $USER, $Controller, $DB, $Templates, $SITE;
     $_POST->setType('newMail', 'numeric');
     $_POST->setType('from', 'numeric');
     $_POST->setType('recipients', 'numeric', true);
     $_POST->setType('subject', 'string');
     $_POST->setType('message', 'any');
     $_POST->setType('personal', 'string');
     $_POST->setType('sendd', 'string');
     $_POST->setType('sendt', 'string');
     $_REQUEST->setType('to', 'numeric');
     $_REQUEST->setType('eedit', 'numeric');
     $_REQUEST->setType('edelete', 'numeric');
     $_POST->setType('save', 'string');
     $_POST->setType('approve', 'string');
     $_POST->setType('continue', 'string');
     $_POST->setType('saveac', 'string');
     $_POST->setType('bypass', 'any');
     if ($_REQUEST['eedit']) {
         if ($_POST['save'] || $_POST['saveac']) {
             $msg = $DB->massmail->getRow(array('msg_id' => $_REQUEST['eedit']));
             if ($msg && ($msg['author'] == $USER->ID || $this->mayI(EDIT))) {
                 if ($_POST->valid('recipients', 'subject', 'message')) {
                     $approved = $_POST['approve'] && $this->mayI(EDIT);
                     $DB->massmail->update(array('author' => $USER->ID, '#!written' . ($_REQUEST['save'] ? '' : 'NO_INSERT') => 'UNIX_TIMESTAMP()', 'from' => $_POST['from'], 'recipients' => $_POST['recipients'], 'subject' => $_POST['subject'], 'message' => $_POST['message'], 'personal' => $_POST['personal'] ? 'yes' : 'no', 'approved' => $approved ? $USER->ID : '0', 'send' => strtotime($_POST['sendd'] . ' ' . $_POST['sendt']), 'override_membercheck' => $_POST['bypass'] && $Controller->{(string) ADMIN_GROUP}(OVERRIDE)->isMember($USER)), array('msg_id' => $msg['msg_id']));
                     if (!($_POST['personal'] || $approved || $Controller->{(string) ADMIN_GROUP}(OVERRIDE)->isMember($USER))) {
                         new Notification(__('New email'), __('A new email has been queued on ') . url(array('id' => 'mailer')), $Controller->{ADMIN_GROUP}(OVERRIDE));
                     }
                     $_POST->clear('newMail', 'from', 'recipients', 'subject', 'message', 'personal', 'send', 'bypass');
                     if ($_POST['save']) {
                         Flash::create(__('Changes were saved'), 'confirmation');
                     } else {
                         Flash::create(__('Email saved and queued for sending'), 'confirmation');
                     }
                     $_POST->clear('from', 'recipients', 'subject', 'message', 'personal', 'send');
                 } else {
                     Flash::create(__('Invalid email. Please try again'), 'warning');
                 }
             }
         }
         if (($_POST['saveac'] || $_POST['continue']) && $this->mayI(EDIT)) {
             if ($_POST['continue']) {
                 $_POST->clear('from', 'recipients', 'subject', 'message', 'personal', 'send');
             }
             $_REQUEST['eedit'] = $DB->massmail->getCell(array('approved' => '0', 'personal' => 'no', 'msg_id!' => $_REQUEST['eedit']), 'msg_id', 'written ASC');
         } elseif ($_POST['save']) {
             $_REQUEST->clear('eedit');
         }
     } elseif ($_REQUEST['edelete']) {
         $msg = $DB->massmail->getRow(array('msg_id' => $_REQUEST['edelete']));
         if ($msg && ($msg['author'] == $USER->ID || $this->mayI(DELETE))) {
             $DB->massmail->delete(array('msg_id' => $msg['msg_id']));
             Flash::create(__('Email deleted'), 'warning');
         }
         unset($msg);
     }
     if ($_POST['newMail']) {
         if ($_POST->validNotEmpty('recipients', 'subject', 'message')) {
             $approved = $_POST['approve'] && $this->mayI(EDIT);
             $DB->massmail->insert(array('author' => $USER->ID, '#!written' => 'UNIX_TIMESTAMP()', 'from' => $_POST['from'], 'recipients' => $_POST['recipients'], 'subject' => $_POST['subject'], 'message' => $_POST['message'], 'personal' => $_POST['personal'] ? 'yes' : 'no', 'approved' => $approved ? $USER->ID : '0', 'send' => $_POST['send'] ? strtotime($_POST['send']) : time(), 'override_membercheck' => $_POST['bypass'] && $Controller->{(string) ADMIN_GROUP}(OVERRIDE)->isMember($USER)));
             if (!($_POST['personal'] || $approved || $Controller->{(string) ADMIN_GROUP}(OVERRIDE)->isMember($USER))) {
                 new Notification(__('New email'), __('A new email has been queued on ') . url(array('id' => 'mailer')), $Controller->{ADMIN_GROUP}(OVERRIDE));
             }
             $_POST->clear('newMail', 'from', 'recipients', 'subject', 'message', 'personal', 'send', 'bypass');
             if ($this->mayI(EDIT)) {
                 if ($_REQUEST['approve']) {
                     Flash::create(__('Email saved and approved for sending'), 'confirmation');
                 } else {
                     Flash::create(__('Email saved'), 'confirmation');
                 }
             } else {
                 Flash::create(__('Email has been queued for approval'), 'confirmation');
             }
         } else {
             Flash::create(__('Invalid email. Please try again'), 'warning');
         }
     }
     $recipients = $Controller->get($DB->spine->asList(array('class' => 'Group'), 'id'), OVERRIDE);
     foreach ($recipients as &$name) {
         $name = $name->Name;
     }
     asort($recipients);
     if ($_REQUEST['eedit']) {
         $msg = $DB->massmail->getRow(array('msg_id' => $_REQUEST['eedit']));
     }
     if ($_REQUEST['eedit'] && $msg && ($msg['author'] == $USER->ID || $this->mayI(EDIT))) {
         if ($msg['sent']) {
             $this->setContent('header', $msg['subject']);
             $r = '<div class="nav"><a href="' . url(null, 'id') . '">' . icon('small/arrow_left') . __('Back') . '</a></div>' . '<ul>' . '<li><span class="label">' . __('Author') . ': </span>' . $Controller->{$msg['author']}->link() . '</li>' . '<li><span class="label">' . __('From') . ': </span>' . ($msg['from'] ? $Controller->{$msg['from']} : __('Default')) . '</li>' . '<li><span class="label">' . __('Recipients') . ': </span>';
             $recipients = $Controller->get($msg['recipients']);
             $recs = array();
             foreach ($recipients as $re) {
                 $recs[] = $re->link();
             }
             $r .= join(', ', $recs) . '</li>' . '<li><span class="label">' . __('Sent') . ': </span>' . strftime('%e/%l, %R', $msg['sent']) . '</li>' . '<li><span class="label">' . __('Subject') . ': </span>' . $msg['subject'] . '</li>' . '<li><span class="label">' . __('Message') . ': </span><div class="message">' . $msg['message'] . '</div></li>' . '</ul>';
             $this->setContent('main', $r);
         } else {
             $valid_senders = false;
             if ($Controller->{ADMIN_GROUP}(OVERRIDE)->isMember($USER)) {
                 $g = $Controller->getClass('Group', OVERRIDE, false, false);
             } elseif ($msg['author'] != $USER->ID && ($author = $Controller->{$msg['author']}('User'))) {
                 $g = $author->groups + $USER->groups;
             } else {
                 $g = $USER->groups;
             }
             $valid_senders = array();
             foreach ($g as $gr) {
                 if ($gr->getEmail()) {
                     $valid_senders[$gr->ID] = $gr->Name;
                 }
             }
             asort($valid_senders);
             unset($valid_senders[EVERYBODY_GROUP]);
             unset($valid_senders[MEMBER_GROUP]);
             JS::loadjQuery(false);
             Head::add('$(function(){$(\'#recslide\').css("cursor", "pointer").toggle(function(){$(\'#recipients\').animate({height: 200}, 500)},function(){$(\'#recipients\').animate({height: 50}, 500)});});', 'js-raw');
             $eform = new Form('editMail', url(null, 'id'), false);
             $this->setContent('header', __('Edit email: ') . $msg['subject']);
             $recip = @$msg['recipients'][0] ? $Controller->{$msg['recipients'][0]}(OVERRIDE, 'Page') : false;
             $this->setContent('main', '<div class="nav"><a href="' . url(null, 'id') . '">' . icon('small/arrow_left') . __('Back') . '</a></div>' . $eform->set(new Hidden('eedit', $_REQUEST['eedit']), $msg['approved'] && !$this->mayI(EDIT) ? __('This email has been approved for sending. If you edit it, the approval will be lost.') : null, new Select(__('From'), 'from', $valid_senders, $_POST['from'] ? $_POST['from'] : $msg['from'], false, __('Default')), is_a($recip, 'Group') ? new FormText(__('Recipients'), new Hidden('recipients[]', $msg['recipients']) . __('Posters on') . ': ' . $recip->link()) : new Select(__('Recipients'), 'recipients', $recipients, $_POST['recipients'] ? $_POST['recipients'] : $msg['recipients'], true, false, 'notempty'), new Input(__('Subject'), 'subject', $_POST['subject'] ? $_POST['subject'] : $msg['subject']), new HTMLField(__('Message'), 'message', $_POST['message'] ? $_POST['message'] : $msg['message']), new Li(new Datepicker(__('Send'), 'sendd', $_POST['sendd'] ? $_POST['sendd'] : date('Y-m-d', $msg['send'])), new Timepickr(false, 'sendt', $_POST['sendt'] ? $_POST['sendt'] : date('h:i', $msg['send']))), new Checkbox(__('Personal draft'), 'personal', ($_POST['personal'] ? $_POST['personal'] : $msg['personal']) === 'yes'), new Checkbox(__('Approve'), 'approve', $_POST['approve'] ? $_POST['approve'] > 0 : $msg['approved'] > 0), $Controller->{(string) ADMIN_GROUP}(OVERRIDE)->isMember($USER) ? new Checkbox(__('Bypass member check'), 'bypass', $_POST['bypass'] ? $_POST['bypass'] > 0 : $msg['override_membercheck'] > 0) : null, new Li(new Submit(__('Save'), 'save'), $this->mayI(EDIT) ? new Submit(__('Save and continue'), 'saveac') : null, $this->mayI(EDIT) ? new Submit(__('Continue'), 'continue') : null)));
         }
     } else {
         if ($Controller->{ADMIN_GROUP}(OVERRIDE)->isMember($USER)) {
             $g = $Controller->getClass('Group', OVERRIDE, false, false);
         } else {
             $g = $USER->groups;
         }
         $valid_senders = array();
         foreach ($g as $gr) {
             if ($gr->getEmail()) {
                 $valid_senders[$gr->ID] = $gr->Name;
             }
         }
         asort($valid_senders);
         unset($valid_senders[EVERYBODY_GROUP]);
         unset($valid_senders[MEMBER_GROUP]);
         JS::loadjQuery(false);
         $nform = new Form('newMail', url(null, array('id', 'to')));
         $this->setContent('header', __('Email'));
         $o = $_REQUEST['to'] ? $Controller->{$_REQUEST['to']}(EDIT, 'Page') : false;
         $this->setContent('main', new Tabber('mail', new EmptyTab(__('New mail'), $nform->set($valid_senders ? new Select(__('From'), 'from', $valid_senders, $_POST['from'], false, __('Default')) : new Hidden('from', ""), $_REQUEST['to'] && $o ? new FormText(__('Recipients'), new Hidden('recipients[]', $_REQUEST['to']) . __('Posters on') . ': ' . $o->link()) : new Select(__('Recipients'), 'recipients', $recipients, $_POST['recipients'], true, false, 'notempty'), new Input(__('Subject'), 'subject', $_POST['subject'], 'required'), new HTMLField(__('Message'), 'message', $_POST['message']), new Li(new Datepicker(__('Send'), 'sendd', $_POST['sendd']), new Timepickr(false, 'sendt', $_POST['sendt'])), new Checkbox(__('Personal draft'), 'personal', $_POST['personal']), $Controller->{(string) ADMIN_GROUP}(OVERRIDE)->isMember($USER) ? new Checkbox(__('Bypass member check'), 'bypass', $_POST['bypass']) : null, $this->mayI(EDIT) ? new Checkbox(__('Approve'), 'approve', $_REQUEST['approve'] > 0) : null)), new Tab(__('Personal drafts'), $this->listEmails('personal')), new Tab(__('Manage emails'), $this->listEmails()), $this->mayI(EDIT) ? new Tab(__('Approve'), $this->listEmails('new')) : null));
     }
     $Templates->render();
 }