/**
  * Carries out the specified action
  */
 function perform()
 {
     $categories = new ArticleCategories();
     $blogCategories = $categories->getBlogCategories($this->_blogInfo->getId());
     // but make sure that we have at least one!
     if (count($blogCategories) == 0) {
         $this->_view = new AdminTemplatedView($this->_blogInfo, "newpostcategory");
         $this->_view->setSuccessMessage($this->_locale->tr("error_must_have_one_category"));
         $this->setCommonData();
         return false;
     }
     // initialize the view
     $this->_view = new AdminNewPostView($this->_blogInfo);
     $this->setCommonData();
     // better to return true if everything fine
     return true;
 }
 function render()
 {
     // fetch the categories
     $categories = new ArticleCategories();
     $blogSettings = $this->_blogInfo->getSettings();
     $categoriesOrder = $blogSettings->getValue("categories_order");
     $blogCategories = $categories->getBlogCategories($this->_blogInfo->getId(), false, $categoriesOrder);
     // get some stuff for the time stamp of the post, which is changeable now
     //$t = new Timestamp();
     $t = Timestamp::getBlogDate($this->_blogInfo);
     //$t->toUTC();
     //
     // changes to make plog store its dates with the time difference already
     // applied, instead of applying it dynamically
     //
     $config =& Config::getConfig();
     /*if( $config->getValue( "time_difference_calculation" == TIME_DIFFERENCE_CALCULATION_STATIC ) {
     		$blogSettings = $this->_blogInfo->getSettings();
     		$difference = $blogSettings->getValue( "time_offset" );
               	$t->setDate( Timestamp::getDateWithOffset( $t->getDate(), $difference ), DATE_FORMAT_TIMESTAMP );
           	}*/
     // fetch the custom fields, if any, but not including the ones that have been set to "hidden"...
     $customFields = new CustomFields();
     $blogFields = $customFields->getBlogCustomFields($this->_blogInfo->getId(), false);
     // and put everything in the template
     $locale = $this->_blogInfo->getLocale();
     $this->setValue("commentsEnabled", $blogSettings->getValue("comments_enabled"));
     $this->setValue("categories", $blogCategories);
     $this->setValue("today", $t);
     $this->setValue("months", $locale->getMonthNames());
     $this->setValue("days", $locale->getDayNamesShort());
     $this->setValue("years", Timestamp::getYears());
     $this->setValue("hours", Timestamp::getAllHours());
     $this->setValue("minutes", Timestamp::getAllMinutes());
     $this->setValue("customfields", $blogFields);
     $this->setValue("poststatus", ArticleStatus::getStatusList());
     $this->setValue("sendPings", $config->getValue("send_xmlrpc_pings_enabled_by_default", true));
     $this->setValue("xmlRpcPingEnabled", $config->getValue("xmlrpc_ping_enabled", false));
     $this->setValue("autoSaveNewDraftsTimeMillis", $config->getValue("autosave_new_drafts_time_millis"));
     $this->setValue("xmlHttpRequestSupportEnabled", $config->getValue("save_drafts_via_xmlhttprequest_enabled"));
     $this->setValue("postDateTime", $t->getDay() . "/" . $t->getMonth() . "/" . $t->getYear() . " " . $t->getHour() . ":" . $t->getMinutes());
     parent::render();
 }
 function render()
 {
     // fetch the current settings
     $blogSettings = $this->_blogInfo->getSettings();
     $pluginEnabled = $blogSettings->getValue("plugin_moblog_enabled");
     $categoryId = $blogSettings->getValue("plugin_moblog_article_category_id");
     $albumId = $blogSettings->getValue("plugin_moblog_gallery_resource_album_id");
     $resourcePreviewType = $blogSettings->getValue("plugin_moblog_resource_preview_type");
     // fetch all the current article categories
     $categories = new ArticleCategories();
     $blogCategories = $categories->getBlogCategories($this->_blogInfo->getId());
     // fetch all the current gallery albums
     $albums = new GalleryAlbums();
     $blogAlbums = $albums->getUserAlbums($this->_blogInfo->getId());
     // finally pass all these things to the templates
     $this->setValue("pluginEnabled", $pluginEnabled);
     $this->setValue("categoryId", $categoryId);
     $this->setValue("albumId", $albumId);
     $this->setValue("albums", $blogAlbums);
     $this->setValue("categories", $blogCategories);
     $this->setValue("resourcePreviewType", $resourcePreviewType);
     parent::render();
 }
 /**
  * renders the view
  */
 function render()
 {
     // fetch all the articles for edition, but we need to know whether we are trying to
     // search for some of them or simply filter them based on certain criteria
     $articles = new Articles();
     $posts = $articles->getBlogArticles($this->_blogInfo->getId(), $this->_showMonth, $this->_itemsPerPage, $this->_showCategory, $this->_showStatus, $this->_showUser, 0, $this->_searchTerms, $this->_page);
     // get the total number of posts
     $numPosts = $articles->getNumBlogArticles($this->_blogInfo->getId(), $this->_showMonth, $this->_itemsPerPage, $this->_showCategory, $this->_showStatus, $this->_showUser, 0, $this->_searchTerms, $this->_page);
     //print("number = $numPosts<br/>");
     $pager = new Pager("?op=editPosts&amp;showStatus={$this->_showStatus}&amp;showCategory={$this->_showCategory}&amp;showUser={$this->_showUser}&amp;searchTerms={$this->_searchTerms}&amp;page=", $this->_page, $numPosts, $this->_itemsPerPage);
     $this->setValue("posts", $posts);
     // throw the even in case somebody is listening to it
     $this->notifyEvent(EVENT_POSTS_LOADED, array("posts" => &$posts));
     // and the categories
     $categories = new ArticleCategories();
     $blogSettings = $this->_blogInfo->getSettings();
     $categoriesOrder = $blogSettings->getValue("categories_order");
     $blogCategories = $categories->getBlogCategories($this->_blogInfo->getId(), false, $categoriesOrder);
     $this->notifyEvent(EVENT_CATEGORIES_LOADED, array("categories" => &$blogCategories));
     // and all the users that belong to this blog
     $users = new Users();
     $blogUsers = $users->getBlogUsers($this->_blogInfo->getId());
     // and all the post status available
     $postStatusList = ArticleStatus::getStatusList(true);
     $this->setValue("categories", $blogCategories);
     // values for the session, so that we can recover the status
     // of the filters later on in subsequent requests
     $this->setSessionValue("showCategory", $this->_showCategory);
     $this->setSessionValue("showStatus", $this->_showStatus);
     $this->setSessionValue("showUser", $this->_showUser);
     $this->setSessionValue("showMonth", $this->_showMonth);
     // values for the view
     $this->setValue("currentcategory", $this->_showCategory);
     $this->setValue("currentstatus", $this->_showStatus);
     $this->setValue("currentuser", $this->_showUser);
     $this->setValue("currentmonth", $this->_showMonth);
     $this->setValue("users", $blogUsers);
     $this->setValue("months", $this->_getMonths());
     $this->setValue("poststatus", $postStatusList);
     $this->setValue("searchTerms", $this->_searchTerms);
     $this->setValue("pager", $pager);
     parent::render();
 }