Exemple #1
0
function wiki_add_entry(&$wiki, &$course, $userid = 0, $groupid = 0)
{
    /// Adds a new wiki entry of the specified type, unless already entered.
    /// No checking is done here. It is assumed that the caller has the correct
    /// privileges to add this entry.
    global $USER;
    /// If this wiki already has a wiki_type entry, return false.
    if (wiki_get_entry($wiki, $course, $userid, $groupid) !== false) {
        return false;
    }
    $wiki_entry = new Object();
    switch ($wiki->wtype) {
        case 'student':
            $wiki_entry->wikiid = $wiki->id;
            $wiki_entry->userid = $userid ? $userid : $USER->id;
            $wiki_entry->pagename = wiki_page_name($wiki);
            $wiki_entry->timemodified = time();
            break;
        case 'group':
            /// Get the groupmode. It's been added to the wiki object.
            $groupmode = groups_get_activity_groupmode($wiki);
            ///give the first groupid by default and try
            $mygroups = mygroupid($course->id);
            /// If there is a groupmode, get the group id.
            if ($groupmode) {
                $groupid = $groupid ? $groupid : $mygroups[0];
            } else {
                $groupid = 0;
            }
            $wiki_entry->wikiid = $wiki->id;
            $wiki_entry->groupid = $groupid;
            $wiki_entry->pagename = wiki_page_name($wiki);
            $wiki_entry->timemodified = time();
            break;
        case 'teacher':
            /// Get the groupmode. It's been added to the wiki object.
            $groupmode = groups_get_activity_groupmode($wiki);
            /// If there is a groupmode, get the user's group id.
            if ($groupmode and $groupid == 0) {
                $mygroupid = mygroupid($course->id);
                $groupid = $mygroupid[0];
            }
            $wiki_entry->wikiid = $wiki->id;
            $wiki_entry->course = $wiki->course;
            $wiki_entry->groupid = $groupid;
            $wiki_entry->pagename = wiki_page_name($wiki);
            $wiki_entry->timemodified = time();
            break;
    }
    $wiki_entry->pagename = addslashes($wiki_entry->pagename);
    return insert_record("wiki_entries", $wiki_entry, true);
}
Exemple #2
0
/**
 * 
 * 에디터 미리보기 스크립트
 *
 * @package	narinwiki
 * @subpackage pages
 * @license GPL2 (http://narinwiki.org/license)
 * @author	byfun (http://byfun.com)
 * @filesource
 */
include_once "_common.php";

$doc = wiki_ajax_data($doc);
$content = wiki_ajax_data($content);

list($ns, $doc, $path) = wiki_page_name(stripslashes($doc));

$wr = array('mb_id'=>$member['mb_id'],
					  'mb_level'=>$member['mb_level'],
					  'mb_name'=>$member['mb_name'],
					  'mb_nick'=>$member['mb_nick'],
					  'wr_subject'=>$doc,
					  'wr_content'=>stripslashes($content)
					 );

$parser =& wiki_class_load("Parser");
$html = $parser->parse($wr);

$no_layout = true;
ob_start();
include_once WIKI_PATH."/head.php";
Exemple #3
0
	/**
	 *
	 * 미디어 파일/이미지
	 *
	 * @param array $matches 매칭 결과
	 * @param array $params {@link NarinParser} 에서 전달하는 파라미터
	 * @param array $close 태그 닫을지 말지
	 * @return string 이미지 또는 파일 링크
	 */
	public function wiki_media($matches, $params) {
		$media =& wiki_class_load("Media");

		// [0] : all string
		// [1] : path
		// [4] : parameters
		// [6] : title

		if(preg_match("/^(http)/", $matches[1])) {
			if($matches[4]) parse_str(str_replace("&", "&", $matches[4]));
			$use_thumb = false;
			if($width && $height) {
				$width = intval($width);
				$height= intval($height);
				$use_thumb = true;
			}
			if($use_thumb) $add = "width='$width' height='$height'";
			else $add = "";
			return "<a href='$matches[1]' class='wiki_image wiki_modal' style='$style' rel='$rn'><img src='$matches[1]' class='$align' style='$imgstyle' $add border='0'/></a>";
		}

		list($ns, $filename, $filepath) = wiki_page_name($matches[1]);
		$fileinfo = $media->getFile($ns, $filename);

		if(!$fileinfo) return '<span class="no_media">[파일없음 : '.$matches[1].']</span>';
		if($fileinfo['img_width'] > 0) {
			return $this->_wiki_media_image($fileinfo, $matches[4], $matches[6], &$params);
		} else {
			return $this->_wiki_media_file($fileinfo, $matches[4], $matches[6], &$params);
		}
	}
