当前位置: 首页>>代码示例>>PHP>>正文


PHP xoops_template_touch函数代码示例

本文整理汇总了PHP中xoops_template_touch函数的典型用法代码示例。如果您正苦于以下问题:PHP xoops_template_touch函数的具体用法?PHP xoops_template_touch怎么用?PHP xoops_template_touch使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了xoops_template_touch函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: tplsadmin_import_data

function tplsadmin_import_data($tplset, $tpl_file, $tpl_source, $lastmodified = 0)
{
    $db =& Database::getInstance();
    // check the file is valid template
    list($count) = $db->fetchRow($db->query("SELECT COUNT(*) FROM " . $db->prefix("tplfile") . " WHERE tpl_tplset='default' AND tpl_file='" . addslashes($tpl_file) . "'"));
    if (!$count) {
        return false;
    }
    // check the template exists in the tplset
    if ($tplset != 'default') {
        list($count) = $db->fetchRow($db->query("SELECT COUNT(*) FROM " . $db->prefix("tplfile") . " WHERE tpl_tplset='" . addslashes($tplset) . "' AND tpl_file='" . addslashes($tpl_file) . "'"));
        if ($count <= 0) {
            // copy from 'default' to the tplset
            $result = $db->query("SELECT * FROM " . $db->prefix("tplfile") . " WHERE tpl_tplset='default' AND tpl_file='" . addslashes($tpl_file) . "'");
            while ($row = $db->fetchArray($result)) {
                $db->queryF("INSERT INTO " . $db->prefix("tplfile") . " SET tpl_refid='" . addslashes($row['tpl_refid']) . "',tpl_module='" . addslashes($row['tpl_module']) . "',tpl_tplset='" . addslashes($tplset) . "',tpl_file='" . addslashes($tpl_file) . "',tpl_desc='" . addslashes($row['tpl_desc']) . "',tpl_type='" . addslashes($row['tpl_type']) . "'");
                $tpl_id = $db->getInsertId();
                $db->queryF("INSERT INTO " . $db->prefix("tplsource") . " SET tpl_id='{$tpl_id}', tpl_source=''");
            }
        }
    }
    // UPDATE just tpl_lastmodified and tpl_source
    $drs = $db->query("SELECT tpl_id FROM " . $db->prefix("tplfile") . " WHERE tpl_tplset='" . addslashes($tplset) . "' AND tpl_file='" . addslashes($tpl_file) . "'");
    while (list($tpl_id) = $db->fetchRow($drs)) {
        $db->queryF("UPDATE " . $db->prefix("tplfile") . " SET tpl_lastmodified='" . addslashes($lastmodified) . "',tpl_lastimported=UNIX_TIMESTAMP() WHERE tpl_id='{$tpl_id}'");
        $db->queryF("UPDATE " . $db->prefix("tplsource") . " SET tpl_source='" . addslashes($tpl_source) . "' WHERE tpl_id='{$tpl_id}'");
        xoops_template_touch($tpl_id);
    }
    return true;
}
开发者ID:BackupTheBerlios,项目名称:peakxoops-svn,代码行数:30,代码来源:tpls_functions.php

示例2: xpress_create_db_template

function xpress_create_db_template($file_name, $file_path, $mydirname, $mid)
{
    if (is_file($file_path)) {
        $tplfile_handler =& xoops_gethandler('tplfile');
        $tplfile =& $tplfile_handler->create();
        $mtime = intval(@filemtime($file_path));
        $tplfile->setVar('tpl_source', file_get_contents($file_path), true);
        $tplfile->setVar('tpl_refid', $mid);
        $tplfile->setVar('tpl_tplset', 'default');
        $tplfile->setVar('tpl_file', $file_name);
        $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)) {
            $msg = '<span style="color:#ff0000;">ERROR: Template Could not added to the database. <b>' . htmlspecialchars($file_name) . '</b> to the database.</span><br />';
        } else {
            $tplid = $tplfile->getVar('tpl_id');
            $msg = 'Template <b>' . htmlspecialchars($file_name) . '</b> added to the database. (ID: <b>' . $tplid . '</b>)<br />';
            // generate compiled file
            include_once XOOPS_ROOT_PATH . '/class/xoopsblock.php';
            include_once XOOPS_ROOT_PATH . '/class/template.php';
            if (!xoops_template_touch($tplid)) {
                $msg = '<span style="color:#ff0000;">ERROR: Failed compiling template <b>' . htmlspecialchars($file_name) . '</b>.</span><br />';
            } else {
                $msg = 'Template <b>' . htmlspecialchars($file_name) . '</b> compiled.</span><br />';
            }
        }
    }
    return $msg;
}
开发者ID:nouphet,项目名称:rata,代码行数:32,代码来源:xpress_templates_make.php

