/**
  * Generuje hash hesla i se solicim retezcem
  * @return string
  */
 public function generateHash($password, $salt = NULL)
 {
     if ($password === Strings::upper($password)) {
         // v pripade zapleho capslocku
         $password = Strings::lower($password);
     }
     return crypt($password, $salt ?: $this->user_salt . Strings::random(23));
 }
 /**
  * Generuje hash hesla i se solicim retezcem
  * @return string
  */
 public function generateHash($heslo, $salt = NULL)
 {
     if ($heslo === Strings::upper($heslo)) {
         // v pripade zapleho capslocku
         $heslo = Strings::lower($heslo);
     }
     return crypt($heslo, $salt ?: '$2a$07$' . Strings::random(23));
 }
 /**
  * Computes password hash.
  *
  * @param string
  * @param string|NULL
  * @return string
  */
 public static function calculateHash($password, $salt = NULL)
 {
     if ($password === Strings::upper($password)) {
         // perhaps caps lock is on
         $password = Strings::lower($password);
     }
     return crypt($password, $salt ?: '$2a$07$' . Strings::random(22));
 }
 /**
  * @param string
  * @param string|NULL
  * @return string
  */
 private function calculateAddonsPortalPasswordHash($password, $salt = NULL)
 {
     if ($password === Strings::upper($password)) {
         // perhaps caps lock is on
         $password = Strings::lower($password);
     }
     return crypt($password, $salt ?: '$2a$07$' . Strings::random(22));
 }
 /**
  * Computes salted password hash.
  * @param  string
  * @return string
  */
 public static function calculateHash($password, $salt = NULL)
 {
     if ($password === Strings::upper($password)) {
         // perhaps caps lock is on
         $password = Strings::lower($password);
     }
     $password = substr($password, 0, self::PASSWORD_MAX_LENGTH);
     return crypt($password, $salt ?: '$2a$07$' . Strings::random(22));
 }
Beispiel #6
0
 public static function decode($string)
 {
     $digits = ['I' => 1, 'V' => 5, 'X' => 10, 'L' => 50, 'C' => 100, 'D' => 500, 'M' => 1000];
     $string = Strings::upper($string);
     if (!Strings::match($string, '#[IVXLCDMN]+#')) {
         throw new \InvalidArgumentException('Malformed symbol detected. Allowed symbols are: IVXLCDMN');
     }
     if (count(explode('V', $string)) > 2 || count(explode('L', $string)) > 2 || count(explode('D', $string)) > 2) {
         throw new \InvalidArgumentException('Multiple occurencies of V, L or D symbols');
     }
     if ($string === 'N') {
         return 0;
     }
     $count = 1;
     $last = 'Z';
     foreach (str_split($string) as $char) {
         if ($char === $last) {
             $count++;
             if ($count === 4) {
                 throw new \InvalidArgumentException('Malformed Roman number');
             }
         } else {
             $count = 1;
             $last = $char;
         }
     }
     $ptr = 0;
     $values = [];
     $maxDigit = 1000;
     while ($ptr < strlen($string)) {
         $numeral = $string[$ptr];
         $digit = $digits[$numeral];
         if ($digit > $maxDigit) {
             throw new \InvalidArgumentException('Rule 3');
         }
         if ($ptr < strlen($string) - 1) {
             $nextNumeral = $string[$ptr + 1];
             $nextDigit = $digits[$nextNumeral];
             if ($nextDigit > $digit) {
                 if (!in_array($numeral, ['I', 'X', 'C']) || $nextDigit > $digit * 10 || count(explode($numeral, $string)) > 2) {
                     throw new \InvalidArgumentException('Rule 3');
                 }
                 $maxDigit = $digit - 1;
                 $digit = $nextDigit - $digit;
                 $ptr++;
             }
         }
         $values[] = $digit;
         $ptr++;
     }
     for ($i = 0; $i < count($values) - 1; $i++) {
         if ($values[$i] < $values[$i + 1]) {
             throw new \InvalidArgumentException('Rule 5');
         }
     }
     return array_sum($values);
 }
 /**
  * Converts the given string to `spinal-case`
  * @param string $string
  * @return string
  */
 public static function spinalCase($string)
 {
     /** RegExp source http://stackoverflow.com/a/1993772 */
     preg_match_all('/([A-Z][A-Z0-9]*(?=$|[A-Z][a-z0-9])|[A-Za-z][a-z0-9]+)/', $string, $matches);
     $matches = $matches[0];
     foreach ($matches as &$match) {
         $match = $match == Strings::upper($match) ? Strings::lower($match) : Strings::firstLower($match);
     }
     return implode('-', $matches);
 }
