Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save gunnicom/f2f1f006ed859b636decd852a59daa59 to your computer and use it in GitHub Desktop.

Select an option

Save gunnicom/f2f1f006ed859b636decd852a59daa59 to your computer and use it in GitHub Desktop.

Revisions

  1. @johnnykage johnnykage created this gist Feb 1, 2013.
    36 changes: 36 additions & 0 deletions TemplateAutoincrement.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,36 @@
    <?php
    require_once('modules/DynamicFields/templates/Fields/TemplateText.php');

    class TemplateAutoincrement extends TemplateText{
    var $type = 'autoincrement';

    function get_field_def(){
    $def = parent::get_field_def();
    $def['studio'] = 'visible';
    $def['type'] = 'autoincrement';
    $def['dbType'] = 'int';

    if( isset($this->ext1) ) $def[ 'startindex' ] = $this->ext1 ;
    if( isset($this->ext2) ) $def[ 'interval' ] = $this->ext2 ;

    return $def;
    }

    function __construct() {
    $this->vardef_map['startindex'] = 'ext1';
    $this->vardef_map['interval'] = 'ext2';
    }

    function set($values){
    parent::set($values);

    if(!empty($this->ext1)){
    $this->startindex = $this->ext1;
    }

    if(!empty($this->ext2)){
    $this->interval = $this->ext2;
    }
    }
    }
    ?>