2017 © Pedro Peláez
 

contao-module contao-haste_plus

An extension for the contao haste module.

image

heimrichhannot/contao-haste_plus

An extension for the contao haste module.

  • Wednesday, May 16, 2018
  • by digitales@heimrich-hannot.de
  • Repository
  • 7 Watchers
  • 0 Stars
  • 9,648 Installations
  • PHP
  • 44 Dependents
  • 0 Suggesters
  • 2 Forks
  • 3 Open issues
  • 100 Versions
  • 16 % Grown

The README.md

Please note:, (*1)

This bundle is deprecated and not actively maintained anymore!, (*2)

Haste Plus

Haste plus extends codefog/contao-haste as a collection of tools and classes to ease working with Contao., (*3)

Module Preview, (*4)

Features

Cache

The PHP high-performance object caching system, phpfastcache is part of hast_plus. Currently only File-Caching is supported, but Pull-Request are welcome., (*5)

Example : FileCache

// MyClass.php

public function getSelectOptions(array $arrNewsArchives)
{
    // select a unique key
    $strCacheKey = 'my_select_options' . implode('_', $arrNewsArchives);

    if(FileCache::getInstance()->isExisting($strCacheKey))
    {
        return FileCache::getInstance()->get($strCacheKey);
    }

    $arrItems = array();

    // heavy sql queries or http-requests (just an example)
    $objItems = \NewsModel::findPublishedByPids($arrNewsArchives);

    if($objItems === null)
    {
        return $arrItems;
    }

    $arrItems = $objItems->fetchEach('headline');

    FileCache::getInstance()->set($strCacheKey, $arrItems);

    return $arrItems;
}

Security

Add security headers to http request (configurable in tl_settings), (*6)

  • IFRAME Clickjacking Protection: X-Frame-Options: SAMEORIGIN
  • Allow Origins Check: Access-Control-Allow-Origins & Access-Control-Allow-Headers

These options don't work anymore with Contao 4! Further Information, (*7)

Input/Widget rgxp

The following regular expression can be used to validate widget input., (*8)

Name Example Description
customDate customDate::d.m Validate custom date format against input.
price price Validate price input.
posfloat posfloat Validate float numbers in input.
maxlength maxlength::120 Validate the user input without html elements against the input given length.

Utils

The following Classes and Methods are helpers that ease the working with Contao., (*9)

Class Description
Files Contains helper function for working with files and filenames.
PaymentUtils Contains helper functions for payment relevant use cases.
StringUtils Contains helper function for working with strings.
Type Name Method Description
Url addScheme \HeimrichHannot\Haste\Util\Url::addScheme($strUrl, $strScheme) Add the given protocol/scheme (http://,https://,ftp://…) to the given url if not present.
Arrays filterByPrefixes \HeimrichHannot\Haste\Util\Arrays::filterByPrefixes($arrData, $arrayPrefixes) Filter an array by given prefixes and return the filtered array.
Arrays getListPositonCssClass \HeimrichHannot\Haste\Util\Arrays::getListPositonCssClass($key, $arrList, $blnReturnAsArray) Create the class names for an item within a array list

Google Maps

If you want to add google maps with ease that are build from dynamic entities, and not withing dlh_googlemaps backend module, use the following code., (*10)

# news_full.html5


venues as $arrVenue): ?>
    <?php $objMap->setCenter($arrVenue['venueSingleCoords']); // lat and lon seperated by comma ?>
    <?php $objMarker = new \HeimrichHannot\Haste\Map\GoogleMapMarker(); ?>
    <?php $objMarker->setPosition($arrVenue['venueSingleCoords']); // lat and lon seperated by comma ?>
    <?php $objMarker->setTitle($arrVenue['venueName']); // for full list of marker options see \HeimrichHannot\Haste\Map\GoogleMapMarker::prepare()?>
    <?php $objMap->addMarker($objMarker); ?>


= $objMap->generate(
    array(
        'mapSize' => array('100%', '400px', ''),
        'zoom'    => 13,
    )
    // for full list of map options see \HeimrichHannot\Haste\Map\GoogleMap::prepare()
); ?>

Inserttags

Tag Arguments Example
trimsplit 1st: the delimiter, 2nd: the value {{trimsplit::,::2,1}}
encrypt 1st: the value {{encrypt::my secret value}}

Developer notes

  • provide a minimum of 3 unit test for each test case of a util method

Notification Tokens

  • Added ##form_submission_html_all##, an equivalent to ##formsubmission## but for html format

The Versions