PageRenderTime 25ms CodeModel.GetById 35ms RepoModel.GetById 0ms app.codeStats 0ms

/modules/mediaplayermodule/class.php

https://github.com/exponentcms/exponent-cms-1
PHP | 163 lines | 125 code | 21 blank | 17 comment | 23 complexity | a131d7e9efc010bf84a3bba26a66235e MD5 | raw file
  1. <?php
  2. ##################################################
  3. #
  4. # Copyright (c) 2004-2006 OIC Group, Inc.
  5. # Written and Designed by James Hunt
  6. #
  7. # This file is part of Exponent
  8. #
  9. # Exponent is free software; you can redistribute
  10. # it and/or modify it under the terms of the GNU
  11. # General Public License as published by the Free
  12. # Software Foundation; either version 2 of the
  13. # License, or (at your option) any later version.
  14. #
  15. # GPL: http://www.gnu.org/licenses/gpl.txt
  16. #
  17. ##################################################
  18. class mediaplayermodule {
  19. function name() { return 'Media Player'; }
  20. function author() { return 'Ron Miller'; }
  21. function description() { return 'Display Internet-Friendly media content using FlowPlayer'; }
  22. function hasContent() { return true; }
  23. function hasSources() { return true; }
  24. function hasViews() { return true; }
  25. function supportsWorkflow() { return false; }
  26. function permissions($internal = '') {
  27. $i18n = exponent_lang_loadFile('modules/swfmodule/class.php');
  28. return array(
  29. 'administrate'=>$i18n['perm_administrate'],
  30. 'configure'=>$i18n['perm_configure'],
  31. );
  32. }
  33. function getLocationHierarchy($loc) {
  34. if ($loc->int == '') {
  35. return array($loc);
  36. } else {
  37. return array($loc,exponent_core_makeLocation($loc->mod,$loc->src));
  38. }
  39. }
  40. function show($view,$location = null, $title = '') {
  41. global $user;
  42. global $db;
  43. $template = new template('mediaplayermodule',$view,$location);
  44. $template->assign('moduletitle',$title);
  45. if (defined('PREVIEW_READONLY') && !defined('SELECTOR')) {
  46. return;
  47. }
  48. if (!defined('SYS_FILES')) require_once(BASE.'subsystems/files.php');
  49. $directory = 'files/mediaplayermodule/' . $location->src;
  50. if (!file_exists(BASE.$directory)) {
  51. $err = exponent_files_makeDirectory($directory);
  52. if ($err != SYS_FILES_SUCCESS) {
  53. $template->assign('noupload',1);
  54. $template->assign('uploadError',$err);
  55. }
  56. }
  57. $data = $db->selectObject('mediaitem',"location_data='".serialize($location)."'");
  58. if($data == null) {
  59. $data->_noflash = 1;
  60. $data->_align = 'center';
  61. $data->loop_media = 0;
  62. $data->auto_rewind = 1;
  63. $data->autoplay = 0;
  64. $data->hide_controls = 0;
  65. } else {
  66. $data->_noflash = 0;
  67. switch ($data->alignment) {
  68. case 1:
  69. $data->_align = 'left';
  70. break;
  71. case 2:
  72. $data->_align = 'right';
  73. break;
  74. default:
  75. $data->_align = 'center';
  76. break;
  77. }
  78. $file = $db->selectObject('file','id='.$data->media_id);
  79. if ($file && is_readable(BASE.$file->directory.'/'.$file->filename)) {
  80. $data->_flashurl=$file->directory.'/'.$file->filename;
  81. } else {
  82. $data->_flashurl='';
  83. }
  84. $file = $db->selectObject('file','id='.$data->alt_image_id);
  85. if ($file && is_readable(BASE.$file->directory.'/'.$file->filename)) {
  86. $data->_noflashurl=$file->directory.'/'.$file->filename;
  87. } else {
  88. $data->_noflashurl='';
  89. }
  90. }
  91. $template->assign('data',$data);
  92. $template->register_permissions(
  93. array('administrate','configure'),
  94. $location
  95. );
  96. $template->assign('loc', $location);
  97. $template->output();
  98. }
  99. function spiderContent($item = null) {
  100. // No searchable content
  101. return false;
  102. }
  103. function deleteIn($loc) {
  104. global $db;
  105. $data = $db->selectObject('mediaitem',"location_data='".serialize($loc)."'");
  106. if ($data) {
  107. $file = $db->selectObject('file','id='.$data->alt_image_id);
  108. file::delete($file);
  109. $db->delete('file','id='.$file->id);
  110. $file = $db->selectObject('file','id='.$data->media_id);
  111. file::delete($file);
  112. $db->delete('file','id='.$file->id);
  113. $db->delete('mediaitem','id='.$data->id);
  114. }
  115. }
  116. function copyContent($oloc,$nloc) {
  117. global $db;
  118. $data = $db->selectObject('mediaitem',"location_data='".serialize($oloc)."'");
  119. if ($data) {
  120. $file = $db->selectObject('file','id='.$data->alt_image_id);
  121. if ($file) {
  122. $newname = time().'_'.$file->filename;
  123. copy(BASE.$file->directory.'/'.$file->filename,BASE.$file->directory.'/'.$newname);
  124. $file->filename = $newname;
  125. unset($file->id);
  126. $data->alt_image_id = $db->insertObject($file,'file');
  127. }
  128. $file = $db->selectObjects('file','id='.$data->media_id);
  129. if ($file) {
  130. $newname = time().'_'.$file->filename;
  131. copy(BASE.$file->directory.'/'.$file->filename,BASE.$file->directory.'/'.$newname);
  132. $file->filename = $newname;
  133. unset($file->id);
  134. $data->media_id = $db->insertObject($file,'file');
  135. }
  136. unset($data->id);
  137. $data->location_data = serialize($nloc);
  138. $db->insertObject($data,'mediaitem');
  139. }
  140. }
  141. }
  142. ?>