Generates a WebDAV propfind response body based on a list of nodes.

If 'strip404s' is set to true, all 404 responses will be removed.

@param array|\Traversable $fileProperties The list with nodes
@param bool               $strip404s

@return string
769398
public function generateMultiStatus($fileProperties, $strip404s = false)
    {
        $w = $this->xml->getWriter();
        $w->openMemory();
        $w->contextUri = $this->baseUri;
        $w->startDocument();

        $w->startElement('{DAV:}multistatus');

        foreach ($fileProperties as $entry) {
            $href = $entry['href'];
            unset($entry['href']);
            if ($strip404s) {
                unset($entry[404]);
            }
            $response = new Xml\Element\Response(
                ltrim($href, '/'),
                $entry
            );
            $w->write([
                'name' => '{DAV:}response',
                'value' => $response,
            ]);
        }
        $w->endElement();

        return $w->outputMemory();
    }
423557
protected function checkLoadProperties($propertiesFile, $propertyType)
    {

        if ($propertiesFile->exists() && $propertiesFile->isDirectory()) {
            $message = $propertyType." is a directory!";
            $this->_haltOnErrorAction(null, $message, Project::MSG_ERR);
            return;
        }

        if ($propertiesFile->exists() && !$propertiesFile->canRead()) {
            $message = "Can not read from the specified ".$propertyType."!";
            $this->_haltOnErrorAction(null, $message, Project::MSG_ERR);
            return;
        }

        $fileParserFactory = new FileParserFactory();
        $fileParser        = $fileParserFactory->createParser($propertiesFile->getFileExtension());
        $properties        = new Properties(null, $fileParser);

        $properties->load($propertiesFile);

        return $properties->getProperties();

    }
359779
private static function fillForFrontend($propertyRows, $property)
    {
        $carry = '';
        $column = static::dataTypeToEavColumn($property->data_type);
        foreach ($propertyRows as $row) {
            $value = Property::castValueToDataType($row[$column], $property->data_type);
            if ($property->allow_multiple_values === false) {
                if (true === empty($carry)) {
                    $carry = $value;
                }
                continue;
            }
            $carry[] = $value;
        }
        return $carry;
    }
413379
public static function fileMime(string $filename, array $detalles = []) {
        if (isset($detalles['path'])) {
            $path = str_start(str_replace("\\", "/", $filename), str_finish(str_replace("\\", "/", $detalles['path']), '/'));
        } else {
            $path = $filename;
        }
        $ext = pathinfo($path, PATHINFO_EXTENSION);
        if (file_exists($path)) {
            $typesArray = config("sirgrimorum.mimebyext", []);
            $mimeType = "";
            if (!count($typesArray) == 0) {
                if (isset($typesArray[$ext])) {
                    $mimeType = $typesArray[$ext];
                }
            }
            $otro = $mimeType;
            if ($mimeType == "") {
                $finfo = finfo_open(FILEINFO_MIME_TYPE);
                $mimeType = finfo_file($finfo, public_path($path));
            }
            return $mimeType;
        } else {
            return false;
        }
    }
389213
public function buildPropertiesString(array $properties)
    {
        $chunks = array();

        foreach ($properties as $property) {
            $chunks[] = $property->toString();
        }

        return implode(' ', $chunks);
    }
347127
public function getResultForMultiStatus()
    {
        $r = [
            200 => [],
            404 => [],
        ];
        foreach ($this->result as $propertyName => $info) {
            if (!isset($r[$info[0]])) {
                $r[$info[0]] = [$propertyName => $info[1]];
            } else {
                $r[$info[0]][$propertyName] = $info[1];
            }
        }
        // Removing the 404's for multi-status requests.
        if (self::ALLPROPS === $this->requestType) {
            unset($r[404]);
        }

        return $r;
    }
328720
public function getPropertyMappingConfigurationForPropertyPaths(array $propertyPaths, $className = '')
	{
		$propertyMappingConfiguration = new PropertyMappingConfiguration();
		$propertyMappingConfiguration->allowAllProperties();
		$propertyMappingConfiguration->setTypeConverterOption(PersistentObjectConverter::class, PersistentObjectConverter::CONFIGURATION_CREATION_ALLOWED, true);

		foreach ($propertyPaths as $propertyPath) {
			$propertyMappingConfiguration->forProperty($propertyPath)->allowAllProperties();
			$propertyMappingConfiguration->forProperty($propertyPath)->setTypeConverterOption(PersistentObjectConverter::class, PersistentObjectConverter::CONFIGURATION_CREATION_ALLOWED, true);
		}
		return $propertyMappingConfiguration;
	}
