Loads a Nails package asset (as a relative url from NAILS_ASSETS_URL . 'packages/')

@param  string $sAsset     The asset to load
@param  string $sForceType Force a particular type of asset (i.e. JS or CSS)

@return void
431831
protected function loadNailsPackage($sAsset, $sForceType)
    {
        $sType = $this->determineType($sAsset, $sForceType);

        switch ($sType) {

            case 'CSS':

                $this->aCss['NAILS-PACKAGE-' . $sAsset] = NAILS_ASSETS_URL . 'packages/' . $sAsset;
                break;

            case 'JS':

                $this->aJs['NAILS-PACKAGE-' . $sAsset] = NAILS_ASSETS_URL . 'packages/' . $sAsset;
                break;
        }
    }
518798
protected function unloadNails($sAsset, $sForceType)
    {
        $sType = $this->determineType($sAsset, $sForceType);

        switch ($sType) {

            case 'CSS':

                unset($this->aCss['NAILS-' . $sAsset]);
                break;

            case 'JS':

                unset($this->aJs['NAILS-' . $sAsset]);
                break;
        }
    }
169946
protected function LoadFromBasketPostProcessData($oBasket, &$aOrderData)
    {
        parent::LoadFromBasketPostProcessData($oBasket, $aOrderData);
        $oUser = TdbDataExtranetUser::GetInstance();
        $oShipping = $oUser->GetShippingAddress();
        $aOrderData['adr_shipping_is_dhl_packstation'] = $oShipping->fieldIsDhlPackstation;
    }
934114
protected function getResource(string $sFile, array $aFields): string
    {
        if (empty(static::RESOURCE_PATH)) {
            throw new NailsException('RESOURCE_PATH is not defined');
        }
        $sResource = require static::RESOURCE_PATH . $sFile;

        foreach ($aFields as $sField => $sValue) {
            $sKey      = '{{' . strtoupper($sField) . '}}';
            $sResource = str_replace($sKey, $sValue, $sResource);
        }

        return $sResource;
    }
359210
protected function loadNailsBower($sAsset, $sForceType)
    {
        $sType = $this->determineType($sAsset, $sForceType);

        switch ($sType) {

            case 'CSS':

                $this->aCss['NAILS-BOWER-' . $sAsset] = NAILS_ASSETS_URL . $this->sBowerDir . $sAsset;
                break;

            case 'JS':

                $this->aJs['NAILS-BOWER-' . $sAsset] = NAILS_ASSETS_URL . $this->sBowerDir . $sAsset;
                break;
        }
    }
579055
public function output($sType = 'ALL', $bOutput = true)
    {
        $aOut  = [];
        $sType = strtoupper($sType);

        //  Linked Stylesheets
        if (!empty($this->aCss) && ($sType == 'CSS' || $sType == 'ALL')) {

            foreach ($this->aCss as $sAsset) {
                $sAsset = $this->addCacheBuster($sAsset);
                $aOut[] = link_tag($sAsset);
            }
        }

        // --------------------------------------------------------------------------

        //  Linked JS
        if (!empty($this->aJs) && ($sType == 'JS' || $sType == 'ALL')) {

            foreach ($this->aJs as $sAsset) {
                $sAsset = $this->addCacheBuster($sAsset);
                $aOut[] = '<script src="' . $sAsset . '"></script>';
            }
        }

        // --------------------------------------------------------------------------

        //  Inline CSS
        if (!empty($this->aCssInline) && ($sType == 'CSS-INLINE' || $sType == 'ALL')) {

            $aOut[] = '<style type="text/css">';
            foreach ($this->aCssInline as $sAsset) {
                $aOut[] = preg_replace('/<\/?style.*?>/si', '', $sAsset);
            }
            $aOut[] = '</style>';
        }

        // --------------------------------------------------------------------------

        //  Inline JS (Header)
        if (!empty($this->aJsInlineHeader) && ($sType == 'JS-INLINE-HEADER' || $sType == 'ALL')) {
            $aOut[] = '<script>';
            foreach ($this->aJsInlineHeader as $sAsset) {
                $aOut[] = preg_replace('/<\/?script.*?>/si', '', $sAsset);
            }
            $aOut[] = '</script>';
        }

        // --------------------------------------------------------------------------

        //  Inline JS (Footer)
        if (!empty($this->aJsInlineFooter) && ($sType == 'JS-INLINE-FOOTER' || $sType == 'ALL')) {
            $aOut[] = '<script>';
            foreach ($this->aJsInlineFooter as $sAsset) {
                $aOut[] = preg_replace('/<\/?script.*?>/si', '', $sAsset);
            }
            $aOut[] = '</script>';
        }

        // --------------------------------------------------------------------------

        //  Force SSL for assets if page is secure
        if (Functions::isPageSecure()) {
            foreach ($aOut as &$sLine) {
                $sLine = str_replace($this->sBaseUrl, $this->sBaseUrlSecure, $sLine);
            }
        }

        // --------------------------------------------------------------------------

        if ($bOutput) {
            echo implode("\n", $aOut);
        }

        return $aOut;
    }