示例3: gnavi_onupdate_base

 function gnavi_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', 'gnavi_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)
     $check_sql = "SELECT arrowhtml FROM " . $db->prefix("{$mydirname}_text");
     if (!$db->query($check_sql)) {
         $db->queryF("ALTER TABLE " . $db->prefix("{$mydirname}_text") . " ADD arrowhtml tinyint(1) NOT NULL default '0',ADD addinfo text");
         $db->queryF("ALTER TABLE " . $db->prefix("{$mydirname}_cat") . " CHANGE icd icd int(5) unsigned NOT NULL default '0'");
         $db->queryF("ALTER TABLE " . $db->prefix("{$mydirname}_photos") . " CHANGE icd icd int(5) unsigned NOT NULL default '0'");
     }
     //version 0.13 -> version 0.7
     $check_sql = "SELECT * FROM " . $db->prefix("{$mydirname}_photos") . " USE INDEX(submitter)";
     if (!$db->query($check_sql)) {
         $db->queryF("ALTER TABLE " . $db->prefix("{$mydirname}_photos") . " ADD INDEX (submitter)");
         $db->queryF("ALTER TABLE " . $db->prefix("{$mydirname}_cat") . " CHANGE lat tmp_lat double(9,6) NOT NULL default '0'");
         $db->queryF("ALTER TABLE " . $db->prefix("{$mydirname}_cat") . " CHANGE lng lat double(9,6) NOT NULL default '0'");
         $db->queryF("ALTER TABLE " . $db->prefix("{$mydirname}_cat") . " CHANGE tmp_lat lng double(9,6) NOT NULL default '0'");
         $db->queryF("ALTER TABLE " . $db->prefix("{$mydirname}_photos") . " CHANGE lat tmp_lat double(9,6) NOT NULL default '0'");
         $db->queryF("ALTER TABLE " . $db->prefix("{$mydirname}_photos") . " CHANGE lng lat double(9,6) NOT NULL default '0'");
         $db->queryF("ALTER TABLE " . $db->prefix("{$mydirname}_photos") . " CHANGE tmp_lat lng double(9,6) NOT NULL default '0'");
     }
     //version 0.8 -> version 0.9
     $check_sql = "SELECT mtype FROM " . $db->prefix("{$mydirname}_photos");
     if (!$db->query($check_sql)) {
         $db->queryF("ALTER TABLE " . $db->prefix("{$mydirname}_photos") . " ADD mtype varchar(30) NOT NULL default ''");
         $db->queryF("ALTER TABLE " . $db->prefix("{$mydirname}_cat") . " ADD mtype varchar(30) NOT NULL default ''");
         $db->queryF("ALTER TABLE " . $db->prefix("{$mydirname}_cat") . " ADD   kmlurl varchar(150) NOT NULL default ''");
     }
     //version 0.95 -> version 0.96
     $check_sql = "SELECT rss FROM " . $db->prefix("{$mydirname}_photos");
     if (!$db->query($check_sql)) {
         $db->queryF("ALTER TABLE " . $db->prefix("{$mydirname}_photos") . " ADD rss varchar(255) NOT NULL default ''");
     }
     // TEMPLATES (all templates have been already removed by modulesadmin)
     $tplfile_handler =& xoops_gethandler('tplfile');
     // block templete must alldelete (for update from V2 module)
     $templates =& $tplfile_handler->find(null, 'block', null, $mydirname);
     $tcount = count($templates);
     if ($tcount > 0) {
         $ret[] = 'Deleting templates...';
         for ($i = 0; $i < $tcount; $i++) {
             if (!$tplfile_handler->delete($templates[$i])) {
                 $msgs[] = '<span style="color:#ff0000;">ERROR: Could not delete template ' . $templates[$i]->getVar('tpl_file', 's') . ' from the database. Template ID: <b>' . $templates[$i]->getVar('tpl_id', 's') . '</b></span><br />';
             } else {
                 $msgs[] = 'Template <b>' . $templates[$i]->getVar('tpl_file', 's') . '</b> deleted from the database. Template ID: <b>' . $templates[$i]->getVar('tpl_id', 's') . '</b><br />';
             }
         }
     }
     unset($templates);
     $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>)';
                     // 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);
     }
//.........这里部分代码省略.........
开发者ID:nouphet,项目名称:rata,代码行数:101,代码来源:onupdate.php

示例4: bulletin_onupdate_base


//.........这里部分代码省略.........
					}
				}
			}
		}
	}

	// 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 ) && substr( $file , -5 ) == '.html' ) {
				$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>)';
					// 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 ) ;

	// BLOCKS
	$tpl_path = dirname(__FILE__).'/templates/blocks' ;
	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 ) && substr( $file , -5 ) == '.html' ) {
				$mtime = intval( @filemtime( $file_path ) ) ;
				$tpl_file = $mydirname . '_' . $file;
				$tpl_source = file_get_contents( $file_path );
				$sql = "SELECT tpl_id, tpl_refid FROM ".$db->prefix('tplfile')." WHERE tpl_module='$mydirname' AND tpl_file='".mysql_escape_string($tpl_file)."'";
				list($tpl_id, $block_id) = $db->fetchRow($db->query($sql));
				if( empty($tpl_id) && empty($block_id)){
					$blocks_info = $module->getInfo('blocks');
					$show_func = '';
					foreach($blocks_info as $oneblock){
						if($tpl_file == $oneblock['template']){
							$show_func = $oneblock['show_func'];
							break;
开发者ID:nunoluciano,项目名称:uxcl,代码行数:67,代码来源:onupdate.php

示例5: time

             } else {
                 $tpl =& $tpltpl_handler->get($old_template[$upload_file]);
             }
             $tpl->setVar('tpl_lastmodified', time());
             $fp = @fopen($uploader->getSavedDestination(), 'r');
             $fsource = @fread($fp, filesize($uploader->getSavedDestination()));
             @fclose($fp);
             $tpl->setVar('tpl_source', $fsource, true);
             @unlink($uploader->getSavedDestination());
             if (!$tpltpl_handler->insert($tpl)) {
                 $msg[] = 'Failed inserting data for ' . $upload_file . ' to database';
             } else {
                 $msg[] = 'Template file <b>' . $upload_file . '</b> updated.';
                 if ($tplset == $xoopsConfig['template_set']) {
                     include_once XOOPS_ROOT_PATH . '/class/template.php';
                     if (xoops_template_touch($tpl, true)) {
                         $msg[] = 'Template file <b>' . $upload_file . '</b> compiled.';
                     }
                 }
             }
         }
     } else {
         if ($uploader->getMediaName() == '') {
             continue;
         } else {
             $msg[] = $uploader->getErrors();
         }
     }
 }
 xoops_cp_header();
 echo '<code>';
