21
McDonald
Re: Youtube HotLink Gallery
  • 2007/8/13 21:40

  • McDonald

  • Home away from home

  • Posts: 1072

  • Since: 2005/8/15


Quote:
Fatal error: Call to a member function on a non-object in /home/nznewbie/public_html/class/xoopsform/form.php on line 193
Errors Notice: Only variables should be assigned by reference in file /class/xoopsform/formdhtmltextarea.php line 183


There are no errors related to XoopsTube, but the Fatal error might cause the problem.

Xoops 2.0.15 had a faulty file: /class/xoopsform/form.php

I guess this is the problem.

You might consider to upgrade to XOOPS 2.0.16

This is the correct version of form.php:
<?php
// $Id: form.php 748 2006-09-20 21:01:31Z skalpa $
//  ------------------------------------------------------------------------ //
//                XOOPS - PHP Content Management System                      //
//                    Copyright (c) 2000 XOOPS.org                           //
//                       <https://xoops.org/>                             //
//  ------------------------------------------------------------------------ //
//  This program is free software; you can redistribute it and/or modify     //
//  it under the terms of the GNU General Public License as published by     //
//  the Free Software Foundation; either version 2 of the License, or        //
//  (at your option) any later version.                                      //
//                                                                           //
//  You may not change or alter any portion of this comment or credits       //
//  of supporting developers from this source code or any supporting         //
//  source code which is considered copyrighted (c) material of the          //
//  original comment or credit authors.                                      //
//                                                                           //
//  This program is distributed in the hope that it will be useful,          //
//  but WITHOUT ANY WARRANTY; without even the implied warranty of           //
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            //
//  GNU General Public License for more details.                             //
//                                                                           //
//  You should have received a copy of the GNU General Public License        //
//  along with this program; if not, write to the Free Software              //
//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA //
//  ------------------------------------------------------------------------ //
// Author: Kazumi Ono (AKA onokazu)                                          //
// URL: http://www.myweb.ne.jp/, https://xoops.org/, http://www.xoopscube.jp/ //
// Project: The XOOPS Project                                                //
// ------------------------------------------------------------------------- //
// public abstruct
/**
 * 
 * 
 * @package     kernel
 * @subpackage  form
 * 
 * @author        Kazumi Ono    <onokazu@xoops.org>
 * @copyright    copyright (c) 2000-2003 XOOPS.org
 */


/**
 * Abstract base class for forms
 * 
 * @author    Kazumi Ono    <onokazu@xoops.org>
 * @copyright    copyright (c) 2000-2003 XOOPS.org
 * 
 * @package     kernel
 * @subpackage  form
 */
class XoopsForm {
    
/**#@+
     * @access  private
     */
    /** 
     * "action" attribute for the html form
     * @var string  
     */
    
var $_action;

    
/**
     * "method" attribute for the form.
     * @var string  
     */
    
var $_method;

    
/**
     * "name" attribute of the form
     * @var string  
     */
    
var $_name;

    
/**
     * title for the form
     * @var string  
     */
    
var $_title;

    
/**
     * array of {@link XoopsFormElement} objects
     * @var  array   
     */
    
var $_elements = array();

    
/**
     * extra information for the <form> tag
     * @var string  
     */
    
var $_extra;

    
/**
     * required elements
     * @var array   
     */
    
var $_required = array();
    
    
/**#@-*/

