Beispiel #1
0
 /**
  * Twig Markup Filter 'flipCss'
  * @param $paths
  * @param bool $force
  * @return array|string
  */
 public function flipCss($paths)
 {
     if (!LanguageDetector::isRtl()) {
         return $paths;
     }
     if (!is_array($paths)) {
         $paths = [$paths];
     }
     $rPaths = [];
     foreach ($paths as $path) {
         $assetPath = $path;
         if (File::exists(dirname($assetPath) . '/' . File::name($assetPath) . '.rtl.' . File::extension($assetPath))) {
             $newPath = dirname($assetPath) . '.rtl.' . File::extension($assetPath);
         } else {
             $newPath = CssFlipper::flipCss($assetPath, true);
         }
         $rPaths[] = $newPath;
     }
     return $rPaths;
 }
Beispiel #2
0
 /**
  * Generate a URL to an application asset.
  *
  * @param  string $path
  * @param  bool|null $secure
  * @return string
  */
 public function asset($path, $secure = null)
 {
     if ($this->isValidUrl($path)) {
         return $path;
     }
     if (!LanguageDetector::isRtl()) {
         return parent::asset($path, $secure);
     }
     if (!strpos($path, '/rtlweb/rtler/assets/css/rtl.css')) {
         $backendUri = Config::get('cms.backendUri', 'backend');
         $requestUrl = Request::url();
         if (File::exists(base_path(dirname($path)) . '.rtl.' . File::extension($path))) {
             $path = dirname($path) . '.rtl.' . File::extension($path);
         } else {
             if (File::extension($path) == 'css' && (strpos($requestUrl, $backendUri) || strpos($path, 'plugins/') || strpos($path, 'modules/'))) {
                 $path = CssFlipper::flipCss($path);
             }
         }
     }
     return parent::asset($path, $secure);
 }
Beispiel #3
0
<?php

\App::before(function ($request) {
    \RtlWeb\Rtler\Classes\LanguageDetector::detect();
});