开发者ID:BackupTheBerlios,项目名称:soopa,代码行数:31,代码来源:main.php

示例6: attachfile_onupdate_base

 function attachfile_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', 'attachfile_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)
     // non
     // 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>)';
                     // 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;
 }
开发者ID:naao,项目名称:attachfile,代码行数:63,代码来源:onupdate.php

示例7: bulletin_oninstall_base

function bulletin_oninstall_base($module, $mydirname)
{
    // transations on module install
    global $ret;
    $db =& Database::getInstance();
    $mid = $module->getVar('mid');
    // for Cube 2.1
    if (defined('XOOPS_CUBE_LEGACY')) {
        $isCube = true;
        $root =& XCube_Root::getSingleton();
        $root->mDelegateManager->add('Legacy.Admin.Event.ModuleInstall.' . ucfirst($mydirname) . '.Success', 'bulletin_message_append_oninstall');
        $ret = array();
    } else {
        $isCube = false;
        if (!is_array($ret)) {
            $ret = array();
        }
    }
    // transations on module installation
    $bulletin_posting_permissions = array(1, 2, 3, 7);
    $gperm_handler = xoops_gethandler('groupperm');
    foreach ($bulletin_posting_permissions as $itemid) {
        $gperm =& $gperm_handler->create();
        $gperm->setVar('gperm_groupid', 1);
        $gperm->setVar('gperm_name', 'bulletin_permit');
        $gperm->setVar('gperm_modid', $mid);
        $gperm->setVar('gperm_itemid', $itemid);
        $gperm_handler->insert($gperm);
    }
    // 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...<br />";
        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[] = '&nbsp;&nbsp;Table <b>' . htmlspecialchars($prefix_mod . '_' . $prefixed_query[4]) . '</b> created.<br />';
                    $created_tables[] = $prefixed_query[4];
                } else {
                    $ret[] = '&nbsp;&nbsp;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) && substr($file, -5) == '.html') {
                $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 />';
                    // 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 />';
                    }
                }
            }
//.........这里部分代码省略.........
开发者ID:nouphet,项目名称:rata,代码行数:101,代码来源:oninstall.php

