[pLog-svn] r3595 - in plog/trunk: class/action/admin
class/view/admin templates/admin
oscar at devel.lifetype.net
oscar at devel.lifetype.net
Fri Jun 16 20:02:20 GMT 2006
Author: oscar
Date: 2006-06-16 20:02:20 +0000 (Fri, 16 Jun 2006)
New Revision: 3595
Modified:
plog/trunk/class/action/admin/adminupdateeditblogaction.class.php
plog/trunk/class/view/admin/admineditsiteblogview.class.php
plog/trunk/templates/admin/editblog.template
Log:
support for editing the subdomain settings in the 'edit blog' screen
Modified: plog/trunk/class/action/admin/adminupdateeditblogaction.class.php
===================================================================
--- plog/trunk/class/action/admin/adminupdateeditblogaction.class.php 2006-06-16 19:42:25 UTC (rev 3594)
+++ plog/trunk/class/action/admin/adminupdateeditblogaction.class.php 2006-06-16 20:02:20 UTC (rev 3595)
@@ -8,6 +8,7 @@
include_once( PLOG_CLASS_PATH."class/dao/userpermissions.class.php" );
include_once( PLOG_CLASS_PATH."class/data/validator/stringvalidator.class.php" );
include_once( PLOG_CLASS_PATH."class/data/validator/integervalidator.class.php" );
+ include_once( PLOG_CLASS_PATH."class/data/validator/domainvalidator.class.php" );
include_once( PLOG_CLASS_PATH."class/data/validator/arrayvalidator.class.php" );
/**
@@ -49,6 +50,10 @@
$this->registerFieldValidator( "userId", new IntegerValidator());
$this->registerFieldValidator( "userName", new StringValidator());
$this->registerField( "blogTimeOffset" );
+ if( Subdomains::getSubdomainsEnabled()) {
+ $this->registerFieldValidator( "blogSubDomain", new DomainValidator());
+ $this->registerFieldValidator( "blogMainDomain", new DomainValidator());
+ }
$view = new AdminEditSiteBlogView( $this->_blogInfo );
$view->setErrorMessage( $this->_locale->tr("error_updating_blog_settings2" ));
$this->setValidationErrorView( $view );
@@ -109,6 +114,44 @@
$blogInfo->setOwner( $this->_blogOwner );
$blogInfo->setStatus( $this->_blogStatus );
$blogInfo->setMangledBlogName( Textfilter::urlize( $blogInfo->getBlog()));
+
+ // check to see whether we are going to save subdomain information
+ if( Subdomains::getSubdomainsEnabled()) {
+
+ // Translate a few characters to valid names, and remove the rest
+ $mainDomain = Textfilter::domainize($this->_request->getValue( "blogMainDomain" ));
+ if(!$mainDomain)
+ $mainDomain = "?";
+ $subDomain = Textfilter::domainize($this->_request->getValue( "blogSubDomain" ));
+
+
+
+ if( !Subdomains::isDomainAvailable( $mainDomain )) {
+ $this->_view = new AdminEditSiteBlogView( $this->_blogInfo );
+ $this->_view->setErrorMessage( $this->_locale->tr("error_updating_blog_subdomain"));
+ $this->_form->setFieldValidationStatus( "blogMainDomain", false );
+ $this->setCommonData();
+ return false;
+ }
+
+ if( !Subdomains::isValidDomainName( $subDomain )) {
+ $this->_view = new AdminEditSiteBlogView( $this->_blogInfo );
+ $this->_view->setErrorMessage( $this->_locale->tr("error_updating_blog_subdomain"));
+ $this->_form->setFieldValidationStatus( "blogSubDomain", false );
+ $this->setCommonData();
+ return false;
+ }
+
+ if($mainDomain == "?"){
+ $blog_domain = $subDomain;
+ }
+ else{
+ $blog_domain = $subDomain . "." . $mainDomain;
+ }
+
+ $blogInfo->setCustomDomain( $blog_domain );
+ }
+
$this->notifyEvent( EVENT_PRE_BLOG_UPDATE, Array( "blog" => &$blogInfo ));
Modified: plog/trunk/class/view/admin/admineditsiteblogview.class.php
===================================================================
--- plog/trunk/class/view/admin/admineditsiteblogview.class.php 2006-06-16 19:42:25 UTC (rev 3594)
+++ plog/trunk/class/view/admin/admineditsiteblogview.class.php 2006-06-16 20:02:20 UTC (rev 3595)
@@ -4,6 +4,8 @@
include_once( PLOG_CLASS_PATH.'class/locale/locales.class.php' );
include_once( PLOG_CLASS_PATH.'class/template/templatesets/templatesets.class.php' );
include_once( PLOG_CLASS_PATH.'class/dao/blogstatus.class.php' );
+ include_once( PLOG_CLASS_PATH."class/net/http/subdomains.class.php" );
+ include_once( PLOG_CLASS_PATH."class/dao/blogcategories.class.php" );
/**
* \ingroup View
@@ -53,6 +55,37 @@
// set the blog users and the available users
$blogUsers = $this->_editBlogInfo->getUsersInfo();
$this->setValue( 'blogusers', $blogUsers );
+
+ // only do blog_domain stuff if subdomains are enabled
+ // Don't waste time here, as well as be less confusing by
+ // not showing the option to users who can't use it
+ if( Subdomains::getSubdomainsEnabled()) {
+ $domain = $this->_editBlogInfo->getCustomDomain();
+
+ $available_domains = Subdomains::getAvailableDomains();
+
+ // default to any domain, this will be overwritten
+ // if the domain is found in the available_domains array
+ $subdomain = $domain;
+ $maindomain = "?";
+
+ foreach($available_domains as $avdomain){
+ // search to see if domain suffix is on
+ // the available_domain list.
+ $found = strpos($domain, $avdomain);
+ if($found !== FALSE && $found == (strlen($domain) - strlen($avdomain))){
+ $subdomain = substr($domain, 0, $found-1);
+ $maindomain = $avdomain;
+ break;
+ }
+ }
+
+ // pass the domain information to the view
+ $this->setValue( "blogSubDomain", $subdomain );
+ $this->setValue( "blogMainDomain", $maindomain );
+ $this->setValue( "blogAvailableDomains", $available_domains );
+ $this->setValue( "blogDomainsEnabled", 1 );
+ }
}
else {
$this->AdminTemplatedView( $blogInfo, 'error' );
Modified: plog/trunk/templates/admin/editblog.template
===================================================================
--- plog/trunk/templates/admin/editblog.template 2006-06-16 19:42:25 UTC (rev 3594)
+++ plog/trunk/templates/admin/editblog.template 2006-06-16 20:02:20 UTC (rev 3595)
@@ -13,7 +13,30 @@
<input style="width:100%" type="text" readonly="readonly" id="ro_blogLink" name="ro_blogLink" class="readOnly" value="{$editBlogUrlGenerator->blogLink()}" />
</div>
+ {if $blogDomainsEnabled}
<div class="field">
+ <label for="blogSubDomain">{$locale->tr("domain")}</label>
+ <div class="formHelp">{$locale->tr("register_blog_domain_help")}</div>
+ <input type="text" name="blogSubDomain" id="blogSubDomain" style="width:150px" value="{$blogSubDomain}" />
+ <select name="blogMainDomain" id="blogMainDomain">
+ {foreach from=$blogAvailableDomains item=domain}
+ <option value="{$domain}"
+ {if $domain == $blogMainDomain}selected{/if}>
+ {if $domain == "?"}
+ {$locale->tr("subdomains_any_domain")}
+ {else}
+ .{$domain}
+ {/if}
+ </option>
+ {/foreach}
+ </select>
+ {include file="$admintemplatepath/validate.template" field=blogSubDomain message=$locale->tr("error_invalid_subdomain")}
+ {include file="$admintemplatepath/validate.template" field=blogMainDomain message=$locale->tr("error_invalid_domain")}
+ </div>
+ {/if}
+
+
+ <div class="field">
<label for="blogName">{$locale->tr("name")}</label>
<span class="required">*</span>
<div class="formHelp">{$locale->tr("blog_name_help")}</div>
More information about the pLog-svn
mailing list