Пример #1
0
 protected function render_inner_html_for_select()
 {
     global $core;
     $native = $core->site->native->language;
     $constructor = $this[self::CONSTRUCTOR];
     $options = [];
     if ($constructor == 'pages') {
         $nodes = $core->models['pages']->select('nid, parentid, title')->filter_by_language($native)->order('weight, created')->all(\PDO::FETCH_OBJ);
         $tree = PagesModel::nestNodes($nodes);
         if ($tree) {
             PagesModel::setNodesDepth($tree);
             $records = PagesModel::levelNodesById($tree);
             foreach ($records as $record) {
                 $options[$record->nid] = str_repeat(" ", $record->depth * 4) . $record->title;
             }
         }
     } else {
         $options = $core->models['nodes']->select('nid, title')->filter_by_constructor_and_language($constructor, $native)->order('title')->pairs;
         foreach ($options as &$label) {
             $label = \ICanBoogie\shorten($label);
         }
         unset($label);
     }
     $this[self::OPTIONS] = [null => 'none'] + $options;
     return parent::render_inner_html_for_select();
 }
Пример #2
0
 protected function process()
 {
     global $core;
     $rc = parent::process();
     unset($core->vars['cached_sites']);
     $record = $this->module->model[$rc['key']];
     $this->response->message = new FormattedString($rc['mode'] == 'update' ? '%title has been updated in %module.' : '%title has been created in %module.', array('title' => \ICanBoogie\shorten($record->title), 'module' => $this->module->title));
     return $rc;
 }
Пример #3
0
 /**
  * Overrides the method to create a nicer log entry.
  */
 protected function process()
 {
     $title = $this->record->title;
     $rc = parent::process();
     if ($rc) {
         $this->response->message = new FormattedString('%title has been deleted from %module.', ['title' => \ICanBoogie\shorten($title), 'module' => $this->module->title]);
     }
     return $rc;
 }
Пример #4
0
 protected function getPreview($entry)
 {
     if (!$entry) {
         return '';
     }
     $title = $entry->title;
     $label = \ICanBoogie\shorten($title, 32, 0.75, $shortened);
     $rc = '<span class="title"' . ($shortened ? ' title="' . \Brickrouge\escape($title) . '"' : '') . '>';
     $rc .= \Brickrouge\escape($label) . '</span>';
     return $rc;
 }
Пример #5
0
 protected function render_inner_html()
 {
     global $core;
     $slug = $this->slug_el['value'];
     $tease = '<strong>Slug&nbsp;:</strong> ';
     $tease .= '<a href="#slug-edit" title="' . I18n\t('edit', [], ['scope' => 'titleslugcombo.element']) . '">' . ($slug ? \ICanBoogie\escape(\ICanBoogie\shorten($slug)) : $this->dataset['auto-label']) . '</a>';
     $tease .= ' <span>&ndash; <a href="slug-delete" class="warn">' . I18n\t('reset', [], ['scope' => 'titleslugcombo.element']) . '</a></span>';
     $this->slug_tease->inner_html = $tease;
     $rc = parent::render_inner_html();
     $nid = $this[self::T_NODEID];
     if ($nid) {
         $node = $core->models['nodes'][$nid];
         if ($node && $node->url && $node->url[0] != '#') {
             $url = $node->url;
             $url_label = \ICanBoogie\shorten($url, 64);
             $rc .= '<p class="small light">';
             $rc .= '<strong>URL&nbsp;:</strong> ' . $url_label;
         }
     }
     return $rc;
 }
Пример #6
0
 protected function render_record(\Icybee\Modules\Nodes\Node $record, $selected, array $range, array $options)
 {
     $recordid = $record->nid;
     return new A(\ICanBoogie\shorten($record->title), '#', ['data-nid' => $recordid, 'data-title' => $record->title]);
 }
Пример #7
0
 protected function get_record_name()
 {
     return \ICanBoogie\shorten($this->record->contents, 32, 1);
 }
Пример #8
0
 /**
  * Overrides the method to provide a nicer log message.
  */
 protected function process()
 {
     $rc = parent::process();
     $this->response->message = new FormattedString($rc['mode'] == 'update' ? '%title has been updated in :module.' : '%title has been created in :module.', array('title' => \ICanBoogie\shorten($this->record->title), 'module' => $this->module->title));
     return $rc;
 }
