public static function generate()
 {
     if (($objConfig = ConfigModel::findByPk(\Input::get('id'))) !== null && ($intCount = \Input::get('count'))) {
         $arrAlphabets = deserialize($objConfig->alphabets, true);
         $arrRules = deserialize($objConfig->rules, true);
         $arrCodes = array();
         for ($i = 0; $i < $intCount; $i++) {
             $strCode = CodeGenerator::generate($objConfig->length, $objConfig->preventAmbiguous, $arrAlphabets, $arrRules, $objConfig->allowedSpecialChars);
             if ($objConfig->preventDoubleCodes) {
                 $blnFound = false;
                 if ($objConfig->doubleCodeTable && $objConfig->doubleCodeTableField) {
                     $blnFound = static::findCodeInTable($strCode, $objConfig->doubleCodeTable, $objConfig->doubleCodeTableField);
                 }
                 while (in_array($strCode, $arrCodes) || $blnFound) {
                     $strCode = CodeGenerator::generate($objConfig->length, $objConfig->preventAmbiguous, $arrAlphabets, $arrRules, $objConfig->allowedSpecialChars);
                     $blnFound = false;
                     if ($objConfig->doubleCodeTable && $objConfig->doubleCodeTableField) {
                         $blnFound = static::findCodeInTable($strCode, $objConfig->doubleCodeTable, $objConfig->doubleCodeTableField);
                     }
                 }
             }
             $arrCodes[] = $strCode;
         }
         Files::sendTextAsFileToBrowser(implode("\n", $arrCodes), 'codes_' . date('Y-m-d-H-i') . '.txt');
     }
 }
 public function modifyPalette()
 {
     $objConfig = ConfigModel::findByPk(\Input::get('id'));
     $arrDca =& $GLOBALS['TL_DCA']['tl_code_config'];
     $arrAlphabets = deserialize($objConfig->alphabets, true);
     if (!in_array(CodeGenerator::SPECIAL_CHARS, $arrAlphabets)) {
         $arrDca['palettes']['default'] = str_replace('allowedSpecialChars', '', $arrDca['palettes']['default']);
     }
     if (!$objConfig->doubleCodeTable) {
         $arrDca['subpalettes']['preventDoubleCodes'] = str_replace('doubleCodeTableField', '', $arrDca['subpalettes']['preventDoubleCodes']);
     }
 }