示例8: insertBlocks

 /**
  * Insert blocks from module into the database
  *
  * @return void
  */
 function insertBlocks()
 {
     global $xoopsConfig, $xoopsUser;
     $block_handler =& xoops_gethandler('block');
     $blocks = $this->getInfo('blocks');
     $this->setMessage('Building blocks...');
     if ($blocks != false) {
         $count = count($blocks);
         $showfuncs = array();
         $funcfiles = array();
         foreach (array_keys($blocks) as $i) {
             if (isset($blocks[$i]['show_func']) && $blocks[$i]['show_func'] != '' && isset($blocks[$i]['file']) && $blocks[$i]['file'] != '') {
                 $editfunc = isset($blocks[$i]['edit_func']) ? $blocks[$i]['edit_func'] : '';
                 $showfuncs[] = $blocks[$i]['show_func'];
                 $funcfiles[] = $blocks[$i]['file'];
                 $template = '';
                 if (isset($blocks[$i]['template']) && trim($blocks[$i]['template']) != '') {
                     $content =& $this->gettemplate($blocks[$i]['template'], true);
                 }
                 if (!isset($content) || !$content) {
                     $content = '';
                 } else {
                     $template = $blocks[$i]['template'];
                 }
                 $options = '';
                 if (!empty($blocks[$i]['options'])) {
                     $options = $blocks[$i]['options'];
                 }
                 $myts =& MyTextSanitizer::getInstance();
                 $criteria = new CriteriaCompo(new Criteria('mid', $this->getVar('mid')));
                 $criteria->add(new Criteria('show_func', $myts->addSlashes($blocks[$i]['show_func'])));
                 $criteria->add(new Criteria('func_file', $myts->addSlashes($blocks[$i]['file'])));
                 if (isset($blocks[$i]['template']) && trim($blocks[$i]['template']) != '') {
                     $criteria->add(new Criteria('template', $myts->addSlashes($blocks[$i]['template'])));
                 }
                 $block = $block_handler->getObjects($criteria);
                 if (isset($block[0])) {
                     $block = $block[0];
                     $this->setMessage("Updating existing block");
                 } else {
                     $this->setMessage("Creating new block");
                     $block =& $block_handler->create();
                     $block->setVar('mid', $this->getVar('mid'));
                     $block->setVar('dirname', $this->getVar('dirname'));
                     $block->setVar('show_func', $blocks[$i]['show_func'], true);
                     $block->setVar('func_file', $blocks[$i]['file'], true);
                     $block->setVar('isactive', 1);
                 }
                 $block->setVar('name', $blocks[$i]['name'], true);
                 $block->setVar('edit_func', $editfunc, true);
                 $block->setVar('options', explode('|', $options), true);
                 $block->setVar('template', $template, true);
                 $block->setVar('last_modified', time());
                 if (!$block_handler->insert($block)) {
                     $this->setMessage('&nbsp;&nbsp;ERROR: Could not insert ' . $blocks[$i]['name']);
                 } else {
                     $this->setMessage('&nbsp;&nbsp;Block <b>' . $blocks[$i]['name'] . '</b> inserted. Block ID: <b>' . $block->getVar('bid') . '</b>');
                     if ($template != '') {
                         //Update or insert template
                         $tplfile_handler =& xoops_gethandler('tplfile');
                         $tplfile =& $tplfile_handler->find('default', 'block', $block->getVar('bid'));
                         if (count($tplfile) == 0) {
                             $tplfile_new =& $tplfile_handler->create();
                             $tplfile_new->setVar('tpl_module', $this->getVar('dirname'));
                             $tplfile_new->setVar('tpl_refid', $block->getVar('bid'));
                             $tplfile_new->setVar('tpl_tplset', 'default');
                             $tplfile_new->setVar('tpl_file', $template, true);
                             $tplfile_new->setVar('tpl_type', 'block');
                         } else {
                             $tplfile_new = $tplfile[0];
                         }
                         $tplfile_new->setVar('tpl_source', $content, true);
                         $tplfile_new->setVar('tpl_desc', $blocks[$i]['description'], true);
                         $tplfile_new->setVar('tpl_lastmodified', time());
                         $tplfile_new->setVar('tpl_lastimported', 0);
                         if (!$tplfile_handler->insert($tplfile_new)) {
                             $this->setMessage('&nbsp;&nbsp;<span style="color:#ff0000;">ERROR: Could not insert template <b>' . $blocks[$i]['template'] . '</b>.</span>');
                         } else {
                             $this->setMessage('&nbsp;&nbsp;Template <b>' . $blocks[$i]['template'] . '</b> inserted.');
                             if (isset($xoopsConfig['template_set']) && $xoopsConfig['template_set'] == 'default') {
                                 if (!xoops_template_touch($tplfile_new)) {
                                     $this->setMessage('&nbsp;&nbsp;<span style="color:#ff0000;">ERROR: Could not compile template <b>' . $blocks[$i]['template'] . '</b>.</span>');
                                 } else {
                                     $this->setMessage('&nbsp;&nbsp;Template <b>' . $blocks[$i]['template'] . '</b> compiled.');
                                 }
                             }
                         }
                     }
                 }
                 $blockids[] = $block->getVar('bid');
             }
         }
     }
     $block_arr = $block_handler->getByModule($this->getVar('mid'));
     if (count($block_arr) > 0) {
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:soopa,代码行数:101,代码来源:module.php

示例9: xsns_oninstall


//.........这里部分代码省略.........
					return false ;
				}
				if( ! $db->query( $prefixed_query[0] ) ) {
					$ret[] = '<b>'.htmlspecialchars( $db->error() ).'</b><br />' ;
					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 ) == '.' || !preg_match('/(\.html$)|(\.css$)/i', $file)){
				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 />';
					// 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 ) ;
	
	
	// Set default categories
	$ini_category_list = array(
		// 小カテゴリ名, 表示順, 中カテゴリID
		array(constant($constpref.'_CATEGORY_1'), 1, 1),
		array(constant($constpref.'_CATEGORY_2'), 2, 1),
		array(constant($constpref.'_CATEGORY_3'), 3, 1),
		array(constant($constpref.'_CATEGORY_4'), 50, 1),
	);
	
	$sql_values = array();
	$selector_arr = array();
	$id = 1;
	
	foreach($ini_category_list as $category){
		$values = array();
		foreach($category as $v){
			$values[] = "'".$v."'";
		}
		$sql_values[] = "(".implode(',', $values).")";
		$selector_arr[] = "<a href=\"".XOOPS_URL."/modules/".$mydirname."/?cat_id=".($id++)."\">".$category[0]."<nobr><small>(0)</small></nobr></a>";
	}
	
	if(count($sql_values) > 0 || count($selector_arr) > 0){
		$sql = "INSERT INTO ".$db->prefix($mydirname.'_c_commu_category').
				" (name,sort_order,c_commu_category_parent_id) VALUES ".
				implode(",", $sql_values);
		if($db->query($sql)){
			$sql = "INSERT INTO ".$db->prefix($mydirname.'_c_commu_category_parent').
					" (name,sort_order,selector) VALUES".
					" ('".constant($constpref.'_CATEGORY')."', '1', '".implode("&nbsp;- ", $selector_arr)."')";
			return $db->query($sql);
		}
		else{
			return false;
		}
	}
	return true;
}
开发者ID:nunoluciano,项目名称:uxcl,代码行数:101,代码来源:oninstall.php

示例10: xoops_module_update


