Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Carousel update #1792

Merged
merged 1 commit into from Dec 16, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions local/modules/Carousel/CHANGELOG.md
@@ -0,0 +1,6 @@
# 2.3.0-alpha1

- Moved the images from the directory 'media' in the module to thelia/local/media/images/carousel.
- The current images will be automatically copied in the new directory during the update of the module
- Removed AdminIncludes directory
- All html,js and css files are now in 'templates'
46 changes: 44 additions & 2 deletions local/modules/Carousel/Carousel.php
Expand Up @@ -13,9 +13,18 @@
namespace Carousel;

use Propel\Runtime\Connection\ConnectionInterface;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Finder\Finder;
use Symfony\Component\Finder\SplFileInfo;
use Thelia\Install\Database;
use Thelia\Model\ConfigQuery;
use Thelia\Module\BaseModule;

/**
* Class Carousel
* @package Carousel
* @author Franck Allimant <franck@cqfdev.fr>
*/
class Carousel extends BaseModule
{
const DOMAIN_NAME = 'carousel';
Expand All @@ -25,7 +34,7 @@ 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'));
$database->insertSql(null, array(__DIR__ . '/Config/thelia.sql'));

$this->setConfigValue('is_initialized', true);
}
Expand All @@ -42,6 +51,39 @@ public function destroy(ConnectionInterface $con = null, $deleteModuleData = fal

public function getUploadDir()
{
return __DIR__ . DS . 'media' . DS . 'carousel';
$uploadDir = ConfigQuery::read('images_library_path');

if ($uploadDir === null) {
$uploadDir = THELIA_LOCAL_DIR . 'media' . DS . 'images';
} else {
$uploadDir = THELIA_ROOT . $uploadDir;
}

return $uploadDir . DS . Carousel::DOMAIN_NAME;
}

/**
* @param string $currentVersion
* @param string $newVersion
* @param ConnectionInterface $con
* @author Thomas Arnaud <tarnaud@openstudio.fr>
*/
public function update($currentVersion, $newVersion, ConnectionInterface $con = null)
{
$uploadDir = $this->getUploadDir();
$fileSystem = new Filesystem();

if (!file_exists($uploadDir)) {
$finder = new Finder();
$finder->files()->in(__DIR__ . DS . 'media' . DS . 'carousel');

$fileSystem->mkdir($uploadDir);

/** @var SplFileInfo $file */
foreach ($finder as $file) {
copy($file, $uploadDir . DS . $file->getRelativePathname());
}
$fileSystem->remove(__DIR__ . DS . 'media');
}
}
}
10 changes: 0 additions & 10 deletions local/modules/Carousel/Config/init.sql

This file was deleted.

10 changes: 8 additions & 2 deletions local/modules/Carousel/Config/module.xml
@@ -1,18 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<module>
<module xmlns="http://thelia.net/schema/dic/module"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://thelia.net/schema/dic/module http://thelia.net/schema/dic/module/module-2_1.xsd">
<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>
<languages>
<language>en_US</language>
<language>fr_FR</language>
</languages>
<version>0.9</version>
<author>
<name>Manuel Raynaud, Franck Allimant</name>
<email>manu@raynaud.io, franck@cqfdev.fr</email>
</author>
<type>classic</type>
<thelia>2.1.0</thelia>
<stability>beta</stability>
<stability>prod</stability>
</module>
61 changes: 0 additions & 61 deletions local/modules/Carousel/Config/sql/thelia.sql

This file was deleted.

9 changes: 3 additions & 6 deletions local/modules/Carousel/Config/thelia.sql
@@ -1,4 +1,3 @@

# 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;
Expand All @@ -7,9 +6,7 @@ SET FOREIGN_KEY_CHECKS = 0;
-- carousel
-- ---------------------------------------------------------------------

DROP TABLE IF EXISTS `carousel`;

CREATE TABLE `carousel`
CREATE TABLE IF NOT EXISTS `carousel`
(
`id` INTEGER NOT NULL AUTO_INCREMENT,
`file` VARCHAR(255),
Expand All @@ -24,9 +21,9 @@ CREATE TABLE `carousel`
-- carousel_i18n
-- ---------------------------------------------------------------------

DROP TABLE IF EXISTS `carousel_i18n`;

CREATE TABLE `carousel_i18n`

CREATE TABLE IF NOT EXISTS `carousel_i18n`
(
`id` INTEGER NOT NULL,
`locale` VARCHAR(5) DEFAULT 'en_US' NOT NULL,
Expand Down
2 changes: 0 additions & 2 deletions local/modules/Carousel/Controller/ConfigurationController.php
Expand Up @@ -111,8 +111,6 @@ public function updateAction()
return $response;
}

$request = $this->getRequest();

$form = $this->createForm('carousel.update');

$error_message = null;
Expand Down
1 change: 0 additions & 1 deletion local/modules/Carousel/Form/CarouselImageForm.php
Expand Up @@ -17,7 +17,6 @@
use Thelia\Core\Translation\Translator;
use Thelia\Form\BaseForm;


/**
* Class CarouselImageForm
* @package Carousel\Form
Expand Down
2 changes: 0 additions & 2 deletions local/modules/Carousel/Loop/CarouselLoop.php
Expand Up @@ -12,7 +12,6 @@

namespace Carousel\Loop;

use Carousel\Carousel;
use Carousel\Model\CarouselQuery;
use Propel\Runtime\ActiveQuery\Criteria;
use Thelia\Core\Event\Image\ImageEvent;
Expand Down Expand Up @@ -72,7 +71,6 @@ protected function getArgDefinitions()
*/
public function parseResults(LoopResult $loopResult)
{
$carousel = new Carousel();
/** @var \Carousel\Model\Carousel $carousel */
foreach ($loopResult->getResultDataCollection() as $carousel) {
$loopResultRow = new LoopResultRow($carousel);
Expand Down
Binary file not shown.
Binary file not shown.
6 changes: 3 additions & 3 deletions local/modules/Tinymce/Hook/HookManager.php
Expand Up @@ -21,11 +21,11 @@
* @package Tinymce\Hook
* @author Franck Allimant <franck@cqfdev.fr>
*/
class HookManager extends BaseHook {

class HookManager extends BaseHook
{
public function onJsWysiwyg(HookRenderEvent $event)
{
$content = $this->render("tinymce_init.tpl");
$event->add($content);
}
}
}