protected function preRender() { $this->begin($this->containerTag); $this->attr('id', either($this->props->containerId, $this->props->id)); $this->attr('class', enum(' ', rtrim($this->className, '_'), $this->props->class, $this->cssClassName, $this->props->disabled ? 'disabled' : null)); if (!empty($this->props->htmlAttrs)) { echo ' ' . $this->props->htmlAttrs; } if ($this->htmlAttrs) { foreach ($this->htmlAttrs as $k => $v) { echo " {$k}=\"" . htmlspecialchars($v) . '"'; } } }
protected function render() { $prop = $this->props; $this->begin('div'); $this->attr('class', enum(' ', $prop->disabled ? 'disabled' : '', $prop->selected ? 'selected' : '')); $this->begin('input'); $this->attr('type', 'radio'); $this->attr('name', $prop->name); $this->attr('value', $prop->value); if (!isset($prop->id)) { $prop->id = 'tab' . $this->getUniqueId(); } $this->attr('id', "{$this->props()->id}Field"); $this->attrIf($prop->disabled, 'disabled', 'disabled'); $this->attrIf($prop->selected, 'checked', 'checked'); $this->end(); $this->begin('label'); $this->attr('for', "{$this->props()->id}Field"); $this->attr('hidefocus', '1'); $this->attr('onclick', 'Tab_change(this' . (isset($this->container_id) ? ",'{$this->container_id}'" : '') . (isset($prop->url) ? ",'{$this->props()->url}')" : ')')); $this->begin('span'); $this->attr('class', 'text'); $this->attr('unselectable', 'on'); /* if (isset($this->style()->icon)) { $this->beginTag('img'); switch ($this->style()->icon_align) { case NULL: case 'left': $this->addAttribute('class', 'icon icon_left'); break; case 'right': $this->addAttribute('class', 'icon icon_right'); break; default: $this->addAttribute('class', 'icon'); break; } $this->addAttribute('src', $this->style()->propertyToImageURI('icon')); $this->endTag(); } */ $this->setContent($prop->label); $this->end(); $this->end(); $this->end(); }
function __call($name, $arguments = array()) { $name = strtolower($name); $content = array_shift($arguments); $params = count($arguments) && count($arguments[0]) ? ' ' . enum(array_shift($arguments))->format('%s="%s"')->join(' ') : ''; $type = substr($name, -1) == '_' ? 'opening' : (substr($name, -1) == '_' ? 'closing' : 'single'); /** Opening tag */ if (substr($name, -1) == '_') { $name = substr($name, 0, -1); $this->stacked .= "<{$name}{$params}>\n"; } elseif ($name[0] == '_') { $name = substr($name, 1); $this->stacked .= "</{$name}>\n"; } else { $this->stacked .= "<{$name}{$params}>\n{$content}\n</{$name}>\n"; } return $this; }
protected function render() { $prop = $this->props; $value = $prop->get('value', ''); $id = $prop->id; $name = $prop->name; $this->context->enableFileUpload(); $this->begin('div'); $this->attr('id', $id . (empty($value) ? 'File' : 'Text')); $this->attr('class', enum(' ', $this->className, $this->cssClassName, $prop->class, $prop->disabled ? 'disabled' : null, empty($value) ? '' : 'with-file')); if (!empty($prop->htmlAttrs)) { echo ' ' . $prop->htmlAttrs; } if ($this->htmlAttrs) { foreach ($this->htmlAttrs as $k => $v) { echo " {$k}=\"" . htmlspecialchars($v) . '"'; } } if (empty($value)) { // File doesn't exist $this->renderInputTypeFile(); } else { // File exists $this->begin('input'); $this->attr('class', $this->cssClassName); $this->attr('type', 'text'); $this->attr('value', Media::getOriginalFileName($value)); $this->attr('readonly', ""); $this->tag('button', ['class' => "btn btn-default {$prop->clearButtonClass}", 'onclick' => "\$('#{$id}Field').val('');\$(this).parent().removeClass('with-file')"]); $this->renderInputTypeFile(); } $this->end(); // container div $this->begin('input'); $this->attr('type', 'hidden'); $this->attr('id', "{$id}Field"); if (isset($name)) { $this->attr('name', $name); } else { $this->attr('name', $id); } $this->attr('value', $value); $this->end(); }
protected function render() { $prop = $this->props; $this->selIdx = $prop->selected_index; $pages = $this->getChildren('pages'); if (!empty($pages)) { //create data source for tabs from tab-pages defined on the source markup $data = []; /** @var TabPage $tabPage */ foreach ($pages as $idx => $tabPage) { $t = new TabsData(); $t->id = $tabPage->props->id; $t->value = either($tabPage->props->value, $idx); $t->label = $tabPage->props->label; $t->icon = $tabPage->props->icon; $t->inactive = $tabPage->hidden; $t->disabled = $tabPage->props->disabled; $t->url = $tabPage->props->url; $data[] = $t; } $propagateDataSource = false; } else { $data = $prop->data; $propagateDataSource = true; } if (!empty($data)) { $template = $prop->pageTemplate; if (isset($template)) { if (isset($pages)) { throw new ComponentException($this, "You may not define both the <b>p:page-template</b> and the <b>p:pages</p> parameters."); } $this->hasPages = true; } if ($propagateDataSource) { $this->viewModel = $data; } $value = either($prop->value, $this->selIdx); foreach ($data as $idx => $record) { if (!get($record, 'inactive')) { $isSel = get($record, $prop->valueField) === $value; if ($isSel) { $this->selIdx = $this->count; } ++$this->count; //create tab $tab = new Tab($this->context, ['id' => $prop->id . 'Tab' . $idx, 'name' => $prop->id, 'value' => get($record, $prop->valueField), 'label' => get($record, $prop->labelField), 'url' => get($record, 'url'), 'disabled' => get($record, 'disabled') || $prop->disabled, 'selected' => false], ['icon' => get($record, 'icon')]); $tab->container_id = $prop->id; $this->addChild($tab); //create tab-page $newTemplate = isset($template) ? clone $template : null; if (isset($template)) { $page = new TabPage($this->context, ['id' => get($record, 'id', $prop->id . 'Page' . $idx), 'label' => get($record, $prop->labelField), 'icon' => get($record, 'icon'), 'content' => $newTemplate, 'lazy_creation' => $prop->lazyCreation]); $newTemplate->attachTo($page); $this->addChild($page); } } } if (!empty($pages)) { $this->addChildren($pages); if ($this->selIdx >= 0) { $pages[$this->selIdx]->props->selected = true; } $this->setupSet($pages); $this->hasPages = true; } } //-------------------------------- $this->begin('fieldset', ['class' => enum(' ', 'tabGroup', $prop->tabAlign ? 'align_' . $prop->tabAlign : '')]); $this->beginContent(); $p = 0; if ($prop->tabAlign == 'right') { $selIdx = $this->count - $this->selIdx - 1; $children = $this->getChildren(); for ($i = count($children) - 1; $i >= 0; --$i) { $child = $children[$i]; if ($child->className == 'Tab') { $s = $selIdx == $p++; $child->props->selected = $s; if ($s) { $selName = $child->props->id; } $child->run(); } } } else { $selIdx = $this->selIdx; foreach ($this->getChildren() as $child) { if ($child->className == 'Tab') { $s = $selIdx == $p++; $child->props->selected = $s; if ($s) { $selName = $child->props->id; } $child->run(); } } } $this->end(); if ($this->hasPages) { $this->begin('div', ['id' => $prop->id . 'Pages', 'class' => enum(' ', 'TabsContainer', $prop->containerCssClass)]); $this->beginContent(); $p = 0; $selIdx = $this->selIdx; foreach ($this->getChildren() as $child) { if ($child->className == 'TabPage') { $s = $selIdx == $p++; $child->props->selected = $s; if ($s) { $sel = $child; } $child->run(); } } $this->end(); if (isset($sel)) { $this->tag('script', null, "Tab_change(\$f('{$selName}Field'),'{$this->props()->id}')"); } } }
include 'includes/header.php'; //Body Contents ?> <div class="container"> <div class="row-fluid"> <?php enum($db_fetch); ?> </div><!--row-fluid--> <div class="row-fluid"> <?php enum($letters); ?> </div><!--row-fluid--> <div class="row-fluid"> <?php enum($numbers); ?> </div><!--row-fluid--> </div><!--container--> <div class="container"> <input type="button" onclick="jsTest()"> <div> <?php //Include footer (important - contains closing </body> tag) include 'includes/footer.php';
/** * Returns a camelized sentence, ie. under_scored_name becomes UnderScoredName. * * @return string */ public function camelize() { return enum($this->explode('_'))->map('ucfirst')->join(); }
/** * @param int $idx * @param Metadata[] $columns * @throws \Matisse\Exceptions\ComponentException */ private function renderRow($idx, array $columns) { $this->begin('tr'); $this->attr('class', 'R' . $idx % 2); if ($this->enableRowClick) { if ($this->isPropertySet('onClickGoTo')) { $onclick = $this->getComputedPropValue('onClickGoTo'); $onclick = "selenia.go('{$onclick}',event)"; } else { $onclick = $this->getComputedPropValue('onClick'); } $onclick = "if (!\$(event.target).closest('[data-nck]').length) {$onclick}"; $this->attr('onclick', $onclick); } if ($this->props->rowSelector) { $this->tag('td', ['class' => 'rh', 'data-nck' => true], $idx + 1); } foreach ($columns as $k => $col) { $col->preRun(); $colAttrs = $col->props; $colType = property($colAttrs, 'type', ''); $al = property($colAttrs, 'align'); $isText = empty($colType); $this->begin('td'); $this->attr('class', enum(' ', property($colAttrs, 'class'), "ta-{$al}", $colType == 'row-selector' ? 'rh' : '', $colType == 'field' ? 'field' : '')); if ($isText) { $this->beginContent(); $col->runChildren(); } else { if ($this->enableRowClick) { $this->attr('data-nck'); } $this->beginContent(); $col->runChildren(); } $this->end(); } $this->end(); }
/** * Recursively moves values from nested arrays to the top level array. * * Example: * $array = array( $one, array($two, three, array($four)), $five ); * enum($array)->flatten() == array( $one, $two, $three, $four, $five ); // true * * @return Enum */ public function flatten() { $output = array(); foreach ($array as $key => $value) { is_array($value) ? $output = array_merge($output, enum($value)->flatten()) : ($output[$key] = $value); } return $this->set($output); }
protected function render() { $prop = $this->props; $align = $prop->align; switch ($align) { case 'left': $this->attr('style', 'float:left'); break; case 'right': $this->attr('style', 'float:right'); break; case 'center': $this->attr('style', 'margin: 0 auto;display:block'); break; } if (exists($prop->alt)) { $this->attr('alt', $prop->alt); } if (exists($prop->onClick)) { $this->attr('onclick', $prop->onClick); } if (exists($prop->href)) { $this->attr('onclick', "location='{$prop->href}'"); } if (exists($prop->value)) { $url = $this->contentRepo->getImageUrl($prop->value, ['w' => when(isset($prop->width), $prop->width), 'h' => when(isset($prop->height), $prop->height), 'q' => when(isset($prop->quality), $prop->quality), 'fit' => when(isset($prop->fit), $prop->fit), 'fm' => when(isset($prop->format), $prop->format), 'nc' => when(!$prop->cache, '1'), 'bg' => when(isset($prop->background), $prop->background)]); if ($this->containerTag == 'img') { $this->addAttrs(['src' => $url, 'width' => $prop->width, 'height' => $prop->height]); } else { $this->attr('style', enum(';', "background-image:url({$url})", "background-repeat:no-repeat", when(exists($prop->size) && $prop->size != 'auto', "background-size:{$prop->size}"), when($prop->position, "background-position:{$prop->position}"), when($prop->width, "width:{$prop->width}px"), when($prop->height, "height:{$prop->height}px"))); } } }
protected function render() { $prop = $this->props; $prop->name = $prop->name ?: $prop->id; $this->context->enableFileUpload(); $this->beginContent(); echo html([h("input#{$prop->id}Field", ['type' => 'hidden', 'name' => $prop->name, 'value' => $prop->value]), h('.wrapper', ['style' => enum(';', isset($prop->width) ? "width:{$prop->width}px" : '', isset($prop->height) ? "height:{$prop->height}px" : '')], [h('img.Image', ['src' => $prop->value ? $this->contentRepo->getImageUrl($prop->value, ['w' => $prop->width, 'h' => $prop->height, 'fit' => 'crop']) : self::EMPTY_IMAGE]), h('span'), h("input", ['type' => 'file', 'name' => "{$prop->name}_" . self::FILE_FIELD_SUFFIX, 'onchange' => "selenia.ext.imageField.onChange('{$prop->id}')", 'disabled' => $prop->disabled]), when(!$prop->noClear, h('button.clearBtn.fa.fa-times', ['type' => 'button', 'onclick' => "selenia.ext.imageField.clear('{$prop->id}')", 'disabled' => $prop->disabled, 'style' => when(!$prop->value, 'display:none')]))])]); }
You might bump into other minor quirks that may get fixed eventually. Any Weird Extensions? - Yes. We support <? | <?= | <?js ... ?>. */ //error_reporting(4095); define("JS_CACHE_DIR", (getenv("TMP") ? getenv("TMP") : "/tmp") . "/es4php"); define("JS_DEBUG", 1); function enum() { static $index = 1; foreach (func_get_args() as $c) { define($c, JS_DEBUG ? $index++ : $c); } } enum("JS_INLINE", "JS_DIRECT"); class js { #-- auto-magic function that should work out of the box without being too inefficient. static function run($src, $mode = JS_DIRECT, $id = NULL) { #-- attempt to setup our cache directory if (!file_exists(JS_CACHE_DIR)) { mkdir(JS_CACHE_DIR, 0777, true); } #-- we need a unique ID for this script. passing $id makes this faster, but whatever. if ($id == NULL) { $id = md5($src); } $path = JS_CACHE_DIR . "/" . $id . ".php"; if (!file_exists($path)) {
/** * Determine whether or not the model can be deleted. * * @param boolean $throwExceptions * * @return boolean * * @throws \App\Exceptions\ModelDeletionException */ public function deletable($throwExceptions = false) { // Prevent deleting Superuser profile if ($this->id == 1) { if ($throwExceptions) { throw new ModelDeletionException(sprintf(_('Deleting %s is not allowed'), $this)); } return false; } // Prevent deleting profiles assigned to users $usernames = $this->users->pluck('username'); if ($usernames->count()) { if ($throwExceptions) { throw new ModelDeletionException(_('Profile cannot be deleted because it is assegned to these users') . ': ' . enum($usernames->all())); } return false; } return true; }
protected function render() { $prop = $this->props; $class = self::CSS_CLASS; $name = either($prop->name, $prop->id); $this->beginContent(); echo html([when(!str_endsWith($prop->name, '[]'), h('input', ['type' => 'checkbox', 'name' => $name, 'value' => '', 'checked' => true, 'style' => 'display:none'])), h('input', ['type' => 'checkbox', 'id' => $prop->id, 'name' => $name, 'class' => enum(' ', "{$class}-checkbox", "{$class}-" . ($prop->customColor ? substr($prop->customColor, 1) : $prop->color)), 'value' => $prop->value, 'checked' => $prop->checked || isset($prop->testValue) && $prop->value === $prop->testValue, 'disabled' => $prop->disabled, 'autofocus' => $prop->autofocus, 'onclick' => $prop->script]), h('label', ['for' => $prop->id, 'class' => "{$class}-label", 'data-off' => $prop->labelOff, 'data-on' => $prop->labelOn, 'title' => $prop->tooltip])]); }
protected function render() { $prop = $this->props; $inputFlds = $this->getClonedChildren(); if (empty($inputFlds)) { throw new ComponentException($this, "<b>field</b> parameter must define <b>one or more</b> component instances.", true); } // Treat the first child component specially /** @var Component $input */ $input = $inputFlds[0]; $append = $this->getChildren('append'); $prepend = $this->getChildren('prepend'); $fldId = $input->props->get('id', $prop->name); if ($fldId) { foreach ($inputFlds as $counter => $c) { if ($c->isPropertySet('hidden') && !$c->getComputedPropValue('hidden')) { break; } } // Special case for the HtmlEditor component. if ($input->className == 'HtmlEditor') { $forId = $fldId . "-{$counter}_field"; $click = "\$('#{$fldId}-{$counter} .redactor_editor').focus()"; } else { $forId = $fldId . "-{$counter}"; $click = $prop->multilang ? "focusMultiInput(this)" : null; } } else { $forId = $click = null; } if ($input->className == 'Input') { if ($prop->type && !$input->props->type) { $input->props->type = $prop->type; } switch ($input->props->type) { case 'date': case 'time': case 'datetime': $btn = Button::create($this, ['class' => 'btn btn-default', 'icon' => 'glyphicon glyphicon-calendar', 'script' => "\$('#{$input->props->id}-0').data('DateTimePicker').show()", 'tabIndex' => -1]); $append = [$btn]; } } if (exists($prop->icon)) { $append = [Text::from($this->context, "<i class=\"{$prop->icon}\"></i>")]; } $this->beginContent(); // Output a LABEL $label = $prop->label; if (!empty($label)) { $this->tag('label', ['class' => enum(' ', $prop->labelClass, $prop->required ? 'required' : ''), 'for' => $forId, 'onclick' => $click], $label); } // Output child components $hasGroup = $append || $prepend || $prop->groupClass || $prop->multilang; if ($hasGroup) { $this->begin('div', ['id' => "{$forId}-group", 'class' => enum(' ', when($append || $prepend || $prop->multilang, 'input-group'), $prop->groupClass)]); } $this->beginContent(); if ($prepend) { $this->renderAddOns($prepend); } if ($prop->multilang) { foreach ($inputFlds as $i => $input) { foreach ($prop->languages as $lang) { $this->outputField($input, $i, $fldId, $prop->name, $lang); } } } else { foreach ($inputFlds as $i => $input) { $this->outputField($input, $i, $fldId, $prop->name); } } if ($append) { $this->renderAddOns($append); } $shortLang = substr($prop->lang, -2); if ($prop->multilang) { echo html([h('span.input-group-btn', [h('button.btn btn-default dropdown-toggle', ["id" => "langMenuBtn_{$forId}", 'type' => "button", 'data-toggle' => "dropdown", 'aria-haspopup' => "true", 'aria-expanded' => "false"], [h('i.fa fa-flag'), h('span.lang', $shortLang), h('span.caret')]), h("ul.dropdown-menu dropdown-menu-right", ['id' => "langMenu_{$forId}", "aria-labelledby" => "langMenuBtn_{$forId}"], map($prop->languages, function ($l) use($forId) { return h('li', [h('a', ['tabindex' => "1", 'href' => "javascript:selenia.setLang('{$l['name']}','#{$forId}-group')"], $l['label'])]); }))])]); } if ($hasGroup) { $this->end(); } }
<?php error_reporting(E_ALL); ini_set('display_errors', true); require "table_names.inc"; require "common.inc"; require "timezone.inc"; require "enum.php"; //define constants for error code enum("AUTH_NONE", "AUTH_SUCCESS", "AUTH_FAILED_INCORRECT_PASSWORD", "AUTH_FAILED_NO_USERNAME_PASSED", "AUTH_FAILED_EMPTY_PASSWORD", "AUTH_LOGOUT", "AUTH_FAILED_LDAP_LOGIN", "AUTH_FAILED_NO_LDAP_MODULE"); //define constants for ldap error code enum("LDAP_AUTH_NONE", "LDAP_CONNECTION_FAILED", "LDAP_MULTIPLE_ENTRIES_RETURNED", "LDAP_SERVER_ERROR", "LDAP_USER_NOT_FOUND"); //define clearance levels define("CLEARANCE_ADMINISTRATOR", 10); /** * Manages and provides authentication services */ class AuthenticationManager { /** * The error code */ var $errorCode = AUTH_NONE; /** * The error text */ var $errorText = "Authentication has not yet been attempted"; /** * The error code to check if errorCode=AUTH_FAILED_LDAP_LOGIN */ var $ldapErrorCode;
<?php function enum() { for ($i = 0; $i < func_num_args(); $i++) { define(func_get_arg($i), $i); } } enum('EVENT_THEORETICAL', 'EVENT_EXPERIMENTAL'); class Timeline { public $from; public $to; } class Event { public $date; public $label; public $content_id; public $id; } class Content { public $title; public $text; public $image; public $id; } class Ressource { public $title;
protected function render() { $prop = $this->props; if (!empty($prop->wrapper)) { $this->begin('a'); } $script = $prop->action ? "selenia.doAction('{$prop->action}','{$prop->param}')" : $prop->script; if (exists($script)) { $this->attr('onclick', $script); } if (exists($prop->tooltip)) { $this->attr('title', $prop->tooltip); } $this->attr('href', $this->disabled ? 'javascript:void(0)' : (isset($prop->href) ? $prop->href . $this->disabled : "javascript:void(0)")); $this->beginContent(); if (exists($prop->icon)) { $this->tag('i', ['class' => enum(' ', $prop->icon, $prop->iconClass)]); } echo e($prop->label); if (!empty($prop->wrapper)) { $this->end(); } }