コード例 #1
0
 /**
  * Private function.
  *
  * @private.
  */
 function _fillBlogInformation($query_result, $extended = false)
 {
     $blogInfo = new BlogInfo(stripslashes($query_result["blog"]), $query_result["owner_id"], stripslashes($query_result["about"]), unserialize($query_result["settings"]), $query_result["id"]);
     // load information about the blog owner
     $blogInfo->setStatus($query_result["status"]);
     $blogInfo->setMangledBlog($query_result["mangled_blog"]);
     return $blogInfo;
 }
コード例 #2
0
 function perform()
 {
     // fetch the validated data
     $this->_blogName = Textfilter::filterAllHTML($this->_request->getValue("blogName"));
     $this->_ownerId = $this->_request->getValue("blogOwner");
     $this->_blogProperties = $this->_request->getValue("properties");
     // check that the user really exists
     $users = new Users();
     $userInfo = $users->getUserInfoFromId($this->_ownerId);
     if (!$userInfo) {
         $this->_view = new AdminCreateBlogView($this->_blogInfo);
         $this->_form->setFieldValidationStatus("blogOwner", false);
         $this->setCommonData(true);
         return false;
     }
     // now that we have validated the data, we can proceed to create the user, making
     // sure that it doesn't already exists
     $blogs = new Blogs();
     $blog = new BlogInfo($this->_blogName, $this->_ownerId, "", "");
     $blog->setProperties($this->_blogProperties);
     $this->notifyEvent(EVENT_PRE_BLOG_ADD, array("blog" => &$blog));
     $newBlogId = $blogs->addBlog($blog);
     if (!$newBlogId) {
         $this->_view = new AdminCreateBlogView($this->_blogInfo);
         $this->_form->setFieldValidationStatus("blogName", false);
         $this->setCommonData();
         return false;
     }
     // add a default category and a default post
     $articleCategories = new ArticleCategories();
     $articleCategory = new ArticleCategory("General", "", $newBlogId, true);
     $catId = $articleCategories->addArticleCategory($articleCategory);
     $config =& Config::getConfig();
     $locale =& Locales::getLocale($config->getValue("default_locale"));
     $articleTopic = $locale->tr("register_default_article_topic");
     $articleText = $locale->tr("register_default_article_text");
     $article = new Article($articleTopic, $articleText, array($catId), $this->_ownerId, $newBlogId, POST_STATUS_PUBLISHED, 0, array(), "welcome");
     $t = new Timestamp();
     $article->setDateObject($t);
     $articles = new Articles();
     $articles->addArticle($article);
     // and inform everyone that everything went ok
     $this->notifyEvent(EVENT_POST_BLOG_ADD, array("blog" => &$blog));
     $this->_view = new AdminSiteBlogsListView($this->_blogInfo);
     $this->_view->setSuccessMessage($this->_locale->pr("blog_added_ok", $blog->getBlog()));
     $this->setCommonData();
     return true;
 }
