private function getUserData() { $users = array(); // Open up the users folder and loop through all the .user files foreach (scandir('config/users') as $file) { if (File::fileExtension($file) == "user") { // Extract the user information from the file into a useful format $userInfo = User::getUserInfo(File::fileName($file)); // Stuff the record into the result array $users[] = $userInfo; } } return $users; }
private function getPageTypes() { $listitems = array(); // Add the Blank Page type $listitems[] = 'Blank Page'; // Add all available templates to the list foreach (scandir(Constants::$ROOT_DIR . 'templates/sandbox') as $file) { if (File::fileExtension($file) == "html") { // Add the filename to the list $listitems[] = File::filename($file); } } return $listitems; }
private function getUnpublished() { $path = File::getUserSandboxPath(); $unpublished = array(); // Loop through all the .html files in the published folder foreach (scandir($path) as $file) { // We only want to show the files that the user can edit (html files) if (File::fileExtension($file) == "html") { $unpublished[] = array("name" => urlencode(File::fileName($file)), "path" => $path . $file); } } return $unpublished; }
public function get() { Session::verifySession(); // if editing existing page, load from file $fileData = ''; $currentPageName = $this->pageState['page']; // Determine if this page is already published $isPublished = false; if ($this->pageState['publish'] == '1') { $isPublished = true; } $this->view->isPublished = $isPublished; // Get the current page's contents if ($currentPageName != '') { if ($isPublished) { $fileData = file_get_contents(File::getUserSandboxPath() . $currentPageName . '.published'); } else { $fileData = file_get_contents(File::getUserSandboxPath() . $currentPageName . '.html'); } } $this->view->fileData = $fileData; // Load up page metadata (if it exists) // Load up existing page metadata information (if it exists) $pageTitle = ''; $pageDescription = ''; $pageKeywords = ''; $handle = @fopen(File::getUserSandboxPath() . $currentPageName . '.config', "r"); if ($handle) { // Read the title if (!feof($handle)) { $a = explode("|", fgets($handle)); $pageTitle = trim($a[1]); } // Read the description if (!feof($handle)) { $a = explode("|", fgets($handle)); $pageDescription = trim($a[1]); } // Read the keywords if (!feof($handle)) { $a = explode("|", fgets($handle)); $pageKeywords = trim($a[1]); } fclose($handle); } // Add to page state $this->view->pageState['pageTitle'] = $pageTitle; $this->view->pageState['pageDescription'] = $pageDescription; $this->view->pageState['pageKeywords'] = $pageKeywords; // Assemble a list of pages in the current folder (we hand this to editor control $pageList = array(); $path = File::getUserSandboxPath(); foreach (scandir($path) as $file) { // We only want to include the user files if (File::fileExtension($file) == "html" || File::fileExtension($file) == "published") { $pageList[] = File::fileName($file); } } $this->view->pageList = $pageList; // Render the view $this->view->setMainTemplate('PageTemplate'); $this->renderView('EditPageView'); }