Skip to content

Commit 472310a

Browse files
committed
Moved to SMFs built in template layer and sub template system. First 2013 commit :)
1 parent 321f0b0 commit 472310a

File tree

2 files changed

+33
-23
lines changed

2 files changed

+33
-23
lines changed

SMF2/Sources/Wiki/SimpleWiki.php

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* @file SimpleWiki-Subs.php
44
* @author James Robson
55
*
6-
* Copyright (c) 2012, James Robson
6+
* Copyright (c) 2013, James Robson
77
* All rights reserved.
88
*
99
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
@@ -35,8 +35,13 @@ function wiki($call = false)
3535
// They better be allowed to view the Wiki...
3636
wikiIsAllowedTo('simplewiki_view');
3737
// Setup the link tree
38-
$context['linktree'][] = array('name'=>$txt['wiki'], 'url' => $scripturl . '?action=wiki',);
39-
38+
$context['linktree'][] = array('name'=>$txt['wiki'], 'url' => $scripturl . '?action=wiki');
39+
40+
// Make sure we have the template loaded up
41+
loadTemplate('SimpleWiki');
42+
// Now setup our template layers
43+
$context['template_layers'][] = 'wiki';
44+
4045
// Come on people... request a page!
4146
if(!isset($_REQUEST['p']) || empty($_REQUEST['p']))
4247
{
@@ -76,7 +81,8 @@ function wiki($call = false)
7681
{
7782
// Load the namespace
7883
call_user_func('wiki_special_namespace_' . $page_parts[0]);
79-
$context['wiki_theme'] = 'special_namespace_' . $page_parts[0];
84+
// Load the right sub template.
85+
$context['sub_template'] = 'wiki_special_namespace_' . $page_parts[0];
8086
}
8187
else
8288
{
@@ -88,7 +94,8 @@ function wiki($call = false)
8894
}
8995
// And now load the namespace
9096
call_user_func('wiki_namespace_' . $page_parts[0], $page_parts[1], $page);
91-
$context['wiki_theme'] = 'namespace_' . $page_parts[0];
97+
// Make sure we're loading the correct sub template.
98+
$context['sub_template'] = 'wiki_namespace_' . $page_parts[0];
9299
$context['wiki']['page_data'] = $page;
93100
}
94101
}
@@ -97,7 +104,6 @@ function wiki($call = false)
97104
// Well this one patently doesn't exist...
98105
fatal_error('Unknown SimpleWiki namesapce requested', false);
99106
}
100-
loadTemplate('SimpleWiki');
101107
}
102108

103109
/**

SMF2/Themes/Default/Wiki/SimpleWiki.template.php

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?php
22
/**
3-
* @file SimpleWiki.template.php
3+
* @file SimpleWiki-Subs.php
44
* @author James Robson
55
*
6-
* Copyright (c) 2012, James Robson
6+
* Copyright (c) 2013, James Robson
77
* All rights reserved.
88
*
99
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
@@ -23,40 +23,45 @@
2323
* @todo Allow drag and drop extending of SimpleWiki
2424
*/
2525

26-
function template_main()
26+
/*function template_main()
2727
{
28-
global $context, $user_info, $txt;
28+
//call_user_func('template_wiki_' . $context['wiki_theme']);
29+
}*/
30+
31+
function template_wiki_above()
32+
{
33+
global $user_info, $txt;
2934
echo '<div class="title_bar">
30-
<h3 class="titlebg">
35+
<h3 class="titlebg">
3136
<div id="quick_search" class="align_right"><form action="index.php?action=wiki;sa=search" method="post">
32-
<input class="input_text" type="text" name="q" value="'.$txt['search'].'" /></form></div>'.$txt['wiki'].'</h3>
37+
<input class="input_text" type="text" name="q" value="', $txt['search'], '" /></form></div>'.$txt['wiki'], '</h3>
3338
</div><span class="upperframe"><span></span></span>
34-
<div class="roundframe">'.sprintf($txt['wiki_welcome'], ($user_info['name']?$user_info['name']:$txt['guest'])).'
39+
<div class="roundframe">', sprintf($txt['wiki_welcome'], ($user_info['name'] ? $user_info['name'] : $txt['guest'])), '
3540
</div><span class="lowerframe"><span></span></span>';
3641
echo '<br /><div id="left_admsection">';
3742
// @todo Wiki Menu
3843
echo '</div>';
3944
echo '<div class="windowbg2" id="main_admsection"><span class="topslice"><span></span></span><div class="content">';
40-
call_user_func('template_wiki_' . $context['wiki_theme']);
41-
echo '</div><span class="botslice clear"><span></span></span></div><br class="clear" />';
45+
}
46+
47+
function template_wiki_below()
48+
{
49+
echo '</div><span class="botslice clear"><span></span></span></div><br class="clear" />';
4250
template_wiki_copyright();
4351
}
4452

4553
function template_wiki_namespace_view()
4654
{
47-
global $context, $txt;
55+
global $context, $txt;
4856
$tools = array(
4957
'edit' => array('name'=>'wiki_edit', 'show'=>wikiAllowedTo('edit'), 'url'=>wiki_link('edit:page_string'), 'image' => 'wiki_edit.png'),
5058
'history' => array('name'=>'wiki_history', 'show'=>wikiAllowedTo('view_history'), 'url'=>wiki_link('history:page_string'), 'image' => 'wiki_history.png'),
5159
'protect' => array('name'=>'wiki_protect_page', 'show'=>wikiAllowedTo('protect'), 'url'=>wiki_link('protect:page_string'), 'image' => 'wiki_lock.png'),
5260
'create' => array('name'=>'wiki_create_new_page', 'show'=>wikiAllowedTo('create'), 'url'=>wiki_link('create:WikiSpecial'), 'image' => 'wiki_create.png'),
5361
);
5462

55-
/*$toolbar = */template_wiki_make_toolbar($tools);
56-
#echo $toolbar;
57-
//if(function_exists('template_wiki_namespace_'.$context['name_space']))
58-
// call_user_func('template_wiki_namespace_'.$context['name_space']);
59-
echo $context['wiki']['page_data']['body'];
63+
template_wiki_make_toolbar($tools);
64+
echo parse_bbc($context['wiki']['page_data']['body']);
6065
}
6166

6267
// @todo clean
@@ -72,7 +77,6 @@ function template_wiki_edit_box($action, $titlebox = false)
7277
{
7378
global $txt, $context;
7479
echo '<form action="', $action, '" method="post">';
75-
// @todo Use proper page name... (i.e. realname)
7680
if($titlebox)
7781
echo '<h2>', $txt['title'], ':</h2><input type="text" value=\'', htmlspecialchars($context['wiki']['page_data']['realname']), '\' name="p" />';
7882
else
@@ -96,5 +100,5 @@ function template_wiki_make_toolbar($tools)
96100

97101
function template_wiki_copyright()
98102
{
99-
echo '<div class="centertext smalltext"><a href="http://simplewiki.co.uk">SimpleWiki &copy; 2010-2012, James Robson</a></div>';
103+
echo '<div class="centertext smalltext"><a href="http://simplewiki.co.uk">SimpleWiki &copy; 2010-2013, James Robson</a></div>';
100104
}

0 commit comments

Comments
 (0)