build dir
@access protected
@param  array $list
@return void
515818
static public function buildDir($dirlist)
    {
        $appPath = static::getAppPath();
        
        $dirlist = (array) $dirlist;
        foreach ($dirlist as $dir) {
            $path = rtrim($appPath, '\\/') . '/' . trim($dir, '\\/');
            if (!is_dir($path)) {
                mkdir($path, 0755, true);
            }
        }
    }
1244975
public function recursive($path, &$list = array(), $limit = 4)
    {
        if(!$path) return;
        if($limit == 0) return;
        $files = scandir($path);
        foreach ($files as $file) {
            if ($file !== '.' && $file !== '..' && !$this->isCommonDirectory($file)) {
                $filename = $path . '/' . $file;
                if (is_dir($filename)) {
                    $this->recursive($filename, $list, $limit - 1);
                } else {
                    if ($file === 'config.yml' && !in_array($filename, $list)) {
                        $list[] = $filename;
                    }
                }
            }
        }
    }
865960
protected static function prepare_list($list) {
        global $OUTPUT;
        $foldericon = $OUTPUT->image_url(file_folder_icon(24))->out(false);

        // Reset the array keys because non-numeric keys will create an object when converted to JSON.
        $list = array_values($list);

        $len = count($list);
        for ($i = 0; $i < $len; $i++) {
            if (is_object($list[$i])) {
                $file = (array)$list[$i];
                $converttoobject = true;
            } else {
                $file =& $list[$i];
                $converttoobject = false;
            }

            if (isset($file['source'])) {
                $file['sourcekey'] = sha1($file['source'] . self::get_secret_key() . sesskey());
            }

            if (isset($file['size'])) {
                $file['size'] = (int)$file['size'];
                $file['size_f'] = display_size($file['size']);
            }
            if (isset($file['license']) && get_string_manager()->string_exists($file['license'], 'license')) {
                $file['license_f'] = get_string($file['license'], 'license');
            }
            if (isset($file['image_width']) && isset($file['image_height'])) {
                $a = array('width' => $file['image_width'], 'height' => $file['image_height']);
                $file['dimensions'] = get_string('imagesize', 'repository', (object)$a);
            }
            foreach (array('date', 'datemodified', 'datecreated') as $key) {
                if (!isset($file[$key]) && isset($file['date'])) {
                    $file[$key] = $file['date'];
                }
                if (isset($file[$key])) {
                    // must be UNIX timestamp
                    $file[$key] = (int)$file[$key];
                    if (!$file[$key]) {
                        unset($file[$key]);
                    } else {
                        $file[$key.'_f'] = userdate($file[$key], get_string('strftimedatetime', 'langconfig'));
                        $file[$key.'_f_s'] = userdate($file[$key], get_string('strftimedatetimeshort', 'langconfig'));
                    }
                }
            }
            $isfolder = (array_key_exists('children', $file) || (isset($file['type']) && $file['type'] == 'folder'));
            $filename = null;
            if (isset($file['title'])) {
                $filename = $file['title'];
            }
            else if (isset($file['fullname'])) {
                $filename = $file['fullname'];
            }
            if (!isset($file['mimetype']) && !$isfolder && $filename) {
                $file['mimetype'] = get_mimetype_description(array('filename' => $filename));
            }
            if (!isset($file['icon'])) {
                if ($isfolder) {
                    $file['icon'] = $foldericon;
                } else if ($filename) {
                    $file['icon'] = $OUTPUT->image_url(file_extension_icon($filename, 24))->out(false);
                }
            }

            // Recursively loop over children.
            if (isset($file['children'])) {
                $file['children'] = self::prepare_list($file['children']);
            }

            // Convert the array back to an object.
            if ($converttoobject) {
                $list[$i] = (object)$file;
            }
        }
        return $list;
    }
772215
protected function prepareListUser(array &$list)
    {
        $stores = $this->store->getList();

        foreach ($list as &$item) {

            $item['url'] = '';

            if (isset($stores[$item['store_id']])) {
                $item['url'] = $this->store->getUrl($stores[$item['store_id']]) . "/account/{$item['user_id']}";
            }
        }
    }
