function d3pipes_onupdate_base($module, $mydirname) { // transations on module update global $msgs; // TODO :-D // for Cube 2.1 if (defined('XOOPS_CUBE_LEGACY')) { $root =& XCube_Root::getSingleton(); $root->mDelegateManager->add('Legacy.Admin.Event.ModuleUpdate.' . ucfirst($mydirname) . '.Success', 'd3pipes_message_append_onupdate'); $msgs = array(); } else { if (!is_array($msgs)) { $msgs = array(); } } $db =& Database::getInstance(); $mid = $module->getVar('mid'); // TABLES (write here ALTER TABLE etc. if necessary) // configs (Though I know it is not a recommended way...) $check_sql = "SHOW COLUMNS FROM " . $db->prefix("config") . " LIKE 'conf_title'"; if (($result = $db->query($check_sql)) && ($myrow = $db->fetchArray($result)) && @$myrow['Type'] == 'varchar(30)') { $db->queryF("ALTER TABLE " . $db->prefix("config") . " MODIFY `conf_title` varchar(255) NOT NULL default '', MODIFY `conf_desc` varchar(255) NOT NULL default ''"); } // 0.2 -> 0.3 $check_sql = "SELECT comments_count FROM " . $db->prefix($mydirname . "_clippings"); if (!$db->query($check_sql)) { $db->queryF("ALTER TABLE " . $db->prefix($mydirname . "_clippings") . " ADD comments_count smallint NOT NULL default 0 AFTER `weight`"); } // TEMPLATES (all templates have been already removed by modulesadmin) $tplfile_handler =& xoops_gethandler('tplfile'); $tpl_path = dirname(__FILE__) . '/templates'; if ($handler = @opendir($tpl_path . '/')) { while (($file = readdir($handler)) !== false) { if (substr($file, 0, 1) == '.') { continue; } $file_path = $tpl_path . '/' . $file; if (is_file($file_path)) { $mtime = intval(@filemtime($file_path)); $tplfile =& $tplfile_handler->create(); $tplfile->setVar('tpl_source', file_get_contents($file_path), true); $tplfile->setVar('tpl_refid', $mid); $tplfile->setVar('tpl_tplset', 'default'); $tplfile->setVar('tpl_file', $mydirname . '_' . $file); $tplfile->setVar('tpl_desc', '', true); $tplfile->setVar('tpl_module', $mydirname); $tplfile->setVar('tpl_lastmodified', $mtime); $tplfile->setVar('tpl_lastimported', 0); $tplfile->setVar('tpl_type', 'module'); if (!$tplfile_handler->insert($tplfile)) { $msgs[] = '<span style="color:#ff0000;">ERROR: Could not insert template <b>' . htmlspecialchars($mydirname . '_' . $file) . '</b> to the database.</span>'; } else { $tplid = $tplfile->getVar('tpl_id'); $msgs[] = 'Template <b>' . htmlspecialchars($mydirname . '_' . $file) . '</b> added to the database. (ID: <b>' . $tplid . '</b>)'; require_once XOOPS_TRUST_PATH . '/libs/altsys/include/altsys_functions.php'; altsys_clear_templates_c(); // generate compiled file /*include_once XOOPS_ROOT_PATH.'/class/xoopsblock.php' ; include_once XOOPS_ROOT_PATH.'/class/template.php' ; if( ! xoops_template_touch( $tplid ) ) { $msgs[] = '<span style="color:#ff0000;">ERROR: Failed compiling template <b>'.htmlspecialchars($mydirname.'_'.$file).'</b>.</span>'; } else { $msgs[] = 'Template <b>'.htmlspecialchars($mydirname.'_'.$file).'</b> compiled.</span>'; }*/ } } } closedir($handler); } include_once XOOPS_ROOT_PATH . '/class/xoopsblock.php'; include_once XOOPS_ROOT_PATH . '/class/template.php'; xoops_template_clear_module_cache($mid); return true; }
function d3pipes_oninstall_base($module, $mydirname) { // transations on module install global $ret; // TODO :-D // for Cube 2.1 if (defined('XOOPS_CUBE_LEGACY')) { $root =& XCube_Root::getSingleton(); $root->mDelegateManager->add('Legacy.Admin.Event.ModuleInstall.' . ucfirst($mydirname) . '.Success', 'd3pipes_message_append_oninstall'); $ret = array(); } else { if (!is_array($ret)) { $ret = array(); } } $db =& Database::getInstance(); $mid = $module->getVar('mid'); // TABLES (loading mysql.sql) $sql_file_path = dirname(__FILE__) . '/sql/mysql.sql'; $prefix_mod = $db->prefix() . '_' . $mydirname; if (file_exists($sql_file_path)) { $ret[] = "SQL file found at <b>" . htmlspecialchars($sql_file_path) . "</b>.<br /> Creating tables..."; if (file_exists(XOOPS_ROOT_PATH . '/class/database/oldsqlutility.php')) { include_once XOOPS_ROOT_PATH . '/class/database/oldsqlutility.php'; $sqlutil = new OldSqlUtility(); } else { include_once XOOPS_ROOT_PATH . '/class/database/sqlutility.php'; $sqlutil = new SqlUtility(); } $sql_query = trim(file_get_contents($sql_file_path)); $sqlutil->splitMySqlFile($pieces, $sql_query); $created_tables = array(); foreach ($pieces as $piece) { $prefixed_query = $sqlutil->prefixQuery($piece, $prefix_mod); if (!$prefixed_query) { $ret[] = "Invalid SQL <b>" . htmlspecialchars($piece) . "</b><br />"; return false; } if (!$db->query($prefixed_query[0])) { $ret[] = '<b>' . htmlspecialchars($db->error()) . '</b><br />'; //var_dump( $db->error() ) ; return false; } else { if (!in_array($prefixed_query[4], $created_tables)) { $ret[] = 'Table <b>' . htmlspecialchars($prefix_mod . '_' . $prefixed_query[4]) . '</b> created.<br />'; $created_tables[] = $prefixed_query[4]; } else { $ret[] = 'Data inserted to table <b>' . htmlspecialchars($prefix_mod . '_' . $prefixed_query[4]) . '</b>.</br />'; } } } } // TEMPLATES $tplfile_handler =& xoops_gethandler('tplfile'); $tpl_path = dirname(__FILE__) . '/templates'; if ($handler = @opendir($tpl_path . '/')) { while (($file = readdir($handler)) !== false) { if (substr($file, 0, 1) == '.') { continue; } $file_path = $tpl_path . '/' . $file; if (is_file($file_path)) { $mtime = intval(@filemtime($file_path)); $tplfile =& $tplfile_handler->create(); $tplfile->setVar('tpl_source', file_get_contents($file_path), true); $tplfile->setVar('tpl_refid', $mid); $tplfile->setVar('tpl_tplset', 'default'); $tplfile->setVar('tpl_file', $mydirname . '_' . $file); $tplfile->setVar('tpl_desc', '', true); $tplfile->setVar('tpl_module', $mydirname); $tplfile->setVar('tpl_lastmodified', $mtime); $tplfile->setVar('tpl_lastimported', 0); $tplfile->setVar('tpl_type', 'module'); if (!$tplfile_handler->insert($tplfile)) { $ret[] = '<span style="color:#ff0000;">ERROR: Could not insert template <b>' . htmlspecialchars($mydirname . '_' . $file) . '</b> to the database.</span><br />'; } else { $tplid = $tplfile->getVar('tpl_id'); $ret[] = 'Template <b>' . htmlspecialchars($mydirname . '_' . $file) . '</b> added to the database. (ID: <b>' . $tplid . '</b>)<br />'; require_once XOOPS_TRUST_PATH . '/libs/altsys/include/altsys_functions.php'; altsys_clear_templates_c(); // generate compiled file /*include_once XOOPS_ROOT_PATH.'/class/xoopsblock.php' ; include_once XOOPS_ROOT_PATH.'/class/template.php' ; if( ! xoops_template_touch( $tplid ) ) { $ret[] = '<span style="color:#ff0000;">ERROR: Failed compiling template <b>'.htmlspecialchars($mydirname.'_'.$file).'</b>.</span><br />'; } else { $ret[] = 'Template <b>'.htmlspecialchars($mydirname.'_'.$file).'</b> compiled.</span><br />'; }*/ } } } closedir($handler); } include_once XOOPS_ROOT_PATH . '/class/xoopsblock.php'; include_once XOOPS_ROOT_PATH . '/class/template.php'; xoops_template_clear_module_cache($mid); return true; }
function altsys_template_touch($tpl_id) { if (in_array(altsys_get_core_type(), array(ALTSYS_CORE_TYPE_X20S, ALTSYS_CORE_TYPE_X23P, ALTSYS_CORE_TYPE_X25))) { // need to delete all files under templates_c/ altsys_clear_templates_c(); } else { // just touch the template xoops_template_touch($tpl_id); } }
} // if default template set has been changed if (!$tpl_updated && $config->getVar('conf_catid') == XOOPS_CONF && $config->getVar('conf_name') == 'template_set') { // clear cached/compiled files and regenerate them if default theme has been changed if ($xoopsConfig['template_set'] != $_POST[$config->getVar('conf_name')]) { $newtplset = $_POST[$config->getVar('conf_name')]; // clear all compiled and cachedfiles $xoopsTpl->clear_compiled_tpl(); // generate compiled files for the new theme // block files only for now.. $tplfile_handler =& xoops_gethandler('tplfile'); $dtemplates =& $tplfile_handler->find('default', 'block'); $dcount = count($dtemplates); // need to do this to pass to xoops_template_touch function $GLOBALS['xoopsConfig']['template_set'] = $newtplset; altsys_clear_templates_c(); /* for ($i = 0; $i < $dcount; $i++) { $found =& $tplfile_handler->find($newtplset, 'block', $dtemplates[$i]->getVar('tpl_refid'), null); if (count($found) > 0) { // template for the new theme found, compile it xoops_template_touch($found[0]->getVar('tpl_id')); } else { // not found, so compile 'default' template file xoops_template_touch($dtemplates[$i]->getVar('tpl_id')); } }*/ // generate image cache files from image binary data, save them under cache/ $image_handler =& xoops_gethandler('imagesetimg'); $imagefiles =& $image_handler->getObjects(new Criteria('tplset_name', $newtplset), true); foreach (array_keys($imagefiles) as $i) { if (!($fp = fopen(XOOPS_CACHE_PATH . '/' . $newtplset . '_' . $imagefiles[$i]->getVar('imgsetimg_file'), 'wb'))) {