MyBB.de Forum

Normale Version: Latest Attachment Gallery
Du siehst gerade eine vereinfachte Darstellung unserer Inhalte. Normale Ansicht mit richtiger Formatierung.
Seiten: 1 2 3 4 5
Ich werde das programmieren.
Das wär goil :-)
Ersetze das:
PHP-Code:
function atchgallery()
{
    global 
$mybb$templates$atchgallery$db$collapsed$collapsedimg$theme$header;
    
    
$forum $mybb->settings['atchgalleryforum'];
    
$max $mybb->settings['atchgallerymax'];
    
$maxperrow $mybb->settings['atchgallerymaxperrow'];
    
    if((
$mybb->settings['showatchgallery'] != 'off') && (is_numeric($forum)) && (is_numeric($max)))
    {
        
$i=0;
        
$query $db->query("SELECT * FROM ".TABLE_PREFIX."attachments WHERE thumbnail != '' ORDER BY aid DESC");
        while(
$i $max && $rows $db->fetch_array($query))
        {
            if(
$forum == -1)
            {
                
$i++;
                
$array[$i][aid] = $rows['aid'];
                
$array[$i][pid] = $rows['pid'];
                
$array[$i][thumbnail] = $rows['thumbnail'];
            }
            else
            {
                
$checkquery $db->simple_select(TABLE_PREFIX."posts""fid""pid = '" $rows['pid'] . "' AND fid = '" $forum "'");
                
$c $db->fetch_array($checkquery);
                if(
is_array($c))
                {
                    
$i++;
                    
$array[$i][aid] = $rows['aid'];
                    
$array[$i][pid] = $rows['pid'];
                    
$array[$i][thumbnail] = $rows['thumbnail'];
                }
            }
        }
        
        
//only show on forum index
        
if($mybb->settings['atchgalleryglobal'] == '1')
        {
            
$visible = (basename($_SERVER["PHP_SELF"]) == "index.php" || basename($_SERVER["PHP_SELF"]) == "portal.php");
        }
        
//only show on THE forum specified to pull attachments from
        
else if($mybb->settings['atchgalleryglobal'] == '-1')
        {
            if((
basename($_SERVER["PHP_SELF"]) == "forumdisplay.php" && $mybb->input['fid'] == $forum) || $forum == '-1')
            {
                
$visible TRUE;
            }
            elseif(
basename($_SERVER["PHP_SELF"]) == "showthread.php")
            {
                
$thread get_thread($mybb->input['tid']);
                if(
$forum == $thread['fid'])
                {
                    
$visible TRUE;
                }
            }
        }
        else
        {
            
$visible TRUE;
        }
        
        if((
$i 0) && $visible)
        {
            
$count 0;
            foreach(
$array as $thumbs)
            {
                
$height $mybb->settings['attachthumbh']+10;
                
$count++;
                
$i--;
                if(
$mybb->settings['atchgallerylink'] == 'no')
                {
                    
$link "attachment.php?aid=" $thumbs[aid];
                }
                else if(
$mybb->settings['atchgallerylink'] == 'yes')
                {
                    
$post get_post($thumbs[pid]);
                    
$link "showthread.php?tid=" $post['tid'] . "&pid=" $thumbs[pid] . "#pid" $thumbs[pid];
                }
                
                
//if there is a thumbnail, that means its a big attachment!
                
$image = ($thumbs[thumbnail]=='SMALL') ? 'aid' 'thumbnail';

                
$rowwidth 100/$maxperrow;
                
$thumbnails .= "<td class=\"trow1\" style=\"text-align: center; width: " $rowwidth "%;\">\n";
                
$thumbnails .= "\t<a href=\"" $link "\" target=\"_blank\"><img src=\"attachment.php?" $image "=" $thumbs[aid] . "\" class=\"attachment\" alt=\"\"></a>\n";
                
$thumbnails .= "</td>\n";
                
                if((
$count == $maxperrow) && ($i != 0))
                {
                    
$thumbnails .= "\n</tr>\n<tr style=\"height: " $height "px;\">";
                    
$count 0;
                }
            }
            
            
$name $mybb->settings['atchgalleryname'];
            
//if the collapse button is enabled
            
if($mybb->settings['atchgallerycollapse'] == 'on')
            {
                
$collapse "
                <div class=\"expcolimage\">
                    <img src=\""
.$theme['imgdir']."/collapse".$collapsedimg[$cid].".gif\" id=\"atchgallery_id_img\" class=\"expander\" alt=\"[-]\" />
                </div>"
;
            }
            eval(
"\$atchgallery = \"".$templates->get('atchgallery')."\";");
            
$header str_replace('{atchgallery}'$atchgallery$header);
        }
    }

durch:
PHP-Code:
function atchgallery()
{
    global 
$mybb$templates$atchgallery$db$collapsed$collapsedimg$theme$header;
    
    
$forum $mybb->settings['atchgalleryforum'];
    
$max $mybb->settings['atchgallerymax'];
    
$maxperrow $mybb->settings['atchgallerymaxperrow'];
    
    if((
$mybb->settings['showatchgallery'] != 'off') && (is_numeric($max)))
    {
        
$i=0;
        
$query $db->query("SELECT * FROM ".TABLE_PREFIX."attachments WHERE thumbnail != '' ORDER BY aid DESC");
        while(
$i $max && $rows $db->fetch_array($query))
        {
            if(
$forum == -1)
            {
                
$i++;
                
$array[$i][aid] = $rows['aid'];
                
$array[$i][pid] = $rows['pid'];
                
$array[$i][thumbnail] = $rows['thumbnail'];
            }
            else
            {
                
$checkquery $db->simple_select(TABLE_PREFIX."posts""fid""pid = '" $rows['pid'] . "' AND fid IN (" $forum ")");
                
$c $db->fetch_array($checkquery);
                if(
is_array($c))
                {
                    
$i++;
                    
$array[$i][aid] = $rows['aid'];
                    
$array[$i][pid] = $rows['pid'];
                    
$array[$i][thumbnail] = $rows['thumbnail'];
                }
            }
        }
        
        
//only show on forum index
        
if($mybb->settings['atchgalleryglobal'] == '1')
        {
            
$visible = (basename($_SERVER["PHP_SELF"]) == "index.php" || basename($_SERVER["PHP_SELF"]) == "portal.php");
        }
        
//only show on THE forum specified to pull attachments from
        
else if($mybb->settings['atchgalleryglobal'] == '-1')
        {
            if((
basename($_SERVER["PHP_SELF"]) == "forumdisplay.php" && stripos(','.$forum.','','.$mybb->input['fid'].',') !== false) || $forum == '-1')
            {
                
$visible TRUE;
            }
            elseif(
basename($_SERVER["PHP_SELF"]) == "showthread.php")
            {
                
$thread get_thread($mybb->input['tid']);
                if(
stripos(','.$forum.','','.$thread['fid'].',') !== false)
                {
                    
$visible TRUE;
                }
            }
        }
        else
        {
            
$visible TRUE;
        }
        
        if((
$i 0) && $visible)
        {
            
$count 0;
            foreach(
$array as $thumbs)
            {
                
$height $mybb->settings['attachthumbh']+10;
                
$count++;
                
$i--;
                if(
$mybb->settings['atchgallerylink'] == 'no')
                {
                    
$link "attachment.php?aid=" $thumbs[aid];
                }
                else if(
$mybb->settings['atchgallerylink'] == 'yes')
                {
                    
$post get_post($thumbs[pid]);
                    
$link "showthread.php?tid=" $post['tid'] . "&pid=" $thumbs[pid] . "#pid" $thumbs[pid];
                }
                
                
//if there is a thumbnail, that means its a big attachment!
                
$image = ($thumbs[thumbnail]=='SMALL') ? 'aid' 'thumbnail';

                
$rowwidth 100/$maxperrow;
                
$thumbnails .= "<td class=\"trow1\" style=\"text-align: center; width: " $rowwidth "%;\">\n";
                
$thumbnails .= "\t<a href=\"" $link "\" target=\"_blank\"><img src=\"attachment.php?" $image "=" $thumbs[aid] . "\" class=\"attachment\" alt=\"\"></a>\n";
                
$thumbnails .= "</td>\n";
                
                if((
$count == $maxperrow) && ($i != 0))
                {
                    
$thumbnails .= "\n</tr>\n<tr style=\"height: " $height "px;\">";
                    
$count 0;
                }
            }
            
            
$name $mybb->settings['atchgalleryname'];
            
//if the collapse button is enabled
            
if($mybb->settings['atchgallerycollapse'] == 'on')
            {
                
$collapse "
                <div class=\"expcolimage\">
                    <img src=\""
.$theme['imgdir']."/collapse".$collapsedimg[$cid].".gif\" id=\"atchgallery_id_img\" class=\"expander\" alt=\"[-]\" />
                </div>"
;
            }
            eval(
"\$atchgallery = \"".$templates->get('atchgallery')."\";");
            
$header str_replace('{atchgallery}'$atchgallery$header);
        }
    }

Dann kannst du anstatt einer fid mehrere angeben. Du musst sie durch Kommas trennen.
Hallo Dragon,

erstmal vielen Dank. Ich hatte erst heute abend etwas Zeit das Plugin zu patchen. Leider lässt sich das Forum wegen SQL-Fehlers dann nicht mehr aufrufen:

MySQL error: 1064
You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near ''' at line 1
Query: SELECT fid FROM mybb_posts WHERE pid = '6995' AND fid IN (19)'


Fehlt da ein Hochkomma vor dem SELECT ? Hab leider im Moment leider selbst keine Zeit im Code zu suchen.

Schöne Woche
Da war ein ' zu viel. Ich habe den Code oben ausgebessert. Funktioniert es jetzt?
Das hätte ich wahrscheinlich ohne Grippe auch gefunden, sorry.

Funktioniert jetzt, aber ohne Beachtung der Userrechte... d. h. er beschränkt die Anzeige nicht auf das einzelne Forum, sondern schmeisst aus den angegebenen Foren die Bilder zusammen.

Dann stimmen aber die Zugriffsrechte nicht mehr, wir haben nämlich einen geschlossenen Forumsbereich.

Es sollte so sein, dass nur Bilder nur eines, nämlich jeweils des angezeigten Forums, angezeigt werden.

Gruss
Hi ihr Meistercoder:

Wieviel aufwand ist es, das PHP-Script so zu ändern, dass es Zufallsbilder wählt und nicht die letzten.
Wäre ein zusätzliches Template denkbar mit nur einem Bild? Unabhängig vom bisherigen Template?
Ich suche sowas für das Portal. Existiert evtl. ein anderes Plugin irgendwo dafür?

Danke Big Grin
Mit der Programmierung des Zufalls kenne ich mich nicht aus. Wink
Du willst noch so ein Plugin, dass nur ein Bild anzeigt und beim Portal zu sehen ist?
Dragon schrieb:Du willst noch so ein Plugin, dass nur ein Bild anzeigt und beim Portal zu sehen ist?

Ja, richtig. Über eine Bildergallerie ist ja schon viel gepostet worden. Aber ich brauche keine große Gallerie. Ich (wir) möchte auf dem Portal und/oder Index eine kleine Box anbringen in der ein zufällig gewähltes Attachment-Bild angezeigt wird. Ähnlich wie es zB im MKPortal möglich ist. Ich möchte aber nicht ein extra Portal von einem Drittanbieter installieren und suche jetzt nach Bordmitteln. Wie zB auch einen Blog.

Technisch stelle ich mit das so vor:
Im PluginPHP ist eine SQL-Abfrage drin. Hab ich schon gesehen. Die ist nach Datum sortiert. Wenn mann jetzt eine Zufallszahl von 1 bis <Anzahl der Attachments> generiert und einfach ein Attach damit rauspickt, wäre das doch mit machbar...?
Ich habe keine Plan von PHP. Sonst würde ich mich selber dransetzen Smile
Auch ein Template einzubinden in das vorhandene PHP müsste doch kein Problem sein. da würde ich mich sogar selber dran trauen.
Das mit der Zufallszahl ist nicht so einfach. Die ID muss es ja auch geben und sie sollte ein Bild sein. Daher geht das nicht so einfach.
Seiten: 1 2 3 4 5