Check for files

@param string $method_template The method template to call
@param string $key             The parameter name
@param string $value           The possible file name or URL

@return mixed
344495
protected function _checkForFiles($method_template, $key, $value) {
    if (!array_key_exists($method_template, self::$_possible_files)
      || !in_array($key, self::$_possible_files[$method_template])
    ) {
      return false;
    }
    $data = $this->_buildBinaryBody($value);
    if ($data === $value) {
      return false;
    }
    return $data;
  }
393266
def get_template(filename_or_string, is_string=False):
    '''
    
    '''

    # Cache against string sha or just the filename
    cache_key = sha1_hash(filename_or_string) if is_string else filename_or_string

    if cache_key in TEMPLATES:
        return TEMPLATES[cache_key]

    if is_string:
        # Set the input string as our template
        template_string = filename_or_string

    else:
        # Load template data into memory
        with open(filename_or_string, 'r') as file_io:
            template_string = file_io.read()

    TEMPLATES[cache_key] = Template(template_string, keep_trailing_newline=True)
    return TEMPLATES[cache_key]
182278
function SmartTemplateParser ( $template_filename )
		{
			// Load Template
			if ($hd = @fopen($template_filename, "r"))
			{
				if (filesize($template_filename))
				{
					$this->template = fread($hd, filesize($template_filename));
				}
				else
				{
					$this->template = "SmartTemplate Parser Error: File size is zero byte: '$template_filename'";
				}
				fclose($hd);
				// Extract the name of the template directory
				$this->template_dir = dirname($template_filename);
			}
			else
			{
				$this->template = "SmartTemplate Parser Error: File not found: '$template_filename'";
			}
		}
111972
public function getTemplateDir($key = null)
    {
        if ($key === null) {
            if (count($this->templateDirs) > 0) {
                return $this->templateDirs;
            }
            return null;
        }
        if (is_string($key) === 'string' || is_int($key)) {
            return isset($this->templateDirs[$key]) ? $this->templateDirs[$key] : null;
        }
        return null;
    }
7081
public static function get_template_part( $_view, $_data = null ) {

		/*
		To be reviewed later, should have more checks and restrictions like a whitelist etc.

		if ( 0 === strpos( $_view, 'http://' ) || 0 === strpos( $_view, 'https://' ) ) {
			$_view = apply_filters( 'pods_view_url_include', $_view );

			if ( empty( $_view ) || ( defined( 'PODS_REMOTE_VIEWS' ) && PODS_REMOTE_VIEWS ) )
				return '';

			$response = wp_remote_get( $_view );

			return wp_remote_retrieve_body( $response );
		}
		*/

		$_view = self::locate_template( $_view );

		if ( empty( $_view ) ) {
			return $_view;
		}

		if ( ! empty( $_data ) && is_array( $_data ) ) {
			extract( $_data, EXTR_SKIP );
		}

		ob_start();
		require $_view;
		$output = ob_get_clean();

		return $output;
	}
1123045
static function canRestoreCache( $key, $timestamp, $templateFilepath )
    {
        if ( !eZTemplateTreeCache::isCacheEnabled() )
            return false;

        $templateCache =& eZTemplateTreeCache::cacheTable();
        $key = eZTemplateTreeCache::internalKey( $key );
        if ( isset( $templateCache[$key] ) )
        {
            return false;
        }
        $cacheFileName = eZTemplateTreeCache::treeCacheFilename( $key, $templateFilepath );

        $php = new eZPHPCreator( eZTemplateTreeCache::cacheDirectory(), $cacheFileName );
        return $php->canRestore( $timestamp );
    }
220883
function getTemplate (templates, fileName) {
  var extMatch = fileName.match(/\.([^\.]*)$/);
  if (extMatch && extMatch.length > 1)
    return templates[extMatch[1]];
  return null;
}
422261
public function compileTemplateSource(Smarty_Internal_Template $_template)
    {
        $_template->source->compileds = array();
        $this->file_dependency = array();
        $this->tpl_function = array();
        $this->includes = array();
        $this->nocache_hash = null;
        $this->unifunc = null;
        // compile locking
        if (!$_template->source->handler->recompiled) {
            if ($saved_timestamp = $_template->compiled->getTimeStamp()) {
                touch($_template->compiled->filepath);
            }
        }
        // call compiler
        try {
            $_template->loadCompiler();
            $code = $_template->compiler->compileTemplate($_template);
        }
        catch (Exception $e) {
            // restore old timestamp in case of error
            if (!$_template->source->handler->recompiled && $saved_timestamp) {
                touch($_template->compiled->filepath, $saved_timestamp);
            }
            throw $e;
        }
        // compiling succeeded
        if ($_template->compiler->write_compiled_code) {
            // write compiled template
            $this->write($_template, $code);
            $code = '';
        }
        // release compiler object to free memory
        unset($_template->compiler);
        return $code;
    }
