1
McDonald
Problem with Tag module and XoopsTube
  • 2007/12/9 23:52

  • McDonald

  • Home away from home

  • Posts: 1072

  • Since: 2005/8/15


At the moment I try to add functionalities from the Tag module to XoopsTube.
I've added these lines to admin/index.php which cause the keywords to be added to the Tag module tables:

// Add keywords to Tag-module
        
if (xtube_tag_module_included()) {
        include_once 
XOOPS_ROOT_PATH."/modules/tag/include/formtag.php";
        
$tag_handler xoops_getmodulehandler('tag''tag');
        
$tag_handler -> updateByItem($_POST['keywords'], $lid$xoopsModule -> getVar('dirname'), $catid =0);
        }


The keywords cq. tags appear in the Tag Cloud block.
When I click on a tag in this block I get the following error:

Error: Handler does not exist
Module: xoopstube
Name: xoopstube in file /include/functions.php line 551

In the folder include I've created the file plugin.tag.php :

<?php
/**
 * Tag info
 *
 * @copyright    The XOOPS project https://xoops.org/
 * @license        http://www.fsf.org/copyleft/gpl.html GNU public license
 * @author        Taiwen Jiang (phppp or D.J.) <php_pp@hotmail.com>
 * @since        1.00
 * @version        $Id$
 * @package        module::tag
 */

if (!defined("XOOPS_ROOT_PATH")) {
    die(
"XOOPS root path not defined");
}

/**
 * Get item fields:
 * title
 * content
 * time
 * link
 * uid
 * uname
 * tags
 *
 * @var        array    $items    associative array of items: [modid][catid][itemid]
 *
 * @return    boolean
 * 
 */
function xoopstube_tag_iteminfo(&$items)
{
    
$items_id = array();
    foreach(
array_keys($items) as $cat_id){
        
// Some handling here to build the link upon catid
            // if catid is not used, just skip it
        
foreach(array_keys($items[$cat_id]) as $item_id){
            
// In article, the item_id is "art_id"
            
$items_id[] = intval($item_id);
        }
    }
    
$item_handler =& xoops_getModuleHandler("xoopstube","xoopstube");
    
$items_obj $item_handler -> getObjects(new Criteria("lid""(".implode(", "$items_id).")""IN"), true);
    
    foreach(
array_keys($items) as $cat_id){
        foreach(
array_keys($items[$cat_id]) as $item_id){
            
$item_obj =& $items_obj[$item_id];
            
$items[$cat_id][$item_id] = array(
                
"title"        => $item_obj -> getVar("title"),
                
"uid"        => $item_obj -> getVar("submitter"),
                
"link"        => "singlevideo.php?lid={$item_id}",
                
"time"        => $item_obj -> getVar("date"),
                
"tags"        => tag_parse_tag($item_obj -> getVar("keywords""n")),
                
"content"    => "",
                );
        }
    }
    unset(
$items_obj);    
}

function 
xoopstube_tag_synchronization($mid)
{
  
// optional
}
?>


I assume the error is caused by

$item_handler =& xoops_getModuleHandler("xoopstube","xoopstube");

but I don't know how to fix this.


Anybody who can help me with this??


TIA!

McDonald

2
trabis
Re: Problem with Tag module and XoopsTube
  • 2007/12/10 1:29

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


Sorry McDonald but you won´t get it that easly. I have browsed you youtube module and did not find a class named xoopstube so

xoops_getModuleHandler("xoopstube","xoopstube");

wont find xoopstube handler in you xoopstube class folder.

