public static function rpc_get_default(Context $ctx) { if (null === ($fid = $ctx->get('fid'))) { $fid = trim(strchr($ctx->query(), '/'), '/'); } $node = Node::load($fid, $ctx->db); $path = os::webpath($ctx->config->getDirName(), $ctx->config->files, $node->filepath); return new Redirect($path, Redirect::PERMANENT); }
/** * Проверяет, разрешено ли использовать редактор на странице. */ private static function isPageEnabled(Context $ctx) { $pages = $ctx->config->getArray('modules/tinymce/routes', array('admin/edit/', 'admin/create/')); if ($ctx->get('tinymcepicker')) { $pages[] = 'admin/content/files'; } $query = $ctx->query(); foreach ($pages as $prefix) { if (0 === strpos($query, $prefix)) { return true; } } return false; }
private static function isLocked(Context $ctx, $enable_admin = true) { $conf = $ctx->config->get('modules/maintenance'); if (!empty($conf['state']) and 'closed' === $conf['state']) { if (!$enable_admin) { return true; } if (!$ctx->canDebug()) { $query = $ctx->query(); if ('admin' != $query and 0 !== strpos($query, 'admin/')) { return true; } } } return false; }
/** * Вывод инфорамации о подключаемых скриптах и стилях. * @mcms_message ru.molinos.cms.page.head */ public static function on_get_head(Context $ctx, array $pathinfo = null) { $output = ''; if (self::isAdminPage($query = $ctx->query())) { list($scripts, $styles) = self::getAdminFiles($ctx, !$ctx->get('nocompress')); } elseif (null !== $pathinfo and !empty($pathinfo['theme'])) { list($scripts, $styles) = self::getThemeFiles($ctx, $pathinfo['theme'], !$ctx->get('nocompress')); } else { $scripts = $styles = array(); } foreach ($styles as $fileName) { if (file_exists($fileName) and filesize($fileName)) { $output .= html::em('link', array('rel' => 'stylesheet', 'type' => 'text/css', 'href' => os::webpath($fileName))); } } foreach ($scripts as $fileName) { if (file_exists($fileName) and filesize($fileName)) { $output .= html::em('script', array('src' => os::webpath($fileName), 'type' => 'text/javascript')); } } return html::wrap('head', html::cdata($output), array('module' => 'compressor', 'weight' => 100)); }
private static function getCGroup(Context $ctx) { if (null === ($cgroup = $ctx->get('cgroup'))) { $parts = explode('/', $ctx->query()); $cgroup = $parts[1]; } return $cgroup; }
/** * Возвращает путь к указанной странице. */ public function getPath(Context $ctx) { $path = array(); $query = $ctx->query(); $tabs = explode('/', $query); $tab = empty($tabs[1]) ? null : 'admin/' . $tabs[1]; while ($query) { if (!empty($this->static[$query])) { $em = $this->static[$query]; $em['name'] = $query; array_unshift($path, $em); } $query = substr($query, 0, strrpos($query, '/')); } $output = ''; foreach ($path as $em) { $output .= self::path($em); } return html::em('location', array('tab' => $tab), $output); }