Make dirs' configurations

@param string|bool $code The dir's name (code)
@return array|bool
9752
public function dirs($code=false){
    $all = $this->options->full_soptions(self::_dev_path());
    $cats = [];
    $r = [];
    foreach ( $all as $a ){
      if ( \defined($a['bbn_path']) ){
        $k = $a['bbn_path'] . '/' . ($a['code'] === '/' ? '' : $a['code']);
        if ( !isset($cats[$a['id_alias']]) ){
          unset($a['alias']['cfg']);
          $cats[$a['id_alias']] = $a['alias'];
        }
        unset($a['cfg']);
        unset($a['alias']);
        $r[$k] = $a;
        $r[$k]['title'] = $r[$k]['text'];
        $r[$k]['alias_code'] = $cats[$a['id_alias']]['code'];
        if ( !empty($cats[$a['id_alias']]['tabs']) ){
          $r[$k]['tabs'] = $cats[$a['id_alias']]['tabs'];
        }
        else{
          $r[$k]['extensions'] = $cats[$a['id_alias']]['extensions'];
        }
        unset($r[$k]['alias']);
      }
    }
    if ( $code ){
      return isset($r[$code]) ? $r[$code] : false;
    }
    return $r;
  }
919481
public function binDir($dir = '')
    {
        if (!empty($dir)) {
            $this->binary_dir = Config::setBinDirectory($dir);

            return $this;
        }
        elseif ($dir == C::DFT) {
            $this->binary_dir = Config::setBinDirectory(Config::getBinDirectory());
        }

        return Config::getBinDirectory();
    }
1013772
public static function getHierarchyNextChild($code)
    {
        $hierarchyField = static::getHierarchyField();
        $child_length = static::getHierarchyChildLength($code);
        if ($child_length < 0) {
            return false;
        }

        $max = static::query()->whereStartsWith($hierarchyField, $code, $child_length)->max($hierarchyField);
        if ($max === null) {
            return $code . str_pad('', $child_length - strlen($code) - 1, '0') . '1';
        } else {
            return static::_calcHierarchyNextChild($max);
        }
    }
979231
private function codeToMessage($code) {
        // get the error message belong to the given code
        switch ($code) {
            case \Th\FileDownloader::FILE_WRONG_MIME:
                $message = "File is of the wrong MIME type";
                break;
            case \Th\FileDownloader::FILE_WRONG_EXTENSION:
                $message = "File is of the wrong extension";
                break;
            case \Th\FileDownloader::INVALID_DOWNLOAD_DIR:
                $message = "User set download directory does not exist";
                break;
            default:
                $message = "Unknown download error";
                break;
        }

        // done, return the error message
        return $message;
    }
1246697
public function setCode($code) {
        $this->code = trim($code);
        $this->codeLength = strlen($this->code);
        return $this;
    }
1093351
public static function get_members_by_permission($code)
    {
        $toplevelGroups = self::get_groups_by_permission($code);
        if (!$toplevelGroups) {
            return new ArrayList();
        }

        $groupIDs = array();
        foreach ($toplevelGroups as $group) {
            $familyIDs = $group->collateFamilyIDs();
            if (is_array($familyIDs)) {
                $groupIDs = array_merge($groupIDs, array_values($familyIDs));
            }
        }

        if (empty($groupIDs)) {
            return new ArrayList();
        }

        $groupClause = DB::placeholders($groupIDs);
        /** @skipUpgrade */
        $members = Member::get()
            ->where(array("\"Group\".\"ID\" IN ($groupClause)" => $groupIDs))
            ->leftJoin("Group_Members", '"Member"."ID" = "Group_Members"."MemberID"')
            ->leftJoin("Group", '"Group_Members"."GroupID" = "Group"."ID"');

        return $members;
    }
664236
public function findByCode($code)
    {
        foreach ($this->sections as $section) {
            if ($section->getCharCodeFrom() <= $code && $section->getCharCodeTo() >= $code) {
                return $section;
            }
        }

        return null;
    }
