00001 <?php
00002 class blogger_userOptions
00003 {
00004 var $parentUser;
00005 var $section;
00006 var $subSection;
00007 var $item;
00008
00009 var $title;
00010
00011 function blogger_userOptions( $parentUser, $section, $subSection )
00012 {
00013 $this->parentUser = &$parentUser;
00014 $this->section = $section;
00015 $this->subSection = $subSection;
00016 }
00017
00018 function renderOptions()
00019 {
00020 global $permissionlevels_array, $blogcategories;
00021
00022 $dialog = new optionsPanel("blogger_options");
00023 $dialog->showHeader = false;
00024
00025 $dialog->addOption( i18n("Personal allowance level"), i18n("Who, except for the owner, is able to view entries marked as personal"), $this->parentUser->getParam("allowsviewpersonal"), "allowsviewpersonal", "select", $permissionlevels_array );
00026
00027 $dialog->addHeader( i18n("Default settings for new blog entries"), "defaults" );
00028 $dialog->addOption( i18n("Personal"), i18n("Is this entry personal?"), $this->parentUser->getParam("personal"), "personal", "checkbox" );
00029 $dialog->addOption( i18n("Viewing allowance level"), i18n("Who, except for the owner, is able to view this entry"), $this->parentUser->getParam("viewlevel"), "viewlevel", "select", $permissionlevels_array );
00030 $dialog->addOption( i18n("Commenting allowance level"), i18n("Who, except for the owner, is able to comment on this entry"), $this->parentUser->getParam("commentlevel"), "commentlevel", "select", $permissionlevels_array );
00031
00032 $dialog->addHeader( i18n("Default categories for new blog entries"), "categories" );
00033
00034 $defaultCategories = $this->parentUser->getParam("defaultCategories");
00035 if( !is_array( $defaultCategories ) )
00036 $defaultCategories = array( "system" => array(), "user" => array() );
00037
00038
00039 foreach( $blogcategories as $key => $value )
00040 $categories[$value] = array( "title" => i18n($value), "description" => "" );
00041 $dialog->addOption( i18n("Sitewide categories"), i18n("Categories defined by the site administrators"), $defaultCategories["system"], "categoriesSystem", "multicheck", $categories );
00042
00043 $usercategories = $this->parentUser->getParam("categories");
00044 if( !is_array( $usercategories ) )
00045 $usercategories = array();
00046 if( count( $usercategories ) > 0 )
00047 {
00048 $categories = array();
00049 foreach( $usercategories as $key => $value )
00050 $categories[$value] = array( "title" => i18n($value), "description" => "" );
00051 $dialog->addOption( i18n("User defined categories"), i18n("Categories defined by the the owner of the blog"), $defaultCategories["user"], "categoriesUser", "multicheck", $categories );
00052 }
00053
00054 if( $dialog->submitted )
00055 {
00056 $this->parentUser->setParam( "allowsviewpersonal", $dialog->getValue("allowsviewpersonal") );
00057 $this->parentUser->setParam( "personal", $dialog->getValue("personal") );
00058 $this->parentUser->setParam( "viewlevel", $dialog->getValue("viewlevel") );
00059 $this->parentUser->setParam( "commentlevel", $dialog->getValue("commentlevel") );
00060
00061
00062 $defaultCategories = array( "system" => array(), "user" => array() );
00063 $newCategoriesSystem = $dialog->getValue("categoriesSystem");
00064 foreach( $blogcategories as $key => $value )
00065 $defaultCategories["system"][$value] = $newCategoriesSystem[$value];
00066 $newCategoriesUser = $dialog->getValue("categoriesUser");
00067 foreach( $usercategories as $key => $value )
00068 $defaultCategories["user"][$value] = $newCategoriesUser[$value];
00069 $this->parentUser->setParam( "defaultCategories", $defaultCategories );
00070 }
00071
00072 return $dialog->render();
00073 }
00074
00075 function renderCategories()
00076 {
00077 $dialog = new SimpleListEditor( $this->parentUser->getGlobalID("edit/options/categories"), $this->subSection, $this->parentUser->getParam("categories"), $this->item );
00078 $dialog->title = i18n("Category");
00079 $dialog->description = i18n("A string containing the name of the category. Please note that any spaces will be translated to underscores.");
00080 $renderedContent = $dialog->render();
00081 if( $dialog->changed )
00082 {
00083 foreach( $dialog->items as $key => $value )
00084 $dialog->items[$key] = str_replace( " ", "_", $value );
00085 $this->parentUser->setParam( "categories", $dialog->items );
00086 }
00087 return $renderedContent;
00088 }
00089
00090 function renderExternal()
00091 {
00092 $dialog = new SimpleListEditor( $this->parentUser->getGlobalID("edit/options/external"), $this->subSection, $this->parentUser->getParam("external"), $this->item );
00093 $dialog->title = i18n("URL");
00094 $dialog->description = i18n("The URL of the external feed you wish to add. Please note this should be an RSS file.");
00095 $renderedContent = $dialog->render();
00096 $oldExternalCache = $this->parentUser->getParam("externalCache");
00097 if( $dialog->changed )
00098 {
00099 foreach( $dialog->items as $key => $value )
00100 {
00101 $dialog->items[$key] = str_replace( " ", "%20", $value );
00102 if( substr( strtolower($dialog->items[$key]), 0, 7 ) != "http://" &&
00103 substr( strtolower($dialog->items[$key]), 0, 8 ) != "https://" &&
00104 substr( strtolower($dialog->items[$key]), 0, 6 ) != "ftp://" )
00105 $dialog->items[$key] = "http://" . $dialog->items[$key];
00106
00107
00108 if( array_key_exists( $dialog->items[$key], $oldExternalCache ) )
00109 $tempExternalCache[$dialog->items[$key]] = $oldExternalCache[$dialog->items[$key]];
00110
00111 else
00112 $tempExternalCache[$dialog->items[$key]] = array();
00113 }
00114
00115 $this->parentUser->setParam( "external", $dialog->items );
00116
00117 $this->parentUser->setParam( "externalCache", $tempExternalCache );
00118 }
00119 return $renderedContent;
00120 }
00121
00122 function render()
00123 {
00124 switch( $this->section )
00125 {
00126 case "external":
00127 $renderedContent = $this->renderExternal();
00128 $this->title = i18n("External Feeds");
00129 break;
00130 case "categories":
00131 $renderedContent = $this->renderCategories();
00132 $this->title = i18n("Categories");
00133 break;
00134 case "options":
00135 default:
00136 $renderedContent = $this->renderOptions();
00137 $this->title = i18n("Options");
00138 break;
00139 }
00140
00141 $renderedContent = "<form method=\"POST\" action=\"" . thisPageURL() . "\">$renderedContent</form>";
00142
00143 return renderInformationBox( $this->title, $renderedContent, false );
00144 }
00145 }
00146 ?>