This repository was archived by the owner on Mar 13, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New Forms, Tables, Views, to support Registration and Catalog processes
- Loading branch information
Showing
12 changed files
with
301 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | ||
) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | ||
) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
{ | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
{ | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
{ | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |