[ Index ] |
|
Code source de CMS made simple 1.0.5 |
1 <?php 2 #CMS - CMS Made Simple 3 #(c)2004 by Ted Kulp (wishy@users.sf.net) 4 #This project's homepage is: http://cmsmadesimple.sf.net 5 # 6 #This program is free software; you can redistribute it and/or modify 7 #it under the terms of the GNU General Public License as published by 8 #the Free Software Foundation; either version 2 of the License, or 9 #(at your option) any later version. 10 # 11 #This program is distributed in the hope that it will be useful, 12 #but WITHOUT ANY WARRANTY; without even the implied warranty of 13 #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 #GNU General Public License for more details. 15 #You should have received a copy of the GNU General Public License 16 #along with this program; if not, write to the Free Software 17 #Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 19 #Author: Sorin Sbarnea / INTERSOL SRL 20 function smarty_cms_function_embed($params, &$smarty) 21 { 22 global $gCms; 23 24 if(!empty($params['header'])) 25 { 26 $code = <<<IFRAMECODE 27 <script type="text/javascript"> 28 29 /*********************************************** 30 * IFrame SSI script II- S Dynamic Drive DHTML code library (http://www.dynamicdrive.com) 31 * Visit DynamicDrive.com for hundreds of original DHTML scripts 32 * This notice must stay intact for legal use 33 ***********************************************/ 34 35 //Input the IDs of the IFRAMES you wish to dynamically resize to match its content height: 36 //Separate each ID with a comma. Examples: ["myframe1", "myframe2"] or ["myframe"] or [] for none: 37 var iframeids=["myframe"] 38 39 //Should script hide iframe from browsers that don't support this script (non IE5+/NS6+ browsers. Recommended): 40 var iframehide="yes" 41 42 var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1] 43 var FFextraHeight=parseFloat(getFFVersion)>=0.1? 16 : 0 //extra height in px to add to iframe in FireFox 1.0+ browsers 44 45 function resizeCaller() { 46 var dyniframe=new Array() 47 for (i=0; i<iframeids.length; i++){ 48 if (document.getElementById) 49 resizeIframe(iframeids[i]) 50 //reveal iframe for lower end browsers? (see var above): 51 if ((document.all || document.getElementById) && iframehide=="no"){ 52 var tempobj=document.all? document.all[iframeids[i]] : document.getElementById(iframeids[i]) 53 tempobj.style.display="block" 54 } 55 } 56 } 57 58 function resizeIframe(frameid){ 59 var currentfr=document.getElementById(frameid) 60 if (currentfr && !window.opera){ 61 currentfr.style.display="block" 62 if (currentfr.contentDocument && currentfr.contentDocument.body.offsetHeight) //ns6 syntax 63 currentfr.height = currentfr.contentDocument.body.offsetHeight+FFextraHeight; 64 else if (currentfr.Document && currentfr.Document.body.scrollHeight) //ie5+ syntax 65 currentfr.height = currentfr.Document.body.scrollHeight; 66 if (currentfr.addEventListener) 67 currentfr.addEventListener("load", readjustIframe, false) 68 else if (currentfr.attachEvent){ 69 currentfr.detachEvent("onload", readjustIframe) // Bug fix line 70 currentfr.attachEvent("onload", readjustIframe) 71 } 72 } 73 } 74 75 function readjustIframe(loadevt) { 76 var crossevt=(window.event)? event : loadevt 77 var iframeroot=(crossevt.currentTarget)? crossevt.currentTarget : crossevt.srcElement 78 if (iframeroot) 79 resizeIframe(iframeroot.id); 80 } 81 82 function loadintoIframe(iframeid, url){ 83 if (document.getElementById) 84 document.getElementById(iframeid).src=url 85 } 86 87 if (window.addEventListener) 88 window.addEventListener("load", resizeCaller, false) 89 else if (window.attachEvent) 90 window.attachEvent("onload", resizeCaller) 91 else 92 window.onload=resizeCaller 93 94 </script> 95 IFRAMECODE; 96 return $code; 97 } 98 99 if (!empty($params['url'])) 100 { 101 $url = $params['url']; 102 } else return "<pre>Invalid call for embed function.<pre>"; 103 104 // $params['height']='200%'; 105 // $params['width']='100%'; 106 // 107 // return '<iframe width="'.$params['width']. 108 // '" scrolling="yes" height="'.$params['height']. 109 // '" frameborder="0" marginwidth="0" marginheight="0" src="http://www2.romanianoffice.ro/forum/index.php"></iframe>'; 110 111 return "<iframe id='myframe' src='$url' scrolling='no' marginwidth='0' marginheight='0' frameborder='0' vspace='0' hspace='0' style='overflow:visible; width:99%; display:none'></iframe>"; 112 113 } 114 115 function smarty_cms_help_function_embed() { 116 ?> 117 <h3>What does this do?</h3> 118 <p>Enable inclusion (embeding) of any other application into the CMS. The most usual use could be a forum. 119 This implementation is using IFRAMES so older browsers can have problems. Sorry bu this is the only known way 120 that works without modifing the embeded application.</p> 121 <h3>How do I use it?</h3> 122 <p>Just insert the tag into your template/page like: <code>{embed url=http://www.google.com/}</code><br></p> 123 <h4>Example to make the iframe larger</h4> 124 <p>Add the following to your style sheet:</p> 125 <pre>#myframe { height: 600px; }</pre> 126 <h3>What parameters does it take?</h3> 127 <ul> 128 <li><em>(required)</em>url - the url to be included 129 <li><em>(optional)</em>header=true - this will generate the header code for good resizing of the IFRAME.</li> 130 131 </ul> 132 <p>You must include in your page content {embed url=..} and in the "Metadata:" section (advanced tab) you must put {embed header=true}. Also be sure to put this in between the "head" tags of your template: {metadata}</p> 133 134 <?php 135 } 136 137 function smarty_cms_about_function_embed() { 138 ?> 139 <p>Author: Sorin Sbarnea<sorin2000@intersol.ro> (remove 2000)</p> 140 <p>Version: 1.0</p> 141 <p> 142 Change History:<br/> 143 None 144 </p> 145 <?php 146 } 147 148 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Tue Apr 3 18:50:37 2007 | par Balluche grâce à PHPXref 0.7 |