Beispiel #8
0
 /**
  * Computes salted password hash.
  * @param  string
  * @return string
  */
 public static function hashPassword($password, $options = NULL)
 {
     if ($password === Strings::upper($password)) {
         // perhaps caps lock is on
         $password = Strings::lower($password);
     }
     $password = substr($password, 0, self::PASSWORD_MAX_LENGTH);
     $options = $options ?: implode('$', array('algo' => PHP_VERSION_ID < 50307 ? '$2a' : '$2y', 'cost' => '07', 'salt' => Strings::random(22)));
     return crypt($password, $options);
 }
Beispiel #9
0
 /**
  * Computes salted password hash.
  *
  * @param $password
  * @param null $options
  * @return string
  */
 public static function hashPassword($password, $options = NULL)
 {
     if ($password === Nette\Utils\Strings::upper($password)) {
         // perhaps caps lock is on
         $password = Nette\Utils\Strings::lower($password);
     }
     $password = substr($password, 0, 4096);
     $options = $options ?: implode('$', ['algo' => PHP_VERSION_ID < 50307 ? '$2a' : '$2y', 'cost' => '07', 'salt' => Nette\Utils\Strings::random(22)]);
     return crypt($password, $options);
 }
Beispiel #10
0
 public function processCons()
 {
     $arr = [];
     foreach (Arrays::get($this->data, 'constants', []) as $name => $cons) {
         if ($this->getDefault($cons) != ";") {
             $arr[] = "\$" . Strings::upper($name) . $this->getDefault($cons);
         }
     }
     $this->template->constants = $arr;
 }
Beispiel #11
0
 public function testRenderWithRenderer()
 {
     $test = $this;
     $this->column->setRenderer(function ($value, $rowData, $cell) use($test) {
         $test->assertTrue(is_string($value));
         $test->assertInstanceOf('stdClass', $rowData);
         $test->assertInstanceOf('Nette\\Utils\\Html', $cell);
         return \Nette\Utils\Strings::upper($value);
     });
     $result = $this->column->render(array('testing', 'is', 'awesome'), array());
     $this->assertEquals('TESTING, IS, AWESOME', $result);
 }
 /**
  * Akce vracející data description a konfiguraci pro EasyMiner UI
  * @param int $id_dm
  * @param int $miner
  * @throws ForbiddenRequestException
  */
 public function actionGetData($id_dm, $miner)
 {
     if (empty($miner)) {
         $miner = $id_dm;
     }
     //------------------------------------------------------------------------------------------------------------------
     $miner = $this->findMinerWithCheckAccess($miner);
     $minerType = $miner->type;
     $FLPathElement = 'FLPath_' . Strings::upper($minerType);
     //------------------------------------------------------------------------------------------------------------------
     #region připravení informací pro UI - s odděleným připravením DataDictionary
     $dataDescriptionPMML = null;
     $dataParser = new DataParser($dataDescriptionPMML, $this->config->{$FLPathElement}, $this->config->FGCPath, null, null, $this->translator->getLang());
     $dataParser->loadData();
     $responseContent = $dataParser->parseData();
     $user = $this->getCurrentUser();
     $responseContent['DD'] = ['dataDictionary' => $this->datasourcesFacade->exportDataDictionaryArr($miner->datasource, $user, $rowsCount), 'transformationDictionary' => $this->metasourcesFacade->exportTransformationDictionaryArr($miner->metasource, $user), 'recordCount' => $rowsCount];
     #endregion připravení informací pro UI - s odděleným připravením DataDictionary
     uksort($responseContent['DD']['transformationDictionary'], function ($a, $b) {
         return strnatcasecmp($a, $b);
     });
     uksort($responseContent['DD']['dataDictionary'], function ($a, $b) {
         return strnatcasecmp($a, $b);
         //return strnatcasecmp(mb_strtolower($a,'utf-8'),mb_strtolower($b,'utf-8'));
     });
     $responseContent['status'] = 'ok';
     $responseContent['miner_type'] = $miner->type;
     $responseContent['miner_name'] = $miner->name;
     if ($miner->ruleSet) {
         $ruleSet = $miner->ruleSet;
     } else {
         $ruleSet = $this->ruleSetsFacade->saveNewRuleSetForUser($miner->name, $this->getCurrentUser());
         $miner->ruleSet = $ruleSet;
         $this->minersFacade->saveMiner($miner);
     }
     $responseContent['miner_ruleset'] = ['id' => $ruleSet->ruleSetId, 'name' => $ruleSet->name];
     $responseContent['miner_config'] = $miner->getExternalConfig();
     $this->sendJsonResponse($responseContent);
 }
