Parses gpx contents of a given file for a given layer.
@param $objLayer
@param $folder
@param $fileInfo
@param $key
@param $count
@return array|bool
556686
private function getFileContent($objLayer, $folder, $fileInfo, $key, $count)
    {
        
        switch ($fileInfo['extension']) {
            case 'gpx':
                $child = array
                (
                    "id"        => strval($key.$count),
                    "pid"       => $key,
                    "name"      => utf8_encode($fileInfo['filename']),
                    "hide"      => $objLayer->published,
                    "display"   => true,
                    "type"      => $fileInfo['extension'],
                    "content" => array(),
                    "cssClass"  => $objLayer->cssClass,
                    "childs" => array()
                );
                
                $childLayerList = array
                (
                    "id" => strval($key.$count),
                    "type" => "urlData",
                    "format" => "GPX",
                    "origType" => "gpx",
                    "locationStyle" => $objLayer->locstyle,
                    "cluster_fillcolor" => $objLayer->cluster_fillcolor,
                    "cluster_fontcolor" => $objLayer->cluster_fontcolor,
                    "cluster_zoom" => $objLayer->cluster_zoom,
                    "cluster_popup" => $objLayer->cluster_popup,
                    "loc_linkurl" => Controller::replaceInsertTags($objLayer->loc_linkurl),
                    "hover_location" => $objLayer->hover_location,
                    "hover_style" => $objLayer->hover_style,
                    "data" => array
                    (
                        "popup" => array(
                            "content" => utf8_encode($fileInfo['filename']),//"tl_c4g_maps" . ":" . $objLayer->id . ":",
                            "async" => false
                        ),
                        "tooltip" => $objLayer->tooltip,
                        "tooltip_length" => $objLayer->tooltip_length,
                        "label" => $objLayer->loc_label,
                        'zoom_onclick' => $objLayer -> loc_onclick_zoomto,
                        "url" => utf8_encode($folder)."/".utf8_encode($fileInfo['basename']),
                    ),
                    "settings" => array
                    (
                        "loadAsync"     => false,
                        "refresh"       => false,
                        "crossOrigine"  => false,
                        "boundingBox"   => false,
                        "cluster"       => $objLayer->cluster_locations ? ($objLayer->cluster_distance ? $objLayer->cluster_distance : 20) : false,
                    )
                );
                $child['content'][] = $childLayerList;
                //        $childs[] = $child;
                return $child;
            case 'xml':
                return false;
            case 'geojson':
                return false;
            default:
                return false;
        }
        
        
    }
130234
public function getFolderData($objLayer, $key=false, $folder=false, $count=0)
    {
        if (!$folder) {
            $folder = $this->getFolder($objLayer);
        }
        if (!$key) {
            $key =$objLayer->id;
        }
        $folderPath = realpath(TL_ROOT.'/'.$folder);
        $countFiles = 2050;
        
        if (is_dir($folderPath)) {
            $dict = scandir($folderPath);
            unset($dict[array_search('.', $dict)]);
            unset($dict[array_search('..', $dict)]);
            foreach ($dict as $value) {
//                $value = utf8_encode($value);
                $path = realpath(TL_ROOT."/".$folder."/".$value);
                if (is_dir($path)) {
                    $fileFolder = pathinfo($path);
                    $arrSubFolder = $this->getFolderContent($objLayer, $fileFolder, $key, $count);
                    $count += 1;
                    $data = $this->getFolderData($objLayer,  $arrSubFolder['id'], $folder."/".$value, $count);
                    if ($data) {
                        $arrSubFolder['childsCount'] = count($data);
                        $arrSubFolder['childs'] = $data;
                        $arrData[] = $arrSubFolder;
                    }
                } elseif (is_file($path)) {
                    $fileData = pathinfo($path);
                    $arrFile = $this->getFileContent($objLayer, $folder, $fileData, $key, $countFiles);
                    $countFiles += 2;
                    if($arrFile) {
                        $arrData[] = $arrFile;
                    }
                }
            }
            return $arrData;
        } else {
            return false;
        }
    }
1340192
public function getMixedCountsForFile($file_path)
    {
        if (!isset($this->mixed_counts[$file_path])) {
            $this->mixed_counts[$file_path] = [0, 0];
        }

        return $this->mixed_counts[$file_path];
    }
345247
public function read($count = 0)
    {
        if (0 === $count) {
            $count = -1;
        }
        fseek($this->resource, $this->readPosition);
        $content = stream_get_contents($this->resource, $count);
        $this->readPosition = ftell($this->resource);
        return $content;
    }
