/** * Generate a page manifest. * * @param integer $pageId * @return array | false */ protected function _generateManifest($pageId) { $page = new Object_Page($pageId); if (!$page->getId()) { return false; } $pageVersion = $page->getMostLatestApprovedVersionAsActive(); $version = $pageVersion ? $pageVersion->version : false; $cloudFileContainer = $pageVersion ? $pageVersion->cloud_file_container : $page->cloud_file_container; if ($cloudFileContainer) { $files = $page->getCloudFilePaths($version, $cloudFileContainer); } else { // Get the files $files = $this->_folderFilePaths($page->getStaticContentFolder() . DS . $page->page_id, $page->page_id . '.html'); } // Prepare the pdf templates $pdfTemplateRows = Repo_PagePdfTemplate::getInstance()->getPagePdfTemplates($page->getId()); $pdfTemplates = array(); if ($pdfTemplateRows && $pdfTemplateRows->count()) { foreach ($pdfTemplateRows as $_tRow) { $_template = new Object_PdfTemplate($_tRow->id); $pdfTemplates[] = array('id' => $_template->getId(), 'name' => $_template->name, 'tokens' => $_template->getTokens(), 'preview' => $_template->getManifestPreviewFilePath()); } } return array('version' => $pageVersion ? $pageVersion->version : $page->version, 'id' => $page->page_id, 'uid' => $page->id, 'legalPageUid' => (int) $page->legal_page_id > 0 ? (int) $page->legal_page_id : '', 'linkedPageUids' => $page->getManifestPageGroupPages(), 'title' => $page->name, 'fileType' => 'htmlEdge', 'type' => 'html', 'typename' => $page->type, 'baseHost' => $page->getBaseHost($cloudFileContainer), 'baseUri' => $page->getBaseUrl($version), 'hash' => Manager_Page_StaticContent::getPageFolderName($page->page_id, $version), 'instructions' => $page->description ? $page->description : '', 'description' => $page->internal_desc ? $page->internal_desc : '', 'navigation' => array(), 'language' => $page->page_language, 'defaultPath' => $page->page_id . '.html', 'width' => $page->getWidth(), 'height' => $page->getHeight(), 'transcript' => $page->transcript ? $page->transcript : '', 'audio' => $page->audio_url, 'filePaths' => $files, 'navigation' => $page->navigation ? unserialize($page->navigation) : array(), 'content_type' => $page->content_type ? Repo_Page::$contentTypeLabels[$page->content_type] : Repo_Page::$contentTypeLabels[Repo_Page::PAGE_CONTENT_TYPE_DEFAULT], 'editor_behaviors' => $page->editor_behaviors ? $page->editor_behaviors : '', 'pdf_templates' => $pdfTemplates, 'tags' => $page->getTags()); }
/** * Generate a page screenshot. * * @param integer $pageId * @return array | false */ protected function _generateScreenshot($pageId) { $page = new Object_Page($pageId); if (!$page->getId()) { return false; } if (!$page->getPreviewLink()) { return false; } $url = $page->getPreviewLink(); if (!$page->cloud_file_container) { $url = Functions_Common::hostUrl() . $url; } $capturedImage = $this->getAdapter()->setWorkingDir($page->getStaticContentFolder())->capture($url, self::$defaultImageName, array('delay' => self::$defaultDelay)); return $capturedImage; }
/** * Get page info by id. * * Example requeset: /admin/ajax/page-info */ public function pageInfoAction() { $ids = $this->_request->getParam('id'); if (!is_array($ids) || empty($ids)) { $this->_responseErrorString = 'Invalid ids'; $this->_sendAjaxResponse(); } $infos = array(); foreach ($ids as $_id) { // It is the page id that is passed in $_pageId = Repo_Page::getInstance()->getIdByPageId($_id); $_object = new Object_Page($_pageId); if (!$_object->getId()) { continue; } $_info = array('id' => $_id, 'name' => $_object->name, 'description' => $_object->internal_desc ? $_object->internal_desc : ''); $infos[] = $_info; } $this->_responseArray = array('pages' => $infos); $this->_sendAjaxResponse(); }
/** * Update a page's static content. * * @param string $zipFilePath * @param integer $pageId * @return boolean */ public function updatePage($zipFilePath, $pageId) { if (!file_exists($zipFilePath)) { return false; } $zip = new ZipArchive(); $res = $zip->open($zipFilePath); if ($res !== TRUE) { return false; } $page = new Object_Page($pageId); if (!$page->getId()) { return false; } $this->_currentClientId = $page->client_id; // Extract to a temp folder $this->_currentTempFolder = $this->_tempPath . DS . time(); mkdir($this->_currentTempFolder, 0777); $zip->extractTo($this->_currentTempFolder); $zip->close(); $folderPath = $this->_currentTempFolder . DS . $page->page_language . DS . $page->page_id; if (!file_exists($folderPath)) { return false; } // Copy to a path $_pageStorageFolder = $this->getClientFolderPath($this->_currentClientId) . DS . self::getPageFolderName($page->page_id); if (!file_exists($_pageStorageFolder)) { mkdir($_pageStorageFolder, 0777); } else { // Remove the existing content since we are updating. if (file_exists($_pageStorageFolder . DS . $page->page_id)) { Functions_File::rrmdir($_pageStorageFolder . DS . $page->page_id); } } Functions_File::recurse_copy($folderPath, $_pageStorageFolder . DS . $page->page_id); // Use static thumb if possible. $page->useStaticThumb(); return true; }
/** * Result detail page: view all results for selected survey/question. */ public function resultDetailAction() { //if export to excel button was selected if ($this->_request->getParam('export')) { $this->view->exporting = $this->_request->getParam('export'); if ($this->_request->getParam('export') == "students") { if ($this->_request->getParam('studentprintfields')) { $this->view->studentprintfields = $this->_request->getParam('studentprintfields'); } } } $id = $this->_request->getParam('id'); $page = new Object_Page($id); $pageId = $page->getId(); $clientId = $this->_request->getParam('client'); $fromDate = $toDate = ""; //if range calendar was changed if ($this->_request->isPost()) { $fromDate = $this->_request->getParam('input-filter-date-from'); $toDate = $this->_request->getParam('input-filter-date-to'); $this->view->currentTab = $this->_request->getParam('current-tab'); } else { $this->view->currentTab = "#averages"; } if (empty($pageId)) { // if no page id, may be a survey id // $this->_request->getParam('survey'); // code here if a survey id has been passed // No page defined, redirect to result page $this->_redirect('/admin/client/result'); return false; } else { // ** CE Student Quizzes code **** if ($fromDate == "" && $toDate == "") { //if no dates were posted, create $toDate = date('Y-m-d'); //add 1 day $toDate = date('Y-m-d', strtotime('+1 day', strtotime($toDate))); $courseBegin = Repo_UserSurvey::getInstance()->getDateOfFirstQuizCompletion($pageId); if ($courseBegin) { if (strtotime($courseBegin) >= strtotime($toDate)) { $courseBegin = date('Y-m-d', strtotime('-1 day', strtotime($courseBegin))); } } //if no quizzes completed yet, default to one week $fromDate = is_null($courseBegin) ? date('Y-m-d', strtotime('-1 week', strtotime($toDate))) : $courseBegin; } $this->view->quizLayout = true; $this->view->dateRange = array($fromDate, $toDate); $pageType = Repo_Page::getInstance()->getPageType($pageId); $this->view->pageType = $pageType; //collect statistics according to page type switch ($pageType) { case "survey": //Tab 1 data: Totals and averages $quizResultsGeneral = Repo_UserSurvey::getInstance()->getResultsQuizGeneral($pageId, $fromDate, $toDate); $this->view->quizResultsGeneral = $quizResultsGeneral; //Tab 2 data: Question data $quizResultsQuestion = Repo_UserSurvey::getInstance()->getResultsQuizQuestions($pageId, $fromDate, $toDate); $this->view->quizResultsQuestion = $quizResultsQuestion; //Tab 3 data: Student details $quizResultsStudent = Repo_UserSurvey::getInstance()->getStudentQuizProgress($pageId, $fromDate, $toDate); $this->view->quizResultsStudent = $quizResultsStudent; break; case "cefeedback": $this->view->currentTab = "#cefeedback"; //Get Question Type: $feedbackData = Repo_UserSurvey::getInstance()->getResultsCEFeedback($pageId, $fromDate, $toDate); //Tab 1 data: feedback results $this->view->CEFeedback = $feedbackData[1]; $this->view->CEFeedbackRespondents = $feedbackData[0]; break; } } if ($clientId > 0) { $client = new Object_Client($clientId); $this->view->clientName = $client->name; } $this->view->page = $page; }
/** * Update a page's static content. * * @param string $zipFilePath * @param integer $pageId * @return boolean */ public function updatePage($zipFilePath, $pageId) { if (!file_exists($zipFilePath)) { return false; } $zip = new ZipArchive(); $res = $zip->open($zipFilePath); if ($res !== TRUE) { return false; } $page = new Object_Page($pageId); if (!$page->getId()) { return false; } $this->_currentClientId = $page->client_id; // Extract to a temp folder $this->_currentTempFolder = $this->_tempPath . DS . time(); mkdir($this->_currentTempFolder, 0777); $zip->extractTo($this->_currentTempFolder); $zip->close(); $folderPath = $this->_currentTempFolder . DS . $page->page_language . DS . $page->page_id; if (!file_exists($folderPath)) { return false; } // Copy to a path $_pageStorageFolder = $this->getClientFolderPath($this->_currentClientId) . self::PS . self::getPageFolderName($page->page_id); // Set client Manager_File_Rackspace::getInstance()->setClientId($page->client_id); // Cleanup first Manager_File_Rackspace::getInstance()->deletePeudoFolder($_pageStorageFolder); // Store Functions_File::recurse_copy_cloud($folderPath, $_pageStorageFolder . self::PS . $page->page_id); // Use static thumb if possible. $page->useStaticThumb(); return true; }