Beispiel #13
0
 private function createPresenterName($string)
 {
     $presenter = '';
     $enlarge = false;
     for ($i = 0; $i < \Nette\Utils\Strings::length($string); $i++) {
         $char = \Nette\Utils\Strings::substring($string, $i, 1);
         if ($char == '-') {
             $enlarge = true;
         }
         if (ord($char) >= 65 && ord($char) <= 90 || ord($char) >= 97 && ord($char) <= 122) {
             if ($i == 0 || $enlarge) {
                 $presenter .= \Nette\Utils\Strings::upper($char);
                 if ($enlarge) {
                     $enlarge = false;
                 }
             } else {
                 $presenter .= $char;
             }
         }
     }
     return $presenter;
 }
Beispiel #14
0
 /**
  * @param PhpNamespace $namespace
  * @param ClassType $class
  * @param Column $column
  * @return void
  */
 public function doDecorate(Column $column, ClassType $class, PhpNamespace $namespace)
 {
     $column->setPhpDoc($doc = new PhpDoc());
     // Annotation
     $doc->setAnnotation('@property');
     // Type
     if ($column->isNullable()) {
         $doc->setType($this->getRealType($column) . '|NULL');
     } else {
         $doc->setType($this->getRealType($column));
     }
     // Variable
     $doc->setVariable(Helpers::camelCase($column->getName()));
     // Defaults
     if ($column->getDefault() !== NULL) {
         $doc->setDefault($this->getRealDefault($column));
     }
     // Enum
     if (!empty($enum = $column->getEnum())) {
         $doc->setEnum(Strings::upper($column->getName()));
     }
     // Relations
     if (($key = $column->getForeignKey()) !== NULL) {
         // Find foreign entity table
         $ftable = $column->getTable()->getDatabase()->getForeignTable($key->getReferenceTable());
         // Update type to Entity name
         $doc->setType($this->resolver->resolveEntityName($ftable));
         $doc->setRelation($relDoc = new PhpRelDoc());
         if ($use = $this->getRealUse($ftable, $namespace)) {
             $namespace->addUse($use);
         }
         $relDoc->setType('???');
         $relDoc->setEntity($this->resolver->resolveEntityName($ftable));
         $relDoc->setVariable('???');
     }
     // Append phpDoc to class
     $class->addDocument((string) $column->getPhpDoc());
 }
Beispiel #15
0
 /**
  * @param PhpNamespace $namespace
  * @param ClassType $class
  * @param Column $column
  * @return void
  */
 public function doDecorate(Column $column, ClassType $class, PhpNamespace $namespace)
 {
     switch ($column->getType()) {
         // Map: DateTime
         case ColumnTypes::TYPE_DATETIME:
             $column->setType('DateTime');
             if ($column->getDefault() !== NULL) {
                 $column->setDefault('now');
             }
             $namespace->addUse('Nette\\Utils\\DateTime');
             break;
             // Map: Enum
         // Map: Enum
         case ColumnTypes::TYPE_ENUM:
             foreach ($column->getEnum() as $enum) {
                 $name = Strings::upper($column->getName()) . '_' . $enum;
                 $class->addConst($name, $enum);
             }
             if ($column->getDefault() !== NULL) {
                 $column->setDefault(Strings::upper($column->getName()) . '_' . $column->getDefault());
             }
             break;
     }
 }
