parse asset callback
@access protected
@param $m array
@return string
@since 3.0
@package Gcs\Framework\Core\Template
354782
protected function _parseAssetCallback($m) {
        if (Config::config()['user']['output']['asset']['enabled']) {
            $data = ['type' => $m[1], 'cache' => $m[3], 'files' => explode(',', $m[2])];

            $asset = new Asset($data);

            if ($m[1] == 'css') {
                return '<link href="{{url:.Gcs.gcs.asset.default:\'' . $asset->getId() . '\',\'' . $asset->getType() . '\'}}" rel="stylesheet" media="screen" type="text/css" />';
            }
            else if ($m[1] == 'js') {
                return '<script type="text/javascript" defer src="{{url:.Gcs.gcs.asset.default:\'' . $asset->getId() . '\',\'' . $asset->getType() . '\'}}" ></script>';
            }
        }
        else {
            $content = '';
            $files = explode(',', $m[2]);

            foreach ($files as $value) {
                $value = preg_replace('#\\n#isU', '', $value);
                $value = preg_replace('#\\r#isU', '', $value);
                $value = preg_replace('#\\t#isU', '', $value);

                if ($m[1] == 'css') {
                    $content .= '<link href="/' . trim($value) . '" rel="stylesheet" media="screen" type="text/css" />' . "\n";
                }
                else {
                    $content .= '<script type="text/javascript" defer src="/' . trim($value) . '"></script>' . "\n";
                }
            }

            return $content;
        }

        return '';
    }
605926
public static function asset($string, $name = null, $return = true)
    {

        $filePath = '';
        if (!file_exists($filePath)) {
            $filePath = BASE_DIR . $string;
        }
        $filenamePath = AssetsParser::findDomainPath($string, $filePath);

        $filePath = self::processAsset($string, $name, $return, $filenamePath);
        $basePath = Config::getParam('resources.cdn.url', Request::getInstance()->getRootUrl());
        $returnPath = empty($name) ? $basePath . '/' . $filePath : $name;
        return $return ? $returnPath : '';
    }
1279204
protected function parseAssetDefinition($asset)
    {
        if (starts_with($asset, 'http://')) {
            return new HttpAsset($asset);
        } elseif (str_contains($asset, array('*', '?'))) {
            return new GlobAsset($this->absolutePath($asset));
        } else {
            return new FileAsset($this->absolutePath($asset));
        }
    }
895306
protected function filterCssUrlCb(array $m)
    {
        if (mb_stripos($m['url'], 'data:') === 0) {
            return $m[0]; // Don't filter `data:` URIs.
        }
        return $m['url_'].$m['open_bracket'].$m['open_encap'].$this->hook_api->applyFilters('css_url()', $m['url']).$m['close_encap'].$m['close_bracket'];
    }
1101329
public function asset_render($params) {
        $group = isset($params['group']) ? $params['group'] : null;
        $raw = isset($params['raw']) ? $params['raw'] : false;
        return Asset::render($group, $raw);
    }
605562
public function asset($asset) : string
    {
        if (Str::contains($asset, ':') === false) {
            throw InvalidAssetPath::missingModuleName($asset);
        }
        list($name, $url) = explode(':', $asset);

        $baseUrl = str_replace(public_path() . DIRECTORY_SEPARATOR, '', $this->getAssetsPath());

        $url = $this->app['url']->asset($baseUrl . "/{$name}/" . $url);

        return str_replace(['http://', 'https://'], '//', $url);
    }
41525
public function blockquote_citation_callback($m)
    {
        $line  = ltrim($m[2]);
        $space = $line[0] == '>' ? '' : ' ';

        return $m[1] . '>' . $space . $line;
    }
423195
public function asset_js($params) {
        if (!isset($params['refs'])) {
            throw new \UnexpectedValueException("The refs parameter is required.");
        }
        $group = isset($params['group']) ? $params['group'] : null;
        $attrs = isset($params['attrs']) ? $params['attrs'] : array();
        $raw = isset($params['raw']) ? $params['raw'] : false;
        return Asset::js($params['refs'], $attrs, $group, $raw);
    }