373111
public function getAuth($code)
    {
        $result = $this->_curl(
            'https://api.weixin.qq.com/sns/oauth2/access_token',
            [
                'appid' => $this->getConfig('appid'),
                'secret' => $this->getConfig('secret'),
                'code' => $code,
                'grant_type' => 'authorization_code',
            ]
        );

        if ($result) {
            return [
                'access_token' => $result['access_token'],
                'openid' => $result['openid'],
            ];
        }

        return false;
    }
475442
public function ls($dir = '')
    {
        if ($dir == '' || substr($dir, 0, 1) !== '/') {
            $dir = $this->dir . '/' . $dir;
        }

        if ($this->driver->sftpIsDir($this->resource, $dir)) {
            $handle = $this->driver->sftpOpenDir($this->resource, $dir);
            $files = array();
            while (false !== ($file = $this->driver->sftpReadDir($handle))) {
                if (substr("$file", 0, 1) != '.') {
                    $files[] = $file;
                }
            }

            //finished searching the directory
            return $files;
        }

        //if IsDir fails that means its either not a directory or doesnt exist
        if (!$this->driver->sftpFileExists($this->resource, $dir)) {
            $this->errorHandler->register("$dir does not exist.", 0);

            return false;
        }

        $this->errorHandler->register("$dir is not a directory", 0);

        return false;
    }
584387
private function optimizeScriptCode($code)
	{
		if (YII_DEBUG)
			return $code;
		require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'JSMin.php';
		$minified = JSMin::minify($code);

		return ($minified === false ? $code : $minified);
	}
1238847
public function getOrganizationsByCode($code = null)
    {
        if (is_null($code)) {
            return $this->getOrganizations();
        }

        $sql = "SELECT gor_id_organization, gor_name
                    FROM gems__organizations
                    WHERE gor_active = 1 and gor_code = ?
                    ORDER BY gor_name";
        return $this->_getSelectPairsCached(__FUNCTION__ . '_' . $code, $sql, $code, 'organizations', 'natsort');
    }
397585
static public function
	MakeDirectory($dir) {
	/*//
	@argv string Directory
	@return bool

	make a directory. returns if successful or not. allows you to
	blindly call it if it already exists to ensure it exists.
	//*/

		// if it already exists...
		if(is_dir($dir)) return true;

		// make it...
		$umask = umask(0);
		@mkdir($dir,0777,true);
		umask($umask);

		// find out if it was successful, lol.
		return is_dir($dir);
	}