    /**
     * constructor
     * 
     * @param    string  $title  title of the form
     * @param    string  $name   "name" attribute for the <form> tag
     * @param    string  $action "action" attribute for the <form> tag
     * @param   string  $method "method" attribute for the <form> tag
     * @param   bool    $addtoken whether to add a security token to the form
     */
    
function XoopsForm($title$name$action$method="post"$addtoken=false){
        
$this->_title $title;
        
$this->_name $name;
        
$this->_action $action;
        
$this->_method $method;
        if (
$addtoken != false) {
            
$this->addElement(new XoopsFormHiddenToken());
        }
    }

    
/**
     * return the title of the form
     * 
     * @return    string
     */
    
function getTitle(){
        return 
$this->_title;
    }

    
/**
     * get the "name" attribute for the <form> tag
     * 
     * @return    string
     */
    
function getName(){
        return 
$this->_name;
    }

    
/**
     * get the "action" attribute for the <form> tag
     * 
     * @return    string
     */
    
function getAction(){
        return 
$this->_action;
    }

    
/**
     * get the "method" attribute for the <form> tag
     * 
     * @return    string
     */
    
function getMethod(){
        return 
$this->_method;
    }

    
/**
     * Add an element to the form
     *
     * @param    object  &$formElement    reference to a {@link XoopsFormElement}
     * @param    bool    $required       is this a "required" element?
     */
    
function addElement(&$formElement$required=false){
        if ( 
is_string$formElement ) ) {
            
$this->_elements[] = $formElement;
        } elseif ( 
is_subclass_of($formElement'xoopsformelement') ) {
            
$this->_elements[] =& $formElement;
            if (
$required) {
                if (!
$formElement->isContainer()) {
                    
$this->_required[] =& $formElement;
                } else {
                    
$required_elements =& $formElement->getRequired();
                    
$count count($required_elements);
                    for (
$i $i $count$i++) {
                        
$this->_required[] =& $required_elements[$i];
                    }
                }
            }
        }
    }

    
/**
     * get an array of forms elements
     * 
     * @param    bool    get elements recursively?
     * @return    array   array of {@link XoopsFormElement}s
     */
    
function &getElements($recurse false){
        if (!
$recurse) {
            return 
$this->_elements;
        } else {
            
$ret = array();
            
$count count($this->_elements);
            for (
$i 0$i $count$i++) {
                if ( 
is_object$this->_elements[$i] ) ) {
                    if (!
$this->_elements[$i]->isContainer()) {
                        
$ret[] =& $this->_elements[$i];
                    } else {
                        
$elements =& $this->_elements[$i]->getElements(true);
                        
$count2 count($elements);
                        for (
$j 0$j $count2$j++) {
                            
$ret[] =& $elements[$j];
                        }
                        unset(
$elements);
                    }
                }
            }
            return 
$ret;
        }
    }

    
/**
     * get an array of "name" attributes of form elements
     * 
     * @return    array   array of form element names
     */
    
function getElementNames()
    {
        
$ret = array();
        
$elements =& $this->getElements(true);
        
$count count($elements);
        for (
$i 0$i $count$i++) {
            
$ret[] = $elements[$i]->getName();
        }
        return 
$ret;
    }

    
/**
     * get a reference to a {@link XoopsFormElement} object by its "name"
     * 
     * @param  string  $name    "name" attribute assigned to a {@link XoopsFormElement}
     * @return object  reference to a {@link XoopsFormElement}, false if not found
     */
    
function &getElementByName($name){
        
$elements $this->getElements(true);
        
$count count($elements);
        for (
$i 0$i $count$i++) {
            if (
$name == $elements[$i]->getName()) {
                return 
$elements[$i];
            }
        }
        
$elt false;
        return 
$elt;
    }

    
/**
     * Sets the "value" attribute of a form element
     * 
     * @param    string $name    the "name" attribute of a form element
     * @param    string $value    the "value" attribute of a form element
     */
    
function setElementValue($name$value){
        
$ele =& $this->getElementByName($name);
        if (
is_object($ele) && method_exists($ele'setValue')) {
            
$ele->setValue($value);
        }
    }

    
/**
     * Sets the "value" attribute of form elements in a batch
     * 
     * @param    array $values    array of name/value pairs to be assigned to form elements
     */
    
function setElementValues($values){
        if (
is_array($values) && !empty($values)) {
            
// will not use getElementByName() for performance..
            
$elements =& $this->getElements(true);
            
$count count($elements);
            for (
$i 0$i $count$i++) {
                
$name $elements[$i]->getName();
                if (
$name && isset($values[$name]) && method_exists($elements[$i], 'setValue')) {
                    
$elements[$i]->setValue($values[$name]);
                }
            }
        }
    }

    
