added more code for rich text editing in wiki
This commit is contained in:
		| @ -19,7 +19,7 @@ CREATE TABLE project ( | ||||
| 	id             VARCHAR(32)  PRIMARY KEY, | ||||
| 	name           VARCHAR(255) UNIQUE NOT NULL, | ||||
| 	summary        VARCHAR(255) NOT NULL, | ||||
| 	description    TEXT NOT NULL, | ||||
| 	description    TEXT         NOT NULL, | ||||
| 	commitable     CHAR(1)      NOT NULL DEFAULT 'Y', | ||||
| 	public         CHAR(1)      NOT NULL DEFAULT 'Y', | ||||
| 	codecharset    VARCHAR(32), | ||||
| @ -44,6 +44,7 @@ CREATE TABLE wiki ( | ||||
| 	projectid  VARCHAR(32)   NOT NULL, | ||||
| 	name       VARCHAR(255)  NOT NULL, | ||||
| 	text       TEXT          NOT NULL, | ||||
| 	type       CHAR(1)       NOT NULL DEFAULT 'C', | ||||
| 	columns    INT           NOT NULL DEFAULT 1, | ||||
|  | ||||
| 	createdon  DATETIME      NOT NULL, | ||||
| @ -108,7 +109,9 @@ CREATE TABLE issue_file_list ( | ||||
| 	description VARCHAR(255)  NOT NULL, | ||||
|  | ||||
| 	createdon   DATETIME      NOT NULL, | ||||
| 	updatedon   DATETIME      NOT NULL, | ||||
| 	createdby   VARCHAR(32)   NOT NULL, | ||||
| 	updatedby   VARCHAR(32)   NOT NULL, | ||||
|  | ||||
| 	UNIQUE KEY issue_file_list_id (projectid, issueid, filename), | ||||
| 	UNIQUE KEY (encname), | ||||
| @ -142,22 +145,24 @@ CREATE TABLE issue_change ( | ||||
|  | ||||
| ) charset=utf8 engine=InnoDB; | ||||
|  | ||||
| CREATE TABLE issue_change_attachment ( | ||||
| CREATE TABLE issue_change_file_list ( | ||||
| 	projectid  VARCHAR(32)   NOT NULL, | ||||
| 	issueid    BIGINT        NOT NULL, | ||||
| 	issuesno   BIGINT        NOT NULL, | ||||
| 	name       VARCHAR(255)  NOT NULL, | ||||
| 	filename   VARCHAR(255)  NOT NULL, | ||||
| 	encname    VARCHAR(255)  NOT NULL, | ||||
|  | ||||
| 	createdon  DATETIME      NOT NULL, | ||||
| 	updatedon  DATETIME      NOT NULL, | ||||
| 	createdby  VARCHAR(32)   NOT NULL, | ||||
| 	updatedby  VARCHAR(32)   NOT NULL, | ||||
|  | ||||
| 	UNIQUE KEY issue_change_attachment_id (projectid, issueid, name), | ||||
| 	UNIQUE KEY issue_change_file_list_id (projectid, issueid, name), | ||||
|  | ||||
| 	CONSTRAINT issue_change_attachment_projectid FOREIGN KEY (projectid) REFERENCES project(id) | ||||
| 	CONSTRAINT issue_change_file_list_projectid FOREIGN KEY (projectid) REFERENCES project(id) | ||||
| 		ON DELETE RESTRICT ON UPDATE CASCADE, | ||||
|  | ||||
| 	CONSTRAINT issue_change_attachment_issueidsno FOREIGN KEY (projectid,issueid,issuesno) REFERENCES issue_change(projectid,id,sno) | ||||
| 	CONSTRAINT issue_change_file_list_issueidsno FOREIGN KEY (projectid,issueid,issuesno) REFERENCES issue_change(projectid,id,sno) | ||||
| 		ON DELETE RESTRICT ON UPDATE CASCADE | ||||
| ) charset=utf8 engine=InnoDB; | ||||
|  | ||||
| @ -167,10 +172,10 @@ CREATE TABLE file ( | ||||
| 	tag         VARCHAR(54)   NOT NULL, | ||||
| 	description TEXT          NOT NULL, | ||||
|  | ||||
| 	createdon  DATETIME       NOT NULL, | ||||
| 	updatedon  DATETIME       NOT NULL,  | ||||
| 	createdby  VARCHAR(32)    NOT NULL, | ||||
| 	updatedby  VARCHAR(32)    NOT NULL, | ||||
| 	createdon   DATETIME      NOT NULL, | ||||
| 	updatedon   DATETIME      NOT NULL,  | ||||
| 	createdby   VARCHAR(32)   NOT NULL, | ||||
| 	updatedby   VARCHAR(32)   NOT NULL, | ||||
|  | ||||
| 	UNIQUE KEY file_id (projectid, name), | ||||
| 	INDEX file_tagged_name (projectid, tag, name), | ||||
| @ -187,10 +192,10 @@ CREATE TABLE file_list ( | ||||
| 	md5sum      CHAR(32)      NOT NULL, | ||||
| 	description VARCHAR(255)  NOT NULL, | ||||
|  | ||||
| 	createdon  DATETIME       NOT NULL, | ||||
| 	updatedon  DATETIME       NOT NULL,  | ||||
| 	createdby  VARCHAR(32)    NOT NULL, | ||||
| 	updatedby  VARCHAR(32)    NOT NULL, | ||||
| 	createdon   DATETIME      NOT NULL, | ||||
| 	updatedon   DATETIME      NOT NULL,  | ||||
| 	createdby   VARCHAR(32)   NOT NULL, | ||||
| 	updatedby   VARCHAR(32)   NOT NULL, | ||||
|  | ||||
| 	INDEX file_list_id (projectid, name), | ||||
| 	UNIQUE KEY file_list_fileid (projectid, filename), | ||||
|  | ||||
| @ -62,6 +62,7 @@ CREATE TABLE "cpot_wiki" ( | ||||
| 	"projectid"  VARCHAR(32)   NOT NULL, | ||||
| 	"name"       VARCHAR(255)  NOT NULL, | ||||
| 	"text"       CLOB          NOT NULL, | ||||
| 	"type"       CHAR(1)       DEFAULT 'C' NOT NULL, | ||||
| 	"columns"    INT           DEFAULT 1 NOT NULL, | ||||
| 	"createdon"  TIMESTAMP     NOT NULL, | ||||
| 	"updatedon"  TIMESTAMP     NOT NULL, | ||||
| @ -111,11 +112,13 @@ CREATE TABLE "cpot_issue_file_list" ( | ||||
| 	"md5sum"      CHAR(32)      NOT NULL, | ||||
| 	"description" CLOB          NOT NULL, | ||||
| 	"createdon"   TIMESTAMP     NOT NULL, | ||||
| 	"updatedon"   TIMESTAMP     NOT NULL, | ||||
| 	"createdby"   VARCHAR(32)   NOT NULL, | ||||
| 	"updatedby"   VARCHAR(32)   NOT NULL, | ||||
| 	UNIQUE ("projectid", "issueid", "filename"), | ||||
| 	UNIQUE ("encname"), | ||||
| 	CONSTRAINT issue_attachment_projectid FOREIGN KEY ("projectid") REFERENCES "cpot_project"("id"), | ||||
| 	CONSTRAINT issue_attachment_issueid FOREIGN KEY ("projectid","issueid") REFERENCES "cpot_issue"("projectid","id") | ||||
| 	CONSTRAINT issue_file_list_projectid FOREIGN KEY ("projectid") REFERENCES "cpot_project"("id"), | ||||
| 	CONSTRAINT issue_file_list_issueid FOREIGN KEY ("projectid","issueid") REFERENCES "cpot_issue"("projectid","id") | ||||
| ); | ||||
|  | ||||
| CREATE TABLE "cpot_issue_change" ( | ||||
| @ -135,17 +138,19 @@ CREATE TABLE "cpot_issue_change" ( | ||||
|  | ||||
| CREATE INDEX cpot_issue_change_index_1 ON "cpot_issue_change"("projectid", "id", "updatedon"); | ||||
|  | ||||
| CREATE TABLE "cpot_issue_change_attachment" ( | ||||
| CREATE TABLE "cpot_issue_change_file_list" ( | ||||
| 	"projectid"  VARCHAR(32)   NOT NULL, | ||||
| 	"issueid"    NUMBER(20,0)  NOT NULL, | ||||
| 	"issuesno"   NUMBER(20,0)  NOT NULL, | ||||
| 	"name"       VARCHAR(255)  NOT NULL, | ||||
| 	"filename"   VARCHAR(255)  NOT NULL, | ||||
| 	"encname"    VARCHAR(255)  NOT NULL, | ||||
| 	"createdon"  TIMESTAMP     NOT NULL, | ||||
| 	"updatedon"  TIMESTAMP     NOT NULL, | ||||
| 	"createdby"  VARCHAR(32)   NOT NULL, | ||||
| 	"updatedby"  VARCHAR(32)   NOT NULL, | ||||
| 	UNIQUE ("projectid", "issueid", "name"), | ||||
| 	CONSTRAINT issue_change_attachment_c1 FOREIGN KEY ("projectid") REFERENCES "cpot_project"("id"), | ||||
| 	CONSTRAINT issue_change_attachment_c2 FOREIGN KEY ("projectid","issueid","issuesno") REFERENCES "cpot_issue_change"("projectid","id","sno") | ||||
| 	CONSTRAINT issue_change_file_list_c1 FOREIGN KEY ("projectid") REFERENCES "cpot_project"("id"), | ||||
| 	CONSTRAINT issue_change_file_list_c2 FOREIGN KEY ("projectid","issueid","issuesno") REFERENCES "cpot_issue_change"("projectid","id","sno") | ||||
| ); | ||||
|  | ||||
| CREATE TABLE "cpot_file" ( | ||||
|  | ||||
| @ -60,6 +60,7 @@ CREATE TABLE wiki ( | ||||
| 	projectid  VARCHAR(32)   NOT NULL, | ||||
| 	name       VARCHAR(255)  NOT NULL, | ||||
| 	text       TEXT          NOT NULL, | ||||
| 	type       CHAR(1)       NOT NULL DEFAULT 'C', | ||||
| 	columns    INT           NOT NULL DEFAULT 1, | ||||
|  | ||||
| 	createdon  TIMESTAMP     NOT NULL, | ||||
| @ -117,24 +118,6 @@ CREATE INDEX issue_index_1 ON issue(projectid, status, type, summary); | ||||
|  | ||||
| CREATE INDEX issue_index_2 ON issue(projectid, summary); | ||||
|  | ||||
| CREATE TABLE issue_attachment ( | ||||
| 	projectid  VARCHAR(32)   NOT NULL, | ||||
| 	issueid    BIGINT        NOT NULL, | ||||
| 	name       VARCHAR(255)  NOT NULL, | ||||
| 	encname    VARCHAR(255)  NOT NULL, | ||||
|  | ||||
| 	createdon  TIMESTAMP     NOT NULL, | ||||
| 	createdby  VARCHAR(32)   NOT NULL, | ||||
|  | ||||
| 	UNIQUE (projectid, issueid, name), | ||||
|  | ||||
| 	CONSTRAINT issue_attachment_projectid FOREIGN KEY (projectid) REFERENCES project(id) | ||||
| 		ON DELETE RESTRICT ON UPDATE CASCADE, | ||||
|  | ||||
| 	CONSTRAINT issue_attachment_issueid FOREIGN KEY (projectid,issueid) REFERENCES issue(projectid,id) | ||||
| 		ON DELETE RESTRICT ON UPDATE CASCADE | ||||
| ); | ||||
|  | ||||
| CREATE TABLE issue_file_list ( | ||||
| 	projectid   VARCHAR(32)   NOT NULL, | ||||
| 	issueid     BIGINT        NOT NULL, | ||||
| @ -143,8 +126,10 @@ CREATE TABLE issue_file_list ( | ||||
| 	md5sum      CHAR(32)      NOT NULL, | ||||
| 	description VARCHAR(255)  NOT NULL, | ||||
|  | ||||
| 	createdon   DATETIME      NOT NULL, | ||||
| 	createdby   VARCHAR(32)   NOT NULL, | ||||
| 	createdon    TIMESTAMP     NOT NULL, | ||||
| 	updatedon    TIMESTAMP     NOT NULL, | ||||
| 	createdby    VARCHAR(32)   NOT NULL, | ||||
| 	updatedby    VARCHAR(32)   NOT NULL, | ||||
|  | ||||
| 	UNIQUE (projectid, issueid, filename), | ||||
| 	UNIQUE (encname), | ||||
| @ -179,22 +164,24 @@ CREATE TABLE issue_change ( | ||||
|  | ||||
| CREATE INDEX issue_change_index_1 ON issue_change(projectid, id, updatedon); | ||||
|  | ||||
| CREATE TABLE issue_change_attachment ( | ||||
| CREATE TABLE issue_change_file_list ( | ||||
| 	projectid  VARCHAR(32)   NOT NULL, | ||||
| 	issueid    BIGINT        NOT NULL, | ||||
| 	issuesno   BIGINT        NOT NULL, | ||||
| 	name       VARCHAR(255)  NOT NULL, | ||||
| 	filename   VARCHAR(255)  NOT NULL, | ||||
| 	encname    VARCHAR(255)  NOT NULL, | ||||
|  | ||||
| 	createdon  TIMESTAMP     NOT NULL, | ||||
| 	updatedon  TIMESTAMP     NOT NULL, | ||||
| 	createdby  VARCHAR(32)   NOT NULL, | ||||
| 	updatedby  VARCHAR(32)   NOT NULL, | ||||
|  | ||||
| 	UNIQUE (projectid, issueid, name), | ||||
|  | ||||
| 	CONSTRAINT issue_change_attachment_projectid FOREIGN KEY (projectid) REFERENCES project(id) | ||||
| 	CONSTRAINT issue_change_file_list_projectid FOREIGN KEY (projectid) REFERENCES project(id) | ||||
| 		ON DELETE RESTRICT ON UPDATE CASCADE, | ||||
|  | ||||
| 	CONSTRAINT issue_change_attachment_issueidsno FOREIGN KEY (projectid,issueid,issuesno) REFERENCES issue_change(projectid,id,sno) | ||||
| 	CONSTRAINT issue_change_file_list_issueidsno FOREIGN KEY (projectid,issueid,issuesno) REFERENCES issue_change(projectid,id,sno) | ||||
| 		ON DELETE RESTRICT ON UPDATE CASCADE | ||||
| ); | ||||
|  | ||||
|  | ||||
| @ -266,7 +266,7 @@ class Wiki extends Controller | ||||
| 						{ | ||||
| 							$atpos = strpos ($att, '@'); | ||||
| 							if ($atpos === FALSE) continue; | ||||
| 	 | ||||
|  | ||||
| 							$attinfo['name'] = $this->converter->HexToAscii( | ||||
| 								substr ($att, 0, $atpos)); | ||||
| 							$attinfo['encname'] = $this->converter->HexToAscii( | ||||
| @ -554,7 +554,7 @@ class Wiki extends Controller | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	function _upload_attachments ($id) | ||||
| 	private function _upload_attachments ($id) | ||||
| 	{ | ||||
| 		$attno = 0; | ||||
| 		$count = count($_FILES); | ||||
| @ -869,4 +869,159 @@ class Wiki extends Controller | ||||
| 			$this->_handle_issue_file ($login, $projectid, $issueid, $filename); | ||||
| 	} | ||||
|  | ||||
|  | ||||
| 	/////////////////////////////////////////////////////////////////// | ||||
|  | ||||
| 	function xhr_edit ($projectid = '') | ||||
| 	{ | ||||
| 		$this->load->model ('ProjectModel', 'projects'); | ||||
| 		$this->load->model ('WikiModel', 'wikis'); | ||||
| 		$this->load->library ('upload'); | ||||
|  | ||||
| 		$login = $this->login->getUser (); | ||||
| 		$revision_saved = -1; | ||||
|  | ||||
| 		if ($login['id'] == '') | ||||
| 		{ | ||||
| 			$status = 'error - anonymous user'; | ||||
| 		} | ||||
| 		else | ||||
| 		{ | ||||
| 			$project = $this->projects->get ($projectid); | ||||
| 			if ($project === FALSE) | ||||
| 			{ | ||||
| 				$status = "error - failed to get the project {$projectid}"; | ||||
| 			} | ||||
| 			else if ($project === NULL) | ||||
| 			{ | ||||
| 				$status = "error - no such project {$projectid}"; | ||||
| 			} | ||||
| 			else if (!$login['sysadmin?'] &&  | ||||
| 			         $this->projects->projectHasMember($projectid, $login['id']) === FALSE) | ||||
| 			{ | ||||
| 				$status = "error - not a member {$login['id']}"; | ||||
| 			} | ||||
| 			else | ||||
| 			{ | ||||
| 				$wiki = new stdClass(); | ||||
| 				$wiki->projectid = $projectid; | ||||
| 				$wiki->name = $this->input->post('wiki_name'); | ||||
| 				$wiki->text = $this->input->post('wiki_text'); | ||||
| 				$wiki->type = $this->input->post('wiki_type'); | ||||
|  | ||||
| 				$wiki->original_name = $this->input->post('wiki_original_name'); | ||||
| 				$wiki_file_count = $this->input->post('wiki_file_count'); | ||||
|  | ||||
| 				if ($wiki->name === FALSE || ($wiki->name = trim($wiki->name)) == '') | ||||
| 				{ | ||||
| 					$status = 'error - empty name'; | ||||
| 				} | ||||
| 				else if (strpbrk ($wiki->name, ':#[]|') !== FALSE) | ||||
| 				{ | ||||
| 					$status = 'error - disallowed characters in name'; | ||||
| 				} | ||||
| 				else if ($wiki->text === FALSE || ($wiki->text = trim($wiki->text)) == '') | ||||
| 				{ | ||||
| 					$status = 'error - empty text'; | ||||
| 				} | ||||
| 				else | ||||
| 				{ | ||||
| 					if ($wiki_file_count === FALSE || $wiki_file_count <= 0) $wiki_file_count = 0; | ||||
|  | ||||
| 					if ($wiki->original_name === FALSE) $wiki->original_name = ''; | ||||
| 					else $wiki->original_name = trim($wiki->original_name); | ||||
|  | ||||
| 					$status = ''; | ||||
| 					$attached_files = array (); | ||||
| 					for ($i = 0; $i < $wiki_file_count; $i++) | ||||
| 					{ | ||||
| 						$fid = "wiki_file_{$i}"; | ||||
| 						if (array_key_exists($fid, $_FILES) && $_FILES[$fid]['name'] != '') | ||||
| 						{ | ||||
| 							if (strpos($_FILES[$fid]['name'], ':') !== FALSE || | ||||
| 							    strpos($_FILES[$fid]['name'], '/') !== FALSE) | ||||
| 							{ | ||||
| 								// prevents these letters for wiki creole  | ||||
| 								$status = "error - colon or slash not allowed - {$_FILES[$fid]['name']}"; | ||||
| 								break; | ||||
| 							} | ||||
|  | ||||
| 							array_push ($attached_files, array ('fid' => $fid, 'name' => $_FILES[$fid]['name'])); | ||||
| 						} | ||||
| 					} | ||||
|  | ||||
| 					if ($status == '') | ||||
| 					{ | ||||
| 						if ($this->wikis->editWithFiles ($login['id'], $wiki, $attached_files, $this->upload) === FALSE) | ||||
| 						{ | ||||
| 							$status = 'error - ' . $this->wikis->getErrorMessage(); | ||||
| 						} | ||||
| 						else | ||||
| 						{ | ||||
| 							$status = 'ok'; | ||||
| 						} | ||||
| 					} | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		print $status; | ||||
| 	} | ||||
|  | ||||
| 	function xhr_delete ($projectid = '', $wikiname = '') | ||||
| 	{ | ||||
| 		$this->load->model ('ProjectModel', 'projects'); | ||||
| 		$this->load->model ('WikiModel', 'wikis'); | ||||
|  | ||||
| 		$login = $this->login->getUser (); | ||||
|  | ||||
| 		if ($login['id'] == '') | ||||
| 		{ | ||||
| 			$status = 'error - anonymous user'; | ||||
| 		} | ||||
| 		else | ||||
| 		{ | ||||
| 			$wikiname = $this->converter->HexToAscii ($wikiname); | ||||
|  | ||||
| 			$project = $this->projects->get ($projectid); | ||||
| 			if ($project === FALSE) | ||||
| 			{ | ||||
| 				$status = "error - failed to get the project {$projectid}"; | ||||
| 			} | ||||
| 			else if ($project === NULL) | ||||
| 			{ | ||||
| 				$status = "error - no such project {$projectid}"; | ||||
| 			} | ||||
| 			else if (!$login['sysadmin?'] &&  | ||||
| 			         $this->projects->projectHasMember($projectid, $login['id']) === FALSE) | ||||
| 			{ | ||||
| 				$status = "error - not a member {$login['id']}"; | ||||
| 			} | ||||
| 			else | ||||
| 			{ | ||||
| 				$post_delete_confirm = $this->input->post('wiki_delete_confirm'); | ||||
|  | ||||
| 				if ($post_delete_confirm !== FALSE && $post_delete_confirm == 'Y') | ||||
| 				{ | ||||
| 					$wiki = new stdClass(); | ||||
| 					$wiki->projectid = $projectid; | ||||
| 					$wiki->name = $wikiname; | ||||
| 					if ($this->wikis->delete ($login['id'], $wiki) === FALSE) | ||||
| 					{ | ||||
| 						$status = 'error - ' . $this->wikis->getErrorMessage(); | ||||
| 					} | ||||
| 					else | ||||
| 					{ | ||||
| 						$status = 'ok'; | ||||
| 					} | ||||
| 				} | ||||
| 				else | ||||
| 				{ | ||||
| 					$status = 'error - not confirmed'; | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		print $status; | ||||
| 	} | ||||
| } | ||||
|  | ||||
| @ -33,6 +33,7 @@ $lang['Edit'] = 'Edit'; | ||||
| $lang['Empty file'] = 'Empty file'; | ||||
| $lang['Enstyle'] = 'Enstyle'; | ||||
| $lang['Error'] = 'Error'; | ||||
| $lang['Exit'] = 'Exit'; | ||||
| $lang['Failure'] = 'Failure'; | ||||
| $lang['File'] = 'File'; | ||||
| $lang['Files'] = 'Files'; | ||||
|  | ||||
| @ -33,6 +33,7 @@ $lang['Edit'] = 'Rubah'; | ||||
| $lang['Empty file'] = 'Empty file'; | ||||
| $lang['Enstyle'] = 'Enstyle'; | ||||
| $lang['Error'] = 'Error'; | ||||
| $lang['Exit'] = 'Exit'; | ||||
| $lang['Failure'] = 'Failure'; | ||||
| $lang['File'] = 'File'; | ||||
| $lang['Files'] = 'File'; | ||||
|  | ||||
| @ -33,6 +33,7 @@ $lang['Edit'] = '수정'; | ||||
| $lang['Empty file'] = '빈파일'; | ||||
| $lang['Enstyle'] = '모양새내기'; | ||||
| $lang['Error'] = '오류'; | ||||
| $lang['Exit'] = '종료'; | ||||
| $lang['Failure'] = '실패'; | ||||
| $lang['File'] = '파일'; | ||||
| $lang['Files'] = '파일'; | ||||
|  | ||||
| @ -475,6 +475,7 @@ class IssueModel extends Model | ||||
| 		$maxid = (empty($result) || $result[0] == NULL)? 0: $result[0]->maxid; | ||||
|  | ||||
| 		$newid = $maxid + 1; | ||||
| 		$now = codepot_nowtodbdate(); | ||||
|  | ||||
| 		$this->db->set ('projectid', $issue->projectid); | ||||
| 		$this->db->set ('id', $newid); | ||||
| @ -484,8 +485,8 @@ class IssueModel extends Model | ||||
| 		$this->db->set ('status', $issue->status); | ||||
| 		$this->db->set ('owner', $issue->owner); | ||||
| 		$this->db->set ('priority', $issue->priority); | ||||
| 		$this->db->set ('createdon', codepot_nowtodbdate()); | ||||
| 		$this->db->set ('updatedon', codepot_nowtodbdate()); | ||||
| 		$this->db->set ('createdon', $now); | ||||
| 		$this->db->set ('updatedon', $now); | ||||
| 		$this->db->set ('createdby', $userid); | ||||
| 		$this->db->set ('updatedby', $userid); | ||||
| 		$this->db->insert ('issue'); | ||||
| @ -504,7 +505,7 @@ class IssueModel extends Model | ||||
| 		$this->db->set ('owner', $issue->owner); | ||||
| 		$this->db->set ('comment', ''); | ||||
| 		$this->db->set ('priority', $issue->priority); | ||||
| 		$this->db->set ('updatedon', codepot_nowtodbdate()); | ||||
| 		$this->db->set ('updatedon', $now); | ||||
| 		$this->db->set ('updatedby', $userid); | ||||
| 		$this->db->insert ('issue_change'); | ||||
| 		if ($this->db->trans_status() === FALSE) | ||||
| @ -552,6 +553,10 @@ class IssueModel extends Model | ||||
| 			$this->db->set ('encname', $ud['file_name']); | ||||
| 			$this->db->set ('description', $f['desc']); | ||||
| 			$this->db->set ('md5sum', $md5sum); | ||||
| 			$this->db->set ('createdon', $now); | ||||
| 			$this->db->set ('createdby', $userid); | ||||
| 			$this->db->set ('updatedon', $now); | ||||
| 			$this->db->set ('updatedby', $userid); | ||||
| 			$this->db->insert ('issue_file_list'); | ||||
| 			if ($this->db->trans_status() === FALSE) | ||||
| 			{ | ||||
| @ -562,7 +567,7 @@ class IssueModel extends Model | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		$this->db->set ('createdon', codepot_nowtodbdate()); | ||||
| 		$this->db->set ('createdon', $now); | ||||
| 		$this->db->set ('type',      'issue'); | ||||
| 		$this->db->set ('action',    'create'); | ||||
| 		$this->db->set ('projectid', $issue->projectid); | ||||
| @ -732,6 +737,8 @@ class IssueModel extends Model | ||||
| 	{ | ||||
| 		$this->db->trans_begin (); // manual transaction. not using trans_start(). | ||||
|  | ||||
| 		$now = codepot_nowtodbdate(); | ||||
|  | ||||
| 		$config['allowed_types'] = '*'; | ||||
| 		$config['upload_path'] = CODEPOT_ISSUE_FILE_DIR; | ||||
| 		$config['max_size'] = CODEPOT_MAX_UPLOAD_SIZE; | ||||
| @ -771,6 +778,12 @@ class IssueModel extends Model | ||||
|  | ||||
| 			$this->db->set ('md5sum', $md5sum); | ||||
| 			$this->db->set ('description', $f['desc']); | ||||
|  | ||||
| 			$this->db->set ('createdon', $now); | ||||
| 			$this->db->set ('createdby', $userid); | ||||
| 			$this->db->set ('updatedon', $now); | ||||
| 			$this->db->set ('updatedby', $userid); | ||||
|  | ||||
| 			$this->db->insert ('issue_file_list'); | ||||
| 			if ($this->db->trans_status() === FALSE) | ||||
| 			{ | ||||
| @ -781,7 +794,7 @@ class IssueModel extends Model | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		$this->db->set ('createdon', codepot_nowtodbdate()); | ||||
| 		$this->db->set ('createdon', $now); | ||||
| 		$this->db->set ('type',      'issue'); | ||||
| 		$this->db->set ('action',    'update'); | ||||
| 		$this->db->set ('projectid', $projectid); | ||||
| @ -814,6 +827,8 @@ class IssueModel extends Model | ||||
| 	{ | ||||
| 		$this->db->trans_begin (); // manual transaction. not using trans_start(). | ||||
|  | ||||
| 		$now = codepot_nowtodbdate(); | ||||
|  | ||||
| 		$kill_files = array(); | ||||
| 		$file_count = count($edit_files); | ||||
| 		for ($i = 0; $i < $file_count; $i++) | ||||
| @ -861,6 +876,8 @@ class IssueModel extends Model | ||||
| 				$this->db->where ('issueid', $issueid); | ||||
| 				$this->db->where ('filename', $f['name']); | ||||
| 				$this->db->set ('description', $f['desc']); | ||||
| 				$this->db->set ('updatedon', $now); | ||||
| 				$this->db->set ('updatedby', $userid); | ||||
| 				$this->db->update ('issue_file_list'); | ||||
| 				if ($this->db->trans_status() === FALSE) | ||||
| 				{ | ||||
|  | ||||
| @ -2,6 +2,18 @@ | ||||
|  | ||||
| class WikiModel extends Model | ||||
| { | ||||
| 	protected $errmsg = ''; | ||||
|  | ||||
| 	function capture_error ($errno, $errmsg) | ||||
| 	{ | ||||
| 		$this->errmsg = $errmsg; | ||||
| 	} | ||||
|  | ||||
| 	function getErrorMessage () | ||||
| 	{ | ||||
| 		return $this->errmsg; | ||||
| 	} | ||||
|  | ||||
| 	function WikiModel () | ||||
| 	{ | ||||
| 		parent::Model (); | ||||
| @ -280,18 +292,30 @@ class WikiModel extends Model | ||||
| 		return TRUE; | ||||
| 	} | ||||
|  | ||||
| 	function delete ($userid, $wiki) | ||||
| 	private function _delete_wiki ($userid, $wiki) | ||||
| 	{ | ||||
| 		// TODO: check if userid can do this.. | ||||
| 		$this->db->trans_start (); | ||||
| 		$this->db->trans_begin (); | ||||
|  | ||||
| 		$this->db->where ('projectid', $wiki->projectid); | ||||
| 		$this->db->where ('wikiname', $wiki->name); | ||||
| 		$this->db->delete ('wiki_attachment'); | ||||
| 		if ($this->db->trans_status() === FALSE) | ||||
| 		{ | ||||
| 			$this->errmsg = $this->db->_error_message();  | ||||
| 			$this->db->trans_rollback (); | ||||
| 			return FALSE; | ||||
| 		} | ||||
|  | ||||
| 		$this->db->where ('projectid', $wiki->projectid); | ||||
| 		$this->db->where ('name', $wiki->name); | ||||
| 		$this->db->delete ('wiki'); | ||||
| 		if ($this->db->trans_status() === FALSE) | ||||
| 		{ | ||||
| 			$this->errmsg = $this->db->_error_message();  | ||||
| 			$this->db->trans_rollback (); | ||||
| 			return FALSE; | ||||
| 		} | ||||
|  | ||||
| 		$this->db->set ('createdon', codepot_nowtodbdate()); | ||||
| 		$this->db->set ('type',      'wiki'); | ||||
| @ -299,12 +323,142 @@ class WikiModel extends Model | ||||
| 		$this->db->set ('projectid', $wiki->projectid); | ||||
| 		$this->db->set ('userid',    $userid); | ||||
| 		$this->db->set ('message',   $wiki->name); | ||||
|  | ||||
| 		$this->db->insert ('log'); | ||||
| 		$this->db->trans_complete (); | ||||
| 		return $this->db->trans_status(); | ||||
| 		if ($this->db->trans_status() === FALSE) | ||||
| 		{ | ||||
| 			$this->errmsg = $this->db->_error_message();  | ||||
| 			$this->db->trans_rollback (); | ||||
| 			return FALSE; | ||||
| 		} | ||||
|  | ||||
| 		$this->db->trans_commit (); | ||||
| 		return TRUE; | ||||
| 	} | ||||
|  | ||||
| 	function delete ($userid, $wiki) | ||||
| 	{ | ||||
| 		set_error_handler (array ($this, 'capture_error')); | ||||
| 		$errmsg = ''; | ||||
| 		$x = $this->_delete_wiki ($userid, $wiki); | ||||
| 		restore_error_handler (); | ||||
| 		return $x; | ||||
| 	} | ||||
| 	/////////////////////////////////////////////////////////////////// | ||||
|  | ||||
| 	private function _edit_wiki ($userid, $wiki, $attached_files, $uploader) | ||||
| 	{ | ||||
| 		$this->db->trans_begin (); // manual transaction. not using trans_start(). | ||||
|  | ||||
| 		$now = codepot_dbdatetodispdate(); | ||||
| 		$is_create = empty($wiki->original_name); | ||||
|  | ||||
| 		if ($is_create) | ||||
| 		{ | ||||
| 			$this->db->set ('projectid', $wiki->projectid);; | ||||
| 			$this->db->set ('name', $wiki->name); | ||||
| 			$this->db->set ('text', $wiki->text); | ||||
| 			$this->db->set ('type', $wiki->type); | ||||
| 			$this->db->set ('createdon', $now); | ||||
| 			$this->db->set ('updatedon', $now); | ||||
| 			$this->db->set ('createdby', $userid); | ||||
| 			$this->db->set ('updatedby', $userid); | ||||
| 			$this->db->insert ('wiki'); | ||||
| 		} | ||||
| 		else | ||||
| 		{ | ||||
| 			$this->db->where ('projectid', $wiki->projectid);; | ||||
| 			$this->db->where ('name', $wiki->original_name); | ||||
| 			$this->db->set ('name', $wiki->name); | ||||
| 			$this->db->set ('text', $wiki->text); | ||||
| 			$this->db->set ('type', $wiki->type); | ||||
| 			$this->db->set ('updatedon', $now); | ||||
| 			$this->db->set ('updatedby', $userid); | ||||
| 			$this->db->update ('wiki'); | ||||
| 		} | ||||
|  | ||||
| 		if ($this->db->trans_status() === FALSE) | ||||
| 		{ | ||||
| 			$this->errmsg = $this->db->_error_message();  | ||||
| 			$this->db->trans_rollback (); | ||||
| 			return FALSE; | ||||
| 		} | ||||
|  | ||||
| 		$config['allowed_types'] = '*'; | ||||
| 		$config['upload_path'] = CODEPOT_ATTACHMENT_DIR; | ||||
| 		$config['max_size'] = CODEPOT_MAX_UPLOAD_SIZE; | ||||
| 		$config['encrypt_name'] = TRUE; | ||||
| 		$config['overwrite'] = FALSE; | ||||
| 		$config['remove_spaces'] = FALSE; | ||||
| 		$uploader->initialize ($config); | ||||
|  | ||||
| 		$ok_files = array(); | ||||
| 		$file_count = count($attached_files); | ||||
| 		for ($i = 0; $i < $file_count; $i++) | ||||
| 		{ | ||||
| 			$f = $attached_files[$i]; | ||||
| 			if (!$uploader->do_upload($f['fid'])) | ||||
| 			{ | ||||
| 				$this->errmsg = "Failed to upload {$f['name']}"; | ||||
| 				$this->db->trans_rollback (); | ||||
| 				$this->delete_all_files ($ok_files); | ||||
| 				return FALSE; | ||||
| 			} | ||||
|  | ||||
| 			$ud = $uploader->data(); | ||||
| 			array_push ($ok_files, $ud['full_path']); | ||||
|  | ||||
| 			/*$md5sum = @md5_file ($ud['full_path']); | ||||
| 			if ($md5sum === FALSE) | ||||
| 			{ | ||||
| 				$this->db->trans_rollback (); | ||||
| 				$this->delete_all_files ($ok_files); | ||||
| 				return FALSE; | ||||
| 			}*/ | ||||
|  | ||||
| 			$this->db->set ('projectid', $wiki->projectid); | ||||
| 			$this->db->set ('wikiname', $wiki->name); | ||||
| 			$this->db->set ('name', $f['name']); | ||||
| 			$this->db->set ('encname', $ud['file_name']); | ||||
| 			/*$this->db->set ('md5sum', $md5sum);*/ | ||||
| 			$this->db->set ('createdon', $now); | ||||
| 			$this->db->set ('createdby', $userid); | ||||
| 			$this->db->insert ('wiki_attachment'); | ||||
| 			if ($this->db->trans_status() === FALSE) | ||||
| 			{ | ||||
| 				$this->errmsg = $this->db->_error_message();  | ||||
| 				$this->db->trans_rollback (); | ||||
| 				$this->delete_all_files ($ok_files); | ||||
| 				return FALSE; | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		$this->db->set ('createdon', $now); | ||||
| 		$this->db->set ('type',      'wiki'); | ||||
| 		$this->db->set ('action',    ($is_create? 'create': 'update')); | ||||
| 		$this->db->set ('projectid', $wiki->projectid); | ||||
| 		$this->db->set ('userid',    $userid); | ||||
| 		$this->db->set ('message',   $wiki->name); | ||||
| 		$this->db->insert ('log'); | ||||
| 		if ($this->db->trans_status() === FALSE) | ||||
| 		{ | ||||
| 			$this->errmsg = $this->db->_error_message();  | ||||
| 			$this->db->trans_rollback (); | ||||
| 			$this->delete_all_files ($ok_files); | ||||
| 			return FALSE; | ||||
| 		} | ||||
|  | ||||
| 		$this->db->trans_commit (); | ||||
| 		return $newid; | ||||
| 	} | ||||
|  | ||||
| 	function editWithFiles ($userid, $wiki, $attached_files, $uploader) | ||||
| 	{ | ||||
| 		set_error_handler (array ($this, 'capture_error')); | ||||
| 		$errmsg = ''; | ||||
| 		$x = $this->_edit_wiki ($userid, $wiki, $attached_files, $uploader); | ||||
| 		restore_error_handler (); | ||||
| 		return $x; | ||||
| 	} | ||||
| } | ||||
|  | ||||
| ?> | ||||
|  | ||||
| @ -227,7 +227,7 @@ $(function () { | ||||
| 								if (data == 'ok')  | ||||
| 								{ | ||||
| 									// refresh the page to the head revision | ||||
| 									$(location).attr ('href', codepot_merge_path('<?php print site_url(); ?>', '<?php print "/file/show/{$project->id}/"; ?>' + codepot_ascii_to_hex(new_name))); | ||||
| 									$(location).attr ('href', codepot_merge_path('<?php print site_url(); ?>', '<?php print "/file/show/{$project->id}/"; ?>' + codepot_string_to_hex(new_name))); | ||||
| 								} | ||||
| 								else | ||||
| 								{ | ||||
|  | ||||
| @ -30,15 +30,15 @@ $hex_wikiname = $this->converter->AsciiToHex ($wiki->name); | ||||
|  | ||||
| function render_wiki(input_text) | ||||
| { | ||||
| 	var column_count = $("#wiki_edit_mainarea_text_column_count").val(); | ||||
| 	var column_count = $("#wiki_edit_text_column_count").val(); | ||||
| 	var x_column_count = parseInt (column_count); | ||||
| 	if (isNaN(x_column_count) || x_column_count < 1) x_column_count = 1; | ||||
| 	else if (x_column_count > 9) x_column_count = 9; // sync this max value with wiki_show. TODO: put this into codepot.ini | ||||
|  | ||||
| 	column_count = x_column_count.toString(); | ||||
| 	$("#wiki_edit_mainarea_text_column_count").val(column_count); | ||||
| 	$("#wiki_edit_text_column_count").val(column_count); | ||||
|  | ||||
| 	$("#wiki_edit_mainarea_text_preview").css ({ | ||||
| 	$("#wiki_edit_text_preview").css ({ | ||||
| 		"-moz-column-count":    column_count, | ||||
| 		"-webkit-column-count": column_count, | ||||
| 		"column-count":         column_count | ||||
| @ -46,7 +46,7 @@ function render_wiki(input_text) | ||||
|  | ||||
| 	creole_render_wiki_with_input_text ( | ||||
| 		input_text, | ||||
| 		"wiki_edit_mainarea_text_preview",  | ||||
| 		"wiki_edit_text_preview",  | ||||
| 		"<?php print site_url()?>/wiki/show/<?php print $project->id?>/", | ||||
| 		"<?php print site_url()?>/wiki/attachment/<?php print $project->id?>/<?php print $hex_wikiname?>/" | ||||
| 	); | ||||
| @ -69,9 +69,9 @@ $(function () { | ||||
| 		} | ||||
| 	); | ||||
|  | ||||
| 	$("#wiki_edit_mainarea_text_preview_button").button().click( | ||||
| 	$("#wiki_edit_text_preview_button").button().click( | ||||
| 		function () { | ||||
| 			render_wiki ($("#wiki_edit_mainarea_text").val()); | ||||
| 			render_wiki ($("#wiki_edit_text_area").val()); | ||||
| 			return false; | ||||
| 		} | ||||
| 	); | ||||
| @ -123,7 +123,7 @@ $this->load->view ( | ||||
| 	</div> | ||||
| 	<div class='form_input_field'> | ||||
| 		<?php  | ||||
| 			$extra = 'maxlength="80" size="40" id="wiki_edit_mainarea_name"'; | ||||
| 			$extra = 'maxlength="80" size="40" id="wiki_edit_name"'; | ||||
| 			//$extra .= ($mode == 'update')? ' readonly="readonly"': '';  | ||||
| 		?> | ||||
| 		<?php print form_input('wiki_name', set_value('wiki_name', $wiki->name), $extra)?> | ||||
| @ -132,12 +132,12 @@ $this->load->view ( | ||||
|  | ||||
| 	<div class='form_input_label'> | ||||
| 		<?php print form_label($this->lang->line('Text').': ', 'wiki_text')?> | ||||
| 		<a href='#' id='wiki_edit_mainarea_text_preview_button'><?php print $this->lang->line('Preview')?></a> | ||||
| 		<a href='#' id='wiki_edit_text_preview_button'><?php print $this->lang->line('Preview')?></a> | ||||
|  | ||||
| 		<?php | ||||
| 			$attrs = array ( | ||||
| 				'name' => 'wiki_columns', | ||||
| 				'id' => 'wiki_edit_mainarea_text_column_count', | ||||
| 				'id' => 'wiki_edit_text_column_count', | ||||
| 				'value' => set_value('wiki_columns', $wiki->columns), | ||||
| 				'size' => '2', | ||||
| 				'min' => '1', | ||||
| @ -155,14 +155,14 @@ $this->load->view ( | ||||
| 			$xdata = array ( | ||||
| 				'name' => 'wiki_text', | ||||
| 				'value' => set_value ('wiki_text', $wiki->text), | ||||
| 				'id' => 'wiki_edit_mainarea_text', | ||||
| 				'id' => 'wiki_edit_text_area', | ||||
| 				'rows' => 20, | ||||
| 				'cols' => 80 | ||||
| 			); | ||||
| 			print form_textarea ($xdata); | ||||
| 		?> | ||||
| 	</div> | ||||
| 	<div id='wiki_edit_mainarea_text_preview' class='form_input_preview'></div> | ||||
| 	<div id='wiki_edit_text_preview' class='form_input_preview'></div> | ||||
|  | ||||
| 	<?php if (!empty($wiki->attachments)): ?> | ||||
| 	<div class='form_input_label'> | ||||
|  | ||||
| @ -73,6 +73,32 @@ function resize_editor() | ||||
|  | ||||
| var new_attachment_no = 0; | ||||
| var wiki_text_editor = null; | ||||
| var work_in_progress = false; | ||||
| var wiki_original_name = '<?php print addslashes($wiki->name); ?>'; | ||||
| var wiki_new_name = ''; | ||||
|  | ||||
| function show_in_progress_message (outputMsg, titleMsg) | ||||
| { | ||||
| 	if (titleMsg == null || outputMsg == null) | ||||
| 	{ | ||||
| 		$('#wiki_edit_alert').dialog('close'); | ||||
| 	} | ||||
| 	else | ||||
| 	{ | ||||
| 		$('#wiki_edit_alert').html(outputMsg).dialog({ | ||||
| 			title: titleMsg, | ||||
| 			resizable: false, | ||||
| 			modal: true, | ||||
| 			width: 'auto', | ||||
| 			height: 'auto', | ||||
|  | ||||
| 			beforeClose: function() {  | ||||
| 				// if importing is in progress, prevent dialog closing | ||||
| 				return !work_in_progress; | ||||
| 			} | ||||
| 		}); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| $(function () { | ||||
| 	$('#wiki_edit_more_new_attachment').button().click ( | ||||
| @ -128,12 +154,96 @@ $(function () { | ||||
| 		} | ||||
| 	}); | ||||
|  | ||||
| <?php if ($mode == 'update'): ?> | ||||
| 	wiki_text_editor.setContent ('<?php print addslashes($wiki->text); ?>', 0); | ||||
| <?php endif; ?> | ||||
|  | ||||
| 	$("#wiki_edit_save_button").button().click (function() { | ||||
| 		// TODO: | ||||
| 		var e = wiki_text_editor.serialize(); | ||||
| 		alert (e.wiki_edit_text_editor.value); | ||||
| 		//console.log ("%o", wiki_text_editor); | ||||
| 		//console.log ("%o", e); | ||||
|  | ||||
| 		if (work_in_progress) return; | ||||
|  | ||||
| 		if (!!window.FormData) | ||||
| 		{ | ||||
| 			// FormData is supported | ||||
| 			work_in_progress = true; | ||||
| 			show_in_progress_message ('Saving in progress. Please wait...', 'Saving...'); | ||||
|  | ||||
| 			wiki_new_name = $('#wiki_edit_name').val(); | ||||
|  | ||||
| 			var form_data = new FormData(); | ||||
|  | ||||
| 			/* | ||||
| 			var f_no = 0; | ||||
| 			for (var i = 0; i <= populated_file_max; i++) | ||||
| 			{ | ||||
|  | ||||
| 				var f = populated_file_obj[i]; | ||||
| 				if (f != null) | ||||
| 				{ | ||||
| 					form_data.append ('wiki_file_' + f_no, f); | ||||
|  | ||||
| 					var d = $('#wiki_edit_file_desc_' + i); | ||||
| 					if (d != null) form_data.append('wiki_file_desc_' + f_no, d.val()); | ||||
|  | ||||
| 					f_no++; | ||||
| 				} | ||||
| 			} | ||||
|  | ||||
| 			form_data.append ('wiki_file_count', f_no);*/ | ||||
|  | ||||
| 			form_data.append ('wiki_type', 'H'); | ||||
| 			form_data.append ('wiki_name', wiki_new_name); | ||||
| 			form_data.append ('wiki_original_name', wiki_original_name); | ||||
| 			form_data.append ('wiki_text', e.wiki_edit_text_editor.value); | ||||
|  | ||||
| 			$.ajax({ | ||||
| 				url: codepot_merge_path('<?php print site_url() ?>', '<?php print "/wiki/xhr_edit/{$project->id}"; ?>'), | ||||
| 				type: 'POST', | ||||
| 				data: form_data, | ||||
| 				mimeType: 'multipart/form-data', | ||||
| 				contentType: false, | ||||
| 				processData: false, | ||||
| 				cache: false, | ||||
|  | ||||
| 				success: function (data, textStatus, jqXHR) {  | ||||
| 					work_in_progress = false; | ||||
| 					show_in_progress_message (null, null); | ||||
| 					if (data == 'ok')  | ||||
| 					{ | ||||
| 						wiki_original_name = wiki_new_name; | ||||
| 						// TODO: reload contents? | ||||
| 					} | ||||
| 					else | ||||
| 					{ | ||||
| 						show_alert ('<pre>' + codepot_htmlspecialchars(data) + '</pre>', "<?php print $this->lang->line('Error')?>"); | ||||
| 					} | ||||
| 				}, | ||||
|  | ||||
| 				error: function (jqXHR, textStatus, errorThrown) {  | ||||
| 					work_in_progress = false; | ||||
| 					show_in_progress_message (null, null); | ||||
| 					var errmsg = ''; | ||||
| 					if (errmsg == '' && errorThrown != null) errmsg = errorThrown; | ||||
| 					if (errmsg == '' && textStatus != null) errmsg = textStatus; | ||||
| 					if (errmsg == '') errmsg = 'Unknown error'; | ||||
| 					show_alert ('Failed - ' + errmsg, "<?php print $this->lang->line('Error')?>"); | ||||
| 				} | ||||
| 			}); | ||||
| 		} | ||||
| 		else | ||||
| 		{ | ||||
| 			show_alert ('<pre>NOT SUPPORTED</pre>', "<?php print $this->lang->line('Error')?>"); | ||||
| 		} | ||||
| 	 | ||||
| 		return false; | ||||
| 	}); | ||||
|  | ||||
| 	$("#wiki_edit_exit_button").button().click (function() { | ||||
| 		if (wiki_original_name == '') | ||||
| 			$(location).attr ('href', codepot_merge_path('<?php print site_url(); ?>', '<?php print "/wiki/home/{$project->id}"; ?>')); | ||||
| 		else | ||||
| 			$(location).attr ('href', codepot_merge_path('<?php print site_url(); ?>', '<?php print "/wiki/show/{$project->id}/"; ?>' + codepot_string_to_hex(wiki_original_name))); | ||||
| 		return false; | ||||
| 	}); | ||||
|  | ||||
| @ -177,12 +287,11 @@ $this->load->view ( | ||||
| <div class="mainarea" id="wiki_edit_mainarea"> | ||||
|  | ||||
| <div class="title-band" id="wiki_edit_title_band"> | ||||
| 	<div class="title"><input type="text" name="wiki_name" value="" maxlength="80" size="40" id="wiki_edit_name" placeholder="<?php print $this->lang->line('Name'); ?>" /></div> | ||||
| 	<div class="title"><input type="text" name="wiki_name" value="<?php print addslashes($wiki->name); ?>" maxlength="80" size="40" id="wiki_edit_name" placeholder="<?php print $this->lang->line('Name'); ?>" /></div> | ||||
|  | ||||
| 	<div class="actions"> | ||||
| 		<?php if (isset($login['id']) && $login['id'] != ''): ?> | ||||
| 		<a id="wiki_edit_save_button" href='#'><?php print $this->lang->line('Save')?></a> | ||||
| 		<?php endif; ?> | ||||
| 		<a id="wiki_edit_exit_button" href='#'><?php print $this->lang->line('Exit')?></a> | ||||
| 	</div> | ||||
|  | ||||
| 	<div style='clear: both'></div> | ||||
| @ -226,12 +335,6 @@ $this->load->view ( | ||||
| </div> | ||||
|  | ||||
| <div id="wiki_edit_result"> | ||||
|  | ||||
| 	<input type="hidden" name="wiki_projectid" value="<?php print addslashes($wiki->projectid); ?>"  id="wiki_edit_projectid" /> | ||||
| 	<?php if ($mode == 'update'): ?> | ||||
| 	<input type="hidden" name="wiki_original_name" value="<?php print addslashes($wiki->name); ?>"  id="wiki_edit_original_name" /> | ||||
| 	<?php endif; ?> | ||||
|  | ||||
| 	<div id='wiki_edit_text_editor'></div> | ||||
| </div> <!-- wiki_edit_result --> | ||||
|  | ||||
| @ -250,7 +353,6 @@ $this->load->view ( | ||||
|  | ||||
| <!----------------------------------------------------------------------------> | ||||
|  | ||||
|  | ||||
| </body> | ||||
|  | ||||
| </html> | ||||
|  | ||||
| @ -39,7 +39,6 @@ $(function () { | ||||
| <?php if (isset($login['id']) && $login['id'] != ''): ?> | ||||
| 	$("#wiki_home_new_button").button().click ( | ||||
| 		function () {  | ||||
| 			//$('#wiki_home_new_form').dialog('open');  | ||||
| 			$(location).attr ('href', codepot_merge_path('<?php print site_url(); ?>', '<?php print "/wiki/createx/{$project->id}"; ?>')); | ||||
| 			return false; | ||||
| 		} | ||||
|  | ||||
| @ -24,13 +24,40 @@ | ||||
| <title><?php  | ||||
| 	printf ('%s - %s', htmlspecialchars($project->name), htmlspecialchars($wiki->name)); | ||||
| ?></title> | ||||
| </head> | ||||
|  | ||||
|  | ||||
| <?php | ||||
| $hexname = $this->converter->AsciiToHex ($wiki->name); | ||||
| $hex_wikiname = $this->converter->AsciiToHex ($wiki->name); | ||||
|  | ||||
| if ($wiki->type == 'H') | ||||
| { | ||||
| 	$is_html = TRUE; | ||||
| 	$update_command = 'updatex'; | ||||
| } | ||||
| else | ||||
| { | ||||
| 	$is_html = FALSE; | ||||
| 	$update_command = 'update'; | ||||
| } | ||||
| ?> | ||||
|  | ||||
| <script type="text/javascript"> | ||||
| function show_alert (outputMsg, titleMsg)  | ||||
| { | ||||
| 	$('#wiki_show_alert').html(outputMsg).dialog({ | ||||
| 		title: titleMsg, | ||||
| 		resizable: true, | ||||
| 		modal: true, | ||||
| 		width: 'auto', | ||||
| 		height: 'auto', | ||||
| 		buttons: { | ||||
| 			"OK": function () { | ||||
| 				$(this).dialog("close"); | ||||
| 			} | ||||
| 		} | ||||
| 	}); | ||||
| } | ||||
|  | ||||
| function render_wiki() | ||||
| { | ||||
| 	var column_count = '<?php print  $wiki->columns ?>'; | ||||
| @ -52,22 +79,124 @@ function render_wiki() | ||||
| 		"wiki_show_wiki_text",  | ||||
| 		"wiki_show_wiki",  | ||||
| 		"<?php print site_url()?>/wiki/show/<?php print $project->id?>/", | ||||
| 		"<?php print site_url()?>/wiki/attachment/<?php print $project->id?>/<?php print $hexname?>/" | ||||
| 		"<?php print site_url()?>/wiki/attachment/<?php print $project->id?>/<?php print $hex_wikiname?>/" | ||||
| 	); | ||||
|  | ||||
| 	prettyPrint (); | ||||
| } | ||||
|  | ||||
| var work_in_progress = false; | ||||
|  | ||||
| $(function () { | ||||
| 	$('#wiki_show_metadata').accordion({ | ||||
| 		collapsible: true, | ||||
| 		heightStyle: "content" | ||||
| 	}); | ||||
|  | ||||
| <?php if (isset($login['id']) && $login['id'] != ''): ?> | ||||
| 	$('#wiki_show_delete_form').dialog ( | ||||
| 		{ | ||||
| 			title: '<?php print $this->lang->line('Delete');?>', | ||||
| 			resizable: true, | ||||
| 			autoOpen: false, | ||||
| 			width: 'auto', | ||||
| 			height: 'auto', | ||||
| 			modal: true, | ||||
| 			buttons: { | ||||
| 				'<?php print $this->lang->line('OK')?>': function () { | ||||
| 					if (work_in_progress) return; | ||||
|  | ||||
| 					if (!!window.FormData) | ||||
| 					{ | ||||
| 						// FormData is supported | ||||
| 						work_in_progress = true; | ||||
|  | ||||
| 						var form_data = new FormData(); | ||||
|  | ||||
| 						var f = $('#wiki_show_delete_confirm'); | ||||
| 						if (f != null && f.is(':checked')) form_data.append ('wiki_delete_confirm', 'Y'); | ||||
|  | ||||
| 						$('#wiki_show_delete_form').dialog('disable'); | ||||
| 						$.ajax({ | ||||
| 							url: codepot_merge_path('<?php print site_url() ?>', '<?php print "/wiki/xhr_delete/{$project->id}/{$hex_wikiname}"; ?>'), | ||||
| 							type: 'POST', | ||||
| 							data: form_data, | ||||
| 							mimeType: 'multipart/form-data', | ||||
| 							contentType: false, | ||||
| 							processData: false, | ||||
| 							cache: false, | ||||
|  | ||||
| 							success: function (data, textStatus, jqXHR) {  | ||||
| 								work_in_progress = false; | ||||
| 								$('#wiki_show_delete_form').dialog('enable'); | ||||
| 								$('#wiki_show_delete_form').dialog('close'); | ||||
| 								if (data == 'ok')  | ||||
| 								{ | ||||
| 									// refresh the page to the head revision | ||||
| 									$(location).attr ('href', codepot_merge_path('<?php print site_url(); ?>', '<?php print "/wiki/home/{$project->id}"; ?>')); | ||||
| 								} | ||||
| 								else | ||||
| 								{ | ||||
| 									show_alert ('<pre>' + codepot_htmlspecialchars(data) + '</pre>', "<?php print $this->lang->line('Error')?>"); | ||||
| 								} | ||||
| 							}, | ||||
|  | ||||
| 							error: function (jqXHR, textStatus, errorThrown) {  | ||||
| 								work_in_progress = false; | ||||
| 								$('#wiki_show_delete_form').dialog('enable'); | ||||
| 								$('#wiki_show_delete_form').dialog('close'); | ||||
| 								show_alert ('Failed - ' + errorThrown, "<?php print $this->lang->line('Error')?>"); | ||||
| 							} | ||||
| 						}); | ||||
| 					} | ||||
| 					else | ||||
| 					{ | ||||
| 						show_alert ('<pre>NOT SUPPORTED</pre>', "<?php print $this->lang->line('Error')?>"); | ||||
| 					} | ||||
| 				}, | ||||
| 				'<?php print $this->lang->line('Cancel')?>': function () { | ||||
| 					if (work_in_progress) return; | ||||
| 					$('#wiki_show_delete_form').dialog('close'); | ||||
| 				} | ||||
| 			}, | ||||
|  | ||||
| 			beforeClose: function() {  | ||||
| 				// if importing is in progress, prevent dialog closing | ||||
| 				return !work_in_progress; | ||||
| 			} | ||||
| 		} | ||||
| 	); | ||||
|  | ||||
| 	$("#wiki_show_new_button").button().click ( | ||||
| 		function () {  | ||||
| 			$(location).attr ('href', codepot_merge_path('<?php print site_url(); ?>', '<?php print "/wiki/createx/{$project->id}"; ?>')); | ||||
| 			return false; | ||||
| 		} | ||||
| 	); | ||||
| 	$("#wiki_show_edit_button").button().click ( | ||||
| 		function () {  | ||||
| 			$(location).attr ('href', codepot_merge_path('<?php print site_url(); ?>', '<?php print "/wiki/{$update_command}/{$project->id}/{$hex_wikiname}"; ?>')); | ||||
| 			return false; | ||||
| 		} | ||||
| 	); | ||||
| 	$('#wiki_show_delete_button').button().click ( | ||||
| 		function () {  | ||||
| 			$('#wiki_show_delete_form').dialog('open');  | ||||
| 			return false; // prevent the default behavior | ||||
| 		} | ||||
| 	); | ||||
| <?php endif; ?> | ||||
|  | ||||
| <?php if ($is_html): ?> | ||||
| 	/* nothing */ | ||||
| <?php else: ?> | ||||
| 	render_wiki (); | ||||
| <?php endif; ?> | ||||
| }); | ||||
| </script> | ||||
|  | ||||
| </head> | ||||
|  | ||||
| <body> | ||||
|  | ||||
| <div class="content" id="wiki_show_content"> | ||||
| @ -92,8 +221,6 @@ $this->load->view ( | ||||
|  | ||||
| 		'ctxmenuitems' => array ( | ||||
| 			array ("wiki/create/{$project->id}", '<i class="fa fa-plus"></i> ' . $this->lang->line('New')), | ||||
| 			array ("wiki/update/{$project->id}/{$hexname}", '<i class="fa fa-edit"></i> ' .$this->lang->line('Edit')), | ||||
| 			array ("wiki/delete/{$project->id}/{$hexname}", '<i class="fa fa-trash"></i> ' .$this->lang->line('Delete')) | ||||
| 		) | ||||
| 	) | ||||
| ); | ||||
| @ -108,6 +235,11 @@ $this->load->view ( | ||||
| 	<div class="title"><?php print htmlspecialchars($wiki->name)?></div> | ||||
|  | ||||
| 	<div class="actions"> | ||||
| 		<?php if (isset($login['id']) && $login['id'] != ''): ?> | ||||
| 		<a id="wiki_show_new_button" href='#'><?php print $this->lang->line('New')?></a> | ||||
| 		<a id="wiki_show_edit_button" href='#'><?php print $this->lang->line('Edit')?></a> | ||||
| 		<a id="wiki_show_delete_button" href='#'><?php print $this->lang->line('Delete')?></a> | ||||
| 		<?php endif; ?> | ||||
| 	</div> | ||||
|  | ||||
| 	<div style='clear: both'></div> | ||||
| @ -136,7 +268,7 @@ $this->load->view ( | ||||
| 					$hexattname = $this->converter->AsciiToHex ($att->name); | ||||
| 					print '<li>'; | ||||
| 					print anchor ( | ||||
| 						"wiki/attachment/{$project->id}/{$hexname}/{$hexattname}",  | ||||
| 						"wiki/attachment/{$project->id}/{$hex_wikiname}/{$hexattname}",  | ||||
| 						htmlspecialchars($att->name) | ||||
| 					); | ||||
| 					print '</li>'; | ||||
| @ -149,15 +281,34 @@ $this->load->view ( | ||||
| 	</div> | ||||
| </div> | ||||
|  | ||||
| <?php  | ||||
| 	if ($is_html) | ||||
| 	{ | ||||
| 		print $wiki->text; | ||||
| 	} | ||||
| 	else | ||||
| 	{ | ||||
| 		print '<div class="result" id="wiki_show_wiki">'; | ||||
| 		print '<pre id="wiki_show_wiki_text" style="visibility: hidden">'; | ||||
| 		print htmlspecialchars($wiki->text); | ||||
| 		print '</pre>'; | ||||
| 		print '</div>'; | ||||
| 	} | ||||
|  | ||||
| <div class="result" id="wiki_show_wiki"> | ||||
| <pre id="wiki_show_wiki_text" style="visibility: hidden"> | ||||
| <?php print htmlspecialchars($wiki->text); ?> | ||||
| </pre> | ||||
| </div> <!-- wiki_show_wiki --> | ||||
| ?> | ||||
|  | ||||
| </div> <!-- wiki_show_result --> | ||||
|  | ||||
|  | ||||
| <?php if (isset($login['id']) && $login['id'] != ''): ?> | ||||
| <div id='wiki_show_delete_form'> | ||||
| 	<input type='checkbox' id='wiki_show_delete_confirm' /> | ||||
| 	<?php print $this->lang->line('MSG_SURE_TO_DELETE_THIS') . ' - ' . htmlspecialchars($wiki->name); ?> | ||||
| </div> | ||||
| <?php endif; ?> | ||||
|  | ||||
| <div id='wiki_show_alert'></div> | ||||
|  | ||||
| </div> <!-- wiki_show_mainarea --> | ||||
|  | ||||
| <div class='footer-pusher'></div> <!-- for sticky footer --> | ||||
|  | ||||
| @ -55,6 +55,7 @@ | ||||
| #wiki_edit_form { | ||||
| } | ||||
|  | ||||
| #wiki_edit_text_area, | ||||
| #wiki_edit_text_editor { | ||||
| 	margin: 0 !important; | ||||
| 	padding: 0 !important; | ||||
| @ -66,4 +67,7 @@ | ||||
| 	outline: none !important; | ||||
| } | ||||
|  | ||||
| #wiki_edit_text_editor pre { | ||||
| 	white-space: pre-wrap !important; | ||||
| } | ||||
|  | ||||
|  | ||||
		Reference in New Issue
	
	Block a user