Merge branch 'master' of https://github.com/thelia/thelia into upload_management

# By Manuel Raynaud (60) and others
# Via Manuel Raynaud (16) and others
* 'master' of https://github.com/thelia/thelia: (113 commits)
  implement process for changing folder position
  allow possibility to change folder visibility
  allow to create folder
  add dispatcher before/after for folder crud management
  icreate folder delete event
  process folder update action
  create folder events
  display info in folders edition template
  push model
  re-add home link in menu
  comment dev menu in layout
  translate some missing string
  fixes order integration
  order process
  change some informations in layou
  fix query in Thelia\Model\Folder::countAllContents
  allow to order products on category page
  Add default language & editing language default field
  Vertical align middle tables
  Fixed translations
  ...

Conflicts:
	core/lib/Thelia/Tools/I18n.php
	templates/admin/default/category-edit.html
This commit is contained in:
gmorel
2013-09-21 14:44:57 +02:00
655 changed files with 38814 additions and 5319 deletions

View File

@@ -23,6 +23,8 @@
namespace Thelia\Tools;
use Propel\Runtime\ActiveQuery\ModelCriteria;
use Propel\Runtime\ActiveRecord\ActiveRecordInterface;
use Thelia\Model\Lang;
/**
@@ -55,4 +57,38 @@ class I18n
return \DateTime::createFromFormat($currentDateFormat, $date);
}
public static function forceI18nRetrieving($askedLocale, $modelName, $id, $needed = array('Title'))
{
$i18nQueryClass = sprintf("\\Thelia\\Model\\%sI18nQuery", $modelName);
$i18nClass = sprintf("\\Thelia\\Model\\%sI18n", $modelName);
/* get customer language translation */
$i18n = $i18nQueryClass::create()
->filterById($id)
->filterByLocale(
$askedLocale
)->findOne();
/* or default translation */
if(null === $i18n) {
$i18n = $i18nQueryClass::create()
->filterById($id)
->filterByLocale(
Lang::getDefaultLanguage()->getLocale()
)->findOne();
}
if(null === $i18n) { // @todo something else ?
$i18n = new $i18nClass();;
$i18n->setId($id);
foreach($needed as $need) {
$method = sprintf('set%s', $need);
if(method_exists($i18n, $method)) {
$i18n->$method('DEFAULT ' . strtoupper($need));
} else {
// @todo throw sg ?
}
}
}
return $i18n;
}
}

44
core/lib/Thelia/Tools/Image.php Executable file
View File

@@ -0,0 +1,44 @@
<?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\Tools;
class Image
{
static public function isImage($filePath, $allowedImageTypes = null)
{
$imageFile = getimagesize($filePath);
$imageType = $imageFile[2];
if(!is_array($allowedImageTypes) && $imageType != IMAGETYPE_UNKNOWN) {
return true;
}
if(in_array($imageType , $allowedImageTypes))
{
return true;
}
return false;
}
}