00001 <?PHP
00005 class blogger_entryEditor
00006 {
00007 var $entry;
00008
00014 function blogger_entryEditor( $entry )
00015 {
00016 $this->entry = &$entry;
00017 }
00018
00019 function render()
00020 {
00021 global $permissionlevels_array, $userinfo_folder, $blogcategories;
00022
00023 $availableCategories = array();
00024
00025 $usercategories = $this->entry->parentUser->getParam("categories");
00026 foreach( $blogcategories as $key => $value );
00027 $availableCategories["system($value)"] = array( "title" => i18n("##0## (system category)", array( i18n( $value ) ) ), "description" => "" );
00028
00029 foreach( $usercategories as $key => $value );
00030 $availableCategories["user($value)"] = array( "title" => $value, "description" => "" );
00031
00032 $theDefaultCategories = array();
00033 $defaultCategories = $this->entry->parentUser->getParam("defaultCategories");
00034 foreach( $defaultCategories["system"] as $key => $value )
00035 $theDefaultCategories["system($key)"] = $value;
00036 foreach( $defaultCategories["user"] as $key => $value )
00037 $theDefaultCategories["user($key)"] = $value;
00038
00039 $dialog = new optionsPanel( "bloggerEntry" );
00040
00041 $dialog->showHeader = false;
00042 $dialog->saveTitle = i18n("Save");
00043 $dialog->addCommand( i18n("Preview"), "preview" );
00044 $dialog->revertTitle = i18n("Discard changes");
00045
00046 $dialog->addOption( i18n("Title"), i18n("The title of the blog entry. This is what is shown in listings when no content is shown"), $this->entry->title, "title", "text" );
00047 $dialog->addOption( i18n("Published"), i18n("Wether or not to show this entry to the world - until the entry is published, it does not show up in any lists for anyone but the author"), $this->entry->published, "published", "checkbox" );
00048 $dialog->addOption( i18n("Time"), i18n("The time the entry was created."), $this->entry->timestamp, "timestamp", "datetime" );
00049 $dialog->addOption( i18n("Personal"), i18n("Is this entry personal?"), $this->entry->personal, "personal", "checkbox" );
00050 $dialog->addOption( i18n("Viewing allowance level"), i18n("Who, except for the owner, is able to view this entry"), $this->entry->viewLevel, "viewLevel", "select", $permissionlevels_array );
00051 $dialog->addOption( i18n("Commenting allowance level"), i18n("Who, except for the owner, is able to comment on this entry"), $this->entry->commentLevel, "commentLevel", "select", $permissionlevels_array );
00052 $dialog->addOption( i18n("Categories"), i18n("What categories do you wish this entry to show up under?"), $theDefaultCategories, "categories", "multicheck", $availableCategories );
00053 $dialog->addOption( i18n("Content"), i18n("The content of the entry"), $this->entry->content, "content", "pagedata" );
00054
00055 $renderedData = "";
00056
00057 if( $dialog->submitted )
00058 {
00059 if( $this->entry->lock() )
00060 {
00061
00062 $this->entry->load();
00063 $this->entry->title = $dialog->getValue("title");
00064 $this->entry->published = $dialog->getValue("published");
00065 $this->entry->personal = $dialog->getValue("personal");
00066 $this->entry->viewLevel = $dialog->getValue("viewLevel");
00067 $this->entry->commentLevel = $dialog->getValue("commentLevel");
00068 $this->entry->categories = $dialog->getValue("categories");
00069 $this->entry->content = $dialog->getValue("content");
00070
00071 $timestampChanged = ( $this->entry->timestamp != $dialog->getValue("timestamp") ) ? $this->entry->timestamp : 0;
00072 $this->entry->timestamp = $dialog->getValue("timestamp");
00073
00074 if( $dialog->submitted == "preview" )
00075 {
00076
00077 $renderedData .= renderWarningBox( i18n("Not saved"), i18n("Please note that this is only a preview and that the entry is NOT saved.\nThe preview shows the listing version of the entry, and the full version of the entry. If there is a horizontal ruler in the content, it further shows the block version of the entry.") );
00078
00079 $renderedData .= $this->entry->render( false, true );
00080 if( strpos( $this->entry->content, "---" ) > 0 )
00081 $renderedData .= $this->entry->render(true);
00082 $renderedData .= $this->entry->render();
00083 }
00084 else
00085 {
00086
00087 if( $timestampChanged > 0 )
00088 {
00089
00091
00092 unlink( $this->entry->filename );
00093 $this->entry->filename = $userinfo_folder . "/" . $this->entry->username . "/blogger/" . $this->entry->timestamp . ".php";
00094
00095 while( file_exists( $this->entry->filename ) )
00096 {
00097
00098 $dialog->options["timestamp"]["current"]++;
00099 $this->entry->timestamp = $dialog->getValue("timestamp");
00100 $this->entry->filename = $userinfo_folder . "/" . $this->entry->username . "/" . $this->entry->timestamp . ".php";
00101 }
00102 }
00103
00104
00105 $this->entry->save();
00106
00107 header( "Location: " . globalIDtoURL("user/" . $this->entry->username . "/blogger/edit") );
00108 }
00109 $this->entry->unlock();
00110 }
00111 else
00112 $renderedData .= renderErrorBox( i18n("Not locked!"), i18n("The entry could not be locked! Please try again.") );
00113 }
00114
00115 $renderedData .= $dialog->render();
00116
00117 return $renderedData;
00118 }
00119 }
00120 ?>