Permalink
Browse files

some code to Zend code standard

  • Loading branch information...
1 parent 77092b6 commit 28f5fe4b998631119e89f73b0c7b634fca1c6a15 @dmelo committed Jul 21, 2012
View
53 application/controllers/ApiController.php
@@ -28,8 +28,13 @@ protected function _registerTracks($resultSet, $artist, $musicTitle)
$trackRow = $this->_trackModel->insert($data);
- $artistMusicTitleId = $this->_artistMusicTitleModel->insert($artist, $musicTitle);
- $this->_musicTrackLinkModel->bond($artistMusicTitleId, $trackRow->id, $this->_bondModel->search);
+ $artistMusicTitleId = $this->_artistMusicTitleModel
+ ->insert($artist, $musicTitle);
+ $this->_musicTrackLinkModel->bond(
+ $artistMusicTitleId,
+ $trackRow->id,
+ $this->_bondModel->search
+ );
$row = $trackRow->getArray();
$row['artist'] = $artist;
@@ -63,11 +68,15 @@ public function searchAction()
$artist = $this->_request->getParam('artist');
$musicTitle = $this->_request->getParam('musicTitle');
$complement = null !== $artist && null !== $musicTitle ?
- array('artist' => $artist, 'musicTitle' => $musicTitle) :
+ array('artist' => $artist, 'musicTitle' => $musicTitle):
array();
- $resultSet = $this->_youtubeModel->search($q, $limit, $offset, $complement);
+ $resultSet = $this->_youtubeModel->search(
+ $q, $limit, $offset, $complement
+ );
if (!empty($complement))
- $list = $this->_registerTracks($resultSet, $artist, $musicTitle);
+ $list = $this->_registerTracks(
+ $resultSet, $artist, $musicTitle
+ );
else
foreach ($resultSet as $result)
$list[] = $result->getArray();
@@ -99,16 +108,32 @@ public function searchsimilarAction()
$q = array();
$list = array();
$i = 0;
- foreach ($this->_lastfmModel->getSimilar($artist, $musicTitle) as $row) {
+ foreach ($this->_lastfmModel->getSimilar($artist, $musicTitle) as
+ $row) {
$q[] = $row->name;
- $resultSet = $this->_youtubeModel->search($row->name, $limit, $offset, array('artist' => $row->artist, 'musicTitle' => $row->musicTitle));
- $this->_registerTracks($resultSet, $row->artist, $row->musicTitle);
- $trackRow = $this->_musicTrackLinkModel->getTrack($row->artist, $row->musicTitle);
- $list[] = array_merge($trackRow->getArray(), array('artist' => $row->artist, 'musicTitle' => $row->musicTitle));
-
- $i++;
- if ($i >= $titlesLimit)
- break;
+ $resultSet = $this->_youtubeModel->search(
+ $row->name, $limit, $offset, array(
+ 'artist' => $row->artist,
+ 'musicTitle' => $row->musicTitle
+ )
+ );
+ $this->_registerTracks(
+ $resultSet, $row->artist, $row->musicTitle
+ );
+ $trackRow = $this->_musicTrackLinkModel->getTrack(
+ $row->artist, $row->musicTitle
+ );
+ $list[] = array_merge(
+ $trackRow->getArray(),
+ array(
+ 'artist' => $row->artist,
+ 'musicTitle' => $row->musicTitle
+ )
+ );
+
+ $i++;
+ if ($i >= $titlesLimit)
+ break;
}
$this->view->output = $list;
View
5 application/controllers/IndexController.php
@@ -16,7 +16,10 @@ class IndexController extends DZend_Controller_Action
* @return void
*/
- public function __construct(Zend_Controller_Request_Abstract $request, Zend_Controller_Response_Abstract $response, array $invokeArgs = array())
+ public function __construct(
+ Zend_Controller_Request_Abstract $request,
+ Zend_Controller_Response_Abstract $response,
+ array $invokeArgs = array())
{
parent::__construct($request, $response, $invokeArgs);
View
27 application/controllers/PlaylistController.php
@@ -93,20 +93,28 @@ public function addtrackAction()
($artist = $this->_request->getPost('artist')) !== null &&
($musicTitle = $this->_request->getPost('musicTitle')) !== null
) {
- $artistMusicTitleId = $this->_artistMusicTitleModel->insert($artist, $musicTitle);
+ $artistMusicTitleId = $this->_artistMusicTitleModel
+ ->insert($artist, $musicTitle);
$trackInfo['artist_music_title_id'] = $artistMusicTitleId;
}
- $this->_logger->debug('PlaylistController::addtrackAction -- ' . print_r($trackInfo, true));
+ $this->_logger->debug(
+ 'PlaylistController::addtrackAction -- ' .
+ print_r($trackInfo, true)
+ );
try {
$trackRow = $this->_playlistModel->addTrack(
$trackInfo,
$this->_request->getPost('playlist')
);
if (isset($artistMusicTitleId))
- $this->_musicTrackLinkModel->bond($artistMusicTitleId, $trackRow->id, $this->_bondModel->insert_playlist);
+ $this->_musicTrackLinkModel->bond(
+ $artistMusicTitleId,
+ $trackRow->id,
+ $this->_bondModel->insert_playlist
+ );
$message = array(
$this->view->t('Track added'),
'success',
@@ -302,11 +310,18 @@ public function voteAction()
$message = array('Invalid request', 'error');
if (($trackId = $this->_request->getParam('track_id')) !== null &&
(($bond = $this->_request->getParam('bond')) !== null) &&
- ($artistMusicTitleId = $this->_request->getParam('artist_music_title_id')) !== null) {
- if (null === $this->_musicTrackLinkModel->bond($artistMusicTitleId, $trackId, $this->_bondModel->{$bond}))
+ (
+ $artistMusicTitleId
+ = $this->_request->getParam('artist_music_title_id')
+ ) !== null) {
+ if (null === $this->_musicTrackLinkModel->bond(
+ $artistMusicTitleId, $trackId, $this->_bondModel->{$bond}
+ ))
$message = array('Error while registering vote', 'error');
else
- $message = array('Vote saved!! Thank you for your help!', 'success');
+ $message = array(
+ 'Vote saved!! Thank you for your help!', 'success'
+ );
};
$this->view->message = $message;
View
3 application/models/DbTable/Artist.php
@@ -2,7 +2,8 @@
class DbTable_Artist extends DZend_Model_DbTable
{
- public function insert($data) {
+ public function insert($data)
+ {
return $this->insertWithoutException($data);
}
}
View
3 application/models/DbTable/MusicTitle.php
@@ -2,7 +2,8 @@
class DbTable_MusicTitle extends DZend_Model_DbTable
{
- public function insert($data) {
+ public function insert($data)
+ {
try {
return parent::insert($data);
} catch(Zend_Db_Exception $e) {
View
9 application/models/DbTable/PlaylistRow.php
@@ -53,7 +53,8 @@ public function addTrack($trackInfo)
'track_id' => $trackRow->id,
'sort' => $maxSort + 1);
if (array_key_exists('artist_music_title_id', $trackInfo))
- $data['artist_music_title_id'] = $trackInfo['artist_music_title_id'];
+ $data['artist_music_title_id']
+ = $trackInfo['artist_music_title_id'];
$this->_playlistHasTrackDb->insert($data);
return $trackRow;
@@ -83,8 +84,10 @@ public function getTrackListAsArray()
$list = $this->_playlistHasTrackDb->findByPlaylistId($this->id);
$ret = array();
foreach ($list as $item) {
- $ret[] = array_merge($trackDb->findRowById($item->trackId)->getArray(),
- array('artist_music_title_id' => $item->artistMusicTitleId));
+ $ret[] = array_merge(
+ $trackDb->findRowById($item->trackId)->getArray(),
+ array('artist_music_title_id' => $item->artistMusicTitleId)
+ );
}
return $ret;
View
9 application/models/DbTable/TrackRow.php
@@ -5,7 +5,14 @@ class DbTable_TrackRow extends DZend_Model_DbTableRow
public function getArray()
{
$columns = array(
- 'id', 'title', 'fid', 'fcode', 'url', 'cover', 'duration', 'youtubeUrl'
+ 'id',
+ 'title',
+ 'fid',
+ 'fcode',
+ 'url',
+ 'cover',
+ 'duration',
+ 'youtubeUrl'
);
$ret = array();
foreach ($columns as $column)
View
14 application/models/MusicTrackLink.php
@@ -15,7 +15,9 @@ public function bond($artistMusicTitleId, $trackId, $bondName)
$currentBondRow = null;
if (null !== $currentMusicTrackLinkRow) {
- $currentBondRow = $this->_bondModel->findRowById($currentMusicTrackLinkRow->bondId);
+ $currentBondRow = $this->_bondModel->findRowById(
+ $currentMusicTrackLinkRow->bondId
+ );
// If the current bond has higher priority than the new bond,
// then don't do the new bond
@@ -40,14 +42,18 @@ public function bond($artistMusicTitleId, $trackId, $bondName)
public function getTrack($artist, $musicTitle)
{
- $artistMusicTitleId = $this->_artistMusicTitleModel->insert($artist, $musicTitle);
- $rowSet = $this->_musicTrackLinkDb->findByArtistMusicTitleId($artistMusicTitleId);
+ $artistMusicTitleId = $this->_artistMusicTitleModel->insert(
+ $artist, $musicTitle
+ );
+ $rowSet = $this->_musicTrackLinkDb->findByArtistMusicTitleId(
+ $artistMusicTitleId
+ );
$points = array();
foreach ($rowSet as $row) {
if (!array_key_exists($row->trackId, $points))
$points[$row->trackId] = 0;
- switch ($row->bond_id) {
+ switch ($row->bondId) {
case 0: // search
$points[$row->trackId] += 1;
break;
View
3 application/models/Playlist.php
@@ -80,7 +80,8 @@ public function export($name)
);
} elseif (gettype($name) === 'integer') {
$playlistRow = $this->_playlistDb->findRowById($name);
- if ($playlistRow->user_id !== $user->id && 'public' !== $playlistRow->privacy)
+ if ($playlistRow->userId !== $user->id
+ && 'public' !== $playlistRow->privacy)
$playlistRow = null;
else
$this->_userListenPlaylistModel->addUserPlaylist($playlistRow);
View
24 application/models/User.php
@@ -87,7 +87,16 @@ public function sendActivateAccountEmail($userRow)
$session = DZend_Session_Namespace::get('session');
$mail = new Zend_Mail('UTF-8');
- $mail->setBodyHtml($this->_translate->_("Hi %s,<br/><br/>Welcome to AMUZI. To activate your account just click on the link bellow:<br/><a href=\"%s\">%s</a><br/><br/>Enjoy!!<p>Best regards,<br/>AMUZI Team", $userRow->name, $userRow->getUrlToken(), $userRow->getUrlToken()));
+ $mail->setBodyHtml(
+ $this->_translate->_(
+ "Hi %s,<br/><br/>Welcome to AMUZI. To activate your account "
+ . "just click on the link bellow:<br/><a href=\"%s\">%s</a>"
+ . "<br/><br/>Enjoy!!<p>Best regards,<br/>AMUZI Team",
+ $userRow->name,
+ $userRow->getUrlToken(),
+ $userRow->getUrlToken()
+ )
+ );
$mail->setFrom('support@amuzi.net', 'AMUZI Team');
$mail->addTo($userRow->email);
$mail->setSubject($this->_translate->_("AMUZI -- Account activation"));
@@ -106,7 +115,18 @@ public function sendForgotPasswordEmail($userRow)
$session = DZend_Session_Namespace::get('session');
$mail = new Zend_Mail('UTF-8');
- $mail->setBodyHtml($this->_translate->_("Hi %s,<br/><br/>Someone, hopefully you, requested a new password on AMUZI. To make a new password, please click the link bellow:<br/><br/><a href=\"%s\">%s</a><br/><br/>Best regards,<br/>AMUZI Team", $userRow->name, $userRow->getForgotPasswordUrl(), $userRow->getForgotPasswordUrl()));
+ $mail->setBodyHtml(
+ $this->_translate->_(
+ "Hi %s,<br/><br/>Someone, hopefully you, requested a new "
+ . "password on AMUZI. To make a new password, please click "
+ . "the link bellow:<br/><br/><a href=\"%s\">%s</a><br/><br/>"
+ . "Best regards,<br/>",
+ "AMUZI Team",
+ $userRow->name,
+ $userRow->getForgotPasswordUrl(),
+ $userRow->getForgotPasswordUrl()
+ )
+ );
$mail->setFrom('support@amuzi.net', 'AMUZI Team');
$mail->addTo($userRow->email);
$mail->setSubject(
View
39 application/modules/Auth/controllers/IndexController.php
@@ -97,28 +97,40 @@ public function registerAction()
$params = $this->_request->getParams();
if ($this->_request->isPost() && $form->isValid($params)) {
if ($params['password'] !== $params['password2'])
- $message = array($this->view->t('Password doesn\'t match'), 'error');
- elseif (($userRow = $this->_userModel->findByEmail($params['email'])) !== null)
- $message = array($this->view->t('Email is already registered'), 'error');
+ $message = array(
+ $this->view->t('Password doesn\'t match'), 'error'
+ );
+ elseif (($userRow
+ = $this->_userModel->findByEmail($params['email'])) !== null)
+ $message = array(
+ $this->view->t('Email is already registered'), 'error'
+ );
else {
- if(
+ if (
$this->_userModel->register(
$params['name'], $params['email'], $params['password']
) === true
) {
$userRow = $this->_userModel->findByEmail($params['email']);
- if($this->_userModel->sendActivateAccountEmail($userRow)) {
- $message = array($this->view->t('User registered. Check your email to activate your account.'), 'success');
+ if ($this->_userModel->sendActivateAccountEmail($userRow)) {
+ $message = array($this->view->t(
+ 'User registered. Check your '
+ . 'email to activate your account.'
+ ), 'success');
if (method_exists($userRow, 'postRegister'))
$userRow->postRegister();
- }
- else {
- $message = array($this->view->t('An error occurred. It was not possible to send the email. Plase try again'), 'error');
+ } else {
+ $message = array($this->view->t(
+ 'An error occurred. It was not possible to send '
+ . 'the email. Plase try again'
+ ), 'error');
$this->_userModel->deleteByEmail($params['email']);
}
}
else
- $message = array($this->view->t('Some error occurred, please try again'), 'error');
+ $message = array($this->view->t(
+ 'Some error occurred, please try again'
+ ), 'error');
}
if($message[1] !== 'success')
@@ -137,12 +149,15 @@ public function activateAction()
$userRow = $this->_userModel->findByEmail($email);
$message = null;
- if(
+ if (
null === $userRow ||
'' === $userRow->token ||
$userRow->token !== $token
) {
- $message = array($this->view->t('The email %s cannot be activated', $email), 'error');
+ $message = array(
+ $this->view->t('The email %s cannot be activated', $email),
+ 'error'
+ );
} else {
$userRow->token = '';
$userRow->save();
View
2 phpcs.sh
@@ -1,3 +1,3 @@
#!/bin/bash
-phpcs --standard=Zend `find application/ locale/ tests/ library/DZend/ library/LightningPackerHelper/ | grep "\.php"` | less
+phpcs --standard=Zend `find application/ locale/ tests/ library/DZend/ library/LightningPackerHelper/ | grep "\.php$"` | less

0 comments on commit 28f5fe4

Please sign in to comment.