885714
public function parse()
    {
        $time   = time();
        $gmdate = gmdate('D, d M Y H:i:s', $time);

        Container::get('response')
            ->setHeader('MDE-Version', \MarkdownExtended\MarkdownExtended::MDE_VERSION)
            ->setHeader('Last-Modified', $gmdate.' GMT')
        ;

        $etag       = '';
        $sources    = $this->getSources();
        $options    = Container::get('request')->getData('options', array());
        $format     = Container::get('request')->getData('format');
        $extract    = Container::get('request')->getData('extract', 'full');
        if (!empty($format)) {
            $options['output_format'] = $format;
        }
        if (!empty($sources)) {
            try {
                foreach ($sources as $index=>$source) {

                    /* @var \MarkdownExtended\Content $mde_content */
                    $mde_content = Helper::parseMdeSource($source, $options);
                    //var_export($mde_content);

                    switch ($extract) {
                        case 'metadata':
                            $parsed_content = $mde_content->getMetadataToString();
                            break;
                        case 'body':
                            $parsed_content = $mde_content->getBody();
                            break;
                        case 'notes':
                            $parsed_content = $mde_content->getNotesToString();
                            break;
                        case 'full':
                        default:
                            $parsed_content =
                                $mde_content->getMetadataToString()
                                .PHP_EOL
                                .$mde_content->getBody()
                                .PHP_EOL
                                .$mde_content->getNotesToString()
                            ;
                            break;
                    }
                    $etag .= $source.'='.$parsed_content.';';

                    $content_index = $this->addContent($parsed_content);
                    if ($this->getSourceType() == 'file' && is_string($index)) {
                        $source = $index;
                    }
                    if ($content_index !== $index) {
                        $this
                            ->unsetSource($index)
                            ->setSource($content_index, $source)
                        ;
                    }
                }
            } catch (\Exception $e) {
                throw $e;
            }
            $etag = md5($etag);
            Container::get('response')->setHeader('ETag', $etag);

        }

        // if not modified, fetch headers and exit
        $if_modified_since  = Container::get('request')->getHeader('If-Modified-Since');
        $if_none_match      = Container::get('request')->getHeader('If-None-Match');
        if (
            (!empty($if_modified_since) && @strtotime($if_modified_since) >= $time) ||
            (!empty($if_none_match) && !empty($etag) && trim($if_none_match) == $etag)
        ) {
            Container::get('response')
                ->setStatus(Response::STATUS_NOT_MODIFIED)
                ->fetchHeaders()
            ;
            exit(PHP_EOL);
        }

        return $this;
    }
119302
protected function _parseExtendsCallback($m) {
        $m[1] = $this->_parseVariableInParameters($m[1]);

        $file = $this->resolve(RESOLVE_TEMPLATE, $m[1]) . '.tpl';

        if ($this->_template->getFile() != $file) {
            if (file_exists($file)) {
                if (isset($m[4])) //precised time cache
                {
                    $this->_parent = new Template($m[1], 'tplExtends_' . $this->_template->getName() . '_' . $m[4] . '_' . Request::instance()->lang, $m[4]);
                }
                else {
                    $this->_parent = new Template($m[1], 'tplExtends_' . $this->_template->getName() . '_' . Request::instance()->lang, 0);
                }

                $this->_parent->assign($this->_template->vars);
            }
            else {
                $this->addError('The template can\'t be extended by "' . $file . '"', __FILE__, __LINE__, ERROR_FATAL);
            }
        }
    }
1170540
protected function _parseRelativePathCss($m) {
        /**
         * We take the page. Each time we have a '../' in a path file in the css, we drop a folder of the parent file. Zxample :
         *   css file : css/dossier/truc/test.css
         *   image file in css : ../../test.png
         *   we have two ../ so we delete two folder : css/test/test.png
         */

        $pathReplace = '';

        if (!preg_match('~(?:f|ht)tps?://~i', $m[1]) && !preg_match('~(data)~i', $m[1])) {
            //we clear the '/' at the beginning
            $m[1] = preg_replace("#^/#isU", '', $m[1]);
            $m[1] = str_replace('"', '', $m[1]);
            $m[1] = str_replace("'", '', $m[1]);
            $this->_currentPath = preg_replace("#^/#isU", '', $this->_currentPath);

            //on count the number of '../'
            $numberParentDir = substr_count($m[1], '../');

            if ($numberParentDir > 0) {
                for ($i = 0; $i < $numberParentDir; $i++) {
                    $pathReplace .= '(.[^\/]+)\/';
                }

                $pathReplace .= '$';
                $newCurrentPath = preg_replace('#' . $pathReplace . '#isU', '/', $this->_currentPath);
                $m[1] = preg_replace('#\.\./#isU', '', $m[1]);

                if ($newCurrentPath != $this->_currentPath) {
                    $m[1] = $newCurrentPath . $m[1];
                }
                else if (!preg_match('#^' . preg_quote($newCurrentPath) . '#isU', $m[1])) {
                    if (!preg_match('#^/asset#isU', $m[1]) && !preg_match('#^asset#isU', $m[1])) {
                        $m[1] = $newCurrentPath . $m[1];
                    }
                }
            }

            if (!preg_match('#^/#isU', $m[1])) {
                $m[1] = '/' . $m[1];
            }

            if (Config::config()['user']['output']['https']) {
                return 'https://' . str_replace('//', '/', $_SERVER['HTTP_HOST'] . '/' . Config::config()['user']['framework']['folder'] . $m[1]);
            }
            else {
                return 'http://' . str_replace('//', '/', $_SERVER['HTTP_HOST'] . '/' . Config::config()['user']['framework']['folder'] . $m[1]);
            }
        }
        else {
            return $m[1];
        }
    }
