13 define(
"TITLE_ADMIN_TAG", _(
"Create Tag"));
19 $this->Name =
"admin_tag";
20 $this->Title = TITLE_ADMIN_TAG;
21 $this->MenuList =
"Admin::Tag::Create Tag";
22 $this->Version =
"1.3";
24 parent::__construct();
38 if (empty($tag_name)) {
39 $text = _(
"TagName must be specified. Tag Not created.");
42 if (! preg_match(
'/^[A-Za-z0-9_~\-!@#\$%\^\*\.\(\)]+$/i', $tag_name)) {
44 "A Tag is only allowed to contain characters from <b>" .
45 htmlentities(
"A-Za-z0-9_~-!@#$%^*.()") .
"</b>. Tag Not created.");
50 $sql =
"SELECT * FROM tag WHERE tag = '".pg_escape_string($tag_name).
"'";
53 if (pg_num_rows($result) < 1) {
54 pg_free_result($result);
56 $sql =
"INSERT INTO tag (tag,tag_desc) VALUES ('" .
57 pg_escape_string($tag_name) .
"', '" . pg_escape_string($tag_desc) .
62 pg_free_result($result);
65 $sql =
"SELECT * FROM tag WHERE tag = '".pg_escape_string($tag_name).
"' LIMIT 1;";
68 if (pg_num_rows($result) < 1) {
69 pg_free_result($result);
70 $text = _(
"Failed to create tag.");
73 pg_free_result($result);
84 $VE = _(
"<h3>Current Tags:</h3>\n");
85 $sql =
"SELECT tag_pk, tag, tag_desc FROM tag ORDER BY tag_pk desc;";
88 if (pg_num_rows($result) > 0) {
89 $VE .=
"<table border=1>\n";
92 $text3 = _(
"Tag Description");
93 $VE .=
"<tr><th>$text1</th><th>$text2</th><th>$text3</th></tr>\n";
94 while ($row = pg_fetch_assoc($result)) {
95 $VE .=
"<tr><td align='center'>" . $row[
'tag_pk'] .
96 "</td><td align='center'>" . htmlspecialchars($row[
'tag']) .
97 "</td><td align='center'>" . htmlspecialchars($row[
'tag_desc']) .
100 $VE .=
"</table><p>\n";
102 pg_free_result($result);
111 $VC = _(
"<h3>Create Tag:</h3>\n");
112 $VC.=
"<form name='form' method='POST' action='" .
Traceback_uri() .
"?mod=admin_tag'>\n";
115 $VC .=
"$text: <input type='text' id='tag_name' name='tag_name' maxlength='32' utocomplete='off'/> ";
117 $text = _(
"Tag description:");
118 $VC .=
"<p>$text <input type='text' name='tag_desc'/></p>";
120 $VC .=
"<input type='hidden' name='action' value='add'/>\n";
121 $VC .=
"<input type='submit' value='$text'>\n";
132 if ($action ==
'add') {
135 $text = _(
"Create Tag Failed");
138 $text = _(
"Create Tag Successful!");
149 $NewPlugin->Initialize();
This is the Plugin class. All plugins should:
__construct()
base constructor. Most plugins will just use this
ShowCreateTagPage()
Display the create tag page.
CreateTag()
Create Tag without tagging anything.
ShowExistTags()
Show all tags.
Output()
This function is called when user output is requested. This function is responsible for content....
displayMessage($Message, $keep=null)
Display a message.
DBCheckResult($result, $sql, $filenm, $lineno)
Check the postgres result for unexpected errors. If found, treat them as fatal.
Traceback_uri()
Get the URI without query to this location.
GetParm($parameterName, $parameterType)
This function will retrieve the variables and check data types.
#define PLUGIN_DB_ADMIN
Plugin requires admin level permission on DB.
foreach($Options as $Option=> $OptVal) if(0==$reference_flag &&0==$nomos_flag) $PG_CONN