PageRenderTime 147ms CodeModel.GetById 12ms RepoModel.GetById 1ms app.codeStats 0ms

/modules/swfmodule/class.php

https://github.com/exponentcms/exponent-cms-1
PHP | 159 lines | 121 code | 21 blank | 17 comment | 23 complexity | f9ba1e92fef3a28832730f25fcbf5b25 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 swfmodule {
  19. function name() { return exponent_lang_loadKey('modules/swfmodule/class.php','module_name'); }
  20. function author() { return 'Greg Otte'; }
  21. function description() { return exponent_lang_loadKey('modules/swfmodule/class.php','module_description'); }
  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('swfmodule',$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/swfmodule/' . $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('swfitem',"location_data='".serialize($location)."'");
  58. if($data == null) {
  59. $data->_noflash = 1;
  60. $data->_align = 'center';
  61. $data->transparentbg = 1;
  62. } else {
  63. $data->_noflash = 0;
  64. switch ($data->alignment) {
  65. case 1:
  66. $data->_align = 'left';
  67. break;
  68. case 2:
  69. $data->_align = 'right';
  70. break;
  71. default:
  72. $data->_align = 'center';
  73. break;
  74. }
  75. $file = $db->selectObject('file','id='.$data->swf_id);
  76. if ($file && is_readable(BASE.$file->directory.'/'.$file->filename)) {
  77. $data->_flashurl=$file->directory.'/'.$file->filename;
  78. } else {
  79. $data->_flashurl='';
  80. }
  81. $file = $db->selectObject('file','id='.$data->alt_image_id);
  82. if ($file && is_readable(BASE.$file->directory.'/'.$file->filename)) {
  83. $data->_noflashurl=$file->directory.'/'.$file->filename;
  84. } else {
  85. $data->_noflashurl='';
  86. }
  87. }
  88. $template->assign('data',$data);
  89. $template->register_permissions(
  90. array('administrate','configure'),
  91. $location
  92. );
  93. $template->output();
  94. }
  95. function spiderContent($item = null) {
  96. // No searchable content
  97. return false;
  98. }
  99. function deleteIn($loc) {
  100. global $db;
  101. $data = $db->selectObject('swfitem',"location_data='".serialize($loc)."'");
  102. if ($data) {
  103. $file = $db->selectObject('file','id='.$data->alt_image_id);
  104. file::delete($file);
  105. $db->delete('file','id='.$file->id);
  106. $file = $db->selectObject('file','id='.$data->swf_id);
  107. file::delete($file);
  108. $db->delete('file','id='.$file->id);
  109. $db->delete('swfitem','id='.$data->id);
  110. }
  111. }
  112. function copyContent($oloc,$nloc) {
  113. global $db;
  114. $data = $db->selectObject('swfitem',"location_data='".serialize($oloc)."'");
  115. if ($data) {
  116. $file = $db->selectObject('file','id='.$data->alt_image_id);
  117. if ($file) {
  118. $newname = time().'_'.$file->filename;
  119. copy(BASE.$file->directory.'/'.$file->filename,BASE.$file->directory.'/'.$newname);
  120. $file->filename = $newname;
  121. unset($file->id);
  122. $data->alt_image_id = $db->insertObject($file,'file');
  123. }
  124. $file = $db->selectObjects('file','id='.$data->swf_id);
  125. if ($file) {
  126. $newname = time().'_'.$file->filename;
  127. copy(BASE.$file->directory.'/'.$file->filename,BASE.$file->directory.'/'.$newname);
  128. $file->filename = $newname;
  129. unset($file->id);
  130. $data->swf_id = $db->insertObject($file,'file');
  131. }
  132. unset($data->id);
  133. $data->location_data = serialize($nloc);
  134. $db->insertObject($data,'swfitem');
  135. }
  136. }
  137. }
  138. ?>