Exemplo n.º 1
0
 public function stat()
 {
     global $core;
     $model = $core->models['contents/rendered'];
     list($count, $size) = $model->select('COUNT(nid) count, SUM(LENGTH(body)) size')->one(\PDO::FETCH_NUM);
     return [(int) $count, I18n\t(':count records<br /><span class="small">:size</span>', [':count' => (int) $count, 'size' => \ICanBoogie\I18n\format_size($size)])];
 }
Exemplo n.º 2
0
 public static function get_vars_stat($regex)
 {
     global $core;
     $n = 0;
     $size = 0;
     foreach ($core->vars->matching($regex) as $pathname => $fileinfo) {
         ++$n;
         $size += $fileinfo->getSize();
     }
     return array($n, I18n\t(':count files<br /><span class="small">:size</span>', array(':count' => $n, 'size' => \ICanBoogie\I18n\format_size($size))));
 }
    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) ? '' : ' &ndash; ' . 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;
    }
Exemplo n.º 4
0
 private static function make_link(\Icybee\Modules\Files\File $file, $label = null)
 {
     if (!$label) {
         $label = $file->label;
     }
     return '<a href="' . \ICanBoogie\escape($file->url('download')) . '">' . \ICanBoogie\escape($label) . '</a> <span class="metas">(' . $file->extension . ' &ndash; ' . \ICanBoogie\I18n\format_size($file->size) . ')</span>';
 }