[ 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/summary/action/ -> doblogregistration.class.php (source)

   1  <?php
   2  
   3      lt_include( PLOG_CLASS_PATH."class/summary/action/registeraction.class.php" );
   4      lt_include( PLOG_CLASS_PATH."class/data/validator/stringvalidator.class.php" );
   5      lt_include( PLOG_CLASS_PATH."class/data/validator/integervalidator.class.php" );
   6      lt_include( PLOG_CLASS_PATH."class/data/validator/blognamevalidator.class.php" );
   7      lt_include( PLOG_CLASS_PATH."class/dao/articlecategories.class.php" );             
   8      lt_include( PLOG_CLASS_PATH."class/summary/view/doblogregistrationview.class.php" );
   9      lt_include( PLOG_CLASS_PATH."class/summary/view/blogtemplatechooserview.class.php" );
  10      lt_include( PLOG_CLASS_PATH."class/locale/locales.class.php" );
  11      lt_include( PLOG_CLASS_PATH."class/data/validator/domainvalidator.class.php" );
  12      lt_include( PLOG_CLASS_PATH."class/net/http/subdomains.class.php" );
  13      lt_include( PLOG_CLASS_PATH."class/config/config.class.php" );    
  14      lt_include( PLOG_CLASS_PATH."class/data/filter/htmlfilter.class.php" );    
  15  
  16      /**
  17       * registers a blog
  18       */
  19      class doBlogRegistration extends RegisterAction 
  20      {
  21          
  22          function doBlogRegistration( $actionInfo, $request )
  23          {
  24              $this->RegisterAction( $actionInfo, $request );
  25      
  26              // input filters
  27              $this->_request->registerFilter( "blogName", new HtmlFilter( true ));
  28              
  29              // data validation
  30              //$this->registerFieldValidator( "userId", new IntegerValidator());
  31              $this->registerFieldValidator( "blogName", new BlogNameValidator());
  32              $this->registerFieldValidator( "blogCategoryId", new IntegerValidator());
  33              $this->registerFieldValidator( "blogLocale", new StringValidator());
  34              $config =& Config::getConfig();
  35              $this->registerField( "blogSubDomain" );
  36              $this->registerField( "blogMainDomain" );
  37              $view = new doBlogRegistrationView();
  38              $view->setErrorMessage( $this->_locale->tr("register_error_creating_blog"));
  39              $this->setValidationErrorView( $view );   
  40          }
  41  
  42  		function validate()
  43          {
  44              $valid = parent::validate();
  45              
  46              // check to see whether we are going to save subdomain information
  47              if( Subdomains::getSubdomainsEnabled()) {
  48  
  49                  // Translate a few characters to valid names, and remove the rest
  50                  $mainDomain = Textfilter::domainize($this->_request->getValue( "blogMainDomain" ));
  51                  if(!$mainDomain)
  52                      $mainDomain = "?";
  53                  $subDomain = Textfilter::domainize($this->_request->getValue( "blogSubDomain" ));
  54  
  55                  // get list of allowed domains
  56                  $available_domains = Subdomains::getAvailableDomains();
  57                  
  58                  if($mainDomain == "?")
  59                      $this->blogDomain = $subDomain;
  60                  else {
  61                      $this->blogDomain = $subDomain . "." . $mainDomain;
  62                  }                            
  63  
  64                  // make sure the mainDomain parameter is one of the blogAvailableDomains and if not, 
  65                  // force a validation error
  66                  if( !Subdomains::isDomainAvailable( $mainDomain ) || !Subdomains::isValidDomainName( $subDomain )) {
  67                      $valid = false;
  68                      $this->_form->setFieldValidationStatus( "blogSubDomain", false );                    
  69                      $this->validationErrorProcessing();                    
  70                  }
  71                  if( Subdomains::domainNameExists( $this->blogDomain )) {
  72                      $valid = false;
  73                      $this->_form->setFieldValidationStatus( "blogSubDomain", false );                    
  74                      $this->validationErrorProcessing();                    
  75                  }                
  76              }
  77  
  78              return( $valid );
  79          }
  80  
  81          function perform()
  82          {
  83              // create the new view and clean the cache
  84              $this->_view = new BlogTemplateChooserView();
  85              $this->setCommonData();
  86  
  87              // save data to the session
  88              SessionManager::setSessionValue( "blogName", $this->_request->getValue( "blogName" ));
  89              SessionManager::setSessionValue( "blogCategoryId", $this->_request->getValue( "blogCategoryId" ));
  90              SessionManager::setSessionValue( "blogLocale", $this->_request->getValue( "blogLocale" ));
  91              SessionManager::setSessionValue( "blogSubDomain", $this->_request->getValue( "blogSubDomain" ));
  92              SessionManager::setSessionValue( "blogMainDomain", $this->_request->getValue( "blogMainDomain" ));
  93              SessionManager::setSessionValue( "blogDomain", $this->blogDomain );
  94  
  95              return( true );
  96          }
  97      }
  98  ?>


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