Beispiel #16
0
 /**
  * @param string $flag
  * @return mixed
  * @throws WebChemistry\Images\ImageStorageException
  */
 private function flagToInteger($flag)
 {
     $flag = trim(Strings::upper($flag));
     $value = @constant('Nette\\Utils\\Image::' . $flag);
     if ($value === NULL) {
         throw new WebChemistry\Images\ImageStorageException("WebChemistry\\Images: Flag '{$flag}' does not exist in Nette\\Utils\\Image.");
     }
     return $value;
 }
Beispiel #17
0
 /**
  * Converts name and surname to short form. E.g. "John Doe" => "John D."
  *
  * @param $name
  * @return string
  * @register
  */
 public static function shortName($name)
 {
     $name = explode(' ', $name, 2);
     if (isset($name[1]) && Strings::length($name[1])) {
         return $name[0] . ' ' . Strings::upper(Strings::substring($name[1], 0, 1)) . '.';
     } else {
         return $name[0];
     }
 }
Beispiel #18
0
 /**
  * Converts the given string to "CONST_CASE".
  * @param string $string
  * @return string
  */
 public static function toConstCase($string)
 {
     return Strings::upper(self::toSnakeCase($string));
 }
 /**
  * @param string $oldName
  * @param string $newName
  * @return bool
  */
 public function renameColumn($oldName, $newName)
 {
     $columnInfoQuery = $this->db->prepare('SHOW COLUMNS FROM `' . $this->tableName . '` LIKE :name ;');
     $columnInfoQuery->execute(array(':name' => $oldName));
     $columnInfo = $columnInfoQuery->fetchObject();
     if (!$columnInfo) {
         return false;
     }
     $sql = 'ALTER TABLE `' . $this->tableName . '` CHANGE `' . $oldName . '` `' . $newName . '` ' . $columnInfo->Type;
     $params = array();
     if (@$columnInfo->Collation != '') {
         $sql .= ' COLLATE ' . $columnInfo->Collation;
     }
     if (Strings::upper(@$columnInfo->Null) == 'YES') {
         $sql .= ' NULL ';
     } else {
         $sql .= ' NOT NULL ';
     }
     if (@$columnInfo->Default != '') {
         $sql .= ' DEFAULT :default ';
         $params[':default'] = $columnInfo->Default;
     }
     $sql .= ' ' . @$columnInfo->Extra;
     if (@$columnInfo->Comment != '') {
         $sql .= ' COMMENT :comment ';
         $params[':comment'] = $columnInfo->Comment;
     }
     $sql .= ';';
     $renameQuery = $this->db->prepare($sql);
     return $renameQuery->execute($params);
 }
Beispiel #20
0
 /**
  * @param string $charset
  * @return \Curl\CurlResponse
  */
 public function convert($to = "UTF-8", $from = NULL)
 {
     if ($from === NULL) {
         $charset = $this->query['head > meta[http-equiv=Content-Type]']->attr('content');
         $charset = $charset ?: $this->query['head > meta[http-equiv=content-type]']->attr('content');
         $charset = $charset ?: $this->headers['Content-Type'];
         $from = static::getCharset($charset);
     }
     $from = Strings::upper($from);
     $to = Strings::upper($to);
     if ($from != $to && $from && $to) {
         if ($body = @iconv($from, $to, $this->body)) {
             $this->Body = ltrim($body);
         } else {
             throw new CurlException("Charset conversion from {$from} to {$to} failed");
         }
     }
     $this->Body = self::fixContentTypeMeta($this->body);
     return $this;
 }
Beispiel #21
0
 /**
  * @param IRequest $request
  *
  * @return string
  */
 protected function detectMethod(IRequest $request)
 {
     $requestMethod = $request->getMethod();
     if ($requestMethod !== 'POST') {
         return $request->getMethod();
     }
     $method = $request->getHeader(self::METHOD_OVERRIDE_HTTP_HEADER);
     if (isset($method)) {
         return Strings::upper($method);
     }
     $method = $request->getQuery(self::METHOD_OVERRIDE_QUERY_PARAM);
     if (isset($method)) {
         return Strings::upper($method);
     }
     return $requestMethod;
 }