Пример #9
0
    public static function dashboard_last()
    {
        global $core;
        if (empty($core->modules['comments'])) {
            return;
        }
        $document = $core->document;
        $document->css->add('../public/admin.css');
        $model = $core->models['comments'];
        $entries = $model->where('(SELECT 1 FROM {prefix}nodes WHERE nid = comment.nid AND (siteid = 0 OR siteid = ?)) IS NOT NULL', $core->site_id)->order('created DESC')->limit(5)->all;
        if (!$entries) {
            return '<p class="nothing">' . I18n\t('No record yet') . '</p>';
        }
        $model->including_node($entries);
        $rc = '';
        $context = $core->site->path;
        foreach ($entries as $entry) {
            $url = $entry->url;
            $author = \ICanBoogie\escape($entry->author);
            if ($entry->author_url) {
                $author = '<a class="author" href="' . \ICanBoogie\escape($entry->author_url) . '">' . $author . '</a>';
            } else {
                $author = '<strong class="author">' . $author . '</strong>';
            }
            $excerpt = \ICanBoogie\shorten(strip_tags((string) html_entity_decode($entry, ENT_COMPAT, \ICanBoogie\CHARSET)), 140);
            $target_url = $entry->node->url;
            $target_title = \ICanBoogie\escape(\ICanBoogie\shorten($entry->node->title));
            $image = \ICanBoogie\escape($entry->author_icon);
            $entry_class = $entry->status == 'spam' ? 'spam' : '';
            $url_edit = "{$context}/admin/comments/{$entry->commentid}/edit";
            $url_delete = "{$context}/admin/comments/{$entry->commentid}/delete";
            $date = \ICanBoogie\I18n\format_date($entry->created, 'dd MMM');
            $txt_delete = I18n\t('Delete');
            $txt_edit = I18n\t('Edit');
            $txt_display_associated_node = I18n\t('Display associated node');
            $rc .= <<<EOT
<div class="record {$entry_class}">
\t<div class="options">
\t\t<img src="{$image}&amp;s=48" alt="" />
\t</div>

\t<div class="contents">
\t\t<div class="head">
\t\t{$author}
\t\t<span class="date light">{$date}</span>
\t\t</div>

\t\t<div class="body"><a href="{$url}">{$excerpt}</a></div>

\t\t<div class="actions light">
\t\t\t<a href="{$url_edit}">{$txt_edit}</a>, <a href="{$url_delete}" class="danger">{$txt_delete}</a> − <a href="{$target_url}" class="target" title="{$txt_display_associated_node}">{$target_title}</a>
\t\t</div>
\t</div>
</div>
EOT;
        }
        $count = $model->joins(':nodes')->where('siteid = 0 OR siteid = ?', $core->site_id)->count;
        $txt_all_comments = I18n\t('comments.count', array(':count' => $count));
        $rc .= <<<EOT
<div class="panel-footer"><a href="{$context}/admin/comments">{$txt_all_comments}</a></div>
EOT;
        return $rc;
    }
Пример #10
0
 /**
  * The component is shortened if it's longer than 52 characters, in which case the title of
  * the element is modified to include the original component.
  */
 public function render()
 {
     $element = parent::render();
     $component = $this->component;
     $html = $component ? \ICanBoogie\escape(\ICanBoogie\shorten($component, 52, 0.75, $shortened)) : I18n\t('<em>no title</em>');
     if (!$shortened) {
         return $element;
     }
     $element[Element::INNER_HTML] = str_replace('…', '<span class="light">…</span>', $html);
     $element['title'] = I18n\t('manage.edit_named', [':title' => $component ? $component : 'unnamed']);
     return $element;
 }
Пример #11
0
 public function render_cell($record)
 {
     $property = $this->id;
     $node = $record->node;
     $rc = '';
     if ($node) {
         $title = $node->title;
         $label = \ICanBoogie\escape(\ICanBoogie\shorten($title, 48, 0.75, $shortened));
         $rc .= new A("", $node->url, array('title' => $title, 'class' => 'icon-external-link')) . ' ';
     } else {
         $label = '<em class="warn">unknown-node-' . $record->{$property} . '</em>';
     }
     return $rc . new FilterDecorator($record, $property, $this->is_filtering, $label);
 }
