⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 plugincreatetool.php

📁 一款基于PHP的网络日记程序。WikyBlog支持:多用户的 BLOG
💻 PHP
📖 第 1 页 / 共 2 页
字号:
		$t[] = $tab.$tab.'$page->scripts[] = \'/include/\'.$jsNum.\'/editingAll.js\';';		$t[] = $tab.$tab.'includeFile(\'tool/pluginEdit.php\');';		$t[] = $tab.$tab.'ob_start();';		$t[] = $tab.$tab.'echo \'<table style="width:100%">\';';				//$_POST['add']			foreach($_POST['add'] as $array){				$temp = strtolower($array['name']);				if( $savebarKeywords && $temp =='keywords'){					continue;				}				$this->classEditValues($array);			}				$t[] = $tab.$tab.'echo \'</table>\';';		$t[] = $tab.$tab.'$page->contentA[$this->editLabel] = wb::get_clean();';		if( $savebarKeywords ){			$t[] = $tab.$tab.'$page->contentA[$this->editLabel] .= saveBar();';		}else{			$t[] = $tab.$tab.'$page->contentA[$this->editLabel] .= saveBar(false);';		}		$t[] = $tab.'}';		$t[] = $tab.'function creationValues(){';		$t[] = $tab.$tab.'return unserialize(\''.addcslashes(serialize($_POST),"\'").'\');';		$t[] = $tab.'}';		$t[] = '';		$t[] = '}';	}		function classEditValues($array){		$tab = "\t";				$temp = strtolower($array['name']);				switch($array['type']){						case 'ENUM':				$this->editEnum($array['name'],$array['len']);			break;			case 'SET':				$this->editSET($array['name'],$array['len']);			break;						case 'WIKI SYNTAX';				$this->classFile[] = $tab.$tab.'pluginEdit::editWiki(\''.$array['name'].'\');';			break;						case 'URL';				$this->classFile[] = $tab.$tab.'pluginEdit::editUrl(\''.$array['name'].'\',255);';			break;						case 'VARCHAR':				$this->classFile[] = $tab.$tab.'pluginEdit::editVarchar(\''.$array['name'].'\','.$array['len'].');';			break;						case 'YEAR':				$this->classFile[] = $tab.$tab.'pluginEdit::editYear(\''.$array['name'].'\');';			break;						case 'TIME':				$this->classFile[] = $tab.$tab.'pluginEdit::editTime(\''.$array['name'].'\');';			break;						case 'DATE':				$this->classFile[] = $tab.$tab.'pluginEdit::editDate(\''.$array['name'].'\');';			break;									//length plus one (for - sign)			case 'TINYINT':				$this->classFile[] = $tab.$tab.'pluginEdit::editInteger(\''.$array['name'].'\',4);';			break;			case 'SMALLINT':				$this->classFile[] = $tab.$tab.'pluginEdit::editInteger(\''.$array['name'].'\',6);';			break;			case 'MEDIUMINT':				$this->classFile[] = $tab.$tab.'pluginEdit::editInteger(\''.$array['name'].'\',8);';			break;			case 'INT':				$this->classFile[] = $tab.$tab.'pluginEdit::editInteger(\''.$array['name'].'\',11);';			break;			case 'BIGINT':				$this->classFile[] = $tab.$tab.'pluginEdit::editInteger(\''.$array['name'].'\',20);';			break;			// 			case 'FLOAT':// 				$this->classFile[] = $tab.$tab.'pluginEdit::editDecimal(\''.$array['name'].'\');';// 			break;// 			case 'DOUBLE':// 				$this->classFile[] = $tab.$tab.'pluginEdit::editDecimal(\''.$array['name'].'\');';// 			break;// 			case 'DECIMAL':// 				$this->classFile[] = $tab.$tab.'pluginEdit::editDecimal(\''.$array['name'].'\');';// 			break;						default:				message('unknown type: '.$array['type']);			break;		}	}	function editEnum($name,$list){		$tab = "\t";		$list = str_replace("'","\'",$list);		$list = "array('".str_replace(',',"','",$list)."')";		$this->classFile[] = $tab.$tab.'pluginEdit::editList(\''.$name.'\','.$list.',false);';	}	function editSet($name,$list){		$tab = "\t";		$list = str_replace("'","\'",$list);		$list = "array('".str_replace(',',"','",$list)."')";		$this->classFile[] = $tab.$tab.'pluginEdit::editList(\''.$name.'\','.$list.',true);';	}		////////////////////////////////////////////////////////////////////////	//	//		Create the SQL File	//		// this needs to match the format of installDB.php	function createSql($array){		//Name			$name = toStorage($array['name'],true);			if($name=='keywords'){				return;			}				//sql			$column =& $this->sqlFile['columns'][$name];			$column = '`'.$name.'` ';						switch($array['type']){				case 'URL':					$column .= 'VARCHAR(255)';				break;				case 'WIKI SYNTAX':					$column .= 'TEXT ';				break;				default:					$column .= $array['type'];				break;			}						switch($this->types[$array['type']]){				case 'len':				case 'int':					if( !empty($array['len']) ){						$column .= '('.$array['len'].')';					}					$column .= ' NOT NULL';				break;				case 'list':					$array['len'] = str_replace("'","\'",$array['len']);					$array['len'] = "'".str_replace(',',"','",$array['len'])."'";					$column .= '('.$array['len'].') NOT NULL';				break;								default:					$column .= ' NOT NULL';				break;			}	}			///////////////////////////////////////////////////////////////	//	//		Check Values	//		function checkAll($name=true){		global $wbTablePrefix;		includeFile('admin/PluginAdd.php');		$done = true;		$_POST['plugin'] = toStorage($_POST['plugin']);		$lowerName = wbStrtolower($_POST['plugin']);				//		//	Plugin Name		//			if( $name ){				$methods = get_class_methods('dbPage');				$methods = array_flip($methods);								if( empty($_POST['plugin']) ){					message('Plugin Name cannot be empty.');					$done = false;				}else{															if( class_exists($_POST['plugin'])) {						message('Please choose a different plugin name. (1)');						$done = false;											}elseif( isset($methods[strtolower($_POST['plugin'])])){						message('Please choose a different plugin name. (2)');						$done = false;											}elseif( !pluginAdd::checkName($lowerName) ){						$done = false;					}				}			}									//		//	Check all the additional		//		if( isset($_POST['add']) && is_array($_POST['add']) ){			$temp = array();			foreach($_POST['add'] as $key => $array){								if( !$this->checkAdditional($array) ){					$done = false;					continue;				}				$_POST['add'][$key] = $array;				$temp[$_POST['add'][$key]['codeName']] = true;			}						if( count($_POST['add']) != count($temp) ){				$done = false;				message('Two Columns cannot share the same name.');			}				}else{			$done = false;			message('There must be at least one Column to create a plugin.');		}		return $done;	}		function checkAdditional(&$array){			if( empty($array['name']) ){				message('You must specify a Name for each of the Additional Fields');				return false;			}			$array['name'] = str_replace(' ','_',$array['name']);			$lowerName = strtolower($array['name']);			$array['codeName'] = $lowerName;					//		//	special names		//			if( $lowerName === 'keywords' ){				if( empty($array['len']) ){					$array['len'] = '255';				}			}elseif( array_key_exists($lowerName, $this->existingVars ) ){				message('"'.$array['name'].'" is a reserved word and cannnot be used for the Name of an Additional Field.');				return false;			}				//		//	isset checks		//						$lowerName = toStorage($lowerName);			$regExp = '^[A-Za-z0-9_-]+$';			if(!eregi($regExp,$lowerName)){				message('Name must only contain alphanumeric, underscore and dash characters.');				return false;			}						if( isset($this->usedCols[$lowerName]) ){				message('You cannot have two 4 named "'.$array['name'].'".');				return false;			}			if( !isset($this->types[$array['type']]) || !$this->types[$array['type']] ){				if( empty($array['type']) ){					message('Unknown Type given for "'.$array['name'].'".');				}else{					message('Unknown Type "'.$array['type'].'" given for "'.$array['name'].'".');				}				return false;			}				//		//	check type		//					$goodType = true;			$temp = $this->types[$array['type']];			switch($temp){				case 'dec':				case 'int':					if( !empty($array['len']) && !is_numeric($array['len']) ){						$goodType = false;						message('Must supply a numeric value for "'.$array['name'].'" ');					}				break;				case 'len':					if( !is_numeric($array['len']) ){						$goodType = false;						message('Must supply a numeric value for "'.$array['name'].'" ');					}				break;								case 'list':					$goodType = $this->needCommaList($array['len'],$array['name']);				break;				case 'WIKI SYNTAX';				case 'url':								case 'text':				case 'date':					//nothing needed				break;				default:					trigger_error('oops');				break;			}						if( !$goodType ){				return false;			}					$this->usedCols[$array['name']] = 1;		return true;	}		function needCommaList($string,$name){		if( empty($string) ){			message('"'.$name.'" must be a comma separated list of words.');			return false;		}		if( strpos($string,',') === false){			message('"'.$name.'" must be a comma separated list of words.');			return false;		}		return true;	}			function formFooter(){		echo '<br/>';		echo '<h2 class="heading">Note</h2><div class="underline"></div>';		echo '<ul>';		echo '<li>';		echo 'Most of the column types are the same as the <a href="http://dev.mysql.com/doc/refman/5.0/en/data-types.html" class="external" target="_new">MySQL Column Types</a>.';		echo '</li>';		echo '</ul>';	}		function form($args){		global $page;		echo '<tr>';			echo '<th>Column Name</th>';			echo '<th>Type</th>';			echo '<th colspan="2">Length/Values</th>';		echo '</tr>';				if( empty($args['cmd']) ){						$array[] =  array('name'=>'','type'=>'','len'=>'');			$array[] =  array('name'=>'','type'=>'','len'=>'');			$array[] =  array('name'=>'Content','type'=>'WIKI SYNTAX','len'=>'');			$array[] =  array('name'=>'Keywords','type'=>'','len'=>'');			foreach($array as $temp){				$this->formRow($temp,4);			}					}else{						switch($page->userCmd){				case 'remove':					if( isset($args['add'][$page->cmdArg[0]]) ){						unset($args['add'][$page->cmdArg[0]]);					}				break;				case 'up':					if( isset($args['add'][$page->cmdArg[0]]) && isset($args['add'][$page->cmdArg[0]-1])){						$temp = $args['add'][$page->cmdArg[0]];						$args['add'][$page->cmdArg[0]] = $args['add'][$page->cmdArg[0]-1];						$args['add'][$page->cmdArg[0]-1] = $temp;					}				break;				case 'down':					if( isset($args['add'][$page->cmdArg[0]]) && isset($args['add'][$page->cmdArg[0]+1])){						$temp = $args['add'][$page->cmdArg[0]+1];						$args['add'][($page->cmdArg[0]+1)] = $args['add'][$page->cmdArg[0]];						$args['add'][$page->cmdArg[0]] = $temp;					}				break;				case 'add field';					$args['add'][] = array();				break;			}													if( isset($args['add']) && is_array($args['add']) ){				$count = count($args['add']);				foreach($args['add'] as $array){					$this->formRow($array,$count);				}			}		}				echo '<tr>';			echo '<td></td>';			echo '<td></td>';			echo '<td></td>';			echo '<td>';			echo '<input type="image" src="'.wbLinks::getDir('/imgs/icons/add.gif').'"  name="cmd" title="Add Field" value="Add Field" /> &nbsp; ';			echo '</td>';		echo '</tr>';		echo '</table>';	}			function formRow($array=array(),$count){		static $i = 0;		static $classes = array(' class="tableRowEven" ',' class="tableRowOdd" ');		$array += array('name'=>'','type'=>'','len'=>'');						//echo '<tr'.$classes[($i%2)].'>'; //messes up the display of <input> elements		if( ($i%2) == 1){			echo '<tr style="BORDER-STYLE: none none dashed none;BORDER-COLOR: #aaaaaa;border-width: 1px;vertical-align:middle;padding: .7em 1em .7em 1em;">';		}else{			echo '<tr style="BORDER-STYLE: none none dashed none;BORDER-COLOR: #aaaaaa;border-width: 1px;vertical-align:middle;padding: .7em 1em .7em 1em;">';		}		echo '<td>';			$name = strtolower($array['name']);						if( $name === 'keywords' ){				echo 'Keywords / Tags';				echo '<input type="hidden" name="add['.$i.'][name]" value="Keywords" />';				echo '</td>';				echo '<td>';					echo '<select name="add['.$i.'][type]">';						if( $array['type'] === 'SET' ){							echo '<option value="VARCHAR">VARCHAR</option>';							echo '<option value="ENUM">ENUM</option>';							echo '<option value="SET" selected="selected">SET</option>';						}elseif($array['type'] === 'ENUM' ){							echo '<option value="VARCHAR">VARCHAR</option>';							echo '<option value="ENUM" selected="selected">ENUM</option>';							echo '<option value="SET">SET</option>';						}else{							echo '<option value="VARCHAR">VARCHAR</option>';							echo '<option value="ENUM">ENUM</option>';							echo '<option value="SET">SET</option>';						}					echo '</select>';				echo '</td>';				echo '<td><input type="text" name="add['.$i.'][len]" value="'.htmlspecialchars($array['len']).'" />';							}else{							echo '<input type="text" name="add['.$i.'][name]" value="'.htmlspecialchars($array['name']).'"/>';				echo '</td>';				echo '<td>';					echo '<select name="add['.$i.'][type]">';						$inGroup = false;						foreach($this->types as $type => $null){							if( is_bool($null) ){								if( $inGroup ){									echo '<option value=""></option>';									echo '</optgroup>';								}								echo '<option value=""></option>';								echo '<optgroup label="'.$type.'" title="'.$type.'">';								$inGroup = true;							}elseif( $array['type'] === $type ){								echo '<option value="'.$type.'" selected="selected">'.$type.'</option>';							}else{								echo '<option value="'.$type.'">'.$type.'</option>';							}						}						if( $inGroup ){							echo '<option value=""></option>';							echo '</optgroup>';						}					echo '</select>';				echo '</td>';				echo '<td>';					echo '<input type="text" name="add['.$i.'][len]" value="'.htmlspecialchars($array['len']).'" />';				echo '</td>';			}						echo '<td>';				if( $i != 0){					echo '<input type="image" src="'.wbLinks::getDir('/imgs/icons/arrow_up.gif').'" name="cmd['.$i.']" title="Move Up" value="up"/>';				}else{					echo '<img src="'.wbLinks::getDir('/imgs/blank.gif').'" height="16" width="16" />';				}				if( ($i+1) != $count ){					echo ' &nbsp; <input type="image" src="'.wbLinks::getDir('/imgs/icons/arrow_down.gif').'" name="cmd['.$i.']" title="Move Down" value="down" />';				}else{					echo ' &nbsp; <img src="'.wbLinks::getDir('/imgs/blank.gif').'" height="16" width="16" />';				}				echo ' &nbsp; <input type="image" src="'.wbLinks::getDir('/imgs/icons/delete.gif').'" name="cmd['.$i.']" title="Remove Field" value="Remove" />';			echo '</td>';		echo '</tr>';		$i++;	}}

⌨️ 快捷键说明

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