Cheetah
All Classes Namespaces Files Functions Variables Pages
ChVideosTemplate.php
Go to the documentation of this file.
1 <?php
2 
8 ch_import('ChWsbFilesTemplate');
9 
11 {
12  function __construct (&$oConfig, &$oDb)
13  {
14  parent::__construct($oConfig, $oDb);
15  }
16 
17  function getFileConcept ($iFileId, $aExtra = array())
18  {
19  $sOverride = false;
20  $oAlert = new ChWsbAlerts($this->_oConfig->getMainPrefix(), 'display_player', $iFileId, getLoggedId(), array('extra' => $aExtra, 'override' => &$sOverride));
21  $oAlert->alert();
22  if ($sOverride)
23  return $sOverride;
24 
25  $iFileId = (int)$iFileId;
26  if(empty($aExtra['ext']))
27  $sPlayer = getApplicationContent('video','player',array('id' => $iFileId, 'user' => $this->iViewer, 'password' => clear_xss($_COOKIE['memberPassword'])),true);
28  else {
29  $sPlayer = str_replace("#video#", $aExtra['ext'], YOUTUBE_VIDEO_PLAYER);
30  $sPlayer = str_replace("#wmode#", getWMode(), $sPlayer);
31  $sPlayer = str_replace("#autoplay#", (getSettingValue("video", "autoPlay") == TRUE_VAL && class_exists('ChVideosPageView') ? "&autoplay=1" : ""), $sPlayer);
32  }
33  return '<div class="viewFile" style="width:100%;">' . $sPlayer . '</div>';
34  }
35 
36  function getViewFile (&$aInfo)
37  {
38  $oVotingView = new ChTemplVotingView('ch_' . $this->_oConfig->getUri(), $aInfo['medID']);
39  $iWidth = (int)$this->_oConfig->getGlParam('file_width');
40  if ($aInfo['prevItem'] > 0)
41  $aPrev = $this->_oDb->getFileInfo(array('fileId'=>$aInfo['prevItem']), true, array('medUri', 'medTitle'));
42  if ($aInfo['nextItem'] > 0)
43  $aNext = $this->_oDb->getFileInfo(array('fileId'=>$aInfo['nextItem']), true, array('medUri', 'medTitle'));
44 
45  $aUnit = array(
46  'file' => $this->getFileConcept($aInfo['medID'], array('ext'=>$aInfo['medExt'], 'source'=>$aInfo['medSource'])),
47  'width_ext' => $iWidth + 2,
48  'width' => $iWidth,
49  'fileUrl' => CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() . 'view/' . $aInfo['medUri'],
50  'fileTitle' => $aInfo['medTitle'],
51  'fileDescription' => nl2br($aInfo['medDesc']),
52  'rate' => $oVotingView->isEnabled() ? $oVotingView->getBigVoting(1, $aInfo['Rate']): '',
53  'favInfo' => isset($aInfo['favCount']) ? $aInfo['favCount'] : '',
54  'viewInfo' => $aInfo['medViews'],
55  'albumUri' => CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() . 'browse/album/' . $aInfo['albumUri'] . '/owner/' . $aInfo['NickName'],
56  'albumCaption' => $aInfo['albumCaption'],
57  'ch_if:prev' => array(
58  'condition' => $aInfo['prevItem'] > 0,
59  'content' => array(
60  'linkPrev' => CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() . 'view/' . $aPrev['medUri'],
61  'titlePrev' => $aPrev['medTitle'],
62  'percent' => $aInfo['nextItem'] > 0 ? 50 : 100,
63  )
64  ),
65  'ch_if:next' => array(
66  'condition' => $aInfo['nextItem'] > 0,
67  'content' => array(
68  'linkNext' => CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() . 'view/' . $aNext['medUri'],
69  'titleNext' => $aNext['medTitle'],
70  'percent' => $aInfo['prevItem'] > 0 ? 50 : 100,
71  )
72  ),
73  );
74  return $this->parseHtmlByName('view_unit.html', $aUnit);
75  }
76 
77  function getEmbedCode ($iFileId, $aExtra = array())
78  {
79  $sOverride = false;
80  $oAlert = new ChWsbAlerts($this->_oConfig->getMainPrefix(), 'embed_code', $iFileId, getLoggedId(), array('override' => &$sOverride));
81  $oAlert->alert();
82  if ($sOverride)
83  return $sOverride;
84 
85  $iFileId = (int)$iFileId;
86  switch ($aExtra["source"]) {
87  case "":
88  $sEmbedCode = getEmbedCode('video', 'player', array('id'=>$iFileId));
89  break;
90  case "youtube":
91  $sEmbedCode = str_replace("#video#", $aExtra["video"], YOUTUBE_VIDEO_EMBED);
92  $sEmbedCode = str_replace("#wmode#", getWMode(), $sEmbedCode);
93  $sEmbedCode = str_replace("#autoplay#", (getSettingValue("video", "autoPlay") == TRUE_VAL ? "&autoplay=1" : ""), $sEmbedCode);
94  break;
95  default:
96  $sEmbedCode = video_getCustomEmbedCode($aExtra["source"], $aExtra["video"]);
97  break;
98  }
99  return $sEmbedCode;
100  }
101 
102  function getCompleteFileInfoForm (&$aInfo, $sUrlPref = '')
103  {
104  $aMain = $this->getBasicFileInfoForm($aInfo, $sUrlPref);
105  if ($aInfo['AllowAlbumView'] == CH_WSB_PG_ALL)
106  {
107  $aAdd = array('embed' => array(
108  'type' => 'text',
109  'value' => $this->getEmbedCode($aInfo['medID'], array('video'=>$aInfo['medExt'], 'source'=>$aInfo['medSource'])),
110  'attrs' => array(
111  'onclick' => 'this.focus(); this.select();',
112  'readonly' => 'readonly',
113  ),
114  'caption'=> _t('_Embed')
115  ),
116  );
117  $aMain = array_merge($aMain, $aAdd);
118  }
119  return $aMain;
120  }
121 
122  function getItemType ()
123  {
124  return 'type="video/x-flv"';
125  }
126 }
ChVideosTemplate\__construct
__construct(&$oConfig, &$oDb)
Definition: ChVideosTemplate.php:12
$aUnit
$aUnit
Definition: short_profile_info.php:31
ch_import
ch_import($sClassName, $aModule=array())
Definition: utils.inc.php:1218
$oAlert
$oAlert
Definition: embed.php:15
ChWsbFilesTemplate
Definition: ChWsbFilesTemplate.php:13
php
ChVideosTemplate\getFileConcept
getFileConcept($iFileId, $aExtra=array())
Definition: ChVideosTemplate.php:17
$aInfo
$aInfo
Definition: constants.inc.php:21
ChWsbAlerts
Definition: ChWsbAlerts.php:39
ChVideosTemplate\getCompleteFileInfoForm
getCompleteFileInfoForm(&$aInfo, $sUrlPref='')
Definition: ChVideosTemplate.php:102
ChVideosTemplate\getItemType
getItemType()
Definition: ChVideosTemplate.php:122
getLoggedId
getLoggedId()
Definition: profiles.inc.php:32
ChVideosTemplate
Definition: ChVideosTemplate.php:11
getWMode
getWMode()
Definition: apiFunctions.inc.php:106
$oDb
global $oDb
Definition: db.inc.php:39
_t
_t($key, $arg0="", $arg1="", $arg2="")
Definition: languages.inc.php:509
getApplicationContent
getApplicationContent($sModule, $sApp, $aParamValues=array(), $bInline=false, $bEmbedCode=false, $sHtmlId="")
Definition: content.inc.php:166
CH_WSB_PG_ALL
const CH_WSB_PG_ALL
Definition: ChWsbPrivacy.php:12
video_getCustomEmbedCode
video_getCustomEmbedCode($sSource, $sVideo)
Definition: customFunctions.inc.php:110
ChWsbFilesTemplate\getBasicFileInfoForm
getBasicFileInfoForm(&$aInfo, $sUrlPref='')
Definition: ChWsbFilesTemplate.php:61
$iFileId
$iFileId
Definition: embed.php:12
getSettingValue
getSettingValue($sWidget, $sSettingKey, $sFile="config", $bFullReturn=false, $sFolder="xml")
Definition: apiFunctions.inc.php:82
ChVideosTemplate\getEmbedCode
getEmbedCode($iFileId, $aExtra=array())
Definition: ChVideosTemplate.php:77
empty
Attr AllowedRel this is empty
Definition: Attr.AllowedRel.txt:7
ChWsbTemplate\parseHtmlByName
parseHtmlByName($sName, $aVariables, $mixedKeyWrapperHtml=null, $sCheckIn=CH_WSB_TEMPLATE_CHECK_IN_BOTH)
Definition: ChWsbTemplate.php:660
ChTemplVotingView
Definition: ChTemplVotingView.php:14
ChVideosTemplate\getViewFile
getViewFile(&$aInfo)
Definition: ChVideosTemplate.php:36
clear_xss
clear_xss($val)
Definition: utils.inc.php:700