createpotfile.php

来自「一款基于PHP的网络日记程序。WikyBlog支持:多用户的 BLOG」· PHP 代码 · 共 75 行

PHP
75
字号
<?phpdefined('WikyBlog') or die("Not an entry point...");global $page;if( $_SESSION['userlevel'] !== 4){	$page->contentA['Admin Only'] = 'You must be an administrator to access this page.';	return;}// an example pot file//http://svn.automattic.com/wordpress-i18n/pot/trunk/wordpress.potclass createPOTfile{		function createPOTfile(){		global $page,$dbObject,$pageOwner,$includeDir;		$page->displayTitle = 'Create POT File';		$dbObject->links['POT File'] = $page->formAction = '/Admin/'.$pageOwner['username'].'/POTfile';				ob_start();		$this->go();				echo '<input type="submit" name="cmd" value="Refresh" />';				$page->contentA['POT File'] = wb::get_clean();	}	function go(){		global $includeDir;		$langDir = $includeDir.'/lang/en/';				$lang = array();				$dh = @opendir($langDir);		if( !$dh ){			message('Could not open lang directory: '.$langDir);			return false;		}		while (($file = readdir($dh)) !== false) {			$pos = strpos($file,'.php');			if( $pos === false ){				continue;			}			if( $pos !== (strlen($file)-4) ){				continue;			}			$fullPath = $langDir.$file;			require($fullPath);		}		$newLine = "\n";		echo '<textarea style="width:100%" rows="'.$_SESSION['textareaY'].'" >';		echo '# WikyBlog POT file.';		echo $newLine.'# This file is distributed under the same license as the WikyBlog package.';		$root = '$lang';		$this->echoLang($lang,$root);		echo '</textarea>';			}	function echoLang($lang,$root){		$newLine = "\n";		foreach($lang as $key => $value){			$newRoot = $root.'[\''.$key.'\']';			if( is_array($value) ){				$this->echoLang($value,$newRoot);				continue;			}			echo $newLine.$newLine.'#: '.$newRoot;			echo $newLine.'msgid "'.str_replace(array('\\','"'),array('\\\\','\"'),$value).'"';			echo $newLine.'msgstr ""';		}	}		}new createPOTfile();

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?