You will need to build a class that have getobject() and getvar() to populate the required info so the above code could work. :(

Otherwise you will have to find a way to do it inside that function
example:

function xoopstube_tag_iteminfo(&$items)
{
    
$items_id = array();
    foreach(
array_keys($items) as $cat_id){
        
// Some handling here to build the link upon catid
            // if catid is not used, just skip it
        
foreach(array_keys($items[$cat_id]) as $item_id){
            
// In article, the item_id is "art_id"
            
$items_id[] = intval($item_id);
        }
    }
    
//$item_handler =& xoops_getModuleHandler("xoopstube","xoopstube");
    //$items_obj = $item_handler -> getObjects(new Criteria("lid", "(".implode(", ", $items_id).")", "IN"), true);
    
    
foreach(array_keys($items) as $cat_id){
        foreach(
array_keys($items[$cat_id]) as $item_id){
            
//$item_obj =& $items_obj[$item_id];
          //Do your querie here to get video info based on $item_id as the video id 
            
$items[$cat_id][$item_id] = array(
                
"title"        => $row['title'],
                
"uid"        => $row['submitter'],
                
blablablablablabla

3
trabis
Re: Problem with Tag module and XoopsTube
  • 2007/12/10 21:55

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


Here is more info about it poste on the wiki!

https://xoops.org/modules/mediawiki/index.php?title=Dev:using_xoops_api&curid=361&oldid=738

4
McDonald
Re: Problem with Tag module and XoopsTube
  • 2007/12/10 23:35

  • McDonald

  • Home away from home

  • Posts: 1072

  • Since: 2005/8/15


Thanks for the replies Trabis.

I will try to make an extra class for in XoopsTube for the Tag-module.

5
McDonald
Re: Problem with Tag module and XoopsTube
  • 2007/12/23 22:39

  • McDonald

  • Home away from home

  • Posts: 1072

  • Since: 2005/8/15


Is there another way to create the tag plugin (plugin.tag.php)?
One that does not rely on an existing class.

Something like the plugins for the RSS module from Brandycoke.

This is the example plugin.tag.php as it comes with tag module:
<?php
/**
 * Tag management for XOOPS
 *
 * @copyright    The XOOPS project https://xoops.org/
 * @license        http://www.fsf.org/copyleft/gpl.html GNU public license
 * @author        Taiwen Jiang (phppp or D.J.) <php_pp@hotmail.com>
 * @since        1.10
 * @version        $Id$
 * @package        module::tag
 */
 
/*
This module provides a centralized toolkit including input, display, stats and substantial more comprehensive applications, so that each module does not need to develop its own tag handling scripts.

Check http://en.wikipedia.org/wiki/Tags for more info about "tag"
*/

/*
terms:
itemid:        unique ID of the object to which the tag belonging, for instance topic_id for newbb topic, art_id for article article;
modid:        module ID of the object
catid:        extra parameter to identify an object. Only useful when you have more than one types of objects in the same module, for instance in a gallery module, type #1 tags are for images, type #2 tags for albums: (IDofImage, mid, catid=1), (IDofAlbum, mid, catid=2)
*/

/*
To enable tag for a module ("mymodule"), following steps are need:
1 add tag input box to your item edit form (required)
2 add tag storage to your item submission page (required)
3 define functions to build info of tagged items (required)
4 add tag display API to your item display page and include tag template in your item template (optional)
5 add module tag view page and tag list page (optional)
6 add module tag blocks (optional) 
*/

/* Step 1: add tag input box */
// File: edit.item.php
$itemid $item_obj->isNew() ? $item_obj->getVar("itemid");
include_once 
XOOPS_ROOT_PATH."/modules/tag/include/formtag.php";
$form_item->addElement(new XoopsFormTag("item_tag"60255$itemid$catid 0));

/* Step 2: add tag storage after item storage */
// File: submit.item.php
$tag_handler xoops_getmodulehandler('tag''tag');
$tag_handler->updateByItem($_POST["item_tag"], $itemid$xoopsModule->getVar("dirname"), $catid =0);

/* Step 3: define functions to build info of tagged items */
// File: /modules/tag/plugin/mymodule.php OR /modules/mymodule/include/plugin.tag.php
/** Get item fields: title, content, time, link, uid, uname, tags **/
function mymodule_tag_iteminfo(&$items)
{
    
$items_id = array();
    foreach(
array_keys($items) as $cat_id){
        
// Some handling here to build the link upon catid
            // If catid is not used, just skip it
        
foreach(array_keys($items[$cat_id]) as $item_id){
            
// In article, the item_id is "art_id"
            
$items_id[] = intval($item_id);
        }
    }
    
$item_handler =& xoops_getmodulehandler("item""module");
    
$items_obj $item_handler->getObjects(new Criteria("itemid""(".implode(", "$items_id).")""IN"), true);
    
    foreach(
array_keys($items) as $cat_id){
        foreach(
array_keys($items[$cat_id]) as $item_id){
            
$item_obj =& $items_obj[$item_id];
            
$items[$cat_id][$item_id] = array(
                
"title"        => $item_obj->getVar("item_title"),
                
"uid"        => $item_obj->getVar("uid"),
                
"link"        => "view.item.php?itemid={$item_id}",
                
"time"        => $item_obj->getVar("item_time"),
                
"tags"        => tag_parse_tag($item_obj->getVar("item_tags""n")), // optional
                
"content"    => "",
                );
        }
    }
    unset(
$items_obj);    
}
/** Remove orphan tag-item links **/
function mymodule_tag_synchronization($mid
{
    
// Optional
}


/* Step 4: Display tags on our tiem page */
// File: view.item.php
include_once XOOPS_ROOT_PATH."/modules/tag/include/tagbar.php";
$xoopsTpl->assign('tagbar'tagBar($itemid$catid 0));
// File: mymodule_item_template.html
<{include file="db:tag_bar.html"}>

/* Step 5: create tag list page and tag view page */
// File: list.tag.php
include "header.php";
include 
XOOPS_ROOT_PATH."/modules/tag/list.tag.php";
// File: view.tag.php
include "header.php";
include 
XOOPS_ROOT_PATH."/modules/tag/view.tag.php";

/* Step 6: create tag blocks */
// File: xoops_version.php
/*
 * $options:  
 *                    $options[0] - number of tags to display
 *                    $options[1] - time duration, in days, 0 for all the time
 *                    $options[2] - max font size (px or %)
 *                    $options[3] - min font size (px or %)
 */
$modversion["blocks"][]    = array(
    
"file"            => "mymodule_block_tag.php",
    
"name"            => "Module Tag Cloud",
    
"description"    => "Show tag cloud",
    
"show_func"        => "mymodule_tag_block_cloud_show",
    
"edit_func"        => "mymodule_tag_block_cloud_edit",
    
"options"        => "100|0|150|80",
    
"template"        => "mymodule_tag_block_cloud.html",
    );
/*
 * $options:  
 *                    $options[0] - number of tags to display
 *                    $options[1] - time duration, in days, 0 for all the time
 *                    $options[2] - sort: a - alphabet; c - count; t - time
 */
$modversion["blocks"][]    = array(
    
"file"            => "mymodule_block_tag.php",
    
"name"            => "Module Top Tags",
    
"description"    => "Show top tags",
    
"show_func"        => "mymodule_tag_block_top_show",
    
"edit_func"        => "mymodule_tag_block_top_edit",
    
"options"        => "50|30|c",
    
"template"        => "mymodule_tag_block_top.html",
    );
// File: module_block_tag.php
function mymodule_tag_block_cloud_show($options
{
    include_once 
XOOPS_ROOT_PATH."/modules/tag/blocks/block.php";
    return 
tag_block_cloud_show($options$module_dirname);
}
function 
mymodule_tag_block_cloud_edit($options
{
    include_once 
XOOPS_ROOT_PATH."/modules/tag/blocks/block.php";
    return 
tag_block_cloud_edit($options);
}
function 
mymodule_tag_block_top_show($options
{
    include_once 
XOOPS_ROOT_PATH."/modules/tag/blocks/block.php";
    return 
tag_block_top_show($options$module_dirname);
}
function 
mymodule_tag_block_top_edit($options
{
    include_once 
XOOPS_ROOT_PATH."/modules/tag/blocks/block.php";
    return 
tag_block_top_edit($options);
}
// File: mymodule_tag_block_cloud.html
<{include file="db:tag_block_cloud.html"}>
// File: mymodule_tag_block_top.html
<{include file="db:tag_block_top.html"}>

/* Over */
?>


And this is a RSS plugin:
<?php
/*
* About this RSSFit plug-in
*
* Author :
*   DuGris - http://www.dugris.info

* Modified by :
*   McDonald
*
* Requirements:
*   Module : RSSFit  - http://www.brandycoke.com
*   verision : 1.20
*
*   Module : XoopsTube - http://members.lycos.nl/mcdonaldsstore
*   Version : 1.0.1
*/ 

if( !defined('RSSFIT_ROOT_PATH') ){ exit(); }
class 
RssfitXoopstube{
    var 
$dirname 'xoopstube';
    var 
$modname;
        var 
$mid;
    var 
$grab;

    function 
RssfitXoopstube(){
    }

    function 
loadModule(){
        global 
$module_handler;
        
$mod $module_handler->getByDirname($this->dirname);
        if( !
$mod || !$mod->getVar('isactive') ){
            return 
false;
        }
        
$this->modname $mod->getVar('name');
        
$this->mid $mod->getVar('mid');
        return 
$mod;
    }

    function 
grabEntries(&$obj){
        global 
$xoopsDB$xoopsUser;

        
$groups is_object$xoopsUser ) ? $xoopsUser -> getGroups() : XOOPS_GROUP_ANONYMOUS;
        
$gperm_handler = &xoops_gethandler'groupperm' );

        
$myts =& MyTextSanitizer::getInstance();
        
$ret = array();
        
$i 0;
        
$sql "SELECT lid, cid, title, url, date, description FROM ".$xoopsDB->prefix('xoopstube_videos')." WHERE status>0 ORDER BY date DESC";
        
$result $xoopsDB->query($sql$this->grab0);
        while( 
$row $xoopsDB->fetchArray($result) ){
            if ( 
$gperm_handler -> checkRight'XTubeCatPerm'$row['cid'], $groups$this->mid ) ) {
            
//    required
                
$ret[$i]['title'] = $row['title'];
                
$ret[$i]['link'] = $ret[$i]['guid'] = XOOPS_URL '/modules/xoopstube/singlevideo.php?cid=' $row['cid'] . '&lid=' $row['lid'];
                
$ret[$i]['timestamp'] = $row['date'];
                
$ret[$i]['description'] = $row['description'];
            
//    optional
                
$ret[$i]['category'] = $this->modname;
                
$ret[$i]['domain'] = XOOPS_URL.'/modules/'.$this->dirname.'/';
                
$i++;
            }
        }
        return 
$ret;
    }
}
?>


If not, I'll skip the support for the tag module.

Thanks!

6
trabis
Re: Problem with Tag module and XoopsTube
  • 2007/12/24 1:39

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


Hello,
I did not tested it but you can try something like this:
function news_tag_iteminfo(&$items)
{
    if(empty(
$items) || !is_array($items)){
        return 
false;
    }

    global 
$xoopsDB;
    
$myts =& MyTextSanitizer::getInstance();

    
$items_id = array();

    foreach(
array_keys($items) as $cat_id){
        
// Some handling here to build the link upon catid
            // If catid is not used, just skip it
        
foreach(array_keys($items[$cat_id]) as $item_id){
            
// In article, the item_id is "art_id"
            
$items_id[] = intval($item_id);
        }
    }

    foreach(
array_keys($items) as $cat_id){
        foreach(
array_keys($items[$cat_id]) as $item_id){
            
$sql "SELECT l.lid, l.title as ltitle, l.date, l.cid, l.submitter, l.screenshot, l.hits, l.comments, l.description, c.title as ctitle FROM ".$xoopsDB->prefix("xoopstube_videos")." l, ".$xoopsDB->prefix("xoopstube_cat")." c WHERE l.lid=".$itemid." AND l.cid=c.cid AND l.status>0 ORDER BY l.date DESC";
            
$result $xoopsDB->query($sql);
            
$row $xoopsDB->fetchArray($result);
            
$items[$cat_id][$item_id] = array(
                
"title"        => $row['ltitle'],
                
"uid"        => $row['submitter'],
                
"link"        => "singlevideo.php?lid=$item_id",
                
"time"        => $row['date'],
                
//"tags"        => tag_parse_tag($item_obj->getVar("item_tags", "n")), // optional
                
"content"    => $myts->makeTareaData4Show$row['description'], ),
            );
        }
    }

}

7
McDonald
Re: Problem with Tag module and XoopsTube
  • 2007/12/24 2:32

  • McDonald

  • Home away from home

  • Posts: 1072

  • Since: 2005/8/15


Thanks trabis!

This works almost. It needs some tuning I think.
Wil have a closer look at this code after xmas.

Thanks you very much!!

Resized Image

8
McDonald
Re: Problem with Tag module and XoopsTube
  • 2007/12/31 2:02

  • McDonald

  • Home away from home

  • Posts: 1072

  • Since: 2005/8/15


So far I have the tag-function working in XoopsTube. The keywords are not used for this, but a seperate input field has be added to the submit form (admin side only).
It's possible to have the tags displayed in single video display, but the tag-links don't work. Same when creating a tag cloud block in XoopsTube.
As long as the Tag module itself is used everything seems to work. See here (tag cloud is in the left column at the bottom).

Also new icons and support for SPIKE/iFilm and Photobucket have been added. Google Video and MySpaceTV have been added also but disabled because there's no relation between the video id-code and the screenshot (thumb) + publisher url.

9
noo-b
Re: Problem with Tag module and XoopsTube
  • 2007/12/31 3:40

  • noo-b

  • Just can't stay away

  • Posts: 456

  • Since: 2007/10/23


great...would be nice if the keywords are use as the tag...
and make it as a required field

most user are lazy to input to many fields...like in my site...i have the auto approve disable and most of the time user didn't enter a single keyword in the video submission..i have to enter the keyword by myself
I Love Xoops

10
McDonald
Re: Problem with Tag module and XoopsTube
  • 2007/12/31 10:04

  • McDonald

  • Home away from home

  • Posts: 1072

  • Since: 2005/8/15


Using the keywords as tags didn't seem to be very practical.
I've implemented the tags in the submit form at admin side only.

If you would like to force users to enter the keywords then find the following lines in submit.php and change false into true:
// Meta keywords form
        
$sform -> addElement( new XoopsFormText_MD_XTUBE_KEYWORDS'keywords'70128$keywords ), false);
        
$sform -> insertBreaksprintf_MD_XTUBE_KEYWORDS_NOTE ), "even" );

Login

Who's Online

200 user(s) are online (138 user(s) are browsing Support Forums)


Members: 0


Guests: 200


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