Generate the template directory

@param array $aEmailBits The supplied classname "bits"

@return string
14834
protected function generateTemplateDir(array $aEmailBits): string
    {
        $sClassName = array_pop($aEmailBits);
        return implode(
            DIRECTORY_SEPARATOR,
            array_map(
                function ($sItem) {
                    return rtrim($sItem, DIRECTORY_SEPARATOR);
                },
                array_merge(
                    [static::TEMPLATE_PATH],
                    array_map('strtolower', $aEmailBits),
                    [DIRECTORY_SEPARATOR]
                )
            )
        );
    }
1314200
public static function initTransactionPartsDebit($transactionPartsTemplate = null) {
        $fields = ['account_id', 'value', 'description'];
        
        $transactionParts = [new TransactionPartDebit()];
        
        $c = 0;
        if ($transactionPartsTemplate !== null) {
            foreach ($transactionPartsTemplate as $tp) {
                
                if ($c >= 1) {
                    array_push($transactionParts, new TransactionPartDebit());
                }
                
                foreach ($fields as $f) {
                    $transactionParts[$c]->$f = $tp->$f;
                }
                $c++;
            }
        }
        
        return $transactionParts;
    }
1003326
def get_email_templates
      url = ApiRequest.base_path("questionpro.survey.getEmailTemplates")
      result = self.class.get(url, body: self.options)

      self.full_response = result
      self.status = result['status']
      
      email_templates = []
      result_email_templates = result['response']['emailTemplates']
      result_email_templates.each do |email_template|
        email_templates.push(EmailTemplate.new(email_template))
      end
      
      return email_templates
    end
1274175
public function getTemplateBlocks($templateFileName)
    {
        $templateBlocksWithContent = [];

        $config = \OxidEsales\Eshop\Core\Registry::getConfig();

        $tplDir = trim($config->getConfigParam('_sTemplateDir'), '/\\');
        $templateFileName = str_replace(['\\', '//'], '/', $templateFileName);
        if (preg_match('@/' . preg_quote($tplDir, '@') . '/(.*)$@', $templateFileName, $m)) {
            $templateFileName = $m[1];
        }

        if ($this->isShopTemplateBlockOverriddenByActiveModule()) {
            $shopId = $config->getShopId();

            $ids = $this->_getActiveModuleInfo();

            $activeModulesId = array_keys($ids);
            $activeThemeIds = oxNew(\OxidEsales\Eshop\Core\Theme::class)->getActiveThemesList();

            $templateBlockRepository = oxNew(ModuleTemplateBlockRepository::class);
            $activeBlockTemplates = $templateBlockRepository->getBlocks($templateFileName, $activeModulesId, $shopId, $activeThemeIds);

            if ($activeBlockTemplates) {
                $activeBlockTemplatesByTheme = $this->filterTemplateBlocks($activeBlockTemplates);

                $templateBlocksWithContent = $this->fillTemplateBlockWithContent($activeBlockTemplatesByTheme);
            }
        }

        return $templateBlocksWithContent;
    }
1234393
public function readBitStream($bits)
    {
        $this->readByteIfNeeded();

        $result = '';
        for ($i = 0; $i < $bits; $i++) {
            $mask = pow(2, $this->currentBitPosition);
            $result = ((($this->currentByte & $mask) === $mask) ? '1' : '0').$result;

            $this->currentBitPosition++;
            if (($i + 1) < $bits) {
                $this->readByteIfNeeded();
            }
        }

        return $result;
    }
384945
private function generateNonce($bits = 64)
    {
        $result          = '';
        $accumulatedBits = 0;
        $random          = mt_getrandmax();

        for ($totalBits = 0; $random != 0; $random >>= 1) {
            ++$totalBits;
        }

        $usableBits = intval($totalBits / 8) * 8;

        while ($accumulatedBits < $bits) {
            $bitsToAdd = min($totalBits - $usableBits, $bits - $accumulatedBits);
            if ($bitsToAdd % 4 != 0) {
                // add bits in whole increments of 4
                $bitsToAdd += 4 - $bitsToAdd % 4;
            }

            // isolate leftmost $bits_to_add from mt_rand() result
            $moreBits = mt_rand() & ((1 << $bitsToAdd) - 1);

            // format as hex (this will be safe)
            $format_string = '%0'.($bitsToAdd / 4).'x';
            $result .= sprintf($format_string, $moreBits);
            $accumulatedBits += $bitsToAdd;
        }

        return $result;
    }
