<commit_before><?php

App::uses('Folder', 'Utility');
App::uses('File', 'Utility');

/**
 * Description of HuradPlugin
 *
 * @author mohammad
 */
class HuradPlugin {

    public static function getPluginData() {
        $dir = new Folder(APP . DS . 'Plugin');
        $files = $dir->read(true, array('empty'));
        foreach ($files[0] as $i => $folder) {
            $file = new File(APP . 'Plugin' . DS . $folder . DS . 'Config' . DS . 'info.xml');
            if ($file->exists()) {
                $fileContent = $file->read();
                $plugin = Xml::toArray(Xml::build($fileContent));
                $plugins[$folder] = $plugin['plugin'];
            }
        }

        return $plugins;
    }

    public static function isActive($alias = NULL) {
        if (Configure::check('Plugins')) {
            $aliases = Configure::read('Plugins');
            $aliases = explode(',', $aliases);

            return in_array($alias, $aliases);
        } else {
            return FALSE;
        }
    }

    public static function activate($alias) {
        $aliases = Configure::read('Plugins');
        if (Configure::check('Plugins') && !empty($aliases)) {
            $aliases = explode(',', $aliases);

            if (count($aliases) > 0) {
                $result = Hash::merge($aliases, $alias);
                $plugins = implode(',', $result);
            } else {
                $plugins = $alias;
            }
        } else {
            $plugins = $alias;
        }
        ClassRegistry::init('Option')->write('Plugins', $plugins);
        return TRUE;
    }

    public static function deactivate($alias) {
        if (Configure::check('Plugins')) {
            $aliases = Configure::read('Plugins');
            $aliases = explode(',', $aliases);
            if (count($aliases) > 0) {
                foreach ($aliases as $i => $value) {
                    if ($alias == $value) {
                        $result = Hash::remove($aliases, $i);
                    }
                }
                $plugins = implode(',', $result);
                ClassRegistry::init('Option')->write('Plugins', $plugins);
                return TRUE;
            }
        } else {
            return FALSE;
        }
    }

    public static function delete($alias) {
        $folder = new Folder(APP . 'Plugin' . DS . $alias);
        if ($folder->delete()) {
            return TRUE;
        } else {
            return $folder->errors();
        }
    }

    public static function loadAll() {
        $plugins = Configure::read('Plugins');

        if (Configure::check('Plugins') && !empty($plugins)) {
            $plugins = explode(',', $plugins);
            $config = array();
            foreach ($plugins as $i => $pluginFolder) {
                $bs = new File(APP . 'Plugin' . DS . $pluginFolder . DS . 'Config' . DS . 'bootstrap.php');
                $rt = new File(APP . 'Plugin' . DS . $pluginFolder . DS . 'Config' . DS . 'routes.php');
                if ($bs->exists()) {
                    $config[$pluginFolder]['bootstrap'] = true;
                }
                if ($rt->exists()) {
                    $config[$pluginFolder]['routes'] = true;
                }
                if ($bs->exists() == FALSE && $rt->exists() == FALSE) {
                    $config[$pluginFolder] = array();
                }
            }
            CakePlugin::load($config);
        }
    }

}<commit_msg>Update phpDoc Reformat code<commit_after><?php

App::uses('Folder', 'Utility');
App::uses('File', 'Utility');

/**
 * Class HuradPlugin
 */
class HuradPlugin
{

    public static function getPluginData()
    {
        $dir = new Folder(APP . DS . 'Plugin');
        $files = $dir->read(true, array('empty'));
        foreach ($files[0] as $i => $folder) {
            $file = new File(APP . 'Plugin' . DS . $folder . DS . 'Config' . DS . 'info.xml');
            if ($file->exists()) {
                $fileContent = $file->read();
                $plugin = Xml::toArray(Xml::build($fileContent));
                $plugins[$folder] = $plugin['plugin'];
            }
        }

        return $plugins;
    }

    public static function isActive($alias = null)
    {
        if (Configure::check('Plugins')) {
            $aliases = Configure::read('Plugins');
            $aliases = explode(',', $aliases);

            return in_array($alias, $aliases);
        } else {
            return false;
        }
    }

    public static function activate($alias)
    {
        $aliases = Configure::read('Plugins');
        if (Configure::check('Plugins') && !empty($aliases)) {
            $aliases = explode(',', $aliases);

            if (count($aliases) > 0) {
                $result = Hash::merge($aliases, $alias);
                $plugins = implode(',', $result);
            } else {
                $plugins = $alias;
            }
        } else {
            $plugins = $alias;
        }
        ClassRegistry::init('Option')->write('Plugins', $plugins);
        return true;
    }

    public static function deactivate($alias)
    {
        if (Configure::check('Plugins')) {
            $aliases = Configure::read('Plugins');
            $aliases = explode(',', $aliases);
            if (count($aliases) > 0) {
                foreach ($aliases as $i => $value) {
                    if ($alias == $value) {
                        $result = Hash::remove($aliases, $i);
                    }
                }
                $plugins = implode(',', $result);
                ClassRegistry::init('Option')->write('Plugins', $plugins);
                return true;
            }
        } else {
            return false;
        }
    }

    public static function delete($alias)
    {
        $folder = new Folder(APP . 'Plugin' . DS . $alias);
        if ($folder->delete()) {
            return true;
        } else {
            return $folder->errors();
        }
    }

    public static function loadAll()
    {
        $plugins = Configure::read('Plugins');

        if (Configure::check('Plugins') && !empty($plugins)) {
            $plugins = explode(',', $plugins);
            $config = array();
            foreach ($plugins as $i => $pluginFolder) {
                $bs = new File(APP . 'Plugin' . DS . $pluginFolder . DS . 'Config' . DS . 'bootstrap.php');
                $rt = new File(APP . 'Plugin' . DS . $pluginFolder . DS . 'Config' . DS . 'routes.php');
                if ($bs->exists()) {
                    $config[$pluginFolder]['bootstrap'] = true;
                }
                if ($rt->exists()) {
                    $config[$pluginFolder]['routes'] = true;
                }
                if ($bs->exists() == false && $rt->exists() == false) {
                    $config[$pluginFolder] = array();
                }
            }
            CakePlugin::load($config);
        }
    }

}
{'fraction_non_alphanumeric': 0.16593949970913321, 'fraction_numerical': 0.0008726003490401396, 'mean_word_length': 1.5404506834133727, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2804573', 'n_tokens_mistral': 1935, 'n_tokens_neox': 1865, 'n_words': 410}