543616
static public function getRequestConfig($code = Service::BP)
    {
        Service::isValid($code);

        $config = [
            static::T540  => ['Date expédition format AAAAMMJJ', true, 8],
            static::T530  => ['Poids format xx.xx', true, 5],
            static::T860  => ['Raison sociale destinataire', true, 35],
            static::T863  => ['Rue destinataire', true, 35],
            static::T861  => ['Complément 1 adresse destinataire', false, 35],
            static::T862  => ['Complément 2 adresse destinataire', false, 35],
            static::T330  => ['Code postal destinataire', true, 10],
            static::T864  => ['Ville Destinataire', true, 35],
            static::T100  => ['Pays Destinataire', true, 2],
            static::T8906 => ['Commentaires', false, 35],
            static::T871  => ['Téléphone Destinataire', false, 20],
            static::T859  => ['Votre référence destinataire', false, 20],
            static::T854  => ['Référence supplémentaire 1', false, 20],
            static::T8908 => ['Référence supplémentaire 2', false, 20],
            static::T1229 => ['Email destinataire', false, 100],
            static::T1230 => ['Portable', false, 20],
            static::T810  => ['Raison sociale Expéditeur', true, 35],
            static::T820  => ['Adresse expéditeur', true, 35],
            static::T821  => ['Pays Expéditeur', true, 2],
            static::T822  => ['Code postal Expéditeur', true, 10],
            static::T823  => ['Ville Expéditeur', true, 35],
            static::T8700 => ['Dépôt GLS Expéditeur', true, 6],
            static::T8915 => ['Code client GLS', true, 10],
            static::T8914 => ['Contact Id (compte sur lequel va être affecté le colis)', true, 10],
            static::T8904 => ['Quantième colis dans Expédition (présent sur l’étiquette physiquement)', true, 3],
            static::T8973 => ['Quantième colis dans Expédition (présent dans le code barre datamatrix)', true, 3],
            static::T8905 => ['Nombre total colis Expédition (présent sur l’étiquette physiquement)', true, 3],
            static::T8702 => ['Nombre total colis Expédition (présent dans le code barre datamatrix)', true, 3],
            static::T8975 => ['Référence Origine GLS', true, 1024],
            static::T082  => ['Constante : UNIQUENO Transmettre cette valeur que si le destinataire est en France', true, 1042],
            static::T090  => ['Constante : NOSAVE ', true, 1042],
        ];

        if ($code === Service::EBP) {
            // Spécificités livraisons Shop Delivery Service
            $config = array_replace($config, [
                static::T200  => ['Service Shod Delivery ("SHD")', true, 3],
                static::T750  => ['Libellé service ("ShopDelivery-Service")', true, 1024],
                static::T1229 => ['Adresse Email Destinataire', true, 100],
                static::T1230 => ['Tél mobile Destinataire', true, 20],
                static::T8237 => ['Identifiant Point relais', true, 10],
                static::T8904 => ['Quantième colis dans Expédition ("1")', true, 3],
                static::T8973 => ['Quantième colis dans Expédition ("1")', true, 3],
                static::T8905 => ['Nombre total colis Expédition ("1")', true, 3],
                static::T8702 => ['Nombre total colis Expédition ("1")', true, 3],
            ]);
        } else if ($code === Service::EP) {
            // Spécificités livraison Express Parcel Guaranteed
            $config = array_replace($config, [
                static::T200  => ['13:00 service ("T13")', true, 3],
                static::T206  => ['Produit Express Parcel Guaranteed ("EP")', true, 1024],
                static::T8904 => ['Quantième colis dans Expédition ("1")', true, 3],
                static::T8973 => ['Quantième colis dans Expédition ("1")', true, 3],
                static::T8905 => ['Nombre total colis Expédition ("1")', true, 3],
                static::T8702 => ['Nombre total colis Expédition ("1")', true, 3],
            ]);
        } else if ($code === Service::FDF) {
            // Spécificités livraison Flex Delivery Service
            $config = array_replace($config, [
                static::T200  => ['Service Flex Delivery Service ("FDF")', true, 3],
                static::T750  => ['Libellé service  ("Flex Delivery Service")', true, 1024],
                static::T1229 => ['Adresse Email Destinataire', true, 100],
                static::T1230 => ['Tél mobile Destinataire', true, 20],
            ]);
        }

        return $config;
    }
997963
public function code($code = false)
    {

        if (!$code) {
            return http_response_code();
        }

        if (headers_sent()) {
            if (self::$exceptOnHeaders && (http_response_code() != $code)) {
                throw new \Exception('Headers already sent. HTTP response code cannot be changed.');
            } else {
                return;
            }
        }

        self::$code = $code;
        http_response_code(self::$code);
    }
1029970
public function findByCodes($codes)
    {
        $codes = (array) $codes;
        $errors = [];
        foreach ($this as $error) {
            $cause = $error->getCause();
            if ($cause instanceof ConstraintViolation && \in_array($cause->getCode(), $codes, true)) {
                $errors[] = $error;
            }
        }

        return new static($this->form, $errors);
    }
336999
protected function getConfigurationFiles($directoryPath)
    {
        $files = [];

        if (is_dir($directoryPath)) {
            foreach (Finder::create()->files()->in($directoryPath) as $file) {
                $group = basename($file->getRealPath(), '.php');
                $files[$group] = $file->getRealPath();
            }
        }

        return $files;
    }
407284
protected function getCode($code)
    {
        if (is_array($code)) {
            return $this->getCodeArray($code);
        }

        return $this->get($code);
    }