Ejemplo n.º 1
0
function xsns_load_language($file)
{
	global $xoopsConfig, $mydirpath;
	$trustdirpath = dirname(dirname(__FILE__));
	
	$langmanpath = XOOPS_TRUST_PATH.'/libs/altsys/class/D3LanguageManager.class.php' ;
	if(file_exists($langmanpath)){
		require_once $langmanpath;
		$langman =& D3LanguageManager::getInstance();
		if(is_object($langman)){
			$langman->read($file, basename($mydirpath), basename($trustdirpath));
			return true;
		}
	}
	
	$language = empty($xoopsConfig['language']) ? 'japanese' : $xoopsConfig['language'];
	if(file_exists($mydirpath.'/language/'.$language.'/'.$file)){
		include_once $mydirpath.'/language/'.$language.'/'.$file;
		return true;
	}
	elseif(file_exists($trustdirpath.'/language/'.$language.'/'.$file)){
		include_once $trustdirpath.'/language/'.$language.'/'.$file;
		return true;
	}
	elseif(file_exists($trustdirpath.'/language/japanese/'.$file)){
		include_once $trustdirpath.'/language/japanese/'.$file;
		return true;
	}
	else{
		return false;
	}
}
Ejemplo n.º 2
0
	function prepare()
	{
		$langmanpath = XOOPS_TRUST_PATH.'/libs/altsys/class/D3LanguageManager.class.php' ;
		if( ! file_exists( $langmanpath ) ) die( 'install the latest altsys' ) ;
		require_once( $langmanpath ) ;
		$this->langman =& D3LanguageManager::getInstance() ;
		$this->langman->language = $this->mLanguageName ;

		parent::prepare();
	}
 function renderCell4BlockOptions($block_data)
 {
     if ($this->target_dirname && substr($this->target_dirname, 0, 1) != '_') {
         $langman =& D3LanguageManager::getInstance();
         $langman->read('admin.php', $this->target_dirname);
     }
     $bid = intval($block_data['bid']);
     $block = new XoopsBlock($bid);
     $legacy_block =& Legacy_Utils::createBlockProcedure($block);
     return $legacy_block->getOptionForm();
 }
 /**
  * constractor
  *
  * @access private
  */
 function XooNIpsUtilityLanguagemanager()
 {
     $this->setSingleton();
     $myxoopsConfig =& xoonips_get_xoops_configs(XOOPS_CONF);
     $this->language = preg_replace('/[^0-9a-zA-Z_-]/', '', $myxoopsConfig['language']);
     if (defined('XOOPS_TRUST_PATH') && XOOPS_TRUST_PATH != '') {
         $langmanpath = XOOPS_TRUST_PATH . '/libs/altsys/class/D3LanguageManager.class.php';
         if (file_exists($langmanpath)) {
             require_once $langmanpath;
             $this->d3langman_instance =& D3LanguageManager::getInstance();
         }
     }
 }
Ejemplo n.º 5
0
 /**
  * Prepare driver before mount volume.
  * Connect to db, check required tables and fetch root path
  *
  * @return bool
  * @author Dmitry (dio) Levashov
  **/
 protected function init()
 {
     $this->mydirname = $mydirname = $this->options['mydirname'];
     $langmanpath = XOOPS_TRUST_PATH . '/libs/altsys/class/D3LanguageManager.class.php';
     if (!file_exists($langmanpath)) {
         return false;
     }
     require_once $langmanpath;
     $langman =& D3LanguageManager::getInstance();
     $langman->read('main.php', $mydirname, 'd3diary');
     $d3dTrustDir = XOOPS_TRUST_PATH . '/modules/d3diary';
     include_once $d3dTrustDir . '/class/d3diaryConf.class.php';
     $this->d3dConf =& D3diaryConf::getInstance($mydirname, 0, 'photolist');
     if (!is_object($this->d3dConf)) {
         return false;
     }
     mysql_set_charset('utf8');
     // make catgory tree
     $func =& $this->d3dConf->func;
     $uid = $this->d3dConf->uid;
     $cat = $func->get_categories($uid, $uid);
     $this->catTree = array();
     $this->catTree['root'] = array('subcats' => array());
     $pcid = 'root';
     //-1
     foreach ($cat as $_cat) {
         if (100 <= $_cat['blogtype']) {
             continue;
         }
         $this->catTree[$_cat['cid']] = array('name' => $_cat['cname'], 'pcid' => $_cat['subcat'] && $pcid ? $pcid : 'root');
         if ($_cat['subcat']) {
             if ($pcid !== 'root') {
                 if (!isset($this->catTree[$pcid]['subcats'])) {
                     $this->catTree[$pcid]['subcats'] = array();
                 }
                 $this->catTree[$pcid]['subcats'][] = $_cat['cid'];
             }
         } else {
             $pcid = $_cat['cid'];
             $this->catTree['root']['subcats'][] = $pcid;
         }
     }
     if (!isset($this->options['extAnother']) || strtolower($this->options['extAnother']) !== 'off') {
         $another_pcid = isset($this->catTree[0]) ? 0 : 'root';
         $this->catTree[-1] = array('name' => 'Another', 'pcid' => $another_pcid);
         $this->catTree[$another_pcid]['subcats'][] = -1;
     }
     return true;
 }
 function renderCell4BlockOptions($block_data)
 {
     if ($this->target_dirname && substr($this->target_dirname, 0, 1) != '_') {
         $langman =& D3LanguageManager::getInstance();
         $langman->read('admin.php', $this->target_dirname);
     }
     $bid = intval($block_data['bid']);
     //HACK by domifara
     //	$block = new XoopsBlock( $bid ) ;
     $handler =& xoops_gethandler('block');
     $block =& $handler->create(false);
     $block->load($bid);
     $legacy_block =& Legacy_Utils::createBlockProcedure($block);
     return $legacy_block->getOptionForm();
 }