976012
function SmartTemplate ( $template_filename = '' )
		{
			global $_CONFIG;

			if (!empty($_CONFIG['smarttemplate_compiled']))
			{
				$this->temp_dir  =  $_CONFIG['smarttemplate_compiled'];
			}
			if (!empty($_CONFIG['smarttemplate_cache']))
			{
				$this->cache_dir  =  $_CONFIG['smarttemplate_cache'];
			}
			if (is_numeric($_CONFIG['cache_lifetime']))
			{
				$this->cache_lifetime  =  $_CONFIG['cache_lifetime'];
			}
			if (!empty($_CONFIG['template_dir'])  &&  is_file($_CONFIG['template_dir'] . '/' . $template_filename))
			{
				$this->template_dir  =  $_CONFIG['template_dir'];
			}
			$this->tpl_file  =  $template_filename;
		}
940318
public function template_fallback( $template, $template_name, $template_path ) {
		if ( ! file_exists( $template ) ) {
			// Woops, no template. Does hametwoo has it?
			$fallback = self::root_dir() . '/templates/' . $template_name;
			if ( file_exists( $fallback ) ) {
				$template = $fallback;
			}
		}
		return $template;
	}
707774
private File getTemplateFile(String filename) throws IOException {
        File templateFile=null;
        final String resource = TEMPLATE_RESOURCES_PATH + "/" + filename;
        InputStream is = Setup.class.getClassLoader().getResourceAsStream(resource);
        if (null == is) {
            throw new RuntimeException("Unable to load required template: " + resource);
        }
        templateFile = File.createTempFile("temp", filename);
        templateFile.deleteOnExit();
        try {
            return copyToNativeLineEndings(is, templateFile);
        } finally {
            is.close();
        }
    }
441579
protected function findFile($module, $template)
    {
        if (! isset($this->modulesMap[$module])) {
            return false;
        }
        $tpl   = str_replace('/', PHP_DS, $template);
        $found = glob($this->modulesMap[$module] . $tpl . '.*');
        if (! $found) {
            return false;
        }
        $file = $found[0];

        $this->templatesMap[$module . '::' . $template] = $file;

        return $file;
    }
1079513
public function getPaymentMethodTemplate($template, array $order, $payment_model)
    {
        if (empty($order['payment'])) {
            return '';
        }

        $method = $payment_model->get($order['payment']);
        return $this->getMethodTemplate($template, $order, $method);
    }
1289154
protected function checkTemplateFile($canUseFlexforms = false)
    {
        if (TYPO3_MODE === 'BE') {
            return;
        }

        $this->checkForNonEmptyString(
            'templateFile',
            $canUseFlexforms,
            's_template_special',
            'This value specifies the HTML template which is essential when ' .
            'creating any output from this extension.'
        );

        if (($this->getFrontEndController() !== null)
            && $this->objectToCheck->hasConfValueString('templateFile', 's_template_special')
        ) {
            $rawFileName = $this->objectToCheck->getConfValueString(
                'templateFile',
                's_template_special',
                true
            );
            if (!is_file($this->getFrontEndController()->tmpl->getFileName($rawFileName))) {
                $message = 'The specified HTML template file <strong>'
                    . htmlspecialchars($rawFileName)
                    . '</strong> cannot be read. '
                    . 'The HTML template file is essential when creating any '
                    . 'output from this extension. '
                    . 'Please either create the file <strong>' . $rawFileName
                    . '</strong> or select an existing file using the TS setup '
                    . 'variable <strong>' . $this->getTSSetupPath()
                    . 'templateFile</strong>';
                if ($canUseFlexforms) {
                    $message .= ' or via FlexForms';
                }
                $message .= '.';
                $this->setErrorMessage($message);
            }
        }
    }
358742
public function get($method_id)
    {
        $methods = $this->getList();
        return empty($methods[$method_id]) ? array() : $methods[$method_id];
    }
836102
function fetch($template_file) {
        $template = $this->twig->load($template_file);
        return $template->render($this->twig_vars);
    }
836884
static function treeCacheFilename( $key, $templateFilepath )
    {
        $internalCharset = eZTextCodec::internalCharset();
        $extraName = '';
        if ( preg_match( "#^.+/(.*)\.tpl$#", $templateFilepath, $matches ) )
            $extraName = '-' . $matches[1];
        else if ( preg_match( "#^(.*)\.tpl$#", $templateFilepath, $matches ) )
            $extraName = '-' . $matches[1];
        $cacheFileKey = "$key-$internalCharset";
        $cacheFileName = md5( $cacheFileKey ) . $extraName . '.php';
        return $cacheFileName;
    }