Exemple #4
0
 *
 * @package	narinwiki
 * @subpackage event
 * @license GPL2 (http://narinwiki.org/license)
 * @author	byfun (http://byfun.com)
 * @filesource
 */
 
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가 

if(file_exists(WIKI_PATH."/narin.config.php") ) {
	if(!$doc && $wr_id) {
		$wikiArticle =& wiki_class_load("Article");
		$tmp = &$wikiArticle->getArticleById($wr_id);
		$doc = wiki_doc($tmp['ns'], $tmp['doc']);
		list($ns, $docname, $doc) = wiki_page_name($doc);
	}

	$scriptFile = basename($_SERVER['SCRIPT_NAME']);
	$wikiEvent =& wiki_class_load("Event");
	extract($wikiEvent->trigger("LOAD_HEAD", array("script"=>$scriptFile, 
													"folder"=>$ns, 
													"docname"=>$docname, 
													"doc"=>$doc)));	
$css_path = $wiki['url'].'/css.php';
$js_path = $wiki['url'].'/js.php';
if($wiki['fancy_url']) {
	$css_path = $wiki['url'].'/_narin.css';
	$js_path = $wiki['url'].'/_narin.js';
}
if(isset($wiki_head)) {
	/**
	 *
	 * 파일 정보 반환
	 *
	 * @param string $ns 폴더 경로
	 * @param string $file 파일명
	 * @return array 파일정보배열 : array("id"=>파일id,
	 * 									 "ns"=>폴더경로,
	 * 									 "source"=>파일원본이름,
	 * 									 "file"=>저장된파일이름,
	 * 									 "path"=>파일저장경로(파일명포함),
	 * 									 "href"=>다운로드URL,
	 * 									 "imgsrc"=>이미지SRC (href와 같음),
	 * 									 "filesize"=>파일크기(bytes),
	 * 									 "downloads"=>다운로드카운트,
	 * 									 "reg_date"=>파일등록시간,
	 * 									 "img_width"=>이미지너비(px),
	 * 									 "img_height"=>이미지높이(px),
	 * 									 "img_type"=>이미지유형,
	 * 									 "mb_id"=>파일등록자 아이디,
	 * 									 "mb_name"=>파일등록자 이름,
	 * 									 "mb_nick"=>파일등록자 닉네임)
	 */
	function getFile($ns, $file = '') {

		if($ns && !$file) {
			list($ns, $file, $full) = wiki_page_name($ns);
		}
		$ns = mysql_real_escape_string($ns);
		$file = mysql_real_escape_string($file);

		$sql = "SELECT m.id, m.ns, m.source, m.file, m.filesize, m.downloads, m.reg_date, m.img_width, m.img_height, m.img_type, m.mb_id, mb.mb_name, mb.mb_nick
					  FROM ".$this->wiki['media_table']." AS m
					  LEFT JOIN {$this->g4['member_table']} AS mb 
					  	ON m.mb_id = mb.mb_id 
					  WHERE m.ns = '$ns' AND m.source = '$file' AND m.bo_table = '".$this->wiki['bo_table']."' 
					  ";		


		$row = sql_fetch($sql);
		if(!$row) return null;
		
		$row['path'] = WIKI_PATH.'/data/'.$this->wiki['bo_table'].'/files/'.$row['file'];
		if(!$this->wiki['fancy_url']) {
			$row['href'] = $this->wiki['url'].'/exe/media_download.php?file='.urlencode(wiki_doc($row['ns'], $row['source']));
			$row['imgsrc'] = $this->wiki['url'].'/exe/media_download.php?file='.urlencode(wiki_doc($row['ns'], $row['source']));
		} else {
			$row['href'] = $this->wiki['url'].'/_media'.wiki_doc($row['ns'], $row['source']);
			$row['imgsrc'] = $this->wiki['url'].'/_media'.wiki_doc($row['ns'], $row['source']);
		}
		return $row;
	}
Exemple #6
0
	/**
	 * 
	 * 문서 작성 중 unlick AJAX 콜에 대한 응답
	 * 
	 * ajax로 문서 lock 갱신
	 * 
	 * @param array $params {@link NarinEvent) 에서 넘겨주는 파라미터
	 */
	public function on_unlock($params) {
		list($ns, $docname, $doc) = wiki_page_name(stripslashes($params['post']['doc']));
		$doc_code = md5($doc);		
		$this->initialize_lock($doc);			
		if($this->locked['ip'] != $this->user_ip) { echo "0"; return; }	// 자신이 lock 한 문서만 unlock 할 수 있음
		$this->unlock($doc);
		echo "unlock";
	}	
	$wikiArticle->addArticle($wr_doc, $wr_id);
} else if($w == 'u') {	// 업데이트 시
	$wikiArticle->updateArticle($wr_doc, $wr_id);
}			

// 공헌자 추가
$wikiArticle->addContributor($wr_id, $editor);

$wikiHistory =& wiki_class_load("History");		
$wikiHistory->update($wr_id, $wr_content, $editor, $wr_history);

// 새문서일 경우 이전 문서 이력과 연결 시켜 줌
if(!$w) $wikiHistory->setLinked($wr_id, $wr_doc);

// 절대경로로 시작하지않는 내부문서 경로에 현재 폴더 경로 추가
list($ns, $docname, $fullname) = wiki_page_name($wr_doc);
$util =& wiki_class_load("Util");
$content = $util->wiki_fix_internal_link($wr_content);
$write['wr_content'] = $content;

if($content != $wr_content) {
	$content = mysql_real_escape_string($content);
	sql_query("UPDATE ".$wiki['write_table']." SET wr_content = '$content' WHERE wr_id = $wr_id");
}

// 캐쉬 업데이트 필드 셋팅
$wikiArticle->shouldUpdateCache($wr_id, 1);
$backlinks = $wikiArticle->getBackLinks($fullname, $includeSelf = true);
for($i=0; $i<count($backlinks); $i++) {
	$wikiArticle->shouldUpdateCache($backlinks[$i]['wr_id'], 1);
}
Exemple #8
0
/**
 *
 * 네비게이션 문자열 반환
 *
 * @uses $navi = wiki_navigation("/narin/plugins/locing", false);
 *
 * @param string $doc 문서 또는 폴더 경로
 * @param boolean $isNS $doc가 폴더 경로인지 아닌지
 * @return string 네비게이션문자열 (e.g. Home > 폴더 > 문서)
 */
function wiki_navigation($doc, $isNS=false) {
	global $wiki;

	if(!$isNS) list($ns, $docname, $fullpath) = wiki_page_name($doc);
	else $ns = $doc;

	$path = explode("/", $ns);

	$wiki_navigation = "<a href='".wiki_url('folder')."'>Home</a> > ";
	$hrefPath = "";
	for($i=0; $i<count($path); $i++) {
		if($path[$i]) {
			$hrefPath .= "/".$path[$i];
			$wiki_navigation .= " <a href='".wiki_url('folder', array('loc'=>$hrefPath))."'>".$path[$i]."</a> > ";
		}
	}
	return $wiki_navigation . " <a href='".wiki_url('read', array('doc'=>$doc))."'>$docname</a>";
}
	/**
	 * 
	 * 페이지 include 매소드
	 * 
	 * @param string $include_path include 할 파일 경로
	 * @param string $layout layout 을 사용할지 말지
	 * @param string $params
	 */
	function includePage($include_path, $layout=false, $params=array()) {
		
		foreach ( $GLOBALS as $key => $value ) { $$key = $value; }	
		
		if(is_array($params)) foreach ( $params as $key => $value ) { $$key = $value; }	
		list($ns, $docname, $doc) = wiki_page_name($doc);
		
		if($layout) include_once WIKI_PATH . "/head.php";		
		include $include_path;		
		if($layout) include_once WIKI_PATH . "/tail.php";				
		
	}
Exemple #10
0
/**
 * Adds a new wiki entry of the specified type, unless already entered.
 *
 * No checking is done here. It is assumed that the caller has the correct
 * privileges to add this entry.
 *
 * @global object
 * @global object
 * @param object $wiki
 * @param object $course
 * @param int $userid
 * @param int $groupid
 * @return bool
 */
function wiki_add_entry(&$wiki, &$course, $userid = 0, $groupid = 0)
{
    global $USER, $DB;
    /// If this wiki already has a wiki_type entry, return false.
    if (wiki_get_entry($wiki, $course, $userid, $groupid) !== false) {
        return false;
    }
    $wiki_entry = new Object();
    switch ($wiki->wtype) {
        case 'student':
            $wiki_entry->wikiid = $wiki->id;
            $wiki_entry->userid = $userid ? $userid : $USER->id;
            $wiki_entry->pagename = wiki_page_name($wiki);
            $wiki_entry->timemodified = time();
            break;
        case 'group':
            /// Get the groupmode. It's been added to the wiki object.
            $groupmode = groups_get_activity_groupmode($wiki);
            ///give the first groupid by default and try
            $mygroups = mygroupid($course->id);
            /// If there is a groupmode, get the group id.
            if ($groupmode) {
                $groupid = $groupid ? $groupid : $mygroups[0];
            } else {
                $groupid = 0;
            }
            $wiki_entry->wikiid = $wiki->id;
            $wiki_entry->groupid = $groupid;
            $wiki_entry->pagename = wiki_page_name($wiki);
            $wiki_entry->timemodified = time();
            break;
        case 'teacher':
            /// Get the groupmode. It's been added to the wiki object.
            $groupmode = groups_get_activity_groupmode($wiki);
            /// If there is a groupmode, get the user's group id.
            if ($groupmode and $groupid == 0) {
                $mygroupid = mygroupid($course->id);
                $groupid = $mygroupid[0];
            }
            $wiki_entry->wikiid = $wiki->id;
            $wiki_entry->course = $wiki->course;
            $wiki_entry->groupid = $groupid;
            $wiki_entry->pagename = wiki_page_name($wiki);
            $wiki_entry->timemodified = time();
            break;
    }
    $wiki_entry->pagename = $wiki_entry->pagename;
    return $DB->insert_record("wiki_entries", $wiki_entry, true);
}
	/**
	 * 
	 * 문서 권한 변경
	 * 
	 * @param string $doc 변경할 문서 (문서 경로를 포함한 문서명)
	 * @param int $access_level 문서 접근 권한
	 * @param int $edit_level 문서 편집 권한
	 */
	function updateLevel($doc, $access_level, $edit_level)
	{
		list($ns, $docname, $fullname) = wiki_page_name($doc);
		$wr = & $this->getArticle($ns, $docname, __FILE__, __LINE__);
		if(!$wr) return;
		$access_level = mysql_real_escape_string($access_level);
		$edit_level = mysql_real_escape_string($edit_level);
		sql_query("UPDATE ".$this->wiki['nsboard_table']." SET access_level = '$access_level', edit_level = '$edit_level' 
				   WHERE bo_table = '".$this->wiki['bo_table']."' AND wr_id = '".$wr['wr_id']."'");
	}