//.........这里部分代码省略.........
            foreach ($templates as $tpl) {
                $tpl['file'] = trim($tpl['file']);
                // START irmtfan solve templates duplicate issue
                // if (!in_array($tpl['file'], $delng)) { // irmtfan bug fix: remove codes for delete templates
                $type = isset($tpl['type']) ? $tpl['type'] : 'module';
                if (preg_match("/\\.css\$/i", $tpl['file'])) {
                    $type = 'css';
                }
                $criteria = new CriteriaCompo();
                $criteria->add(new Criteria('tpl_refid', $newmid), 'AND');
                $criteria->add(new Criteria('tpl_module', $dirname), 'AND');
                $criteria->add(new Criteria('tpl_tplset', 'default'), 'AND');
                $criteria->add(new Criteria('tpl_file', $tpl['file']), 'AND');
                $criteria->add(new Criteria('tpl_type', $type), 'AND');
                $tplfiles = $tplfile_handler->getObjects($criteria);
                $tpldata =& xoops_module_gettemplate($dirname, $tpl['file'], $type);
                $tplfile = empty($tplfiles) ? $tplfile_handler->create() : $tplfiles[0];
                // END irmtfan solve templates duplicate issue
                $tplfile->setVar('tpl_refid', $newmid);
                $tplfile->setVar('tpl_lastimported', 0);
                $tplfile->setVar('tpl_lastmodified', time());
                $tplfile->setVar('tpl_type', $type);
                $tplfile->setVar('tpl_source', $tpldata, true);
                $tplfile->setVar('tpl_module', $dirname);
                $tplfile->setVar('tpl_tplset', 'default');
                $tplfile->setVar('tpl_file', $tpl['file'], true);
                $tplfile->setVar('tpl_desc', $tpl['description'], true);
                if (!$tplfile_handler->insert($tplfile)) {
                    $msgs[] = '&nbsp;&nbsp;<span style="color:#ff0000;">' . sprintf(_AM_SYSTEM_MODULES_TEMPLATE_ADD_ERROR, '<strong>' . $tpl['file'] . '</strong>') . '</span>';
                } else {
                    $newid = $tplfile->getVar('tpl_id');
                    $msgs[] = '&nbsp;&nbsp;' . sprintf(_AM_SYSTEM_MODULES_TEMPLATE_INSERT_DATA, '<strong>' . $tpl['file'] . '</strong>');
                    if ($xoopsConfig['template_set'] === 'default') {
                        if (!xoops_template_touch($newid)) {
                            $msgs[] = '&nbsp;&nbsp;<span style="color:#ff0000;">' . sprintf(_AM_SYSTEM_MODULES_TEMPLATE_RECOMPILE_ERROR, '<strong>' . $tpl['file'] . '</strong>') . '</span>';
                        } else {
                            $msgs[] = '&nbsp;&nbsp;<span>' . sprintf(_AM_SYSTEM_MODULES_TEMPLATE_RECOMPILE, '<strong>' . $tpl['file'] . '</strong>') . '</span>';
                        }
                    }
                }
                unset($tpldata);
                // irmtfan bug fix: remove codes for delete templates
                /*
                } else {
                    $msgs[] = '&nbsp;&nbsp;<span style="color:#ff0000;">'.sprintf(_AM_SYSTEM_MODULES_TEMPLATE_DELETE_OLD_ERROR, "<strong>".$tpl['file']."</strong>").'</span>';
                }
                */
                // irmtfan bug fix: remove codes for delete templates
            }
        }
        $blocks = $module->getInfo('blocks');
        $msgs[] = _AM_SYSTEM_MODULES_BLOCKS_REBUILD;
        if ($blocks != false) {
            $showfuncs = array();
            $funcfiles = array();
            foreach ($blocks as $i => $block) {
                if (isset($block['show_func']) && $block['show_func'] != '' && isset($block['file']) && $block['file'] != '') {
                    $editfunc = isset($block['edit_func']) ? $block['edit_func'] : '';
                    $showfuncs[] = $block['show_func'];
                    $funcfiles[] = $block['file'];
                    $template = '';
                    if (isset($block['template']) && trim($block['template']) != '') {
                        $content =& xoops_module_gettemplate($dirname, $block['template'], 'blocks');
                    }
                    if (!$content) {
                        $content = '';
开发者ID:geekwright,项目名称:XoopsCore25,代码行数:67,代码来源:modulesadmin.php

示例11: array

}

// EDIT UPDATE
$errors = array() ;
if( ! empty( $_POST['do_modifycont'] ) || ! empty( $_POST['do_modify'] ) ) {
	if ( ! $xoopsGTicket->check( true , 'dbcss' ) ) {
		redirect_header(XOOPS_URL.'/modules/'.$mydirname.'/admin/index.php',3,$xoopsGTicket->getErrors());
	}

	$post_source = addslashes($myts->stripSlashesGPC( $_POST['tpl_source'] ) );

	$result = $db->query( "UPDATE ".$db->prefix("tplsource")." SET tpl_source='".$post_source."' WHERE tpl_id=$tpl_id" ) ;
	if( ! $result ) $errors[] = $tpl_id ;
	$result = $db->query( "UPDATE ".$db->prefix("tplfile")." SET tpl_lastmodified=UNIX_TIMESTAMP() WHERE tpl_id=$tpl_id" ) ;
	if( ! $result ) $errors[] = $tpl_id ;
	xoops_template_touch( $tpl_id ) ;

	// CONTINUE OR END ?
	if( ! empty( $_POST['do_modifycont'] ) ) {
		redirect_header(  XOOPS_URL."/modules/$mydirname/admin/index.php?page=mytplsform&tpl_id=".$tpl_id."&#dbcss_tplsform_top." , 2 , $errors ? sprintf( _MD_DBCSS_ERROR_MESSEAGE , implode( ',' , $errors ) ) : _MD_DBCSS_MYTPLSFORM_UPDATED ) ;
	} else {
		if( ! empty( $bid ) ) {
			redirect_header( XOOPS_URL."/modules/$mydirname/admin/index.php?mode=admin&lib=altsys&page=myblocksadmin&op=edit&bid=".$bid , 2 , $errors ? sprintf( _MD_DBCSS_ERROR_MESSEAGE , implode( ',' , $errors ) ) : _MD_DBCSS_MYTPLSFORM_UPDATED ) ;
		} else {
			redirect_header( XOOPS_URL."/modules/$mydirname/admin/index.php?page=export" , 2 , $errors ? sprintf( _MD_DBCSS_ERROR_MESSEAGE , implode( ',' , $errors ) ) : _MD_DBCSS_MYTPLSFORM_UPDATED ) ;
		}
	}
	exit() ;
}

// DISPLAY STAGE
开发者ID:nunoluciano,项目名称:uxcl,代码行数:31,代码来源:mytplsform.php

示例12: dbtheme_oninstall_base


//.........这里部分代码省略.........
                     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 />';
                     }
                 }
             }
         }
     }
     // IMPORT THE SELECTED THEME AS THIS MODULE'S TEMPLATES
     $tplfile_handler =& xoops_gethandler('tplfile');
     /*************** BEGIN DBTHEME SPECIFIC PART ******************/
     // set weight=0
     $db->queryF("UPDATE " . $db->prefix("modules") . " SET weight=0 WHERE mid={$mid}");
     // set tpl_path
     $module_handler =& xoops_gethandler('module');
     $module =& $module_handler->getByDirname($mydirname);
     $config_handler =& xoops_gethandler('config');
     $mod_config =& $config_handler->getConfigsByCat(0, $module->getVar('mid'));
     if (file_exists(dirname(__FILE__) . '/templates/theme.html')) {
         $tpl_path = dirname(__FILE__) . '/templates';
     } else {
         if (!empty($mod_config['base_theme'])) {
             $tpl_path = XOOPS_ROOT_PATH . '/themes/' . $mod_config['base_theme'];
         } else {
             $tpl_path = XOOPS_ROOT_PATH . '/themes/' . $GLOBALS['xoopsConfig']['theme_set'];
         }
     }
     /*************** END DBTHEME SPECIFIC PART ******************/
     // 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) && in_array(strrchr($file, '.'), array('.html', '.css', '.js'))) {
                 $mtime = intval(@filemtime($file_path));
                 $tplfile =& $tplfile_handler->create();
                 /*************** BEGIN DBTHEME SPECIFIC PART ******************/
                 // modify the theme/css
                 $tpl_source = file_get_contents($file_path);
                 $searches = array();
                 $replacements = array();
                 if (strrchr($file, '.') == '.html') {
                     // CSS hooking
                     $searches[] = '/\\"\\<\\{\\$xoops_imageurl\\}\\>([0-9a-zA-Z_-]+)\\.(css|html|js)\\"/';
                     $replacements[] = '"<{$xoops_url}>/modules/' . $mydirname . '/?template=$1.$2' . '"';
                 } else {
                     if (strrchr($file, '.') == '.css') {
                         // url() hooking
                         $searches[] = '#url\\(\\s*([\\"\']?)([0-9a-z./]{3})#i';
                         $replacements[] = 'url($1<{$xoops_imageurl}>$2';
                     }
                 }
                 $tplfile->setVar('tpl_source', preg_replace($searches, $replacements, $tpl_source));
                 $mtime = time();
                 /*************** END DBTHEME SPECIFIC PART ******************/
                 //				$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 />';
                     // 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;
 }
