Skip to content
This repository was archived by the owner on Mar 13, 2022. It is now read-only.

Commit

Permalink
New Forms, Tables, Views, to support Registration and Catalog processes
Browse files Browse the repository at this point in the history
  • Loading branch information
A.J. Brown authored and ajbrown committed Feb 9, 2009
1 parent 0fe1599 commit 8a2bca8
Show file tree
Hide file tree
Showing 12 changed files with 301 additions and 0 deletions.
2 changes: 2 additions & 0 deletions NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Currently, releases, tracks, and artists can only have alphanumeric titles. We
should extend this to include any printable character.
6 changes: 6 additions & 0 deletions application/dashboard/views/scripts/catalog/addrelease.phtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php $this->placeholder( 'title' )->set( 'Add New Release' ); ?>

<div class="tundra">
<?php echo $this->form; ?>
</div>

29 changes: 29 additions & 0 deletions application/dashboard/views/scripts/catalog/index.phtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php $this->placeholder( 'title' )->set( 'Manage Catalog' ); ?>
<h2>My Releases</h2>

<table class="releases">
<?php foreach( $this->releases as $release ) : ?>
<thead>
<tr>
<th colspan="3"><?php echo $release->title; ?></th>
<th><?php echo $release->publishDate; ?></th>
</tr>
<tr>
<th>Title</th>
<th>Encode Status</th>
<th>Single</th>
<th>Publish Date</th>
</tr>
</thead>
<?php foreach( $release->Track as $track ): ?>
<tbody>
<tr>
<td><?php echo $track->title; ?></td>
<td><?php echo $track->encodingStatus; ?></td>
<td><?php echo $track->single ? 'x' : '' ?></td>
<td><?php echo $track->publishDate; ?></td>
</tr>
</tbody>
<?php endforeach; ?>
<?php endforeach; ?>
</table>
8 changes: 8 additions & 0 deletions application/default/views/scripts/mail/confirm-html.phtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<p>
Your Confirmation Code is:

<pre><?php echo $this->confirmCode; ?></pre>

<p>To confirm your account, please click the following link:</p>

<p><a href="<?php echo $this->link; ?>"><?php echo $this->link; ?></a></p>
7 changes: 7 additions & 0 deletions application/default/views/scripts/mail/confirm-text.phtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Your Confirmation Code is:

<?php echo $this->confirmCode; ?>

To confirm your account, please click the following link:

<?php echo $this->link; ?>
54 changes: 54 additions & 0 deletions library/App/Form/ConfirmRegister.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php

require_once 'Zend/Dojo/Form.php';

class App_Form_ConfirmRegister extends Zend_Dojo_Form
{

public function init()
{
parent::init();

$this->setName( 'confirmRegisterForm' );
$this->setAttrib( 'id', 'confirm-register-form' );
$this->addElementPrefixPath( 'App_Validate', 'App/Validate/', 'validate' );

$this->setDecorators( array(
'FormElements',
'DijitForm',
) );

$config = Initializer::getConfig();

//--------------------------------------
// Elements
//--------------------------------------

$this->addElement( 'ValidationTextBox', 'emailAddress', array(
'label' => 'Your E-Mail Address',
'description' => 'The E-mail address you wish you confirm',
'required' => true,
'trim' => true,
'filters' => array( 'StringToLower' ),
'validators' => array(
array( 'EmailAddress', false, array( 'validateMx' => true ) ),
),
) );

$this->addElement( 'TextBox', 'code', array(
'label' => 'Confirmation Code',
'description' => 'This is the code you received from us.',
'required' => true,
'trim' => true,
'filters' => array( 'StringToUpper' ),
'validators' => array( 'Alnum' ),
) );

$this->addElement( 'SubmitButton', 'submit',
array(
'ignore' => true,
'label' => 'Confirm My E-Mail Address'
)
);
}
}
81 changes: 81 additions & 0 deletions library/App/Form/Register.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?php

require_once 'Zend/Dojo/Form.php';

