diff --git a/contao/assets/style.css b/contao/assets/style.css
index fa90c77..c93e004 100644
--- a/contao/assets/style.css
+++ b/contao/assets/style.css
@@ -1,4 +1,4 @@
-/* additional_metafields (Martin Kozianka 2013-2014 )
+/* additional_metafields (Martin Kozianka 2013-2015 )
---------------------------------------------------------------------------------*/
.tl_metawizard_plus label.tl_metafields {
diff --git a/contao/classes/MetafieldsHelper.php b/contao/classes/MetafieldsHelper.php
index 91e56ae..ac15e67 100644
--- a/contao/classes/MetafieldsHelper.php
+++ b/contao/classes/MetafieldsHelper.php
@@ -2,13 +2,13 @@
/**
* Contao Open Source CMS
- * Copyright (C) 2005-2014 Leo Feyer
+ * Copyright (C) 2005-2015 Leo Feyer
*
*
* PHP version 5
- * @copyright Martin Kozianka 2013-2014
+ * @copyright Martin Kozianka 2013-2015
* @author Martin Kozianka
- * @package additional_metafields
+ * @package contao-metafields
* @license LGPL
* @filesource
*/
@@ -20,12 +20,13 @@
* Class MetafieldsHelper
*
* Provides some helper functions
- * @copyright Martin Kozianka 2013-2014
+ * @copyright Martin Kozianka 2013-2015
* @author Martin Kozianka
- * @package additional_metafields
+ * @package contao-metafields
*/
-class MetafieldsHelper extends \Frontend {
+class MetafieldsHelper extends \Frontend
+{
const TYPE_FOLDER = '__TYPE_FOLDER__';
@@ -42,41 +43,48 @@ class MetafieldsHelper extends \Frontend {
*
* @return MetafieldsHelper The MetafieldsHelper object
*/
- static public function getInstance() {
-
- if (static::$instance === null) {
+ static public function getInstance()
+ {
+ if (static::$instance === null)
+ {
static::$instance = new static();
}
return static::$instance;
}
- public function getFields($activeRecord) {
+ public function getFields($activeRecord)
+ {
$arrMetafields = $this->loadFields();
$strType = ($activeRecord->type !== 'folder') ? $activeRecord->extension : self::TYPE_FOLDER;
- if (!array_key_exists($strType, $arrMetafields) ) {
+ if (!array_key_exists($strType, $arrMetafields) )
+ {
return null;
}
return $arrMetafields[$strType];
}
- public function injectMetaData($objRow, $strBuffer, $objElement) {
+ public function injectMetaData($objRow, $strBuffer, $objElement)
+ {
global $objPage;
- if (!in_array($objRow->type, array('text', 'image', 'gallery', 'accordionSingle'))) {
+ if (!in_array($objRow->type, array('text', 'image', 'gallery', 'accordionSingle')))
+ {
return $strBuffer;
}
- if ($objRow->type === 'gallery') {
+ if ($objRow->type === 'gallery')
+ {
$objElement->__set('metadata', $this->getMultiMetaData($objRow->multiSRC));
$strBuffer = $objElement->generate();
}
if ($objRow->type === 'image'
|| ($objRow->type === 'text' && $objRow->addImage === '1')
- || ($objRow->type === 'accordionSingle' && $objRow->addImage === '1')) {
+ || ($objRow->type === 'accordionSingle' && $objRow->addImage === '1'))
+ {
$objFile = \FilesModel::findByUuid($objRow->singleSRC);
$objElement->__set('singleSRC', $objFile->uuid);
$objElement->__set('metadata', $this->getMetaData($objFile->meta, $objPage->language));
@@ -87,14 +95,16 @@ public function injectMetaData($objRow, $strBuffer, $objElement) {
return $strBuffer;
}
- public function injectMetaDataArticleImage(&$objTmpl, $row, $obj) {
+ public function injectMetaDataArticleImage(&$objTmpl, $row, $obj)
+ {
global $objPage;
$objFile = \FilesModel::findByUuid($row['singleSRC']);
$objTmpl->metadata = $this->getMetaData($objFile->meta, $objPage->language);
}
- private function getMultiMetaData($multiSRC) {
+ private function getMultiMetaData($multiSRC)
+ {
global $objPage;
$images = array();
@@ -103,29 +113,38 @@ private function getMultiMetaData($multiSRC) {
if($objFiles !== null) {
while ($objFiles->next()) {
// Continue if the files has been processed or does not exist
- if (isset($images[$objFiles->path]) || !file_exists(TL_ROOT . '/' . $objFiles->path)) {
+ if (isset($images[$objFiles->path]) || !file_exists(TL_ROOT . '/' . $objFiles->path))
+ {
continue;
}
// Single files
- if ($objFiles->type == 'file') {
+ if ($objFiles->type == 'file')
+ {
$objFile = new \File($objFiles->path, true);
- if (!$objFile->isGdImage) {
+ if (!$objFile->isGdImage)
+ {
continue;
}
$images[$objFiles->path] = $this->getMetaData($objFiles->meta, $objPage->language);
- } else {
+ }
+ else
+ {
$objSubfiles = \FilesModel::findByPid($objFiles->uuid);
- if ($objSubfiles === null) {
+ if ($objSubfiles === null)
+ {
continue;
}
- while ($objSubfiles->next()) {
+ while ($objSubfiles->next())
+ {
// Skip subfolders
- if ($objSubfiles->type == 'folder') {
+ if ($objSubfiles->type == 'folder')
+ {
continue;
}
$objFile = new \File($objSubfiles->path, true);
- if (!$objFile->isGdImage) {
+ if (!$objFile->isGdImage)
+ {
continue;
}
@@ -138,14 +157,19 @@ private function getMultiMetaData($multiSRC) {
return $images;
}
- public static function embedData(&$body, $metadata) {
- if (!is_array($metadata)) {
+ public static function embedData(&$body, $metadata)
+ {
+ if (!is_array($metadata))
+ {
return false;
}
- foreach($body as $class => $row) {
- foreach($row as $key => $col) {
- if (array_key_exists($col->singleSRC, $metadata) && sizeof($metadata[$col->singleSRC]) > 0) {
+ foreach($body as $class => $row)
+ {
+ foreach($row as $key => $col)
+ {
+ if (array_key_exists($col->singleSRC, $metadata) && sizeof($metadata[$col->singleSRC]) > 0)
+ {
$body[$class][$key]->metadata = $metadata[$col->singleSRC];
}
}
@@ -153,32 +177,40 @@ public static function embedData(&$body, $metadata) {
return true;
}
- private function loadFields() {
- if($this->arrMetafields !== null) {
+ private function loadFields()
+ {
+ if($this->arrMetafields !== null)
+ {
return $this->arrMetafields;
}
$this->arrMetafields = array();
// Todo label translation
$collection = MetafieldsModel::findAll();
- if ($collection === null) {
+ if ($collection === null)
+ {
return $this->arrMetafields;
}
- foreach($collection as $objField) {
+ foreach($collection as $objField)
+ {
$extensions = array_map('trim', explode(',', $objField->extensions));
$alias = $objField->alias;
$label = $objField->label;
$folderAttr = ($objField->folder === '1');
- foreach($extensions as $ext) {
- if (!is_array($this->arrMetafields[$ext])) {
+ foreach($extensions as $ext)
+ {
+ if (!is_array($this->arrMetafields[$ext]))
+ {
$this->arrMetafields[$ext] = array();
}
$this->arrMetafields[$ext][$alias] = $label;
- if ($folderAttr) {
- if (!is_array($this->arrMetafields[static::TYPE_FOLDER])) {
+ if ($folderAttr)
+ {
+ if (!is_array($this->arrMetafields[static::TYPE_FOLDER]))
+ {
$this->arrMetafields[static::TYPE_FOLDER] = array();
}
$this->arrMetafields[static::TYPE_FOLDER][$alias] = $label;
diff --git a/contao/config/autoload.php b/contao/config/autoload.php
index 3871f10..f0f7ae6 100644
--- a/contao/config/autoload.php
+++ b/contao/config/autoload.php
@@ -2,22 +2,22 @@
/**
* Contao Open Source CMS
- * Copyright (C) 2005-2014 Leo Feyer
+ * Copyright (C) 2005-2015 Leo Feyer
*
*
* PHP version 5
- * @copyright Martin Kozianka 2013-2014
+ * @copyright Martin Kozianka 2013-2015
* @author Martin Kozianka
- * @package additional_metafields
+ * @package contao-metafields
* @license LGPL
* @filesource
*/
ClassLoader::addNamespace('AdditionalMetafields');
-ClassLoader::addClasses(array(
- 'AdditionalMetafields\MetafieldsHelper' => 'system/modules/metafields/classes/MetafieldsHelper.php',
- 'AdditionalMetafields\MetaWizardPlus' => 'system/modules/metafields/widgets/MetaWizardPlus.php',
- 'AdditionalMetafields\MetafieldsModel' => 'system/modules/metafields/models/MetafieldsModel.php',
-));
+ClassLoader::addClasses([
+ 'AdditionalMetafields\MetafieldsHelper' => 'system/modules/metafields/classes/MetafieldsHelper.php',
+ 'AdditionalMetafields\MetaWizardPlus' => 'system/modules/metafields/widgets/MetaWizardPlus.php',
+ 'AdditionalMetafields\MetafieldsModel' => 'system/modules/metafields/models/MetafieldsModel.php',
+]);
diff --git a/contao/config/config.php b/contao/config/config.php
index 4789fef..4933aca 100644
--- a/contao/config/config.php
+++ b/contao/config/config.php
@@ -2,13 +2,13 @@
/**
* Contao Open Source CMS
- * Copyright (C) 2005-2014 Leo Feyer
+ * Copyright (C) 2005-2015 Leo Feyer
*
*
* PHP version 5
- * @copyright Martin Kozianka 2013-2014
+ * @copyright Martin Kozianka 2013-2015
* @author Martin Kozianka
- * @package additional_metafields
+ * @package contao-metafields
* @license LGPL
* @filesource
*/
diff --git a/contao/config/runonce.php b/contao/config/runonce.php
index 048866e..22623f1 100644
--- a/contao/config/runonce.php
+++ b/contao/config/runonce.php
@@ -2,13 +2,13 @@
/**
* Contao Open Source CMS
- * Copyright (C) 2005-2014 Leo Feyer
+ * Copyright (C) 2005-2015 Leo Feyer
*
*
* PHP version 5
- * @copyright Martin Kozianka 2013-2014
+ * @copyright Martin Kozianka 2013-2015
* @author Martin Kozianka
- * @package additional_metafields
+ * @package contao-metafields
* @license LGPL
* @filesource
*/
diff --git a/contao/dca/tl_files.php b/contao/dca/tl_files.php
index 913c56a..42b8465 100644
--- a/contao/dca/tl_files.php
+++ b/contao/dca/tl_files.php
@@ -2,13 +2,13 @@
/**
* Contao Open Source CMS
- * Copyright (C) 2005-2014 Leo Feyer
+ * Copyright (C) 2005-2015 Leo Feyer
*
*
* PHP version 5
- * @copyright Martin Kozianka 2013-2014
+ * @copyright Martin Kozianka 2013-2015
* @author Martin Kozianka
- * @package additional_metafields
+ * @package contao-metafields
* @license LGPL
* @filesource
*/
diff --git a/contao/dca/tl_metafields.php b/contao/dca/tl_metafields.php
index 0fd29c0..8eccdf0 100644
--- a/contao/dca/tl_metafields.php
+++ b/contao/dca/tl_metafields.php
@@ -2,150 +2,129 @@
/**
* Contao Open Source CMS
- * Copyright (C) 2005-2014 Leo Feyer
+ * Copyright (C) 2005-2015 Leo Feyer
*
*
* PHP version 5
- * @copyright Martin Kozianka 2013-2014
+ * @copyright Martin Kozianka 2013-2015
* @author Martin Kozianka
- * @package additional_metafields
+ * @package contao-metafields
* @license LGPL
* @filesource
*/
-$GLOBALS['TL_DCA']['tl_metafields'] = array(
+$GLOBALS['TL_DCA']['tl_metafields'] = [
// Config
- 'config' => array
- (
+ 'config' => [
'dataContainer' => 'Table',
'enableVersioning' => true,
- 'sql' => array(
- 'keys' => array('id' => 'primary')
- )
- ),
+ 'sql' => ['keys' => ['id' => 'primary']]
+ ],
// List
- 'list' => array
- (
- 'sorting' => array
- (
- 'fields' => array('label'),
+ 'list' => [
+ 'sorting' => [
+ 'fields' => ['label'],
'flag' => 1,
- ),
- 'label' => array
- (
- 'fields' => array('label', 'alias', 'extensions', 'folder'),
+ ],
+ 'label' => [
+ 'fields' => ['label', 'alias', 'extensions', 'folder'],
'showColumns' => true,
- ),
- 'global_operations' => array
- (
- 'all' => array
- (
+ ],
+ 'global_operations' => [
+ 'all' => [
'label' => &$GLOBALS['TL_LANG']['MSC']['all'],
'href' => 'act=select',
'class' => 'header_edit_all',
'attributes' => 'onclick="Backend.getScrollOffset();"'
- )
- ),
- 'operations' => array
- (
- 'edit' => array
- (
+ ]
+ ],
+ 'operations' => [
+ 'edit' => [
'label' => &$GLOBALS['TL_LANG']['tl_metafields']['edit'],
'href' => 'act=edit',
'icon' => 'edit.gif'
- ),
- 'delete' => array
- (
+ ],
+ 'delete' => [
'label' => &$GLOBALS['TL_LANG']['tl_metafields']['delete'],
'href' => 'act=delete',
'icon' => 'delete.gif',
'attributes' => 'onclick="if (!confirm(\'' . $GLOBALS['TL_LANG']['MSC']['deleteConfirm'] . '\')) return false; Backend.getScrollOffset();"'
- )
- )
- ),
+ ]
+ ]
+ ],
// Palettes
- 'palettes' => array
- (
+ 'palettes' => [
'default' => '{metafields_legend}, alias, label, extensions, folder;',
- ),
+ ],
// Fields
- 'fields' => array
- (
- 'id' => array
- (
- 'label' => array('ID'),
+ 'fields' => [
+ 'id' => [
+ 'label' => ['ID'],
'search' => false,
'sql' => "int(10) unsigned NOT NULL auto_increment"
- ),
- 'tstamp' => array
- (
- 'label' => array('TSTAMP'),
+ ],
+ 'tstamp' => [
+ 'label' => ['TSTAMP'],
'search' => false,
'sql' => "int(10) unsigned NOT NULL default '0'",
- ),
- 'label' => array
- (
+ ],
+ 'label' => [
'label' => &$GLOBALS['TL_LANG']['tl_metafields']['label'],
'exclude' => true,
'flag' => 1,
'inputType' => 'text',
- 'eval' => array('mandatory'=>true, 'tl_class' => 'w50'),
+ 'eval' => ['mandatory'=>true, 'tl_class' => 'w50'],
'sql' => "varchar(255) NOT NULL default ''",
- ),
- 'alias' => array
- (
+ ],
+ 'alias' => [
'label' => &$GLOBALS['TL_LANG']['tl_metafields']['alias'],
'exclude' => true,
'flag' => 1,
'inputType' => 'text',
- 'eval' => array('doNotCopy'=>true, 'maxlength'=>128, 'tl_class'=>'w50'),
- 'save_callback' => array
- (
- array('tl_metafields', 'generateAlias')
- ),
+ 'eval' => ['doNotCopy'=>true, 'maxlength'=>128, 'tl_class'=>'w50'],
+ 'save_callback' => [['tl_metafields', 'generateAlias']],
'sql' => "varchar(128) COLLATE utf8_bin NOT NULL default ''"
- ),
- 'extensions' => array
- (
+ ],
+ 'extensions' => [
'label' => &$GLOBALS['TL_LANG']['tl_metafields']['extensions'],
'exclude' => true,
'flag' => 1,
'inputType' => 'text',
- 'eval' => array('mandatory'=>false, 'tl_class' => 'w50'),
+ 'eval' => ['mandatory'=>false, 'tl_class' => 'w50'],
'sql' => "varchar(255) NOT NULL default ''",
- ),
- 'folder' => array
- (
+ ],
+ 'folder' => [
'label' => &$GLOBALS['TL_LANG']['tl_metafields']['folder'],
'exclude' => true,
'flag' => 1,
'inputType' => 'checkbox',
- 'eval' => array('mandatory'=>false, 'tl_class' => 'w50 m12'),
+ 'eval' => ['mandatory'=>false, 'tl_class' => 'w50 m12'],
'sql' => "char(1) NOT NULL default ''",
- ),
-
- )
-);
+ ],
+ ]
+];
/**
* Class tl_metafields
*
* Provide miscellaneous methods that are used by the data configuration array.
- * @copyright Martin Kozianka 2013-2014
+ * @copyright Martin Kozianka 2013-2015
* @author Martin Kozianka
- * @package additional_metafields
+ * @package contao-metafields
*/
-class tl_metafields extends Backend {
-
- public function generateAlias($varValue, DataContainer $dc) {
+class tl_metafields extends Backend
+{
+ public function generateAlias($varValue, DataContainer $dc)
+ {
// Generate an alias if there is none
- if ($varValue == '') {
+ if ($varValue == '')
+ {
$varValue = standardize(String::restoreBasicEntities($dc->activeRecord->label));
}
@@ -153,12 +132,12 @@ public function generateAlias($varValue, DataContainer $dc) {
->execute($dc->id, $varValue);
// Check whether the alias exists
- if ($objAlias->numRows > 1) {
+ if ($objAlias->numRows > 1)
+ {
throw new Exception(sprintf($GLOBALS['TL_LANG']['ERR']['aliasExists'], $varValue));
}
return $varValue;
}
-
}
diff --git a/contao/languages/de/default.php b/contao/languages/de/default.php
index fc0a7e9..7663181 100644
--- a/contao/languages/de/default.php
+++ b/contao/languages/de/default.php
@@ -1,4 +1,4 @@
+ * @copyright Martin Kozianka 2013-2015
* @author Martin Kozianka
- * @package additional_metafields
+ * @package contao-metafields
* @license LGPL
* @filesource
*/
@@ -18,11 +18,11 @@
* Class MetafieldsModel
*
* Provides some helper functions
- * @copyright Martin Kozianka 2013-2014
+ * @copyright Martin Kozianka 2013-2015
* @author Martin Kozianka
- * @package additional_metafields
+ * @package contao-metafields
*/
-class MetafieldsModel extends \Model {
-
+class MetafieldsModel extends \Model
+{
protected static $strTable = 'tl_metafields';
}
\ No newline at end of file
diff --git a/contao/widgets/MetaWizardPlus.php b/contao/widgets/MetaWizardPlus.php
index 6d853c4..ac73d7c 100644
--- a/contao/widgets/MetaWizardPlus.php
+++ b/contao/widgets/MetaWizardPlus.php
@@ -2,13 +2,13 @@
/**
* Contao Open Source CMS
- * Copyright (C) 2005-2014 Leo Feyer
+ * Copyright (C) 2005-2015 Leo Feyer
*
*
* PHP version 5
- * @copyright Martin Kozianka 2013-2014
+ * @copyright Martin Kozianka 2013-2015
* @author Martin Kozianka
- * @package additional_metafields
+ * @package contao-metafields
* @license LGPL
* @filesource
*/
@@ -18,11 +18,12 @@
* Class MetaWizardPlus
*
* Extends the MetaWizard class
- * @copyright Martin Kozianka 2013-2014
+ * @copyright Martin Kozianka 2013-2015
* @author Martin Kozianka
- * @package additional_metafields
+ * @package contao-metafields
*/
-class MetaWizardPlus extends \MetaWizard {
+class MetaWizardPlus extends \MetaWizard
+{
/**
* Generate the widget and return it as string
* @return string