开发者ID:BackupTheBerlios,项目名称:peakxoops-svn,代码行数:101,代码来源:oninstall.php

示例13: pico_onupdate_base


//.........这里部分代码省略.........
     }
     // 0.2 -> 0.9
     $check_sql = "SELECT cat_vpath FROM " . $db->prefix($mydirname . "_categories");
     if (!$db->query($check_sql)) {
         $db->queryF("ALTER TABLE " . $db->prefix($mydirname . "_categories") . " ADD   `cat_vpath` varchar(255) AFTER `cat_id`, ADD UNIQUE KEY (`cat_vpath`)");
         $db->queryF("ALTER TABLE " . $db->prefix($mydirname . "_contents") . " ADD   `vpath` varchar(255) AFTER `content_id`, ADD UNIQUE KEY (`vpath`)");
     }
     // 0.9 -> 0.95
     $check_sql = "SELECT cat_vpath_mtime FROM " . $db->prefix($mydirname . "_categories");
     if (!$db->query($check_sql)) {
         $db->queryF("ALTER TABLE " . $db->prefix($mydirname . "_categories") . " ADD cat_created_time int(10) NOT NULL default 0, ADD cat_modified_time int(10) NOT NULL default 0, ADD cat_vpath_mtime int(10) NOT NULL default 0");
         $db->queryF("ALTER TABLE " . $db->prefix($mydirname . "_contents") . " MODIFY weight smallint(5) NOT NULL default 0");
     }
     // 1.0 -> 1.1/1.2
     $check_sql = "SELECT COUNT(*) FROM " . $db->prefix($mydirname . "_content_histories");
     if (!$db->query($check_sql)) {
         $db->queryF("CREATE TABLE " . $db->prefix($mydirname . "_content_histories") . " ( content_history_id int(10) unsigned NOT NULL auto_increment, content_id int(10) unsigned NOT NULL default 0, vpath varchar(255), cat_id smallint(5) unsigned NOT NULL default 0, created_time int(10) NOT NULL default 0, modified_time int(10) NOT NULL default 0, poster_uid mediumint(8) unsigned NOT NULL default 0, poster_ip varchar(15) NOT NULL default '', modifier_uid mediumint(8) unsigned NOT NULL default 0, modifier_ip varchar(15) NOT NULL default '', subject varchar(255) NOT NULL default '', htmlheader mediumtext, body mediumtext, filters text, PRIMARY KEY (content_history_id), KEY (content_id), KEY (created_time), KEY (modified_time), KEY (modifier_uid) ) TYPE=MyISAM");
         $db->queryF("ALTER TABLE " . $db->prefix($mydirname . "_contents") . " MODIFY htmlheader mediumtext, MODIFY htmlheader_waiting mediumtext, MODIFY body mediumtext, MODIFY body_waiting mediumtext, MODIFY body_cached mediumtext");
     }
     // 1.1/1.2 -> 1.3/1.4
     $check_sql = "SELECT cat_redundants FROM " . $db->prefix($mydirname . "_categories");
     if (!$db->query($check_sql)) {
         $db->queryF("ALTER TABLE " . $db->prefix($mydirname . "_categories") . " MODIFY cat_id smallint(5) unsigned NOT NULL, ADD cat_redundants text AFTER cat_vpath_mtime");
         $db->queryF("ALTER TABLE " . $db->prefix($mydirname . "_contents") . " ADD comments_count int(10) unsigned NOT NULL default 0 AFTER votes_count");
         $db->queryF("INSERT INTO " . $db->prefix($mydirname . "_categories") . " (cat_id,pid,cat_title) VALUES (0,0xffff,'TOP')");
     }
     // 1.3/1.4 -> 1.5/1.6
     $check_sql = "SELECT COUNT(*) FROM " . $db->prefix($mydirname . "_content_extras");
     if (!$db->query($check_sql)) {
         $db->queryF("CREATE TABLE " . $db->prefix($mydirname . "_content_extras") . " ( content_extra_id int(10) unsigned NOT NULL auto_increment, content_id int(10) unsigned NOT NULL default 0, extra_type varchar(255) NOT NULL default '', created_time int(10) NOT NULL default 0, modified_time int(10) NOT NULL default 0, data mediumtext, PRIMARY KEY (content_extra_id), KEY (content_id), KEY (extra_type), KEY (created_time) ) TYPE=MyISAM");
         $db->queryF("ALTER TABLE " . $db->prefix($mydirname . "_contents") . " ADD `locked` tinyint(1) NOT NULL default 0 AFTER subject_waiting, ADD `redundants` text AFTER filters");
     }
     $check_sql = "SHOW CREATE TABLE " . $db->prefix($mydirname . "_content_histories");
     list(, $create_sql) = $db->fetchRow($db->queryF($check_sql));
     if (stristr($create_sql, '`body` text')) {
         $db->queryF("ALTER TABLE " . $db->prefix($mydirname . "_content_histories") . " MODIFY `htmlheader` mediumtext, MODIFY `body` mediumtext");
     }
     $db->queryF("ALTER TABLE " . $db->prefix($mydirname . "_categories") . " MODIFY `cat_redundants` mediumtext");
     // 1.5/1.6 -> 1.7/1.8
     $check_sql = "SELECT cat_permission_id FROM " . $db->prefix($mydirname . "_categories");
     if (!$db->query($check_sql)) {
         $db->queryF("ALTER TABLE " . $db->prefix($mydirname . "_contents") . " ADD permission_id int(10) unsigned NOT NULL default 0 AFTER `content_id`, ADD expiring_time int(10) NOT NULL default 0x7fffffff AFTER `modified_time`, ADD last_cached_time int(10) NOT NULL default 0 AFTER `modified_time`, ADD `extra_fields` mediumtext AFTER `filters`, ADD `for_search` mediumtext AFTER `redundants`, MODIFY `redundants` mediumtext, ADD `tags` text AFTER `filters`, ADD KEY (`modified_time`), ADD KEY (`expiring_time`), ADD KEY (`permission_id`)");
         $db->queryF("UPDATE " . $db->prefix($mydirname . "_contents") . " SET `expiring_time`=0x7fffffff");
         $db->queryF("ALTER TABLE " . $db->prefix($mydirname . "_content_histories") . " ADD tags text, ADD extra_fields mediumtext");
         $db->queryF("ALTER TABLE " . $db->prefix($mydirname . "_categories") . " ADD `cat_permission_id` int(10) unsigned NOT NULL AFTER `cat_id`, ADD KEY (`cat_permission_id`)");
         $db->queryF("UPDATE " . $db->prefix($mydirname . "_categories") . " SET `cat_permission_id`=`cat_id`");
         $db->queryF("CREATE TABLE " . $db->prefix($mydirname . "_tags") . " ( label varchar(255) NOT NULL default '', weight int(10) unsigned NOT NULL default 0, count int(10) unsigned NOT NULL default 0, content_ids mediumtext, created_time int(10) NOT NULL default 0, modified_time int(10) NOT NULL default 0, PRIMARY KEY (label), KEY (count), KEY (weight), KEY (created_time) ) TYPE=MyISAM");
     }
     // 1.7/1.8 -> 1.9/2.0 (1)
     $check_sql = "SELECT * FROM " . $db->prefix($mydirname . "_content_ef_sortables");
     if (!$db->query($check_sql)) {
         $db->queryF("ALTER TABLE " . $db->prefix($mydirname . "_categories") . " ADD `cat_extra_fields` mediumtext AFTER `cat_vpath_mtime`;");
         $db->queryF("CREATE TABLE " . $db->prefix($mydirname . "_content_ef_sortables") . " ( content_id int(10) unsigned NOT NULL default 0, ef0 char(64) NOT NULL default '', ef1 char(64) NOT NULL default '', ef2 char(64) NOT NULL default '', ef3 char(64) NOT NULL default '', ef4 char(64) NOT NULL default '', ef5 char(64) NOT NULL default '', ef6 char(64) NOT NULL default '', ef7 char(64) NOT NULL default '', ef8 char(64) NOT NULL default '', ef9 char(64) NOT NULL default '', KEY (ef0), KEY (ef1), KEY (ef2), KEY (ef3), KEY (ef4), KEY (ef5), KEY (ef6), KEY (ef7), KEY (ef8), KEY (ef9), PRIMARY KEY (content_id) ) TYPE=MyISAM");
     }
     // 1.7/1.8 -> 1.9/2.0 (2)
     // content_histories ...
     // 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>)';
                     // 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;
 }
