From d7ec6865b4ed07f1c5d37158f5e20d97a27617a7 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 14 Sep 2017 04:06:09 -0700 Subject: bring back wiki download --- Zotlabs/Lib/NativeWikiPage.php | 6 +++--- Zotlabs/Module/Wiki.php | 36 ++++++++++++++++++++++++++++++++---- 2 files changed, 35 insertions(+), 7 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/NativeWikiPage.php b/Zotlabs/Lib/NativeWikiPage.php index 558a70a3c..4b637781e 100644 --- a/Zotlabs/Lib/NativeWikiPage.php +++ b/Zotlabs/Lib/NativeWikiPage.php @@ -607,11 +607,11 @@ class NativeWikiPage { } static public function get_file_ext($arr) { - if($arr['mimeType'] === 'text/bbcode') + if($arr['mimetype'] === 'text/bbcode') return '.bb'; - elseif($arr['mimeType'] === 'text/markdown') + elseif($arr['mimetype'] === 'text/markdown') return '.md'; - elseif($arr['mimeType'] === 'text/plain') + elseif($arr['mimetype'] === 'text/plain') return '.txt'; } diff --git a/Zotlabs/Module/Wiki.php b/Zotlabs/Module/Wiki.php index 1eb600f51..9a30d1b42 100644 --- a/Zotlabs/Module/Wiki.php +++ b/Zotlabs/Module/Wiki.php @@ -113,12 +113,13 @@ class Wiki extends \Zotlabs\Web\Controller { $o = ''; // Download a wiki -/* + if((argc() > 3) && (argv(2) === 'download') && (argv(3) === 'wiki')) { $resource_id = argv(4); + $w = Zlib\NativeWiki::get_wiki($owner['channel_id'],$observer_hash,$resource_id); - $w = Zlib\NativeWiki::get_wiki($owner,$observer_hash,$resource_id); +// $w = Zlib\NativeWiki::get_wiki($owner,$observer_hash,$resource_id); if(! $w['htmlName']) { notice(t('Error retrieving wiki') . EOL); } @@ -133,8 +134,35 @@ class Wiki extends \Zotlabs\Web\Controller { $zip_filename = $w['urlName']; $zip_filepath = '/tmp/' . $zip_folder_name . '/' . $zip_filename; + // Generate the zip file - ZLib\ExtendedZip::zipTree($w['path'], $zip_filepath, \ZipArchive::CREATE); + + $zip = new \ZipArchive; + $r = $zip->open($zip_filepath, \ZipArchive::CREATE); + if($r === true) { + $i = q("select * from item where resource_type = 'nwikipage' and resource_id = '%s'", + dbesc($resource_id) + ); + if($i) { + foreach($i as $iv) { + if($iv['mimetype'] === 'text/plain') { + $content = html_entity_decode($iv['body'],ENT_COMPAT,'UTF-8'); + } + elseif($iv['mimetype'] === 'text/bbcode') { + $content = html_entity_decode($iv['body'],ENT_COMPAT,'UTF-8'); + } + elseif($iv['mimetype'] === 'text/markdown') { + $content = html_entity_decode(\Zlib\MarkdownSoap::unescape($iv['body']),ENT_COMPAT,'UTF-8'); + } + $fname = get_iconfig($iv['id'],'nwikipage','pagetitle') . Zlib\NativeWikiPage::get_file_ext($iv); + $zip->addFromString($fname,$content); + } + + + } + + } + $zip->close(); // Output the file for download @@ -153,7 +181,7 @@ class Wiki extends \Zotlabs\Web\Controller { killme(); } -*/ + switch(argc()) { case 2: $wikis = Zlib\NativeWiki::listwikis($owner, get_observer_hash()); -- cgit v1.2.3 From cf120b235117017a81b8a9b1a073919fb1b7d50b Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 14 Sep 2017 17:14:50 -0700 Subject: wiki: lock mimetype --- Zotlabs/Lib/NativeWiki.php | 15 ++++++++++----- Zotlabs/Module/Wiki.php | 7 +++++++ Zotlabs/Widget/Wiki_pages.php | 3 +++ 3 files changed, 20 insertions(+), 5 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/NativeWiki.php b/Zotlabs/Lib/NativeWiki.php index 4301feaa0..0c1894625 100644 --- a/Zotlabs/Lib/NativeWiki.php +++ b/Zotlabs/Lib/NativeWiki.php @@ -22,6 +22,7 @@ class NativeWiki { $w['htmlName'] = escape_tags($w['rawName']); $w['urlName'] = urlencode(urlencode($w['rawName'])); $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); } } @@ -84,7 +85,9 @@ class NativeWiki { if(! set_iconfig($arr, 'wiki', 'mimeType', $wiki['mimeType'], true)) { return array('item' => null, 'success' => false); } - + + set_iconfig($arr,'wiki','typelock',$wiki['typelock'],true); + $post = item_store($arr); $item_id = $post['item_id']; @@ -150,13 +153,15 @@ class NativeWiki { // Get wiki metadata $rawName = get_iconfig($w, 'wiki', 'rawName'); $mimeType = get_iconfig($w, 'wiki', 'mimeType'); + $typelock = get_iconfig($w, 'wiki', 'typelock'); return array( - 'wiki' => $w, - 'rawName' => $rawName, + 'wiki' => $w, + 'rawName' => $rawName, 'htmlName' => escape_tags($rawName), - 'urlName' => urlencode(urlencode($rawName)), - 'mimeType' => $mimeType + 'urlName' => urlencode(urlencode($rawName)), + 'mimeType' => $mimeType, + 'typelock' => $typelock ); } } diff --git a/Zotlabs/Module/Wiki.php b/Zotlabs/Module/Wiki.php index 9a30d1b42..adea3f515 100644 --- a/Zotlabs/Module/Wiki.php +++ b/Zotlabs/Module/Wiki.php @@ -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') ]), '$name' => t('Name'), '$type' => t('Type'), + '$unlocked' => t('Any type'), '$lockstate' => $x['lockstate'], '$acl' => $x['acl'], '$allow_cid' => $x['allow_cid'], '$allow_gid' => $x['allow_gid'], '$deny_cid' => $x['deny_cid'], '$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'))) )); @@ -323,6 +325,9 @@ class Wiki extends \Zotlabs\Web\Controller { '$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)'); $o .= replace_macros(get_markup_template('wiki.tpl'),array( @@ -337,6 +342,7 @@ class Wiki extends \Zotlabs\Web\Controller { '$resource_id' => $resource_id, '$page' => $pageUrlName, '$mimeType' => $mimeType, + '$typename' => $currenttype, '$content' => $content, '$renderedContent' => $renderedContent, '$pageRename' => array('pageRename', t('New page name'), '', ''), @@ -422,6 +428,7 @@ class Wiki extends \Zotlabs\Web\Controller { $wiki['htmlName'] = escape_tags($_POST['wikiName']); $wiki['urlName'] = urlencode(urlencode($_POST['wikiName'])); $wiki['mimeType'] = $_POST['mimeType']; + $wiki['typelock'] = $_POST['typelock']; if($wiki['urlName'] === '') { notice( t('Error creating wiki. Invalid name.') . EOL); diff --git a/Zotlabs/Widget/Wiki_pages.php b/Zotlabs/Widget/Wiki_pages.php index 3999d9858..f98081da0 100644 --- a/Zotlabs/Widget/Wiki_pages.php +++ b/Zotlabs/Widget/Wiki_pages.php @@ -35,6 +35,7 @@ class Wiki_pages { if (!$wikiname) { $wikiname = ''; } + $typelock = $w['typelock']; } $can_create = perm_is_allowed(\App::$profile['uid'],get_observer_hash(),'write_wiki'); @@ -50,6 +51,8 @@ class Wiki_pages { '$canadd' => $can_create, '$candel' => $can_delete, '$addnew' => t('Add new page'), + '$typelock' => $typelock, + '$lockedtype' => $w['mimeType'], '$mimetype' => mimetype_select(0,$w['mimeType'], [ 'text/markdown','text/bbcode', 'text/plain' ]), '$pageName' => array('pageName', t('Page name')), '$refresh' => $arr['refresh'] -- cgit v1.2.3