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 . '&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 °', '180' => '180 °', '270' => '270 °'), $_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>'; }
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>'; }
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>'; }
function render() { $id = idfy($this->name); if ($this->multiple) { JS::loadJQuery(true); JS::lib('jquery/plugins/localisation/jquery.localisation-min'); JS::lib('jquery/plugins/scrollTo/jquery.scrollTo-min'); JS::lib('jquery/ui.multiselect'); if (!$this->nojs) { /*FIXME: Translation JS::raw('$(function(){$.localise("ui-multiselect", {language: "en", path: "lib/js/locale/"});});'); */ JS::raw('$(function(){$("#' . $id . '").multiselect({' . $this->jsparams . '});});'); } Head::add('ui.multiselect', 'css-lib'); if ($this->class) { $this->class .= ' '; } $this->class .= 'multiselect'; } $r = ($this->label === false ? '' : '<label for="' . $id . '">' . $this->label . '</label>') . '<select id="' . $id . '" name="' . $this->name . ($this->multiple ? '[]" multiple="multiple"' : '"') . ' class="' . $this->validate . ($this->validate ? ' ' : '') . $this->class . '">'; if ($this->startEmpty) { $r .= '<option value="">' . ($this->startEmpty !== true ? $this->startEmpty : '') . '</option>'; } if (is_array($this->data)) { foreach ($this->data as $value => $text) { if (is_array($text)) { if (isset($text['id'])) { $r .= $this->inflatedGroup($text); } else { $r .= $this->optgroup($value, $text); } } else { if (is_bool($this->selected)) { $s = $this->selected; } else { $match_pos = array_search($value, $this->selected, true); if (!$match_pos) { $match_pos = array_search($value, $this->selected); } $match = $match_pos === false ? false : $this->selected[$match_pos]; $s = strcmp($match, $value) === 0; } $r .= '<option value="' . $value . '"' . ($s ? ' selected="selected"' : '') . '>' . $text . '</option>'; } } } $r .= '</select>' . (strpos($this->validate, 'required') !== false ? '<span class="reqstar">*</span>' : '') . ($this->description ? '<span class="description">' . $this->description . '</span>' : ($this->multiple ? ' ' : '')); return '<span class="formelem">' . $r . '</span>'; }
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>'; }
/** * 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 . '&encURL=' . urlencode($url) . ($label ? '&urlLabel=' . $label : '') . '" /><param name="movie" value="/lib/swf/flashurl.swf" /><param name="wmode" value="transparent" /></object></span>'; }
function lib($what, $IE = false, $defer = true) { if (!is_array($what)) { $what = array($what); } global $SITE; foreach ($what as $inc) { $cdir = getcwd(); chdir($SITE->base_dir . '/lib/js'); $files = glob($inc . '.js'); if (empty($files)) { chdir($cdir); return; } sort($files); $file = array_pop($files); if (!($dep = file($file))) { chdir($cdir); return; } chdir($cdir); $dep = $dep[0]; if (preg_match('#^//Deps:#', $dep)) { $deps = explode(',', substr($dep, 7)); foreach ($deps as $d) { $d = trim($d); if ($d == 'jquery') { self::loadjQuery(false, $defer); } elseif ($d == 'jquery-ui') { self::loadjQuery(true, $defer); } else { JS::lib($d, $IE, $defer); } } } Head::add($inc, 'js-lib', $defer, true, $IE); } }
function viewAds() { //FIXME:Move setting to CompanyEditor $slider = true; $cycletime = 5000; $r = ''; $ms = self::sortedList('main'); $s = self::sortedList('sub'); if ($ms) { $r .= '<div class="col first four company"><h2>' . __('Main sponsors') . '</h2>' . $ms . '</div>'; } if ($s) { $r .= '<div class="col first four company"><h2>' . __('Sponsors') . '</h2>' . $s . '</div>'; } if ($slider) { JS::lib('jquery/jquery.cycle.all.min'); JS::raw('$(function(){ $(".companies_sub").css({height:"230px"}).children("li").css({top:0,left:0,position:"fixed"}); $(".companies_sub").cycle({fx:"scrollHorz",timeout:' . $cycletime . '}); });'); } return $r; }
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); }
function dropdown($icon, $text, $rows, $class = "") { JS::loadjQuery(false); JS::lib('dropdowns'); return '<span class="dropdown' . ($class ? " " . $class : '') . '">' . '<span class="dropdown-icon">' . icon($icon, $text, false, true) . '</span>' . '<ul><li>' . (is_array($rows) ? implode('</li><li>', $rows) : $rows) . '</li></ul></span>'; }
/** * Generate the XHTML/CSS to administrate the folder * @return void */ function genHTML() { $this->loadStructure(); $this->fileExtCSS(); global $CONFIG, $Controller; Head::add($CONFIG->UI->jQuery_theme . '/jquery-ui-*', 'css-lib'); $r = '<div class="ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all">' . '<span class="fixed-width">' . $this->pcrumbs() . '</span>' . Box::tools($this) . '</div>'; $r .= '<ul class="filetree">'; $i = 0; foreach ($this->folders as $cur) { if (!$cur->mayI(READ)) { continue; } $r .= '<li class="' . ($i % 2 ? 'odd' : 'even') . ' directory">' . '<span class="fixed-width"><a href="' . url(array('id' => $cur->ID), array('popup', 'filter')) . '" title="' . __('Open folder') . '">' . $cur . '</a></span>' . Box::tools($cur) . icon('large/down-16', __('Download'), url(array('id' => $cur->ID, 'action' => 'download'))) . '</li>'; $i++; } $r .= '</ul>'; global $SITE; if ($_REQUEST['popup'] == "ckeditor") { //http://docs.cksource.com/CKEditor_3.x/Developers_Guide/File_Browser_(Uploader)/Custom_File_Browser Head::add("function getUrlParam(paramName)\n\t\t{\n\t\t var reParam = new RegExp('(?:[\\?&]|&)' + paramName + '=([^&]+)', 'i') ;\n\t\t var match = window.location.search.match(reParam) ;\n\n\t\t return (match && match.length > 1) ? match[1] : '' ;\n\t\t}\n\t\tvar funcNum = getUrlParam('CKEditorFuncNum');\n\t\tvar fileUrl = 'https://www.ysektionen.se/';\n\t\t", 'js-raw'); Head::add("function select(id) {try{window.opener.CKEDITOR.tools.callFunction(funcNum, 'https://www.ysektionen.se/'+id);} catch(err) {}window.close();}", 'js-raw'); } else { if ($_REQUEST['popup']) { Head::add("function select(id) {try{window.opener.fileCallback(id,'{$_REQUEST['popup']}');} catch(err) {}window.close();}", 'js-raw'); } } foreach ($this->files as $cur) { if (!$cur->mayI(READ)) { continue; } if ($_REQUEST['filter']) { switch ($_REQUEST['filter']) { case 'images': case 'documents': if (!in_array(strtolower($cur->extension), $CONFIG->extensions->{$_REQUEST['filter']})) { continue 2; } break; default: if (!stristr($cur->basename, $_REQUEST['filter'])) { continue 2; } } } $r .= '<li class="' . ($i % 2 ? 'odd' : 'even') . ' file ext_' . $cur->extension . '"><span class="fixed-width"'; if ($_REQUEST['popup']) { $r .= '></span><a href="javascript: select(' . $cur->ID . ');"'; } if ($cur->isImage()) { if (!$_REQUEST['popup']) { $r .= '><span'; } JS::lib('jquery/imgPreview'); Head::add('#imgpreview{' . 'position:absolute;' . 'border:1px solid #ccc;' . 'background:#333;' . 'padding:5px;' . 'display:none;' . 'color:#fff;}', 'css-raw'); $r .= ' class="imagepreview" rel="/' . $cur->ID . '?mw=100">' . $cur->basename; if (!$_REQUEST['popup']) { $r .= '</span>'; } } else { $r .= '>' . $cur->basename; } if ($_REQUEST['popup']) { $r .= '</a>'; } $r .= '</span><div class="tools">' . Box::tools($cur) . '</div></li>'; $i++; } return $r . '</ul>'; }
/** * 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; }
/** * Creates the form for outputting * Usage example * <code> * $form = new Form('uploadToFolder', url(null, 'id')); * return $form->collection( * new Fieldset(__('Select files'), * new FileUpload(__('File to upload'), 'uFiles[]'), * new CheckBox(__('Uncompress compressed files'), 'uncompress', false) * ), * new Fieldset(__('Select another file'), * new FileUpload(__('File to upload'), 'uFiles[]'), * new CheckBox(__('Uncompress compressed files'), 'uncompress', false) * ) * ); * </code> * @param The objects that make up the form * @return string */ public function collection() { $args = func_get_args(); $args = $this->__flatten($args); $rt = ''; foreach ($args as $arg) { if (is_object($arg) && method_exists($arg, 'render')) { $rt .= $arg->render(); } elseif (is_string($arg)) { $rt .= $arg; } } $r = '<form action="' . (empty($this->action) ? url(false, true) : (is_array($this->action) ? url($this->action) : $this->action)) . '" method="' . $this->method . '"' . (stripos($rt, 'type="file"') !== false ? ' enctype="multipart/form-data"' : ''); if (!$this->id) { $r .= '>'; } else { $r .= ' id="' . $this->id . '"><div style="display: none;"><input type="hidden" value="' . time() . '" name="' . $this->id . '" /></div>'; } $r .= '<div class="formdiv">' . $rt . '</div>'; if ($this->submittext !== false) { $r .= '<div class="submit">' . new Submit($this->submittext ? $this->submittext : __('Submit')) . '</div>'; } $r .= '</form>'; if ($this->validate) { JS::lib('jquery/jquery-validate/jquery.validate.min'); JS::raw('$(function(){$("#' . $this->id . '").validate();});'); } return $r; }
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(); }
<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() { $(this).stop(true) .animate({backgroundPosition:"0 -50px"},"fast") }); '); */