571157
public function getCollectionAction(Request $request, $start, $count, KeyWord $parent = null)
    {
        $results = [];

        $term = $request->query->get('term', null);
        $uids = array_filter(explode(',', $request->query->get('uids')));
        $preserveOrder = (boolean) $request->query->get('preserve_order');

        if (null !== $term) {
            $results = $this->getKeywordRepository()->getLikeKeyWords($term);
        } elseif (!empty($uids)) {
            $results = $this->getKeywordRepository()->findBy(['_uid' => $uids]);

            if ($preserveOrder === true) {
                $results = $this->sortByUids($uids, $results);
            }
        } else {
            $orderInfos = [
                'field' => '_leftnode',
                'dir' => 'asc',
            ];
            $results = $this->getKeywordRepository()->getKeyWords($parent, $orderInfos, array('start' => $start, 'limit' => $count));
        }

        $total = count($results);
        if ($results instanceof Paginator) {
            $results = iterator_to_array($results->getIterator());
        }

        return $this->addRangeToContent($this->createJsonResponse($results), $total, $start, count($results));
    }
188123
public function count($folder, $label = null, $read = 1)
    {
        return $this->repository
            ->pushCriteria(new MessageResourceCriteria($folder, $label, $read))
            ->mailCount();
    }
215009
public static void serialize(final File folder, final String content, final String fileName) throws IOException {
        if (!folder.exists()) {
            folder.mkdirs();
        }

        final File output = new File(folder, fileName);

        try (
                final FileWriter writer = new FileWriter(output);
        ) {
            writer.write(content);
            writer.flush();
        } catch (Exception e) {
            throw new IOException("Failed to serialize the notification in folder " + folder.getPath(), e);
        }
    }
163312
private void listFolder(final StructrShellCommand parent, final Iterable<AbstractFile> folder) throws FrameworkException, IOException {

		boolean hasContents = false;

		for (final AbstractFile child : folder) {

			if (parent.isAllowed(child, Permission.read, false)) {

				hasContents = true;

				if (child instanceof Folder) {

					term.setBold(true);
					term.setTextColor(4);
					term.print(child.getName() + "  ");
					term.setTextColor(7);
					term.setBold(false);

				} else {

					term.print(child.getName() + "  ");
				}
			}
		}

		if (hasContents) {
			term.println();
		}
	}
415392
static public function count($countable, $count, $message = null, $propertyPath = null)
        {
            if ($count !== count($countable)) {
                $message = $message ?: sprintf(
                    'List does not contain exactly "%d" elements.',
                    static::stringify($countable),
                    static::stringify($count)
                );

                throw static::createException($countable, $message, static::INVALID_COUNT, $propertyPath, array('count' => $count));
            }
        }
694176
public function listFilesInFolder($folder, array $filter = null, array $sortOrder = null, array $limit = null) {
		$timeStamp = microtime(true);
		$response = $this->getFileUploadFolder($folder);
		if($response->error->exist){
			return $response;
		}
		$folder = $response->result->set;
        $filter[] = array(
            'glue' => ' and',
            'condition' => array(
                'column' => $this->entity['f']['alias'] . '.file_upload_folder',
                'comparison' => '=',
                'value' => $folder->getId())
        );
        $response = $this->listFiles($filter, $sortOrder, $limit);

		$response->stats->execution->start = $timeStamp;
		$response->stats->execution->end = microtime(true);

		return $response;
    }