开发者ID:BackupTheBerlios,项目名称:peakxoops-svn,代码行数:101,代码来源:onupdate.php

示例14: xoops_gethandler

         $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;
         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]);
             } else {
                 // not found, so compile 'default' template file
                 xoops_template_touch($dtemplates[$i]);
             }
         }
         // 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'))) {
             } else {
                 fwrite($fp, $imagefiles[$i]->getVar('imgsetimg_body'));
                 fclose($fp);
             }
         }
     }
     $tpl_updated = true;
 }
开发者ID:BackupTheBerlios,项目名称:xoops4-svn,代码行数:31,代码来源:main.php

示例15: dbtheme_onupdate_base

 function dbtheme_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', 'dbtheme_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 ''");
     }
     // IMPORT THE SELECTED THEME AS THIS MODULE'S TEMPLATES
     $tplfile_handler =& xoops_gethandler('tplfile');
     /*************** BEGIN DBTHEME SPECIFIC PART ******************/
     $module_handler =& xoops_gethandler('module');
     $module =& $module_handler->getByDirname($mydirname);
     $config_handler =& xoops_gethandler('config');
     $mod_config =& $config_handler->getConfigsByCat(0, $module->getVar('mid'));
     if (file_exists(dirname(__FILE__) . '/templates/theme.html')) {
         $tpl_path = dirname(__FILE__) . '/templates';
     } else {
         if (!empty($mod_config['base_theme'])) {
             $tpl_path = XOOPS_ROOT_PATH . '/themes/' . $mod_config['base_theme'];
         } else {
             $tpl_path = XOOPS_ROOT_PATH . '/themes/' . $GLOBALS['xoopsConfig']['theme_set'];
         }
     }
     /*************** END DBTHEME SPECIFIC PART ******************/
     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) && in_array(strrchr($file, '.'), array('.html', '.css', '.js'))) {
                 $mtime = intval(@filemtime($file_path));
                 $tplfile =& $tplfile_handler->create();
                 /*************** BEGIN DBTHEME SPECIFIC PART ******************/
                 $tpl_source = file_get_contents($file_path);
                 $searches = array();
                 $replacements = array();
                 if (strrchr($file, '.') == '.html') {
                     // CSS hooking
                     $searches[] = '/\\"\\<\\{\\$xoops_imageurl\\}\\>([0-9a-zA-Z_-]+)\\.(css|html|js)\\"/';
                     $replacements[] = '"<{$xoops_url}>/modules/' . $mydirname . '/?template=$1.$2' . '"';
                 } else {
                     if (strrchr($file, '.') == '.css') {
                         // url() hooking
                         $searches[] = '#url\\(\\s*([\\"\']?)([0-9a-z./]{3})#i';
                         $replacements[] = 'url($1<{$xoops_imageurl}>$2';
                     }
                 }
                 $tplfile->setVar('tpl_source', preg_replace($searches, $replacements, $tpl_source));
                 $mtime = time();
                 /*************** END DBTHEME SPECIFIC PART ******************/
                 //				$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>)';
                     // 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;
 }
开发者ID:BackupTheBerlios,项目名称:peakxoops-svn,代码行数:99,代码来源:onupdate.php


注:本文中的xoops_template_touch函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。