/**
     * Gets the "value" attribute of a form element
     * 
     * @param    string     $name    the "name" attribute of a form element
     * @return    string     the "value" attribute assigned to a form element, null if not set
     */
    
function getElementValue($name){
        
$ele =& $this->getElementByName($name);
        if (
is_object($ele) && method_exists($ele'getValue')) {
            return 
$ele->getValue($value);
        }
        return;
    }

    
/**
     * gets the "value" attribute of all form elements
     * 
     * @return    array     array of name/value pairs assigned to form elements
     */
    
function getElementValues(){
        
// will not use getElementByName() for performance..
        
$elements =& $this->getElements(true);
        
$count count($elements);
        
$values = array();
        for (
$i 0$i $count$i++) {
            
$name $elements[$i]->getName();
            if (
$name && method_exists($elements[$i], 'getValue')) {
                
$values[$name] =& $elements[$i]->getValue();
            }
        }
        return 
$values;
    }

    
/**
     * set the extra attributes for the <form> tag
     *
     * @param    string  $extra  extra attributes for the <form> tag
     */
    
function setExtra($extra){
        
$this->_extra " ".$extra;
    }

    
/**
     * get the extra attributes for the <form> tag
     *
     * @return    string
     */
    
function &getExtra(){
        if (isset(
$this->_extra)) {
            return 
$this->_extra;
        }
        
$extra null;
        return 
$extra;
    }

    
/**
     * make an element "required"
     *
     * @param    object  &$formElement    reference to a {@link XoopsFormElement}
     */
    
function setRequired(&$formElement){
        
$this->_required[] =& $formElement;
    }

    
/**
     * get an array of "required" form elements
     * 
     * @return    array   array of {@link XoopsFormElement}s 
     */
    
function &getRequired(){
        return 
$this->_required;
    }

    
/**
     * insert a break in the form
     * 
     * This method is abstract. It must be overwritten in the child classes.
     *
     * @param    string  $extra  extra information for the break
     * @abstract
     */
    
function insertBreak($extra null){
    }

    
/**
     * returns renderered form
     *
     * This method is abstract. It must be overwritten in the child classes.
     *
     * @abstract
     */
    
function render(){
    }

    
/**
     * displays rendered form
     */
    
function display(){
        echo 
$this->render();
    }

    
/**
     * Renders the Javascript function needed for client-side for validation
     *
     * Form elements that have been declared "required" and not set will prevent the form from being
     * submitted. Additionally, each element class may provide its own "renderValidationJS" method
     * that is supposed to return custom validation code for the element.
     * 
     * The element validation code can assume that the JS "myform" variable points to the form, and must
     * execute <i>return false</i> if validation fails.
     * 
     * A basic element validation method may contain something like this:
     * <code>
     * function renderValidationJS() {
     *   $name = $this->getName();
     *   return "if ( myform.{$name}.value != 'valid' ) { " .
     *     "myform.{$name}.focus(); window.alert( '$name is invalid' ); return false;" .
     *     " }";
     * }
     * </code>
     * 
     * @param        boolean  $withtags    Include the < javascript > tags in the returned string
     */
    
function renderValidationJS$withtags true ) {
        
$js "";
        if ( 
$withtags ) {
            
$js .= "n<!-- Start Form Validation JavaScript //-->n<script type='text/javascript'>n<!--//n";
        }
        
$myts =& MyTextSanitizer::getInstance();
        
$formname $this->getName();
        
$js .= "function xoopsFormValidate_{$formname}() {
    myform = window.document.
$formname;n";
        
// First, output code to check required elements
        
$elements $this->getRequired();
        foreach ( 
$elements as $elt ) {
            
$eltname    $elt->getName();
            
$eltcaption trim$elt->getCaption() );
            
$eltmsg = empty($eltcaption) ? sprintf_FORM_ENTER$eltname ) : sprintf_FORM_ENTER$eltcaption );
            
