function run() { global $Templates, $DB, $Controller; Head::add('booking', 'css-lib'); $Objects = $Controller->get($DB->booking_items->asList(array('parent' => array('0', '')), 'id', false, false, 'place ASC')); $this->setContent('main', listify(array_map(create_function('$a', 'return $a->link();'), $Objects))); $Templates->render(); }
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 recentChanges() { global $USER; if ($USER->ID == NOBODY) { return ''; } $changed = array(); if (isset($_SESSION['lastLogin'])) { global $DB, $Controller; $changed = $Controller->max($DB->{'spine,updates'}->get(array('spine.class!' => 'User', 'updates.edited>=' => strtotime($_SESSION['lastLogin'])), 'spine.id', false, '`updates`.`edited` DESC', false, false, true), 10); } if (!$changed) { $changed = array(__('None')); } echo '<div class="box recentChanges">' . listify($changed) . '</div>'; }
/** * Display the current companies. * @return string */ private function displayCompanies() { global $USER, $DB, $Controller; $req = $Controller->getClass('Company', OVERRIDE); if (!is_array($req)) { $req = array(); } $i = array('main' => 0, 'sub' => 0); $companyList = array('main' => array(), 'sub' => array()); foreach ($req as $company) { $companyList[$company->type ? $company->type : 'sub'][] = '<span class="fixed-width">' . $company->Name . '</span><div class="tools">' . ($this->mayI(EDIT) ? icon('small/vcard_edit', 'Edit', url(array('edit' => $company->ID), 'id')) . icon('small/pencil', __('Edit company page'), url(array('id' => 'pageEditor', 'edit' => $company->ID))) : '') . ($this->mayI(DELETE) ? icon('small/delete', __('Delete'), url(array('delCompany' => $company->ID), array('id'))) : '') . ($Controller->menuEditor->mayI(EDIT) ? icon('small/page_add', __('Add company page to menu'), url(array('madd' => $company->ID), 'id')) : '') . '</div>'; } if (!$companyList['main']) { $companyList['main'][] = __('None'); } if (!$companyList['sub']) { $companyList['sub'][] = __('None'); } $companyStr = '<ul class="flul">' . '<li class="fletter">' . __('Main sponsor') . listify($companyList['main'], '') . '</li>'; $companyStr .= '<li class="fletter">' . __('Sub sponsor') . listify($companyList['sub'], '') . '</li>'; $companyList .= '</ul>'; return new Tabber('cc', new EmptyTab(__('Current Companies'), $companyStr), !$this->may($USER, EDIT) ? null : new EmptyTab(__('New'), $this->companyForm())); }
/** * View a list of the object and it's subobjects * @return string List */ function listView() { global $DB, $Controller; $Objects = $Controller->get(arrayPrepend($DB->booking_items->asList(array('parent' => $this->ID), 'id', false, false, 'place ASC'), $this->ID)); $booked_items = array(); foreach ($Objects as $obj) { $booked_items[] = array('link' => $obj->link(), 'id' => $obj->ID, 'parent' => $obj->parentBookID()); } return listify(inflate($booked_items), false, true, 'link', 'children'); }
function viewResult($echo = false, $no_stats = false) { $_REQUEST->setType('cout', '#^(email|sortedtable)$#'); global $DB, $Controller, $USER; if ($USER->ID == NOBODY) { return false; } if ($_REQUEST['cout']) { $this->sendFile($_REQUEST['cout']); } $_REQUEST->setType('delpost', 'any'); $myPosts = array(); $where = array('id' => $this->ID); if (!$this->mayI(EDIT)) { $myPosts = $DB->formdata->asList(array('id' => $this->ID, 'field_id' => 'poster', 'value' => $USER->ID), 'post_id'); if (!$this->_Public_Form) { if (!$myPosts) { return ''; } $where['post_id'] = $myPosts; } $no_stats = true; } if ($_REQUEST['delpost']) { if ($this->mayI(EDIT) || in_array($_REQUEST['delpost'], $myPosts)) { $DB->formdata->delete(array('id' => $this->ID, 'post_id' => $_REQUEST['delpost']), false); if (!is_null($this->_PostCount)) { --$this->_PostCount; } } } $sort = array(); $r = $DB->formfields->get(array('id' => $this->ID), false, false, 'sort'); while (false !== ($field = Database::fetchAssoc($r))) { $sort[$field['field_id']] = $field['sort']; $fields[$field['field_id']] = $field; $labels[$field['field_id']] = self::fieldlabel($field['label'], $this->loadedLanguage); } asort($sort); $sort = array_flip(array_keys($sort)); $r = $DB->formdata->get($where); $data = array(); $postSort = array(); $u = 0; $stats = array(); while (false !== ($res = Database::fetchAssoc($r))) { if (in_array($res['field_id'], array('poster', 'posted', 'poster:ip', 'language'))) { $postMeta[$res['post_id']][$res['field_id']] = $res['value']; if ($res['field_id'] == 'posted') { $postSort[$res['value']] = $res['post_id']; } } else { if ($this->_Public_Form < 2 && !$this->mayI(EDIT) && !in_array($res['post_id'], $myPosts)) { continue; } if (@in_array($fields[$res['field_id']]['type'], array('Checkbox', 'pCheckbox')) && substr_count($fields[$res['field_id']]['value'], ',') == 0) { if ($res['value']) { $res['value'] = __('Yes'); } else { $res['value'] = __('No'); } } if (!$no_stats) { if (@(!in_array($fields[$res['field_id']]['type'], array('htmlfield', 'textarea', 'hidden', 'mselect')))) { if (isset($stats[$res['field_id']][$res['value']])) { $stats[$res['field_id']][$res['value']]++; } else { $stats[$res['field_id']][$res['value']] = 1; } } elseif ($fields[$res['field_id']]['type'] == 'mselect') { if (!is_array($res['value'])) { $res['value'] = array($res['value']); } foreach ($res['value'] as $sel) { if (isset($stats[$res['field_id']][$sel])) { $stats[$res['field_id']][$sel]++; } else { $stats[$res['field_id']][$sel] = 1; } } } } $data[$res['post_id']][isset($sort[$res['field_id']]) ? $sort[$res['field_id']] : count($sort) + $u++] = new Tablerow(@$labels[$res['field_id']], $res['value']); } } if (empty($postSort)) { return ''; } $sortData = array(); ksort($postSort); foreach ($postSort as $post_id) { if (isset($data[$post_id])) { ksort($data[$post_id]); $sortedData[$post_id] = $data[$post_id]; } else { $sortedData[$post_id] = null; } } $oa = array(); foreach ($sortedData as $post_id => $rows) { $tbl = new Table(new Tableheader(__('Posted by') . ': ' . @$Controller->{$postMeta[$post_id]['poster']}, $this->mayI(EDIT) || in_array($post_id, $myPosts) ? icon('small/delete', __('Delete post'), url(array('delpost' => $post_id), true)) : ''), $rows); $tbl->class = 'form_posterdata'; $oa[] = $tbl; } $output = listify($oa); $_REQUEST->setType('to', 'numeric'); if ($this->mayI(EDIT)) { $output .= '<span class="forminfo">' . $this->PostCount . ' ' . __('posters') . ($this->_Limit ? ' (of ' . $this->_Limit . ')' : '') . '</span>' . '<span class="uform_posterdata"><a href="' . url(array('cout' => 'email'), 'id') . '">' . __('Contact data') . '</a>|<a href="' . url(array('cout' => 'sortedtable'), 'id') . '">' . __('Sorted table') . '</a>' . ($Controller->mailer ? '|<a href="' . url(array('id' => 'mailer', 'to' => $this->ID)) . '">' . __('Email posters') . '</a>' : '') . '</span>'; } if (!$no_stats) { $s = new Table(new Tableheader(__('Field'), __('Data'), __('Occurrances'))); $s->class = 'form_stats_table'; foreach ($stats as $field_id => $values) { $st_rows = array(); $i = 0; foreach ($values as $value => $count) { $st_rows[] = new Tablerow(!$i++ ? @$labels[$field_id] : '', $value, $count); } $s->append($st_rows); } $output .= $s; } if ($echo) { echo $output; } return $output; }
function flowList() { $r = array(); $flows = Flow::flows(); foreach ($flows as $f) { $r[] = '<span class="fixed-width">' . $f . '</span><div class="tools">' . icon('small/pencil', __('Edit flow'), url(array('edit' => $f->ID))) . icon('small/feed', __('View flow'), $f->link) . '</div>'; } return listify($r); }
/** * Display file link * @param $obj Top folder * @param $url URL to send the rendered links to. "$" in the URL will be replaced with the ID of the link * @return HTML Rendered list */ function displayLink($obj, $url) { if (is_array($obj)) { return arrap_map(array($this, 'displayLink'), $obj, array_fill(0, count($obj), $url)); } $subfolders = $obj->folders; return '<a href="' . str_replace(array('%24', '$'), $obj->ID, $url) . '">' . $obj . '</a>' . (@empty($subfolders) ? '' : listify(array_map(array($this, 'displayLink'), $subfolders, array_fill(0, count($subfolders), $url)))); }
function editTab() { $_REQUEST->addType('view', 'string'); $_REQUEST->addType('lang', 'string'); $_REQUEST->setType('ch', 'numeric'); global $Controller, $CONFIG, $DB, $USER; $this->setContent('header', __('Editing user') . ': ' . $this->that); $form = new Form('editUser'); /** * User settings */ global $SITE; $settingsform = $this->that->settings->getFormElements('usersettings'); /** * Load voluntary groups * @var groups */ $volkeys = $DB->{'spine,metadata'}->asList(array('spine.class' => 'Group', 'metadata.field' => 'GroupType', 'metadata.value' => array('vol', 'volpre')), 'spine.id'); $volgroups = $Controller->get($volkeys, OVERRIDE); propsort($volgroups, 'Name'); /** * Group membership page */ $groups = $this->that->groups(); $gTypes = array('vol' => array(), 'assigned' => array()); foreach ($groups as $group) { if (!$group->isMember($this->that)) { continue; } switch ($group->GroupType) { case 'vol': case 'volpre': $gTypes['vol'][] = $group->ID; break; default: $gTypes['assigned']['g' . $group->ID] = $group; break; } } $checked = array(); foreach ($volgroups as $vg) { if (in_array($vg->ID, $gTypes['vol'])) { $checked[] = $vg->ID; } } asort($gTypes['assigned']); return array(@$this->that->password !== 'LDAP' ? new Formsection(__('Login information'), new Input(__('Username'), 'username', @$this->that->username), new Password(__('Password'), 'password1'), new Password(__('Password again'), 'password2')) : null, new Formsection(__('Presentation'), new HTMLField(false, 'presentation', $this->that->getContent('presentation'))), $settingsform ? new Formsection(__('User settings'), $settingsform) : null, @UInfoFields::edit($id, 'Tab'), new Formsection(__('Group membership'), new Fieldset(__('Assigned groups'), listify(arrayExtract($gTypes['assigned'], 'link', false, true))), empty($volgroups) ? null : new checkset(__('Voluntary groups'), 'volgroups', $volgroups, $checked))); }
function list_all($offset) { return listify(Flow::retrieve($this->flows, $this->items_per_page, false, false, false, $offset)); }
function toolList($objects) { return listify(array_map(array('self', '__toolListHelper'), $objects)); }
/** * Creates a HTML-list of an array * @param array $array The array to convert to HTML-list * @param string $class Defines which class the top-level UL should be assigned * @return string */ function listify($array, $class = 'list', $vary = true, $textfield = false, $childfield = false) { if (!$array) { return; } static $i = -1; static $recursion = 0; ++$recursion; if ($vary === true) { $vary = array('odd', 'even'); } $vlen = count($vary); $result = ''; $result = '<ul' . ($class ? ' class="' . $class . '"' : '') . '>'; foreach ($array as $key => $li) { $result .= '<li' . ($vary ? ' class="' . $vary[++$i % $vlen] . '"' : '') . '>' . ($textfield ? @$li[$textfield] : (is_array($li) ? $key : $li)) . (is_array($li) ? $childfield ? isset($li[$childfield]) ? listify($li[$childfield], false, $vary, $textfield, $childfield) : '' : listify($li, false, $vary, $textfield, $childfield) : ''); } $result .= '</ul>'; --$recursion; if (!$recursion) { $i = 0; } return $result; }
/** * Display the page for managing installations * @see lib/Page#run() */ function run() { global $USER, $CONFIG, $Templates, $SITE, $Controller; if (!$this->may($USER, READ)) { return; } $_REQUEST->setType('place', 'numeric'); $_REQUEST->setType('parent', 'numeric'); $_REQUEST->setType('reinstall', 'string'); $_REQUEST->setType('new', 'string'); if ($this->mayI(EDIT)) { if ($_REQUEST['reinstall']) { $this->reinstall($_REQUEST['reinstall']); Flash::create($_REQUEST['reinstall'] . ' ' . __('was reinstalled')); } elseif ($_REQUEST['new']) { $class = $_REQUEST['new']; if (validInclude($class) && ($class == 'MenuItem' || @is_subclass_of($class, 'MenuItem')) && $Controller->menuEditor->mayI(EDIT)) { $obj = $Controller->newObj($class); $obj->move($_REQUEST['place'] ? $_REQUEST['place'] : 'last', $_REQUEST['parent']); Flash::queue(__('New') . ' ' . $class . ' ' . __('installed')); redirect(url(array('id' => 'menuEditor'))); } unset($class); } } $installed = $CONFIG->base->installed; $dir = 'plugins'; $fullpath = ROOTDIR . DIRECTORY_SEPARATOR . $dir; $entries = readDirFilesRecursive($fullpath, true); natcasesort($entries); $i = 0; $c = array(); foreach ($entries as $entry) { if (substr($entry, -4) == '.php') { $class = substr($entry, false, -4); $methods = class_exists($class) ? get_class_methods($class) : array(); $c[] = '<span class="fixed-width">' . $class . '</span><div class="tools">' . ($this->may($USER, EDIT) && (@in_array('installable', $methods) && @in_array('install', $methods) && call_user_func(array($class, 'installable')) == $class) ? icon('small/arrow_refresh_small', __('Reinstall'), url(array('reinstall' => $class), array('id'))) : '') . (($class == 'MenuItem' || @is_subclass_of($class, 'MenuItem')) && $Controller->menuEditor->may($USER, EDIT) ? icon('small/add', __('Add new instance to menu'), url(array('new' => $class), array('id'))) : '') . '</div>'; } } $this->setContent('header', __('Installer')); $this->setContent('main', listify($c)); $Templates->admin->render(); }
function groupStatistics() { $_REQUEST->setType('viewMembers', 'any'); $r = ''; $directMembers = $group->memberUsers(true, true); $allMembers = $group->memberUsers(false, true); $statsTable = new Table(new tablerow(__('Direct users') . ': ', count($directMembers)), new tablerow(__('All users') . ': ', $memcount = count($allMembers))); $r .= $statsTable; if ($_REQUEST['viewMembers']) { global $Controller; Base::preload(array_slice($allMembers, 0, 100), false); $pagination = Pagination::getRange(100, $memcount); $Count = 0; $activeMembers = array(); foreach ($allMembers as $member_id) { if ($pagination['range']['start'] > $Count++) { continue; } $u = $Controller->get($member_id, OVERRIDE, false, false); if ($u->isActive()) { $activeMembers[] = $u; } if ($Count >= $pagination['range']['stop']) { break; } } $r .= listify($activeMembers) . $pagination['links']; } else { $r .= '<a href="' . url(array('viewMembers' => '1'), array('edit', 'with', 'stats')) . '">' . __('View members') . '</a>'; } return $r; }
/** * @return string */ private function mainView() { global $USER, $CONFIG, $DB, $Controller; $aList = array(); $total = $DB->getCell("SELECT DISTINCT COUNT(*) FROM updates AS t1 \n LEFT JOIN spine sp ON sp.id = t1.id\n LEFT JOIN updates t2 ON t1.id = t2.id\n AND t1.edited < t2.edited\n WHERE t2.edited IS NULL\n AND sp.class = 'Article'\n ORDER BY t1.edited DESC"); $perpage = 20; $pager = Pagination::getRange($perpage, $total); $r = $DB->query("SELECT DISTINCT sp.id FROM updates AS t1 \n LEFT JOIN spine sp ON sp.id = t1.id\n LEFT JOIN updates t2 ON t1.id = t2.id\n AND t1.edited < t2.edited\n WHERE t2.edited IS NULL\n AND sp.class = 'Article'\n ORDER BY t1.edited DESC\n LIMIT " . $pager['range']['start'] . ", " . $perpage); while (false !== ($article = $DB->fetchAssoc($r))) { $article = $Controller->{$article['id']}; $aList[] = '<li><span class="fixed-width">' . $article->Name . '</span><div class="tools">' . icon('small/eye', __('View'), url(array('id' => $article->ID))) . icon('small/pencil', __('Edit'), url(array('edit' => $article->ID), array('id'))) . icon('small/delete', __('Delete'), url(array('del' => $article->ID), 'id')) . '</div></li>'; } $aList = listify($aList); if ($total > $perpage) { $aList .= $pager['links']; } $form = new Form('newArticle'); $calendarSettings->params = 'collapsible:true,active:false'; return new Tabber('events', __('Article manager'), $aList, __('New article'), $form->collection(new Hidden('asave', 1), new Hidden('edit', $_REQUEST['edit'] ? $_REQUEST['edit'] : 'new'), new Set(new Select(__('Language'), 'lang', google::languages($CONFIG->Site->languages), $USER->settings['language']), new Input(__('Title'), 'atitle'), new Li(new Datepicker(__('Publish'), 'apubd'), new Timepickr(false, 'apubt')), new htmlfield(__('Text'), 'atxt'), new htmlfield(__('Preamble'), 'apre')))); }