From 0d92858f584ce91944e6c1ddddd14e0fc969e7d3 Mon Sep 17 00:00:00 2001
From: llaffont <llaffont@git-test.afi-sa.fr>
Date: Sat, 8 Sep 2012 09:02:22 +0000
Subject: [PATCH] Formulaire pour l'upload de la vignette notice

---
 .gitattributes                                |  2 +
 .../admin/controllers/UploadController.php    |  6 +++
 .../scripts/upload/vignette-notice.phtml      |  1 +
 .../opac/controllers/UploadController.php     |  4 +-
 library/ZendAfi/Form/VignetteNotice.php       | 38 +++++++++++++++++++
 .../controllers/UploadControllerTest.php      | 26 ++++++++++++-
 6 files changed, 75 insertions(+), 2 deletions(-)
 create mode 100644 application/modules/admin/views/scripts/upload/vignette-notice.phtml
 create mode 100644 library/ZendAfi/Form/VignetteNotice.php

diff --git a/.gitattributes b/.gitattributes
index 93a2f9c1cc4..5f9fb482635 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -520,6 +520,7 @@ application/modules/admin/views/scripts/systeme/mailtest.phtml -text
 application/modules/admin/views/scripts/systeme/phpinfo.phtml -text
 application/modules/admin/views/scripts/systeme/webservices.phtml -text
 application/modules/admin/views/scripts/upload/multiple.phtml -text
+application/modules/admin/views/scripts/upload/vignette-notice.phtml -text
 application/modules/admin/views/scripts/usergroup/_form.phtml -text
 application/modules/admin/views/scripts/usergroup/_usergroup.phtml -text
 application/modules/admin/views/scripts/usergroup/editmembers.phtml -text
@@ -2004,6 +2005,7 @@ library/ZendAfi/Form/FRBR/Link.php -text
 library/ZendAfi/Form/FRBR/LinkType.php -text
 library/ZendAfi/Form/Login.php -text
 library/ZendAfi/Form/SuggestionAchat.php -text
+library/ZendAfi/Form/VignetteNotice.php -text
 library/ZendAfi/Translate.php -text
 library/ZendAfi/Validate/FieldGreater.php -text
 library/ZendAfi/Validate/FieldsGreater.php -text
diff --git a/application/modules/admin/controllers/UploadController.php b/application/modules/admin/controllers/UploadController.php
index 59316ad6f76..267c7b6bcb8 100644
--- a/application/modules/admin/controllers/UploadController.php
+++ b/application/modules/admin/controllers/UploadController.php
@@ -68,5 +68,11 @@ $(document).ready(function () {
 
 		$this->_helper->json(array('success' => 'false'));
 	}
+
+
+	public function vignetteNoticeAction() {
+		$this->_helper->getHelper('viewRenderer')->setLayoutScript('empty.phtml');
+		$this->view->form = new ZendAfi_Form_VignetteNotice();
+	}
 }
 ?>
\ No newline at end of file
diff --git a/application/modules/admin/views/scripts/upload/vignette-notice.phtml b/application/modules/admin/views/scripts/upload/vignette-notice.phtml
new file mode 100644
index 00000000000..2e55e706a8c
--- /dev/null
+++ b/application/modules/admin/views/scripts/upload/vignette-notice.phtml
@@ -0,0 +1 @@
+<?php echo $this->form; ?>
\ No newline at end of file
diff --git a/application/modules/opac/controllers/UploadController.php b/application/modules/opac/controllers/UploadController.php
index 8b68a5bf252..46161290a8d 100644
--- a/application/modules/opac/controllers/UploadController.php
+++ b/application/modules/opac/controllers/UploadController.php
@@ -152,4 +152,6 @@ class UploadController extends Zend_Controller_Action
 		echo htmlspecialchars(json_encode($ret), ENT_NOQUOTES);
 		exit;
 	}
-}
\ No newline at end of file
+}
+
+?>
\ No newline at end of file
diff --git a/library/ZendAfi/Form/VignetteNotice.php b/library/ZendAfi/Form/VignetteNotice.php
new file mode 100644
index 00000000000..861aa16ffd8
--- /dev/null
+++ b/library/ZendAfi/Form/VignetteNotice.php
@@ -0,0 +1,38 @@
+<?php
+/**
+ * Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved.
+ *
+ * AFI-OPAC 2.0 is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
+ * the Free Software Foundation.
+ *
+ * There are special exceptions to the terms and conditions of the AGPL as it
+ * is applied to this software (see README file).
+ *
+ * AFI-OPAC 2.0 is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+ *
+ * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
+ * along with AFI-OPAC 2.0; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA 
+ */
+
+class ZendAfi_Form_VignetteNotice extends ZendAfi_Form {
+	use Trait_Translator;
+
+	public function init() {
+		parent::init();
+		$this
+			->addElement('url', 
+									 'url_vignette', 
+									 ['label' => $this->_('URL de la vignette'),
+										'placeholder' => 'ex: http://upload.wikimedia.org/wikipedia/en/2/2c/Harry_Potter_and_the_Philosopher%27s_Stone.jpg'])
+			->addElement('submit',
+									 'envoyer',
+									 ['label' => 'Envoyer']);
+	}
+}
+
+?>
\ No newline at end of file
diff --git a/tests/application/modules/admin/controllers/UploadControllerTest.php b/tests/application/modules/admin/controllers/UploadControllerTest.php
index 73a99bbd095..56ba373bbba 100644
--- a/tests/application/modules/admin/controllers/UploadControllerTest.php
+++ b/tests/application/modules/admin/controllers/UploadControllerTest.php
@@ -138,4 +138,28 @@ class UploadControllerMultipleProcessPostAction extends AbstractControllerTestCa
 		$today = new Zend_Date();
 		$this->assertContains($today->toString('yyyy-MM-dd'),	$album->getDateMaj());
 	}
-}
\ No newline at end of file
+}
+
+
+
+
+class UploadControllerVignetteNoticeActionTest extends AbstractControllerTestCase {
+	public function setUp() {
+		parent::setUp();
+
+		$this->dispatch('/admin/upload/vignette-notice', true);
+	}
+
+	/** @test */
+	public function formShouldHaveInputUrlVignette() {
+		$this->assertXPath('//form//input[@type="url"][@name="url_vignette"][contains(@placeholder, "ex: http://upload")]');
+	}
+
+
+	/** @test */
+	public function formShouldHaveSubmitButtonEnvoyer() {
+		$this->assertXPath('//form//input[@type="submit"][@value="Envoyer"]');
+	}
+}
+
+?>
\ No newline at end of file
-- 
GitLab