コード例 #3
0
 function perform()
 {
     // retrieve the values from the view
     $this->_blogName = $this->_request->getValue("blogName");
     $this->_ownerId = $this->_request->getValue("ownerid");
     $this->_blogProperties = $this->_request->getValue("properties");
     $this->_blogTemplate = $this->_request->getValue("blogTemplate");
     $this->_blogLocale = $this->_request->getValue("blogLocale");
     // configure the blog
     $blogs = new Blogs();
     $blog = new BlogInfo($this->_blogName, $this->_ownerId, "", "");
     $blog->setProperties($this->_blogProperties);
     $blog->setStatus(BLOG_STATUS_ACTIVE);
     $blogSettings = $blog->getSettings();
     $blogSettings->setValue("locale", $this->_blogLocale);
     $blogSettings->setValue("template", $this->_blogTemplate);
     $blog->setSettings($blogSettings);
     // and now save it to the database
     $newblogId = $blogs->addBlog($blog);
     if (!$newblogId) {
         $this->_view = new WizardView("step4");
         $this->_view->setValue("siteLocales", Locales::getLocales());
         $ts = new TemplateSets();
         $this->_view->setValue("siteTemplates", $ts->getGlobalTemplateSets());
         $this->_view->setErrorMessage("There was an error creating the new blog");
         $this->setCommonData(true);
         return false;
     }
     // if the blog was created, we can add some basic information
     // add a category
     $articleCategories = new ArticleCategories();
     $articleCategory = new ArticleCategory("General", "", $newblogId, true);
     $catId = $articleCategories->addArticleCategory($articleCategory);
     // load the right locale
     $locale =& Locales::getLocale($this->_blogLocale);
     // and load the right text
     $articleTopic = $locale->tr("register_default_article_topic");
     $articleText = $locale->tr("register_default_article_text");
     $article = new Article($articleTopic, $articleText, array($catId), $this->_ownerId, $newblogId, POST_STATUS_PUBLISHED, 0, array(), "welcome");
     $t = new Timestamp();
     $article->setDateObject($t);
     $articles = new Articles();
     $articles->addArticle($article);
     // save a few things in the default configuration
     $config =& Config::getConfig();
     // default blog id
     $config->saveValue("default_blog_id", (int) $newblogId);
     // default locale
     $config->saveValue("default_locale", $this->_blogLocale);
     // and finally, the default template
     $config->saveValue("default_template", $this->_blogTemplate);
     //
     // detect wether we have GD available and set the blog to use it
     //
     if (GdDetector::detectGd()) {
         $config->saveValue("thumbnail_method", "gd");
         $message = "GD has been detected and set as the backend for dealing with images.";
     } else {
         $pathToConvert = $config->getValue("path_to_convert");
         if ($pathToConvert) {
             $config->saveValue("thumbnail_method", "imagemagick");
             $message = "ImageMagick has been detected and set as the backend for dealing with images.";
         } else {
             // nothing was found, so we'll have to do away with the 'null' resizer...
             $config->saveValue("thumbnail_method", "null");
             $message = "Neither GD nor ImageMagick have been detected in this host so it will not be possible to generate thumbnails from images.";
         }
     }
     $this->_view = new WizardView("step5");
     $this->_view->setValue("message", $message);
     return true;
 }
コード例 #4
0
 /**
  * create the blog
  */
 function createBlog($userId)
 {
     $this->blogName = stripslashes($this->_request->getValue("blogName"));
     $this->blogLocale = $this->_request->getValue("blogLocale");
     $this->templateId = $this->_request->getValue("templateId");
     // get the default locale configured for the site
     $blogs = new Blogs();
     $blogInfo = new BlogInfo($this->blogName, $userId, "", "");
     if ($this->need_confirm == 1) {
         $blogInfo->setStatus(BLOG_STATUS_UNCONFIRMED);
     } else {
         $blogInfo->setStatus(BLOG_STATUS_ACTIVE);
     }
     $locale = Locales::getLocale($this->blogLocale);
     $blogInfo->setLocale($locale);
     $blogInfo->setTemplate($this->templateId);
     $newblogId = $blogs->addBlog($blogInfo);
     if (!$newblogId) {
         $this->_view = new SummaryView("registererror");
         $this->_view->setErrorMessage($this->_locale->tr("error_creating_blog"));
         return false;
     }
     // get info about the blog
     $blogInfo = $blogs->getBlogInfo($newblogId);
     $this->_blogInfo = $blogInfo;
     // if the blog was created, we can add some basic information
     // add a category
     $articleCategories = new ArticleCategories();
     $articleCategory = new ArticleCategory($locale->tr("register_default_category"), "", $newblogId, true);
     $catId = $articleCategories->addArticleCategory($articleCategory);
     // add an article based on that category
     $articleTopic = $locale->tr("register_default_article_topic");
     $articleText = $locale->tr("register_default_article_text");
     $article = new Article($articleTopic, $articleText, array($catId), $userId, $newblogId, POST_STATUS_PUBLISHED, 0, array(), "welcome");
     $article->setDateObject(new Timestamp());
     // set it to the current date
     $article->setCommentsEnabled(true);
     // enable comments
     $articles = new Articles();
     $articles->addArticle($article);
     return true;
 }