Source of file ModuloDataExtension.php
Size: 1,258 Bytes - Last Modified: 2022-02-21T10:01:58+00:00
/var/www/docs.ssmods.com/process/src/code/data_extensions/ModuloDataExtension.php
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 | <?php /** * Provides with some modulo helper functionality for * use in templates. * * Add this extension to a DataObject instance * by adding this to your _config.php: * * Object::add_extension('DataObject', 'ModuloDataExtension'); * * @package cleanutilities * @subpackage data_extensions * * @author arillo */ class ModuloDataExtension extends DataExtension { /** * Indicator for, if this object is the nth child of a collection. * * @param int $pos current position in the list * @param int $modulo * @return bool */ public function GetModulo($pos, $modulo) { return (($pos%$modulo) == 0); } /** * Indicator for, if this object is before the nth child of a collection. * * @param int $pos current position in the list * @param int $modulo * @return bool */ public function GetBeforeModulo($pos, $modulo) { return (($pos-1) % $modulo == 0); } /** * Tests if current position is smaller than a * given value. * * @param int $pos current position in the list * @param int $num * @return bool */ public function LessThan($pos, $num) { return ($pos < $num); } } |