Пример #12
0
function make_set($constructor, $entries, $count, $search, $has_pager = false)
{
    global $core;
    $flat_id = 'module.' . strtr($constructor, '.', '_');
    $rc = '<div class="set">';
    if (empty($_GET['constructor'])) {
        $title = $constructor == 'google' ? 'Google' : $core->modules->descriptors[$constructor][Module::T_TITLE];
        $title = I18n\t(strtr($constructor, '.', '_'), array(), array('scope' => 'module_title', 'default' => $title));
        $rc .= '<h2>' . $title . '</h2>';
    }
    $rc .= '<p class="count">';
    $rc .= I18n\t('found', array(':count' => $count, '%search' => $search), array('scope' => array($flat_id, 'search')));
    $rc .= '</p>';
    if ($entries) {
        $rc .= '<ol>';
        foreach ($entries as $entry) {
            $rc .= '<li>';
            $rc .= '<h3><a href="' . $entry->url . '">' . \ICanBoogie\escape(\ICanBoogie\shorten($entry->title, 80)) . '</a></h3>';
            $rc .= '<cite>' . \ICanBoogie\shorten($entry->url, 64) . '</cite>';
            $excerpt = search_excerpt($search, html_entity_decode($entry->body, ENT_COMPAT, 'utf-8'));
            $rc .= '<p class="excerpt">' . $excerpt . '</p>';
            $rc .= '</li>';
        }
        $rc .= '</ol>';
        if ($count > count($entries)) {
            if ($has_pager) {
                $rc .= new Pager('div', array(Pager::T_COUNT => $count, Pager::T_LIMIT => $core->site->metas->get('search.limits.list', 10), Pager::T_POSITION => isset($_GET['page']) ? (int) $_GET['page'] : 0, Pager::T_WITH => 'q,constructor', 'class' => 'pagination'));
            } else {
                $more_url = '?' . http_build_query(array('q' => $search, 'constructor' => $constructor));
                $rc .= '<p class="more"><a href="' . $more_url . '">';
                $rc .= I18n\t('more', array(':count' => $count, '%search' => $search), array('scope' => array($flat_id, 'search')));
                $rc .= '</a></p>';
            }
        }
    }
    $rc .= '</div>';
    return $rc;
}
Пример #13
0
 protected function render_inner_html()
 {
     $page = $node = $this[self::PAGE];
     $slices = array();
     while ($node) {
         $url = $node->url;
         $label = $node->label;
         $label = \ICanBoogie\shorten($label, 48);
         $label = \Brickrouge\escape($label);
         $slices[] = array('url' => $url, 'label' => $label, 'class' => $node->css_class('-type -slug -template -constructor -node-id -node-constructor'), 'page' => $node);
         if (!$node->parent && !$node->is_home) {
             $node = $node->home;
         } else {
             $node = $node->parent;
         }
     }
     $slices = array_reverse($slices);
     $divider = $this[self::DIVIDER] ?: self::DEFAULT_DIVIDER;
     new BreadcrumbElement\BeforeRenderInnerHTMLEvent($this, array('slices' => &$slices, 'divider' => &$divider, 'page' => $page));
     $html = '';
     $slices = array_values($slices);
     $last = count($slices) - 1;
     foreach ($slices as $i => $slice) {
         $html .= '<li class="' . $slice['class'] . '">';
         if ($i) {
             $html .= '<span class="divider">' . $divider . '</span>';
         }
         $class = \Brickrouge\escape($slice['class']);
         $label = \Brickrouge\escape($slice['label']);
         if ($i != $last) {
             $html .= '<a href="' . \Brickrouge\escape($slice['url']) . '" class="' . $class . '">' . $label . '</a>';
         } else {
             $html .= '<strong class="' . $class . '">' . $label . '</strong>';
         }
         $html .= '</li>';
     }
     new BreadcrumbElement\RenderInnerHTMLEvent($this, array('html' => &$html, 'page' => $page));
     return $html;
 }
Пример #14
0
    public static function dashboard_user_modified()
    {
        global $core, $document;
        $document->css->add(DIR . 'public/dashboard.css');
        $model = $core->models['nodes'];
        $entries = $model->where('uid = ? AND (siteid = 0 OR siteid = ?)', [$core->user_id, $core->site_id])->order('updated_at desc')->limit(10)->all;
        if (!$entries) {
            return '<p class="nothing">' . I18n\t('No record yet') . '</p>';
        }
        $last_date = null;
        $context = $core->site->path;
        $rc = '<table>';
        foreach ($entries as $record) {
            $date = \ICanBoogie\I18n\date_period($record->updated_at);
            if ($date === $last_date) {
                $date = '&mdash;';
            } else {
                $last_date = $date;
            }
            $title = \ICanBoogie\shorten($record->title, 48);
            $title = \ICanBoogie\escape($title);
            $rc .= <<<EOT
\t<tr>
\t<td class="date light">{$date}</td>
\t<td class="title"><a href="{$context}/admin/{$record->constructor}/{$record->nid}/edit">{$title}</a></td>
\t</tr>
EOT;
        }
        $rc .= '</table>';
        return $rc;
    }