Fix orphaned categories, textile plugin, smarty commentform function
This commit is contained in:
parent
de2f7fe707
commit
0fa785d1a6
@ -3,6 +3,13 @@
|
||||
Version 1.1-beta4 ()
|
||||
------------------------------------------------------------------------
|
||||
|
||||
* Made category-recursion show orphaned categories because of
|
||||
permission restrictions (garvinhicking)
|
||||
|
||||
* Fix some markup functions in textile plugin (Matthias Leisi)
|
||||
|
||||
* Add Smarty function to show commentform (garvinhicking)
|
||||
|
||||
* Group management now allows to disallow certain plugins or even
|
||||
specific plugin hooks per usergroup (garvinhicking)
|
||||
|
||||
|
@ -293,8 +293,9 @@ function serendipity_fetchTemplateInfo($theme, $abspath = null) {
|
||||
function serendipity_walkRecursive($ary, $child_name = 'id', $parent_name = 'parent_id', $parentid = 0, $depth = 0) {
|
||||
global $serendipity;
|
||||
static $_resArray;
|
||||
static $_remain;
|
||||
|
||||
if ( sizeof($ary) == 0 ) {
|
||||
if (sizeof($ary) == 0) {
|
||||
return array();
|
||||
}
|
||||
|
||||
@ -302,14 +303,16 @@ function serendipity_walkRecursive($ary, $child_name = 'id', $parent_name = 'par
|
||||
$parentid = 0;
|
||||
}
|
||||
|
||||
if ( $depth == 0 ) {
|
||||
if ($depth == 0) {
|
||||
$_resArray = array();
|
||||
$_remain = $ary;
|
||||
}
|
||||
|
||||
foreach ($ary as $data) {
|
||||
foreach($ary AS $key => $data) {
|
||||
if ($parentid === VIEWMODE_LINEAR || !isset($data[$parent_name]) || $data[$parent_name] == $parentid) {
|
||||
$data['depth'] = $depth;
|
||||
$_resArray[] = $data;
|
||||
$_resArray[] = $data;
|
||||
unset($_remain[$key]);
|
||||
if ($data[$child_name] && $parentid !== VIEWMODE_LINEAR ) {
|
||||
serendipity_walkRecursive($ary, $child_name, $parent_name, $data[$child_name], ($depth+1));
|
||||
}
|
||||
@ -320,6 +323,14 @@ function serendipity_walkRecursive($ary, $child_name = 'id', $parent_name = 'par
|
||||
if ($depth !== 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (count($_remain) > 0) {
|
||||
// Remaining items need to be appended
|
||||
foreach($_remain AS $key => $data) {
|
||||
$data['depth'] = 0;
|
||||
$_resArray[] = $data;
|
||||
}
|
||||
}
|
||||
|
||||
return $_resArray;
|
||||
}
|
||||
|
@ -321,6 +321,70 @@ function serendipity_smarty_fetchPrintEntries($params, &$smarty) {
|
||||
return $out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Smarty Function: Shows a commentform
|
||||
*
|
||||
* @access public
|
||||
* @param array Smarty parameter input array:
|
||||
* id: An entryid to show the commentform for
|
||||
* url: an optional HTML target link for the form
|
||||
* comments: Optional array of containing comments
|
||||
* data: possible pre-submitted values to the input values
|
||||
* showToolbar: Toggle whether to show extended options of the comment form
|
||||
* moderate_comments: Toggle whether comments to this entry are allowed
|
||||
* @param object Smarty object
|
||||
* @return void
|
||||
*/
|
||||
function serendipity_smarty_showCommentForm($params, &$smarty) {
|
||||
global $serendipity;
|
||||
|
||||
if (!isset($params['id']) || !isset($params['entry'])) {
|
||||
$smarty->trigger_error(__FUNCTION__ .": missing 'id' or 'entry' parameter");
|
||||
return;
|
||||
}
|
||||
|
||||
if (empty($params['url'])) {
|
||||
$params['url'] = $serendipity['serendipityHTTPPath'] . $serendipity['indexFile'] . '?url=' . $params['entry']['commURL'];
|
||||
}
|
||||
|
||||
if (!isset($params['comments'])) {
|
||||
$params['comments'] = NULL;
|
||||
}
|
||||
|
||||
if (!isset($params['data'])) {
|
||||
$params['data'] = $serendipity['POST'];
|
||||
}
|
||||
|
||||
if (!isset($params['showToolbar'])) {
|
||||
$params['showToolbar'] = true;
|
||||
}
|
||||
|
||||
if (!isset($params['moderate_comments'])) {
|
||||
$params['moderate_comments'] = serendipity_db_bool($params['entry']['moderate_comments']);
|
||||
}
|
||||
|
||||
|
||||
$comment_add_data = array(
|
||||
'comments_messagestack' => (isset($serendipity['messagestack']['comments']) ? (array)$serendipity['messagestack']['comments'] : array()),
|
||||
'is_comment_added' => (isset($serendipity['GET']['csuccess']) && $serendipity['GET']['csuccess'] == 'true' ? true: false),
|
||||
'is_comment_moderate' => (isset($serendipity['GET']['csuccess']) && $serendipity['GET']['csuccess'] == 'moderate' ? true: false)
|
||||
);
|
||||
|
||||
$smarty->assign($comment_add_data);
|
||||
|
||||
serendipity_displayCommentForm(
|
||||
$params['id'],
|
||||
$params['url'],
|
||||
$params['comments'],
|
||||
$params['data'],
|
||||
$params['showToolbar'],
|
||||
$params['moderate_comments'],
|
||||
$params['entry']
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Smarty Function: Be able to include the output of a sidebar plugin within a smarty template
|
||||
*
|
||||
@ -675,7 +739,7 @@ function serendipity_smarty_init($vars = array()) {
|
||||
$serendipity['smarty']->register_function('serendipity_fetchPrintEntries', 'serendipity_smarty_fetchPrintEntries');
|
||||
$serendipity['smarty']->register_function('serendipity_getTotalCount', 'serendipity_smarty_getTotalCount');
|
||||
$serendipity['smarty']->register_function('pickKey', 'serendipity_smarty_pickKey');
|
||||
|
||||
$serendipity['smarty']->register_function('serendipity_showCommentForm', 'serendipity_smarty_showCommentForm');
|
||||
$serendipity['smarty']->register_prefilter('serendipity_replaceSmartyVars');
|
||||
}
|
||||
|
||||
@ -686,11 +750,11 @@ function serendipity_smarty_init($vars = array()) {
|
||||
$serendipity['smarty_raw_mode'] = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!isset($serendipity['smarty_file'])) {
|
||||
$serendipity['smarty_file'] = 'index.tpl';
|
||||
}
|
||||
|
||||
|
||||
$category = false;
|
||||
$category_info = array();
|
||||
if (isset($serendipity['GET']['category'])) {
|
||||
@ -701,11 +765,11 @@ function serendipity_smarty_init($vars = array()) {
|
||||
$category_info = serendipity_fetchCategoryInfo($category);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!isset($serendipity['smarty_vars']['head_link_stylesheet'])) {
|
||||
$serendipity['smarty_vars']['head_link_stylesheet'] = serendipity_rewriteURL('serendipity.css');
|
||||
}
|
||||
|
||||
|
||||
$serendipity['smarty']->assign(
|
||||
array(
|
||||
'head_charset' => LANG_CHARSET,
|
||||
@ -713,43 +777,43 @@ function serendipity_smarty_init($vars = array()) {
|
||||
'head_title' => $serendipity['head_title'],
|
||||
'head_subtitle' => $serendipity['head_subtitle'],
|
||||
'head_link_stylesheet' => $serendipity['smarty_vars']['head_link_stylesheet'],
|
||||
|
||||
|
||||
'is_xhtml' => true,
|
||||
'use_popups' => $serendipity['enablePopup'],
|
||||
'is_embedded' => (!$serendipity['embed'] || $serendipity['embed'] === 'false' || $serendipity['embed'] === false) ? false : true,
|
||||
'is_raw_mode' => $serendipity['smarty_raw_mode'],
|
||||
'is_logged_in' => serendipity_userLoggedIn(),
|
||||
|
||||
|
||||
'entry_id' => (isset($serendipity['GET']['id']) && is_numeric($serendipity['GET']['id'])) ? $serendipity['GET']['id'] : false,
|
||||
'is_single_entry' => (isset($serendipity['GET']['id']) && is_numeric($serendipity['GET']['id'])),
|
||||
|
||||
|
||||
'blogTitle' => htmlspecialchars($serendipity['blogTitle']),
|
||||
'blogSubTitle' => (!empty($serendipity['blogSubTitle']) ? htmlspecialchars($serendipity['blogSubTitle']) : ''),
|
||||
'blogDescription' => htmlspecialchars($serendipity['blogDescription']),
|
||||
|
||||
|
||||
'serendipityHTTPPath' => $serendipity['serendipityHTTPPath'],
|
||||
'serendipityBaseURL' => $serendipity['baseURL'],
|
||||
'serendipityRewritePrefix' => $serendipity['rewrite'] == 'none' ? $serendipity['indexFile'] . '?/' : '',
|
||||
'serendipityIndexFile' => $serendipity['indexFile'],
|
||||
'serendipityVersion' => $serendipity['version'],
|
||||
|
||||
|
||||
'lang' => $serendipity['lang'],
|
||||
'category' => $category,
|
||||
'category_info' => $category_info,
|
||||
'template' => $serendipity['template'],
|
||||
|
||||
|
||||
'dateRange' => (!empty($serendipity['range']) ? $serendipity['range'] : array())
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
if (count($vars) > 0) {
|
||||
$serendipity['smarty']->assign($vars);
|
||||
}
|
||||
|
||||
|
||||
// For advanced usage, we allow template authors to create a file 'config.inc.php' where they can
|
||||
// setup custom smarty variables, modifiers etc. to use in their templates.
|
||||
@include_once $serendipity['smarty']->config_dir . '/config.inc.php';
|
||||
|
||||
|
||||
if (is_array($template_config)) {
|
||||
$template_vars =& serendipity_loadThemeOptions($template_config);
|
||||
$serendipity['smarty']->assign_by_ref('template_option', $template_vars);
|
||||
|
@ -22,7 +22,7 @@ class serendipity_event_textile extends serendipity_event
|
||||
$propbag->add('description', PLUGIN_EVENT_TEXTILE_DESC);
|
||||
$propbag->add('stackable', false);
|
||||
$propbag->add('author', 'Serendipity Team');
|
||||
$propbag->add('version', '1.2');
|
||||
$propbag->add('version', '1.3');
|
||||
$propbag->add('requirements', array(
|
||||
'serendipity' => '0.8',
|
||||
'smarty' => '2.6.7',
|
||||
@ -228,4 +228,3 @@ class serendipity_event_textile extends serendipity_event
|
||||
}
|
||||
|
||||
/* vim: set sts=4 ts=4 expandtab : */
|
||||
?>
|
||||
|
@ -168,6 +168,9 @@ Applying Attributes:
|
||||
|
||||
*/
|
||||
|
||||
function myglobals() {
|
||||
global $textile_hlgn, $textile_vlgn, $textile_clas, $textile_lnge, $textile_styl,
|
||||
$textile_cspn, $textile_rspn, $textile_a, $textile_s, $textile_c, $textile_pnct;
|
||||
$textile_hlgn = "(?:\<(?!>)|(?<!<)\>|\<\>|\=|[()]+)";
|
||||
$textile_vlgn = "[\-^~]";
|
||||
$textile_clas = "(?:\([^)]+\))";
|
||||
@ -179,6 +182,9 @@ Applying Attributes:
|
||||
$textile_s = "(?:$textile_cspn?$textile_rspn?|$textile_rspn?$textile_cspn?)";
|
||||
$textile_c = "(?:$textile_clas?$textile_styl?$textile_lnge?|$textile_styl?$textile_lnge?$textile_clas?|$textile_lnge?$textile_styl?$textile_clas?)";
|
||||
$textile_pnct = '[\!"#\$%&\'()\*\+,\-\./:;<=>\?@\[\\\]\^_`{\|}\~]';
|
||||
}
|
||||
|
||||
myglobals();
|
||||
|
||||
function textile($text,$lite='') {
|
||||
|
||||
@ -299,7 +305,7 @@ Applying Attributes:
|
||||
|
||||
foreach(preg_split("/\|$/m",$matches[2],-1,PREG_SPLIT_NO_EMPTY) as $row){
|
||||
if (preg_match("/^($textile_a$textile_c\. )(.*)/m",$row,$rmtch)) {
|
||||
$ratts = pba($rmtch[1],'tr');
|
||||
$ratts = textile_pba($rmtch[1],'tr');
|
||||
$row = $rmtch[2];
|
||||
} else $ratts = '';
|
||||
|
||||
@ -307,7 +313,7 @@ Applying Attributes:
|
||||
$textile_ctyp = "d";
|
||||
if (preg_match("/^_/",$textile_cell)) $textile_ctyp = "h";
|
||||
if (preg_match("/^(_?$textile_s$textile_a$textile_c\. )(.*)/",$textile_cell,$textile_cmtch)) {
|
||||
$textile_catts = pba($textile_cmtch[1],'td');
|
||||
$textile_catts = textile_pba($textile_cmtch[1],'td');
|
||||
$textile_cell = $textile_cmtch[2];
|
||||
} else $textile_catts = '';
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user