コード例 #1
0
 /**
  * Добавление файлов с FTP (форма).
  */
 public static function on_get_ftp_form(Context $ctx)
 {
     if (!($files = self::getFtpFiles($ctx))) {
         throw new PageNotFoundException();
     }
     $options = array('name' => 'addfile', 'title' => t('Добавление <a href="@url">файлов</a>, загруженных по FTP', array('@url' => 'admin/content/files')), 'mode' => 'ftp', 'target' => 'admin/create/file/ftp?destination=' . urlencode($ctx->get('destination')), 'back' => $ctx->get('destination'));
     $content = '';
     foreach ($files as $file) {
         $content .= html::em('file', array('name' => basename($file), 'size' => filesize($file), 'sizeh' => mcms::filesize(filesize($file)), 'time' => mcms::now(filemtime($file))));
     }
     $content .= self::get_modes($ctx, 'ftp');
     return html::em('content', $options, $content);
 }
コード例 #2
0
 private static function getSummary(Context $ctx, array &$parts)
 {
     $parts = array();
     self::count($ctx, $parts, 'SELECT COUNT(*) FROM `node`', 'Объектов: !count', '?q=admin/content/list&columns=name,class,uid,created');
     self::count($ctx, $parts, 'SELECT COUNT(*) FROM `node` WHERE `deleted` = 1', 'удалённых: !count', '?q=admin/content/list/trash');
     self::count($ctx, $parts, 'SELECT COUNT(*) FROM `node` WHERE `published` = 0 AND `deleted` = 0', 'в модерации: !count', '?q=admin/content/list/drafts');
     self::count($ctx, $parts, 'SELECT COUNT(*) FROM `node__session`', 'сессий: !count');
     if ('SQLite' == $ctx->db->getDbType()) {
         $parts[] = t('объём&nbsp;БД:&nbsp;%size', array('%size' => mcms::filesize($ctx->db->getDbName())));
     }
     if ($tmp = mcms::config('runtime.modules')) {
         $parts[] = t('<a href=\'@url\'>модулей</a>:&nbsp;%count', array('%count' => count(explode(',', $tmp)), '@url' => '?q=admin/structure/modules'));
     }
     return join(', ', $parts);
 }
コード例 #3
0
ファイル: control.links.php プロジェクト: umonkey/molinos-cms
 public function set($value, &$node)
 {
     $result = array();
     foreach (preg_split('/[\\r\\n]+/', $value) as $line) {
         if (count($parts = preg_split('/\\s+/', $line, 2, PREG_SPLIT_NO_EMPTY))) {
             $link = array();
             if ($tmp = array_shift($parts)) {
                 $link['href'] = $tmp;
             }
             if ($tmp = array_shift($parts)) {
                 $link['name'] = $tmp;
             }
             if (!empty($link['href'])) {
                 $link['host'] = url::host($link['href']);
             }
             try {
                 $head = http::head($link['href']);
                 if (200 == ($link['status'] = $head['_status'])) {
                     if (!empty($head['Content-Type'])) {
                         $link['type'] = $head['Content-Type'];
                     }
                     if (!empty($head['Content-Length'])) {
                         $link['size'] = intval($head['Content-Length']);
                         $link['sizefm'] = mcms::filesize($link['size']);
                     }
                 }
             } catch (Exception $e) {
             }
             $result[] = $link;
         }
     }
     if (empty($result)) {
         unset($node->{$this->value});
     } else {
         $node->{$this->value} = $result;
     }
 }
コード例 #4
0
 /**
  * Возвращает текст страницы.
  */
 protected function getContent()
 {
     $content = $this->content;
     if ('text/html' == $this->type) {
         $content = str_replace(array('$request_time', '$peak_memory'), array(microtime(true) - MCMS_START_TIME, mcms::filesize(memory_get_peak_usage())), $content);
         if (!empty($_GET['__cleanurls'])) {
             $re = '@(href|src|action)=([\'"])\\?q=([^&"\']+)\\&amp\\;+@';
             $content = preg_replace($re, '\\1=\\2\\3?', $content);
             $re = '@(href|src|action)=([\'"])\\?q=([^&"\']+)([\'"])+@';
             $content = preg_replace($re, '\\1=\\2\\3\\4', $content);
         }
     }
     return $content;
 }
コード例 #5
0
ファイル: node.file.php プロジェクト: umonkey/molinos-cms
 /**
  * Возвращает дополнительные поля для предварительного просмотра.
  */
 public function getPreviewXML(Context $ctx)
 {
     $result = parent::getPreviewXML($ctx);
     if ($this->width and $this->height) {
         $tmp = $this->width . '×' . $this->height;
         if ($this->filesize) {
             $tmp .= ', ' . mcms::filesize($this->filesize);
         }
         $result .= html::em('field', array('title' => t('Исходные размеры')), html::em('value', html::cdata($tmp)));
     }
     if ($this->duration) {
         $result .= html::em('field', array('title' => t('Продолжительность')), html::em('value', html::cdata($this->duration)));
     }
     if ($this->bitrate) {
         $result .= html::em('field', array('title' => t('Битрейт')), html::em('value', html::cdata(ceil($this->bitrate))));
     }
     if ($this->channels) {
         switch ($this->channels) {
             case 1:
                 $tmp = t('моно');
                 break;
             case 2:
                 $tmp = t('стерео');
                 break;
             case 4:
                 $tmp = t('квадро');
                 break;
             default:
                 $tmp = t('%count каналов', array('%count' => $this->channels));
         }
         $result .= html::em('field', array('title' => t('Звук')), html::em('value', array('channels' => $this->channels), html::cdata($tmp)));
     }
     if ($tmp = $this->getEmbedHTML($ctx)) {
         $result .= html::em('field', array('title' => t('Оригинал')), html::em('value', array('class' => 'embed'), html::cdata($tmp)));
     }
     if (!empty($this->versions)) {
         foreach ((array) $this->versions as $name => $info) {
             $em = array('title' => t('Версия %name', array('%name' => $name)));
             $url = os::webpath($ctx->config->getPath('modules/files/storage'), $info['filename']);
             $tmp = t('<a href="@url"><img src="@url" width="%width" height="%height" alt="%filename" /></a>', array('%name' => $name, '%width' => $info['width'], '%height' => $info['height'], '%filename' => basename($info['filename']), '@url' => $url));
             $tmp .= t('<br/>%width×%height', array('%width' => $info['width'], '%height' => $info['height']));
             $em['#text'] = html::em('value', html::cdata($tmp));
             $result .= html::em('field', $em);
         }
     }
     $count = Node::count(array('deleted' => 0, 'tagged' => $this->id), $ctx->db);
     if ($count) {
         $message = t('%count документов используют этот файл (<a href="@url">список</a>)', array('%count' => $count, '@url' => 'admin/content/list?search=tagged%3A' . $this->id));
         $result .= html::em('field', array('title' => t('Статистика')), html::em('value', html::cdata($message)));
     }
     return $result;
 }