Esempio n. 1
0
	/**
	 * 
	 * 플러그인 로드
	 * 
	 * 시스템 기본 플러그인인 lib/narin.action.php 을 먼저 로드한 뒤,
	 * plugins/ 에 있는 action.php 파일들을 로드한다.
	 */
	protected function loadPlugins()
	{
		include_once WIKI_PATH."/lib/narin.Plugin.class.php";
		include_once WIKI_PATH."/lib/narin.ActionPlugin.class.php";

		$path = WIKI_PATH."/plugins";
		$use_plugins = array();
		foreach($this->wiki_config->using_plugins as $v) $use_plugins[$v] = $v;

		// 기본 액션 로드
		include_once "narin.action.php";
		$action = new NarinActionDefault();
		$action->register($this);

		// Action 플러그인 로드

		$d = dir($path);
		while ($entry = $d->read()) {
				
			$pluginPath = $path ."/". $entry;
				
			if(is_dir($pluginPath) && substr($entry, 0, 1) != ".") {
					
				if(!$use_plugins[$entry]) continue;
					
				$classFile = $pluginPath ."/action.php";

				if(file_exists($classFile)) {
						
					$realClassName = "NarinAction".ucfirst($entry);

					include_once $classFile;
						
					if(class_exists($realClassName)) {

						$p = new $realClassName();
						if(!is_a($p, "NarinActionPlugin")) continue;
						$p->register($this);
					}
						
				} // if(file_exts...

			} // if(is_dir(....
				
		} // while
		

		// 이벤트를 order 순으로 정렬
		foreach($this->actions as $k=>$v) {
			$this->actions[$k] = wiki_subval_asort($this->actions[$k], 'order');
		}
		
	}
Esempio n. 2
0
	/**
	 *
	 * 플러그인 로드
	 *
	 * 시스템 기본 플러그인인 lib/narin.syntax.php 을 먼저 로드한 뒤,
	 * plugins/ 에 있는 syntax.php 파일들을 로드한다.
	 */
	protected function loadPlugins()
	{
		include_once WIKI_PATH."/lib/narin.Plugin.class.php";
		include_once WIKI_PATH."/lib/narin.SyntaxPlugin.class.php";

		$path = WIKI_PATH."/plugins";
		$use_plugins = array();
		foreach($this->wiki_config->using_plugins as $v) $use_plugins[$v] = $v;

		$plugins = array();
		
		// 기본 문법 해석기 로드
		include_once "narin.syntax.php";
		$syntax = new NarinSyntaxDefault();		
		array_push($plugins, array('order'=>$syntax->order, 'plugin'=>$syntax));

		// syntax 플러그인 로드
		$d = dir($path);
		while ($entry = $d->read()) {

			$pluginPath = $path ."/". $entry;

			if(is_dir($pluginPath) && substr($entry, 0, 1) != ".") {

				if(!$use_plugins[$entry]) {
					continue;
				}
				$classFile = $pluginPath ."/syntax.php";
				if(file_exists($classFile)) {

					$realClassName = "NarinSyntax".ucfirst($entry);
					include_once $classFile;

					if(class_exists($realClassName)) {

						$p = new $realClassName();
						if(!is_a($p, "NarinSyntaxPlugin")) continue;
						array_push($plugins, array('order'=>$p->order, 'plugin'=>$p));
					}

				}
			}
		}
		
		$plugins = wiki_subval_asort($plugins, 'order');
		
		foreach($plugins as $k=>$p) {
			$p['plugin']->register($this);
			array_push($this->plugins, $p['plugin']);
		}
		
		$this->addLineParser($id = $syntax->id."_wiki_par",
		$klass = $syntax,
		$regx = '^(.*?)$',
		$method = 'wiki_par');

	}
	/**
	 *
	 * 폴더내 폴더/문서 목록 반환
	 *
	 * @todo $this->namespaces() 와 겹치는 듯?
	 * @param string $parent 타겟 폴더 경로
	 * @param boolean $withArticle 문서도 목록으로 만들지 여부
	 * @return array 폴더/파일 목록
	 */
	function getList($parent = "/", $withArticle=true) {
		$escapedParent = mysql_real_escape_string($parent);
		$regp = ($parent == "/" ? "/" : $escapedParent."/");
		if($parent != "/") {
			$add =	"nt.ns = '$escapedParent' OR ";
			$addSlash = "/";
		}

		$sql = "SELECT *  FROM ".$this->wiki['ns_table']."
				WHERE $add ns LIKE '$escapedParent%' 
						AND ns NOT REGEXP '^$regp(.*)/' 
						AND bo_table ='".$this->wiki['bo_table']."'";
		if($withArticle) {
			$sql = "SELECT nt.ns, nt.bo_table, nt.ns_access_level, nb.access_level, nb.edit_level, wb.mb_id, wb.wr_name, mb.mb_nick, wb.wr_subject AS doc, wb.wr_id, wb.wr_datetime, ht.editor_mb_id AS editor, ht.reg_date AS update_date, wb.wr_good, wb.wr_nogood, wb.wr_comment, wb.wr_hit
					FROM ".$this->wiki['ns_table']." AS nt 
					LEFT JOIN ".$this->wiki['nsboard_table']." AS nb ON nt.ns = nb.ns AND nt.bo_table = nb.bo_table 
					LEFT JOIN ".$this->wiki['write_table']." AS wb ON nb.wr_id = wb.wr_id 
					LEFT JOIN ".$this->g4['member_table']." AS mb ON mb.mb_id = wb.mb_id 
					LEFT JOIN ".$this->wiki['history_table']." AS ht ON nb.wr_id = ht.wr_id 					
					WHERE $add nt.ns LIKE '$escapedParent$addSlash%' 
						AND nt.ns NOT REGEXP '^$regp(.*)/' 
						AND nt.bo_table = '".$this->wiki['bo_table']."' 
					GROUP BY wb.wr_id 
					ORDER BY wb.wr_subject";
		}

		$folders = array();
		$files = array();
		$already = array();
		$result = sql_query($sql);
		while ($row = sql_fetch_array($result))
		{
			if(!$row['update_date']) $row['update_date'] = $row['wr_datetime'];
			if(!$row['editor']) $row['editor'] = ($row['mb_id'] ? $row['mb_id'] : $row['mb_name']);
			if($row['ns'] == $parent) {
				if(!$row['doc']) continue;
				$row['name'] = $row['doc'];
				$row['path'] = ($row['ns'] == "/" ? "/" : $row['ns']."/").$row['doc'];
				$row['href'] = wiki_url('read', array('doc'=>$row['path']));
				$row['internal_link'] = "[[".$row['path']."]]";
				$row['type'] = 'doc';				
				array_push($files, $row);
			} else {
				$row['href'] = wiki_url('folder', array('loc'=>$row['ns']));
				$name = ereg_replace($parent."/", "", $row['ns']);
				$row['name'] = ereg_replace($parent, "", $name);
				$row['path'] = $row['ns'];
				if($already[$name]) continue;
				$already[$name] = $name;
				$row['internal_link'] = "[[folder=".$row['ns']."]]";
				$row['type'] = 'folder';
				unset($row['editor']);
				unset($row['wr_hit']);
				unset($row['wr_name']);
				unset($row['mb_id']);
				unset($row['wr_name']);
				unset($row['wr_comment']);
				unset($row['wr_nogood']);
				unset($row['wr_good']);				
				array_push($folders, $row);
			}
			//if($this->is_admin) print_r2($row);
		}
		if(count($folders)) $folders = wiki_subval_asort($folders, "name");
		$list = array_merge($folders, $files);

		return $list;
	}