Ejemplo n.º 7
0
function b_d3pipes_get_pipe_options($mydirname)
{
    $mytrustdirname = basename(dirname(dirname(__FILE__)));
    require_once dirname(dirname(__FILE__)) . '/include/admin_functions.php';
    require_once XOOPS_TRUST_PATH . '/libs/altsys/class/D3LanguageManager.class.php';
    $langman =& D3LanguageManager::getInstance();
    $langman->read('admin.php', $mydirname, $mytrustdirname);
    $db =& Database::getInstance();
    $result = $db->query("SELECT pipe_id,name,joints FROM " . $db->prefix($mydirname . "_pipes") . " WHERE block_disp ORDER BY weight,pipe_id");
    $pipe_options = array('' => '----');
    while ($myrow = $db->fetchArray($result)) {
        $joints = unserialize($myrow['joints']);
        $pipe_options[intval($myrow['pipe_id'])] = htmlspecialchars('(' . $myrow['pipe_id'] . ') ' . d3pipes_admin_judge_type_of_pipe($joints) . ' - ' . $myrow['name'], ENT_QUOTES);
    }
    return $pipe_options;
}
 function setConfigLabels()
 {
     // read modinfo.php
     $langman =& D3LanguageManager::getInstance();
     $langman->read('modinfo.php', $this->mydirname, $this->mytrustdirname);
     // NAME/DESC of the configs
     $module_handler =& xoops_gethandler('module');
     $module =& $module_handler->getByDirname($this->mydirname);
     $config_handler =& xoops_gethandler('config');
     $criteria =& new Criteria('conf_modid', $module->mid());
     $modConfigObjs = $config_handler->getConfigs($criteria);
     $this->config_labels = array();
     foreach ($modConfigObjs as $modConfigObj) {
         $conf_name = $modConfigObj->getVar('conf_name', 'n');
         $conf_title = $modConfigObj->getVar('conf_title', 'n');
         $conf_desc = $modConfigObj->getVar('conf_desc', 'n');
         if (defined($conf_title)) {
             $this->config_labels[$conf_name] = constant($conf_title) . ($conf_desc ? ":\n \n" . @constant($conf_desc) : '');
         }
     }
 }
Ejemplo n.º 9
0
function b_d3pipes_sync_show($options)
{
    $mydirname = empty($options[0]) ? 'd3pipes' : $options[0];
    $unique_id = empty($options[1]) ? uniqid(rand()) : htmlspecialchars($options[1], ENT_QUOTES);
    // just dummy
    $pipe_ids = empty($options[2]) ? array(0) : explode(',', preg_replace('/[^0-9,:]/', '', $options[2]));
    $max_entries = empty($options[3]) ? 0 : intval($options[3]);
    $this_template = empty($options[4]) ? 'db:' . $mydirname . '_block_sync.html' : trim($options[4]);
    $union_class = @$options[5] == 'separated' ? 'separated' : 'mergesort';
    $link2clipping = empty($options[6]) ? false : true;
    $keep_pipeinfo = empty($options[7]) ? false : true;
    if (preg_match('/[^0-9a-zA-Z_-]/', $mydirname)) {
        die('Invalid mydirname');
    }
    $module_handler =& xoops_gethandler('module');
    $module =& $module_handler->getByDirname($mydirname);
    $config_handler =& xoops_gethandler('config');
    $configs = $config_handler->getConfigList($module->mid());
    $constpref = '_MB_' . strtoupper($mydirname);
    // Union object
    $union_obj =& d3pipes_common_get_joint_object($mydirname, 'union', $union_class, sizeof($pipe_ids) == 1 ? $pipe_ids[0] . ':' . $max_entries : implode(',', $pipe_ids) . '||' . ($keep_pipeinfo ? 1 : 0));
    $union_obj->setModConfigs($configs);
    $entries = $union_obj->execute(array(), $max_entries);
    $pipes_entries = method_exists($union_obj, 'getPipesEntries') ? $union_obj->getPipesEntries() : array();
    $errors = $union_obj->getErrors();
    // language file of main.php
    $langman =& D3LanguageManager::getInstance();
    $langman->read('main.php', $mydirname, basename(dirname(dirname(__FILE__))));
    $block = array('mydirname' => $mydirname, 'mod_url' => XOOPS_URL . '/modules/' . $mydirname, 'mod_imageurl' => XOOPS_URL . '/modules/' . $mydirname . '/' . $configs['images_dir'], 'xoops_config' => $GLOBALS['xoopsConfig'], 'mod_config' => $configs, 'pipe_ids' => $pipe_ids, 'max_entries' => $max_entries, 'union_class' => $union_class, 'link2clipping' => $link2clipping, 'keep_pipeinfo' => $keep_pipeinfo, 'errors' => $errors, 'entries' => $entries, 'pipes_entries' => $pipes_entries, 'timezone_offset' => xoops_getUserTimestamp(0));
    if (empty($options['disable_renderer'])) {
        require_once XOOPS_TRUST_PATH . '/libs/altsys/class/D3Tpl.class.php';
        $tpl = new D3Tpl();
        $tpl->assign('block', $block);
        $ret['content'] = $tpl->fetch($this_template);
        return $ret;
    } else {
        return $block;
    }
}
Ejemplo n.º 10
0
}
// Skip for ORETEKI XOOPS
if (defined('XOOPS_ORETEKI')) {
    return;
}
global $xoopsModule;
if (!is_object($xoopsModule)) {
    die('$xoopsModule is not set');
}
// language files (modinfo.php)
$langmanpath = XOOPS_TRUST_PATH . '/libs/altsys/class/D3LanguageManager.class.php';
if (!file_exists($langmanpath)) {
    die('install the latest altsys');
}
require_once $langmanpath;
$langman =& D3LanguageManager::getInstance();
$langman->read('modinfo.php', $mydirname, $mytrustdirname);
include dirname(dirname(__FILE__)) . '/admin_menu.php';
$adminmenu = array_merge($adminmenu, $adminmenu4altsys);
$mymenu_uri = empty($mymenu_fake_uri) ? $_SERVER['REQUEST_URI'] : $mymenu_fake_uri;
$mymenu_link = substr(strstr($mymenu_uri, '/admin/'), 1);
// highlight
foreach (array_keys($adminmenu) as $i) {
    if ($mymenu_link == $adminmenu[$i]['link']) {
        $adminmenu[$i]['selected'] = true;
        $adminmenu_hilighted = true;
        $GLOBALS['altsysAdminPageTitle'] = $adminmenu[$i]['title'];
    } else {
        $adminmenu[$i]['selected'] = false;
    }
}
 function readLanguage($filename = null)
 {
     if (empty($filename)) {
         $filename = $this->mypluginname;
     }
     // read language files for this plugin
     $langmanpath = XOOPS_TRUST_PATH . '/libs/altsys/class/D3LanguageManager.class.php';
     require_once $langmanpath;
     $langman =& D3LanguageManager::getInstance();
     $langman->read($filename . '.php', $this->mydirname, 'pico');
 }