756862
public function removeDotDirectories(array $list)
	{
		$filter = function ($line)
		{
			if (!empty($line) && !preg_match('#.* \.(\.)?$|^total#', $line))
			{
				return true;
			}

			return false;
		};

		return array_filter($list, $filter);
	}
483964
public function removeHashPrefixesFromList($list)
  {
    $this->debugLog('removeHashPrefixesFromList() list '.$list);
    $listdir=$this->getListStorageDir($list);
    if(!$listdir || strlen($listdir)<10){
      $this->warningLog('removeHashPrefixesFromList() invalid list directory for list '.$list);
      return;
    }
    if(!is_dir($listdir)){
      $this->debugLog('removeHashPrefixesFromList() no list directory for list '.$list);
      return;
    }
    if(!is_file($listdir.$this->prefixes_filename)){
      $this->debugLog('removeHashPrefixesFromList() no prefix file for list '.$list);
      return;
    }
    unlink($listdir.$this->prefixes_filename);
  }
456650
public static function iterateVolatile(array &$list)
    {
        // Keyed by already-iterated items
        $iterated = [];
        // Get all items not yet iterated
        while ($items = array_diff_key($list, $iterated)) {
            // Yield all results
            foreach ($items as $key => $value) {
                // Skip items removed by a prior step
                if (array_key_exists($key, $list)) {
                    // Ensure we yield from the source list
                    $iterated[$key] = true;
                    yield $key => $list[$key];
                }
            }
        }
    }
898723
private function formatListForApi(array $list)
    {
        $values = [];

        foreach ($list as $value) {
            $values[] = $this->formatValueForApi($value);
        }

        return ['values' => $values];
    }
1154108
public function buildMenuFromMenuList( ADT_Tree_Menu_List $list )
	{
		$root	= array(
			array(
				'id' 	=> $this->rootId,
				'level' => 0,
				'label' => $this->rootLabel
			)
		);
		return self::buildLayersRecursive( $list, $this->rootId, $root );
	}
346854
protected static function build_list($type = 'ul', array $list = array(), $attr = false, $indent = '')
	{
		if ( ! is_array($list))
		{
			$result = false;
		}

		$out = '';
		foreach ($list as $key => $val)
		{
			if ( ! is_array($val))
			{
				$out .= $indent."\t".html_tag('li', false, $val).PHP_EOL;
			}
			else
			{
				$out .= $indent."\t".html_tag('li', false, $key.PHP_EOL.static::build_list($type, $val, '', $indent."\t\t").$indent."\t").PHP_EOL;
			}
		}
		$result = $indent.html_tag($type, $attr, PHP_EOL.$out.$indent).PHP_EOL;
		return $result;
	}
1131069
protected function prepareList(array $list)
    {
        foreach ($list as &$item) {
            if (!empty($item['data']['conditions'])) {
                gplcart_array_sort($item['data']['conditions']);
            }
        }

        return $list;
    }
40882
private function process_directory( $dir_list ) {
		$translation_list = array_map(
			function( $e ) {
					return pathinfo( $e, PATHINFO_FILENAME );
			}, $dir_list
		);
		$translation_list = array_unique( $translation_list );

		return $translation_list;
	}
794215
private static void getFilesAndDirs(File dir, List<File> list) {
        File[] files = dir.listFiles();
        for (File element : files) {
            list.add(element);
            if (element.isDirectory()) {
                getFilesAndDirs(element, list);
            }
        }
    }
355203
public function rmdirr($dir)
    {
        if ($handle = opendir("$dir")) {
            while ($item = readdir($handle)) {
                if (($item != ".") && ($item != "..")) {
                    if (is_dir("$dir/$item")) {
                        $this->rmdirr("$dir/$item");
                    } else {
                        unlink("$dir/$item");
                    }
                }
            }
            closedir($handle);
            rmdir($dir);
        }
    }
734920
public function setList($list)
    {
        $this->list = $list;
        $this->failover = $this->list;
        return $this;
    }
593919
public function rmdir($dir) {
		$this->connectIfNeeded();
		$this->handle->rmdir($dir);
		$this->onFolderDeleted(new Event(['sender' => $this, 'data' => $dir]));
	}
737740
public function listToMap(array $list)
    {
        $map = array();
        for ($i = 0, $n = count($list); $i < $n; $i += 2) {
            $map[$list[$i]] = $list[$i + 1];
        }
        return (object)$map;
    }