From 57c212c9c85efcf904c7fcd49235c43a305bc519 Mon Sep 17 00:00:00 2001 From: real_nowhereman Date: Fri, 3 Jul 2009 15:39:23 +0000 Subject: [PATCH] added new comment form, fixed a few issues with fpdb, cosmetich changes for the comment form, minor changes in comment handling --- comments.php | 13 ++-- fp-includes/core/core.entry.php | 62 +++++++++++++++++++ fp-includes/core/core.fpdb.class.php | 16 +++-- fp-interface/sharedtpls/comment-form.tpl | 54 ++++++++++++++++ fp-interface/themes/leggero/comments.tpl | 2 +- .../themes/leggero/leggero/res/admin.css | 8 ++- 6 files changed, 143 insertions(+), 12 deletions(-) create mode 100644 fp-interface/sharedtpls/comment-form.tpl diff --git a/comments.php b/comments.php index 0570ac3..cc50db3 100644 --- a/comments.php +++ b/comments.php @@ -83,9 +83,6 @@ );*/ - $name = trim(stripslashes(@$_POST['name'])); - $email = isset($_POST['email'])? trim($_POST['email']) : null; - $url = isset($_POST['url'])? trim(stripslashes($_POST['url'])) : null; $content= isset($_POST['content'])? trim(stripslashes($_POST['content'])) : null; $errors = array(); @@ -93,8 +90,16 @@ $loggedin = false; if (user_loggedin()) { + $user = user_get(); $loggedin = $arr['loggedin']=true; + $email = $user['email']; + $url = $user['www']; + $name = $user['userid']; } else { + + $name = trim(stripslashes(@$_POST['name'])); + $email = isset($_POST['email'])? trim($_POST['email']) : null; + $url = isset($_POST['url'])? trim(stripslashes($_POST['url'])) : null; /* * check name @@ -147,7 +152,7 @@ } $arr['version'] = system_ver(); - $arr['name'] = $_POST['name']; + $arr['name'] = $name; if (!$loggedin) diff --git a/fp-includes/core/core.entry.php b/fp-includes/core/core.entry.php index 53dd0fc..f61f1ee 100755 --- a/fp-includes/core/core.entry.php +++ b/fp-includes/core/core.entry.php @@ -583,6 +583,68 @@ } */ + function entry_categories_list() { + if (!$string = io_load_file(CONTENT_DIR . 'categories.txt')) + return false; + + $lines = explode("\n", trim($string)); + $idstack = array(0); + $indentstack=array(); + + + // $categories = array(0=>null); + $lastindent = 0; + $lastid = 0; + $parent = 0; + + $NEST = 0; + + foreach ($lines as $v) { + + $vt = trim($v); + + if (!$vt) continue; + + $text=''; + $indent = utils_countdashes($vt, $text); + + $val = explode(':', $text); + + $id = trim($val[1]); + $label = trim($val[0]); + + // echo "PARSE: $id:$label\n"; + if ($indent > $lastindent) { + // echo "INDENT ($indent, $id, $lastid)\n"; + $parent = $lastid; + array_push($indentstack, $lastindent); + array_push($idstack, $lastid); + $lastindent = $indent; + $NEST++; + } elseif ($indent < $lastindent) { + // echo "DEDENT ($indent)\n"; + do { + $dedent = array_pop($indentstack); + array_pop($idstack); + $NEST--; + } while ($dedent > $indent); + if ($dedent < $indent) return false; //trigger_error("failed parsing ($dedent<$indent)", E_USER_ERROR); + $parent = end($idstack); + $lastindent = $indent; + $lastid = $id; + } + + $lastid = $id; + // echo "NEST: $NEST\n"; + + + $categories[ $id ] = $parent; + + } + + return $categories; + + } function entry_categories_get($what=null) { diff --git a/fp-includes/core/core.fpdb.class.php b/fp-includes/core/core.fpdb.class.php index b809b24..3e1f418 100644 --- a/fp-includes/core/core.fpdb.class.php +++ b/fp-includes/core/core.fpdb.class.php @@ -52,7 +52,7 @@ } } - + if (isset($params['fullparse'])) { $this->fullparse = @@ -263,10 +263,11 @@ $filteredkeys = $obj->getList(); $index_count = $obj->getCount(); - $this->walker =& $entry_index->walker( - entry_idtokey($filteredkeys[0]), true, - entry_idtokey($filteredkeys[$index_count-1]), true - ); + if ($filteredkeys) + $this->walker =& $entry_index->walker( + entry_idtokey($filteredkeys[0]), true, + entry_idtokey($filteredkeys[$index_count-1]), true + ); } @@ -389,7 +390,10 @@ } else { // only title - $cont = array('subject' => $this->walker->current_value()); + $cont = array( + 'subject' => $this->walker->current_value(), + 'date' => entry_idtotime($id) + ); } diff --git a/fp-interface/sharedtpls/comment-form.tpl b/fp-interface/sharedtpls/comment-form.tpl new file mode 100644 index 0000000..f55ac98 --- /dev/null +++ b/fp-interface/sharedtpls/comment-form.tpl @@ -0,0 +1,54 @@ +{if !$entry_commslock} +

{$lang.comments.head}

+

{$lang.comments.descr}

+ + +
+ + + {include file='shared:errorlist.tpl'} + + + {if not $flatpress.loggedin} + + + + {*
*} +
+ +

+ + +

+ +

+ + +

+ +

+ + +

+ + {comment_form} + +
+ + {/if} + + +
+

+ {*here will go a plugin hook*} +
+ +
+ +
+ + +{/if} diff --git a/fp-interface/themes/leggero/comments.tpl b/fp-interface/themes/leggero/comments.tpl index 27c07e9..e9b33c9 100755 --- a/fp-interface/themes/leggero/comments.tpl +++ b/fp-interface/themes/leggero/comments.tpl @@ -46,7 +46,7 @@ {/entry_block} - {include file="shared:comments.tpl"} + {include file="shared:comment-form.tpl"} diff --git a/fp-interface/themes/leggero/leggero/res/admin.css b/fp-interface/themes/leggero/leggero/res/admin.css index 989f72a..f809c7c 100755 --- a/fp-interface/themes/leggero/leggero/res/admin.css +++ b/fp-interface/themes/leggero/leggero/res/admin.css @@ -161,7 +161,7 @@ ul#admin-tabmenu li a.admin-tab-current { /* ===== ADMIN ENTRY ===== */ input#subject { - width: 100%; + width: 99%; font-size: 1.3em; color: #333333; font-weight: bold @@ -510,6 +510,12 @@ li.widget-class { font-weight: bold; } +.widetextinput { + width: 99%; + font-size: 1.3em; + color: #333333; +} + .option-set input.textinput , .option-set select.textinput { width: 20em;