From 6cfdeb71b7c77c5eb01b64f24eae728e894451c7 Mon Sep 17 00:00:00 2001 From: steinm Date: Fri, 14 Dec 2012 08:57:29 +0000 Subject: [PATCH] =?UTF-8?q?-=20code=20has=20mo=D1=95tly=20been=20moved=20i?= =?UTF-8?q?nto=20views?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- inc/inc.ClassUI.php | 1094 ++----------------------------------------- 1 file changed, 49 insertions(+), 1045 deletions(-) diff --git a/inc/inc.ClassUI.php b/inc/inc.ClassUI.php index 6b40de2b1..3071d28c2 100644 --- a/inc/inc.ClassUI.php +++ b/inc/inc.ClassUI.php @@ -18,6 +18,10 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +require_once('inc.ClassUI_Default.php'); +require_once('inc.ClassViewCommon.php'); + +/* $theme was possibly set in inc.Authentication.php */ if (!isset($theme) || strlen($theme)==0) { $theme = $settings->_theme; } @@ -25,1069 +29,69 @@ if (strlen($theme)==0) { $theme="blue"; } -// for extension use LOWER CASE only -$icons = array(); -$icons["txt"] = "txt.png"; -$icons["text"] = "txt.png"; -$icons["doc"] = "word.png"; -$icons["dot"] = "word.png"; -$icons["docx"] = "word.png"; -$icons["dotx"] = "word.png"; -$icons["rtf"] = "document.png"; -$icons["xls"] = "excel.png"; -$icons["xlt"] = "excel.png"; -$icons["xlsx"] = "excel.png"; -$icons["xltx"] = "excel.png"; -$icons["ppt"] = "powerpoint.png"; -$icons["pot"] = "powerpoint.png"; -$icons["pptx"] = "powerpoint.png"; -$icons["potx"] = "powerpoint.png"; -$icons["exe"] = "binary.png"; -$icons["html"] = "html.png"; -$icons["htm"] = "html.png"; -$icons["gif"] = "image.png"; -$icons["jpg"] = "image.png"; -$icons["jpeg"] = "image.png"; -$icons["bmp"] = "image.png"; -$icons["png"] = "image.png"; -$icons["tif"] = "image.png"; -$icons["tiff"] = "image.png"; -$icons["log"] = "log.png"; -$icons["midi"] = "midi.png"; -$icons["pdf"] = "pdf.png"; -$icons["wav"] = "sound.png"; -$icons["mp3"] = "sound.png"; -$icons["c"] = "source_c.png"; -$icons["cpp"] = "source_cpp.png"; -$icons["h"] = "source_h.png"; -$icons["java"] = "source_java.png"; -$icons["py"] = "source_py.png"; -$icons["tar"] = "tar.png"; -$icons["gz"] = "gz.png"; -$icons["7z"] = "gz.png"; -$icons["bz"] = "gz.png"; -$icons["bz2"] = "gz.png"; -$icons["tgz"] = "gz.png"; -$icons["zip"] = "gz.png"; -$icons["mpg"] = "video.png"; -$icons["avi"] = "video.png"; -$icons["tex"] = "tex.png"; -$icons["ods"] = "ooo_spreadsheet.png"; -$icons["ots"] = "ooo_spreadsheet.png"; -$icons["sxc"] = "ooo_spreadsheet.png"; -$icons["stc"] = "ooo_spreadsheet.png"; -$icons["odt"] = "ooo_textdocument.png"; -$icons["ott"] = "ooo_textdocument.png"; -$icons["sxw"] = "ooo_textdocument.png"; -$icons["stw"] = "ooo_textdocument.png"; -$icons["odp"] = "ooo_presentation.png"; -$icons["otp"] = "ooo_presentation.png"; -$icons["sxi"] = "ooo_presentation.png"; -$icons["sti"] = "ooo_presentation.png"; -$icons["odg"] = "ooo_drawing.png"; -$icons["otg"] = "ooo_drawing.png"; -$icons["sxd"] = "ooo_drawing.png"; -$icons["std"] = "ooo_drawing.png"; -$icons["odf"] = "ooo_formula.png"; -$icons["sxm"] = "ooo_formula.png"; -$icons["smf"] = "ooo_formula.png"; -$icons["mml"] = "ooo_formula.png"; +/* Sooner or later the parent will be removed, because all output will + * be done by the new view classes. + */ +class UI extends UI_Default { + /** + * Create a view from a class in the given theme + * + * This method will check for a class file in the theme directory + * and returns an instance of it. + * + * @param string $theme theme + * @param string $class name of view class + * @param array $params parameter passed to constructor of view class + * @return object an object of a class implementing the view + */ + function factory($theme, $class, $params=array()) { /* {{{ */ + global $settings; + if(file_exists("../views/".$theme."/class.".$class.".php")) { + require("../views/".$theme."/class.".$class.".php"); + $classname = "LetoDMS_View_".$class; + $view = new $classname($params, $theme); + /* Set some configuration parameters */ + $view->setParam('sitename', $settings->_siteName); + $view->setParam('rootfolderid', $settings->_rootFolderID); + $view->setParam('disableselfedit', $settings->_disableSelfEdit); + $view->setParam('enableusersview', $settings->_enableUsersView); + $view->setParam('enablecalendar', $settings->_enableCalendar); + $view->setParam('calendardefaultview', $settings->_calendarDefaultView); + $view->setParam('enablefullsearch', $settings->_enableFullSearch); + $view->setParam('enablelargefileupload', $settings->_enableLargeFileUpload); + $view->setParam('printdisclaimer', $settings->_printDisclaimer); + $view->setParam('footnote', $settings->_footNote); + $view->setParam('logfileenable', $settings->_logFileEnable); + $view->setParam('expandfoldertree', $settings->_expandFolderTree); + $view->setParam('partionsize', $settings->_partitionSize); + return $view; + } + return null; + } /* }}} */ -$icons["default"] = "default.png"; - -class UI { function getStyles() { /* {{{ */ global $settings; $themes = array(); - $path = $settings->_rootDir . "styles/"; + $path = $settings->_rootDir . "views/"; $handle = opendir($path); while ($entry = readdir($handle) ) { if ($entry == ".." || $entry == ".") continue; - else if (is_dir($path . $entry)) + else if (is_dir($path . $entry) || is_link($path . $entry)) array_push($themes, $entry); } closedir($handle); return $themes; } /* }}} */ - function htmlStartPage($title="", $bodyClass="") { /* {{{ */ - global $theme, $settings; - - if(file_exists("../themes/".$theme."/HTMLHead.html")) { - include("../themes/".$theme."/HTMLHead.html"); - } else { - echo "\n"; - echo "\n\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "".(strlen($settings->_siteName)>0 ? $settings->_siteName : "LetoDMS").(strlen($title)>0 ? ": " : "").htmlspecialchars($title)."\n"; - echo "\n"; - echo "0 ? " class=\"".$bodyClass."\"" : "").">\n"; - } - } /* }}} */ - - function htmlEndPage() { /* {{{ */ + function exitError($pagetitle, $error) { global $theme; - - UI::footNote(); - if(file_exists("../themes/".$theme."/HTMLFoot.html")) { - include("../themes/".$theme."/HTMLFoot.html"); - } else { - echo "\n\n"; - } - } /* }}} */ - - function footNote() { /* {{{ */ - global $settings; - - if ($settings->_printDisclaimer){ - echo "
".getMLText("disclaimer")."
"; - } - - if (isset($settings->_footNote) && strlen((string)$settings->_footNote)>0) { - echo "
".(string)$settings->_footNote."
"; - } - - return; - } /* }}} */ - - function globalBanner() { /* {{{ */ - global $settings; - - echo "
\n"; - echo "
\n"; - echo "
\n"; - echo "
". - (strlen($settings->_siteName)>0 ? $settings->_siteName : "LetoDMS"). - "
\n"; - echo "
 