Ejemplo n.º 12
0
 public function __construct($mydirname, $req_uid = 0, $caller = "")
 {
     global $xoopsUser, $xoopsConfig;
     $this->start_time = (int) (microtime(true) * 1000);
     $this->db =& Database::getInstance();
     $this->mydirname = $mydirname;
     $this->caller = $caller;
     if (is_object(@$xoopsUser)) {
         $this->uid = intval($xoopsUser->getVar('uid'));
         $this->uname = $xoopsUser->getVar('uname');
         $this->name = $xoopsUser->getVar('name');
     } else {
         $this->uid = 0;
         $this->uname = "";
         $this->name = "";
     }
     $this->req_uid = (int) $req_uid > 0 ? (int) $req_uid : ((int) $this->getpost_param("req_uid") ? (int) $this->getpost_param("req_uid") : 0);
     //	((int)$this->getpost_param("req_uid") ? (int)$this->getpost_param("req_uid") : $this->uid )  ; // !! Must not do this
     //var_dump($this->mydirname); var_dump($this->req_uid); var_dump($this->uid); var_dump($caller); echo "<br />";
     // module ID
     $module_handler =& xoops_gethandler('module');
     $this_module =& $module_handler->getByDirname($this->mydirname);
     if (is_object($this_module)) {
         $this->mid = (int) $this_module->getVar('mid');
         $this->module_name = $this_module->getVar('name');
         // module config
         $config_handler =& xoops_gethandler("config");
         $this->mod_config = $config_handler->getConfigsByCat(0, $this->mid);
     }
     // is_main
     $constpref = "_MB_" . strtoupper($this->mydirname);
     if (defined("_MD_W_SUN")) {
         $this->is_main = true;
     } elseif (!defined($constpref . "_W_SUN")) {
         $langmanpath = XOOPS_TRUST_PATH . '/libs/altsys/class/D3LanguageManager.class.php';
         if (!file_exists($langmanpath)) {
             die('install the latest altsys');
         }
         require_once $langmanpath;
         $langman =& D3LanguageManager::getInstance();
         $mytrustdirname = basename(dirname(dirname(__FILE__)));
         $langman->read('blocks_each.php', $this->mydirname, $mytrustdirname, false);
     }
     if (XOOPS_USE_MULTIBYTES == 1) {
         // mbstring emulator
         if (!extension_loaded('mbstring') && !class_exists('HypMBString')) {
             if (file_exists(XOOPS_TRUST_PATH . '/class/hyp_common/mbemulator/mb-emulator.php')) {
                 require_once XOOPS_TRUST_PATH . '/class/hyp_common/mbemulator/mb-emulator.php';
             }
         }
         // rss feed encoding from
         switch ($this->mod_config['enc_from']) {
             case 'xoops_charset':
                 $this->enc_from = _CHARSET;
                 break;
             case 'auto':
                 $this->enc_from = "auto";
                 break;
             case 'default':
             default:
                 // null
         }
     }
     $this->params['uploaddir_abs'] = XOOPS_ROOT_PATH . '/modules/' . $mydirname . '/upimg/';
     // photo upload dir
     $this->params['previewdir'] = 'prev/';
     // photo preview dir
     $this->params['cachedir'] = XOOPS_ROOT_PATH . '/modules/' . $mydirname . '/cache/';
     // photo cache dir
     //if( $caller != "xoops_uname" ) {
     $_year = $this->getpost_param('year');
     $_month = $this->getpost_param('month');
     $this->set_month($_year, $_month);
     // permission_class (read ef class and create the object)
     $perm_class = empty($this->mod_config['permission_class']) ? 'd3diaryPermission' : preg_replace('/[^0-9a-zA-Z_]/', '', $this->mod_config['permission_class']);
     (method_exists('MyTextSanitizer', 'sGetInstance') and $this->myts =& MyTextSanitizer::sGetInstance()) || ($this->myts =& MyTextSanitizer::getInstance());
     require_once dirname(__FILE__) . '/' . $perm_class . '.class.php';
     require_once dirname(__FILE__) . '/groupperm.class.php';
     require_once dirname(__FILE__) . '/func.class.php';
     include_once dirname(__FILE__) . '/diaryconfig.class.php';
     require_once dirname(__FILE__) . '/sanitizer.class.php';
     $this->mPerm = new $perm_class($this);
     $this->gPerm = new D3dGperm($this);
     $this->func = new D3diaryFunc($this);
     // needs req_uid
     $this->mPerm->ini_set();
     $this->gPerm->ini_set();
     $this->func->ini_set();
     // get personal config for req_uid
     $this->dcfg = new DiaryConfig();
     $this->dcfg->uid = $this->req_uid;
     $this->dcfg->readdb($this->mydirname);
     // sanitizer class for input validation vulnerabilities
     $this->sani = new D3diarySanitizer();
     // mail post class
     if ($this->caller == "mailpost" || $this->caller == "index") {
         require_once dirname(__FILE__) . '/mailpost.class.php';
         $this->mPost = new D3diaryMailPost($this);
         $this->mPost->ini_set();
     }
     $this->debug_appendtime('d3dConf_construct');
     //}
     $this->page = $this->func->htmlspecialchars($this->func->getpost_param('page'));
     $this->q_mode = $this->func->htmlspecialchars($this->func->getpost_param('mode'));
     $this->q_cid = (int) $this->func->getpost_param('cid');
     $this->q_tag_noquote = rawurldecode($this->func->getpost_param('tag_name'));
     $this->q_tag = $this->func->htmlspecialchars($this->q_tag_noquote);
     $this->q_year = (int) $this->func->getpost_param('year');
     $this->q_month = (int) $this->func->getpost_param('month');
     $this->q_day = (int) $this->func->getpost_param('day');
     $this->q_odr = $this->func->htmlspecialchars($this->func->getpost_param('odr'));
     $this->q_fr = (int) $this->func->getpost_param('fr');
     $this->q_multidel = (int) $this->func->getpost_param('multidel');
     // create url for sort and common links
     $this->urluppr = XOOPS_URL . '/modules/' . $this->mydirname . '/index.php?';
     $this->urlbase_dlst = "page=diarylist";
     $this->urlbase_exph = "";
     if (strcmp($this->page, "photolist") == 0) {
         if ($this->req_uid > 0) {
             $this->urlbase = "page=photolist&amp;req_uid=" . $this->req_uid;
             $this->urlbase_exph = "req_uid=" . $this->req_uid;
         } else {
             $this->urlbase = "page=photolist";
             $this->urlbase_exph = "page=diarylist";
         }
     } else {
         if ($this->req_uid > 0) {
             $this->urlbase = "req_uid=" . $this->req_uid;
         } else {
             $this->urlbase = "page=diarylist";
         }
         if ($this->q_multidel > 0) {
             $this->urlbase .= "&amp;multidel=1";
         }
     }
     $this->urlbase_exfr = $this->urlbase;
     // exclude category
     if (strcmp($this->q_mode, "category") == 0) {
         $this->url4_all = "&amp;mode=category&amp;cid=" . $this->q_cid;
     }
     // exclude friend
     $this->url4ex_fr = $this->url4_all;
     if ($this->q_fr > 0 && $this->req_uid > 0) {
         $this->url4_all .= "&amp;fr=1";
         $this->url4ex_cat .= $_tmp_para;
     }
     // exclude date
     $this->url4ex_date = $this->url4_all;
     if ($this->q_day > 0) {
         $_tmp_para = "&amp;year=" . $this->q_year . "&amp;month=" . $this->q_month . "&amp;day=" . $this->q_day;
         $this->url4_all .= $_tmp_para;
         $this->url4ex_cat .= $_tmp_para;
         $this->url4ex_fr .= $_tmp_para;
     } elseif ($this->q_month > 0) {
         $_tmp_para = "&amp;year=" . $this->q_year . "&amp;month=" . $this->q_month;
         $this->url4_all .= $_tmp_para;
         $this->url4ex_cat .= $_tmp_para;
         $this->url4ex_fr .= $_tmp_para;
     }
     // exclude tag
     $this->url4ex_tag = $this->url4_all;
     if (!empty($this->q_tag)) {
         $_tmp_para = "&amp;tag_name=" . $this->q_tag;
         $this->url4_all .= $_tmp_para;
         $this->url4ex_date .= $_tmp_para;
         $this->url4ex_cat .= $_tmp_para;
         $this->url4ex_fr .= $_tmp_para;
     }
     // exclude order
     $this->url4ex_odr = $this->url4_all;
     if (!empty($this->q_odr)) {
         $_tmp_para = "&amp;odr=" . $this->q_odr;
         $this->url4_all .= $_tmp_para;
         $this->url4ex_date .= $_tmp_para;
         $this->url4ex_cat .= $_tmp_para;
         $this->url4ex_fr .= $_tmp_para;
         $this->url4ex_tag .= $_tmp_para;
     }
     $this->url4ex_ph .= $this->url4_all;
     $this->style_s['time_dsc'] = $this->style_s['title_dsc'] = $this->style_s['name_dsc'] = $this->style_s['count_dsc'] = $this->style_s['hit_dsc'] = "d3dSortDsc";
     $this->style_s['time_asc'] = $this->style_s['title_asc'] = $this->style_s['name_asc'] = $this->style_s['count_asc'] = $this->style_s['hit_asc'] = "d3dSortAsc";
     switch ($this->q_odr) {
         case "time_asc":
             $this->style_s['time_asc'] = "d3dSortAsc_s";
             break;
         case "title_dsc":
             $this->style_s['title_dsc'] = "d3dSortDsc_s";
             break;
         case "title_asc":
             $this->style_s['title_asc'] = "d3dSortAsc_s";
             break;
         case "name_dsc":
             $this->style_s['name_dsc'] = "d3dSortDsc_s";
             break;
         case "name_asc":
             $this->style_s['name_asc'] = "d3dSortAsc_s";
             break;
         case "count_dsc":
             $this->style_s['count_dsc'] = "d3dSortDsc_s";
             break;
         case "count_asc":
             $this->style_s['count_asc'] = "d3dSortAsc_s";
             break;
         case "hit_dsc":
             $this->style_s['hit_dsc'] = "d3dSortDsc_s";
             break;
         case "hit_asc":
             $this->style_s['hit_asc'] = "d3dSortAsc_s";
             break;
         case "time_dsc":
         default:
             $this->style_s['time_dsc'] = "d3dSortDsc_s";
             break;
     }
     $this->debug_mode = $xoopsConfig['debug_mode'];
     // for debugging
     $this->server_TZ = (int) $xoopsConfig['server_TZ'];
 }
