protected function render_body() { global $core; $rendered_columns_cells = $this->render_columns_cells($this->columns); $rows = $this->columns_to_rows($rendered_columns_cells); $html = ''; foreach ($rows as $i => $row) { $record = $this->records[$i]; $title = $record->title; $label = new Element('a', array(Element::INNER_HTML => \ICanBoogie\escape($title), 'class' => 'goto-edit', 'title' => I18n\t('Edit this item'), 'href' => \ICanBoogie\Routing\contextualize("/admin/{$record->constructor}/{$record->nid}/edit"))); $img = $record->thumbnail('$gallery')->to_element(array('title' => $title, 'alt' => $title)); $html .= <<<EOT <div class="thumbnailer-wrapper" data-key="{$record->nid}" style="width: 128px;"> \t<a href="{$record->path}" rel="lightbox[]">{$img}</a> \t{$label} </div> EOT; } $colspan = count($this->columns) + 1; return <<<EOT <tr id="gallery"> \t<td colspan="{$colspan}" class="gallery-inner"> \t\t<div class="gallery-contents">{$html}</div> \t</td> </tr> EOT; }
/** * Returns the contextualized URL of a route. * * @param Core|CoreBindings $app * @param string|Route $route * @param array|object|null $values * * @return string */ public static function url_for(Core $app, $route, $values = null) { if (!$route instanceof Route) { $route = $app->routes[$route]; } $url = $route->format($values); return \ICanBoogie\Routing\contextualize($url); }
public function render_cell($record) { $label = $record->username; $name = $record->name; if ($label != $name) { $label .= ' <small>(' . $name . ')</small>'; } return new Element('a', [Element::INNER_HTML => $label, 'class' => 'edit', 'href' => \ICanBoogie\Routing\contextualize("/admin/{$record->constructor}/{$record->uid}/edit"), 'title' => I18n\t('manage.edit')]); }
protected function get_attributes() { global $core; $page = $core->site->resolve_view_target('search/home'); if ($page) { $description_link = (string) new A($page->title, \ICanBoogie\Routing\contextualize("/admin/pages/{$page->nid}/edit")); } else { $description_link = '<q>' . new A('Pages', \ICanBoogie\Routing\contextualize('/admin/pages')) . '</q>'; } return \ICanBoogie\array_merge_recursive(parent::get_attributes(), array(Element::GROUPS => array('primary' => array('description' => I18n\t($page ? 'description' : 'description_nopage', array(':link' => $description_link)))))); }
protected function process() { global $core; $enabled = array_keys($core->modules->enabled_modules_descriptors); $enabled = array_combine($enabled, $enabled); if ($this->key) { foreach (array_keys($this->key) as $key) { unset($enabled[$key]); unset($core->modules[$key]); } } $core->vars['enabled_modules'] = array_values($enabled); $this->response->location = \ICanBoogie\Routing\contextualize('/admin/' . $this->module->id); return true; }
public static function create_attachment($entry, $hard_bond = false) { global $core; $hiddens = null; $links = array(); $i = uniqid(); $size = \ICanBoogie\I18n\format_size($entry->size); $preview = null; if ($entry instanceof Uploaded) { $title = $entry->name; $extension = $entry->extension; $hiddens .= '<input type="hidden" class="file" name="nodes_attachments[' . $i . '][file]" value="' . \ICanBoogie\escape(basename($entry->location)) . '" />' . PHP_EOL; $hiddens .= '<input type="hidden" name="nodes_attachments[' . $i . '][mime]" value="' . \ICanBoogie\escape($entry->mime) . '" />' . PHP_EOL; $links = array('<a href="#remove" class="btn btn-warning">' . I18n\t('label.remove') . '</a>'); } else { $fid = $entry->nid; $title = $entry->title; $extension = substr($entry->path, strrpos($entry->path, '.')); $hiddens .= '<input type="hidden" name="nodes_attachments[' . $i . '][fileid]" value="' . $fid . '" />'; $links = array('<a href="' . \ICanBoogie\Routing\contextualize('/admin/files/' . $fid . '/edit') . '" class="btn"><i class="icon-pencil"></i> ' . I18n\t('label.edit') . '</a>', '<a href="' . Operation::encode('files/' . $fid . '/download') . '" class="btn"><i class="icon-download-alt"></i> ' . I18n\t('label.download') . '</a>', $hard_bond ? '<a href="#delete" class="btn btn-danger"><i class="icon-remove icon-white"></i> ' . I18n\t('Delete file') . '</a>' : '<a href="#remove" class="btn btn-warning"><i class="icon-remove"></i> ' . t('Break link') . '</a>'); $node = $core->models['nodes'][$entry->nid]; if ($node instanceof \Icybee\Modules\Images\Image) { $preview = $node->thumbnail('$icon')->to_element(array('data-popover-image' => $node->thumbnail('$popup')->url)); } } $title = \ICanBoogie\escape($title); $links = empty($links) ? '' : ' – ' . implode(' ', $links); if ($extension) { $extension = '<span class="lighter">(' . $extension . ')</span>'; } return <<<EOT <li> \t<span class="handle">↕</span>{$preview}<input type="text" name="nodes_attachments[{$i}][title]" value="{$title}" /> \t<span class="small"> \t\t<span class="info light">{$size} {$extension}</span> {$links} \t</span> \t{$hiddens} </li> EOT; }
/** * Encodes a RESTful operation. * * @param string $pattern * @param array $params * * @return string The operation encoded as a RESTful relative URL. */ public static function encode($pattern, array $params = []) { $destination = null; $name = null; $key = null; if (isset($params[self::DESTINATION])) { $destination = $params[self::DESTINATION]; unset($params[self::DESTINATION]); } if (isset($params[self::NAME])) { $name = $params[self::NAME]; unset($params[self::NAME]); } if (isset($params[self::KEY])) { $key = $params[self::KEY]; unset($params[self::KEY]); } $qs = http_build_query($params, '', '&'); $rc = self::RESTFUL_BASE . strtr($pattern, ['{destination}' => $destination, '{name}' => $name, '{key}' => $key]) . ($qs ? '?' . $qs : ''); return \ICanBoogie\Routing\contextualize($rc); }
public function render_cell($descriptor) { global $core; $module_id = $descriptor[Module::T_ID]; if (empty($core->routes["admin:{$module_id}/config"])) { return; } $route = $core->routes["admin:{$module_id}/config"]; return new A('Configure', \ICanBoogie\Routing\contextualize($route->pattern)); }
protected function __deprecated__render_cell_title($record, $property) { global $core; static $languages; static $languages_count; if ($languages === null) { $languages = $core->models['sites']->count('language'); $languages_count = count($languages); } $title = $record->{$property}; $label = $title ? \ICanBoogie\escape(\ICanBoogie\shorten($title, 52, 0.75, $shortened)) : $this->t('<em>no title</em>'); if ($shortened) { $label = str_replace('…', '<span class="light">…</span>', $label); } $rc = ''; if ($rc) { $rc .= ' '; } $rc .= new Element('a', [Element::INNER_HTML => $label, 'class' => 'edit', 'href' => \ICanBoogie\Routing\contextualize("/admin/{$record->constructor}/{$record->nid}/edit"), 'title' => $shortened ? $this->t('edit_named', [':title' => $title ? $title : 'unnamed']) : $this->t('edit')]); $metas = ''; $language = $record->language; if ($languages_count > 1 && $language != $core->site->language) { $metas .= ', <span class="language">' . ($language ? $language : 'multilingue') . '</span>'; } if (!$record->siteid) { $metas .= ', multisite'; } if ($metas) { $rc .= '<span class="metas small light">:' . substr($metas, 2) . '</span>'; } return $rc; }
/** * Returns the template to use for a specified page. * * @param int $nid * * @return array An array composed of the template name, the description and a boolean * representing wheter or not the template is inherited for the specified page. */ protected function resolve_template($nid, $request_template = null) { global $core; $inherited = false; $is_alone = !$this->model->select('nid')->filter_by_siteid($core->site_id)->rc; if ($is_alone) { $template = 'home.html'; } $description = I18n\t("The template defines a page model of which some elements are editable."); if (!$nid) { if ($is_alone) { $description .= " Parce que la page est seule elle utilise le gabarit <q>home.html</q>."; } else { if (!$request_template) { $template = 'page.html'; } else { $template = $request_template; } } return array($template, $description, $template == 'page.html'); } $record = $this->model[$nid]; $definer = null; $template = $request_template !== null ? $request_template : $record->template; // \ICanBoogie\log('template: \1 (requested: \3), is_home: \2', array($template, $record->is_home, $request_template)); if ($template == 'page.html' && (!$record->parent || $record->parent && $record->parent->is_home)) { // \ICanBoogie\log('page parent is home, hence the page.html template'); $inherited = true; // TODO-20100507: à réviser, parce que la page peut ne pas avoir de parent. $description .= ' ' . "Parce qu'aucun gabarit n'est défini pour la page, elle utilise\n\t\t\tle gabarit <q>page.html</q>."; } else { if ($template == 'home.html' && (!$record->parent && $record->weight == 0)) { $inherited = true; //$template_description .= ' ' . "Cette page utilise le gabarit « home.html »."; } else { if (!$request_template) { $definer = $record->parent; if (!$definer) { $template = 'page.html'; $inherited = true; $description .= ' ' . "Parce qu'aucun gabarit n'est défini pour la page, elle utilise\n\t\t\t\tle gabarit <q>page.html</q>."; } } else { $definer = $record; $parent = $record->parent; // \ICanBoogie\log('parent: \1 (\2 ?= \3)', array($definer->title, $definer->template, $template)); while ($parent) { // \ICanBoogie\log('parent: \1, template: \2', array($parent->title, $parent->template)); if ($parent->template == $request_template) { break; } $parent = $parent->parent; } // \ICanBoogie\log('end parent: \1', array($parent ? $parent->title : 'none')); if ($parent && $parent->template == $request_template) { $definer = $parent; } // \ICanBoogie\log('definer: \1:\3 (\2), record: \4:\5', array($definer->title, $definer->template, $definer->nid, $record->title, $record->nid)); } } } if ($definer && $definer != $record) { // \ICanBoogie\log("entry template: $template ($record->nid), from: $inherited->template ($inherited->nid: $inherited->title)"); $description .= ' ' . I18n\t('This page uses the <q>:template</q> template, inherited from the parent page <q><a href="!url">!title</a></q>.', array('template' => $template, 'url' => \ICanBoogie\Routing\contextualize("/admin/{$this->id}/{$definer->nid}/edit"), 'title' => $definer->title)); $inherited = true; } return array($template, $description, $inherited); }