PageRenderTime 40ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/openconstructor/lib/smarty/plugins/function.treewidget.php

http://openconstructor.googlecode.com/
PHP | 63 lines | 39 code | 1 blank | 23 comment | 2 complexity | 804241f70f271405f39be3bd8be92e23 MD5 | raw file
Possible License(s): GPL-2.0
  1. <?php
  2. /**
  3. * Copyright 2003 - 2007 eSector Solutions, LLC
  4. *
  5. * All rights reserved.
  6. *
  7. * This file is part of Open Constructor (http://www.openconstructor.org/).
  8. *
  9. * Open Constructor is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License version 2
  11. * as published by the Free Software Foundation.
  12. *
  13. * Open Constructor is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * The GNU General Public License can be found at
  19. * http://www.gnu.org/copyleft/gpl.html
  20. *
  21. * @author Sanjar Akhmedov
  22. *
  23. * $Id: function.treewidget.php,v 1.2 2007/02/27 11:23:21 sanjar Exp $
  24. */
  25. function smarty_function_treewidget($params, &$smarty) {
  26. if(!isset($params['field'])) {
  27. $smarty->trigger_error("treewidget: missing 'field' parameter");
  28. return;
  29. }
  30. $doc = &$smarty->get_template_vars('doc');
  31. if(!array_key_exists(@substr($params['field'], 2), $doc)) {
  32. $smarty->trigger_error("treewidget: field '{$params['field']}' doesn't exists");
  33. return;
  34. }
  35. $ctl = 'ctl_'.$params['field'];
  36. if($params['width'])
  37. $width = "width='{$params['width']}'";
  38. if($params['height'])
  39. $height = "height='{$params['height']}'";
  40. ob_start();
  41. echo '<nobr class="tool">';
  42. wysiwygtoolbar($ctl);
  43. echo '</nobr>';
  44. ?>
  45. <iframe id='iframe.<?=$params['field']?>' <?=$width.' '.$height?>></iframe>
  46. <script>
  47. var <?=$ctl?> = new WYSIWYGController();
  48. addListener(window, 'onload', function() {
  49. new WYSIWYGWidget(
  50. document.getElementById('<?=$params['field']?>'),
  51. document.getElementById('iframe.<?=$params['field']?>'),
  52. <?=$ctl?>,
  53. '@import url("http://<?=$_SERVER['HTTP_HOST']?>/css/content.css");'
  54. );
  55. });
  56. </script>
  57. <?php
  58. $result = ob_get_contents();
  59. ob_end_clean();
  60. return $result;
  61. }
  62. ?>