566971
public function load($filename, array $vars = [], $return = false)
    {
        if ($filename instanceof \SplFileInfo) {
            return $this->page($filename->getRealPath(), array_merge($vars, $filename->getVars()));
        }

        if (strpos($filename, 'Pages') !== false) {
            return $this->page($filename, $vars, $return);
        }

        presenter()->merge($vars);

        if (false !== ($filePath = $this->getFilePath($filename))) {

            // Load Assets
            presenter()->assets->addFilePath(dirname($filePath) . DIRECTORY_SEPARATOR);

            presenter()->assets->loadCss(pathinfo($filePath, PATHINFO_FILENAME));
            presenter()->assets->loadJs(pathinfo($filePath, PATHINFO_FILENAME));

            if ($return === false) {
                if (presenter()->partials->hasPartial('content') === false) {
                    if (is_ajax()) {
                        parser()->loadFile($filePath);
                        $content = parser()->parse(presenter()->getArrayCopy());

                        presenter()->partials->addPartial('content', $content);
                    } else {
                        presenter()->partials->addPartial('content', $filePath);
                    }
                } else {
                    presenter()->partials->addPartial(pathinfo($filePath, PATHINFO_FILENAME), $filePath);
                }
            } else {
                parser()->loadFile($filePath);

                return parser()->parse(presenter()->getArrayCopy());
            }
        } else {
            $vars = presenter()->getArrayCopy();
            extract($vars);

            $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);

            $error = new ErrorException(
                'E_VIEW_NOT_FOUND',
                0,
                @$backtrace[ 0 ][ 'file' ],
                @$backtrace[ 0 ][ 'line' ],
                [trim($filename)]
            );

            unset($backtrace);

            ob_start();
            include output()->getFilePath('error');
            $content = ob_get_contents();
            ob_end_clean();

            if ($return === false) {
                if (presenter()->partials->hasPartial('content') === false) {
                    presenter()->addPartial('content', $content);
                } else {
                    presenter()->addPartial(pathinfo($filePath, PATHINFO_FILENAME), $content);
                }
            } else {
                return $content;
            }
        }
    }
617779
private function getWebspaceNodesByPaths(
        array $paths,
        $locale,
        MappingInterface $mapping,
        array $webspaces,
        array $contents,
        UserInterface $user
    ) {
        $webspaceKey = null;
        if ($firstContent = reset($contents)) {
            $webspaceKey = $firstContent->getWebspaceKey();
        }

        $webspaceContents = $this->get('sulu_page.content_repository')->findByPaths(
            $paths,
            $locale,
            $mapping,
            $user
        );

        foreach ($webspaceContents as $webspaceContent) {
            $webspaceContent->setDataProperty('title', $webspaces[$webspaceContent->getWebspaceKey()]->getName());

            if ($webspaceContent->getWebspaceKey() === $webspaceKey) {
                $webspaceContent->setChildren($contents);
            }
        }

        return $webspaceContents;
    }
1084181
public static function replaceFilePlaceholders($filePath, $variables, $destPath = null, $pending = '$')
    {
        if (!$destPath) {
            $destPath = $filePath;
        }
        if (is_dir($filePath)) {
            $files = scandir($filePath);
            foreach ($files as $file) {
                if ($file != "." && $file != "..") {
                    Utils::replaceFilePlaceholders("$filePath" . DIRECTORY_SEPARATOR . "$file", $variables, $destPath,
                        $pending);
                }
            }
        } elseif (file_exists($filePath)) {
            $template = file_get_contents($filePath);
            $templateData = Utils::fillTemplate($variables, $template, $pending);
            $folder = dirname($destPath);
            if (!file_exists($folder)) {
                mkdir($folder, 0755, true);
            }
            file_put_contents($destPath, $templateData);
        }
    }
898910
public function FieldHolder($properties=array()) {
        Requirements::css(CB_DIR.'/css/PackageSelectionField.css');
        Requirements::javascript(CB_DIR.'/javascript/PackageSelectionField.js');
        
        return parent::FieldHolder($properties);
    }
1155875
protected function findVariants($fileID, Filesystem $filesystem)
    {
        $dirname = ltrim(dirname($fileID), '.');
        foreach ($filesystem->listContents($dirname) as $next) {
            if ($next['type'] !== 'file') {
                continue;
            }
            $nextID = $next['path'];
            // Compare given file to target, omitting variant
            if ($fileID === $this->removeVariant($nextID)) {
                yield $nextID;
            }
        }
    }
370634
function GetPropertyTypes() {
		$response = $this->MakeAPICall("GET", "propertytypes", '24h');

		if ($response['success'] == true) {
			$records = array();
			foreach ($response['results'] as $res) {
				$records[$res['MlsCode']] = $res['MlsName'];
			}

			return $records;
		}
		else {
			return false;
		}
	}