class App_Form_Register extends Zend_Dojo_Form
{

public function init()
{
parent::init();

$this->setName( 'registerForm' );
$this->setAttrib( 'id', 'register-form' );
$this->setMethod( 'post' );

$this->addElementPrefixPath( 'App_Validate', 'App/Validate/', 'validate' );

$this->setDecorators( array(
'FormElements',
'DijitForm',
) );

$config = Initializer::getConfig();

//--------------------------------------
// Elements
//--------------------------------------

$this->addElement( 'ValidationTextBox', 'emailAddress', array(
'label' => 'Your E-Mail Address',
'description' => 'Give us your valid E-mail address. We check this, so make sure its valid and you can access it.',
'required' => true,
'trim' => true,
'filters' => array( 'StringToLower' ),
'validators' => array(
array( 'EmailAddress', false, array( 'validateMx' => true ) ),
array( 'UniqueAccountDetail', false, array( 'field' => 'emailAddress' ) ),
),
) );

$this->addElement( 'PasswordTextBox', 'password', array(
'label' => 'Choose a Password',
'description' => 'Make it a good one. It must be at least 6 characters',
'required' => true,
'trim' => false,
'validators' => array(
array( 'StringLength', false, array( 6 ) ),
array( 'PasswordConfirmation', true, array( 'field' => 'confirm_password' ) ),
)
) );

$this->addElement( 'PasswordTextBox', 'confirm_password', array(
'label' => 'Retype Your Password',
'description' => 'Just to make sure you didn\'t mess up',
'required' => true,
'trim' => false
) );

$this->addElement( 'CheckBox', 'sellerAccount', array(
'label' => 'I want to sell music, too.',
'description' => 'Check this box if you want to sell music on BitNotion. You will still be able to purchase music using this account.'
) );

$this->addElement( 'Captcha', 'captcha', array(
'label' => 'Are you human?',
'descripton' => 'Type the letters shown, and prove you\'re smarter than the average robot.',
'captcha' => array(
'captcha' => 'ReCaptcha',
'privkey' => $config->recaptcha->privateKey,
'pubkey' => $config->recaptcha->publicKey,
)
) );

$this->addElement( 'SubmitButton', 'submit',
array(
'ignore' => true,
'label' => 'Create My Account'
)
);
}
}
9 changes: 9 additions & 0 deletions library/App/Table/Account.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

require_once 'App/Table/Abstract.php';

class App_Table_Account extends App_Table_Abstract
{


}
9 changes: 9 additions & 0 deletions library/App/Table/AccountConfirm.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

require_once 'App/Table/Abstract.php';

class App_Table_AccountConfirm extends App_Table_Abstract
{


}
9 changes: 9 additions & 0 deletions library/App/Table/Artist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

require_once 'App/Table/Abstract.php';

class App_Table_Artist extends App_Table_Abstract
{


}
43 changes: 43 additions & 0 deletions library/App/Validate/PasswordConfirmation.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

require_once 'Zend/Validate/Abstract.php';

class App_Validate_PasswordConfirmation extends Zend_Validate_Abstract
{
const NOT_MATCH = 'notMatch';

protected $_messageTemplates = array(
self::NOT_MATCH => 'Password confirmation does not match'
);

protected $_field;

public function __construct( $field )
{
$this->setField( $field );
}

public function isValid($value, $context = null)
{
$value = (string) $value;
$this->_setValue($value);

if (is_array($context)) {
if (isset($context[ $this->_field ])
&& ($value == $context[ $this->_field ]))
{
return true;
}
} elseif (is_string($context) && ($value == $context)) {
return true;
}

$this->_error(self::NOT_MATCH);
return false;
}

public function setField( $field )
{
$this->_field = $field;
}
}
44 changes: 44 additions & 0 deletions library/App/Validate/UniqueAccountDetail.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

require_once 'Zend/Validate/Abstract.php';

class App_Validate_UniqueAccountDetail extends Zend_Validate_Abstract
{
const NOT_UNIQUE= 'notUnique';

protected $_messageTemplates = array(
self::NOT_UNIQUE => 'This value is already in use.'
);

protected $_field;

public function __construct( $field = null )
{
$this->setField( $field );
}

public function isValid($value, $context = null)
{

if( empty( $this->_field ) ) {
require_once 'Zend/Validate/Exception.php';
throw new Zend_Validate_Exception( 'Invalid field specified' );
}

$accounts = new App_Table_Account();
$query = $accounts->createQuery()
->addWhere( $this->_field . ' = ?', array( $value ) );

if ( $query->count() == 0 ) {
return true;
}

$this->_error(self::NOT_UNIQUE);
return false;
}

public function setField( $field )
{
$this->_field = $field;
}
}

0 comments on commit 8a2bca8

Please sign in to comment.