741826
protected function parseLayer($objLayer)
    {
        $stringClass = $GLOBALS['con4gis']['stringClass'];
        $arrLayerData = [];
        $arrLayerData['id'] = $objLayer->id;
        $arrLayerData['pid'] = $objLayer->pid;
        $arrLayerData['name'] =  \Contao\Controller::replaceInsertTags($stringClass::decodeEntities($objLayer->name));
        $arrLayerData['zoom_locations'] = $objLayer->zoom_locations;
        $arrLayerData['async_content'] = $objLayer->async_content;
        $arrLayerData['noFilter'] = $objLayer->exemptFromFilter;
        $arrLayerData['locstyle'] = $objLayer->locstyle;
        
        if ($objLayer->cluster_locations) {
            $arrLayerData['cluster'] = [
                'distance' => $objLayer->cluster_distance,
                'fillcolor' => $objLayer->cluster_fillcolor,
                'fontcolor' => $objLayer->cluster_fontcolor,
                'zoom' => $objLayer->cluster_zoom,
                'popup' => $objLayer->cluster_popup
            ];
        }

        // check parent hide status
        $parentLayer = C4gMapsModel::findById($objLayer->pid);
        
        if (!$parentLayer->is_map && $parentLayer->data_hidelayer) {
            $arrLayerData['hide'] = $parentLayer->data_hidelayer;
        } else {
            $arrLayerData['hide'] = $objLayer->data_hidelayer;
        }

        if ($objLayer->loc_minzoom>0 || $objLayer->loc_maxzoom>0) {
            $arrLayerData['zoom'] = [
                'min' => $objLayer->loc_minzoom,
                'max' => $objLayer->loc_maxzoom,
                'onclick_to' => $objLayer->loc_onclick_zoomto
            ];
        }

        if ($objLayer->data_layername) {
            $arrLayerData['name'] = \Contao\Controller::replaceInsertTags($stringClass::decodeEntities($objLayer->data_layername));
            $arrLayerData['display'] = true;
            $arrLayerData['hide_child'] = $objLayer->hide_child;
        } else {
            $arrLayerData['display'] = false;
        }
        
        if ($objLayer->split_geojson) {
            $arrLayerData['split_geojson'] = $objLayer->split_geojson;
            $arrLayerData['geojson_attributes'] = $objLayer->geojson_attributes;
            $arrLayerData['geojson_zoom'] = $objLayer->geojson_zoom;
        }

        // hide when element is rendered in starboard tab
        if ($objLayer->hide_when_in_tab) {
            $arrLayerData['hide_when_in_tab'] = true;
        }

        $arrLayerData['type'] = $objLayer->location_type;
        if ($objLayer->location_type === 'link') {
            $arrLayerData = $this->handleLayerLink($objLayer, $arrLayerData);
        } else {
            $arrLayerData['content'] = $this->getContentForType($objLayer);
        }
        
        if ($objLayer->location_type === 'startab') {
            $arrLayerData['awesomeicon'] = $objLayer->awesomeicon;
        }
        
        $arrLayerData['raw'] = $objLayer;

        return $arrLayerData;
    }
1271956
function stream_read($count) {
        $ret = substr($this->_data, $this->_position, $count);
        $this->_position += strlen($ret);
        return $ret;
    }
650715
public function readFromFolder($listName, $folderName = '', $isLibrary = false, $limit = NULL, $query = NULL, $view = NULL, $sort = NULL) {
		return $this->read($listName, $limit, $query, $view, $sort, "<Folder>" . ($isLibrary ? '' : 'Lists/') . $listName . '/' . $folderName . "</Folder>" );
	}
251752
public function read($count)
    {
        if ($this->isEof()) {
            return null;
        }
        $buffer         = substr($this->buffer, $this->position, $count);
        $this->position += $count;
        return $buffer;
    }
450416
public function spop($key, $count = 1)
    {
        $this->init();
        if ($count == 1 || $count === null) {
            $result = $this->driver->spop($key);
            return $this->convertFalseToNull($result);
        }

        $members = [];
        for ($i = 0; $i < $count; ++$i) {
            $member = $this->driver->spop($key);
            if (!$member) {
                break;
            }
            $members[] = $member;
        }
        return empty($members) ? null : $members;
    }
726792
function collectResults(resultsGlob) {
    var glob = require("glob"),
        fs = require("fs"),
        Q = require('q'),
        JunitConverter = require("./formats/junitConverter"),
        response = {},
        count = 0,
        specs,
        files = [],
        converter,
        result;

    for (var i = 0; i < resultsGlob.length; i++) {
        files = files.concat(glob.sync(resultsGlob[i]));
    }

    var converterCallback = function(output) {
        result = output;
    };

    for (i = 0; i < files.length; i++) {
        if (files[i].indexOf(".xml") !== -1) {
            converter = new JunitConverter(files[i]);
            converter.exec(converterCallback);
        } else {
            try {
                result = JSON.parse(fs.readFileSync(files[i]));
            } catch (err) {
                console.log('Error parsing JSON of ' + files[i]);
                result = {};
            }
        }
        response = mergeResults(result, response);
        count++;
    }
    return Q.fcall(function () {
        return response;
    });
}
868034
public function getImageCount($storageName = '', $folder = '')
    {


        $strURI = Product::$baseProductUri . '/slides/' . $this->getFileName() . '/images';
        if ($folder != '') {
            $strURI .= '?folder=' . $folder;
        }
        if ($storageName != '') {
            $strURI .= '&storage=' . $storageName;
        }
        $signedURI = Utils::sign($strURI);

        $responseStream = Utils::processCommand($signedURI, 'GET', '', '');

        $json = json_decode($responseStream);

        return count($json->Images->List);
    }