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

/xoops_trust_path/modules/d3pipes/blocks/async_show.php

http://xoopscube-modules.googlecode.com/
PHP | 83 lines | 70 code | 11 blank | 2 comment | 6 complexity | 4ab7600a509264c1b2ac3f8711286342 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1, AGPL-1.0
  1. <?php
  2. function b_d3pipes_async_show( $options )
  3. {
  4. $mydirname = empty( $options[0] ) ? 'd3pipes' : $options[0] ;
  5. $unique_id = empty( $options[1] ) ? uniqid( rand() ) : htmlspecialchars( $options[1] , ENT_QUOTES ) ;
  6. $pipe_ids = empty( $options[2] ) ? array(0) : explode( ',' , preg_replace( '/[^0-9,:]/' , '' , $options[2] ) ) ;
  7. $max_entries = empty( $options[3] ) ? 0 : intval( $options[3] ) ;
  8. $this_template = empty( $options[4] ) ? 'db:'.$mydirname.'_block_async.html' : trim( $options[4] ) ;
  9. $union_class = @$options[5] == 'separated' ? 'separated' : 'mergesort' ;
  10. $link2clipping = empty( $options[6] ) ? false : true ;
  11. $keep_pipeinfo = empty( $options[7] ) ? false : true ;
  12. if( preg_match( '/[^0-9a-zA-Z_-]/' , $mydirname ) ) die( 'Invalid mydirname' ) ;
  13. $module_handler =& xoops_gethandler('module');
  14. $module =& $module_handler->getByDirname($mydirname);
  15. $config_handler =& xoops_gethandler('config');
  16. $configs = $config_handler->getConfigList( $module->mid() ) ;
  17. $constpref = '_MB_' . strtoupper( $mydirname ) ;
  18. // insert javascript if necessary
  19. d3pipes_insert_javascript4async() ;
  20. $block = array(
  21. 'mydirname' => $mydirname ,
  22. 'mod_url' => XOOPS_URL.'/modules/'.$mydirname ,
  23. 'mod_imageurl' => XOOPS_URL.'/modules/'.$mydirname.'/'.$configs['images_dir'] ,
  24. 'mod_config' => $configs ,
  25. 'unique_id' => $unique_id ,
  26. 'pipe_ids' => $pipe_ids ,
  27. 'max_entries' => $max_entries ,
  28. 'union_class' => $union_class ,
  29. 'link2clipping' => $link2clipping ,
  30. 'keep_pipeinfo' => $keep_pipeinfo ,
  31. 'lang_async_noscript' => constant($constpref."_ASYNC_NOSCRIPT") ,
  32. ) ;
  33. if( empty( $options['disable_renderer'] ) ) {
  34. require_once XOOPS_TRUST_PATH.'/libs/altsys/class/D3Tpl.class.php' ;
  35. $tpl = new D3Tpl() ;
  36. $tpl->assign( 'block' , $block ) ;
  37. $ret['content'] = $tpl->fetch( $this_template ) ;
  38. return $ret ;
  39. } else {
  40. return $block ;
  41. }
  42. }
  43. function d3pipes_insert_javascript4async()
  44. {
  45. // javascript placed between <head></head>
  46. $head_script = '
  47. <script type="text/javascript">
  48. <!--
  49. function d3pipes_add_script( url )
  50. {
  51. script = document.createElement("script");
  52. script.setAttribute("type", "text/javascript");
  53. script.setAttribute("src", url + "&time=" + (new Date().getTime()) );
  54. script.setAttribute("charset", "'._CHARSET.'");
  55. document.getElementsByTagName("head").item(0).appendChild(script);
  56. }
  57. function d3pipes_insert_html( id , html )
  58. {
  59. document.getElementById( id ).innerHTML = html ;
  60. }
  61. //-->
  62. </script>
  63. ' ;
  64. if( is_object( $GLOBALS['xoopsTpl'] ) ) {
  65. $xoops_module_header = $GLOBALS['xoopsTpl']->get_template_vars( "xoops_module_header" ) ;
  66. if( ! strstr( $xoops_module_header , 'd3pipes_add_script' ) ) {
  67. $GLOBALS['xoopsTpl']->assign( 'xoops_module_header' , $head_script . $xoops_module_header ) ;
  68. }
  69. }
  70. }
  71. ?>