$eltmsg str_replace('"''"'stripslashes$eltmsg ) );
            
$js .= "if ( myform.{$eltname}.value == "" ) "
                
"{ window.alert("{$eltmsg}"); myform.{$eltname}.focus(); return false; }n";
        }
        
// Now, handle custom validation code
        
$elements $this->getElementstrue );
        foreach ( 
$elements as $elt ) {
            if ( 
method_exists$elt'renderValidationJS' ) ) {
                if ( 
$eltjs $elt->renderValidationJS() ) {
                    
$js .= $eltjs "n";
                }
            }
        }
        
$js .= "return true;n}n";
        if ( 
$withtags ) {
            
$js .= "//--></script>n<!-- End Form Vaidation JavaScript //-->n";
        }
        return 
$js;
    }
    
/**
     * assign to smarty form template instead of displaying directly
     *
     * @param    object  &$tpl    reference to a {@link Smarty} object
     * @see     Smarty
     */
    
function assign(&$tpl){
        
$i 0;
        
$elements = array();
        foreach ( 
$this->getElements() as $ele ) {
            
$n = ($ele->getName() != "") ? $ele->getName() : $i;
            
$elements[$n]['name']      = $ele->getName();
            
$elements[$n]['caption']  = $ele->getCaption();
            
$elements[$n]['body']      = $ele->render();
            
$elements[$n]['hidden']      = $ele->isHidden();
            if (
$ele->getDescription() != '') {
                
$elements[$n]['description']  = $ele->getDescription();
            }
            
$i++;
        }
        
$js $this->renderValidationJS();
        
$tpl->assign($this->getName(), array('title' => $this->getTitle(), 'name' => $this->getName(), 'action' => $this->getAction(),  'method' => $this->getMethod(), 'extra' => 'onsubmit="return xoopsFormValidate_'.$this->getName().'();"'.$this->getExtra(), 'javascript' => $js'elements' => $elements));
    }
}
?>

22
nznewbie
Re: Youtube HotLink Gallery
  • 2007/8/14 4:16

  • nznewbie

  • Just popping in

  • Posts: 11

  • Since: 2007/8/3 2


i just updated form.php with the code u posted - my video management appeared and i just posted my first youtube movie.

looks great so far :)

thank you for your patients and time ron it is very much appreciated.

23
elbeer
Re: Youtube HotLink Gallery
  • 2007/9/3 13:50

  • elbeer

  • Just popping in

  • Posts: 68

  • Since: 2007/8/26


OK i have intalled this mod. It works fine apart from users can not submit any videos.

I have treble checked the permissions and the group settings but now avail.

The submit file works because admins can upload.

24
McDonald
Re: Youtube HotLink Gallery
  • 2007/9/3 14:49

  • McDonald

  • Home away from home

  • Posts: 1072

  • Since: 2005/8/15


First you have to create categories and set the permissions for each category.
There's a permission to give registered users the possibility to submit a video. Anonymous users can't for some reason. The only thing they can't do is uploading a screenshot of the video.

25
jayjay
Re: Youtube HotLink Gallery
  • 2007/9/5 10:32

  • jayjay

  • Not too shy to talk

  • Posts: 175

  • Since: 2003/9/10


Hi MacDo!

I like the look of your module, but I have an issue. I'm trying to embed a movie but when I use the original youtube code, I see two clips and some html code on my singlevideo.php page.

Edit:
Nevermind. I figured it out already. You only need to fill in the video id, eg. y7x7z0LDMRM in the upload form

This is the code:
<object width="425" height="350"><param name="movie" value="http://www.youtube.com/v/y7x7z0LDMRM"></param><embed src="http://www.youtube.com/v/y7x7z0LDMRM" type="application/x-shockwave-flash" width="425" height="350"></embed></object>


Do I only need to fill in part of the embed code?

I also have a suggestion: why not automatically import (or link to) the youtube thumbnail of a video?

This is the link structure:

video url
http://www.youtube.com/v/y7x7z0LDMRM

