Prepare an array of products
@param array $list
3573
protected function prepareListProduct(array &$list)
    {
        foreach ($list as &$item) {
            $this->setItemPriceFormatted($item, $this->price);
            $this->setItemUrlEntity($item, $this->store, 'product');
        }
    }
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;
    }
647384
protected function prepareListLibrary(array &$list)
    {
        foreach ($list as &$item) {
            $item['status'] = empty($item['errors']);
            $item['has_dependencies'] = !empty($item['requires']) || !empty($item['required_by']);
        }
    }
1116073
protected function _toArray( array $list )
	{
		$result = array();

		foreach( $list as $item ) {
			$result[] = (object) $item->toArray();
		}

		return $result;
	}
1348540
protected function limitList(array &$list, array $limit)
    {
        list($from, $to) = $limit;
        $list = array_slice($list, $from, $to, true);
    }
145051
public function hash(array $list)
    {
        $ids = '';
        foreach ($list as $item) {
            $ids .= ':'.$item['id'];
        }
        return md5($ids);
    }
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;
    }
240803
protected static function prepareWhere(array $array, $list)
    {
        if (!is_array($list)) {
            $list = [$list];
        }
        foreach ($list as $v) {
            if (array_key_exists($v, $array)) {
                return $v;
            }
        }

        return null;
    }
1094781
public function fromArray( array $list )
	{
		if( array_key_exists( $this->_prefix . 'id', $list ) )
		{
			$this->setId( $list[$this->_prefix . 'id'] );
			unset( $list[$this->_prefix . 'id'] );
		}

		unset( $list[$this->_prefix . 'siteid'] );
		unset( $list[$this->_prefix . 'ctime'] );
		unset( $list[$this->_prefix . 'mtime'] );
		unset( $list[$this->_prefix . 'editor'] );

		return $list;
	}
227540
public function readForOnly($list)
	{
		$this->read();

		$files = $this->getFiles();

		$filtered = [];

		foreach ($this->getList($list) as $list)
		{
			$list = trim($list);
			
			if (in_array($list, $files) || in_array($list . '.php', $files))
			{
				$filtered[] = $list;
			}
		}

		$this->setFiles($filtered);
	}
115312
protected function fill_collections($list=""){
		$names=explode(",",$list);
		for ($i=0; $i < sizeof($names); $i++) { 
			$name = $this->resolve_parameter($names[$i]);
			if (!array_key_exists($name,$this->options)){
				$this->options[$name] = new DistinctOptionsConnector($this->get_connection(),$this->names["db_class"]);
				$c = new DataConfig($this->config);
				$r = new DataRequestConfig($this->request);
				$c->minimize($name);
				
				$this->options[$name]->render_connector($c,$r);
			} 
			
			$this->extra_output.="<coll_options for='{$names[$i]}'>";
			if (!is_string($this->options[$name]))
				$this->extra_output.=$this->options[$name]->render();
			else
				$this->extra_output.=$this->options[$name];
			$this->extra_output.="</coll_options>";
		}
	}
164168
protected function prepareListFieldValue(array &$list)
    {
        foreach ($list as &$item) {
            $this->setItemThumb($item, $this->image, array('placeholder' => false));
        }
    }
1021178
protected function prepareListModule(array &$list)
    {
        foreach ($list as &$item) {
            $item['has_dependencies'] = !empty($item['requires']) || !empty($item['required_by']);
        }
    }
1333788
protected function clear_list($list)
	{
		is_array($list) or $list = array($list);

		foreach ($list as $_list)
		{
			$this->{$_list} = array();
		}
	}
727464
private function finish($list)
    {
        if (is_array($list) || ($list instanceof ArrayObject)) {
            foreach ($list as $index => $item) {
                $list[$index] = $this->finish($item);
            }

            if ($list instanceof ArrayObject) {
                $list = $list->getArrayCopy();
            }
        } elseif (is_object($list)) {
            $list->values = $this->finish($list->values);
        }

        return $list;
    }
663431
protected function prepareList(array $libraries)
    {
        foreach ($libraries as $library_id => &$library) {
            $this->prepareListItem($libraries, $library_id, $library);
        }

        $this->validateDependencies($libraries);
        $prepared = $this->graph->build($libraries);
        gplcart_array_sort($prepared);

        return $prepared;
    }
1209798
protected function prepareListFile(array &$list)
    {
        foreach ($list as &$item) {

            $path = strval(str_replace("\0", "", $item['path']));
            $item['url'] = '';

            if ($path && file_exists(GC_DIR_FILE . '/' . $path)) {
                $item['url'] = $this->url->file($item['path']);
            }
        }
    }