Esempio n. 4
0
/**
 *
 * 연관배열 키 기준으로 정렬 (sort)
 *
 * @param array $a 연관배열
 * @param string $subkey 정렬기준키
 * @return array 정렬된 배열
 */
function wiki_subval_sort($a,$subkey) {
	$c = wiki_subval_asort($a, $subkey);
	$c = array_reverse($c);
	return $c;
}
Esempio n. 5
0
	/**
	 * 
	 * 백링크 반환
	 * (백링크 : 문서를 링크하고 있는 다른 문서들)
	 * 
	 * @param string $doc 문서경로를 포함한 문서명
	 * @param boolean $includeSelf $doc 자신도 백링크에 포함할지 안할지
	 * @return array 문서목록 배열
	 */
	public function getBackLinks($doc, $includeSelf = false)
	{
		$escapedDoc = mysql_real_escape_string($doc);
		$list = array();
		// 2011-12-11 : 문서명뒤의 hash 태그사용할 수 있도록 수정
		$sql = "SELECT *, wb.wr_subject AS doc FROM ".$this->wiki['write_table']." AS wb 
				LEFT JOIN ".$this->wiki['nsboard_table']." AS nt ON wb.wr_id = nt.wr_id 
				WHERE nt.bo_table= '".$this->wiki['bo_table']."' 
							AND ( 
							      wb.wr_content LIKE '%[[".$escapedDoc."]]%' 
							      OR wb.wr_content LIKE '%[[".$escapedDoc."#%]]%'
							      OR wb.wr_content LIKE '%[[".$escapedDoc."|%'
							      OR wb.wr_content LIKE '%[[".$escapedDoc."#%|%'
							    ) 
							AND wb.wr_content NOT LIKE '%[[".$escapedDoc."/%'";
		$result = sql_query($sql);
		while($row = sql_fetch_array($result))
		{
			if(!$this->hasInternalLink($row['wr_content'], $doc)) {
				continue;
			}
			$bdoc = ($row['ns'] == "/" ? "/" : $row['ns'] . "/") . $row['doc'];
			if(!$includeSelf && $bdoc == $doc) continue;
				
			$row['href'] = wiki_url('read', array('doc'=>$bdoc));
			array_push($list, $row);
		}
		
		if(count($list)) $list = wiki_subval_asort($list, "doc");
		return $list;
	}