[ Index ]
 

Code source de LifeType 1.2.4

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/class/view/admin/ -> admineditsiteblogview.class.php (source)

   1  <?php
   2  
   3      lt_include( PLOG_CLASS_PATH.'class/view/admin/admintemplatedview.class.php' );
   4      lt_include( PLOG_CLASS_PATH.'class/locale/locales.class.php' );
   5      lt_include( PLOG_CLASS_PATH.'class/template/templatesets/templatesets.class.php' );
   6      lt_include( PLOG_CLASS_PATH.'class/dao/blogstatus.class.php' );
   7      lt_include( PLOG_CLASS_PATH."class/net/http/subdomains.class.php" );
   8      lt_include( PLOG_CLASS_PATH."class/dao/blogcategories.class.php" );        
   9      
  10      /**
  11       * \ingroup View
  12       * @private
  13       *    
  14       * shows the view to edit a blog from the site
  15       */
  16      class AdminEditSiteBlogView extends AdminTemplatedView
  17      {
  18          var $_editBlogInfo;
  19          var $_error;
  20      
  21  		function AdminEditSiteBlogView( $blogInfo, $editBlogInfo = null )
  22          {
  23              // fetch information about the blog we're editing
  24              if( $editBlogInfo == null )
  25                  $this->_editBlogInfo = $this->getSessionValue( 'editBlogInfo' );
  26              else
  27                  $this->_editBlogInfo = $editBlogInfo;
  28              
  29              // this stuff is a bit weird but I couldn't find a better way to do it!
  30              if( $this->_editBlogInfo ) {
  31                  $this->AdminTemplatedView( $blogInfo, 'editblog' );
  32                  $this->_error = false;
  33                  $this->setSessionValue( 'editBlogInfo', $this->_editBlogInfo );
  34                  // ...
  35                  // export data to the view
  36                  $this->setValue( 'editblog', $this->_editBlogInfo );
  37                  $this->setValue( 'editblogsettings', $this->_editBlogInfo->getSettings());
  38                  // blog settings...
  39                  $blogTemplateSet = $this->_editBlogInfo->getTemplateSet();
  40                  $this->setValue( 'blogTemplate', $blogTemplateSet->getName());
  41                  $ts = new TemplateSets();
  42                  // get the blog template sets
  43                  $this->setValue( 'templates', $ts->getBlogTemplateSets( $this->_editBlogInfo->getId(), true ));
  44                  // and the list of locale availables
  45                  $this->setValue( 'locales', Locales::getLocales());
  46                  $this->setValue( 'blogStatus', $this->_editBlogInfo->getStatus());
  47                  $this->setValue( 'blogStatusList', BlogStatus::getStatusList());
  48                  $blogSettings = $this->_editBlogInfo->getSettings();
  49                  $this->setValue( 'blogTimeOffset', $blogSettings->getValue( 'time_offset' ));
  50                  $this->setValue( 'blogOwnerInfo', $this->_editBlogInfo->getOwnerInfo());
  51                  $this->setValue( 'blogName', $this->_editBlogInfo->getBlog());
  52                  $this->setValue( 'blogLocale', $blogSettings->getValue( "locale" ));                
  53                  $this->setValue( 'blogResourcesQuota', $this->_editBlogInfo->getResourcesQuota());
  54                  
  55                  // set the blog users and the available users
  56                  $blogUsers = $this->_editBlogInfo->getUsersInfo();
  57                  $this->setValue( 'blogusers', $blogUsers );
  58                  
  59                  // only do blog_domain stuff if subdomains are enabled
  60                  // Don't waste time here, as well as be less confusing by
  61                  // not showing the option to users who can't use it
  62                  if( Subdomains::getSubdomainsEnabled()) {
  63                      $domain = $this->_editBlogInfo->getCustomDomain();
  64  
  65                      $available_domains = Subdomains::getAvailableDomains();
  66  
  67                      // default to any domain, this will be overwritten
  68                      // if the domain is found in the available_domains array
  69                      $subdomain = $domain;
  70                      $maindomain = "?";
  71  
  72                      foreach($available_domains as $avdomain){
  73                          // search to see if domain suffix is on
  74                          // the available_domain list.
  75                          $found = strpos($domain, $avdomain);
  76                          if($found !== FALSE && $found == (strlen($domain) - strlen($avdomain))){
  77                          $subdomain = substr($domain, 0, $found-1);
  78                          $maindomain = $avdomain;
  79                          break;
  80                          }
  81                      }
  82  
  83                      // pass the domain information to the view
  84                      $this->setValue( "blogSubDomain", $subdomain );
  85                      $this->setValue( "blogMainDomain", $maindomain );
  86                      $this->setValue( "blogAvailableDomains", $available_domains );
  87                      $this->setValue( "blogDomainsEnabled", 1 );
  88                  }                            
  89              }
  90              else {
  91                  $this->AdminTemplatedView( $blogInfo, 'error' );
  92                  $this->setValue( 'message', 'Unexpected error loading blog!' );
  93                  $this->_error = true;
  94              }
  95          }
  96          
  97  
  98          /**
  99           * Removes all the users in blogUsers from siteUsers and
 100           * returns the new array.
 101           *
 102           * @static
 103           */
 104          function filterAvailableUsers( $siteUsers, $blogUsers )
 105          {
 106              $resultArray = Array();
 107  
 108              // not the cleanest and fastest solution in the world, tho :(
 109              $found = false;
 110              foreach( $siteUsers as $siteUser ) {
 111                  foreach( $blogUsers as $blogUser ) {
 112                      if( $blogUser->getId() == $siteUser->getId()) {
 113                          $found = true;
 114                          break;
 115                      }
 116                      else
 117                          $found = false;
 118                  }
 119  
 120                  if( !$found ) {
 121                      array_push( $resultArray, $siteUser );
 122                      $found = false;
 123                  }
 124              }
 125  
 126              return $resultArray;
 127          }
 128      }
 129  ?>


Généré le : Mon Nov 26 21:04:15 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics