octoberfa / oc-persian

OctoberCms Persian Support
MIT License
5 stars 2 forks source link

How to disable flipcss for the backend only #7

Closed ahmeddhifi closed 5 years ago

ahmeddhifi commented 5 years ago

Hello, It'll be nice to have the option to disable the flipcss just for the backend. Most users prefer to user the backend in english while the frontend is localised. THanks

TheServat commented 5 years ago

flipcss is a twig filter if you don't want back-end in rtl mode simply disable or uninstall plugin. you can write a simple plugin for flipcss twig filter with using this class https://github.com/octoberfa/oc-persian/blob/master/classes/CssFlipper.php and add this code in your plugin.php file

class Plugin extends PluginBase
{
    public function register()
    {
        $this->registerMarkupTags();
    }
    public function registerMarkupTags()
    {
        MarkupManager::instance()->registerCallback(function ($manager) {
            $manager->registerFilters([
                'flipCss' => [$this, 'flipCss'],
            ]);
        });
    }

    /**
     * Twig Markup Filter 'flipCss'
     * @param $paths
     * @param bool $force
     * @return array|string
     */
    public function flipCss($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;
    }
}
ahmeddhifi commented 5 years ago

Thank you very much. Appreciated.

Le ven. 3 mai 2019 à 09:43, Sajjad Servatjoo notifications@github.com a écrit :

flipcss is a twig filter if you don't want back-end in rtl mode simply disable or uninstall plugin. you can write a simple plugin for flipcss twig filter with using this class https://github.com/octoberfa/oc-persian/blob/master/classes/CssFlipper.php http://CSSFlipper and add this code in your plugin.php file

class Plugin extends PluginBase{ public function register() { $this->registerMarkupTags(); } public function registerMarkupTags() { MarkupManager::instance()->registerCallback(function ($manager) { $manager->registerFilters([ 'flipCss' => [$this, 'flipCss'], ]); }); } /* Twig Markup Filter 'flipCss' @param $paths @param bool $force @return array|string / public function flipCss($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; }}

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/octoberfa/oc-persian/issues/7#issuecomment-489012372, or mute the thread https://github.com/notifications/unsubscribe-auth/AL34BIVEUJ7WZFCS37N6BFLPTP3JPANCNFSM4HJ6GHKQ .

-- Ahmed DHIFI AAWEB Design & Développement +216 52 790 164