Coppermine within SMF (tích hợp Coppermine với SMF)

Started by saos@ngmo, 21/08/06, 18:31

Previous topic - Next topic

saos@ngmo

I shared this over at smf with kegobeer, and thought others might find it interesting here. This hack will allow you to have your forum wrapped around coppermine, assuming you have already bridged the 2 Wink

example:

http://www.snork13.net/forum/index.php?action=gallery


You will need to create the 2 new files: Gallery.php & Gallery.template.php
edit 2 other files: index.php & index.template.php

**3/15/06*** edited Gallery.php to provide a linktree, and uploaded a copy, just remove the .txt Wink

sources/Gallery.php
Code:

<?php
if (!defined('SMF'))
die('Hacking attempt...');

Function Gallery()
{

   global  $txt, $scripturl,  $db_prefix, $context;
   LoadTemplate('Gallery');
   $context['page_title'] = "Gallery";
   $context['linktree'][] = array(
      'url' => $scripturl . '?action=gallery',
      'name' => $txt['gallery']
   );

}

?>


themes/???/Gallery.template.php
Code:

<?php
// Version: 1.1 RC2; Gallery

function template_main()
{
   global $context, $settings, $options, $txt, $scripturl;

   echo '
   <script language="JavaScript" type="text/javascript"><!--
      function checkAll(onOff)
      {
         for (var i = 0; i < document.searchform.elements.length; i++)
         {
            if (document.searchform.elements.name.substr(0, 3) == "brd")
               document.searchform.elements.checked = onOff;
         }
      }
   // --></script>
   <form action="', $scripturl, '?action=search2" method="post" name="searchform" id="searchform">

<script type="text/javascript"><!--

/***********************************************
* IFrame SSI script II- © Dynamic Drive DHTML code library (http://www.dynamicdrive.com)
* Visit DynamicDrive.com for hundreds of original DHTML scripts
* This notice must stay intact for legal use
***********************************************/

//Input the IDs of the IFRAMES you wish to dynamically resize to match its content height:
//Separate each ID with a comma. Examples: ["myframe1", "myframe2"] or ["myframe"] or [] for none:
var iframeids=["myframe"]

//Should script hide iframe from browsers that don\'t support this script (non IE5+/NS6+ browsers. Recommended):
var iframehide="yes"

var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1]
var FFextraHeight=parseFloat(getFFVersion)>=0.1? 16 : 0 //extra height in px to add to iframe in FireFox 1.0+ browsers

function resizeCaller() {
var dyniframe=new Array()
for (i=0; i<iframeids.length; i++){
if (document.getElementById)
resizeIframe(iframeids)
//reveal iframe for lower end browsers? (see var above):
if ((document.all || document.getElementById) && iframehide=="no"){
var tempobj=document.all? document.all[iframeids] : document.getElementById(iframeids)
tempobj.style.display="block"
}
}
}

function resizeIframe(frameid){
var currentfr=document.getElementById(frameid)
if (currentfr && !window.opera){
currentfr.style.display="block"
if (currentfr.contentDocument && currentfr.contentDocument.body.offsetHeight) //ns6 syntax
currentfr.height = currentfr.contentDocument.body.offsetHeight+FFextraHeight;
else if (currentfr.Document && currentfr.Document.body.scrollHeight) //ie5+ syntax
currentfr.height = currentfr.Document.body.scrollHeight;
if (currentfr.addEventListener)
currentfr.addEventListener("load", readjustIframe, false)
else if (currentfr.attachEvent){
currentfr.detachEvent("onload", readjustIframe) // Bug fix line
currentfr.attachEvent("onload", readjustIframe)
}
}
}

function readjustIframe(loadevt) {
var crossevt=(window.event)? event : loadevt
var iframeroot=(crossevt.currentTarget)? crossevt.currentTarget : crossevt.srcElement
if (iframeroot)
resizeIframe(iframeroot.id);
}

function loadintoIframe(iframeid, url){
if (document.getElementById)
document.getElementById(iframeid).src=url
}

if (window.addEventListener)
window.addEventListener("load", resizeCaller, false)
else if (window.attachEvent)
window.attachEvent("onload", resizeCaller)
else
window.onload=resizeCaller

// --></script>

      <table width="100%" border="0" cellspacing="0" cellpadding="4" align="center" class="tborder">
         <tr class="titlebg">
            <td>Gallery</td>
         </tr><tr>
            <td class="windowbg">';

               // load the gallery
               echo '<iframe id="myframe" src="http://www.???.com/gallery" scrolling="no" marginwidth="0" marginheight="0" frameborder="0" vspace="0" hspace="0" style="overflow:novisible; width:100%; display:none"></iframe>';

   echo '
            </td>
         </tr>
      </table>
   </form>';
}

?>


/index.php


find:

Code:

'findmember' => array('Subs-Auth.php', 'JSMembers'),


after add;
Code:

'gallery' => array('Gallery.php', 'Gallery'),



themes/???/index.template

find:

if ($context['user']['is_logged'])
      echo '
            <a href="', $scripturl, '?action=calendar">', ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/calendar.gif" alt="' . $txt['calendar24'] . '" style="margin: 2px 0;" border="0" />' : $txt['calendar24']), '</a>', $context['menu_separator'];
      


after add:
Code:

   echo'
            <a href="', $scripturl, '?action=gallery">', ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/gallery.gif" alt="Gallery"' . $txt[''] . '" style="margin: 2px 0;" border="0" />' : $txt['Gallery']), '</a>', $context['menu_separator'];


change www.Huh.com to reflect your actual location, the template has a javascript that allows the iframe to open full, it's the best i could do. It similar to the FlashChat intergration and where i got the idea Smiley

i would also suggestion tweaking the gallery menu to meet your needs, and you could also prevent direct access to the gallery via a .htaccess file


Source: http://coppermine-gallery.net/forum/index.php?topic=25877.0

SEO ngành nghề, cỏ nhân tạo, chuyên sửa máy rửa bát tại hà nội, tình yêu độ xe Mercedes, chuyên sửa chữa tivi tại nhà ở Hà Nội, đặt hàng tượng phật đồ thờ tâm linh làng nghề Sơn Đồng | Điện lạnh Bách Khoa Hà Nội