diff options
author | Michael Gapczynski <GapczynskiM@gmail.com> | 2011-08-09 10:42:50 -0400 |
---|---|---|
committer | Michael Gapczynski <GapczynskiM@gmail.com> | 2011-08-09 10:42:50 -0400 |
commit | ec6aed847585565f703e0c8bef0b75782bfe4560 (patch) | |
tree | ae8e3a897143ea2198381dfb736ae82b2949dd49 /lib | |
parent | 9a8eb7298c16ea3c10019d04695be04d6205a701 (diff) | |
parent | 1419d7f2b02a2182eb746443b62572f1b4b3f655 (diff) | |
download | nextcloud-server-ec6aed847585565f703e0c8bef0b75782bfe4560.tar.gz nextcloud-server-ec6aed847585565f703e0c8bef0b75782bfe4560.zip |
Merge branch 'master' into sharing
Diffstat (limited to 'lib')
-rw-r--r-- | lib/app.php | 228 | ||||
-rw-r--r-- | lib/l10n.php | 11 | ||||
-rw-r--r-- | lib/setup.php | 49 | ||||
-rw-r--r-- | lib/template.php | 49 |
4 files changed, 117 insertions, 220 deletions
diff --git a/lib/app.php b/lib/app.php index 9e81ed8184e..f1363c8af5a 100644 --- a/lib/app.php +++ b/lib/app.php @@ -30,10 +30,10 @@ class OC_App{ static private $init = false; static private $apps = array(); static private $activeapp = ''; - static private $adminpages = array(); - static private $settingspages = array(); static private $navigation = array(); - static private $subnavigation = array(); + static private $settingsForms = array(); + static private $adminForms = array(); + static private $personalForms = array(); /** * @brief loads all apps @@ -167,38 +167,6 @@ class OC_App{ } /** - * @brief adds a sub entry to the navigation - * @param $parent id of the parent - * @param $data array containing the data - * @returns true/false - * - * This function adds a new sub entry to the navigation visible to users. - * these entries are visible only if the parent navigation entry is marked - * as being active (see activateNavigationEntry()). $data is an associative - * array. - * The following keys are required: - * - id: unique id for this entry ('addressbook_index') - * - href: link to the page - * - name: Human readable name ('Addressbook') - * - * The following keys are optional: - * - icon: path to the icon of the app - * - order: integer, that influences the position of your application in - * the navigation. Lower values come first. - */ - public static function addNavigationSubEntry( $parent, $data ){ - $data['active']=false; - if(!isset($data['icon'])){ - $data['icon']=''; - } - if( !array_key_exists( $parent, self::$subnavigation )){ - self::$subnavigation[$parent] = array(); - } - self::$subnavigation[$parent][] = $data; - return true; - } - - /** * @brief marks a navigation entry as active * @param $id id of the entry * @returns true/false @@ -224,70 +192,6 @@ class OC_App{ } /** - * @brief registers an admin page - * @param $data array containing the data - * @returns true/false - * - * This function registers a admin page that will be shown in the admin - * menu. $data is an associative array. - * The following keys are required: - * - id: unique id for this entry ('files_admin') - * - href: link to the admin page - * - name: Human readable name ('Files Administration') - * - * The following keys are optional: - * - order: integer, that influences the position of your application in - * the list. Lower values come first. - */ - public static function addAdminPage( $data = array()){ - // TODO: write function - OC_App::$adminpages[] = $data; - return true; - } - - /** - * @brief registers a settings page - * @param $data array containing the data - * @returns true/false - * - * This function registers a settings page. $data is an associative array. - * The following keys are required: - * - app: app the settings belong to ('files') - * - id: unique id for this entry ('files_public') - * - href: link to the admin page - * - name: Human readable name ('Public files') - * - * The following keys are optional: - * - order: integer, that influences the position of your application in - * the list. Lower values come first. - * - * For the main settings page of an app, the keys 'app' and 'id' have to be - * the same. - */ - public static function addSettingsPage( $data = array()){ - // TODO: write function - OC_App::$settingspages[] = $data; - return true; - } - - /** - * @brief Returns the navigation - * @returns associative array - * - * This function returns an array containing all entries added. The - * entries are sorted by the key 'order' ascending. Additional to the keys - * given for each app the following keys exist: - * - active: boolean, signals if the user is on this navigation entry - * - children: array that is empty if the key 'active' is false or - * contains the subentries if the key 'active' is true - */ - public static function getNavigation(){ - $navigation = self::proceedNavigation( self::$navigation ); - $navigation = self::addSubNavigation( $navigation ); - return $navigation; - } - - /** * @brief Returns the Settings Navigation * @returns associative array * @@ -295,57 +199,20 @@ class OC_App{ * entries are sorted by the key 'order' ascending. */ public static function getSettingsNavigation(){ - $navigation = self::proceedNavigation( self::$settingspages ); - $navigation = self::addSubNavigation( $navigation ); - - return $navigation; - } - - /** - * @brief Returns the admin navigation - * @returns associative array - * - * This function returns an array containing all admin pages added. The - * entries are sorted by the key 'order' ascending. - */ - public static function getAdminNavigation(){ - $navigation = self::proceedNavigation( self::$adminpages ); - $navigation = self::addSubNavigation( $navigation ); - - return $navigation; - } - - /// Private foo - private static function addSubNavigation( $list ){ - if(isset(self::$subnavigation[self::$activeapp])){ - $subNav=self::$subnavigation[self::$activeapp]; - foreach( $list as &$naventry ){ - if( $naventry['id'] == self::$activeapp ){ - $naventry['active'] = true; - $naventry['subnavigation'] = $subNav; - } - } - }else{ - foreach(self::$subnavigation as $parent=>$entries){ - $activeParent=false; - foreach($entries as &$subNav){ - $subNav['active']=$subNav['id'] == self::$activeapp; - if($subNav['active']){ - $activeParent=true; - } - } - if($activeParent){ - foreach( $list as &$naventry ){ - if( $naventry['id'] == $parent ){ - $naventry['active'] = true; - $naventry['subnavigation'] = $entries; - } - } - } - } + $admin=array( + array( "id" => "core_users", "order" => 2, "href" => OC_Helper::linkTo( "admin", "users.php" ), "name" => "Users", "icon" => OC_Helper::imagePath( "admin", "users.png" )), + array( "id" => "core_apps", "order" => 3, "href" => OC_Helper::linkTo( "admin", "apps.php?installed" ), "name" => "Apps", "icon" => OC_Helper::imagePath( "admin", "apps.png" )), + array( "id" => "files_administration", "order" => 3, "href" => OC_Helper::linkTo( "files", "admin.php" ), "name" => "Files", "icon" => OC_Helper::imagePath( "files", "folder.png" )), + ); + $settings=array( + array( "id" => "help", "order" => 1000, "href" => OC_Helper::linkTo( "help", "index.php" ), "name" => "Help", "icon" => OC_Helper::imagePath( "help", "help.png" )), + array( "id" => "settings", "order" => 1, "href" => OC_Helper::linkTo( "settings", "index.php" ), "name" => "Personal", "icon" => OC_Helper::imagePath( "settings", "personal.png" )) + ); + if( OC_Group::inGroup( $_SESSION["user_id"], "admin" )){ + $settings=array_merge($admin,$settings); } - - return $list; + $navigation = self::proceedNavigation($settings); + return $navigation; } /// This is private as well. It simply works, so don't ask for more details @@ -354,9 +221,6 @@ class OC_App{ $naventry['subnavigation'] = array(); if( $naventry['id'] == self::$activeapp ){ $naventry['active'] = true; - if( array_key_exists( $naventry['id'], self::$subnavigation )){ - $naventry['subnavigation'] = self::$subnavigation[$naventry['id']]; - } } else{ $naventry['active'] = false; @@ -393,6 +257,22 @@ class OC_App{ } /** + * @brief Returns the navigation + * @returns associative array + * + * This function returns an array containing all entries added. The + * entries are sorted by the key 'order' ascending. Additional to the keys + * given for each app the following keys exist: + * - active: boolean, signals if the user is on this navigation entry + * - children: array that is empty if the key 'active' is false or + * contains the subentries if the key 'active' is true + */ + public static function getNavigation(){ + $navigation = self::proceedNavigation( self::$navigation ); + return $navigation; + } + + /** * get the id of loaded app * @return string */ @@ -407,4 +287,48 @@ class OC_App{ return $topFolder; } } + + + /** + * get the forms for either settings, admin or personal + */ + public static function getForms($type){ + $forms=array(); + switch($type){ + case 'settings': + $source=self::$settingsForms; + break; + case 'admin': + $source=self::$adminForms; + break; + case 'personal': + $source=self::$personalForms; + break; + } + foreach($source as $form){ + $forms[]=include $form; + } + return $forms; + } + + /** + * register a settings form to be shown + */ + public static function registerSettings($app,$page){ + self::$settingsForms[]='apps/'.$app.'/'.$page.'.php'; + } + + /** + * register an admin form to be shown + */ + public static function registerAdmin($app,$page){ + self::$adminForms[]='apps/'.$app.'/'.$page.'.php'; + } + + /** + * register a personal form to be shown + */ + public static function registerPersonal($app,$page){ + self::$personalForms[]='apps/'.$app.'/'.$page.'.php'; + } } diff --git a/lib/l10n.php b/lib/l10n.php index 4e65af66c4f..5271bd4e589 100644 --- a/lib/l10n.php +++ b/lib/l10n.php @@ -146,16 +146,11 @@ class OC_L10N{ // If you add something don't forget to add it to $localizations // at the top of the page case 'date': - if( is_string( $data )) $data = strtotime( $data ); - return date( $this->localizations['date'], $data ); - break; case 'datetime': - if( is_string( $data )) $data = strtotime( $data ); - return date( $this->localizations['datetime'], $data ); - break; case 'time': - if( is_string( $data )) $data = strtotime( $data ); - return date( $this->localizations['time'], $data ); + if( $data instanceof DateTime ) return $data->format($this->localizations[$type]); + elseif( is_string( $data )) $data = strtotime( $data ); + return date( $this->localizations[$type], $data ); break; default: return false; diff --git a/lib/setup.php b/lib/setup.php index f87581d7582..192fd134608 100644 --- a/lib/setup.php +++ b/lib/setup.php @@ -46,39 +46,26 @@ class OC_Setup { $error[] = 'STEP 2 : data directory path is not set.'; } - if($dbtype=='mysql') { //mysql needs more config options + if($dbtype=='mysql' or $dbtype=='pgsql') { //mysql and postgresql needs more config options + if($dbtype=='mysql') + $dbprettyname = 'MySQL'; + else + $dbprettyname = 'PostgreSQL'; + if(empty($options['dbuser'])) { - $error[] = 'STEP 3 : MySQL database user is not set.'; + $error[] = "STEP 3 : $dbprettyname database user is not set."; } if(empty($options['dbpass'])) { - $error[] = 'STEP 3 : MySQL database password is not set.'; + $error[] = "STEP 3 : $dbprettyname database password is not set."; } if(empty($options['dbname'])) { - $error[] = 'STEP 3 : MySQL database name is not set.'; + $error[] = "STEP 3 : $dbprettyname database name is not set."; } if(empty($options['dbhost'])) { - $error[] = 'STEP 3 : MySQL database host is not set.'; + $error[] = "STEP 3 : $dbprettyname database host is not set."; } if(!isset($options['dbtableprefix'])) { - $error[] = 'STEP 3 : MySQL database table prefix is not set.'; - } - } - - if($dbtype=='pgsql') { //postgresql needs more config options - if(empty($options['pg_dbuser'])) { - $error[] = 'STEP 3 : PostgreSQL database user is not set.'; - } - if(empty($options['pg_dbpass'])) { - $error[] = 'STEP 3 : PostgreSQL database password is not set.'; - } - if(empty($options['pg_dbname'])) { - $error[] = 'STEP 3 : PostgreSQL database name is not set.'; - } - if(empty($options['pg_dbhost'])) { - $error[] = 'STEP 3 : PostgreSQL database host is not set.'; - } - if(!isset($options['pg_dbtableprefix'])) { - $error[] = 'STEP 3 : PostgreSQL database table prefix is not set.'; + $error[] = "STEP 3 : $dbprettyname database table prefix is not set."; } } @@ -150,11 +137,11 @@ class OC_Setup { } } elseif($dbtype == 'pgsql') { - $dbuser = $options['pg_dbuser']; - $dbpass = $options['pg_dbpass']; - $dbname = $options['pg_dbname']; - $dbhost = $options['pg_dbhost']; - $dbtableprefix = $options['pg_dbtableprefix']; + $dbuser = $options['dbuser']; + $dbpass = $options['dbpass']; + $dbname = $options['dbname']; + $dbhost = $options['dbhost']; + $dbtableprefix = $options['dbtableprefix']; OC_CONFIG::setValue('dbname', $dbname); OC_CONFIG::setValue('dbhost', $dbhost); OC_CONFIG::setValue('dbtableprefix', $dbtableprefix); @@ -224,7 +211,9 @@ class OC_Setup { OC_Installer::installShippedApps(true); //create htaccess files for apache hosts - self::createHtaccess(); //TODO detect if apache is used + if (strstr($_SERVER['SERVER_SOFTWARE'], 'Apache')) { + self::createHtaccess(); + } //and we are done OC_Config::setValue('installed', true); diff --git a/lib/template.php b/lib/template.php index 124343bd85b..2ba26eebac8 100644 --- a/lib/template.php +++ b/lib/template.php @@ -202,15 +202,12 @@ class OC_Template{ * * This function proceeds the template and prints its output. */ - public function printPage() - { + public function printPage(){ $data = $this->fetchPage(); - if( $data === false ) - { + if( $data === false ){ return false; } - else - { + else{ print $data; return true; } @@ -223,41 +220,29 @@ class OC_Template{ * This function proceeds the template. If $this->renderas is set, it will * will produce a full page. */ - public function fetchPage() - { + public function fetchPage(){ // global Data we need global $WEBROOT; global $SERVERROOT; $data = $this->_fetch(); - if( $this->renderas ) - { + if( $this->renderas ){ // Decide which page we show - if( $this->renderas == "user" ) - { + if( $this->renderas == "user" ){ $page = new OC_Template( "core", "layout.user" ); $search=new OC_Template( 'core', 'part.searchbox'); $search->assign('searchurl',OC_Helper::linkTo( 'search', 'index.php' )); $page->assign('searchbox', $search->fetchPage()); + if(array_search(OC_APP::getCurrentApp(),array('settings','admin','help'))!==false){ + $page->assign('bodyid','body-settings'); + }else{ + $page->assign('bodyid','body-user'); + } // Add navigation entry $page->assign( "navigation", OC_App::getNavigation()); - } - elseif( $this->renderas == "admin" ) - { - $page = new OC_Template( "core", "layout.admin" ); - $search=new OC_Template( 'core', 'part.searchbox'); - $search->assign('searchurl',OC_Helper::linkTo( 'search', 'index.php' )); - $page->assign('searchbox', $search->fetchPage()); - - // Add menu data - if( OC_Group::inGroup( $_SESSION["user_id"], "admin" )){ - $page->assign( "adminnavigation", OC_App::getAdminNavigation()); - } $page->assign( "settingsnavigation", OC_App::getSettingsNavigation()); - } - else - { + }else{ $page = new OC_Template( "core", "layout.guest" ); } @@ -295,8 +280,7 @@ class OC_Template{ $page->assign( "content", $data ); return $page->fetchPage(); } - else - { + else{ return $data; } } @@ -329,9 +313,14 @@ class OC_Template{ * Includes another template. use <?php echo $this->inc('template'); ?> to * do this. */ - public function inc( $file ){ + public function inc( $file, $additionalparams = null ){ // $_ erstellen $_ = $this->vars; + $l = $this->l10n; + + if( !is_null($additionalparams)){ + $_ = array_merge( $additionalparams, $this->vars ); + } // Einbinden ob_start(); |