wiki: lock mimetype
This commit is contained in:
		| @@ -22,6 +22,7 @@ class NativeWiki { | |||||||
| 				$w['htmlName'] = escape_tags($w['rawName']); | 				$w['htmlName'] = escape_tags($w['rawName']); | ||||||
| 				$w['urlName']  = urlencode(urlencode($w['rawName'])); | 				$w['urlName']  = urlencode(urlencode($w['rawName'])); | ||||||
| 				$w['mimeType'] = get_iconfig($w, 'wiki', 'mimeType'); | 				$w['mimeType'] = get_iconfig($w, 'wiki', 'mimeType'); | ||||||
|  | 				$w['typelock'] = get_iconfig($w, 'wiki', 'typelock'); | ||||||
| 				$w['lock']     = (($w['item_private'] || $w['allow_cid'] || $w['allow_gid'] || $w['deny_cid'] || $w['deny_gid']) ? true : false); | 				$w['lock']     = (($w['item_private'] || $w['allow_cid'] || $w['allow_gid'] || $w['deny_cid'] || $w['deny_gid']) ? true : false); | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| @@ -84,7 +85,9 @@ class NativeWiki { | |||||||
| 		if(! set_iconfig($arr, 'wiki', 'mimeType', $wiki['mimeType'], true)) { | 		if(! set_iconfig($arr, 'wiki', 'mimeType', $wiki['mimeType'], true)) { | ||||||
| 			return array('item' => null, 'success' => false); | 			return array('item' => null, 'success' => false); | ||||||
| 		} | 		} | ||||||
| 	 |  | ||||||
|  | 		set_iconfig($arr,'wiki','typelock',$wiki['typelock'],true); | ||||||
|  |  | ||||||
| 		$post = item_store($arr); | 		$post = item_store($arr); | ||||||
|  |  | ||||||
| 		$item_id = $post['item_id']; | 		$item_id = $post['item_id']; | ||||||
| @@ -150,13 +153,15 @@ class NativeWiki { | |||||||
| 			// Get wiki metadata | 			// Get wiki metadata | ||||||
| 			$rawName  = get_iconfig($w, 'wiki', 'rawName'); | 			$rawName  = get_iconfig($w, 'wiki', 'rawName'); | ||||||
| 			$mimeType = get_iconfig($w, 'wiki', 'mimeType'); | 			$mimeType = get_iconfig($w, 'wiki', 'mimeType'); | ||||||
|  | 			$typelock = get_iconfig($w, 'wiki', 'typelock'); | ||||||
|  |  | ||||||
| 			return array( | 			return array( | ||||||
| 				'wiki' => $w, | 				'wiki'     => $w, | ||||||
| 				'rawName' => $rawName, | 				'rawName'  => $rawName, | ||||||
| 				'htmlName' => escape_tags($rawName), | 				'htmlName' => escape_tags($rawName), | ||||||
| 				'urlName' => urlencode(urlencode($rawName)), | 				'urlName'  => urlencode(urlencode($rawName)), | ||||||
| 				'mimeType' => $mimeType | 				'mimeType' => $mimeType, | ||||||
|  | 				'typelock' => $typelock | ||||||
| 			); | 			); | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|   | |||||||
| @@ -201,12 +201,14 @@ class Wiki extends \Zotlabs\Web\Controller { | |||||||
| 						'$mimeType' => array('mimeType', t('Content type'), '', '', ['text/markdown' => t('Markdown'), 'text/bbcode' => t('BBcode'), 'text/plain' => t('Text') ]), | 						'$mimeType' => array('mimeType', t('Content type'), '', '', ['text/markdown' => t('Markdown'), 'text/bbcode' => t('BBcode'), 'text/plain' => t('Text') ]), | ||||||
| 						'$name' => t('Name'), | 						'$name' => t('Name'), | ||||||
| 						'$type' => t('Type'), | 						'$type' => t('Type'), | ||||||
|  | 						'$unlocked' => t('Any type'), | ||||||
| 						'$lockstate' => $x['lockstate'], | 						'$lockstate' => $x['lockstate'], | ||||||
| 						'$acl' => $x['acl'], | 						'$acl' => $x['acl'], | ||||||
| 						'$allow_cid' => $x['allow_cid'], | 						'$allow_cid' => $x['allow_cid'], | ||||||
| 						'$allow_gid' => $x['allow_gid'], | 						'$allow_gid' => $x['allow_gid'], | ||||||
| 						'$deny_cid' => $x['deny_cid'], | 						'$deny_cid' => $x['deny_cid'], | ||||||
| 						'$deny_gid' => $x['deny_gid'], | 						'$deny_gid' => $x['deny_gid'], | ||||||
|  | 						'$typelock' => array('typelock', t('Lock content type'), '', '', array(t('No'), t('Yes'))), | ||||||
| 						'$notify' => array('postVisible', t('Create a status post for this wiki'), '', '', array(t('No'), t('Yes'))) | 						'$notify' => array('postVisible', t('Create a status post for this wiki'), '', '', array(t('No'), t('Yes'))) | ||||||
| 					)); | 					)); | ||||||
|  |  | ||||||
| @@ -323,6 +325,9 @@ class Wiki extends \Zotlabs\Web\Controller { | |||||||
| 			'$cancel' => t('Cancel') | 			'$cancel' => t('Cancel') | ||||||
| 		)); | 		)); | ||||||
|  |  | ||||||
|  | 		$types = [ 'text/bbcode' => t('BBcode'), 'text/markdown' => t('Markdown'), 'text/plain' => 'Text' ]; | ||||||
|  | 		$currenttype = $types[$mimeType]; | ||||||
|  |  | ||||||
| 		$placeholder = t('Short description of your changes (optional)'); | 		$placeholder = t('Short description of your changes (optional)'); | ||||||
| 				 | 				 | ||||||
| 		$o .= replace_macros(get_markup_template('wiki.tpl'),array( | 		$o .= replace_macros(get_markup_template('wiki.tpl'),array( | ||||||
| @@ -337,6 +342,7 @@ class Wiki extends \Zotlabs\Web\Controller { | |||||||
| 			'$resource_id' => $resource_id, | 			'$resource_id' => $resource_id, | ||||||
| 			'$page' => $pageUrlName, | 			'$page' => $pageUrlName, | ||||||
| 			'$mimeType' => $mimeType, | 			'$mimeType' => $mimeType, | ||||||
|  | 			'$typename' => $currenttype, | ||||||
| 			'$content' => $content, | 			'$content' => $content, | ||||||
| 			'$renderedContent' => $renderedContent, | 			'$renderedContent' => $renderedContent, | ||||||
| 			'$pageRename' => array('pageRename', t('New page name'), '', ''), | 			'$pageRename' => array('pageRename', t('New page name'), '', ''), | ||||||
| @@ -422,6 +428,7 @@ class Wiki extends \Zotlabs\Web\Controller { | |||||||
| 			$wiki['htmlName']    = escape_tags($_POST['wikiName']); | 			$wiki['htmlName']    = escape_tags($_POST['wikiName']); | ||||||
| 			$wiki['urlName']     = urlencode(urlencode($_POST['wikiName']));  | 			$wiki['urlName']     = urlencode(urlencode($_POST['wikiName']));  | ||||||
| 			$wiki['mimeType']    = $_POST['mimeType']; | 			$wiki['mimeType']    = $_POST['mimeType']; | ||||||
|  | 			$wiki['typelock']    = $_POST['typelock']; | ||||||
|  |  | ||||||
| 			if($wiki['urlName'] === '') {				 | 			if($wiki['urlName'] === '') {				 | ||||||
| 				notice( t('Error creating wiki. Invalid name.') . EOL); | 				notice( t('Error creating wiki. Invalid name.') . EOL); | ||||||
|   | |||||||
| @@ -35,6 +35,7 @@ class Wiki_pages { | |||||||
| 			if (!$wikiname) { | 			if (!$wikiname) { | ||||||
| 				$wikiname = ''; | 				$wikiname = ''; | ||||||
| 			} | 			} | ||||||
|  | 			$typelock = $w['typelock']; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		$can_create = perm_is_allowed(\App::$profile['uid'],get_observer_hash(),'write_wiki'); | 		$can_create = perm_is_allowed(\App::$profile['uid'],get_observer_hash(),'write_wiki'); | ||||||
| @@ -50,6 +51,8 @@ class Wiki_pages { | |||||||
| 				'$canadd' => $can_create, | 				'$canadd' => $can_create, | ||||||
| 				'$candel' => $can_delete, | 				'$candel' => $can_delete, | ||||||
| 				'$addnew' => t('Add new page'), | 				'$addnew' => t('Add new page'), | ||||||
|  | 				'$typelock' => $typelock, | ||||||
|  | 				'$lockedtype' => $w['mimeType'], | ||||||
| 				'$mimetype' => mimetype_select(0,$w['mimeType'], [ 'text/markdown','text/bbcode', 'text/plain' ]), | 				'$mimetype' => mimetype_select(0,$w['mimeType'], [ 'text/markdown','text/bbcode', 'text/plain' ]), | ||||||
| 				'$pageName' => array('pageName', t('Page name')), | 				'$pageName' => array('pageName', t('Page name')), | ||||||
| 				'$refresh' => $arr['refresh'] | 				'$refresh' => $arr['refresh'] | ||||||
|   | |||||||
| @@ -1,6 +1,7 @@ | |||||||
| <div class="generic-content-wrapper" {{if $hideEditor}}style="display: none;"{{/if}}> | <div class="generic-content-wrapper" {{if $hideEditor}}style="display: none;"{{/if}}> | ||||||
| 	<div class="section-title-wrapper"> | 	<div class="section-title-wrapper"> | ||||||
| 		<div class="pull-right"> | 		<div class="pull-right"> | ||||||
|  | 			<span class="wiki-typename">[{{$typename}}] </span> | ||||||
| 			{{if $showPageControls}} | 			{{if $showPageControls}} | ||||||
| 			<div id="page-tools" class="btn-group" style="display: none;"> | 			<div id="page-tools" class="btn-group" style="display: none;"> | ||||||
| 				<button type="button" class="btn btn-outline-secondary btn-sm dropdown-toggle" data-toggle="dropdown"> | 				<button type="button" class="btn btn-outline-secondary btn-sm dropdown-toggle" data-toggle="dropdown"> | ||||||
|   | |||||||
| @@ -21,7 +21,11 @@ | |||||||
| 	<div id="new-page-form-wrapper" class="sub-menu" style="display:none;"> | 	<div id="new-page-form-wrapper" class="sub-menu" style="display:none;"> | ||||||
| 		<form id="new-page-form" action="wiki/{{$channel_address}}/create/page" method="post" > | 		<form id="new-page-form" action="wiki/{{$channel_address}}/create/page" method="post" > | ||||||
| 			<input type="hidden" name="resource_id" value="{{$resource_id}}"> | 			<input type="hidden" name="resource_id" value="{{$resource_id}}"> | ||||||
|  | 			{{if $typelock}} | ||||||
|  | 			<input type="hidden" name="mimetype" value="{{$lockedtype}}"> | ||||||
|  | 			{{else}} | ||||||
| 			{{$mimetype}} | 			{{$mimetype}} | ||||||
|  | 			{{/if}} | ||||||
| 			{{include file="field_input.tpl" field=$pageName}} | 			{{include file="field_input.tpl" field=$pageName}} | ||||||
| 			<button id="new-page-submit" class="btn btn-primary" type="submit" name="submit" >Submit</button> | 			<button id="new-page-submit" class="btn btn-primary" type="submit" name="submit" >Submit</button> | ||||||
| 		</form> | 		</form> | ||||||
|   | |||||||
| @@ -10,6 +10,7 @@ | |||||||
| 		<form id="new-wiki-form" action="wiki/{{$channel}}/create/wiki" method="post" class="acl-form" data-form_id="new-wiki-form" data-allow_cid='{{$allow_cid}}' data-allow_gid='{{$allow_gid}}' data-deny_cid='{{$deny_cid}}' data-deny_gid='{{$deny_gid}}'> | 		<form id="new-wiki-form" action="wiki/{{$channel}}/create/wiki" method="post" class="acl-form" data-form_id="new-wiki-form" data-allow_cid='{{$allow_cid}}' data-allow_gid='{{$allow_gid}}' data-deny_cid='{{$deny_cid}}' data-deny_gid='{{$deny_gid}}'> | ||||||
| 			{{include file="field_input.tpl" field=$wikiName}} | 			{{include file="field_input.tpl" field=$wikiName}} | ||||||
| 			{{include file="field_select.tpl" field=$mimeType}} | 			{{include file="field_select.tpl" field=$mimeType}} | ||||||
|  | 			{{include file="field_checkbox.tpl" field=$typelock}} | ||||||
| 			{{include file="field_checkbox.tpl" field=$notify}} | 			{{include file="field_checkbox.tpl" field=$notify}} | ||||||
| 			<div> | 			<div> | ||||||
| 				<div class="btn-group pull-right"> | 				<div class="btn-group pull-right"> | ||||||
| @@ -31,6 +32,7 @@ | |||||||
| 				<th width="1%">{{$type}}</th> | 				<th width="1%">{{$type}}</th> | ||||||
| 				<th width="1%" class="wikis-index-tool"></th> | 				<th width="1%" class="wikis-index-tool"></th> | ||||||
| 				<th width="1%" class="wikis-index-tool"></th> | 				<th width="1%" class="wikis-index-tool"></th> | ||||||
|  | 				<th width="1%" class="wikis-index-tool"></th> | ||||||
| 				{{if $owner}} | 				{{if $owner}} | ||||||
| 				<th width="1%"></th> | 				<th width="1%"></th> | ||||||
| 				{{/if}} | 				{{/if}} | ||||||
| @@ -38,16 +40,17 @@ | |||||||
| 			{{foreach $wikis as $wiki}} | 			{{foreach $wikis as $wiki}} | ||||||
| 			<tr class="wikis-index-row"> | 			<tr class="wikis-index-row"> | ||||||
| 				<td><a href="/wiki/{{$channel}}/{{$wiki.urlName}}/Home" title="{{$view}}"{{if $wiki.active}} class="active"{{/if}}>{{$wiki.title}}</a></td> | 				<td><a href="/wiki/{{$channel}}/{{$wiki.urlName}}/Home" title="{{$view}}"{{if $wiki.active}} class="active"{{/if}}>{{$wiki.title}}</a></td> | ||||||
| 				<td>{{$wiki.mimeType}}</td> | 				<td>{{if $wiki.typelock}}{{$wiki.mimeType}}{{else}}{{$unlocked}}{{/if}}</td> | ||||||
| 				<td class="wiki-index-tool dropdown"> | 				<td class="wiki-index-tool dropdown"> | ||||||
| 					{{if $wiki.lock}} | 					{{if $wiki.lock}} | ||||||
| 					<i class="fa fa-lock lockview" data-toggle="dropdown" onclick="lockview('item',{{$wiki.id}});"></i></button> | 					<button class="btn btn-default btn-sm" onclick="lockview('item',{{$wiki.id}});"><i class="fa fa-lock lockview" data-toggle="dropdown" ></i></button> | ||||||
| 					<ul id="panel-{{$wiki.id}}" class="lockview-panel dropdown-menu dropdown-menu-right"></ul> | 					<ul id="panel-{{$wiki.id}}" class="lockview-panel dropdown-menu dropdown-menu-right"></ul> | ||||||
| 					{{/if}} | 					{{/if}} | ||||||
| 				</td> | 				</td> | ||||||
| 				<td class="wiki-index-tool"><i class="fa fa-download fakelink" onclick="wiki_download_wiki('{{$wiki.resource_id}}'); return false;"></i></td> | 				<td class="wiki-index-tool"><button class="btn btn-default btn-sm" onclick="wiki_download_wiki('{{$wiki.resource_id}}'); return false;"><i class="fa fa-download fakelink" ></i></button></td> | ||||||
| 				{{if $owner}} | 				{{if $owner}} | ||||||
| 				<td><i class="fa fa-trash-o drop-icons" onclick="wiki_delete_wiki('{{$wiki.title}}', '{{$wiki.resource_id}}'); return false;"></i></td> | 				<td> </td> | ||||||
|  | 				<td><button class="btn btn-default btn-sm" onclick="wiki_delete_wiki('{{$wiki.title}}', '{{$wiki.resource_id}}'); return false;"><i class="fa fa-trash-o drop-icons" ></i></button></td> | ||||||
| 				{{/if}} | 				{{/if}} | ||||||
| 			</tr> | 			</tr> | ||||||
| 			{{/foreach}} | 			{{/foreach}} | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user