21
trabis
Re: Xoops 2.5.x Functions
  • 2011/11/22 13:49

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


Quote:
The problem is that if you use a file created by me in language/italian/homepage.php taken by the function: xoops_loadLanguage('homepage'); does not work, only if I use the main.php of theme, it works


What do you mean with main.php of theme?

xoops_loadLanguage('homepage') should include file xoopsroot/language/italian/homepage.php

xoops_loadLanguage('homepage', 'xnews') should include file xoopsroot/modules/xnews/language/italian/homepage.php

don't forget to read this, you may have missed it:
https://xoops.org/modules/newbb/viewtopic.php?post_id=342677#forumpost342677

22
timgno
Re: Xoops 2.5.x Functions
  • 2011/11/22 13:58

  • timgno

  • Module Developer

  • Posts: 1504

  • Since: 2007/6/21


Quote:

trabis wrote:
What do you mean with main.php of theme?


xoopsroot/themes/mytheme/language/italian/main.php

This course takes from xoops_loadLanguage('main'); in xoopsroot/index.php

23
trabis
Re: Xoops 2.5.x Functions
  • 2011/11/22 14:05

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


Quote:

timgno wrote:

xoopsroot/themes/mytheme/language/italian/main.php

This course takes from xoops_loadLanguage('main'); in xoopsroot/index.php


no no, only main.php is loaded from themes. and it is not loaded with xoops_loadLanguage(), it is loaded internally by the theme class.

In 2.6.0 you will be able to load any file from theme folder.

24
timgno
Re: Xoops 2.5.x Functions
  • 2011/11/22 14:37

  • timgno

  • Module Developer

  • Posts: 1504

  • Since: 2007/6/21


The question is this:

If I take the information from the database of such news, I'm forced to use the way of the modules?
It would be better by the core to give me the ability to access, with any php file directly to the database with a general instance?

25
timgno
Re: Xoops 2.5.x Functions
  • 2011/11/22 15:27

  • timgno

  • Module Developer

  • Posts: 1504

  • Since: 2007/6/21


@trabis
The initVar() and assignVar() are already defined in XoopsObject, why I have to redefine them in nw_stories?

26
timgno
Re: Xoops 2.5.x Functions
  • 2011/11/22 16:16

  • timgno

  • Module Developer

  • Posts: 1504

  • Since: 2007/6/21


Ok!

Now the code for the objects in this class is:

include_once XOOPS_ROOT_PATH.'/class/xoopsstory.php';
include_once 
XOOPS_ROOT_PATH.'/include/comment_constants.php';
include_once 
NW_MODULE_PATH '/include/functions.php';