thumb urls
http://img.youtube.com/vi/y7x7z0LDMRM/1.jpg
http://img.youtube.com/vi/y7x7z0LDMRM/2.jpg
http://img.youtube.com/vi/y7x7z0LDMRM/3.jpg

Maybe you could add a function to automatically import one of these thumbnails?

26
elbeer
Re: Youtube HotLink Gallery
  • 2007/9/5 10:45

  • elbeer

  • Just popping in

  • Posts: 68

  • Since: 2007/8/26


Quote:

McDonald wrote:
First you have to create categories and set the permissions for each category.
There's a permission to give registered users the possibility to submit a video. Anonymous users can't for some reason. The only thing they can't do is uploading a screenshot of the video.


Tried that - how can i remove the permissions from the submit.php form

My users are not stored in registered user group but in another different named one.

27
McDonald
Re: Youtube HotLink Gallery
  • 2007/9/5 10:55

  • McDonald

  • Home away from home

  • Posts: 1072

  • Since: 2005/8/15


@jayjay,

Hello jayjay,

The only code you have to enter is the red part in the example below.

http://www.youtube.com/watch?v=[b][color=CC0000]dsym78V22v8[/color][/b]




@elbeer,

The module XoopsTube is based on WF-Links 1.03b (or c I am not sure).
It might be that I made a typo somewhere when changing the constants.
At the moment I have no time to like at the problem, because I've to go back to work for the next 4 weeks. Maybe I will have a look at it in October.
You can try to solve it yourself by comparing the code of WF-Links with the code of XoopsTube.

28
jayjay
Re: Youtube HotLink Gallery
  • 2007/9/5 11:14

  • jayjay

  • Not too shy to talk

  • Posts: 175

  • Since: 2003/9/10


@MacDo
I figured it out right after posting and I edited my post immediately

What about my suggestion? Would it be possible to link to the youtube screenshot automatically? Considering the easy link, I don't think it would be too difficult?

Another suggestion: Why not show the thumbnail in the recent and top blocks?

I'm looking into these things. Will keep you posted.

29
McDonald
Re: Youtube HotLink Gallery
  • 2007/9/5 11:38

  • McDonald

  • Home away from home

  • Posts: 1072

  • Since: 2005/8/15


Linking directly is not a problem, because the code of a videoclip is used for the thumbnail too.
I am only wondering if it works for all thumbs because not all thumbs I've seen have the same dimensions (120x90pixels).
On the positive site I think it will tell you when a videoclip doesn't exsist anymore on YouTube because the thumb will be gone too.

You might try the following. Find this code in videoload.html
<img src="<{$video.screenshot_thumb}>" alt="<{$video.title}>" hspace="7" vspace="3" border="0" align="left" />


and replace it with this one:
<img src="http://img.youtube.com/vi/<{$video.url}>/default.jpg" alt="<{$video.title}>" width="120" height="90" hspace="7" vspace="3" border="0" align="left" />


I haven't tested this yet, it's just a rough guess.

30
jayjay
Re: Youtube HotLink Gallery
  • 2007/9/5 11:52

  • jayjay

  • Not too shy to talk

  • Posts: 175

  • Since: 2003/9/10


Quote:

McDonald wrote:
You might try the following. Find this code in videoload.html
<img src="<{$video.screenshot_thumb}>" alt="<{$video.title}>" hspace="7" vspace="3" border="0" align="left" />


and replace it with this one:
<img src="http://img.youtube.com/vi/<{$video.url}>/default.jpg" alt="<{$video.title}>" width="120" height="90" hspace="7" vspace="3" border="0" align="left" />


I haven't tested this yet, it's just a rough guess.


That's a very elegant solution, and it works! You will also have to remove this to make it work though:
[d]<{if $show_screenshot == true}> <{if $video.screenshot_full != ''}>[/d]
IMAGE
[d]<{/if}><{/if}>[/d]

Login

Who's Online

231 user(s) are online (126 user(s) are browsing Support Forums)


Members: 0


Guests: 231


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Mar 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits