Merge remote-tracking branch 'upstream/dev' into doco

This commit is contained in:
Andrew Manning 2016-11-29 22:13:24 -05:00
commit 50a8ba8c18
16 changed files with 938 additions and 904 deletions

View File

@ -42,6 +42,20 @@ class System {
} }
static public function get_project_link() {
if(is_array(\App::$config) && is_array(\App::$config['system']) && \App::$config['system']['project_link'])
return \App::$config['system']['project_link'];
return 'https://hubzilla.org';
}
static public function get_project_srclink() {
if(is_array(\App::$config) && is_array(\App::$config['system']) && \App::$config['system']['project_srclink'])
return \App::$config['system']['project_srclink'];
return 'https://github.com/redmatrix/hubzilla';
}
static public function get_server_role() { static public function get_server_role() {
if(is_array(\App::$config) && is_array(\App::$config['system']) && \App::$config['system']['server_role']) if(is_array(\App::$config) && is_array(\App::$config['system']) && \App::$config['system']['server_role'])
return \App::$config['system']['server_role']; return \App::$config['system']['server_role'];

View File

@ -22,6 +22,7 @@ class Site {
$banner = ((x($_POST,'banner')) ? trim($_POST['banner']) : false); $banner = ((x($_POST,'banner')) ? trim($_POST['banner']) : false);
$admininfo = ((x($_POST,'admininfo')) ? trim($_POST['admininfo']) : false); $admininfo = ((x($_POST,'admininfo')) ? trim($_POST['admininfo']) : false);
$siteinfo = ((x($_POST,'siteinfo')) ? trim($_POST['siteinfo']) : '');
$language = ((x($_POST,'language')) ? notags(trim($_POST['language'])) : ''); $language = ((x($_POST,'language')) ? notags(trim($_POST['language'])) : '');
$theme = ((x($_POST,'theme')) ? notags(trim($_POST['theme'])) : ''); $theme = ((x($_POST,'theme')) ? notags(trim($_POST['theme'])) : '');
$theme_mobile = ((x($_POST,'theme_mobile')) ? notags(trim($_POST['theme_mobile'])) : ''); $theme_mobile = ((x($_POST,'theme_mobile')) ? notags(trim($_POST['theme_mobile'])) : '');
@ -97,6 +98,7 @@ class Site {
linkify_tags($a, $admininfo, local_channel()); linkify_tags($a, $admininfo, local_channel());
set_config('system', 'admininfo', $admininfo); set_config('system', 'admininfo', $admininfo);
} }
set_config('system','siteinfo',$siteinfo);
set_config('system', 'language', $language); set_config('system', 'language', $language);
set_config('system', 'theme', $theme); set_config('system', 'theme', $theme);
if ( $theme_mobile === '---' ) { if ( $theme_mobile === '---' ) {
@ -273,6 +275,7 @@ class Site {
'$banner' => array('banner', t("Banner/Logo"), $banner, ""), '$banner' => array('banner', t("Banner/Logo"), $banner, ""),
'$admininfo' => array('admininfo', t("Administrator Information"), $admininfo, t("Contact information for site administrators. Displayed on siteinfo page. BBCode can be used here")), '$admininfo' => array('admininfo', t("Administrator Information"), $admininfo, t("Contact information for site administrators. Displayed on siteinfo page. BBCode can be used here")),
'$siteinfo' => array('siteinfo', t('Site Information'), get_config('system','siteinfo'), t("Publicly visible description of this site. Displayed on siteinfo page. BBCode can be used here")),
'$language' => array('language', t("System language"), get_config('system','language'), "", $lang_choices), '$language' => array('language', t("System language"), get_config('system','language'), "", $lang_choices),
'$theme' => array('theme', t("System theme"), get_config('system','theme'), t("Default system theme - may be over-ridden by user profiles - <a href='#' id='cnftheme'>change theme settings</a>"), $theme_choices), '$theme' => array('theme', t("System theme"), get_config('system','theme'), t("Default system theme - may be over-ridden by user profiles - <a href='#' id='cnftheme'>change theme settings</a>"), $theme_choices),
'$theme_mobile' => array('theme_mobile', t("Mobile system theme"), get_config('system','mobile_theme'), t("Theme for mobile devices"), $theme_choices_mobile), '$theme_mobile' => array('theme_mobile', t("Mobile system theme"), get_config('system','mobile_theme'), t("Theme for mobile devices"), $theme_choices_mobile),

View File

@ -48,9 +48,6 @@ class Connedit extends \Zotlabs\Web\Controller {
} }
static public function xchan_name_sort($a,$b) {
return strcasecmp($a['xchan_name'],$b['xchan_name']);
}
/* @brief Evaluate posted values and set changes /* @brief Evaluate posted values and set changes
* *
@ -401,6 +398,7 @@ class Connedit extends \Zotlabs\Web\Controller {
return login(); return login();
} }
$section = ((array_key_exists('section',$_REQUEST)) ? $_REQUEST['section'] : '');
$channel = \App::get_channel(); $channel = \App::get_channel();
$my_perms = get_channel_default_perms(local_channel()); $my_perms = get_channel_default_perms(local_channel());
$role = get_pconfig(local_channel(),'system','permissions_role'); $role = get_pconfig(local_channel(),'system','permissions_role');
@ -557,12 +555,11 @@ class Connedit extends \Zotlabs\Web\Controller {
$contact_id = \App::$poi['abook_id']; $contact_id = \App::$poi['abook_id'];
$contact = \App::$poi; $contact = \App::$poi;
$cn = q("SELECT abook_id, xchan_name from abook left join xchan on abook_xchan = xchan_hash where abook_channel = %d and abook_self = 0", $cn = q("SELECT abook_id, xchan_name from abook left join xchan on abook_xchan = xchan_hash where abook_channel = %d and abook_self = 0 order by xchan_name",
intval(local_channel()) intval(local_channel())
); );
if($cn) {
usort($cn, '\\Zotlabs\\Module\\Connedit::xchan_name_sort');
if($cn) {
$pntotal = count($cn); $pntotal = count($cn);
for($x = 0; $x < $pntotal; $x ++) { for($x = 0; $x < $pntotal; $x ++) {
@ -783,6 +780,7 @@ class Connedit extends \Zotlabs\Web\Controller {
'$header' => (($self) ? t('Connection Default Permissions') : sprintf( t('Connection: %s'),$contact['xchan_name'])), '$header' => (($self) ? t('Connection Default Permissions') : sprintf( t('Connection: %s'),$contact['xchan_name'])),
'$autoperms' => array('autoperms',t('Apply these permissions automatically'), ((get_pconfig(local_channel(),'system','autoperms')) ? 1 : 0), t('Connection requests will be approved without your interaction'), $yes_no), '$autoperms' => array('autoperms',t('Apply these permissions automatically'), ((get_pconfig(local_channel(),'system','autoperms')) ? 1 : 0), t('Connection requests will be approved without your interaction'), $yes_no),
'$addr' => $contact['xchan_addr'], '$addr' => $contact['xchan_addr'],
'$section' => $section,
'$addr_text' => t('This connection\'s primary address is'), '$addr_text' => t('This connection\'s primary address is'),
'$loc_text' => t('Available locations:'), '$loc_text' => t('Available locations:'),
'$locstr' => $locstr, '$locstr' => $locstr,

View File

@ -15,63 +15,33 @@ class Siteinfo extends \Zotlabs\Web\Controller {
function get() { function get() {
if(! get_config('system','hidden_version_siteinfo')) { $siteinfo = replace_macros(get_markup_template('siteinfo.tpl'),
$version = sprintf( t('Version %s'), \Zotlabs\Lib\System::get_project_version()); [
if(@is_dir('.git') && function_exists('shell_exec')) { '$title' => t('About this site'),
$commit = @shell_exec('git log -1 --format="%h"'); '$sitenametxt' => t('Site Name'),
$tag = \Zotlabs\Lib\System::get_std_version(); // @shell_exec('git describe --tags --abbrev=0'); '$sitename' => \Zotlabs\Lib\System::get_site_name(),
} '$headline' => t('Site Information'),
if(! isset($commit) || strlen($commit) > 16) '$site_about' => bbcode(get_config('system','siteinfo')),
$commit = ''; '$admin_headline' => t('Administrator'),
} '$admin_about' => bbcode(get_config('system','admininfo')),
else { '$terms' => t('Terms of Service'),
$version = $commit = ''; '$prj_header' => t('Software and Project information'),
} '$prj_name' => t('This site is powered by $Projectname'),
'$prj_transport' => t('Federated and decentralised networking and identity services provided by Zot'),
'$transport_link' => '<a href="http://zotlabs.com">http://zotlabs.com</a>',
'$prj_version' => ((get_config('system','hidden_version_siteinfo')) ? '' : sprintf( t('Version %s'), \Zotlabs\Lib\System::get_project_version())),
'$prj_linktxt' => t('Project homepage'),
'$prj_srctxt' => t('Developer homepage'),
'$prj_link' => \Zotlabs\Lib\System::get_project_link(),
'$prj_src' => \Zotlabs\Lib\System::get_project_srclink(),
]
);
$plugins_list = implode(', ',visible_plugin_list()); call_hooks('about_hook', $siteinfo);
if($plugins_list) return $siteinfo;
$plugins_text = t('Installed plugins/addons/apps:');
else
$plugins_text = t('No installed plugins/addons/apps');
$txt = get_config('system','admininfo');
$admininfo = bbcode($txt);
if(file_exists('doc/site_donate.html'))
$donate .= file_get_contents('doc/site_donate.html');
if(function_exists('sys_getloadavg'))
$loadavg = sys_getloadavg();
$o = replace_macros(get_markup_template('siteinfo.tpl'), array(
'$title' => t('$Projectname'),
'$description' => t('This is a hub of $Projectname - a global cooperative network of decentralized privacy enhanced websites.'),
'$version' => $version,
'$tag_txt' => t('Tag: '),
'$tag' => $tag,
'$polled' => t('Last background fetch: '),
'$lastpoll' => get_poller_runtime(),
'$load_average' => t('Current load average: '),
'$loadavg_all' => $loadavg[0] . ', ' . $loadavg[1] . ', ' . $loadavg[2],
'$commit' => $commit,
'$web_location' => t('Running at web location') . ' ' . z_root(),
'$visit' => t('Please visit <a href="http://hubzilla.org">hubzilla.org</a> to learn more about $Projectname.'),
'$bug_text' => t('Bug reports and issues: please visit'),
'$bug_link_url' => 'https://github.com/redmatrix/hubzilla/issues',
'$bug_link_text' => t('$projectname issues'),
'$contact' => t('Suggestions, praise, etc. - please email "redmatrix" at librelist - dot com'),
'$donate' => $donate,
'$adminlabel' => t('Site Administrators'),
'$admininfo' => $admininfo,
'$plugins_text' => $plugins_text,
'$plugins_list' => $plugins_list
));
call_hooks('about_hook', $o);
return $o;
} }
} }

View File

@ -35,9 +35,6 @@ class Wiki extends \Zotlabs\Web\Controller {
return; return;
} }
$tab = 'wiki';
require_once('include/wiki.php'); require_once('include/wiki.php');
require_once('include/acl_selectors.php'); require_once('include/acl_selectors.php');
require_once('include/conversation.php'); require_once('include/conversation.php');
@ -151,6 +148,7 @@ class Wiki extends \Zotlabs\Web\Controller {
'$create' => t('Create New'), '$create' => t('Create New'),
'$submit' => t('Submit'), '$submit' => t('Submit'),
'$wikiName' => array('wikiName', t('Wiki name')), '$wikiName' => array('wikiName', t('Wiki name')),
'$mimeType' => array('mimeType', t('Content type'), '', '', ['text/markdown' => 'Markdown', 'text/bbcode' => 'BB Code']),
'$name' => t('Name'), '$name' => t('Name'),
'$lockstate' => $x['lockstate'], '$lockstate' => $x['lockstate'],
'$acl' => $x['acl'], '$acl' => $x['acl'],
@ -315,17 +313,19 @@ class Wiki extends \Zotlabs\Web\Controller {
if (local_channel() !== intval($owner['channel_id'])) { if (local_channel() !== intval($owner['channel_id'])) {
goaway('/' . argv(0) . '/' . $nick . '/'); goaway('/' . argv(0) . '/' . $nick . '/');
} }
$wiki = array(); $wiki = array();
// Generate new wiki info from input name // Generate new wiki info from input name
$wiki['postVisible'] = ((intval($_POST['postVisible']) === 0) ? 0 : 1); $wiki['postVisible'] = ((intval($_POST['postVisible']) === 0) ? 0 : 1);
$wiki['rawName'] = $_POST['wikiName']; $wiki['rawName'] = $_POST['wikiName'];
$wiki['htmlName'] = escape_tags($_POST['wikiName']); $wiki['htmlName'] = escape_tags($_POST['wikiName']);
$wiki['urlName'] = urlencode($_POST['wikiName']); $wiki['urlName'] = urlencode($_POST['wikiName']);
$wiki['mimeType'] = $_POST['mimeType'];
if($wiki['urlName'] === '') { if($wiki['urlName'] === '') {
notice( t('Error creating wiki. Invalid name.') . EOL); notice( t('Error creating wiki. Invalid name.') . EOL);
goaway('/wiki'); goaway('/wiki');
} }
// Get ACL for permissions // Get ACL for permissions
$acl = new \Zotlabs\Access\AccessList($owner); $acl = new \Zotlabs\Access\AccessList($owner);
$acl->set_from_array($_POST); $acl->set_from_array($_POST);
@ -387,7 +387,7 @@ class Wiki extends \Zotlabs\Web\Controller {
'commit_msg' => t('New page created'), 'commit_msg' => t('New page created'),
'resource_id' => $resource_id, 'resource_id' => $resource_id,
'observer' => $ob, 'observer' => $ob,
'files' => array($page['page']['urlName'].'.md') 'files' => array($page['page']['fileName'])
)); ));
if($commit['success']) { if($commit['success']) {
json_return_and_die(array('url' => '/'.argv(0).'/'.argv(1).'/'.$page['wiki']['urlName'].'/'.$page['page']['urlName'], 'success' => true)); json_return_and_die(array('url' => '/'.argv(0).'/'.argv(1).'/'.$page['wiki']['urlName'].'/'.$page['page']['urlName'], 'success' => true));
@ -443,7 +443,7 @@ class Wiki extends \Zotlabs\Web\Controller {
'commit_msg' => $commitMsg, 'commit_msg' => $commitMsg,
'resource_id' => $resource_id, 'resource_id' => $resource_id,
'observer' => $ob, 'observer' => $ob,
'files' => array($pageUrlName.'.md') 'files' => array($saved['fileName'])
)); ));
if($commit['success']) { if($commit['success']) {
json_return_and_die(array('message' => 'Wiki git repo commit made', 'success' => true)); json_return_and_die(array('message' => 'Wiki git repo commit made', 'success' => true));
@ -582,7 +582,7 @@ class Wiki extends \Zotlabs\Web\Controller {
'commit_msg' => 'Renamed ' . urldecode($pageUrlName) . ' to ' . $renamed['page']['htmlName'], 'commit_msg' => 'Renamed ' . urldecode($pageUrlName) . ' to ' . $renamed['page']['htmlName'],
'resource_id' => $resource_id, 'resource_id' => $resource_id,
'observer' => $ob, 'observer' => $ob,
'files' => array($pageUrlName . '.md', $renamed['page']['fileName']), 'files' => array($pageUrlName . substr($renamed['page']['fileName'], -3), $renamed['page']['fileName']),
'all' => true 'all' => true
)); ));
if($commit['success']) { if($commit['success']) {

View File

@ -48,7 +48,7 @@ require_once('include/zid.php');
define ( 'PLATFORM_NAME', 'hubzilla' ); define ( 'PLATFORM_NAME', 'hubzilla' );
define ( 'STD_VERSION', '1.15.1' ); define ( 'STD_VERSION', '1.15.2' );
define ( 'ZOT_REVISION', '1.1' ); define ( 'ZOT_REVISION', '1.1' );
define ( 'DB_UPDATE_VERSION', 1185 ); define ( 'DB_UPDATE_VERSION', 1185 );

View File

@ -787,6 +787,12 @@ function bbcode($Text, $preserve_nl = false, $tryoembed = true, $cache = false)
if (strpos($Text,'[/color]') !== false) { if (strpos($Text,'[/color]') !== false) {
$Text = preg_replace("(\[color=(.*?)\](.*?)\[\/color\])ism", "<span style=\"color: $1;\">$2</span>", $Text); $Text = preg_replace("(\[color=(.*?)\](.*?)\[\/color\])ism", "<span style=\"color: $1;\">$2</span>", $Text);
} }
// Check for colored text
if (strpos($Text,'[/hl]') !== false) {
$Text = preg_replace("(\[hl\](.*?)\[\/hl\])ism", "<span style=\"background-color: yellow;\">$1</span>", $Text);
$Text = preg_replace("(\[hl=(.*?)\](.*?)\[\/hl\])ism", "<span style=\"background-color: $1;\">$2</span>", $Text);
}
// Check for sized text // Check for sized text
// [size=50] --> font-size: 50px (with the unit). // [size=50] --> font-size: 50px (with the unit).
if (strpos($Text,'[/size]') !== false) { if (strpos($Text,'[/size]') !== false) {

View File

@ -98,7 +98,7 @@ class DBA {
abstract class dba_driver { abstract class dba_driver {
// legacy behavior // legacy behavior
protected $db; public $db;
protected $pdo = array(); protected $pdo = array();
public $debug = 0; public $debug = 0;

View File

@ -19,6 +19,7 @@ function wiki_list($channel, $observer_hash) {
$w['htmlName'] = get_iconfig($w, 'wiki', 'htmlName'); $w['htmlName'] = get_iconfig($w, 'wiki', 'htmlName');
$w['urlName'] = get_iconfig($w, 'wiki', 'urlName'); $w['urlName'] = get_iconfig($w, 'wiki', 'urlName');
$w['path'] = get_iconfig($w, 'wiki', 'path'); $w['path'] = get_iconfig($w, 'wiki', 'path');
$w['path'] = get_iconfig($w, 'wiki', 'mimeType');
} }
} }
// TODO: query db for wikis the observer can access. Return with two lists, for read and write access // TODO: query db for wikis the observer can access. Return with two lists, for read and write access
@ -44,7 +45,7 @@ function wiki_page_list($resource_id) {
// TODO: Check that the files are all text files // TODO: Check that the files are all text files
$i = 1; $i = 1;
foreach($files as $file) { foreach($files as $file) {
// strip the .md file extension and unwrap URL encoding to leave HTML encoded name // strip the file extension and unwrap URL encoding to leave HTML encoded name
$title = substr($file, 0, -3); $title = substr($file, 0, -3);
if(urldecode($title) !== 'Home') { if(urldecode($title) !== 'Home') {
$pages[] = [ $pages[] = [
@ -139,6 +140,9 @@ function wiki_create_wiki($channel, $observer_hash, $wiki, $acl) {
if (!set_iconfig($arr, 'wiki', 'urlName', $wiki['urlName'], true)) { if (!set_iconfig($arr, 'wiki', 'urlName', $wiki['urlName'], true)) {
return array('item' => null, 'success' => false); return array('item' => null, 'success' => false);
} }
if (!set_iconfig($arr, 'wiki', 'mimeType', $wiki['mimeType'], true)) {
return array('item' => null, 'success' => false);
}
$post = item_store($arr); $post = item_store($arr);
$item_id = $post['item_id']; $item_id = $post['item_id'];
@ -168,8 +172,8 @@ function wiki_delete_wiki($resource_id) {
function wiki_get_wiki($resource_id) { function wiki_get_wiki($resource_id) {
$item = q("SELECT * FROM item WHERE resource_type = '%s' AND resource_id = '%s' AND item_deleted = 0 limit 1", $item = q("SELECT * FROM item WHERE resource_type = '%s' AND resource_id = '%s' AND item_deleted = 0 limit 1",
dbesc(WIKI_ITEM_RESOURCE_TYPE), dbesc(WIKI_ITEM_RESOURCE_TYPE),
dbesc($resource_id) dbesc($resource_id)
); );
if (!$item) { if (!$item) {
return array('wiki' => null, 'path' => null); return array('wiki' => null, 'path' => null);
@ -179,17 +183,21 @@ function wiki_get_wiki($resource_id) {
$rawName = get_iconfig($w, 'wiki', 'rawName'); $rawName = get_iconfig($w, 'wiki', 'rawName');
$htmlName = get_iconfig($w, 'wiki', 'htmlName'); $htmlName = get_iconfig($w, 'wiki', 'htmlName');
$urlName = get_iconfig($w, 'wiki', 'urlName'); $urlName = get_iconfig($w, 'wiki', 'urlName');
$mimeType = get_iconfig($w, 'wiki', 'mimeType');
$path = get_iconfig($w, 'wiki', 'path'); $path = get_iconfig($w, 'wiki', 'path');
if (!realpath(__DIR__ . '/../' . $path)) { if (!realpath(__DIR__ . '/../' . $path)) {
return array('wiki' => null, 'path' => null); return array('wiki' => null, 'path' => null);
} }
// Path to wiki exists // Path to wiki exists
$abs_path = realpath(__DIR__ . '/../' . $path); $abs_path = realpath(__DIR__ . '/../' . $path);
return array( 'wiki' => $w, return array(
'path' => $abs_path, 'wiki' => $w,
'rawName' => $rawName, 'path' => $abs_path,
'htmlName' => $htmlName, 'rawName' => $rawName,
'urlName' => $urlName 'htmlName' => $htmlName,
'urlName' => $urlName,
'mimeType' => $mimeType
); );
} }
} }
@ -236,7 +244,8 @@ function wiki_create_page($name, $resource_id) {
if (!$w['path']) { if (!$w['path']) {
return array('page' => null, 'wiki' => null, 'message' => 'Wiki not found.', 'success' => false); return array('page' => null, 'wiki' => null, 'message' => 'Wiki not found.', 'success' => false);
} }
$page = array('rawName' => $name, 'htmlName' => escape_tags($name), 'urlName' => urlencode(escape_tags($name)), 'fileName' => urlencode(escape_tags($name)).'.md');
$page = array('rawName' => $name, 'htmlName' => escape_tags($name), 'urlName' => urlencode(escape_tags($name)), 'fileName' => urlencode(escape_tags($name)) . wiki_get_mimetype($w));
$page_path = $w['path'] . '/' . $page['fileName']; $page_path = $w['path'] . '/' . $page['fileName'];
if (is_file($page_path)) { if (is_file($page_path)) {
return array('page' => null, 'wiki' => null, 'message' => 'Page already exists.', 'success' => false); return array('page' => null, 'wiki' => null, 'message' => 'Page already exists.', 'success' => false);
@ -258,11 +267,11 @@ function wiki_rename_page($arr) {
if (!$w['path']) { if (!$w['path']) {
return array('message' => 'Wiki not found.', 'success' => false); return array('message' => 'Wiki not found.', 'success' => false);
} }
$page_path_old = $w['path'].'/'.$pageUrlName.'.md'; $page_path_old = $w['path'] . '/' . $pageUrlName . wiki_get_mimetype($w);
if (!is_readable($page_path_old) === true) { if (!is_readable($page_path_old) === true) {
return array('message' => 'Cannot read wiki page: ' . $page_path_old, 'success' => false); return array('message' => 'Cannot read wiki page: ' . $page_path_old, 'success' => false);
} }
$page = array('rawName' => $pageNewName, 'htmlName' => escape_tags($pageNewName), 'urlName' => urlencode(escape_tags($pageNewName)), 'fileName' => urlencode(escape_tags($pageNewName)).'.md'); $page = array('rawName' => $pageNewName, 'htmlName' => escape_tags($pageNewName), 'urlName' => urlencode(escape_tags($pageNewName)), 'fileName' => urlencode(escape_tags($pageNewName)) . wiki_get_mimetype($w));
$page_path_new = $w['path'] . '/' . $page['fileName'] ; $page_path_new = $w['path'] . '/' . $page['fileName'] ;
if (is_file($page_path_new)) { if (is_file($page_path_new)) {
return array('message' => 'Page already exists.', 'success' => false); return array('message' => 'Page already exists.', 'success' => false);
@ -283,7 +292,7 @@ function wiki_get_page_content($arr) {
if (!$w['path']) { if (!$w['path']) {
return array('content' => null, 'message' => 'Error reading wiki', 'success' => false); return array('content' => null, 'message' => 'Error reading wiki', 'success' => false);
} }
$page_path = $w['path'].'/'.$pageUrlName.'.md'; $page_path = $w['path'] . '/' . $pageUrlName . wiki_get_mimetype($w);
if (is_readable($page_path) === true) { if (is_readable($page_path) === true) {
if(filesize($page_path) === 0) { if(filesize($page_path) === 0) {
$content = ''; $content = '';
@ -305,7 +314,7 @@ function wiki_page_history($arr) {
if (!$w['path']) { if (!$w['path']) {
return array('history' => null, 'message' => 'Error reading wiki', 'success' => false); return array('history' => null, 'message' => 'Error reading wiki', 'success' => false);
} }
$page_path = $w['path'].'/'.$pageUrlName.'.md'; $page_path = $w['path'] . '/' . $pageUrlName . wiki_get_mimetype($w);
if (!is_readable($page_path) === true) { if (!is_readable($page_path) === true) {
return array('history' => null, 'message' => 'Cannot read wiki page: ' . $page_path, 'success' => false); return array('history' => null, 'message' => 'Cannot read wiki page: ' . $page_path, 'success' => false);
} }
@ -330,12 +339,14 @@ function wiki_save_page($arr) {
if (!$w['path']) { if (!$w['path']) {
return array('message' => 'Error reading wiki', 'success' => false); return array('message' => 'Error reading wiki', 'success' => false);
} }
$page_path = $w['path'].'/'.$pageUrlName.'.md';
$fileName = $pageUrlName . wiki_get_mimetype($w);
$page_path = $w['path'] . '/' . $fileName;
if (is_writable($page_path) === true) { if (is_writable($page_path) === true) {
if(!file_put_contents($page_path, $content)) { if(!file_put_contents($page_path, $content)) {
return array('message' => 'Error writing to page file', 'success' => false); return array('message' => 'Error writing to page file', 'success' => false);
} }
return array('message' => '', 'success' => true); return array('message' => '', 'filename' => $filename, 'success' => true);
} else { } else {
return array('message' => 'Page file not writable', 'success' => false); return array('message' => 'Page file not writable', 'success' => false);
} }
@ -348,7 +359,7 @@ function wiki_delete_page($arr) {
if (!$w['path']) { if (!$w['path']) {
return array('message' => 'Error reading wiki', 'success' => false); return array('message' => 'Error reading wiki', 'success' => false);
} }
$page_path = $w['path'].'/'.$pageUrlName.'.md'; $page_path = $w['path'] . '/' . $pageUrlName . wiki_get_mimetype($w);
if (is_writable($page_path) === true) { if (is_writable($page_path) === true) {
if(!unlink($page_path)) { if(!unlink($page_path)) {
return array('message' => 'Error deleting page file', 'success' => false); return array('message' => 'Error deleting page file', 'success' => false);
@ -370,7 +381,7 @@ function wiki_revert_page($arr) {
if (!$w['path']) { if (!$w['path']) {
return array('content' => $content, 'message' => 'Error reading wiki', 'success' => false); return array('content' => $content, 'message' => 'Error reading wiki', 'success' => false);
} }
$page_path = $w['path'].'/'.$pageUrlName.'.md'; $page_path = $w['path'] . '/' . $pageUrlName . wiki_get_mimetype($w);
if (is_writable($page_path) === true) { if (is_writable($page_path) === true) {
$reponame = ((array_key_exists('title', $w['wiki'])) ? urlencode($w['wiki']['title']) : 'repo'); $reponame = ((array_key_exists('title', $w['wiki'])) ? urlencode($w['wiki']['title']) : 'repo');
@ -382,7 +393,7 @@ function wiki_revert_page($arr) {
try { try {
$git->setIdentity($observer['xchan_name'], $observer['xchan_addr']); $git->setIdentity($observer['xchan_name'], $observer['xchan_addr']);
foreach ($git->git->tree($commitHash) as $object) { foreach ($git->git->tree($commitHash) as $object) {
if ($object['type'] == 'blob' && $object['file'] === $pageUrlName.'.md' ) { if ($object['type'] == 'blob' && $object['file'] === $pageUrlName . wiki_get_mimetype($w)) {
$content = $git->git->cat->blob($object['hash']); $content = $git->git->cat->blob($object['hash']);
} }
} }
@ -407,7 +418,7 @@ function wiki_compare_page($arr) {
if (!$w['path']) { if (!$w['path']) {
return array('message' => 'Error reading wiki', 'success' => false); return array('message' => 'Error reading wiki', 'success' => false);
} }
$page_path = $w['path'].'/'.$pageUrlName.'.md'; $page_path = $w['path'] . '/' . $pageUrlName . wiki_get_mimetype($w);
if (is_readable($page_path) === true) { if (is_readable($page_path) === true) {
$reponame = ((array_key_exists('title', $w['wiki'])) ? urlencode($w['wiki']['title']) : 'repo'); $reponame = ((array_key_exists('title', $w['wiki'])) ? urlencode($w['wiki']['title']) : 'repo');
if($reponame === '') { if($reponame === '') {
@ -417,12 +428,12 @@ function wiki_compare_page($arr) {
$compareContent = $currentContent = ''; $compareContent = $currentContent = '';
try { try {
foreach ($git->git->tree($currentCommit) as $object) { foreach ($git->git->tree($currentCommit) as $object) {
if ($object['type'] == 'blob' && $object['file'] === $pageUrlName.'.md' ) { if ($object['type'] == 'blob' && $object['file'] === $pageUrlName . wiki_get_mimetype($w)) {
$currentContent = $git->git->cat->blob($object['hash']); $currentContent = $git->git->cat->blob($object['hash']);
} }
} }
foreach ($git->git->tree($compareCommit) as $object) { foreach ($git->git->tree($compareCommit) as $object) {
if ($object['type'] == 'blob' && $object['file'] === $pageUrlName.'.md' ) { if ($object['type'] == 'blob' && $object['file'] === $pageUrlName . wiki_get_mimetype($w)) {
$compareContent = $git->git->cat->blob($object['hash']); $compareContent = $git->git->cat->blob($object['hash']);
} }
} }
@ -485,15 +496,6 @@ function wiki_git_commit($arr) {
} }
} }
function wiki_generate_page_filename($name) {
$file = urlencode(escape_tags($name));
if( $file === '') {
return null;
} else {
return $file . '.md';
}
}
function wiki_convert_links($s, $wikiURL) { function wiki_convert_links($s, $wikiURL) {
if (strpos($s,'[[') !== false) { if (strpos($s,'[[') !== false) {
@ -563,6 +565,13 @@ function wiki_bbcode($s) {
return $s; return $s;
} }
function wiki_get_mimetype($arr) {
if($arr['mimeType'] == 'text/bbcode')
return '.bb';
else
return '.md';
}
// This function is derived from // This function is derived from
// http://stackoverflow.com/questions/32068537/generate-table-of-contents-from-markdown-in-php // http://stackoverflow.com/questions/32068537/generate-table-of-contents-from-markdown-in-php
function wiki_toc($content) { function wiki_toc($content) {

View File

@ -425,6 +425,10 @@ function zot_refresh($them, $channel = null, $force = false) {
$next_birthday = NULL_DATE; $next_birthday = NULL_DATE;
} }
// Keep original perms to check if we need to notify them
$previous_perms = get_all_perms($channel['channel_id'],$x['hash']);
$r = q("select * from abook where abook_xchan = '%s' and abook_channel = %d and abook_self = 0 limit 1", $r = q("select * from abook where abook_xchan = '%s' and abook_channel = %d and abook_self = 0 limit 1",
dbesc($x['hash']), dbesc($x['hash']),
intval($channel['channel_id']) intval($channel['channel_id'])
@ -488,10 +492,6 @@ function zot_refresh($them, $channel = null, $force = false) {
} }
} }
// Keep original perms to check if we need to notify them
$previous_perms = get_all_perms($channel['channel_id'],$x['hash']);
$closeness = get_pconfig($channel['channel_id'],'system','new_abook_closeness'); $closeness = get_pconfig($channel['channel_id'],'system','new_abook_closeness');
if($closeness === false) if($closeness === false)
$closeness = 80; $closeness = 80;

File diff suppressed because it is too large Load Diff

View File

@ -269,7 +269,7 @@ function string2bb(element) {
$.fn.bbco_autocomplete = function(type) { $.fn.bbco_autocomplete = function(type) {
if(type=='bbcode') { if(type=='bbcode') {
var open_close_elements = ['bold', 'italic', 'underline', 'overline', 'strike', 'superscript', 'subscript', 'quote', 'code', 'open', 'spoiler', 'map', 'nobb', 'list', 'checklist', 'ul', 'ol', 'dl', 'li', 'table', 'tr', 'th', 'td', 'center', 'color', 'font', 'size', 'zrl', 'zmg', 'rpost', 'qr', 'observer', 'embed']; var open_close_elements = ['bold', 'italic', 'underline', 'overline', 'strike', 'superscript', 'subscript', 'quote', 'code', 'open', 'spoiler', 'map', 'nobb', 'list', 'checklist', 'ul', 'ol', 'dl', 'li', 'table', 'tr', 'th', 'td', 'center', 'color', 'font', 'size', 'zrl', 'zmg', 'rpost', 'qr', 'observer', 'embed', 'hl'];
var open_elements = ['observer.baseurl', 'observer.address', 'observer.photo', 'observer.name', 'observer.webname', 'observer.url', '*', 'hr', ]; var open_elements = ['observer.baseurl', 'observer.address', 'observer.photo', 'observer.name', 'observer.webname', 'observer.url', '*', 'hr', ];
var elements = open_close_elements.concat(open_elements); var elements = open_close_elements.concat(open_elements);

View File

@ -21,10 +21,10 @@
{{if $abook_prev || $abook_next}} {{if $abook_prev || $abook_next}}
<div class="btn-group"> <div class="btn-group">
{{if $abook_prev}} {{if $abook_prev}}
<a href="connedit/{{$abook_prev}}" class="btn btn-default btn-xs" ><i class="fa fa-backward"></i></a> <a href="connedit/{{$abook_prev}}{{if $section}}?f=&section={{$section}}{{/if}}" class="btn btn-default btn-xs" ><i class="fa fa-backward"></i></a>
{{/if}} {{/if}}
{{if $abook_next}} {{if $abook_next}}
<a href="connedit/{{$abook_next}}" class="btn btn-default btn-xs" ><i class="fa fa-forward"></i></a> <a href="connedit/{{$abook_next}}{{if $section}}?f=&section={{$section}}{{/if}}" class="btn btn-default btn-xs" ><i class="fa fa-forward"></i></a>
{{/if}} {{/if}}
</div> </div>
{{/if}} {{/if}}
@ -63,6 +63,7 @@
<form id="abook-edit-form" action="connedit/{{$contact_id}}" method="post" > <form id="abook-edit-form" action="connedit/{{$contact_id}}" method="post" >
<input type="hidden" name="contact_id" value="{{$contact_id}}"> <input type="hidden" name="contact_id" value="{{$contact_id}}">
<input type="hidden" name="section" value="{{$section}}">
<div class="panel-group" id="contact-edit-tools" role="tablist" aria-multiselectable="true"> <div class="panel-group" id="contact-edit-tools" role="tablist" aria-multiselectable="true">
{{if $notself}} {{if $notself}}
@ -96,7 +97,7 @@
</a> </a>
</h3> </h3>
</div> </div>
<div id="affinity-tool-collapse" class="panel-collapse collapse{{if !$is_pending}} in{{/if}}" role="tabpanel" aria-labelledby="affinity-tool"> <div id="affinity-tool-collapse" class="panel-collapse collapse{{if !$is_pending || $section == 'affinity'}} in{{/if}}" role="tabpanel" aria-labelledby="affinity-tool">
<div class="section-content-tools-wrapper"> <div class="section-content-tools-wrapper">
{{if $slide}} {{if $slide}}
<div class="form-group"><strong>{{$lbl_slider}}</strong></div> <div class="form-group"><strong>{{$lbl_slider}}</strong></div>
@ -127,7 +128,7 @@
</a> </a>
</h3> </h3>
</div> </div>
<div id="fitert-tool-collapse" class="panel-collapse collapse{{if !$is_pending && !($slide || $multiprofs)}} in{{/if}}" role="tabpanel" aria-labelledby="fitert-tool"> <div id="fitert-tool-collapse" class="panel-collapse collapse{{if ( !$is_pending && !($slide || $multiprofs)) || $section == 'filter' }} in{{/if}}" role="tabpanel" aria-labelledby="fitert-tool">
<div class="section-content-tools-wrapper"> <div class="section-content-tools-wrapper">
{{include file="field_textarea.tpl" field=$incl}} {{include file="field_textarea.tpl" field=$incl}}
{{include file="field_textarea.tpl" field=$excl}} {{include file="field_textarea.tpl" field=$excl}}
@ -181,7 +182,7 @@
</h3> </h3>
</div> </div>
{{/if}} {{/if}}
<div id="perms-tool-collapse" class="panel-collapse collapse{{if $self}} in{{/if}}" role="tabpanel" aria-labelledby="perms-tool"> <div id="perms-tool-collapse" class="panel-collapse collapse{{if $self || $section === 'perms'}} in{{/if}}" role="tabpanel" aria-labelledby="perms-tool">
<div class="section-content-tools-wrapper"> <div class="section-content-tools-wrapper">
<div class="section-content-warning-wrapper"> <div class="section-content-warning-wrapper">
{{if $notself}}{{$permnote}}{{/if}} {{if $notself}}{{$permnote}}{{/if}}

View File

@ -49,6 +49,7 @@
{{/if}} {{/if}}
{{include file="field_textarea.tpl" field=$banner}} {{include file="field_textarea.tpl" field=$banner}}
{{include file="field_textarea.tpl" field=$siteinfo}}
{{include file="field_textarea.tpl" field=$admininfo}} {{include file="field_textarea.tpl" field=$admininfo}}
{{include file="field_select.tpl" field=$language}} {{include file="field_select.tpl" field=$language}}
{{include file="field_select.tpl" field=$theme}} {{include file="field_select.tpl" field=$theme}}

View File

@ -1,26 +1,41 @@
<div class="generic-content-wrapper-styled"> <div class="generic-content-wrapper-styled">
<h3>{{$title}}</h3> <h2>{{$title}}</h2>
<p></p>
<p>{{$description}}</p> <h3>{{$sitenametxt}}</h3>
{{if $version}}
<p>{{$version}}{{if $commit}}+{{$commit}}{{/if}}</p> <div>{{$sitename}}</div>
<h3>{{$headline}}</h3>
<div>{{if $site_about}}{{$site_about}}{{else}}--{{/if}}</div>
<h3>{{$admin_headline}}</h3>
<div>{{if $admin_about}}{{$admin_about}}{{else}}--{{/if}}</div>
<br><br>
<div><a href="help/TermsOfService">{{$terms}}</a></div>
<hr>
<h2>{{$prj_header}}</h2>
<div>{{$prj_name}}</div>
{{if $prj_version}}
<div>{{$prj_version}}</div>
{{/if}} {{/if}}
{{if $tag}}
<p>{{$tag_txt}} {{$tag}}</p>
{{/if}} <h3>{{$prj_linktxt}}</h3>
{{if $polled}}
<p>{{$polled}} {{$lastpoll}}</p> <div>{{$prj_link}}</div>
{{/if}}
<p>{{$load_average}} {{$loadavg_all}}</p> <h3>{{$prj_srctxt}}</h3>
<p>{{$web_location}}</p>
<p>{{$visit}}</p> <div>{{$prj_src}}</div>
<p>{{$bug_text}} <a href="{{$bug_link_url}}">{{$bug_link_text}}</a></p>
<p>{{$adminlabel}}</p> <br><br>
<p>{{$admininfo}}</p> <div>{{$prj_transport}} ({{$transport_link}})</div>
<p>{{$contact}}</p>
<p>{{$plugins_text}}</p>
{{if $plugins_list}}
<div style="margin-left: 25px; margin-right: 25px;">{{$plugins_list}}</div>
{{/if}}
<p>{{$donate}}</p>
</div> </div>

View File

@ -9,6 +9,8 @@
<div id="new-wiki-form-wrapper" class="section-content-tools-wrapper"> <div id="new-wiki-form-wrapper" class="section-content-tools-wrapper">
<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 *}}
<input type="hidden" name="mimeType" value="text/markdown">
{{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">