Beispiel #22
0
 /**
  * @param string $code
  * @return bool
  */
 public static function validate($code)
 {
     return isset(self::$TYPES[\Nette\Utils\Strings::upper($code)]);
 }
Beispiel #23
0
 /**
  * Vraci pocatecni pismeno/znak nazvu tagu
  * @return string
  */
 public function getFirstLetter()
 {
     $smallTitle = Strings::upper($this->title);
     return substr($smallTitle, 0, 1);
 }
Beispiel #24
0
 /**
  * @param  Nette\Http\IRequest $request
  * @return string
  */
 public function resolveMethod(Nette\Http\IRequest $request)
 {
     if (!empty($request->getHeader('X-HTTP-Method-Override'))) {
         return Strings::upper($request->getHeader('X-HTTP-Method-Override'));
     }
     if ($method = Strings::upper($request->getQuery('__apiRouteMethod'))) {
         if (isset($this->actions[$method])) {
             return $method;
         }
     }
     return Strings::upper($request->getMethod());
 }
Beispiel #25
0
 /**
  * Converts raw TXT to internal CSV
  */
 private function raw2csv()
 {
     $verifier = new Verifier();
     $lines = preg_split('/[\\r\\n]+/', $this->_sourceData);
     foreach ($lines as $line) {
         // if it's not a blank line, and it's not the header row
         if ($line == '' || Strings::length($line) < 10 || Strings::startsWith($line, 'SEPA Country') || Strings::startsWith($line, 'Name of country')) {
             continue;
         }
         // assigned fields to named variables
         list($countryName, $countryCode, $domesticExample, $bban, $bbanStructure, $bbanLength, $bbanBiPosition, $bbanBiLength, $bbanBiExample, $bbanExample, $iban, $ibanStructure, $ibanLength, $ibanElectronicExample, $ibanPrintExample, $countrySepa, $contactDetails) = array_map(function ($item) {
             return trim(trim($item, '"'), ' ');
         }, explode("\t", $line));
         // sanitise
         $countryCode = Strings::upper(substr($countryCode, 0, 2));
         // sanitise comments away
         $bbanStructure = Strings::replace($bbanStructure, '/[:;]/');
         // errors seen in Germany, Hungary entries
         $ibanStructure = Strings::replace($ibanStructure, '/, .*$/');
         // duplicates for FO, GL seen in DK
         $ibanElectronicExample = Strings::replace($ibanElectronicExample, '/, .*$/');
         // duplicates for FO, GL seen in DK
         switch ($countryCode) {
             case 'MU':
                 $ibanElectronicExample = str_replace(' ', '', $ibanElectronicExample);
                 // MU example has a spurious space
                 break;
             case 'CZ':
                 $ibanElectronicExample = Strings::replace($ibanElectronicExample, '/ \\{10,}+$/');
                 // extra example for CZ
                 $ibanPrintExample = Strings::replace($ibanPrintExample, '/^(CZ.. .... .... .... .... ....).*$/', '$1');
                 // extra example
                 break;
             case 'FI':
                 // remove additional example
                 $ibanElectronicExample = Strings::replace($ibanElectronicExample, '/ or .*$/');
                 // fix bban example to remove verbosity and match domestic example
                 $bban = '12345600000785';
                 break;
         }
         $ibanPrintExample = Strings::replace($ibanPrintExample, '/, .*$/');
         // calculate $bban_regex from $bban_structure
         $bbanRegex = $this->swift2regex($bbanStructure);
         // calculate $iban_regex from $iban_structure
         $ibanRegex = $this->swift2regex($ibanStructure);
         // calculate numeric $bban_length
         $bbanLength = Strings::replace($bbanLength, '/[^\\d]/');
         // calculate numeric $iban_length
         $ibanLength = Strings::replace($ibanLength, '/[^\\d]/');
         /*
          * calculate bban_bankid_<start|stop>_offset
          * .... First we have to parse the freetext $bban_bi_position, eg: 
          * Bank Identifier 1-3, Branch Identifier
          * Position 1-2
          * Positions 1-2
          * Positions 1-3
          * Positions 1-3 ;Branch is not available
          * Positions 1-3, Branch identifier
          * Positions 1-3, Branch identifier positions
          * Positions 1-4
          * Positions 1-4, Branch identifier
          * Positions 1-4, Branch identifier positions
          * Positions 1-5
          * Positions 1-5 (positions 1-2 bank identifier; positions 3-5 branch identifier). In case of payment institutions Positions 1-5, Branch identifier positions
          * Positions 1-6,  Branch identifier positions
          * Positions 1-6. First two digits of bank identifier indicate the bank or banking group (For example, 1 or 2 for Nordea, 31 for Handelsbanken, 5 for cooperative banks etc)
          * Positions 1-7
          * Positions 1-8
          * Positions 2-6, Branch identifier positions
          * positions 1-3, Branch identifier positions
          *
          *  ... our algorithm is as follows:
          *   - find all <digit>-<digit> tokens
          */
         $matches = Strings::matchAll($bbanBiPosition, '/(\\d)-(\\d\\d?)/', PREG_PATTERN_ORDER);
         // - discard overlaps ({1-5,1-2,3-5} becomes {1-2,3-5})
         $tmptokens = [];
         for ($j = 0; $j < count($matches[0]); $j++) {
             $from = $matches[1][$j];
             $to = $matches[2][$j];
             // (if we don't yet have a match starting here, or it goes further,
             //  overwrite the match-from-this-position record)
             if (!isset($tmptokens[$from]) || $to < $tmptokens[$from]) {
                 $tmptokens[$from] = $to;
             }
         }
         unset($matches);
         // done
         // - assume the token starting from position 1 is the bank identifier
         //  (or, if it does not exist, the token starting from position 2)
         $bbanBankidStartOffset = 0;
         // decrement 1 on assignment
         if (isset($tmptokens[1])) {
             $bbanBankidStopOffset = $tmptokens[1] - 1;
             // decrement 1 on assignment
             unset($tmptokens[1]);
         } else {
             $bbanBankidStopOffset = $tmptokens[2] - 1;
             // decrement 1 on assignment
             unset($tmptokens[2]);
         }
         // - assume any subsequent token, if present, is the branch identifier.
         $tmpkeys = array_keys($tmptokens);
         $start = array_shift($tmpkeys);
         unset($tmpkeys);
         //done
         $bbanBranchidStartOffset = $bbanBranchidStopOffset = '';
         if ($start != '') {
             // we have a branch identifier!
             $bbanBranchidStartOffset = $start - 1;
             $bbanBranchidStopOffset = $tmptokens[$start] - 1;
         } else {
             /*
              * (note: this codepath occurs for around two thirds of all records)
              * we have not yet found a branch identifier. HOWEVER, we can analyse the
              * structure of the BBAN to determine whether there is more than one
              * remaining non-tiny field (tiny fields on the end of a BBAN typically
              * being checksums) and, if so, assume that the first/shorter one is the branch identifier.
              */
             $reducedBbanStructure = Strings::replace($bbanStructure, '/^\\d+![nac]/');
             $tokens = $this->swiftTokenize($reducedBbanStructure, TRUE);
             // discard any tokens of length 1 or 2
             for ($t = 0; $t < count($tokens[0]); $t++) {
                 $tokens['discarded'][$t] = $tokens[1][$t] < 3 ? 1 : 0;
             }
             // interesting fields are those that are not discarded...
             $interestingFieldCount = !isset($tokens['discarded']) ? count($tokens[0]) : count($tokens[0]) - count($tokens['discarded']);
             // ...if we have at least two of them, there's a branchid-type field
             if ($interestingFieldCount >= 2) {
                 // now loop through until we assign the branchid start offset
                 // (this occurs just after the first non-discarded field)
                 $found = FALSE;
                 for ($f = 0; !$found && $f < count($tokens[0]); $f++) {
                     // if this is a non-discarded token, of >2 length...
                     if ((!isset($tokens['discarded'][$f]) || $tokens['discarded'][$f] != 1) && $tokens[1][$f] > 2) {
                         // ... then assign.
                         $preOffset = $bbanBankidStopOffset + 1;
                         // this is the offset before we reduced the structure to remove the bankid field
                         $bbanBranchidStartOffset = $preOffset + $tokens['offset'][$f];
                         $bbanBranchidStopOffset = $preOffset + $tokens['offset'][$f] + $tokens[1][$f] - 1;
                         // decrement by one on assignment
                         $found = TRUE;
                     }
                 }
             }
         }
         /*
          * calculate 1=Yes, 0=No for $country_sepa
          * note: This is buggy due to the free inclusion of random text by the registry publishers.
          *  Notably it requires modification for places like Finland and Portugal where these comments are known to exist.
          */
         $countrySepa = Strings::lower($countrySepa) == 'yes';
         // set registry edition
         $registryEdition = date('Y-m-d');
         // now prepare generate our registry lines...
         $toGenerate = [$countryCode => $countryName];
         switch ($countryCode) {
             case 'DK':
                 $toGenerate = ['DK' => $countryName, 'FO' => 'Faroe Islands', 'GL' => 'Greenland'];
                 break;
             case 'FR':
                 $toGenerate = ['FR' => $countryName, 'BL' => 'Saint Barthelemy', 'GF' => 'French Guyana', 'GP' => 'Guadelope', 'MF' => 'Saint Martin (French Part)', 'QM' => 'Martinique', 'RE' => 'Reunion', 'PF' => 'French Polynesia', 'TF' => 'French Sounthern Territories', 'YT' => 'Mayotte', 'NC' => 'New Caledonia', 'PM' => 'Saint Pierre et Miquelon', 'WF' => 'Wallis and Futuna Islands'];
                 break;
         }
         // output loop
         foreach ($toGenerate as $countryCode => $countryName) {
             $ibanElectronicExample = $verifier->setChecksum($countryCode . substr($ibanElectronicExample, 2));
             $ibanStructure = $countryCode . substr($ibanStructure, 2);
             $ibanRegex = '^' . $countryCode . substr($ibanRegex, 3);
             $this->_csvData[] = [$countryCode, $countryName, $domesticExample, $bbanExample, $bbanStructure, $bbanRegex, $bbanLength, $ibanElectronicExample, $ibanStructure, $ibanRegex, $ibanLength, $bbanBankidStartOffset, $bbanBankidStopOffset, $bbanBranchidStartOffset, $bbanBranchidStopOffset, $registryEdition, $countrySepa];
         }
     }
 }