569026
function resolveSassPath(sassPath, loadPaths, extensions) {
  // trim sass file extensions
  var re = new RegExp('(\.('+extensions.join('|')+'))$', 'i');
  var sassPathName = sassPath.replace(re, '');
  // check all load paths
  var i, j, length = loadPaths.length, scssPath, partialPath;
  for (i = 0; i < length; i++) {
    for (j = 0; j < extensions.length; j++) {
      scssPath = path.normalize(loadPaths[i] + '/' + sassPathName + '.' + extensions[j]);
      try {
        if (fs.lstatSync(scssPath).isFile()) {
          return scssPath;
        }
      } catch (e) {}
    }

    // special case for _partials
    for (j = 0; j < extensions.length; j++) {
      scssPath = path.normalize(loadPaths[i] + '/' + sassPathName + '.' + extensions[j]);
      partialPath = path.join(path.dirname(scssPath), '_' + path.basename(scssPath));
      try {
        if (fs.lstatSync(partialPath).isFile()) {
          return partialPath;
        }
      } catch (e) {}
    }
  }

  // File to import not found or unreadable so we assume this is a custom import
  return false;
}
351328
protected function loadSomeFixtures($selectedFixtures)
    {
        $fixtures = glob("{$this->config['location']}/*.php");

        foreach ($fixtures as $fixture) {
            $tableName = basename($fixture, '.php');

            if (in_array($tableName, $selectedFixtures)) {
                $this->loadFixture($fixture);
            }
        }
    }
1149081
private function loadAssetsFromConfig($content, $dir, $type = null, $isFromVendor = false, $siteName = '')
    {
        $newContent = $content;
        $assetsConfig = $dir.'assets.config.php';
        /**
         * check if the config exist
         */
        if (file_exists($assetsConfig)) {
            $files = include($assetsConfig);
            /**
             * check if assets config is not empty
             */
            if (!empty($files)) {
                foreach($files as $key => $file){
                    /**
                     * check if type to know what asset are
                     * we going to load
                     */
                    if(empty($type)) {
                        /**
                         * this will load the assets from the config
                         */
                        $cssToAdd = "\n";
                        $jsToLoad = "\n";
                        if (strtolower($key) == 'css') {
                            foreach ($file as $k => $css) {
                                $css = str_replace('/public', '', $css);
                                $css = $this->editFileName($css, $isFromVendor, $siteName);
                                $cssToAdd .= '<link href="' . $css . '" media="screen" rel="stylesheet" type="text/css">' . "\n";
                            }
                        }
                        elseif (strtolower($key) == 'js') {
                            foreach ($file as $k => $js) {
                                $js = str_replace('/public', '', $js);
                                $js = $this->editFileName($js, $isFromVendor, $siteName);
                                $jsToLoad .= '<script type="text/javascript" src="' . $js . '"></script>' . "\n";
                            }
                        }
                        $newContent = $this->createLink($newContent, $cssToAdd, $jsToLoad);
                    }
                    elseif($type == 'css'){
                        /**
                         * this will load only the css
                         * from the config
                         */
                        if (strtolower($key) == 'css') {
                            $cssToAdd = "\n";
                            foreach ($file as $k => $css) {
                                $css = str_replace('/public', '', $css);
                                $css = $this->editFileName($css, $isFromVendor, $siteName);
                                $cssToAdd .= '<link href="' . $css . '" media="screen" rel="stylesheet" type="text/css">' . "\n";
                            }
                            $newContent = $this->createCssLink($content, $cssToAdd);
                        }
                    }elseif($type == 'js'){
                        /**
                         * this will load the js only from the config
                         */
                        if (strtolower($key) == 'js') {
                            $jsToLoad = "\n";
                            foreach ($file as $k => $js) {
                                $js = str_replace('/public', '', $js);
                                $js = $this->editFileName($js, $isFromVendor, $siteName);
                                $jsToLoad .= '<script type="text/javascript" src="' . $js . '"></script>' . "\n";
                            }
                            $newContent = $this->createJsLink($content, $jsToLoad);
                        }
                    }
                }
            }
        }
        return $newContent;
    }
1034857
public function addThemeCSSFile($filename, $type=null) {
		$this->addCSSURL($this->getCSSURL().$filename, $type);
	}