Ejemplo n.º 13
0
    /**
     * Get JavaScript of switch to (BB-code or Wiki) editor (Static Fundtion)
     *
     * @param string $id        DomId
     * @param string $mydirname xpWiki Module dirname
     * @return string           JavaScript
     */
    public static function sGet_BBCode_switch_js($id, $mydirname = null)
    {
        if (is_null($mydirname)) {
            if (defined('XPWIKI_RENDERER_DIR')) {
                $mydirname = XPWIKI_RENDERER_DIR;
            } else {
                $mydirname = 'xpwiki';
            }
        }
        $constpref = '_MI_' . strtoupper($mydirname);
        if (!defined($constpref . '_MSG_TO_SWITCH_EDITOR')) {
            // language file (modinfo.php)
            $langmanpath = XOOPS_TRUST_PATH . '/libs/altsys/class/D3LanguageManager.class.php';
            if (!file_exists($langmanpath)) {
                die('install the latest altsys');
            }
            require_once $langmanpath;
            $langman =& D3LanguageManager::getInstance();
            $langman->read('modinfo.php', $mydirname, 'xpwiki');
        }
        $msgToBBcode = htmlspecialchars(constant($constpref . '_MSG_TO_BBCODE_EDITOR'), ENT_QUOTES, _CHARSET);
        $msgToWiki = htmlspecialchars(constant($constpref . '_MSG_TO_WIKI_EDITOR'), ENT_QUOTES, _CHARSET);
        $msgSwitch = htmlspecialchars(constant($constpref . '_MSG_TO_SWITCH_EDITOR'), ENT_QUOTES, _CHARSET);
        return <<<EOD
<script type="text/javascript">
//<![CDATA[
(function(){
if (typeof wikihelper_load_cookie == 'function' ) {
\tvar target = document.getElementById('{$id}');
\tvar switcherId = '{$id}-bbcodeSwitcher';
\tif (target.previousSibling && target.previousSibling.id != switcherId) {
\t\ttarget._ToBBCodeDone = true;
\t\tvar c_ehlp = wikihelper_load_cookie('__whlp');
\t\tvar editor_bbcode = false;
\t\tif (c_ehlp) {
\t\t\teditor_bbcode = (c_ehlp.match(/^1/));
\t\t\tc_ehlp = (c_ehlp.replace(/^\\d+/, '') === 'on')? 'on' : '';
\t\t} else {
\t\t\tc_ehlp = '';
\t\t}
\t\tvar elm = document.createElement('div');
\t\telm.id = switcherId;
\t\tvar btn = document.createElement('button');
\t\ttry { btn.type = 'button'; } catch(e) {} // try for IE8
\t\tbtn.onclick = function(){
\t\t\t\tif (confirm('{$msgSwitch}')) {
\t\t\t\t\twikihelper_save_cookie("__whlp", (editor_bbcode? '0' : '1') + c_ehlp, 90 ,'/');
\t\t\t\t\tlocation.reload(false);
\t\t\t\t}
\t\t\t\treturn false;
\t\t\t};
\t\tvar str = document.createTextNode(editor_bbcode? '{$msgToWiki}' : '{$msgToBBcode}');
\t\tbtn.appendChild(str);
\t\telm.appendChild(btn);
\t\ttarget.parentNode.insertBefore(elm, target);
\t}
}
}());
//]]>
</script>
EOD;
    }
 function includeLanguageBlock()
 {
     $langmanpath = XOOPS_TRUST_PATH . '/libs/altsys/class/D3LanguageManager.class.php';
     if (!file_exists($langmanpath)) {
         die('install the latest altsys');
     }
     require_once $langmanpath;
     $langman =& D3LanguageManager::getInstance();
     $langman->read('blocks.php', $this->target_dirname);
 }
