From 754ac2cff72b0d9d5d9b389740cc8946ed1e40b2 Mon Sep 17 00:00:00 2001 From: Klaus Weidenbach Date: Mon, 6 Apr 2015 23:51:30 +0200 Subject: Fix Design Tool navigation for sys channel. Fix creating menu for sys channel. --- include/text.php | 22 ++++++++++++++++------ mod/layouts.php | 6 ++---- mod/menu.php | 27 +++++++++++++++++++-------- mod/webpages.php | 8 +++----- view/tpl/menuedit.tpl | 3 +-- view/tpl/menulist.tpl | 15 +++++++-------- 6 files changed, 48 insertions(+), 33 deletions(-) diff --git a/include/text.php b/include/text.php index 664d5f83d..fefe67c4e 100644 --- a/include/text.php +++ b/include/text.php @@ -1258,15 +1258,19 @@ function format_categories(&$item,$writeable) { return $s; } -// Add any hashtags which weren't mentioned in the message body, e.g. community tags - +/** + * @brief Add any hashtags which weren't mentioned in the message body, e.g. community tags + * + * @param[in] array &$item + * @return string HTML link of hashtag + */ function format_hashtags(&$item) { - $s = ''; - $terms = get_terms_oftype($item['term'],TERM_HASHTAG); + + $terms = get_terms_oftype($item['term'], TERM_HASHTAG); if($terms) { foreach($terms as $t) { - $term = htmlspecialchars($t['term'],ENT_COMPAT,'UTF-8',false) ; + $term = htmlspecialchars($t['term'], ENT_COMPAT, 'UTF-8', false) ; if(! trim($term)) continue; if(strpos($item['body'], $t['url'])) @@ -1278,6 +1282,7 @@ function format_hashtags(&$item) { $s .= '#' . $term . ''; } } + return $s; } @@ -1301,6 +1306,7 @@ function format_mentions(&$item) { $s .= '@' . $term . ''; } } + return $s; } @@ -2065,7 +2071,11 @@ function json_decode_plus($s) { return $x; } - +/** + * @brief Creates navigation menu for webpage, layout, blocks, menu sites. + * + * @return string + */ function design_tools() { $channel = get_app()->get_channel(); diff --git a/mod/layouts.php b/mod/layouts.php index 74a713cf1..2616513f8 100644 --- a/mod/layouts.php +++ b/mod/layouts.php @@ -98,7 +98,6 @@ function layouts_content(&$a) { header('Content-disposition: attachment; filename="' . $r[0]['sid'] . '.pdl"'); echo json_encode($r); killme(); - } } @@ -156,7 +155,7 @@ function layouts_content(&$a) { 'title' => $rr['sid'], 'mid' => $rr['mid'] ); - } + } } //Build the base URL for edit links @@ -172,7 +171,6 @@ function layouts_content(&$a) { '$preview' => '1', )); - - return $o; + return $o; } diff --git a/mod/menu.php b/mod/menu.php index 7e9c580a8..4153f1ac0 100644 --- a/mod/menu.php +++ b/mod/menu.php @@ -3,11 +3,20 @@ require_once('include/menu.php'); require_once('include/identity.php'); +function menu_init(&$a) { + if (array_key_exists('sys', $_REQUEST) && $_REQUEST['sys'] && is_site_admin()) { + $sys = get_sys_channel(); + if ($sys && intval($sys['channel_id'])) { + $a->is_sys = true; + } + } +} + function menu_post(&$a) { $uid = local_channel(); - if(array_key_exists('sys',$_REQUEST) && $_REQUEST['sys'] && is_site_admin()) { + if(array_key_exists('sys', $_REQUEST) && $_REQUEST['sys'] && is_site_admin()) { $sys = get_sys_channel(); $uid = intval($sys['channel_id']); $a->is_sys = true; @@ -17,7 +26,7 @@ function menu_post(&$a) { return; $_REQUEST['menu_channel_id'] = $uid; - + if($_REQUEST['menu_bookmark']) $_REQUEST['menu_flags'] |= MENU_BOOKMARK; if($_REQUEST['menu_system']) @@ -44,7 +53,6 @@ function menu_post(&$a) { notice( t('Unable to create menu.'). EOL); } - } @@ -52,7 +60,7 @@ function menu_content(&$a) { $uid = local_channel(); - if($a->is_sys && is_site_admin()) { + if ($a->is_sys && is_site_admin()) { $sys = get_sys_channel(); $uid = intval($sys['channel_id']); } @@ -82,7 +90,8 @@ function menu_content(&$a) { '$hintnew' => t('Create a new menu'), '$hintdrop' => t('Delete this menu'), '$hintcontent' => t('Edit menu contents'), - '$hintedit' => t('Edit this menu') + '$hintedit' => t('Edit this menu'), + '$sys' => $a->is_sys )); return $o; @@ -91,18 +100,20 @@ function menu_content(&$a) { if(argc() > 1) { - if(argv(1) === 'new') { + if(argv(1) === 'new') { $o = replace_macros(get_markup_template('menuedit.tpl'), array( '$header' => t('New Menu'), '$menu_name' => array('menu_name', t('Menu name'), '', t('Must be unique, only seen by you'), '*'), '$menu_desc' => array('menu_desc', t('Menu title'), '', t('Menu title as seen by others'), ''), '$menu_bookmark' => array('menu_bookmark', t('Allow bookmarks'), 0 , t('Menu may be used to store saved bookmarks'), ''), - '$submit' => t('Create') + '$submit' => t('Create'), + '$sys' => $a->is_sys )); + return $o; } - elseif(intval(argv(1))) { + elseif(intval(argv(1))) { $m = menu_fetch_id(intval(argv(1)),$uid); if(! $m) { notice( t('Menu not found.') . EOL); diff --git a/mod/webpages.php b/mod/webpages.php index 6aff72a5e..a2a0ebf7b 100644 --- a/mod/webpages.php +++ b/mod/webpages.php @@ -71,7 +71,7 @@ function webpages_content(&$a) { if(feature_enabled($owner,'expert')) { $mimetype = (($_REQUEST['mimetype']) ? $_REQUEST['mimetype'] : get_pconfig($owner,'system','page_mimetype')); if(! $mimetype) - $mimetype = 'choose'; + $mimetype = 'choose'; } else { $mimetype = 'text/bbcode'; @@ -129,7 +129,7 @@ function webpages_content(&$a) { // Get a list of webpages. We can't display all them because endless scroll makes that unusable, // so just list titles and an edit link. - //TODO - this should be replaced with pagelist_widget + /** @TODO - this should be replaced with pagelist_widget */ $r = q("select * from item_id left join item on item_id.iid = item.id where item_id.uid = %d and service = 'WEBPAGE' order by item.created desc", @@ -157,7 +157,7 @@ function webpages_content(&$a) { $url = z_root() . '/editwebpage/' . $which; $o .= replace_macros(get_markup_template('webpagelist.tpl'), array( - '$listtitle' => t('Webpages'), + '$listtitle' => t('Webpages'), '$baseurl' => $url, '$edit' => t('Edit'), '$pages' => $pages, @@ -169,9 +169,7 @@ function webpages_content(&$a) { '$title_txt' => t('Title'), '$created_txt' => t('Created'), '$edited_txt' => t('Edited') - )); return $o; - } diff --git a/view/tpl/menuedit.tpl b/view/tpl/menuedit.tpl index 1ccfb3d68..9ea184269 100644 --- a/view/tpl/menuedit.tpl +++ b/view/tpl/menuedit.tpl @@ -5,7 +5,7 @@ {{$editcontents}} {{/if}} -