429473
public static function _generateRSAKeys($keyBits = 2048) {
        $conf = array(
            'digest_alg' => 'sha256',
            'private_key_type' => OPENSSL_KEYTYPE_RSA,
            'private_key_bits' => $keyBits,
            'encrypt_key' => true,
        );


        $res = openssl_pkey_new($conf);
        $keys = array();
        openssl_pkey_export($res, $keys['private']);
        $publickey = openssl_pkey_get_details($res);
        $keys['public'] = $publickey["key"];
        return($keys);
    }
1081312
public function generate($bits = 50.0)
    {
        $bits = (float) $bits;
        $separators = $this->getSeparators();
        $separatorBits = $this->precisionFloat(log(strlen($separators), 2));
        $passPhrase = '';
        
        try
        {
            if ($bits < self::MIN_ENTROPY_BITS || $bits > self::MAX_ENTROPY_BITS)
            {
                throw new \InvalidArgumentException('Invalid parameter: $bits must be between ' . self::MIN_ENTROPY_BITS . ' and ' . self::MAX_ENTROPY_BITS);
            }
            
            $words = $this->_wordlistHandler->getWordsAsArray();
            $count = count($words);
            if ($count < self::MIN_WORD_COUNT)
            {
                throw new \RuntimeException('Wordlist must have at least ' . self::MIN_WORD_COUNT . ' unique words');
            }

            $countForBits = $count;
            if ($this->_disableWordModifier !== true)
            {
                $countForBits = $countForBits * $this->_wordModifier->getWordCountMultiplier();
            }
            $wordBits = $this->precisionFloat(log($countForBits, 2));
            
            if ($wordBits < 1)
            {
                throw new \RuntimeException('Words does not have enough bits to create a passphrase');
            }
            
            $maxIndex = $count;
            
            if ($this->_disableSeparators === true)
            {
                $useSeparators = false;
            }
            else if ($this->_alwaysUseSeparators)
            {
                $useSeparators = true;
            }
            else
            {
                $useSeparators = $this->makesSenseToUseSeparators($bits, $wordBits, $separatorBits);
            }
            
            do
            {
                $index = $this->_randomProvider->getElement($maxIndex);
                $word = $words[$index];
                
                if ($this->_disableWordModifier !== true)
                {
                    $word = $this->_wordModifier->modify($word, $this->_encoding);
                }

                $passPhrase .= $word;
                $bits -= $wordBits;

                if ($bits > $separatorBits && $useSeparators === true && isset($separators[0]))
                {
					// At least two separator characters
					if (isset($separators[1]))
					{
						$passPhrase .= $separators[$this->_randomProvider->getElement(strlen($separators))];
						$bits -= $separatorBits;
					}
					else
					{
						$passPhrase .= $separators[0];
					}
                }
                else if ($bits > 0.0)
                {
                    $passPhrase .= ' ';
                }
            }
            while ($bits > 0.0);
        }
        catch (\Exception $e)
        {
            throw $e;
        }
        
        return $passPhrase;
    }
692407
public static function emailEncode($sEmail)
	{
		$sEmail = bin2hex($sEmail);
		$sEmail = chunk_split($sEmail, 2, '%');
		$sEmail = '%' . substr($sEmail, 0, strlen($sEmail) - 1);
		return $sEmail;
	}
393989
public function metaBoxTemplateAreas()
    {
	global $wp_registered_sidebars;
	global $modularityOptions;

	usort($wp_registered_sidebars, function ($a, $b) {
	    return $a['name'] > $b['name'];
	});

	$coreTemplates = \Modularity\Helper\Wp::getCoreTemplates();
	$coreTemplates = apply_filters('Modularity/CoreTemplatesInTheme', $coreTemplates);
	$customTemplates = get_page_templates();
	$templates = array_merge($coreTemplates, $customTemplates);

	include MODULARITY_TEMPLATE_PATH . 'options/partials/modularity-template-areas.php';
    }
156188
public static function generate(array $values) : string
    {
        $namespace = '__CustomDoctrineEnums';
        $className = 'CustomEnum__' . preg_replace('/[^a-zA-Z0-9_]/', '_', implode('__', $values));

        /** @var string|BaseEnumType $fullClassName */
        $fullClassName = $namespace . '\\' . $className;

        if (!class_exists($fullClassName, false)) {
            $class = strtr(self::$template, [
                    '{namespace}'  => $namespace,
                    '{class}'      => $className,
                    '{base_class}' => '\\' . BaseEnumType::class,
                    '{values}'     => var_export($values, true)
            ]);

            eval($class);
            Type::addType($fullClassName::getTypeName(), $fullClassName);
        }


        return $fullClassName::getTypeName();
    }
589685
public function getTemplateBase($admin = false)
    {
        // Base template dir is the parent dir of template dir
        return str_replace($this->_sTemplateDir . '/', '', $this->getDir(null, $this->_sTemplateDir, $admin, null, null, null, false));
    }
