• User Attivo

    Aiuto BBcode you tube

    Ciao a tutti, ho bisogno del vostro aiuto, da sola proprio non ci riesco.
    Voglio a tutti i costi permettere l'inserimento dei video youtube sul social network di Zoint.

    Ho pensato, visto che non riesco a creare un blocco, di modificare il blocco dei commenti inserendoci da qualche parte il codice (in php) per permettere ad un utente di inserire un video youtube.

    Il codice è questo:

    <?php
    error_reporting(E_ALL & ~E_NOTICE);
    
    $this->zopts['editlimit'] = 3600;
    
    class mod_quick_comments extends z_module
    {
        var $aopts = array('maxcomments' => array('type' => VAR_UINT, 'value' => 20)
        );
        
        function update($content)
        {
            $content['opts']['limit'] = intval($content['opts']['limit']);
            $content['opts']['avatars'] = intval($content['opts']['avatars']);
    
            if ($content['opts']['limit'] > $this->get_adminopt('maxcomments'))
            {
                $this->_zoints->throw_error('max comments block limit', $this->get_adminopt('maxcomments'));
            }
    
            return $content;
        }
        
        function edit()
        {
            $content = $this->content;
            $html = '';
    
            if (empty($content['opts']))
            {
                $content['opts']['limit'] = 8;
                $content['opts']['avatars'] = true;
            }
    
            if ($content['opts']['avatars'])
            {
                $avataryes = ' checked="checked"';
            }
            else
            {
                $avatarno = ' checked="checked"';
            }
    
            $html .= '<div class="pmain1"><table cellpadding="2" cellspacing="0">
            <tr>
            <td>'. L('num-of-comments') .':&nbsp;&nbsp;</td><td><input name="mod[content][opts][limit]" type="text" size="2" value="' . $content['opts']['limit'] . '" /> ('. L('max') .': ' . $this->get_adminopt('maxcomments') . ')</td>
            </tr>
            <tr>
            <td>'. L('display-avatars') .'</td>
            <td><input type="radio"' . $avataryes . ' name="mod[content][opts][avatars]" value="1" /> '. L('yes') .' <input type="radio"' . $avatarno . ' name="mod[content][opts][avatars]" value="0" /> '. L('no') .'</td>
            </tr>
            </table>
            </div>';
    
            return $html;
        }
    
        function contents()
        {
            $html = '';
            $content =& $this->content;
    
            if (!is_array($content['opts']) OR !count($content['opts']))
            {
                $content['opts']['limit'] = 8;
                $content['opts']['avatars'] = true;
            }
    
            // If the block is not yet active, this will prevent a db error
            $this->linkid = intval($this->linkid);
    
            if ($this->_zoints->_user->logged_in())
            {
                $html .= '<div class="' . $this->style[$this->switch_bg()] . '"><a href="' . $this->_zoints->url('comments', 'cmd=newreply&amp;modid=' . $this->linkid . '&amp;rtab=' . $this->tab->info['tabid']) . '"><img class="zicon" src="' . IMAGEDIR . 'icon_add.gif" alt="" /></a><a href="' . $this->_zoints->url('comments', 'cmd=newreply&amp;modid=' . $this->linkid . '&amp;rtab=' . $this->tab->info['tabid']) . '">'. L('add-comment') .'</a></div>';
            }
    
            $getposts = $this->_db->query_read("
                    SELECT post.postid, post.userid, user.username, dateline, comment, comment_parsed, private,  avatar
                    FROM " . ZPRE . "profile_post_ids pids
                    LEFT JOIN " . ZPRE . "profile_post post ON (pids.postid = post.postid)
                    LEFT JOIN " . ZPRE . "user user ON (post.userid = user.userid)
                    WHERE pids.modid = " . $this->linkid . " AND pids.masterid = " . $this->zuser . (!$this->powner ? ' AND private = 0 OR (pids.masterid = ' . $this->zuser . ' AND private = 1 AND post.userid = ' . $this->_zoints->_user->get('userid') . ')' : '') . "
                    ORDER BY dateline DESC
                    LIMIT " . $content['opts']['limit']
            );
            if ($this->_db->num_rows($getposts))
            {
                $tmpposts = array();
                while ($post = $this->_db->fetch_array($getposts))
                {
                    $this->_zoints->cache_avatar($post['userid']);
                    $tmpposts[] = $post;
                }
    
                foreach ($tmpposts as $post)
                {
                    $bgclass = $this->style[$this->switch_bg()];
                    
                    //$post['comment_parsed'] = $this->_zoints->word_wrap($post['comment_parsed'], '400px');
    
                    // Main header w/ date, reply, delete, & edit options
                    $html .= '<div><div class="' . $this->style['phead'] . ' pad3"><div class="f_right" style="margin-top: -5px;">' . 
                        ($post['private'] ? ' (' . L('private-post') . ')' : '') . 
    
                        ((!$post['private'] AND $this->_zoints->_user->logged_in()) ? 
                            '<a href="' . $this->_zoints->url('comments', 'cmd=newreply&amp;rtab=' . $this->tab->info['tabid'] . '&amp;postid=' . $post['postid']) . '"><img class="zicon" src="' . IMAGEDIR . 'quote-button.png" alt="' . L('quote-post') . '" title="' . L('quote-post') . '" border="0"  width="43" height="16" /></a>' : '') . 
    
                        (($this->_zoints->_user->get('userid') == $post['userid'] AND $post['dateline'] > (TIME - $this->zopts['editlimit'])) ? 
                            '<a href="' . $this->_zoints->url('comments', 'cmd=editpost&amp;postid=' . $post['postid']) . '"><img class="zicon" src="' . IMAGEDIR . 'icon_edit.gif" alt="' . L('edit-post') . '" title="' . L('edit-post') . '" border="0" /></a>' : '') . 
    
                        ((($this->_zoints->_user->get('userid') == $post['userid'] AND $post['dateline'] > (TIME - $this->zopts['editlimit'])) OR $this->powner) ? 
                            '<a href="' . $this->_zoints->url('comments', 'cmd=delconf&amp;postid=' . $post['postid']) . '&amp;modid=' . $this->linkid . '"><img class="zicon" src="' . IMAGEDIR . 'icon_delete.gif" alt="' . L('delete-post') . '" title="' . L('delete-post') . '" border="0" /></a>' : '') . 
                        '</div>' . $this->_zoints->external->date($post['dateline']) . '</div>';
    
                    // Start content with the avatar, username, and post text
                    $html .= '<div class="' . $bgclass . ' pad3"><div class="f_left"><div style="font-weight:bold;margin-bottom: 2px;"><a href="' . $this->_zoints->profile_url($post) . '">' . $post['username'] . '</a></div>';
                    
                    if ($content['opts']['avatars'])
                    {
                        $html .= '<a href="' . $this->_zoints->profile_url($post) . '">' . $this->_zoints->get_avatar($post) . '</a>';
                    }
                    
                    $html .= '</div><div class="clear">' . $post['comment_parsed'] . '</div></div></div>';
                }
            }
            else
            {
                $html .= '<div class="' . $this->style['pmain1'] . '">'. L('no-comments') .'</div>';
            }
    
            $html .= '<div class="' . $this->style[$this->switch_bg()] . '"><img src="' . IMAGEDIR . 'spacer.gif" height="10" width="1" alt="" /></div><div class="' . $this->style[$this->switch_bg()] . '">' . 
                ($this->_zoints->_user->logged_in() ? '<a href="' . $this->_zoints->url('comments', 'modid=' . $this->linkid) . '"><img class="zicon" src="' . IMAGEDIR . 'icon_view.gif" border="0" alt="" /></a><a href="' . $this->_zoints->url('comments', 'modid=' . $this->linkid) . '">'. L('view-all-comments') .'</a>' : '') . 
                ($this->_zoints->_user->logged_in() ? '<div style="margin-top:4px"><a href="' . $this->_zoints->url('comments', 'cmd=newreply&amp;modid=' . $this->linkid . '&amp;rtab=' . $this->tab->info['tabid']) . '"><img class="zicon" src="' . IMAGEDIR . 'icon_add.gif" alt="" /></a><a href="' . $this->_zoints->url('comments', 'cmd=newreply&amp;modid=' . $this->linkid . '&amp;rtab=' . $this->tab->info['tabid']) . '">'. L('add-comment') .'</a></div>' : '') . '</div>';
    
            return $html;
        }
        
        function adminopts()
        {
            $this->_zoints->lang->load('modules/general_aopts');
            
            $html = '<label>'  . L('max-comments') . ': <input type="text" name="aopts[maxcomments]" value="' . $this->get_adminopt('maxcomments') . '" size="2" maxlength="2" /></label>';
            
            return $html;
        }
    }
    
    ?>
    

    Mi aiutate a modificarlo in modo da inserire anche questa funzione?
    Grazie.


  • Super User

    Il quesito è preferibile porlo nella sezione php, perchè quì non abbiamo competenze per modifiche articolate del codice, ed in particolare di prodotti di terze parti.

    Questo thread lo lasceremo aperto per indicare la possibile soluzione che otterrai dagli esperti di php, però apri una nuova discussione nella sezione dedicata 😉


  • User Attivo

    Grazie karapoto, lo faccio subito. :ciauz:


  • User Attivo

    Discussione aperta qua, spero di aver fatto correttamente:
    giorgiotave.it/forum/funzioni-di-php/109570-aiuto-bbcode-you-tube.html#post633173