Ejemplo n.º 15
0
 /**
  * Prepare driver before mount volume.
  * Connect to db, check required tables and fetch root path
  *
  * @return bool
  * @author Dmitry (dio) Levashov
  **/
 protected function init()
 {
     $this->mydirname = $mydirname = $this->options['mydirname'];
     $langmanpath = XOOPS_TRUST_PATH . '/libs/altsys/class/D3LanguageManager.class.php';
     if (!file_exists($langmanpath)) {
         return false;
     }
     require_once $langmanpath;
     $langman =& D3LanguageManager::getInstance();
     $langman->read('main.php', $mydirname, 'd3diary');
     $d3dTrustDir = XOOPS_TRUST_PATH . '/modules/d3diary';
     include_once $d3dTrustDir . '/class/d3diaryConf.class.php';
     $this->d3dConf =& D3diaryConf::getInstance($mydirname, 0, 'photolist');
     if (!is_object($this->d3dConf)) {
         return false;
     }
     xoops_elFinder::dbSetCharset('utf8');
     // make catgory tree
     $func =& $this->d3dConf->func;
     $uid = $this->d3dConf->uid;
     $cat = $func->get_categories($uid, $uid);
     $this->catTree = array();
     $this->catTree['root'] = array('subcats' => array());
     $pcid = 'root';
     foreach ($cat as $_cat) {
         if (100 <= $_cat['blogtype'] || $_cat['subcat'] && !$_cat['num']) {
             continue;
         }
         $this->catTree[$_cat['cid']] = array('subcats' => array(), 'num' => $_cat['num'], 'name' => $_cat['cname'], 'pcid' => $_cat['subcat'] && $pcid ? $pcid : 'root');
         if ($_cat['subcat']) {
             if ($pcid !== 'root') {
                 $this->catTree[$pcid]['subcats'][$_cat['cid']] = $_cat['cname'];
             }
         } else {
             if ($pcid !== 'root' && !$this->catTree[$pcid]['subcats'] && !$this->catTree[$pcid]['num']) {
                 // no entry
                 unset($this->catTree[$this->catTree[$pcid]['pcid']]['subcats'][$pcid], $this->catTree[$pcid]);
             }
             $pcid = $_cat['cid'];
             $this->catTree['root']['subcats'][$pcid] = $_cat['cname'];
         }
     }
     if (!isset($this->options['extAnother']) || strtolower($this->options['extAnother']) !== 'off') {
         if (!isset($this->catTree[0])) {
             $this->catTree[0] = array('subcats' => array(), 'name' => _MD_NOCNAME, 'pcid' => 'root');
             $this->catTree['root']['subcats'][0] = $this->strToUTF8(_MD_NOCNAME);
         }
         $this->catTree[0]['name'] = $this->strToUTF8($this->catTree[0]['name']);
         $this->catTree[-1] = array('subcats' => array(), 'name' => 'Another', 'pcid' => 0);
         $this->catTree[0]['subcats'][-1] = 'Another';
     }
     if (is_null($this->options['syncChkAsTs'])) {
         $this->options['syncChkAsTs'] = true;
     }
     return true;
 }