\n". - "
\n"; - return; - } /* }}} */ - - function globalNavigation($folder=null) { /* {{{ */ - - global $settings, $user; - - echo "
\n"; - echo "
\n"; - echo "\n"; - echo "
\n"; - echo "
". - (strlen($settings->_siteName)>0 ? $settings->_siteName : "LetoDMS"). - "
\n"; - echo "\n"; - echo "
".getMLText("signed_in_as")." ".htmlspecialchars($user->getFullName()). - " (".getMLText("sign_out").").
\n"; - echo "
 
\n". - "
\n"; - return; - } /* }}} */ - - function pageNavigation($pageTitle, $pageType=null, $extra=null) { /* {{{ */ - global $settings, $user; - - echo "
\n"; - // This spacer span is an awful hack, but it is the only way I know to - // get the spacer to match the mainheading content's size. - echo "".($settings->_titleDisplayHack ? $pageTitle : "")."\n"; - echo "
".$pageTitle."
\n"; - echo "
\n
\n"; - - if ($pageType!=null && strcasecmp($pageType, "noNav")) { - echo "
\n"; - switch ($pageType) { - case "view_folder": - UI::folderNavigationBar($extra); - break; - case "view_document": - UI::documentNavigationBar(); - break; - case "my_documents": - UI::myDocumentsNavigationBar(); - break; - case "my_account": - UI::accountNavigationBar(); - break; - case "admin_tools": - UI::adminToolsNavigationBar(); - break; - case "calendar"; - UI::calendarNavigationBar($extra); - break; - } - echo "
\n
\n"; - } - - return; - } /* }}} */ - - function folderNavigationBar($folder) { /* {{{ */ - - global $user, $settings, $theme; - - if (!is_object($folder) || strcasecmp(get_class($folder), "LetoDMS_Core_Folder")) { - echo "\n"; - return; - } - $accessMode = $folder->getAccessMode($user); - $folderID = $folder->getID(); - echo "\n"; - return; - } /* }}} */ - - function documentNavigationBar() { /* {{{ */ - - global $user, $settings, $document; - - $accessMode = $document->getAccessMode($user); - $docid=".php?documentid=" . $document->getID(); - - echo "\n"; - return; - } /* }}} */ - - function accountNavigationBar() { /* {{{ */ - - global $settings,$user; - - echo "\n"; - return; - } /* }}} */ - - function myDocumentsNavigationBar() { /* {{{ */ - - echo "\n"; - return; - } /* }}} */ - - function adminToolsNavigationBar() { /* {{{ */ - - global $settings; - - echo "\n"; - return; - } /* }}} */ - - function calendarNavigationBar($d){ /* {{{ */ - - global $settings,$user; - - $ds="&day=".$d[0]."&month=".$d[1]."&year=".$d[2]; - - echo "\n"; - return; - - } /* }}} */ - - function pageList($pageNumber, $totalPages, $baseURI, $params) { /* {{{ */ - - if (!is_numeric($pageNumber) || !is_numeric($totalPages) || $totalPages<2) { - return; - } - - // Construct the basic URI based on the $_GET array. One could use a - // regular expression to strip out the pg (page number) variable to - // achieve the same effect. This seems to be less haphazard though... - $resultsURI = $baseURI; - $first=true; - foreach ($params as $key=>$value) { - // Don't include the page number in the basic URI. This is added in - // during the list display loop. - if (!strcasecmp($key, "pg")) { - continue; - } - if (is_array($value)) { - foreach ($value as $subvalue) { - $resultsURI .= ($first ? "?" : "&").$key."%5B%5D=".$subvalue; - $first = false; - } - } - else { - $resultsURI .= ($first ? "?" : "&").$key."=".$value; - } - $first = false; - } - - echo "
"; - echo getMLText("results_page").": "; - for ($i = 1; $i <= $totalPages; $i++) { - if ($i == $pageNumber) echo "".$i." "; - else echo "".$i.""." "; - } - if ($totalPages>1) { - echo "".getMLText("all_pages").""." "; - } - echo "
"; - - return; - } /* }}} */ - - function contentContainer($content) { /* {{{ */ - echo "
\n"; - echo "
\n"; - echo "
\n"; - echo $content; - echo "
\n
\n
\n"; - return; - } /* }}} */ - - function contentContainerStart() { /* {{{ */ - - echo "
\n"; - echo "
\n"; - echo "
\n"; - return; - } /* }}} */ - - function contentContainerEnd() { /* {{{ */ - - echo "
\n
\n
\n"; - return; - } /* }}} */ - - function contentHeading($heading, $noescape=false) { /* {{{ */ - - if($noescape) - echo "
".$heading."
\n"; - else - echo "
".htmlspecialchars($heading)."
\n"; - return; - } /* }}} */ - - function contentSubHeading($heading, $first=false) { /* {{{ */ - - echo "
".htmlspecialchars($heading)."
\n"; - return; - } /* }}} */ - - function getMimeIcon($fileType) { /* {{{ */ - global $icons; - - $ext = strtolower(substr($fileType, 1)); - if (isset($icons[$ext])) { - return $icons[$ext]; - } - else { - return $icons["default"]; - } - } /* }}} */ - - function printDateChooser($defDate = -1, $varName) { /* {{{ */ - - if ($defDate == -1) - $defDate = mktime(); - $day = date("d", $defDate); - $month = date("m", $defDate); - $year = date("Y", $defDate); - - print " \n"; - print " \n"; - print ""; - } /* }}} */ - - function printSequenceChooser($objArr, $keepID = -1) { /* {{{ */ - if (count($objArr) > 0) { - $max = $objArr[count($objArr)-1]->getSequence() + 1; - $min = $objArr[0]->getSequence() - 1; - } - else { - $max = 1.0; - } - print ""; - } /* }}} */ - - function printDocumentChooser($formName) { /* {{{ */ - global $settings; - ?> - - "; - print ""; - print "  "; - } /* }}} */ - - function printFolderChooser($formName, $accessMode, $exclude = -1, $default = false) { /* {{{ */ - global $settings; - ?> - - getID() : "") ."\">"; - print "getName()) : "") ."\">"; - print "  "; - } /* }}} */ - - function printCategoryChooser($formName, $categories=array()) { /* {{{ */ - global $settings; -?> - -getId(); - $names[] = htmlspecialchars($cat->getName()); - } - } - print ""; - print ""; - print "  \"\""; - print "  "; - } /* }}} */ - - function printAttributeEditField($attrdef, $objvalue, $fieldname='attributes') { /* {{{ */ - if($valueset = $attrdef->getValueSetAsArray()) { - echo ""; - } else { - echo "getId()."]\" value=\"".htmlspecialchars($objvalue)."\" />"; - } - } /* }}} */ - - function getImgPath($img) { /* {{{ */ - global $theme; - - if ( is_file("../styles/$theme/images/$img") ) { - return "../styles/$theme/images/$img"; - } - else if ( is_file("../styles/$theme/img/$img") ) { - return "../styles/$theme/img/$img"; - } - return "../out/images/$img"; - } /* }}} */ - - function printImgPath($img) { /* {{{ */ - print UI::getImgPath($img); - } /* }}} */ - - function exitError($pagetitle,$error) { /* {{{ */ - - UI::htmlStartPage($pagetitle); - UI::globalNavigation(); - - print "
"; - print htmlspecialchars($error); - print "
"; - - UI::htmlEndPage(); - - add_log_line(" UI::exitError error=".$error." pagetitle=".$pagetitle); - - exit; - } /* }}} */ - - // navigation flag is used for items links (navigation or selection) - function printFoldersTree($accessMode, $exclude, $folderID, $currentFolderID=-1, $navigation=false) { /* {{{ */ - global $dms, $user, $form, $settings; - - if ($settings->_expandFolderTree==2){ - - // folder completely open - $is_open=true; - - }else if ($settings->_expandFolderTree==1 && $folderID==$settings->_rootFolderID ){ - - $is_open=true; - - }else{ - // open the tree until the current folder - $is_open=false; - - if ($currentFolderID!=-1){ - - $currentFolder=$dms->getFolder($currentFolderID); - - if (is_object($currentFolder)){ - - $parent=$currentFolder->getParent(); - - while (is_object($parent)){ - if ($parent->getID()==$folderID){ - $is_open=true; - break; - } - $parent=$parent->getParent(); - } - } - } - } - - $folder = $dms->getFolder($folderID); - if (!is_object($folder)) return; - - $subFolders = $folder->getSubFolders(); - $subFolders = LetoDMS_Core_DMS::filterAccess($subFolders, $user, M_READ); - - if ($folderID == $settings->_rootFolderID) print "