class 
Nw_NewsStory extends XoopsObject
{
    var 
$newstopic;       // XoopsTopic object
    
var $rating;        // news rating
      
var $votes;            // Number of votes
      
var $description;    // META, desciption
      
var $keywords;        // META, keywords
      
var $picture;
      var 
$topic_imgurl;
      var 
$topic_title;
    var 
$tags;
    
//var $imagerows;
    //var $pdfrows;

    // Default constructor by Timgno
    
function __construct()
    {
        
$this->XoopsObject();
        
$this->initVar("storyid",XOBJ_DTYPE_INT,null,false,8);
        
$this->initVar("uid",XOBJ_DTYPE_INT,null,false,5);
        
$this->initVar("title",XOBJ_DTYPE_TXTBOX,null,false);
        
$this->initVar("created",XOBJ_DTYPE_INTnullfalse,10);
        
$this->initVar("published",XOBJ_DTYPE_INT,null,false,10);
        
$this->initVar("expired",XOBJ_DTYPE_INT,null,false,10);
        
$this->initVar("hostname",XOBJ_DTYPE_TXTBOX,null,false);
        
$this->initVar("nohtml",XOBJ_DTYPE_INT,null,false,1);
        
$this->initVar("nosmiley",XOBJ_DTYPE_TXTBOX,null,false,1);
        
$this->initVar("hometext",XOBJ_DTYPE_TXTAREAnullfalse);
        
$this->initVar("bodytext",XOBJ_DTYPE_TXTAREAnullfalse);
        
$this->initVar("keywords",XOBJ_DTYPE_TXTBOX,null,false);
        
$this->initVar("description",XOBJ_DTYPE_TXTBOX,null,false);
        
$this->initVar("counter",XOBJ_DTYPE_INT,null,false,8);
        
$this->initVar("topicid",XOBJ_DTYPE_INT,null,false,4);
        
$this->initVar("ihome",XOBJ_DTYPE_INTnullfalse,1);
        
$this->initVar("notifypub",XOBJ_DTYPE_INT,null,false,1);
        
$this->initVar("story_type",XOBJ_DTYPE_TXTBOX,null,false);
        
$this->initVar("topicdisplay",XOBJ_DTYPE_INT,null,false,1);
        
$this->initVar("topicalign",XOBJ_DTYPE_TXTBOX,null,false);
        
$this->initVar("comments",XOBJ_DTYPE_INT,null,false,5);
        
$this->initVar("rating",XOBJ_DTYPE_DECIMALnullfalse,10);
        
$this->initVar("votes",XOBJ_DTYPE_INT,null,false,11);
        
$this->initVar("picture",XOBJ_DTYPE_TXTBOX,null,false);
        
$this->initVar("dobr",XOBJ_DTYPE_INT,null,false,1);
        
$this->initVar("tags",XOBJ_DTYPE_TXTBOX,null,false);
        
$this->initVar("imagerows",XOBJ_DTYPE_INT,null,false,4);
        
$this->initVar("pdfrows",XOBJ_DTYPE_INTnullfalse,4);    
    }
    
    
/**
     * Constructor
     */
    
function Nw_NewsStory($storyid=-1)
    {
        
$this->__construct(); // by Timgno
        
$this->db =& Database::getInstance();
        
$this->table $this->db->prefix('nw_stories');
        
$this->topicstable $this->db->prefix('nw_topics');
        if (
is_array($storyid)) {
            
$this->makeStory($storyid);
        } elseif(
$storyid != -1) {
            
$this->getStory(intval($storyid));
        }
    }

....


ed il mio codice per prelevare è:

include_once $GLOBALS['xoops']->path('modules/xnews/class/class.newstopic.php');
//include_once $GLOBALS['xoops']->path('modules/xnews/class/class.newsstory.php');
include_once $GLOBALS['xoops']->path('modules/xnews/class/nw_stories.php');
include_once 
$GLOBALS['xoops']->path('include/functions.php');

/**************************** Variables for module xnews *************************/
$nw_storiesHandler =& xoops_getModuleHandler('nw_stories''xnews');
//$nw_storiesHandler = new Nw_NewsStory();
$criteria = new CriteriaCompo();
$criteria->setSort("storyid");
$criteria->setOrder("DESC");
$nwrows $nw_storiesHandler->getCount();
if (isset(
$_REQUEST['limit'])) {
     
$criteria->setLimit($_REQUEST['limit']);
     
$limit $_REQUEST['limit'];
    
//$GLOBALS['xoopsTpl']->assign('xnews_limit', $limit);     

$nw_stories_arr $nw_storiesHandler->getAll($criteria);
if (
$nwrows>0)
{
    foreach (
array_keys($nw_stories_arr) as $i)
    {
         
$xnews_title $nw_stories_arr[$i]->getVar("title");
         
$xnews_description $nw_stories_arr[$i]->getVar("description");
         
$xnews_picture $nw_stories_arr[$i]->getVar("picture");
         
$GLOBALS['xoopsTpl']->append('last_news', array('title' => $xnews_title
                                                         
'description' => $xnews_description,'picture' => $xnews_picture));
    }
}


no positive results.

P.S: The object of type decimal, what value should it have?

27
trabis
Re: Xoops 2.5.x Functions
  • 2011/11/22 18:50

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


Quote:

timgno wrote:
Ok!

Now the code for the objects in this class is:

include_once XOOPS_ROOT_PATH.'/class/xoopsstory.php';
include_once 
XOOPS_ROOT_PATH.'/include/comment_constants.php';
include_once 
NW_MODULE_PATH '/include/functions.php';

class 
Nw_NewsStory extends XoopsObject
{
    var 
$newstopic;       // XoopsTopic object
    
var $rating;        // news rating
      
var $votes;            // Number of votes
      
var $description;    // META, desciption
      
var $keywords;        // META, keywords
      
var $picture;
      var 
$topic_imgurl;
      var 
$topic_title;
    var 
$tags;
    
//var $imagerows;
    //var $pdfrows;

    // Default constructor by Timgno
    
function __construct()
    {
        
$this->XoopsObject();
        
$this->initVar("storyid",XOBJ_DTYPE_INT,null,false,8);
        
$this->initVar("uid",XOBJ_DTYPE_INT,null,false,5);
        
$this->initVar("title",XOBJ_DTYPE_TXTBOX,null,false);
        
$this->initVar("created",XOBJ_DTYPE_INTnullfalse,10);
        
$this->initVar("published",XOBJ_DTYPE_INT,null,false,10);
        
$this->initVar("expired",XOBJ_DTYPE_INT,null,false,10);
        
$this->initVar("hostname",XOBJ_DTYPE_TXTBOX,null,false);
        
$this->initVar("nohtml",XOBJ_DTYPE_INT,null,false,1);
        
$this->initVar("nosmiley",XOBJ_DTYPE_TXTBOX,null,false,1);
        
$this->initVar("hometext",XOBJ_DTYPE_TXTAREAnullfalse);
        
$this->initVar("bodytext",XOBJ_DTYPE_TXTAREAnullfalse);
        
$this->initVar("keywords",XOBJ_DTYPE_TXTBOX,null,false);
        
$this->initVar("description",XOBJ_DTYPE_TXTBOX,null,false);
        
$this->initVar("counter",XOBJ_DTYPE_INT,null,false,8);
        
$this->initVar("topicid",XOBJ_DTYPE_INT,null,false,4);
        
$this->initVar("ihome",XOBJ_DTYPE_INTnullfalse,1);
        
$this->initVar("notifypub",XOBJ_DTYPE_INT,null,false,1);
        
$this->initVar("story_type",XOBJ_DTYPE_TXTBOX,null,false);
        
$this->initVar("topicdisplay",XOBJ_DTYPE_INT,null,false,1);
        
$this->initVar("topicalign",XOBJ_DTYPE_TXTBOX,null,false);
        
$this->initVar("comments",XOBJ_DTYPE_INT,null,false,5);
        
$this->initVar("rating",XOBJ_DTYPE_DECIMALnullfalse,10);
        
$this->initVar("votes",XOBJ_DTYPE_INT,null,false,11);
        
$this->initVar("picture",XOBJ_DTYPE_TXTBOX,null,false);
        
$this->initVar("dobr",XOBJ_DTYPE_INT,null,false,1);
        
$this->initVar("tags",XOBJ_DTYPE_TXTBOX,null,false);
        
$this->initVar("imagerows",XOBJ_DTYPE_INT,null,false,4);
        
$this->initVar("pdfrows",XOBJ_DTYPE_INTnullfalse,4);    
    }
    
    
/**
     * Constructor
     */
    
function Nw_NewsStory($storyid=-1)
    {
        
$this->__construct(); // by Timgno
        
$this->db =& Database::getInstance();
        
$this->table $this->db->prefix('nw_stories');
        
$this->topicstable $this->db->prefix('nw_topics');
        if (
is_array($storyid)) {
            
$this->makeStory($storyid);
        } elseif(
$storyid != -1) {
            
$this->getStory(intval($storyid));
        }
    }

....


ed il mio codice per prelevare è:

include_once $GLOBALS['xoops']->path('modules/xnews/class/class.newstopic.php');
//include_once $GLOBALS['xoops']->path('modules/xnews/class/class.newsstory.php');
include_once $GLOBALS['xoops']->path('modules/xnews/class/nw_stories.php');
include_once 
$GLOBALS['xoops']->path('include/functions.php');

/**************************** Variables for module xnews *************************/
$nw_storiesHandler =& xoops_getModuleHandler('nw_stories''xnews');
//$nw_storiesHandler = new Nw_NewsStory();
$criteria = new CriteriaCompo();
$criteria->setSort("storyid");
$criteria->setOrder("DESC");
$nwrows $nw_storiesHandler->getCount();
if (isset(
$_REQUEST['limit'])) {
     
$criteria->setLimit($_REQUEST['limit']);
     
$limit $_REQUEST['limit'];
    
//$GLOBALS['xoopsTpl']->assign('xnews_limit', $limit);     

$nw_stories_arr $nw_storiesHandler->getAll($criteria);
if (
$nwrows>0)
{
    foreach (
array_keys($nw_stories_arr) as $i)
    {
         
$xnews_title $nw_stories_arr[$i]->getVar("title");
         
$xnews_description $nw_stories_arr[$i]->getVar("description");
         
$xnews_picture $nw_stories_arr[$i]->getVar("picture");
         
$GLOBALS['xoopsTpl']->append('last_news', array('title' => $xnews_title
                                                         
'description' => $xnews_description,'picture' => $xnews_picture));
    }
}


no positive results.

P.S: The object of type decimal, what value should it have?


You don't have to specify default values, you can use 0 for decimal if you want.

The problem is that you have two constructors in your class, you should merge them like this:

include_once XOOPS_ROOT_PATH.'/class/xoopsstory.php';
include_once 
XOOPS_ROOT_PATH.'/include/comment_constants.php';
include_once 
NW_MODULE_PATH '/include/functions.php';

class 
Nw_NewsStory extends XoopsObject
{
    var 
$newstopic;       // XoopsTopic object
    
var $rating;        // news rating
      
var $votes;            // Number of votes
      
var $description;    // META, desciption
      
var $keywords;        // META, keywords
      
var $picture;
      var 
$topic_imgurl;
      var 
$topic_title;
    var 
$tags;
    
//var $imagerows;
    //var $pdfrows;

    // Default constructor by Timgno
    
function __construct($storyid=-1)
    {
        
//$this->XoopsObject(); don't need this line
        
$this->initVar("storyid",XOBJ_DTYPE_INT,null,false,8);
        
$this->initVar("uid",XOBJ_DTYPE_INT,null,false,5);
        
$this->initVar("title",XOBJ_DTYPE_TXTBOX,null,false);
        
$this->initVar("created",XOBJ_DTYPE_INTnullfalse,10);
        
$this->initVar("published",XOBJ_DTYPE_INT,null,false,10);
        
$this->initVar("expired",XOBJ_DTYPE_INT,null,false,10);
        
$this->initVar("hostname",XOBJ_DTYPE_TXTBOX,null,false);
        
$this->initVar("nohtml",XOBJ_DTYPE_INT,null,false,1);
        
$this->initVar("nosmiley",XOBJ_DTYPE_TXTBOX,null,false,1);
        
$this->initVar("hometext",XOBJ_DTYPE_TXTAREAnullfalse);
        
$this->initVar("bodytext",XOBJ_DTYPE_TXTAREAnullfalse);
        
$this->initVar("keywords",XOBJ_DTYPE_TXTBOX,null,false);
        
$this->initVar("description",XOBJ_DTYPE_TXTBOX,null,false);
        
$this->initVar("counter",XOBJ_DTYPE_INT,null,false,8);
        
$this->initVar("topicid",XOBJ_DTYPE_INT,null,false,4);
        
$this->initVar("ihome",XOBJ_DTYPE_INTnullfalse,1);
        
$this->initVar("notifypub",XOBJ_DTYPE_INT,null,false,1);
        
$this->initVar("story_type",XOBJ_DTYPE_TXTBOX,null,false);
        
$this->initVar("topicdisplay",XOBJ_DTYPE_INT,null,false,1);
        
$this->initVar("topicalign",XOBJ_DTYPE_TXTBOX,null,false);
        
$this->initVar("comments",XOBJ_DTYPE_INT,null,false,5);
        
$this->initVar("rating",XOBJ_DTYPE_DECIMALnullfalse,10);
        
$this->initVar("votes",XOBJ_DTYPE_INT,null,false,11);
        
$this->initVar("picture",XOBJ_DTYPE_TXTBOX,null,false);
        
$this->initVar("dobr",XOBJ_DTYPE_INT,null,false,1);
                
$this->initVar("tags",XOBJ_DTYPE_TXTBOX,null,false);
                
$this->initVar("imagerows",XOBJ_DTYPE_INT,null,false,4);
                
$this->initVar("pdfrows",XOBJ_DTYPE_INTnullfalse,4);    
   
        
$this->db =& Database::getInstance();
        
$this->table $this->db->prefix('nw_stories');
        
$this->topicstable $this->db->prefix('nw_topics');
        if (
is_array($storyid)) {
            
$this->makeStory($storyid);
        } elseif(
$storyid != -1) {
            
$this->getStory(intval($storyid));
        }
        }

    

....

28
timgno
Re: Xoops 2.5.x Functions
  • 2011/11/25 19:46

  • timgno

  • Module Developer

  • Posts: 1504

  • Since: 2007/6/21


With regard to the functions in XoopsStory, what would you suggest we do best to not repeat the same work twice?

Since different classes have been canceled in xoops 2.6.0, how to integrate the functions: nohtml, nosmiley, notifypub, etc.???

29
trabis
Re: Xoops 2.5.x Functions
  • 2011/11/25 22:55

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


Quote:

timgno wrote:
With regard to the functions in XoopsStory, what would you suggest we do best to not repeat the same work twice?

You have other modules using this class? Many core files have hard coded support for news module(backend.php, xmlrpc.php, class/xml). We need to move this classes out of core, as they belong to news module.

Quote:

Since different classes have been canceled in xoops 2.6.0, how to integrate the functions: nohtml, nosmiley, notifypub, etc.???


You need to init those vars also.
Even if they are not used for db save/update, they can/will be used by the parent object class for vars of type XOBJ_DTYPE_TXTAREA (for calling textsanitizer correctly).

I plan to work in the news module conversion at a latter stage.

30
timgno
Re: Xoops 2.5.x Functions
  • 2011/11/25 22:59

  • timgno

  • Module Developer

  • Posts: 1504

  • Since: 2007/6/21


I'm converting the AMS module, and it is hard work

Login

Who's Online

279 user(s) are online (182 user(s) are browsing Support Forums)


Members: 0


Guests: 279


more...

Donat-O-Meter

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

Latest GitHub Commits