Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.
 All Data Structures Functions Variables Pages
GameCoinContainerView.php
1 <?php
2  /*********************************************************************************
3  * Zurmo is a customer relationship management program developed by
4  * Zurmo, Inc. Copyright (C) 2017 Zurmo Inc.
5  *
6  * Zurmo is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU Affero General Public License version 3 as published by the
8  * Free Software Foundation with the addition of the following permission added
9  * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
10  * IN WHICH THE COPYRIGHT IS OWNED BY ZURMO, ZURMO DISCLAIMS THE WARRANTY
11  * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
12  *
13  * Zurmo is distributed in the hope that it will be useful, but WITHOUT
14  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15  * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Affero General Public License along with
19  * this program; if not, see http://www.gnu.org/licenses or write to the Free
20  * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21  * 02110-1301 USA.
22  *
23  * You can contact Zurmo, Inc. with a mailing address at 27 North Wacker Drive
24  * Suite 370 Chicago, IL 60606. or at email address contact@zurmo.com.
25  *
26  * The interactive user interfaces in original and modified versions
27  * of this program must display Appropriate Legal Notices, as required under
28  * Section 5 of the GNU Affero General Public License version 3.
29  *
30  * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
31  * these Appropriate Legal Notices must retain the display of the Zurmo
32  * logo and Zurmo copyright notice. If the display of the logo is not reasonably
33  * feasible for technical reasons, the Appropriate Legal Notices must display the words
34  * "Copyright Zurmo Inc. 2017. All rights reserved".
35  ********************************************************************************/
36 
41  {
42  protected $controller;
43 
47  public function __construct(CController $controller)
48  {
49  $this->controller = $controller;
50  }
51 
52  public function isUniqueToAPage()
53  {
54  return true;
55  }
56 
57  protected function renderContent()
58  {
59  if (Yii::app()->gameHelper->getModalCoinsEnabled() && GameCoin::showCoin($this->controller))
60  {
61  $this->registerScripts();
62  return $this->renderCoinContainerContent();
63  }
64  }
65 
66  protected function registerScripts()
67  {
68  $cs = Yii::app()->getClientScript();
69  //$cs->registerCoreScript('jquery-animate-sprite');
70  $cs->registerScriptFile(
71  Yii::app()->getAssetManager()->publish(
72  Yii::getPathOfAlias('application.modules.gamification.views.assets')
73  ) . '/jquery.animateSprite.js',
74  CClientScript::POS_END
75  );
76 
77  $url = $this->makeAjaxClickUrl();
78  $coin = ZurmoHtml::tag('div', array('class' => 'game-coin-quantity'),
79  ($this->getGameCoinForCurrentUser()->value + 1) . '<i></i>');
80  // Begin Not Coding Standard
81  $script = "$('.random-game-coin').click(function(e){
82  $(this).unbind('click');
83  " . ZurmoHtml::ajax(array('type' => 'GET', 'url' => $url)) . "
84  var audio = document.getElementById('game-coin-chime');
85  audio.play();
86  $('.game-coin').animate({top:15}, 75, function(){ $(this).hide(0) });
87  $('.smoke').show(0).animate({top:0}, 500).animateSprite({
88  columns: 8,
89  totalFrames: 40,
90  duration: 1000,
91  loop: false,
92  complete: function(){
93  $('.random-game-coin').remove();
94  }
95  });
96  $('$coin').prependTo('#user-toolbar')
97  .delay(300)
98  .animate({top:8}, 250)
99  .delay(3500)
100  .fadeOut(250, function(){
101  $(this).remove();
102  });
103  });";
104  Yii::app()->clientScript->registerScript('gameCoinClickScript', $script);
105  // End Not Coding Standard
106  }
107 
108  protected function renderCoinContainerContent()
109  {
110  $content = $this->renderCoinContent();
111  $content .= $this->renderAudioContent();
112  return ZurmoHtml::tag('div', array('class' => 'random-game-coin'), $content);
113  }
114 
115  protected function renderCoinContent()
116  {
117  $content = ZurmoHtml::tag('div', array('class' => 'game-coin'), '');
118  $content .= ZurmoHtml::tag('div', array('class' => 'smoke'), '');
119  return ZurmoHtml::tag('div', array(), $content);
120  }
121 
122  protected function renderAudioContent()
123  {
124  $publishedAssetsPath = Yii::app()->assetManager->publish(
125  Yii::getPathOfAlias("application.modules.gamification.views.assets.audio"));
126  $MP3AudioFilePath = $publishedAssetsPath . '/cash-register.mp3';
127  $OGGAudioFilePath = $publishedAssetsPath . '/cash-register.ogg';
128  $WAVAudioFilePath = $publishedAssetsPath . '/cash-register.wav';
129  $content = ZurmoHtml::tag('source', array('src' => $MP3AudioFilePath, 'type' => 'audio/mpeg'), '');
130  $content .= ZurmoHtml::tag('source', array('src' => $OGGAudioFilePath, 'type' => 'audio/ogg'), '');
131  $content .= ZurmoHtml::tag('source', array('src' => $WAVAudioFilePath, 'type' => 'audio/wav'), '');
132  return ZurmoHtml::tag('audio', array('id' => 'game-coin-chime'), $content);
133  }
134 
135  protected function getGameCoinForCurrentUser()
136  {
137  return GameCoin::resolveByPerson(Yii::app()->user->userModel);
138  }
139 
140  protected function makeAjaxClickUrl()
141  {
142  return Yii::app()->createUrl('gamification/default/CollectRandomCoin');
143  }
144  }
145 ?>
__construct(CController $controller)
static resolveByPerson(Item $person)
Definition: GameCoin.php:60
Definition: View.php:43
static showCoin(CController $controller)
Definition: GameCoin.php:142
Generated on Thu Jul 9 2020 07:10:33
Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.