Beispiel #26
0
 public function getOrderedPosts($prop, $direction = 'ASC')
 {
     $direction = Strings::upper($direction);
     return $this->getPosts()->where(':props.prop_type', $prop)->order(':props.' . static::propType2ColumnName($prop) . ' ' . $direction);
 }
Beispiel #27
0
 /**
  * Fixes caps lock accidentally turned on.
  * @param $password
  * @return mixed
  */
 private function removeCapsLock($password)
 {
     return $password === Strings::upper($password) ? Strings::lower($password) : $password;
 }
Beispiel #28
0
 protected function paymentInformation()
 {
     $multiplier = 0;
     if ($this->order->getDueDate()) {
         $this->image->text('&#xe660;', 1445, 710 + $multiplier * 55, function (Font $font) {
             $font->color($this->template->getPrimaryColor());
             $font->file($this->template->getIconFont());
             $font->size(37);
         });
         $this->image->text($this->translate('dueDate') . ':', 1520, 705 + $multiplier * 55, function (Font $font) {
             $font->color($this->template->getPrimaryColor());
             $font->size(27);
             $font->file($this->template->getFont());
         });
         $this->image->text($this->order->getDueDate()->format('d/m/Y'), 1850, 705 + $multiplier * 55, function (Font $font) {
             $font->size(27);
             $font->file($this->template->getFont());
             $font->color($this->template->getFontColor());
         });
         $multiplier++;
     }
     if ($this->order->getAccount()->getAccountNumber()) {
         $this->image->text('&#xe645;', 1445, 710 + $multiplier * 55, function (Font $font) {
             $font->color($this->template->getPrimaryColor());
             $font->file($this->template->getIconFont());
             $font->size(37);
         });
         $this->image->text($this->translate('accountNumber') . ':', 1520, 705 + $multiplier * 55, function (Font $font) {
             $font->color($this->template->getPrimaryColor());
             $font->size(27);
             $font->file($this->template->getFont());
         });
         $this->image->text($this->order->getAccount()->getAccountNumber(), 1850, 705 + $multiplier * 55, function (Font $font) {
             $font->size(27);
             $font->file($this->template->getFont());
             $font->color($this->template->getFontColor());
         });
         $multiplier++;
     }
     if ($this->order->getAccount()->getIBan()) {
         $this->image->text('&#xe645;', 1445, 710 + $multiplier * 55, function (Font $font) {
             $font->color($this->template->getPrimaryColor());
             $font->file($this->template->getIconFont());
             $font->size(37);
         });
         $this->image->text(Strings::upper($this->translate('iban')) . ':', 1520, 705 + $multiplier * 55, function (Font $font) {
             $font->color($this->template->getPrimaryColor());
             $font->size(27);
             $font->file($this->template->getFont());
         });
         $this->image->text($this->order->getAccount()->getIBan(), 1850, 705 + $multiplier * 55, function (Font $font) {
             $font->size(27);
             $font->file($this->template->getFont());
             $font->color($this->template->getFontColor());
         });
         $multiplier++;
     }
     if ($this->order->getAccount()->getSwift()) {
         $this->image->text('&#xe645;', 1445, 710 + $multiplier * 55, function (Font $font) {
             $font->color($this->template->getPrimaryColor());
             $font->file($this->template->getIconFont());
             $font->size(37);
         });
         $this->image->text(Strings::upper($this->translate('swift')) . ':', 1520, 705 + $multiplier * 55, function (Font $font) {
             $font->color($this->template->getPrimaryColor());
             $font->size(27);
             $font->file($this->template->getFont());
         });
         $this->image->text($this->order->getAccount()->getSwift(), 1850, 705 + $multiplier * 55, function (Font $font) {
             $font->size(27);
             $font->file($this->template->getFont());
             $font->color($this->template->getFontColor());
         });
         $multiplier++;
     }
     if ($this->order->getPayment()->getVariableSymbol()) {
         $this->image->text('&#xe6a3;', 1455, 710 + $multiplier * 55, function (Font $font) {
             $font->color($this->template->getPrimaryColor());
             $font->file($this->template->getIconFont());
             $font->size(37);
         });
         $this->image->text($this->translate('varSymbol') . ':', 1520, 705 + $multiplier * 55, function (Font $font) {
             $font->color($this->template->getPrimaryColor());
             $font->size(27);
             $font->file($this->template->getFont());
         });
         $this->image->text($this->order->getPayment()->getVariableSymbol(), 1850, 705 + $multiplier * 55, function (Font $font) {
             $font->size(27);
             $font->file($this->template->getFont());
             $font->color($this->template->getFontColor());
         });
         $multiplier++;
     }
     if ($this->order->getPayment()->getConstantSymbol()) {
         $this->image->text('&#xe6a3;', 1455, 710 + $multiplier * 55, function (Font $font) {
             $font->color($this->template->getPrimaryColor());
             $font->file($this->template->getIconFont());
             $font->size(37);
         });
         $this->image->text($this->translate('constSymbol') . ':', 1520, 705 + $multiplier * 55, function (Font $font) {
             $font->color($this->template->getPrimaryColor());
             $font->size(27);
             $font->file($this->template->getFont());
         });
         $this->image->text($this->order->getPayment()->getConstantSymbol(), 1850, 705 + $multiplier * 55, function (Font $font) {
             $font->size(27);
             $font->file($this->template->getFont());
             $font->color($this->template->getFontColor());
         });
         $multiplier++;
     }
     $this->image->text('&#xe68c;', 1445, 710 + $multiplier * 55, function (Font $font) {
         $font->color($this->template->getPrimaryColor());
         $font->file($this->template->getIconFont());
         $font->size(37);
     });
     $this->image->text($this->translate('totalPrice') . ':', 1520, 705 + $multiplier * 55, function (Font $font) {
         $font->color($this->template->getPrimaryColor());
         $font->size(27);
         $font->file($this->template->getFont());
     });
     $this->image->text($this->formatNumber($this->getTotalPrice(TRUE)) . ' ' . $this->order->getPayment()->getCurrency(), 1850, 705 + $multiplier * 55, function (Font $font) {
         $font->size(27);
         $font->file($this->template->getFont());
         $font->color($this->template->getFontColor());
     });
 }