44126
protected function unloadAppPackage($sAsset, $sForceType)
    {
        $sType = $this->determineType($sAsset, $sForceType);

        switch ($sType) {

            case 'CSS':

                unset($this->aCss['APP-PACKAGE-' . $sAsset]);
                break;

            case 'JS':

                unset($this->aJs['APP-PACKAGE-' . $sAsset]);
                break;
        }
    }
566158
protected function loadSubset($subset)
    {
        $subsetStoragePath = $this->storagePath . DIRECTORY_SEPARATOR . $subset . '.json';
        $json = file_get_contents($subsetStoragePath);
        $json = json_decode($json);
        $this->$subset = $json;
        return $json;
    }
983042
protected function loadAppBower($sAsset, $sForceType)
    {
        $sType = $this->determineType($sAsset, $sForceType);

        switch ($sType) {

            case 'CSS':

                $this->aCss['APP-BOWER-' . $sAsset] = $this->sBaseUrl . $this->sBowerDir . $sAsset;
                break;

            case 'JS':

                $this->aJs['APP-BOWER-' . $sAsset] = $this->sBaseUrl . $this->sBowerDir . $sAsset;
                break;
        }
    }
687555
function sassLoader(content) {
  const callback = this.async();
  const isSync = typeof callback !== 'function';
  const self = this;
  const { resourcePath } = this;

  function addNormalizedDependency(file) {
    // node-sass returns POSIX paths
    self.dependency(path.normalize(file));
  }

  if (isSync) {
    throw new Error(
      'Synchronous compilation is not supported anymore. See https://github.com/webpack-contrib/sass-loader/issues/333'
    );
  }

  let resolve = pify(this.resolve);

  // Supported since v4.27.0
  if (this.getResolve) {
    resolve = this.getResolve({
      mainFields: ['sass', 'main'],
      extensions: ['.scss', '.sass', '.css'],
    });
  }

  const options = normalizeOptions(
    this,
    content,
    webpackImporter(resourcePath, resolve, addNormalizedDependency)
  );

  // Skip empty files, otherwise it will stop webpack, see issue #21
  if (options.data.trim() === '') {
    callback(null, '');
    return;
  }

  const render = getRenderFuncFromSassImpl(
    // eslint-disable-next-line import/no-extraneous-dependencies, global-require
    options.implementation || getDefaultSassImpl()
  );

  render(options, (err, result) => {
    if (err) {
      formatSassError(err, this.resourcePath);

      if (err.file) {
        this.dependency(err.file);
      }

      callback(err);
      return;
    }

    if (result.map && result.map !== '{}') {
      // eslint-disable-next-line no-param-reassign
      result.map = JSON.parse(result.map);
      // result.map.file is an optional property that provides the output filename.
      // Since we don't know the final filename in the webpack build chain yet, it makes no sense to have it.
      // eslint-disable-next-line no-param-reassign
      delete result.map.file;
      // One of the sources is 'stdin' according to dart-sass/node-sass because we've used the data input.
      // Now let's override that value with the correct relative path.
      // Since we specified options.sourceMap = path.join(process.cwd(), "/sass.map"); in normalizeOptions,
      // we know that this path is relative to process.cwd(). This is how node-sass works.
      // eslint-disable-next-line no-param-reassign
      const stdinIndex = result.map.sources.findIndex(
        (source) => source.indexOf('stdin') !== -1
      );

      if (stdinIndex !== -1) {
        result.map.sources[stdinIndex] = path.relative(
          process.cwd(),
          resourcePath
        );
      }
      // node-sass returns POSIX paths, that's why we need to transform them back to native paths.
      // This fixes an error on windows where the source-map module cannot resolve the source maps.
      // @see https://github.com/webpack-contrib/sass-loader/issues/366#issuecomment-279460722
      // eslint-disable-next-line no-param-reassign
      result.map.sourceRoot = path.normalize(result.map.sourceRoot);
      // eslint-disable-next-line no-param-reassign
      result.map.sources = result.map.sources.map(path.normalize);
    } else {
      // eslint-disable-next-line no-param-reassign
      result.map = null;
    }

    result.stats.includedFiles.forEach(addNormalizedDependency);

    callback(null, result.css.toString(), result.map);
  });
}
208895
public static function setNailsConstants()
    {
        //  Generic and branding constants
        Functions::define('NAILS_PACKAGE_NAME', 'Nails');
        Functions::define('NAILS_PACKAGE_URL', 'http://nailsapp.co.uk/');
        Functions::define('NAILS_BRANDING', true);

        //  Paths
        Functions::define('NAILS_PATH', static::$sBaseDirectory . 'vendor/nails/');
        Functions::define('NAILS_APP_PATH', static::$sBaseDirectory);
        Functions::define('NAILS_COMMON_PATH', NAILS_PATH . 'common/');
        Functions::define('NAILS_CI_APP_PATH', static::$sBaseDirectory . 'vendor/codeigniter/framework/application/');
        Functions::define('NAILS_CI_SYSTEM_PATH', static::$sBaseDirectory . 'vendor/codeigniter/framework/system/');

        //  So CodeIgniter configures itself correctly
        Functions::define('BASEPATH', NAILS_CI_SYSTEM_PATH);

        //  URLs
        Functions::define('BASE_URL', '/');
        Functions::define('SECURE_BASE_URL', preg_replace('/^http:/', 'https:', BASE_URL));
        Functions::define('NAILS_URL', (Functions::isPageSecure() ? SECURE_BASE_URL : BASE_URL) . 'vendor/nails/');

        //  @todo (Pablo - 2018-11-16) - Move these into the asset service
        Functions::define('NAILS_ASSETS_URL', NAILS_URL . 'module-asset/assets/');
        Functions::define('NAILS_ASSETS_PATH', NAILS_PATH . 'module-asset/assets/');

        //  Environment
        Functions::define('ENVIRONMENT', Environment::ENV_DEV);
        Functions::define('NAILS_TIMEZONE', 'UTC');

        //  Cache constants
        //  @todo (Pablo - 2018-11-16) - Move these to the cache service
        Functions::define('CACHE_PATH', static::$sBaseDirectory . 'cache' . DIRECTORY_SEPARATOR . 'private' . DIRECTORY_SEPARATOR);
        Functions::define('CACHE_PUBLIC_PATH', static::$sBaseDirectory . 'cache' . DIRECTORY_SEPARATOR . 'public' . DIRECTORY_SEPARATOR);
        Functions::define('CACHE_PUBLIC_URL', rtrim(BASE_URL, '/') . '/cache/public/');

        //  Database
        //  @todo (Pablo - 2018-11-16) - Move these to the database service

        //  Consistent between deployments
        Functions::define('APP_DB_DRIVER', 'mysqli');
        Functions::define('APP_DB_GLOBAL_PREFIX', '');
        Functions::define('APP_DB_PCONNECT', true);
        Functions::define('APP_DB_CACHE', false);
        Functions::define('APP_DB_CHARSET', 'utf8mb4');
        Functions::define('APP_DB_DBCOLLAT', 'utf8mb4_unicode_ci');
        Functions::define('APP_DB_STRICT', true);
        Functions::define('NAILS_DB_PREFIX', 'nails_');
        Functions::define('APP_DB_PREFIX', '');

        //  Potentially vary between deployments
        Functions::define('DEPLOY_DB_HOST', 'localhost');
        Functions::define('DEPLOY_DB_USERNAME', '');
        Functions::define('DEPLOY_DB_PASSWORD', '');
        Functions::define('DEPLOY_DB_DATABASE', '');

        //  App Constants
        Functions::define('APP_PRIVATE_KEY', '');
        Functions::define('APP_NAME', 'Untitled');
        Functions::define('APP_NATIVE_LOGIN_USING', 'BOTH');   //  [EMAIL|USERNAME|BOTH]

        //  Log constants
        //  @todo (Pablo - 2018-11-16) - Move these to the log service
        Functions::define('DEPLOY_LOG_DIR', static::$sBaseDirectory . 'application/logs/');

        //  Email constants
        Functions::define('APP_DEVELOPER_EMAIL', '');
        Functions::define('EMAIL_OVERRIDE', '');
        Functions::define('EMAIL_WHITELIST', '');
        Functions::define('DEPLOY_EMAIL_HOST', '127.0.0.1');
        Functions::define('DEPLOY_EMAIL_USER', '');
        Functions::define('DEPLOY_EMAIL_PASS', '');
        Functions::define('DEPLOY_EMAIL_PORT', 25);

        //  Ensure the app's constants file is also loaded
        //  @todo (Pablo - 2018-11-16) - Remove reliance on this feature
        if (is_file(static::$sBaseDirectory . 'application/config/constants.php')) {
            require_once static::$sBaseDirectory . 'application/config/constants.php';
        }
    }
1259275
public function setType(string $type)
    {
        $types = [
            self::TYPE_FILE,
            self::TYPE_INLINE
        ];

        if (!in_array($type, $types)) {
            Throw new CssException('Css type must be "inline" or "file".');
        }

        $this->type = $type;
    }
168223
protected function loadAppPackage($sAsset, $sForceType)
    {
        $sType = $this->determineType($sAsset, $sForceType);

        switch ($sType) {

            case 'CSS':

                $this->aCss['APP-PACKAGE-' . $sAsset] = $this->sBaseUrl . 'packages/' . $sAsset;
                break;

            case 'JS':

                $this->aJs['APP-PACKAGE-' . $sAsset] = $this->sBaseUrl . 'packages/' . $sAsset;
                break;
        }
    }