1115516
public function read($properties, $request = null, $strip = false)
    {
        $defaults = $this->query->getDefaultScope();

        $where = "";
        if (isset($request->filter)) {
            $where = $this->filter($properties, $request->filter);
            $this->bindFilterValues($request->filter);
        }

        $result = [];
        $result['total'] = $this->total($where);

        $select = [];
        foreach ($properties as $key => $value) {
            $select[] = "$value as $key";
        }

        $this->query = $this->query->select($select);

        $sort = $this->mergeSortDescriptors($request);

        if (count($sort) > 0) {
            $orders = [];
            foreach ($sort as $s) {
                if (!empty($properties[$s->field])) {
                    $orders[$s->field] = ($s->dir == 'desc') ? SORT_DESC : SORT_ASC;
                }
            }

            $this->query = $this->query->orderBy($orders);
        } elseif (isset($defaults['order'])) {
            $this->query = $this->query->orderBy($defaults['order']);
        }

        if (isset($request->skip)) {
            $this->query = $this->query->offset($request->skip);
        }

        if (isset($request->take)) {
            $this->query = $this->query->limit($request->take);
        } else {
            if (isset($defaults['limit'])) {
                $this->query = $this->query->limit($defaults['limit']);
            } else {
                if (defined("YII_DEBUG")) {
                    $this->query = $this->query->limit(500);
                }
            }
        }

        $data = $this->query->createCommand($this->db)->queryAll();

        for ($i = 0; $i < count($data); $i++) {
            foreach ($data[$i] as $name => $value) {
                $data[$i][$name] = $this->query->formatExportValue($name, $value, $strip);
            }
        }

        if (isset($request->group) && count($request->group) > 0) {
            $data = $this->group($data, $request->group, $request, $properties);
            $result['groups'] = $data;
        } else {
            $result['data'] = $data;
        }

        if (isset($request->aggregate)) {
            $result["aggregates"] = $this->calculateAggregates($request->aggregate, $request, $properties);
        }

        return $result;
    }
643136
public function handle($filePath, $results)
    {
        $responseCollection = new PredefinedResponseCollection();
        $responseCollection->append(
            new PredefinedResponse('postpone', 'postpone', self::POSTPONE)
        );
        $responseCollection->append(
            new PredefinedResponse('show diff', 'show diff', self::SHOW_DIFF)
        );
        $responseCollection->append(
            new PredefinedResponse('erase', 'erase', self::ERASE)
        );
        $responseCollection->append(
            new PredefinedResponse('cancel', 'cancel', self::CANCEL)
        );

        $question = new QuestionWithPredefinedResponse(
            sprintf('File "%s" already exist, erase it with the new', $filePath),
            'conflict' . $filePath,
            $responseCollection
        );

        $question->setShutdownWithoutResponse(true, sprintf('Conflict with file "%s" not resolved', $filePath));

        while (($response = $this->context->askCollection($question)) !== null) {
            $response = intval($response);

            if ($response === self::SHOW_DIFF) {
                // write to output the diff
                $this->context->log(
                    '<info>' . $this->diffPHP->diff($results, $this->fileManager->fileGetContent($filePath)) . '</info>'
                );
            } else {
                break;
            }
        }

        if ($response === self::POSTPONE) {
            //Generate the diff file
            $this->fileManager->filePutsContent(
                $filePath . '.diff',
                $this->diffPHP->diff(
                    $results,
                    $this->fileManager->fileGetContent($filePath)
                )
            );
            $this->context->log('--> Generate diff and new file ' . $filePath . '.diff', 'generationLog');
        } elseif ($response === self::ERASE) {
            $this->fileManager->filePutsContent($filePath, $results);
            $this->context->log('--> Replace file ' . $filePath, 'generationLog');
        }
    }
767664
private function generateGetResultBody(Property $property): string
    {
        if ($this->wrapperClass === null) {
            return sprintf('return $this->%s;', $property->getName());
        }

        return sprintf(
            'return new %s($this->%s);',
            Normalizer::getClassNameFromFQN($this->wrapperClass),
            $property->getName()
        );
    }
820387
function createDOMNodeFromFile( $filename, $siteAccess, $filetype = false )
    {
        $path = substr( $filename, strpos( $filename, '/', 7 ) );

        $dom = new DOMDocument( '1.0', 'utf-8' );
        $fileDOMNode = $dom->createElement( 'file' );
        $fileDOMNode->setAttribute( 'site-access', $siteAccess );

        if ( $filetype !== false )
        {
            $fileDOMNode->setAttribute( 'file-type', $filetype );
        }

        $dom->appendChild( $fileDOMNode );
        $originalPathNode = $dom->createElement( 'original-path' );
        $originalPathNode->appendChild( $dom->createTextNode( $filename ) );
        $fileDOMNode->appendChild( $originalPathNode );
        $pathNode = $dom->createElement( 'path' );
        $pathNode->appendChild( $dom->createTextNode( $path ) );
        $fileDOMNode->appendChild( $pathNode );

        $destinationPath = $this->Package->path() . '/' .  eZContentObjectPackageHandler::contentObjectDirectory() . '/' . $path;
        eZDir::mkdir( eZDir::dirpath( $destinationPath ),  false,  true );
        eZFileHandler::copy( $filename, $destinationPath );

        return $fileDOMNode;
    }