Merge branch 'master' of https://github.com/thelia/thelia
This commit is contained in:
60
core/lib/Thelia/Core/Event/GenerateRewrittenUrlEvent.php
Normal file
60
core/lib/Thelia/Core/Event/GenerateRewrittenUrlEvent.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program 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 General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event;
|
||||
|
||||
|
||||
/**
|
||||
* Class GenerateRewrittenUrlEvent
|
||||
* @package Thelia\Core\Event
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class GenerateRewrittenUrlEvent extends ActionEvent {
|
||||
|
||||
protected $object;
|
||||
protected $locale;
|
||||
|
||||
protected $url;
|
||||
|
||||
public function __construct($object, $locale)
|
||||
{
|
||||
$this->object;
|
||||
$this->locale;
|
||||
}
|
||||
|
||||
public function setUrl($url)
|
||||
{
|
||||
$this->url = $url;
|
||||
}
|
||||
|
||||
public function isRewritten()
|
||||
{
|
||||
return null !== $this->url;
|
||||
}
|
||||
|
||||
public function getUrl()
|
||||
{
|
||||
return $this->url;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -441,4 +441,9 @@ final class TheliaEvents
|
||||
*/
|
||||
const MAILTRANSPORTER_CONFIG = 'action.mailertransporter.config';
|
||||
|
||||
/**
|
||||
* sent when Thelia try to generate a rewriten url
|
||||
*/
|
||||
const GENERATE_REWRITTENURL = 'action.generate_rewritenurl';
|
||||
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ use Thelia\Core\Template\Smarty\SmartyPluginDescriptor;
|
||||
use Thelia\Core\Template\Smarty\AbstractSmartyPlugin;
|
||||
use Thelia\Tools\URL;
|
||||
use Thelia\Core\HttpFoundation\Request;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
|
||||
class UrlGenerator extends AbstractSmartyPlugin
|
||||
{
|
||||
@@ -47,11 +48,27 @@ class UrlGenerator extends AbstractSmartyPlugin
|
||||
public function generateUrlFunction($params, &$smarty)
|
||||
{
|
||||
// the path to process
|
||||
$path = $this->getParam($params, 'path');
|
||||
$path = $this->getParam($params, 'path', null);
|
||||
$file = $this->getParam($params, 'file', null);
|
||||
|
||||
if ($file !== null) {
|
||||
$path = $file;
|
||||
$mode = URL::PATH_TO_FILE;
|
||||
}
|
||||
else if ($path !== null) {
|
||||
$mode = URL::WITH_INDEX_PAGE;
|
||||
}
|
||||
else {
|
||||
throw \InvalidArgumentException(Translator::getInstance()->trans("Please specify either 'path' or 'file' parameter in {url} function."));
|
||||
}
|
||||
|
||||
$target = $this->getParam($params, 'target', null);
|
||||
|
||||
$url = URL::getInstance()->absoluteUrl($path, $this->getArgsFromParam($params, array('path', 'target')));
|
||||
$url = URL::getInstance()->absoluteUrl(
|
||||
$path,
|
||||
$this->getArgsFromParam($params, array('path', 'file', 'target')),
|
||||
$mode
|
||||
);
|
||||
|
||||
if ($target != null) $url .= '#'.$target;
|
||||
|
||||
|
||||
@@ -56,9 +56,15 @@ class ConfigQuery extends BaseConfigQuery {
|
||||
|
||||
public static function getPageNotFoundView()
|
||||
{
|
||||
return self::read("page_not_found_view", '404.html');
|
||||
return self::read("page_not_found_view", '404');
|
||||
}
|
||||
|
||||
public static function getPassedUrlView()
|
||||
{
|
||||
return self::read('passed_url_view', 'passed-url');
|
||||
}
|
||||
|
||||
|
||||
public static function getActiveTemplate()
|
||||
{
|
||||
return self::read('active-template', 'default');
|
||||
|
||||
@@ -200,6 +200,12 @@ class Product extends BaseProduct
|
||||
*/
|
||||
public function postDelete(ConnectionInterface $con = null)
|
||||
{
|
||||
RewritingUrlQuery::create()
|
||||
->filterByView($this->getRewrittenUrlViewName())
|
||||
->filterByViewId($this->getId())
|
||||
->update(array(
|
||||
"View" => ConfigQuery::getPassedUrlView()
|
||||
));
|
||||
$this->dispatchEvent(TheliaEvents::AFTER_DELETEPRODUCT, new ProductEvent($this));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
|
||||
namespace Thelia\Model\Tools;
|
||||
|
||||
use Thelia\Core\Event\GenerateRewrittenUrlEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Exception\UrlRewritingException;
|
||||
use Thelia\Model\RewritingUrlQuery;
|
||||
use Thelia\Model\RewritingUrl;
|
||||
@@ -61,7 +63,21 @@ trait UrlRewritingTrait {
|
||||
|
||||
$this->setLocale($locale);
|
||||
|
||||
$title = $this->getTitle() ?: $this->getRef();
|
||||
$generateEvent = new GenerateRewrittenUrlEvent($this, $locale);
|
||||
|
||||
$this->dispatchEvent(TheliaEvents::GENERATE_REWRITTENURL, $generateEvent);
|
||||
|
||||
|
||||
if($generateEvent->isRewritten())
|
||||
{
|
||||
return $generateEvent->getUrl();
|
||||
}
|
||||
|
||||
$title = $this->getTitle();
|
||||
|
||||
if(null == $title) {
|
||||
throw new \RuntimeException('Impossible to create an url if title is null');
|
||||
}
|
||||
// Replace all weird characters with dashes
|
||||
$string = preg_replace('/[^\w\-~_\.]+/u', '-', $title);
|
||||
|
||||
@@ -104,7 +120,7 @@ trait UrlRewritingTrait {
|
||||
->filterByViewLocale($locale)
|
||||
->filterByView($this->getRewrittenUrlViewName())
|
||||
->filterByViewId($this->getId())
|
||||
->filterByRedirected(0)
|
||||
->filterByRedirected(null)
|
||||
->findOne()
|
||||
;
|
||||
|
||||
|
||||
108
core/lib/Thelia/Tests/Rewriting/BaseRewritingObject.php
Normal file
108
core/lib/Thelia/Tests/Rewriting/BaseRewritingObject.php
Normal file
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program 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 General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Tests\Rewriting;
|
||||
|
||||
|
||||
/**
|
||||
* Class BaseRewritingObject
|
||||
* @package Thelia\Tests\Rewriting
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
abstract class BaseRewritingObject extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* @return mixed an instance of Product, Folder, Content or Category Model
|
||||
*/
|
||||
abstract function getObject();
|
||||
|
||||
/**
|
||||
* @covers Thelia\Model\Tools\UrlRewritingTrait::generateRewrittenUrl
|
||||
*/
|
||||
public function testSimpleFrenchRewrittenUrl()
|
||||
{
|
||||
$object = $this->getObject();
|
||||
$object->setVisible(1)
|
||||
->setPosition(1)
|
||||
->setLocale('fr_FR')
|
||||
->setTitle('Mon super titre en français')
|
||||
->save();
|
||||
|
||||
$this->assertRegExp('/^mon-super-titre-en-français(-[0-9]+)?\.html$/', $object->getRewrittenUrl('fr_FR'));
|
||||
|
||||
$rewrittenUrl = $object->generateRewrittenUrl('fr_FR');
|
||||
$this->assertNotNull($rewrittenUrl, "rewritten url can not be null");
|
||||
$this->assertRegExp('/^mon-super-titre-en-français(-[0-9]+)?\.html$/', $rewrittenUrl);
|
||||
//mon-super-titre-en-français-2.html
|
||||
|
||||
$object->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Thelia\Model\Tools\UrlRewritingTrait::generateRewrittenUrl
|
||||
*/
|
||||
public function testSimpleEnglishRewrittenUrl()
|
||||
{
|
||||
$object = $this->getObject();
|
||||
$object->setVisible(1)
|
||||
->setPosition(1)
|
||||
->setLocale('en_US')
|
||||
->setTitle('My english super Title')
|
||||
->save();
|
||||
|
||||
$this->assertRegExp('/^my-english-super-title(-[0-9]+)?\.html$/', $object->getRewrittenUrl('en_US'));
|
||||
|
||||
$rewrittenUrl = $object->generateRewrittenUrl('en_US');
|
||||
$this->assertNotNull($rewrittenUrl, "rewritten url can not be null");
|
||||
$this->assertRegExp('/^my-english-super-title(-[0-9]+)?\.html$/', $rewrittenUrl);
|
||||
|
||||
$object->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Thelia\Model\Tools\UrlRewritingTrait::generateRewrittenUrl
|
||||
* @expectedException \RuntimeException
|
||||
* @expectedExceptionMessage Impossible to create an url if title is null
|
||||
*/
|
||||
public function testRewrittenWithoutTitle()
|
||||
{
|
||||
$object = $this->getObject();
|
||||
$object->setVisible(1)
|
||||
->setPosition(1)
|
||||
->setLocale('en_US')
|
||||
->setDescription('My english super Description')
|
||||
->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Thelia\Model\Tools\UrlRewritingTrait::generateRewrittenUrl
|
||||
* @expectedException \RuntimeException
|
||||
*/
|
||||
public function testOnNotSavedObject()
|
||||
{
|
||||
$object = $this->getObject();
|
||||
|
||||
$object->generateRewrittenUrl('fr_FR');
|
||||
}
|
||||
}
|
||||
43
core/lib/Thelia/Tests/Rewriting/CategoryRewritingTest.php
Normal file
43
core/lib/Thelia/Tests/Rewriting/CategoryRewritingTest.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program 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 General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Tests\Rewriting;
|
||||
use Thelia\Model\Category;
|
||||
|
||||
|
||||
/**
|
||||
* Class CategoryRewritingTest
|
||||
* @package Thelia\Tests\Rewriting
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class CategoryRewritingTest extends BaseRewritingObject
|
||||
{
|
||||
|
||||
/**
|
||||
* @return \Thelia\Model\Category
|
||||
*/
|
||||
function getObject()
|
||||
{
|
||||
return new Category();
|
||||
}
|
||||
}
|
||||
43
core/lib/Thelia/Tests/Rewriting/ContentRewritingTest.php
Normal file
43
core/lib/Thelia/Tests/Rewriting/ContentRewritingTest.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program 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 General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Tests\Rewriting;
|
||||
use Thelia\Model\Content;
|
||||
|
||||
|
||||
/**
|
||||
* Class ContentRewritingTest
|
||||
* @package Thelia\Tests\Rewriting
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class ContentRewritingTest extends BaseRewritingObject
|
||||
{
|
||||
|
||||
/**
|
||||
* @return \Thelia\Model\Content
|
||||
*/
|
||||
function getObject()
|
||||
{
|
||||
return new Content();
|
||||
}
|
||||
}
|
||||
43
core/lib/Thelia/Tests/Rewriting/FolderRewritingTest.php
Normal file
43
core/lib/Thelia/Tests/Rewriting/FolderRewritingTest.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program 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 General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Tests\Rewriting;
|
||||
use Thelia\Model\Folder;
|
||||
|
||||
|
||||
/**
|
||||
* Class FolderRewritingTest
|
||||
* @package Thelia\Tests\Rewriting
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class FolderRewritingTest extends BaseRewritingObject
|
||||
{
|
||||
|
||||
/**
|
||||
* @return mixed an instance of Product, Folder, Content or Category Model
|
||||
*/
|
||||
function getObject()
|
||||
{
|
||||
return new Folder();
|
||||
}
|
||||
}
|
||||
@@ -31,59 +31,14 @@ use Thelia\Model\ProductQuery;
|
||||
* @package Thelia\Tests\Rewriting
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class ProductRewriteTest extends \PHPUnit_Framework_TestCase
|
||||
class ProductRewriteTest extends BaseRewritingObject
|
||||
{
|
||||
protected static $productId;
|
||||
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
$product = new Product();
|
||||
$product->setRef(sprintf("TestRewrittenProduct%s",uniqid()))
|
||||
->setPosition(1)
|
||||
->setVisible(1)
|
||||
->setLocale('en_US')
|
||||
->setTitle('My english super Title')
|
||||
->setLocale('fr_FR')
|
||||
->setTitle('Mon super titre en français')
|
||||
->save();
|
||||
|
||||
self::$productId = $product->getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Thelia\Model\Tools\UrlRewritingTrait::generateRewrittenUrl
|
||||
* @return mixed an instance of Product, Folder, Content or Category Model
|
||||
*/
|
||||
public function testFrenchRewrittenUrl()
|
||||
function getObject()
|
||||
{
|
||||
$product = ProductQuery::create()->findPk(self::$productId);
|
||||
|
||||
$rewrittenUrl = $product->generateRewrittenUrl('fr_FR');
|
||||
$this->assertNotNull($rewrittenUrl, "rewritten url can not be null");
|
||||
$this->assertRegExp('/^mon-super-titre-en-français(-[0-9]+)?\.html$/', $rewrittenUrl);
|
||||
//mon-super-titre-en-français-2.html
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Thelia\Model\Tools\UrlRewritingTrait::generateRewrittenUrl
|
||||
*/
|
||||
public function testEnglishRewrittenUrl()
|
||||
{
|
||||
$product = ProductQuery::create()->findPk(self::$productId);
|
||||
|
||||
$rewrittenUrl = $product->generateRewrittenUrl('en_US');
|
||||
$this->assertNotNull($rewrittenUrl, "rewritten url can not be null");
|
||||
$this->assertRegExp('/^my-english-super-title(-[0-9]+)?\.html$/', $rewrittenUrl);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Thelia\Model\Tools\UrlRewritingTrait::generateRewrittenUrl
|
||||
* @expectedException \RuntimeException
|
||||
* @expectedExceptionMessage Object product must be saved before generating url
|
||||
*/
|
||||
public function testOnNotSavedProduct()
|
||||
{
|
||||
$product = new Product();
|
||||
|
||||
$product->generateRewrittenUrl('fr_FR');
|
||||
return new Product();
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,8 @@ INSERT INTO `config` (`name`, `value`, `secured`, `hidden`, `created_at`, `updat
|
||||
('image_cache_dir_from_web_root', 'cache/images', 0, 0, NOW(), NOW()),
|
||||
('document_cache_dir_from_web_root', 'cache/documents', 0, 0, NOW(), NOW()),
|
||||
('currency_rate_update_url', 'http://www.ecb.int/stats/eurofxref/eurofxref-daily.xml', 0, 0, NOW(), NOW()),
|
||||
('page_not_found_view', '404.html', 0, 0, NOW(), NOW()),
|
||||
('page_not_found_view', '404', 0, 0, NOW(), NOW()),
|
||||
('passed_url_view', 'passed-url', 0, 0, NOW(), NOW()),
|
||||
('use_tax_free_amounts', 0, 0, 0, NOW(), NOW()),
|
||||
('process_assets', '1', 0, 0, NOW(), NOW()),
|
||||
('thelia_admin_remember_me_cookie_name', 'tarmcn', 0, 0, NOW(), NOW()),
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<div id="wrapper" class="container">
|
||||
|
||||
{module_include location='home_top'}
|
||||
|
||||
|
||||
<div class="col-md-12 general-block-decorator dashboard">
|
||||
|
||||
<div class="title title-without-tabs clearfix">
|
||||
@@ -17,8 +17,8 @@
|
||||
<button type="button" class="btn btn-default disabled"><span class="glyphicon glyphicon-calendar"></span></button>
|
||||
<button type="button" class="btn btn-default"><span class="glyphicon glyphicon-chevron-right"></span></button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="text-center clearfix">
|
||||
<div class="btn-group">
|
||||
<button type="button" class="btn btn-default active" data-toggle="jqplot" data-target="turnover"><span class="glyphicon glyphicon-euro"></span> {intl l="Turnover"}</button>
|
||||
@@ -26,11 +26,11 @@
|
||||
<button type="button" class="btn btn-success" data-toggle="jqplot" data-target="orders"><span class="glyphicon glyphicon-shopping-cart"></span> {intl l="Orders"}</button>
|
||||
<button type="button" class="btn btn-info" data-toggle="jqplot" data-target="first-orders"><span class="glyphicon glyphicon-thumbs-up"></span> {intl l="First orders"}</button>
|
||||
<button type="button" class="btn btn-danger" data-toggle="jqplot" data-target="aborted-orders"><span class="glyphicon glyphicon-thumbs-down"></span> {intl l="Aborted orders"}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr/>
|
||||
|
||||
|
||||
<div class="jqplot-content">
|
||||
<div id="jqplot"></div>
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
@@ -91,10 +91,10 @@
|
||||
<td>0</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="col-md-4">
|
||||
<div class="general-block-decorator">
|
||||
<div class="title title-without-tabs">{intl l="Sales statistics"}</div>
|
||||
@@ -138,7 +138,7 @@
|
||||
<td>25.00 €</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</table>
|
||||
</div>
|
||||
<div class="tab-pane fade" id="statmois">
|
||||
<table class="table table-striped">
|
||||
@@ -206,7 +206,7 @@
|
||||
<td>25.00 €</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -230,7 +230,7 @@
|
||||
<td><a href="" target="_blank">{intl l="Click here"}</a></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -245,7 +245,7 @@
|
||||
|
||||
{javascripts file='assets/js/jqplot/jquery.jqplot.min.js'}
|
||||
<script src="{$asset_url}"></script>
|
||||
|
||||
|
||||
{javascripts file='assets/js/jqplot/plugins/jqplot.highlighter.min.js'}
|
||||
<script type="text/javascript" src="{$asset_url}"></script>
|
||||
{/javascripts}
|
||||
@@ -259,19 +259,19 @@
|
||||
<script>
|
||||
|
||||
(function($, window, document){
|
||||
|
||||
$(function(){
|
||||
|
||||
$(function(){
|
||||
|
||||
var $elem = $('#jqplot');
|
||||
|
||||
var url = '/web/test_to_remove/admin-stats.json',
|
||||
var url = "{url file='/test_to_remove/admin-stats.json'}",
|
||||
series = [],
|
||||
seriesColors = [],
|
||||
ticks = [],
|
||||
days = 0,
|
||||
jqplot;
|
||||
|
||||
var options = {
|
||||
var options = {
|
||||
animate: true,
|
||||
axesDefaults: {
|
||||
tickOptions: { showMark: true, showGridline: true }
|
||||
@@ -288,13 +288,13 @@
|
||||
},
|
||||
seriesDefaults: {
|
||||
lineWidth: 3,
|
||||
shadow : false,
|
||||
shadow : false,
|
||||
markerOptions: { shadow : false, style: 'filledCircle', size: 12 }
|
||||
},
|
||||
grid: {
|
||||
grid: {
|
||||
background: '#FFF',
|
||||
shadow : false,
|
||||
borderColor : '#FFF'
|
||||
borderColor : '#FFF'
|
||||
},
|
||||
highlighter: {
|
||||
show: true,
|
||||
@@ -302,7 +302,7 @@
|
||||
tooltipLocation: 'n',
|
||||
tooltipContentEditor: function(str, seriesIndex, pointIndex, plot){
|
||||
|
||||
// Return axis value : data value
|
||||
// Return axis value : data value
|
||||
return ticks[pointIndex][1] + ': ' + plot.data[seriesIndex][pointIndex][1];
|
||||
}
|
||||
}
|
||||
@@ -310,26 +310,26 @@
|
||||
|
||||
// Get datas Json
|
||||
$.getJSON(url)
|
||||
.done(function(data) {
|
||||
.done(function(data) {
|
||||
|
||||
// Init series datas and colors
|
||||
initJqplotDatas(series, seriesColors, options, data);
|
||||
initJqplotDatas(series, seriesColors, options, data);
|
||||
|
||||
// Add days to xaxis
|
||||
for(var i = 1; i < (days+1); i++){
|
||||
ticks.push([i-1, i]);
|
||||
}
|
||||
|
||||
|
||||
// Start jqplot
|
||||
var elementId = $elem.attr('id');
|
||||
jqplot = $.jqplot(elementId, series, options);
|
||||
|
||||
$('[data-toggle="jqplot"]').each(function(){
|
||||
$('[data-toggle="jqplot"]').each(function(){
|
||||
|
||||
$(this).click(function(){
|
||||
|
||||
if($('[data-toggle="jqplot-serie"].active').length > 1 || !$(this).hasClass('active')){
|
||||
|
||||
|
||||
// Active button and jqplot-serie management
|
||||
$(this).toggleClass('active');
|
||||
|
||||
@@ -341,16 +341,16 @@
|
||||
seriesColors = [];
|
||||
|
||||
// Init series datas and colors
|
||||
initJqplotDatas(series, seriesColors, options, data);
|
||||
initJqplotDatas(series, seriesColors, options, data);
|
||||
|
||||
// Restart jqplot
|
||||
jqplot.destroy();
|
||||
jqplot = $.jqplot(elementId, series, options);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
$(window).bind('resize', function(event, ui) {
|
||||
jqplot.replot( { resetAxes: true } );
|
||||
@@ -359,15 +359,15 @@
|
||||
})
|
||||
.fail(function() {
|
||||
$elem.append('<div class="alert alert-danger">An error occurred while reading from JSON file</div>');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
function initJqplotDatas(series, seriesColors, options, json){
|
||||
$('[data-toggle="jqplot-serie"].active').each(function(i){
|
||||
var position = $(this).index() - 1;
|
||||
var position = $(this).index() - 1;
|
||||
series.push(json.series[position].datas);
|
||||
seriesColors.push(json.series[position].color);
|
||||
});
|
||||
seriesColors.push(json.series[position].color);
|
||||
});
|
||||
|
||||
// Number of days to display ( = datas.length in one serie)
|
||||
days = json.series[0].datas.length;
|
||||
@@ -380,7 +380,7 @@
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
}(window.jQuery, window, document));
|
||||
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user