1221428
public function sectionTemplatesInsert()
	{
		$filename = arg('name');
		$filter = new Eresus_FS_NameFilter();
		$filename = $filter->filter($filename);

		if ('' === $filename)
		{
			$filename = uniqid();
		}

		if ($filename != arg('name'))
		{
            Eresus_Kernel::app()->getPage()->addErrorMessage(
                sprintf(ADM_THEMES_FILENAME_FILTERED, $filename));
		}

		$templates = Templates::getInstance();
		$templates->add($filename, '', arg('code'), arg('desc'));
		HTTP::redirect(arg('submitURL'));
	}
1073291
public function single( $templates ) {

		$templates = [];

		// Get the queried post.
		$post = get_queried_object();

		// Decode the post name.
		$name = urldecode( $post->post_name );

		// Check for a custom post template.
		$custom = get_page_template_slug( $post->ID );

		if ( $custom ) {
			$templates[] = $custom;
		}

		// If viewing an attachment page, handle the files by mime type.
		if ( is_attachment() ) {

			// Split the mime type into two distinct parts.
			$type    = get_post_mime_type( $post );
			$subtype = '';

			if ( false !== strpos( $type, '/' ) ) {
				list( $type, $subtype ) = explode( '/', $type );
			}

			if ( $subtype ) {
				$templates[] = "attachment-{$type}-{$subtype}.php";
				$templates[] = "attachment-{$subtype}.php";
			}

			$templates[] = "attachment-{$type}.php";

		// If not viewing an attachment page.
		} else {

			// Add a post ID template.
			$templates[] = "single-{$post->post_type}-{$post->ID}.php";
			$templates[] = "{$post->post_type}-{$post->ID}.php";

			// Add a post name (slug) template.
			$templates[] = "single-{$post->post_type}-{$name}.php";
			$templates[] = "{$post->post_type}-{$name}.php";
		}

		// Add a template based off the post type name.
		$templates[] = "single-{$post->post_type}.php";
		$templates[] = "{$post->post_type}.php";

		// Allow for WP standard 'single' template.
		$templates[] = 'single.php';

		// Return the template hierarchy.
		return $templates;
	}
578626
public static function generateQueryString(array $parts)
    {
        $return = "";

        foreach ($parts as $part) {
            if ($part instanceof Table) {
                $return .= "`{$part->getTableName()}`";
                if ($part->getTableAs() !== null) {
                    $return .= " " . $part->getTableAs();
                }

                $return .= ",";
            }
        }

        return ($return !== "" ? substr($return, 0, -1) : "*");
    }
924017
public function send($sMailTemplate, $sEmailList, $arDefaultEmailData = [], $sEmailDataEventName = null, $bCheckActiveLang = false)
    {
        if (empty($sEmailList) || (!is_string($sEmailList) && !is_array($sEmailList))) {
            return;
        }

        //Get template name
        $this->sMailTemplate = $sMailTemplate;
        if ($bCheckActiveLang) {
            $this->sMailTemplate = $this->addActiveLangSuffix($this->sMailTemplate);
        }

        //Get template data
        $this->arMailData = $this->getMailData($sEmailDataEventName, $arDefaultEmailData);

        //Process email list
        if (is_string($sEmailList)) {
            $arEmailList = explode(',', $sEmailList);
        } else {
            $arEmailList = $sEmailList;
        }

        foreach ($arEmailList as $sEmail) {
            $sEmail = trim($sEmail);

            $this->sendMail($sEmail);
        }
    }
433986
protected function generateTool()
    {

        $this->data = $this->getMappedArguments();
        $generatorPath = str_replace(DIRECTORY_SEPARATOR, '/', dirname(__DIR__)) . '/studentToolGenerator';
        $targetPath    = $generatorPath . '/generated-code/' . $this->data['client'] . '/' . $this->data['tool-id'];
        $templatePath  = $generatorPath . '/template';

        $objects = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($templatePath), \RecursiveIteratorIterator::SELF_FIRST);

        $patterns = $this -> getPatterns();
        $replacements = $this -> getReplacements();

        foreach($objects as $tplFile => $cursor){
            if(in_array(basename($tplFile), array('.', '..'))) {
                continue;
            }

            $toolFile = str_replace($templatePath, $targetPath, $tplFile);

            if($cursor->isDir() && !is_dir($toolFile)) {
                mkdir($toolFile, 0755, true);
            }
            else if($cursor->isFile()){
                $toolFile = dirname($toolFile) . '/' . str_replace('template', $this->data['tool-base'], basename($toolFile));
                $toolContent = str_replace($patterns, $replacements, file_get_contents($tplFile));
                file_put_contents($toolFile, $toolContent);
            }
        }
        return $targetPath;
    }