XOOPS  2.6.0
AbstractHelper.php
Go to the documentation of this file.
1 <?php
2 /*
3  You may not change or alter any portion of this comment or credits
4  of supporting developers from this source code or any supporting source code
5  which is considered copyrighted (c) material of the original comment or credit authors.
6 
7  This program is distributed in the hope that it will be useful,
8  but WITHOUT ANY WARRANTY; without even the implied warranty of
9  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10  */
11 
13 
15 
31 abstract class AbstractHelper
32 {
36  protected $module;
37 
41  protected $debug;
42 
52  public function __construct($module = null)
53  {
54  $this->module = null;
55 
56  if (empty($module)) {
57  // nothing specified, use current module
58  // check if we are running in 2.6
59  if (class_exists('Xoops', false)) {
61  if ($xoops->isModule()) {
62  $this->module = $xoops->module;
63  }
64  } else {
65  $this->module = $GLOBALS['xoopsModule'];
66  }
67  } elseif (is_scalar($module)) {
68  // dirname specified, get a module object
70  if ($helper) {
71  $this->module = $helper->getModule();
72  }
73  } else {
74  // assume a passed object is appropriate
75  if (is_object($module)) {
76  $this->module = $module;
77  }
78  }
79  if (is_object($this->module)) {
80  $this->init();
81  }
82  }
83 
91  abstract public function init();
92 
100  public function setDebug($bool = true)
101  {
102  $this->debug = (bool) $bool;
103  }
104 
112  public function addLog($log)
113  {
114  if ($this->debug) {
115  \Xoops::getInstance()->logger()->debug($log, array('channel'=>'Extra'));
116  }
117  }
118 }
static getHelper($dirname= 'system')
Definition: Helper.php:41
static getInstance()
Definition: Xoops.php:160
$xoops
Definition: admin.php:25
$helper
$GLOBALS['xoops']
Definition: common.php:33