-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
132 additions
and
44 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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
<?php | ||
/******************************************************************* | ||
* (c) 2017 Stephan Preßl, www.prestep.at <[email protected]> | ||
* (c) 2018 Stephan Preßl, www.prestep.at <[email protected]> | ||
* All rights reserved | ||
* Modification, distribution or any other action on or with | ||
* this file is permitted unless explicitly granted by IIDO | ||
|
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 |
---|---|---|
@@ -1,13 +1,10 @@ | ||
<?php | ||
/******************************************************************* | ||
* | ||
* (c) 2017 Stephan Preßl, www.prestep.at <[email protected]> | ||
* (c) 2018 Stephan Preßl, www.prestep.at <[email protected]> | ||
* All rights reserved | ||
* | ||
* Modification, distribution or any other action on or with | ||
* this file is permitted unless explicitly granted by IIDO | ||
* www.iido.at <[email protected]> | ||
* | ||
*******************************************************************/ | ||
|
||
namespace IIDO\BasicBundle; | ||
|
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 |
---|---|---|
@@ -1,13 +1,10 @@ | ||
<?php | ||
/******************************************************************* | ||
* | ||
* (c) 2017 Stephan Preßl, www.prestep.at <[email protected]> | ||
* (c) 2018 Stephan Preßl, www.prestep.at <[email protected]> | ||
* All rights reserved | ||
* | ||
* Modification, distribution or any other action on or with | ||
* this file is permitted unless explicitly granted by IIDO | ||
* www.iido.at <[email protected]> | ||
* | ||
*******************************************************************/ | ||
|
||
namespace IIDO\BasicBundle; | ||
|
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 |
---|---|---|
@@ -1,13 +1,10 @@ | ||
<?php | ||
/******************************************************************* | ||
* | ||
* (c) 2017 Stephan Preßl, www.prestep.at <[email protected]> | ||
* (c) 2018 Stephan Preßl, www.prestep.at <[email protected]> | ||
* All rights reserved | ||
* | ||
* Modification, distribution or any other action on or with | ||
* this file is permitted unless explicitly granted by IIDO | ||
* www.iido.at <[email protected]> | ||
* | ||
*******************************************************************/ | ||
|
||
namespace IIDO\BasicBundle\ContaoManager; | ||
|
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
<?php | ||
/******************************************************************* | ||
* (c) 2017 Stephan Preßl, www.prestep.at <[email protected]> | ||
* (c) 2018 Stephan Preßl, www.prestep.at <[email protected]> | ||
* All rights reserved | ||
* Modification, distribution or any other action on or with | ||
* this file is permitted unless explicitly granted by IIDO | ||
|
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 |
---|---|---|
@@ -1,20 +1,21 @@ | ||
<?php | ||
/****************************************************************** | ||
* | ||
* (c) 2015 Stephan Preßl <[email protected]> | ||
/******************************************************************* | ||
* (c) 2018 Stephan Preßl, www.prestep.at <[email protected]> | ||
* All rights reserved | ||
* | ||
* Modification, distribution or any other action on or with | ||
* this file is permitted unless explicitly granted by IIDO | ||
* www.iido.at <[email protected]> | ||
* | ||
******************************************************************/ | ||
*******************************************************************/ | ||
|
||
namespace IIDO\BasicBundle\Helper; | ||
|
||
|
||
use IIDO\BasicBundle\Table\AllTables; | ||
|
||
|
||
/** | ||
* Class Helper | ||
* Class DCA Helper | ||
* | ||
* @package IIDO\BasicBundle | ||
*/ | ||
class DcaHelper extends \Frontend | ||
|
@@ -63,6 +64,10 @@ public static function addField($fieldName, $fieldType, $strTable, $eval = array | |
// self::addTextField($fieldName, $strTable, $eval, $classes, $replaceClasses, $langTable, $defaultConfig); | ||
break; | ||
|
||
case "alias": | ||
self::addAliasField($fieldName, $strTable, $eval, $classes, $replaceClasses, $langTable); | ||
break; | ||
|
||
case "color": | ||
case "colorfield": | ||
self::addColorField($fieldName, $strTable, $eval, $classes, $replaceClasses, $langTable); | ||
|
@@ -777,6 +782,43 @@ public static function addUrlField($fieldName, $strTable, $eval = array(), $clas | |
|
||
|
||
|
||
public static function addAliasField($fieldName, $strTable, $eval = array(), $classes = '', $replaceClasses = false, $langTable = '') | ||
{ | ||
if( strlen($langTable) ) | ||
{ | ||
\Controller::loadLanguageFile( $langTable ); | ||
} | ||
|
||
$defaultEval = array | ||
( | ||
'rgxp' => 'alias', | ||
'doNotCopy' => true, | ||
'maxlength' => 128, | ||
'tl_class' => ($replaceClasses ? $classes : 'w50 clr' . (strlen($classes) ? ' ' . $classes : '')) | ||
); | ||
|
||
if( count($eval) ) | ||
{ | ||
$defaultEval = array_merge($defaultEval, $eval); | ||
} | ||
|
||
$GLOBALS['TL_DCA'][ $strTable ]['fields'][ $fieldName ] = array | ||
( | ||
'label' => &$GLOBALS['TL_LANG']['tl_article']['alias'], | ||
'exclude' => true, | ||
'inputType' => 'text', | ||
'search' => true, | ||
'eval' => $defaultEval, | ||
'save_callback' => array | ||
( | ||
array(AllTables::class, 'generateAlias') | ||
), | ||
'sql' => "varchar(" . $defaultEval['maxlength']?:128 . ") COLLATE utf8mb4_bin NOT NULL default ''" | ||
); | ||
} | ||
|
||
|
||
|
||
public static function addProtectedFieldsToTable( $strTable, $toPalette = '', $replaceLegend = '', $replacePosition = 'after' ) | ||
{ | ||
\Controller::loadLanguageFile( $strTable ); | ||
|
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 |
---|---|---|
@@ -1,13 +1,10 @@ | ||
<?php | ||
/******************************************************************* | ||
* | ||
* (c) 2017 Stephan Preßl, www.prestep.at <[email protected]> | ||
* (c) 2018 Stephan Preßl, www.prestep.at <[email protected]> | ||
* All rights reserved | ||
* | ||
* Modification, distribution or any other action on or with | ||
* this file is permitted unless explicitly granted by IIDO | ||
* www.iido.at <[email protected]> | ||
* | ||
*******************************************************************/ | ||
|
||
namespace IIDO\BasicBundle; | ||
|
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
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
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 |
---|---|---|
@@ -1,13 +1,10 @@ | ||
<?php | ||
/******************************************************************* | ||
* | ||
* (c) 2017 Stephan Preßl, www.prestep.at <[email protected]> | ||
* (c) 2018 Stephan Preßl, www.prestep.at <[email protected]> | ||
* All rights reserved | ||
* | ||
* Modification, distribution or any other action on or with | ||
* this file is permitted unless explicitly granted by IIDO | ||
* www.iido.at <[email protected]> | ||
* | ||
*******************************************************************/ | ||
|
||
namespace IIDO\BasicBundle\Table; | ||
|
@@ -199,4 +196,66 @@ public function rewFilePicker(\DataContainer $dc) | |
{ | ||
return ' <a href="contao/file.php?do='.\Input::get('do').'&table='.$dc->table.'&field='.preg_replace('/_row[0-9]*_/i', '__', $dc->field).'&value='.$dc->value.'" title="'.specialchars(str_replace("'", "\\'", $GLOBALS['TL_LANG']['MSC']['filepicker'])).'" onclick="Backend.getScrollOffset();Backend.openModalSelector({\'width\':765,\'title\':\''.specialchars($GLOBALS['TL_LANG']['MOD']['files'][0]).'\',\'url\':this.href,\'id\':\''.$dc->field.'\',\'tag\':\'ctrl_'.$dc->field . ((\Input::get('act') == 'editAll') ? '_' . $dc->id : '').'\',\'self\':this});return false">' . \Image::getHtml('pickfile.gif', $GLOBALS['TL_LANG']['MSC']['filepicker'], 'style="vertical-align:top;cursor:pointer"') . '</a>'; | ||
} | ||
|
||
|
||
|
||
/** | ||
* Auto-generate an article alias if it has not been set yet | ||
* | ||
* @param mixed $varValue | ||
* @param \DataContainer $dc | ||
* | ||
* @return string | ||
* | ||
* @throws \Exception | ||
*/ | ||
public function generateAlias($varValue, \DataContainer $dc) | ||
{ | ||
echo "<pre>"; print_r( $dc ); exit; | ||
$prefix = 'article-'; | ||
$strTable = ''; | ||
|
||
$autoAlias = false; | ||
|
||
// Generate an alias if there is none | ||
if ($varValue == '') | ||
{ | ||
$autoAlias = true; | ||
$slugOptions = array(); | ||
|
||
// Read the slug options from the associated page | ||
if (($objPage = \PageModel::findWithDetails($dc->activeRecord->pid)) !== null) | ||
{ | ||
$slugOptions['locale'] = $objPage->language; | ||
|
||
if ($objPage->validAliasCharacters) | ||
{ | ||
$slugOptions['validChars'] = $objPage->validAliasCharacters; | ||
} | ||
} | ||
|
||
$varValue = \System::getContainer()->get('contao.slug.generator')->generate(\StringUtil::stripInsertTags($dc->activeRecord->title), $slugOptions); | ||
} | ||
|
||
// Add a prefix to reserved names (see #6066) | ||
if ($strTable === "tl_article" && \in_array($varValue, array('top', 'wrapper', 'header', 'container', 'main', 'left', 'right', 'footer'))) | ||
{ | ||
$varValue = $prefix . $varValue; | ||
} | ||
|
||
$objAlias = \Database::getInstance()->prepare("SELECT id FROM " . $strTable . " WHERE id=? OR alias=?")->execute($dc->id, $varValue); | ||
|
||
// Check whether the page alias exists | ||
if ($objAlias->numRows > 1) | ||
{ | ||
if (!$autoAlias) | ||
{ | ||
throw new \Exception(sprintf($GLOBALS['TL_LANG']['ERR']['aliasExists'], $varValue)); | ||
} | ||
|
||
$varValue .= '-' . $dc->id; | ||
} | ||
|
||
return $varValue; | ||
} | ||
} |
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 |
---|---|---|
@@ -1,13 +1,12 @@ | ||
<?php | ||
/*************************************************************************** | ||
* | ||
* (c) 2016 Stephan Preßl, www.stephanpressl.at <[email protected]> | ||
/******************************************************************* | ||
* (c) 2018 Stephan Preßl, www.prestep.at <[email protected]> | ||
* All rights reserved | ||
* | ||
* Modification, distribution or any other action on or with | ||
* this file is permitted unless explicitly granted by Stephan Preßl | ||
* | ||
***************************************************************************/ | ||
* this file is permitted unless explicitly granted by IIDO | ||
* www.iido.at <[email protected]> | ||
*******************************************************************/ | ||
|
||
namespace IIDO\BasicBundle\Twig; | ||
|
||
|
||
|
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