Ejemplo n.º 16
0
function d3forum_render_comments($mydirname, $forum_id, $params, &$smarty)
{
    global $xoopsUser, $xoopsConfig, $xoopsModule;
    $mydirpath = XOOPS_ROOT_PATH . '/modules/' . $mydirname;
    $mytrustdirname = basename(dirname(dirname(__FILE__)));
    $mytrustdirpath = dirname(dirname(__FILE__));
    $db =& Database::getInstance();
    // extract $external_* from $parms
    $external_link_id = $params['external_link_id'];
    $external_dirname = $params['external_dirname'];
    $external_trustdirname = $params['external_trustdirname'];
    // language files
    $langmanpath = XOOPS_TRUST_PATH . '/libs/altsys/class/D3LanguageManager.class.php';
    if (!file_exists($langmanpath)) {
        die('install the latest altsys');
    }
    require_once $langmanpath;
    $langman =& D3LanguageManager::getInstance();
    $langman->read('main.php', $mydirname, $mytrustdirname);
    // local $xoopsModuleConfig
    $module_hanlder =& xoops_gethandler('module');
    $module =& $module_hanlder->getByDirname($mydirname);
    $config_handler =& xoops_gethandler('config');
    $xoopsModuleConfig =& $config_handler->getConfigsByCat(0, $module->getVar('mid'));
    include dirname(__FILE__) . '/common_prepend.php';
    $forum_id = intval($forum_id);
    if (!(include dirname(__FILE__) . '/process_this_forum.inc.php')) {
        return;
    }
    if (!(include dirname(__FILE__) . '/process_this_category.inc.php')) {
        return;
    }
    // get $odr_options, $solved_options, $query4assign
    //$query4nav = "forum_id=$forum_id" ;
    //include dirname(__FILE__).'/process_query4topics.inc.php' ;
    // force UPDATE forums.forum_external_link_format "(dirname)::(classname)::(trustdirname)"
    if (empty($forum_row['forum_external_link_format']) && !empty($params['class'])) {
        $db->queryF("UPDATE " . $db->prefix($mydirname . "_forums") . " SET forum_external_link_format='" . addslashes($external_dirname . '::' . $params['class'] . '::' . $external_trustdirname) . "' WHERE forum_id={$forum_id}");
    }
    // check $params
    $params['posts_num'] = @$params['posts_num'] > 0 ? intval($params['posts_num']) : 10;
    // INVISIBLE
    $whr_invisible = $isadminormod ? '1' : '! t.topic_invisible';
    /************ THREADED VIEW ************/
    if (@$params['view'] == 'listtopics') {
        $this_template = 'db:' . $mydirname . '_comment_listtopics.html';
        // number query
        $sql = "SELECT COUNT(t.topic_id) FROM " . $db->prefix($mydirname . "_topics") . " t LEFT JOIN " . $db->prefix($mydirname . "_users2topics") . " u2t ON t.topic_id=u2t.topic_id AND u2t.uid={$uid} LEFT JOIN " . $db->prefix($mydirname . "_posts") . " lp ON lp.post_id=t.topic_last_post_id LEFT JOIN " . $db->prefix($mydirname . "_posts") . " fp ON fp.post_id=t.topic_first_post_id WHERE t.forum_id={$forum_id} AND ({$whr_invisible}) AND topic_external_link_id='" . addslashes($external_link_id) . "'";
        if (!($trs = $db->query($sql))) {
            die(_MD_D3FORUM_ERR_SQL . __LINE__);
        }
        list($topic_hits) = $db->fetchRow($trs);
        $post_hits = 0;
        // pagenav
        /*
        if( $topic_hits > $num ) {
        	require_once XOOPS_ROOT_PATH.'/class/pagenav.php' ;
        	$pagenav_obj = new XoopsPageNav( $topic_hits , $num , $pos , 'pos', $query4nav ) ;
        	$pagenav = $pagenav_obj->renderNav() ;
        }
        */
        $sql_order = @$params['order'] == 'asc' ? 'ASC' : 'DESC';
        // main query
        $sql = "SELECT t.*, lp.subject AS lp_subject, lp.icon AS lp_icon, lp.number_entity AS lp_number_entity, lp.special_entity AS lp_special_entity, fp.subject AS fp_subject, fp.icon AS fp_icon, fp.number_entity AS fp_number_entity, fp.special_entity AS fp_special_entity, u2t.u2t_time, u2t.u2t_marked, u2t.u2t_rsv FROM " . $db->prefix($mydirname . "_topics") . " t LEFT JOIN " . $db->prefix($mydirname . "_users2topics") . " u2t ON t.topic_id=u2t.topic_id AND u2t.uid={$uid} LEFT JOIN " . $db->prefix($mydirname . "_posts") . " lp ON lp.post_id=t.topic_last_post_id LEFT JOIN " . $db->prefix($mydirname . "_posts") . " fp ON fp.post_id=t.topic_first_post_id WHERE t.forum_id={$forum_id} AND ({$whr_invisible}) AND topic_external_link_id='" . addslashes($external_link_id) . "' ORDER BY t.topic_last_post_time {$sql_order}";
        if (!($trs = $db->query($sql))) {
            die(_MD_D3FORUM_ERR_SQL . __LINE__);
        }
        // topics loop
        $topics = array();
        while ($topic_row = $db->fetchArray($trs)) {
            $topic_id = intval($topic_row['topic_id']);
            // get last poster's object
            $user_handler =& xoops_gethandler('user');
            $last_poster_obj =& $user_handler->get(intval($topic_row['topic_last_uid']));
            $last_post_uname4html = is_object($last_poster_obj) ? $last_poster_obj->getVar('uname') : $xoopsConfig['anonymous'];
            $first_poster_obj =& $user_handler->get(intval($topic_row['topic_first_uid']));
            $first_post_uname4html = is_object($first_poster_obj) ? $first_poster_obj->getVar('uname') : $xoopsConfig['anonymous'];
            // topics array
            $topics[] = array('id' => $topic_row['topic_id'], 'title' => $myts->makeTboxData4Show($topic_row['topic_title'], $topic_row['fp_number_entity'], $topic_row['fp_special_entity']), 'replies' => intval($topic_row['topic_posts_count']) - 1, 'views' => intval($topic_row['topic_views']), 'last_post_time' => intval($topic_row['topic_last_post_time']), 'last_post_time_formatted' => formatTimestamp($topic_row['topic_last_post_time'], 'm'), 'last_post_id' => intval($topic_row['topic_last_post_id']), 'last_post_icon' => intval($topic_row['lp_icon']), 'last_post_subject' => $myts->makeTboxData4Show($topic_row['lp_subject'], $topic_row['lp_number_entity'], $topic_row['lp_special_entity']), 'last_post_uid' => intval($topic_row['topic_last_uid']), 'last_post_uname' => $last_post_uname4html, 'first_post_time' => intval($topic_row['topic_first_post_time']), 'first_post_time_formatted' => formatTimestamp($topic_row['topic_first_post_time'], 'm'), 'first_post_id' => intval($topic_row['topic_first_post_id']), 'first_post_icon' => intval($topic_row['fp_icon']), 'first_post_subject' => $myts->makeTboxData4Show($topic_row['fp_subject'], $topic_row['fp_number_entity'], $topic_row['fp_special_entity']), 'first_post_uid' => intval($topic_row['topic_first_uid']), 'first_post_uname' => $first_post_uname4html, 'bit_new' => $topic_row['topic_last_post_time'] > @$topic_row['u2t_time'] ? 1 : 0, 'bit_hot' => $topic_row['topic_posts_count'] > $xoopsModuleConfig['hot_threshold'] ? 1 : 0, 'locked' => intval($topic_row['topic_locked']), 'sticky' => intval($topic_row['topic_sticky']), 'solved' => intval($topic_row['topic_solved']), 'invisible' => intval($topic_row['topic_invisible']), 'u2t_time' => intval(@$topic_row['u2t_time']), 'u2t_marked' => intval(@$topic_row['u2t_marked']), 'votes_count' => intval($topic_row['topic_votes_count']), 'votes_sum' => intval($topic_row['topic_votes_sum']), 'votes_avg' => round($topic_row['topic_votes_sum'] / ($topic_row['topic_votes_count'] - 1.0E-7), 2));
        }
        $post = array();
        /************ DEFAULT VIEW (listposts_flat) ************/
    } else {
        $this_template = 'db:' . $mydirname . '_comment_listposts_flat.html';
        $posts = array();
        $sql_whr = "t.forum_id={$forum_id} AND ({$whr_invisible}) AND t.topic_external_link_id='" . addslashes($external_link_id) . "'";
        // post order
        $postorder = 0;
        $postorder4sql = 'post_time DESC';
        if (isset($params['order'])) {
            if ($params['order'] == 'asc') {
                $postorder = 1;
                $postorder4sql = 'post_time ASC';
            }
        }
        // post_hits ~ pagenavi //naao from
        // count post
        $sql = "SELECT COUNT(post_id) FROM " . $db->prefix($mydirname . "_posts") . " p LEFT JOIN " . $db->prefix($mydirname . "_topics") . " t ON p.topic_id=t.topic_id WHERE {$sql_whr}";
        if (!($nrs = $db->query($sql))) {
            die(_MD_D3FORUM_ERR_SQL . __LINE__);
        }
        list($post_hits) = $db->fetchRow($nrs);
        // pagenav
        $pagenav = '';
        // LIMIT
        $num = $params['posts_num'] < 5 ? 5 : intval($params['posts_num']);
        $pos = 0;
        if ($post_hits > $num) {
            // POS
            $pos = isset($_GET['d3f_pos']) ? intval($_GET['d3f_pos']) : ($postorder == 1 ? (int) (($post_hits - 1) / $num) * $num : 0);
            if (!empty($_SERVER['QUERY_STRING'])) {
                if (preg_match("/^d3f_pos=[0-9]+/", $_SERVER['QUERY_STRING'])) {
                    $query4nav = "";
                } else {
                    $query4nav = preg_replace("/^(.*)\\&d3f_pos=[0-9]+/", "\$1", $_SERVER['QUERY_STRING']);
                }
            } else {
                $query4nav = "";
            }
            require_once dirname(dirname(__FILE__)) . '/class/D3forumPagenav.class.php';
            $pagenav_obj = new D3forumPagenav($post_hits, $num, $pos, 'd3f_pos', $query4nav);
            $pagenav = $pagenav_obj->getNav();
        }
        // post_hits ~ pagenavi //naao to
        $sql = "SELECT p.*,t.topic_locked FROM " . $db->prefix($mydirname . "_posts") . " p LEFT JOIN " . $db->prefix($mydirname . "_topics") . " t ON p.topic_id=t.topic_id WHERE {$sql_whr} ORDER BY {$postorder4sql} LIMIT {$pos},{$num}";
        //naao
        if (!($prs = $db->query($sql))) {
            die(_MD_D3FORUM_ERR_SQL . __LINE__);
        }
        while ($post_row = $db->fetchArray($prs)) {
            // get poster's information ($poster_*), $can_reply, $can_edit, $can_delete
            $topic_row = array('topic_locked' => $post_row['topic_locked']);
            include dirname(__FILE__) . '/process_eachpost.inc.php';
            // posts array
            $posts[] = array('id' => intval($post_row['post_id']), 'subject' => $myts->makeTboxData4Show($post_row['subject'], $post_row['number_entity'], $post_row['special_entity']), 'pid' => intval($post_row['pid']), 'topic_id' => intval($post_row['topic_id']), 'post_time' => intval($post_row['post_time']), 'post_time_formatted' => formatTimestamp($post_row['post_time'], 'm'), 'modified_time' => intval($post_row['modified_time']), 'modified_time_formatted' => formatTimestamp($post_row['modified_time'], 'm'), 'poster_uid' => intval($post_row['uid']), 'poster_uname' => $poster_uname4disp, 'poster_ip' => htmlspecialchars($post_row['poster_ip'], ENT_QUOTES), 'poster_rank_title' => $poster_rank_title4disp, 'poster_rank_image' => $poster_rank_image4disp, 'poster_is_online' => $poster_is_online, 'poster_avatar' => $poster_avatar, 'poster_posts_count' => $poster_posts_count, 'poster_regdate' => $poster_regdate, 'poster_regdate_formatted' => formatTimestamp($poster_regdate, 's'), 'poster_from' => $poster_from4disp, 'modifier_ip' => htmlspecialchars($post_row['poster_ip'], ENT_QUOTES), 'html' => intval($post_row['html']), 'smiley' => intval($post_row['smiley']), 'br' => intval($post_row['br']), 'xcode' => intval($post_row['xcode']), 'icon' => intval($post_row['icon']), 'attachsig' => intval($post_row['attachsig']), 'signature' => $signature4disp, 'invisible' => intval($post_row['invisible']), 'approval' => intval($post_row['approval']), 'uid_hidden' => intval($post_row['uid_hidden']), 'depth_in_tree' => intval($post_row['depth_in_tree']), 'order_in_tree' => intval($post_row['order_in_tree']), 'unique_path' => htmlspecialchars(substr($post_row['unique_path'], 1), ENT_QUOTES), 'votes_count' => intval($post_row['votes_count']), 'votes_sum' => intval($post_row['votes_sum']), 'votes_avg' => round($post_row['votes_sum'] / ($post_row['votes_count'] - 1.0E-7), 2), 'past_vote' => -1, 'guest_name' => $myts->makeTboxData4Show($post_row['guest_name']), 'guest_email' => $myts->makeTboxData4Show($post_row['guest_email']), 'guest_url' => $myts->makeTboxUrl4Show($post_row['guest_url']), 'guest_trip' => $myts->makeTboxData4Show($post_row['guest_trip']), 'post_text' => $myts->displayTarea($post_row['post_text'], $post_row['html'], $post_row['smiley'], $post_row['xcode'], $xoopsModuleConfig['allow_textimg'], $post_row['br'], 0, $post_row['number_entity'], $post_row['special_entity']), 'post_text_raw' => $post_row['post_text'], 'can_edit' => $can_edit, 'can_delete' => $can_delete, 'can_reply' => $can_reply, 'can_vote' => $can_vote);
        }
        //if( @$params['order'] == 'asc' && !empty($posts)) {
        //	$posts = array_reverse( $posts ) ; // thx naao
        //}
        $topics = array();
        // form elements or javascripts for anti-SPAM
        if (d3forum_common_is_necessary_antispam($xoopsUser, $xoopsModuleConfig)) {
            $antispam_obj =& d3forum_common_get_antispam_object($xoopsModuleConfig);
            $antispam4assign = $antispam_obj->getHtml4Assign();
        } else {
            $antispam4assign = array();
        }
        // naao from
        if (is_object($xoopsUser)) {
            if ($xoopsModuleConfig['use_name'] == 1 && $xoopsUser->getVar('name')) {
                $poster_uname4disp = $xoopsUser->getVar('name');
            } else {
                $poster_uname4disp = $xoopsUser->getVar('uname');
            }
        } else {
            $poster_uname4disp = '';
        }
        // naao to
    }
    $tree = array();
    if ($external_link_id > 0) {
        $sql = "SELECT p.*, t.topic_locked, t.topic_id, t.forum_id, t.topic_last_uid, t.topic_last_post_time \n\t\tFROM " . $db->prefix($mydirname . "_topics") . " t \n\t\tLEFT JOIN " . $db->prefix($mydirname . "_posts") . " p ON p.topic_id=t.topic_id \n\t\tWHERE t.forum_id={$forum_id} AND ({$whr_invisible}) AND p.depth_in_tree='0' \n\t\t\tAND (t.topic_external_link_id='" . addslashes($external_link_id) . "' ) ";
        //naao
        if (!($prs = $db->query($sql))) {
            die(_MD_D3FORUM_ERR_SQL . __LINE__);
        }
        while ($post_row = $db->fetchArray($prs)) {
            // topics array
            $topic_last_uid = intval($post_row['topic_last_uid']);
            $topic_last_post_time = intval($post_row['topic_last_post_time']);
            $topic_last_uname = XoopsUser::getUnameFromId($topic_last_uid, $xoopsModuleConfigs['use_name']);
            //naao usereal=1
            $topic_last_uname = $topic_last_uid > 0 ? $topic_last_uname : $myts->makeTboxData4Show($post_row['guest_name']);
            $tree[] = array('id' => intval($post_row['post_id']), 'subject' => $myts->makeTboxData4Show($post_row['subject'], $post_row['number_entity'], $post_row['special_entity']), 'post_time_formatted' => formatTimestamp($post_row['post_time'], 'm'), 'poster_uid' => $topic_last_uid, 'poster_uname' => $topic_last_uname, 'icon' => intval($post_row['icon']), 'depth_in_tree' => intval($post_row['depth_in_tree']), 'order_in_tree' => intval($post_row['order_in_tree']), 'topic_id' => intval($post_row['topic_id']), 'ul_in' => '<ul><li>', 'ul_out' => '</li></ul>');
        }
        $topics_count = count($tree);
    }
    // naao to
    require_once XOOPS_ROOT_PATH . '/class/template.php';
    $tpl = new XoopsTpl();
    $tpl->assign(array('mydirname' => $mydirname, 'mod_url' => XOOPS_URL . '/modules/' . $mydirname, 'mod_imageurl' => XOOPS_URL . '/modules/' . $mydirname . '/' . $xoopsModuleConfig['images_dir'], 'mod_config' => $xoopsModuleConfig, 'uid' => $uid, 'uname' => $poster_uname4disp, 'subject_raw' => $params['subject_raw'], 'postorder' => $postorder, 'icon_meanings' => $d3forum_icon_meanings, 'category' => $category4assign, 'forum' => $forum4assign, 'topics' => $topics, 'topic_hits' => intval(@$topic_hits), 'post_hits' => intval(@$post_hits), 'posts' => $posts, 'odr_options' => @$odr_options, 'solved_options' => @$solved_options, 'pagenav' => $pagenav, 'pos' => $pos, 'external_link_id' => $external_link_id, 'page' => 'listtopics', 'plugin_params' => $params, 'xoops_pagetitle' => $forum4assign['title'], 'antispam' => $antispam4assign));
    // naao from
    if (@$params['view'] != 'listtopics' && $external_link_id > 0) {
        $tpl->assign(array('tree' => $tree, 'tree_tp_count' => $topics_count));
    }
    // naao to
    $tpl->display($this_template);
}