media first swipe

This commit is contained in:
Andy Miller
2014-09-22 15:49:53 -06:00
parent be02b0a238
commit 02f62e283a
5 changed files with 37 additions and 8 deletions

View File

@@ -130,8 +130,9 @@ class AdminPlugin extends Plugin
// Make local copy of POST.
$post = !empty($_POST) ? $_POST : array();
// Handle tasks.
$task = !empty($post['task']) ? $post['task'] : $this->uri->param('task');
$this->admin->task = $task = !empty($post['task']) ? $post['task'] : $this->uri->param('task');
if ($task) {
require_once __DIR__ . '/classes/controller.php';
$controller = new AdminController($this->grav, $this->template, $task, $this->route, $post);
@@ -173,7 +174,13 @@ class AdminPlugin extends Plugin
$theme_url = $this->config->get('system.base_url_relative') . '/user/plugins/admin/themes/'.$this->theme;
$twig = $this->grav['twig'];
$twig->template = $this->template . '.html.twig';
// Dynamic type support
$format = $this->uri->extension();
$ext = '.' . ($format ? $format : 'html') . TWIG_EXT;
// \Tracy\Debugger::dump($this->admin);
$twig->template = $this->template . $ext;
$twig->twig_vars['location'] = $this->template;
$twig->twig_vars['base_url_relative'] .=
($twig->twig_vars['base_url_relative'] != '/' ? '/' : '') . trim($this->config->get('plugins.admin.route'), '/');

View File

@@ -137,6 +137,19 @@ class AdminController
return true;
}
protected function taskListmedia()
{
$page = $this->admin->page(true);
$media_list = array();
foreach ($page->media()->all() as $name=> $media) {
$media_list[$name] = ['url'=>$media->url(),'size'=>$media->get('size')];
}
$this->admin->media = $media_list;
return true;
}
/**
* Enable plugin.
*

7
pages/admin/media.md Normal file
View File

@@ -0,0 +1,7 @@
---
title: Media
access:
admin.pages: true
admin.super: true
---

View File

@@ -0,0 +1,7 @@
{% if admin.task == 'listmedia' %}
{{ admin.media|json_encode }}
{% elseif admin.task == 'delmedia' %}
deleted!
{% elseif admin.task == 'addmedia' %}
added!
{% endif %}

View File

@@ -94,7 +94,7 @@
{% if mode == 'new' %}
{% include 'partials/blueprints-new.html.twig' with { blueprints: admin.blueprints('pages/page'), data: context } %}
{% elseif mode == 'edit' %}
<div class="admin-form-wrapper">
<div class="admin-form-wrapper" data-media-url="{{ base_url }}/media/{{ admin.route|trim('/') }}.json">
{% if context.blueprints.fields %}
<form id="admin-mode-toggle">
<div class="switch-toggle switch-grav">
@@ -118,11 +118,6 @@
<form id="page-filtering">
<div class="page-filters">
<input type="text" placeholder="Add Filters" class="page-filter" value="Routable,Visible,Modular" name="page-filter" />
<script>
$(function() {
});
</script>
</div>
<div class="page-search">
<input type="text" placeholder="Search Pages" name="page-search" />