*/ /** * This view will display a file. Inspired by a contribution from Jesse Mullan * * @package Debug * @subpackage UserInterface */ class FileViewerView extends GalleryView { /** * @see GalleryView::loadTemplate() */ function loadTemplate(&$template, &$form) { global $gallery; $platform = $gallery->getPlatform(); list ($file, $line) = GalleryUtilities::getRequestVariables('file', 'line'); /* Make sure the file is on the approved list */ $legal = false; $manifest = GalleryUtilities::readManifest(); if (isset($manifest[$file]) && $manifest[$file]['viewable']) { $lines = $platform->file(dirname(__FILE__) . '/../../' . $file); $actualChecksum = sprintf("%u", crc32(join("", $lines))); if ($actualChecksum == $manifest[$file]['checksum']) { $legal = true; } } $FileViewer = array(); if ($legal) { $bodyFile = 'FileViewerLegalFile.tpl'; $FileViewer['fileName'] = $file; $FileViewer['currentLine'] = $line; $FileViewer['lines'] = $lines; } else { $bodyFile = 'FileViewerIllegalFile.tpl'; } $template->setVariable('FileViewer', $FileViewer); list ($ret, $module) = GalleryCoreApi::loadPlugin('module', 'debug'); if ($ret->isError()) { return array($ret->wrap(__FILE__, __LINE__), null); } $template->title($module->translate('Gallery Debug File Viewer')); return array(GalleryStatus::success(), array('body' => 'modules/debug/templates/' . $bodyFile)); } } ?>