framework/RedKiteCms/Content/PageCollection/PageCollectionManager.php
public function edit(array $values)
    {
        $currentName = $values["currentName"];
        unset($values["currentName"]);

        $pageDir = $this->pagesDir . '/' . $values["name"];
        if (!is_dir($pageDir)) {
            $pageDir = $this->pagesDir . '/' . $currentName;
        }

        $pageFile = $pageDir . '/' . $this->pageFile;
        $currentValues = json_decode(FilesystemTools::readFile($pageFile), true);
        if (array_key_exists("template", $values) && $currentValues["template"] != $values["template"]) {
            Dispatcher::dispatch(
                PageCollectionEvents::TEMPLATE_CHANGED,
                new TemplateChangedEvent($currentValues["template"], $values["template"], $this->username)
            );
        }
        $values = array_merge($currentValues, $values);

        $values = $this->slugifyPageName($values);
        $targetFolder = $this->pagesDir . '/' . $values["name"];

        $encodedPage = json_encode($values);
        $event = Dispatcher::dispatch(PageCollectionEvents::PAGE_COLLECTION_EDITING, new PageCollectionEditingEvent($pageFile, $encodedPage));
        $encodedPage = $event->getFileContent();

        FilesystemTools::writeFile($pageFile, $encodedPage);
        if ($currentName != $values["name"]) {
            rename($pageDir, $targetFolder);
        }

        Dispatcher::dispatch(PageCollectionEvents::PAGE_COLLECTION_EDITED, new PageCollectionEditedEvent($pageFile, $encodedPage));
        DataLogger::log(sprintf('Page "%s" was successfully edited', $currentName));

        return $encodedPage;
    }
public function edit(array $values)
    {
        $currentName = $values["currentName"];
        unset($values["currentName"]);

        $pageDir = $this->pagesDir . '/' . $values["name"];
        if (!is_dir($pageDir)) {
            $pageDir = $this->pagesDir . '/' . $currentName;
        }

        $pageFile = $pageDir . '/' . $this->pageFile;
        $currentValues = json_decode(FilesystemTools::readFile($pageFile), true);
        if (array_key_exists("template", $values) && $currentValues["template"] != $values["template"]) {
            Dispatcher::dispatch(
                PageCollectionEvents::TEMPLATE_CHANGED,
                new TemplateChangedEvent($currentValues["template"], $values["template"], $this->username)
            );
        }
        $values = array_merge($currentValues, $values);

        $values = $this->slugifyPageName($values);
        $targetFolder = $this->pagesDir . '/' . $values["name"];

        $encodedPage = json_encode($values);
        $event = Dispatcher::dispatch(PageCollectionEvents::PAGE_COLLECTION_EDITING, new PageCollectionEditingEvent($pageFile, $encodedPage));
        $encodedPage = $event->getFileContent();

        FilesystemTools::writeFile($pageFile, $encodedPage);
        if ($currentName != $values["name"]) {
            rename($pageDir, $targetFolder);
        }

        Dispatcher::dispatch(PageCollectionEvents::PAGE_COLLECTION_EDITED, new PageCollectionEditedEvent($pageFile, $encodedPage));
        DataLogger::log(sprintf('Page "%s" was successfully edited', $currentName));

        return $encodedPage;
    }
public function edit ( array $ values ) { $ currentName = $ values [ "currentName" ] ; unset ( $ values [ "currentName" ] ) ; $ pageDir = $ this -> pagesDir . '/' . $ values [ "name" ] ; if ( ! is_dir ( $ pageDir ) ) { $ pageDir = $ this -> pagesDir . '/' . $ currentName ; } $ pageFile = $ pageDir . '/' . $ this -> pageFile ; $ currentValues = json_decode ( FilesystemTools :: readFile ( $ pageFile ) , true ) ; if ( array_key_exists ( "template" , $ values ) && $ currentValues [ "template" ] != $ values [ "template" ] ) { Dispatcher :: dispatch ( PageCollectionEvents :: TEMPLATE_CHANGED , new TemplateChangedEvent ( $ currentValues [ "template" ] , $ values [ "template" ] , $ this -> username ) ) ; } $ values = array_merge ( $ currentValues , $ values ) ; $ values = $ this -> slugifyPageName ( $ values ) ; $ targetFolder = $ this -> pagesDir . '/' . $ values [ "name" ] ; $ encodedPage = json_encode ( $ values ) ; $ event = Dispatcher :: dispatch ( PageCollectionEvents :: PAGE_COLLECTION_EDITING , new PageCollectionEditingEvent ( $ pageFile , $ encodedPage ) ) ; $ encodedPage = $ event -> getFileContent ( ) ; FilesystemTools :: writeFile ( $ pageFile , $ encodedPage ) ; if ( $ currentName != $ values [ "name" ] ) { rename ( $ pageDir , $ targetFolder ) ; } Dispatcher :: dispatch ( PageCollectionEvents :: PAGE_COLLECTION_EDITED , new PageCollectionEditedEvent ( $ pageFile , $ encodedPage ) ) ; DataLogger :: log ( sprintf ( 'Page "%s" was successfully edited' , $ currentName ) ) ; return $ encodedPage ; }
Edits the handled page
@param array $values

@return string The encoded page
Edits the handled page @param array $values