1290226
public function AssetAction () {
		$ext = '';
		$path = $this->GetParam('path', 'a-zA-Z0-9_\-\/\.');
		$path = '/' . ltrim(str_replace('..', '', $path), '/');
		if (
			strpos($path, static::$staticPath) !== 0 &&
			strpos($path, static::$tmpPath) !== 0
		) {
			throw new \ErrorException("[".get_class($this)."] File path: '$path' is not allowed.", 500);
		}
		$path = $this->request->GetAppRoot() . $path;
		if (!file_exists($path)) {
			throw new \ErrorException("[".get_class($this)."] File not found: '$path'.", 404);
		}
		$lastDotPos = strrpos($path, '.');
		if ($lastDotPos !== FALSE) {
			$ext = substr($path, $lastDotPos + 1);
		}
		if (isset(self::$_assetsMimeTypes[$ext])) {
			header('Content-Type: ' . self::$_assetsMimeTypes[$ext]);
		}
		header_remove('X-Powered-By');
		header('Vary: Accept-Encoding');
		$assetMTime = @filemtime($path);
		if ($assetMTime) header('Last-Modified: ' . gmdate('D, d M Y H:i:s T', $assetMTime));
		readfile($path);
		exit;
	}
131027
public function findFallbackAsset($asset, $Folder = null)
    {
        $folderEmpty = empty($Folder);
        $folderAllowFallback = ! empty($Folder) && $Folder->getFallback();

        if ($folderEmpty || $folderAllowFallback) {
            $fallbackPath = $this->engine->getDirectory();

            $fallbackPath = $this->removeViewFromPath($fallbackPath);
            if (file_exists($fallbackPath . DS . $asset)) {
                $this->createSymlink($fallbackPath);

                return '/' . $this->assetDir . '/' . $this->asset['asset'];
            }
        }

        return false;
    }
1277164
public static function parse_html_value( $mf, $property ) {
		if ( ! array_key_exists( $property, $mf['properties'] ) ) {
			return null;
		}
		$textcontent = false;
		$htmlcontent = false;
		$content     = $mf['properties'][ $property ][0];
		if ( is_string( $content ) ) {
			$textcontent = $content;
		} elseif ( ! is_string( $content ) && is_array( $content ) && array_key_exists( 'value', $content ) ) {
			if ( array_key_exists( 'html', $content ) ) {
				$htmlcontent = trim( wp_kses_post( $content['html'] ) );
				$textcontent = trim( str_replace( '&#xD;', "\r", $content['value'] ) );
			} else {
				$textcontent = trim( $content['value'] );
			}
		}
		$data = array(
			'text' => $textcontent,
		);
		if ( $htmlcontent && $textcontent !== $htmlcontent ) {
			$data['html'] = $htmlcontent;
		}
		return $data;
	}
909073
protected function handleAssetRequest(array $params)
    {
        $response = new Response();

        $assetsConf = $this->config->getSection('asset_resolv');
        $assetsDir  = $this->config->get('app.public_dir') . '/assets';

        if (! empty($assetsConf['current'])) {
            $file = $assetsDir . '/' . $assetsConf['current'] . '/' . $params['filename'];

            if (file_exists($file)) {
                $fileResource = new Http\File\File($file);
                $mtime = filemtime($fileResource->getPathname());

                $response->headers->set('Content-Type', $fileResource->getMimeType());
                $response->setContent(file_get_contents($fileResource->getPathname()));
                $response->setCache(array(
                    'public' => true,
                    'last_modified' => new \DateTime(gmdate("D, d M Y H:i:s", $mtime))
                ));

                $response->setExpires(new \DateTime(gmdate("D, j M Y H:i:s", time() + MONTH)));
                $response->isNotModified($this->request);

                return $response;
            }
        } elseif (! empty($assetsConf['fallback'])) {

        }
    }
