00001 <?php
00002
00003 lt_include( PLOG_CLASS_PATH."class/database/dbobject.class.php" );
00004 lt_include( PLOG_CLASS_PATH."class/dao/blogsettings.class.php" );
00005
00012 class BlogInfo extends DbObject
00013 {
00014
00015 var $_blog;
00016 var $_owner;
00017 var $_about;
00018 var $_settings;
00019 var $_id;
00020
00021
00022 var $_createDate;
00023 var $_updateDate;
00024 var $_totalPosts;
00025 var $_totalComments;
00026 var $_totalTrackbacks;
00027 var $_ownerInfo;
00028 var $_usersInfo;
00029 var $_mangledBlog;
00030 var $_customDomain;
00031
00032
00033 var $_templateSet;
00034
00035
00036 var $_locale;
00037 var $_blogLocale;
00038
00039
00040 var $_status;
00041
00042
00043 var $_categoryId;
00044 var $_category;
00045
00046 function BlogInfo( $blog, $owner, $about, $settings, $id = -1 )
00047 {
00048 lt_include( PLOG_CLASS_PATH."class/data/timestamp.class.php" );
00049
00050 $this->DbObject();
00051
00052 $this->setBlog( $blog );
00053 $this->_owner = $owner;
00054 $this->_about = $about;
00055 $this->_settings = $settings;
00056 if( empty( $this->_settings ) )
00057 $this->_settings = new BlogSettings();
00058
00059 $this->_id = $id;
00060
00061 $this->_createDate = "";
00062 $this->_updateDate = "";
00063 $this->_totalPosts = 0;
00064 $this->_totalTrackbacks = 0;
00065 $this->_totalComments = 0;
00066 $this->_usersInfo = null;
00067
00068 $t = new Timestamp();
00069 $this->_createDate = $t->getTimestamp();
00070 $this->_updateDate = $t->getTimestamp();
00071
00072
00073 $this->_templateSet = null;
00074
00075
00076 $this->_status = BLOG_STATUS_ACTIVE;
00077
00078
00079 $this->_ownerInfo = null;
00080
00081
00082 $this->_category = null;
00083 $this->_categoryId = 0;
00084
00085
00086 $this->_showInSummary = true;
00087
00088 $this->_pk = "id";
00089 $this->_fields = Array(
00090 "blog" => "getBlog",
00091 "owner_id" => "getOwnerId",
00092 "about" => "getUnformattedAbout",
00093 "settings" => "getSettings",
00094 "mangled_blog" => "getMangledBlogName",
00095 "status" => "getStatus",
00096 "show_in_summary" => "getShowInSummary",
00097 "blog_category_id" => "getBlogCategoryId",
00098 "create_date" => "getCreateDate",
00099 "last_update_date" => "getUpdateDate",
00100 "num_posts" => "getTotalPosts",
00101 "num_comments" => "getTotalComments",
00102 "num_trackbacks" => "getTotalTrackbacks",
00103 "custom_domain" => "getCustomDomain"
00104 );
00105 }
00106
00112 function getBlog()
00113 {
00114 return $this->_blog;
00115 }
00116
00122 function getOwnerId()
00123 {
00124 return $this->_owner;
00125 }
00126
00133 function getOwner()
00134 {
00135 return $this->_owner;
00136 }
00137
00145 function getAbout( $format = true )
00146 {
00147 $text = $this->_about;
00148
00149 if( $format ) {
00150 lt_include( PLOG_CLASS_PATH."class/data/textfilter.class.php" );
00151 $text = TextFilter::autoP( $text );
00152 }
00153
00154 return( $text );
00155 }
00156
00160 function getUnformattedAbout()
00161 {
00162 return( $this->getAbout( false ));
00163 }
00164
00169 function getSettings()
00170 {
00171 return $this->_settings;
00172 }
00173
00174 function getSetting( $setting )
00175 {
00176 return $this->_settings->getValue( $setting );
00177 }
00178
00182 function getValue( $value )
00183 {
00184 if( !$this->_settings )
00185 return "";
00186
00187 return $this->getSetting( $value );
00188 }
00189
00193 function setValue( $key, $value )
00194 {
00195 if( !$this->_settings )
00196 return true;
00197
00198 $this->_settings->setValue( $key, $value );
00199
00200 return true;
00201 }
00202
00208 function addProperties( $properties )
00209 {
00210 return $this->setProperties( $properties );
00211 }
00212
00216 function setProperties( $properties )
00217 {
00218
00219 if( !is_array($properties))
00220 return true;
00221
00222 foreach( $properties as $key => $value ) {
00223 $this->setValue( $key, $value );
00224 }
00225
00226 return true;
00227 }
00228
00232 function getCreateDateObject()
00233 {
00234 lt_include( PLOG_CLASS_PATH."class/data/timestamp.class.php" );
00235 return( new Timestamp( $this->_createDate ));
00236 }
00237
00238 function getCreateDate()
00239 {
00240 return( $this->_createDate );
00241 }
00242
00243 function setCreateDate( $date )
00244 {
00245 $this->_createDate = $date;
00246 }
00247
00250 function getUpdateDateObject()
00251 {
00252 lt_include( PLOG_CLASS_PATH."class/data/timestamp.class.php" );
00253 return( new Timestamp( $this->_updateDate ));
00254 }
00255
00256 function getUpdateDate()
00257 {
00258 return( $this->_updateDate );
00259 }
00260
00261 function setUpdateDate( $date )
00262 {
00263 $this->_updateDate = $date;
00264 }
00265
00268 function getTotalPosts()
00269 {
00270 return $this->_totalPosts;
00271 }
00272
00276 function setTotalPosts( $totalPosts )
00277 {
00278 $this->_totalPosts = $totalPosts;
00279 }
00280
00284 function setTotalComments( $totalComments )
00285 {
00286 $this->_totalComments = $totalComments;
00287 }
00288
00291 function getTotalComments()
00292 {
00293 return $this->_totalComments;
00294 }
00295
00299 function setTotalTrackbacks( $totalTrackbacks )
00300 {
00301 $this->_totalTrackbacks = $totalTrackbacks;
00302 }
00303
00306 function getTotalTrackbacks()
00307 {
00308 return $this->_totalTrackbacks;
00309 }
00310
00315 function getOwnerInfo()
00316 {
00317 lt_include( PLOG_CLASS_PATH."class/dao/users.class.php" );
00318
00319 if( $this->_ownerInfo === null ) {
00320 $users = new Users();
00321 $ownerInfo = $users->getUserInfoFromId( $this->_owner );
00322 $this->setOwnerInfo( $ownerInfo );
00323 }
00324
00325 return $this->_ownerInfo;
00326 }
00327
00334 function getUsersInfo()
00335 {
00336 lt_include( PLOG_CLASS_PATH."class/dao/users.class.php" );
00337
00338 if( $this->_usersInfo === null ) {
00339 $users = new Users();
00340 $blogUsers = $users->getBlogUsers( $this->getId());
00341 $this->setUsersInfo( $blogUsers );
00342 }
00343
00344 return $this->_usersInfo;
00345 }
00346
00352 function getId()
00353 {
00354 return $this->_id;
00355 }
00356
00360 function setBlog( $blog )
00361 {
00362 lt_include( PLOG_CLASS_PATH."class/data/textfilter.class.php" );
00363
00364 $tf = new Textfilter();
00365 $this->_blog = $tf->filterAllHTML($blog);
00366 }
00367
00372 function setOwner( $owner )
00373 {
00374 $this->_owner = $owner;
00375 }
00376
00380 function setAbout( $about )
00381 {
00382 $this->_about = $about;
00383 }
00384
00388 function setSettings( $settings )
00389 {
00390 $this->_settings = $settings;
00391 }
00392
00396 function setOwnerInfo( $newOwnerInfo )
00397 {
00398 $this->_ownerInfo = $newOwnerInfo;
00399 }
00400
00404 function setUsersInfo( $newUsersInfo )
00405 {
00406 $this->_usersInfo = $newUsersInfo;
00407 }
00408
00412 function setId( $id )
00413 {
00414 $this->_id = $id;
00415 }
00416
00422 function getTemplate()
00423 {
00424 return $this->getSetting( "template");
00425 }
00426
00433 function setTemplate( $template )
00434 {
00435
00436 $this->_settings->setValue( "template", $template );
00437
00438
00439 $this->_templateSet = null;
00440
00441 return true;
00442 }
00443
00452 function getBlogRequestGenerator()
00453 {
00454 lt_include( PLOG_CLASS_PATH."class/net/requestgenerator.class.php" );
00455
00456 return RequestGenerator::getRequestGenerator( $this );
00457 }
00458
00465 function getTemplateSet()
00466 {
00467
00468
00469 if( $this->_templateSet === null ) {
00470 lt_include( PLOG_CLASS_PATH."class/template/templatesets/templatesets.class.php" );
00471 $ts = new TemplateSets();
00472 $this->_templateSet = $ts->getTemplateSet( $this->getTemplate(), $this->getId());
00473 if( $this->_templateSet == null ) {
00474
00475 $this->_templateSet = $ts->getDefaultTemplateSet();
00476 }
00477 }
00478
00479 return $this->_templateSet;
00480 }
00481
00488 function setTemplateSet( $templateSet )
00489 {
00490 $this->setTemplate( $templateSet->getName());
00491
00492 return true;
00493 }
00494
00500 function &getLocale()
00501 {
00502 if( $this->_locale === null ) {
00503 lt_include( PLOG_CLASS_PATH."class/locale/locales.class.php" );
00504 $this->_locale =& Locales::getLocale( $this->getSetting( "locale" ), "en_UK" );
00505 }
00506
00507 return $this->_locale;
00508 }
00509
00510 function &getBlogLocale()
00511 {
00512 if( $this->_blogLocale === null ) {
00513 lt_include( PLOG_CLASS_PATH."class/locale/locales.class.php" );
00514 $this->_blogLocale =& Locales::getBlogLocale( $this->getSetting( "locale" ), "en_UK" );
00515 }
00516
00517 return $this->_blogLocale;
00518 }
00519
00520
00527 function setLocale( $locale )
00528 {
00529 $this->_locale = $locale;
00530 $this->_settings->setValue( "locale", $locale->getLocaleCode());
00531
00532 return true;
00533 }
00534
00540 function getStatus()
00541 {
00542 return $this->_status;
00543 }
00544
00551 function setStatus( $status )
00552 {
00553 $this->_status = $status;
00554
00555 return true;
00556 }
00557
00564 function getResourcesQuota()
00565 {
00566 $quota = $this->getSetting( "resources_quota" );
00567
00568
00569
00570 if( $quota == "" ) {
00571 lt_include( PLOG_CLASS_PATH."class/gallery/dao/galleryresourcequotas.class.php" );
00572 $quota = GalleryResourceQuotas::getGlobalResourceQuota();
00573 }
00574
00575 return $quota;
00576 }
00577
00583 function setResourcesQuota( $quota )
00584 {
00585 $this->_settings->setValue( "resources_quota", $quota );
00586
00587 return true;
00588 }
00589
00596 function getBlogCategoryId()
00597 {
00598 return( $this->_categoryId );
00599 }
00600
00606 function setBlogCategoryId( $categoryId )
00607 {
00608 if( $categoryId != $this->_categoryId )
00609 $this->_category = null;
00610
00611 $this->_categoryId = $categoryId;
00612 }
00613
00619 function getBlogCategory()
00620 {
00621
00622
00623 if( $this->_categoryId == 0 )
00624 return( false );
00625
00626 if( $this->_category == null ) {
00627 lt_include( PLOG_CLASS_PATH."class/dao/blogcategories.class.php" );
00628 $blogCategories = new BlogCategories();
00629 $this->_category = $blogCategories->getBlogCategory( $this->_categoryId );
00630 }
00631
00632 return( $this->_category );
00633 }
00634
00640 function setMangledBlogName( $mangledBlog, $modify = false )
00641 {
00642 if( $modify ) {
00643 lt_include( PLOG_CLASS_PATH."class/data/textfilter.class.php" );
00644 $mangledBlog = Textfilter::domainize( $mangledBlog );
00645 }
00646 $this->_mangledBlog = $mangledBlog;
00647 }
00648
00652 function getMangledBlogName()
00653 {
00654
00655 if( $this->_mangledBlog === null ) {
00656 lt_include( PLOG_CLASS_PATH."class/data/textfilter.class.php" );
00657 $this->setMangledBlogName( $this->getBlog(), true );
00658 }
00659
00660 return( $this->_mangledBlog );
00661 }
00662
00663
00669 function setCustomDomain($customDomain)
00670 {
00671 lt_include( PLOG_CLASS_PATH."class/data/textfilter.class.php" );
00672 $this->_customDomain = Textfilter::domainize($customDomain);
00673 }
00674
00678 function getCustomDomain()
00679 {
00680
00681 if($this->_customDomain === null){
00682 lt_include( PLOG_CLASS_PATH."class/data/textfilter.class.php" );
00683 $this->_customDomain = Textfilter::domainize($this->getMangledBlog());
00684 }
00685
00686 return($this->_customDomain);
00687 }
00688
00693 function getMangledBlog()
00694 {
00695 return( $this->getMangledBlogName());
00696 }
00697
00701 function getShowInSummary()
00702 {
00703 return( $this->_showInSummary );
00704 }
00705
00711 function setShowInSummary( $showInSummary )
00712 {
00713 $this->_showInSummary = $showInSummary;
00714 }
00715
00719 function __sleep()
00720 {
00721 $this->_ownerInfo = null;
00722 $this->_usersInfo = null;
00723 $this->_category = null;
00724 $this->_locale = null;
00725 $this->_blogLocale = null;
00726
00727 return( parent::__sleep());
00728 }
00729 }
00730 ?>