-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Carousel module as a default module
- Loading branch information
0 parents
commit 924bd0d
Showing
36 changed files
with
7,152 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{if $module_code == 'Carousel'} | ||
<script> | ||
$(function() { | ||
// Set proper image ID in delete from | ||
$('a.image-delete').click(function(ev) { | ||
$('#image_delete_id').val($(this).data('id')); | ||
}); | ||
|
||
|
||
}); | ||
</script> | ||
{/if} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
<div class="general-block-decorator"> | ||
<div class="row"> | ||
<div class="col-md-12 title title-without-tabs"> | ||
{intl l='Edit your carousel.' d='carousel.ai'} | ||
</div> | ||
</div> | ||
|
||
<div class="row"> | ||
<div class="col-md-12"> | ||
<div class="form-container"> | ||
{form name="carousel.image"} | ||
<form method="POST" action="{url path="/admin/module/carousel/upload"}" {form_enctype form=$form} class="clearfix"> | ||
|
||
{form_hidden_fields form=$form} | ||
|
||
{form_field form=$form field='file'} | ||
<div class="form-group {if $error}has-error{/if}"> | ||
<label for="{$label_attr.for}" class="control-label">{intl d='carousel.ai' l='Add an image to the carousel'}</label> | ||
<div class="input-group"> | ||
<input type="file" id="{$label_attr.for}" {if $required}required="required"{/if} name="{$name}" value="{$value}" title="{intl l='Carousel image' d='carousel.ai'}" placeholder="{intl l='Carousel image' d='carousel.ai'}" class="form-control"> | ||
<span class="input-group-btn"> | ||
<input type="submit" class="form-submit-button btn btn-sm btn-success" value="{intl d='carousel.ai' l='Add this image to the carousel'}" > | ||
</span> | ||
</div> | ||
</div> | ||
{/form_field} | ||
</form> | ||
{/form} | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<div class="row"> | ||
<div class="col-md-12 title title-without-tabs"> | ||
{intl l='Carousel images' d='carousel.ai'} | ||
</div> | ||
</div> | ||
|
||
<div class="row"> | ||
<div class="col-md-12"> | ||
<div class="form-container"> | ||
{ifloop rel="carousel.image"} | ||
{form name="carousel.update"} | ||
<form method="post" action="{url path="/admin/module/carousel/update"}" {form_enctype form=$form} class="clearfix"> | ||
|
||
{include | ||
file = "includes/inner-form-toolbar.html" | ||
page_url = "{url path='/admin/module/Carousel'}" | ||
close_url = "{url path='/admin/modules'}" | ||
} | ||
|
||
{form_hidden_fields form=$form} | ||
|
||
{loop name="carousel.image" type="carousel" width="550" height="200" resize_mode="borders" backend_context="1" lang="$edit_language_id"} | ||
|
||
{* Not yet implemented *} | ||
{form_field form=$form field="position{$ID}"} | ||
<input type="hidden" name="{$name}" value={$POSITION}> | ||
{/form_field} | ||
|
||
<div class="well well-sm"> | ||
<div class="row"> | ||
<div class="col-md-6"> | ||
<p> | ||
<a href="{$ORIGINAL_IMAGE_URL}" class="thumbnail" target="_blank"> | ||
<img src="{$IMAGE_URL}" alt="{$ALT}"> | ||
</a> | ||
</p> | ||
|
||
<div class="btn-group"> | ||
<a class="btn btn-default btn-sm image-delete" href="#delete_carousel_dialog" data-toggle="modal" data-id="{$ID}"> | ||
<i class="glyphicon glyphicon-trash"></i> {intl d='carousel.ai' l='Remove this image'} | ||
</a> | ||
</div> | ||
</div> | ||
|
||
<div class="col-md-6"> | ||
{* Not yet implemented | ||
{render_form_field form=$form field="chapo{$ID} value=$CHAPO"} | ||
*} | ||
{render_form_field form=$form field="title{$ID}" value=$TITLE} | ||
{render_form_field form=$form field="alt{$ID}" value=$ALT} | ||
{render_form_field form=$form field="url{$ID}" value=$URL} | ||
{render_form_field form=$form field="description{$ID}" extra_class="wysiwyg" value=$DESCRIPTION} | ||
{* Not yet implemented | ||
{render_form_field form=$form field="postscriptum{$ID}" value=$POSTSCRIPTUM} | ||
*} | ||
</div> | ||
</div> | ||
</div> | ||
{/loop} | ||
|
||
{include | ||
file = "includes/inner-form-toolbar.html" | ||
page_url = "{url path='/admin/module/Carousel'}" | ||
close_url = "{url path='/admin/modules'}" | ||
page_bottom = true | ||
} | ||
</form> | ||
{/form} | ||
{/ifloop} | ||
|
||
{elseloop rel="carousel.image"} | ||
<div class="alert alert-info"> | ||
{intl d='carousel.ai' l="Your carousel contains no image. Please add one using the form above."} | ||
</div> | ||
{/elseloop} | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
{capture "delete_dialog"} | ||
<input type="hidden" name="image_id" id="image_delete_id" value="" /> | ||
{/capture} | ||
|
||
{include | ||
file = "includes/generic-confirm-dialog.html" | ||
|
||
dialog_id = "delete_carousel_dialog" | ||
dialog_title = {intl l="Delete a carousel image" d="carousel.ai"} | ||
dialog_message = {intl l="Do you really want to remove this image from the carousel ?" d="carousel.ai"} | ||
|
||
form_action = {url path='/admin/module/carousel/delete'} | ||
form_content = {$smarty.capture.delete_dialog nofilter} | ||
} | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
/*************************************************************************************/ | ||
/* This file is part of the Thelia package. */ | ||
/* */ | ||
/* Copyright (c) OpenStudio */ | ||
/* email : [email protected] */ | ||
/* web : http://www.thelia.net */ | ||
/* */ | ||
/* For the full copyright and license information, please view the LICENSE.txt */ | ||
/* file that was distributed with this source code. */ | ||
/*************************************************************************************/ | ||
|
||
namespace Carousel; | ||
|
||
use Propel\Runtime\Connection\ConnectionInterface; | ||
use Thelia\Install\Database; | ||
use Thelia\Module\BaseModule; | ||
|
||
class Carousel extends BaseModule | ||
{ | ||
const DOMAIN_NAME = 'carousel'; | ||
|
||
public function preActivation(ConnectionInterface $con = null) | ||
{ | ||
if (! $this->getConfigValue('is_initialized', false)) { | ||
$database = new Database($con); | ||
|
||
$database->insertSql(null, array(__DIR__ . '/Config/sql/thelia.sql')); | ||
|
||
$this->setConfigValue('is_initialized', true); | ||
} | ||
} | ||
|
||
public function destroy(ConnectionInterface $con = null, $deleteModuleData = false) | ||
{ | ||
$database = new Database($con); | ||
|
||
$database->insertSql(null, array(__DIR__ . '/Config/sql/destroy.sql')); | ||
} | ||
|
||
public function getUploadDir() | ||
{ | ||
return __DIR__ . DS . 'media' . DS . 'carousel'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<config xmlns="http://thelia.net/schema/dic/config" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://thelia.net/schema/dic/config http://thelia.net/schema/dic/config/thelia-1.0.xsd"> | ||
|
||
<loops> | ||
<loop name="carousel" class="Carousel\Loop\CarouselLoop" /> | ||
</loops> | ||
|
||
<forms> | ||
<form name="carousel.image" class="Carousel\Form\CarouselImageForm" /> | ||
<form name="carousel.update" class="Carousel\Form\CarouselUpdateForm" /> | ||
</forms> | ||
|
||
<hooks> | ||
<hook id="carousel.hook" class="Carousel\Hook\CarouselHook" scope="request"> | ||
<tag name="hook.event_listener" event="home.body" /> | ||
</hook> | ||
</hooks> | ||
</config> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
INSERT INTO `carousel` (`id`, `file`, `position`, `url`, `created_at`, `updated_at`) VALUES | ||
(1, 'sample-carousel-image-1.png', NULL, NULL, NOW(), NOW()), | ||
(2, 'sample-carousel-image-2.png', NULL, NULL, NOW(), NOW()); | ||
|
||
|
||
INSERT INTO `carousel_i18n` (`id`, `locale`, `alt`, `title`, `description`, `chapo`, `postscriptum`) VALUES | ||
(1, 'en_US', 'Thelia e-commerce', 'A sample carousel image', NULL, NULL, NULL), | ||
(1, 'fr_FR', 'Thelia e-commerce', 'Une image de démonstration', NULL, NULL, NULL), | ||
(2, 'en_US', 'Based on Symfony 2', 'Another sample carousle image', NULL, NULL, NULL), | ||
(2, 'fr_FR', 'Construit avec Symphony 2', 'Un autre image de démonstration', NULL, NULL, NULL); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<module> | ||
<fullnamespace>Carousel\Carousel</fullnamespace> | ||
<descriptive locale="en_US"> | ||
<title>An image carousel</title> | ||
</descriptive> | ||
<descriptive locale="fr_FR"> | ||
<title>Un carrousel d'images</title> | ||
</descriptive> | ||
<version>0.9</version> | ||
<author> | ||
<name>Manuel Raynaud, Franck Allimant</name> | ||
<email>[email protected], [email protected]</email> | ||
</author> | ||
<type>classic</type> | ||
<thelia>2.1.0</thelia> | ||
<stability>beta</stability> | ||
</module> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
|
||
<routes xmlns="http://symfony.com/schema/routing" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd"> | ||
|
||
<!-- | ||
if a /admin/module/carousel/ route is provided, a "Configuration" button will be displayed | ||
for the module in the module list. Clicking this button will invoke this route. | ||
<route id="my_route_id" path="/admin/module/carousel"> | ||
<default key="_controller">Carousel\Full\Class\Name\Of\YourConfigurationController::methodName</default> | ||
</route> | ||
<route id="my_route_id" path="/admin/module/carousel/route-name"> | ||
<default key="_controller">Carousel\Full\Class\Name\Of\YourAdminController::methodName</default> | ||
</route> | ||
<route id="my_route_id" path="/my/route/name"> | ||
<default key="_controller">Carousel\Full\Class\Name\Of\YourOtherController::methodName</default> | ||
</route> | ||
...add as many routes as required. | ||
<route> | ||
... | ||
</route> | ||
--> | ||
<route id="carousel.upload.image" path="/admin/module/carousel/upload" methods="post"> | ||
<default key="_controller">Carousel\Controller\ConfigurationController::uploadImage</default> | ||
</route> | ||
|
||
<route id="carousel.update" path="/admin/module/carousel/update" methods="post"> | ||
<default key="_controller">Carousel\Controller\ConfigurationController::updateAction</default> | ||
</route> | ||
|
||
<route id="carousel.delete" path="/admin/module/carousel/delete" methods="post"> | ||
<default key="_controller">Carousel\Controller\ConfigurationController::deleteAction</default> | ||
</route> | ||
|
||
</routes> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<database defaultIdMethod="native" name="thelia" namespace="Carousel\Model"> | ||
<!-- | ||
See propel documentation on http://propelorm.org for all information about schema file | ||
--> | ||
|
||
<table name="carousel"> | ||
<column autoIncrement="true" name="id" primaryKey="true" required="true" type="INTEGER" /> | ||
<column name="file" type="VARCHAR" size="255" /> | ||
<column name="position" type="INTEGER" /> | ||
<column name="alt" size="255" type="VARCHAR" /> | ||
<column name="url" size="255" type="VARCHAR" /> | ||
<column name="title" size="255" type="VARCHAR" /> | ||
<column name="description" type="CLOB" /> | ||
<column name="chapo" type="LONGVARCHAR" /> | ||
<column name="postscriptum" type="LONGVARCHAR" /> | ||
<behavior name="timestampable" /> | ||
<behavior name="i18n"> | ||
<parameter name="i18n_columns" value="alt, title, description, chapo, postscriptum" /> | ||
</behavior> | ||
</table> | ||
|
||
<external-schema filename="local/config/schema.xml" referenceOnly="true" /> | ||
</database> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
SET FOREIGN_KEY_CHECKS = 0; | ||
|
||
DROP TABLE IF EXISTS `carousel`; | ||
DROP TABLE IF EXISTS `carousel_i18n`; | ||
|
||
SET FOREIGN_KEY_CHECKS = 1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
|
||
# This is a fix for InnoDB in MySQL >= 4.1.x | ||
# It "suspends judgement" for fkey relationships until are tables are set. | ||
SET FOREIGN_KEY_CHECKS = 0; | ||
|
||
-- --------------------------------------------------------------------- | ||
-- carousel | ||
-- --------------------------------------------------------------------- | ||
|
||
DROP TABLE IF EXISTS `carousel`; | ||
|
||
CREATE TABLE `carousel` | ||
( | ||
`id` INTEGER NOT NULL AUTO_INCREMENT, | ||
`file` VARCHAR(255), | ||
`position` INTEGER, | ||
`url` VARCHAR(255), | ||
`created_at` DATETIME, | ||
`updated_at` DATETIME, | ||
PRIMARY KEY (`id`) | ||
) ENGINE=InnoDB; | ||
|
||
-- --------------------------------------------------------------------- | ||
-- carousel_i18n | ||
-- --------------------------------------------------------------------- | ||
|
||
DROP TABLE IF EXISTS `carousel_i18n`; | ||
|
||
CREATE TABLE `carousel_i18n` | ||
( | ||
`id` INTEGER NOT NULL, | ||
`locale` VARCHAR(5) DEFAULT 'en_US' NOT NULL, | ||
`alt` VARCHAR(255), | ||
`title` VARCHAR(255), | ||
`description` LONGTEXT, | ||
`chapo` TEXT, | ||
`postscriptum` TEXT, | ||
PRIMARY KEY (`id`,`locale`), | ||
CONSTRAINT `carousel_i18n_FK_1` | ||
FOREIGN KEY (`id`) | ||
REFERENCES `carousel` (`id`) | ||
ON DELETE CASCADE | ||
) ENGINE=InnoDB; | ||
|
||
# This restores the fkey checks, after having unset them earlier | ||
SET FOREIGN_KEY_CHECKS = 1; | ||
|
||
# ---------------------------------------------------------------------------------------- | ||
# Insert sample values | ||
# ---------------------------------------------------------------------------------------- | ||
|
||
INSERT INTO `carousel` (`id`, `file`, `position`, `url`, `created_at`, `updated_at`) VALUES | ||
(1, 'sample-carousel-image-1.png', NULL, NULL, NOW(), NOW()), | ||
(2, 'sample-carousel-image-2.png', NULL, NULL, NOW(), NOW()); | ||
|
||
|
||
INSERT INTO `carousel_i18n` (`id`, `locale`, `alt`, `title`, `description`, `chapo`, `postscriptum`) VALUES | ||
(1, 'en_US', 'Thelia e-commerce', 'A sample carousel image', NULL, NULL, NULL), | ||
(1, 'fr_FR', 'Thelia e-commerce', 'Une image de démonstration', NULL, NULL, NULL), | ||
(2, 'en_US', 'Based on Symfony 2', 'Another sample carousle image', NULL, NULL, NULL), | ||
(2, 'fr_FR', 'Construit avec Symphony 2', 'Un autre image de démonstration', NULL, NULL, NULL); |
Oops, something went wrong.