753695
protected function _parseTemplateCallback($m) {
        if (!class_exists('block' . $m[1])) {
            $vars = explode(',', $m[2]);
            $varList = '';

            foreach ($vars as $value) {
                if ($value == '*') {
                    foreach ($this->_template->vars as $key => $value2) {
                        if (!in_array('$' . $key, $vars)) {
                            $varList .= '$' . $key . ',';
                        }
                        else {
                            $this->addError('the template function "template' . $m[1] . '" has already this parameter (' . $value . ')', __FILE__, __LINE__, ERROR_FATAL);
                            $varList .= '$' . $key . ',';
                        }
                    }
                }
                else {
                    $varList .= $value . ',';
                }
            }

            $varList = trim($varList, ',');

            $blockFunction = '<?php class template' . $m[1] . ' extends Gcs\Framework\Core\Template\Template{  ' . "\n";
            $blockFunction .= '		public function __construct(){' . "\n";
            $blockFunction .= '		}' . "\n";
            $blockFunction .= '		public function ' . $m[1] . '(' . $varList . '){ ?> ' . "\n";
            $blockFunction .= '			' . $m[3] . "\n";
            $blockFunction .= ' <?php } } ?>';

            return $blockFunction;
        }
        else {
            $this->addError('the class "template' . $m[1] . '" already exists', __FILE__, __LINE__, ERROR_FATAL);

            return '';
        }
    }
1104076
function parse($key = '') {
    global $messageStack;

    if (isset($_FILES[$this->file])) {
      if (zen_not_null($key)) {
        $file = array('name' => $_FILES[$this->file]['name'][$key],
        'type' => $_FILES[$this->file]['type'][$key],
        'size' => $_FILES[$this->file]['size'][$key],
        'tmp_name' => $_FILES[$this->file]['tmp_name'][$key]);
      } else {
        $file = array('name' => $_FILES[$this->file]['name'],
        'type' => $_FILES[$this->file]['type'],
        'size' => $_FILES[$this->file]['size'],
        'tmp_name' => $_FILES[$this->file]['tmp_name']);
      }
    } elseif (isset($GLOBALS['HTTP_POST_FILES'][$this->file])) {
      global $HTTP_POST_FILES;

      $file = array('name' => $HTTP_POST_FILES[$this->file]['name'],
      'type' => $HTTP_POST_FILES[$this->file]['type'],
      'size' => $HTTP_POST_FILES[$this->file]['size'],
      'tmp_name' => $HTTP_POST_FILES[$this->file]['tmp_name']);
    } else {
      $file = array('name' => (isset($GLOBALS[$this->file . '_name']) ? $GLOBALS[$this->file . '_name'] : ''),
      'type' => (isset($GLOBALS[$this->file . '_type']) ? $GLOBALS[$this->file . '_type'] : ''),
      'size' => (isset($GLOBALS[$this->file . '_size']) ? $GLOBALS[$this->file . '_size'] : ''),
      'tmp_name' => (isset($GLOBALS[$this->file]) ? $GLOBALS[$this->file] : ''));
    }
    //if (!zen_not_null($file['tmp_name'])) return false;
    //if ($file['tmp_name'] == 'none') return false;
    //if (!is_uploaded_file($file['tmp_name'])) return false;

// not working at this time to test for server limit error
    if (!is_uploaded_file($file['tmp_name'])) {
      if ($this->message_location == 'direct') {
        $messageStack->add_session('header', WARNING_NO_FILE_UPLOADED, 'warning');
      } else {
        $messageStack->add_session('upload', WARNING_NO_FILE_UPLOADED, 'warning');
      }
      return false;
    }

    if ( zen_not_null($file['tmp_name']) && ($file['tmp_name'] != 'none') && is_uploaded_file($file['tmp_name']) ) {
      if (zen_not_null($file['size']) and ($file['size'] > MAX_FILE_UPLOAD_SIZE)) {
        if ($this->message_location == 'direct') {
          $messageStack->add_session('header', ERROR_FILE_TOO_BIG, 'error');
        } else {
          $messageStack->add_session('upload', ERROR_FILE_TOO_BIG, 'error');
        }
        return false;
      }
      if (substr($file['name'], -9) == '.htaccess' || (sizeof($this->extensions) > 0 && !in_array(strtolower(substr($file['name'], strrpos($file['name'], '.')+1)), $this->extensions))) {
          if ($this->message_location == 'direct') {
            $messageStack->add_session('header', ERROR_FILETYPE_NOT_ALLOWED . ' ' . UPLOAD_FILENAME_EXTENSIONS, 'error');
          } else {
            $messageStack->add_session('upload', ERROR_FILETYPE_NOT_ALLOWED . ' - ' . UPLOAD_FILENAME_EXTENSIONS, 'error');
          }
          return false;
      }

      $this->set_file($file);
      $this->set_filename($file['name']);
      $this->set_tmp_filename($file['tmp_name']);

      return $this->check_destination();
    } else {
      if ($this->message_location == 'direct') {
        $messageStack->add_session('header', WARNING_NO_FILE_UPLOADED, 'warning');
      } else {
        $messageStack->add_session('upload', WARNING_NO_FILE_UPLOADED, 'warning');
      }
      return false;
    }
  }