24 define(
"TITLE_ADMIN_TAG", _(
"Create Tag"));
28 function __construct()
30 $this->Name =
"admin_tag";
31 $this->Title = TITLE_ADMIN_TAG;
32 $this->MenuList =
"Admin::Tag::Create Tag";
33 $this->Version =
"1.3";
35 parent::__construct();
49 if (empty($tag_name)) {
50 $text = _(
"TagName must be specified. Tag Not created.");
53 if (! preg_match(
'/^[A-Za-z0-9_~\-!@#\$%\^\*\.\(\)]+$/i', $tag_name)) {
55 "A Tag is only allowed to contain characters from <b>" .
56 htmlentities(
"A-Za-z0-9_~-!@#$%^*.()") .
"</b>. Tag Not created.");
61 $sql =
"SELECT * FROM tag WHERE tag = '".pg_escape_string($tag_name).
"'";
62 $result = pg_query($PG_CONN, $sql);
64 if (pg_num_rows($result) < 1) {
65 pg_free_result($result);
67 $sql =
"INSERT INTO tag (tag,tag_desc) VALUES ('" .
68 pg_escape_string($tag_name) .
"', '" . pg_escape_string($tag_desc) .
70 $result = pg_query($PG_CONN, $sql);
73 pg_free_result($result);
76 $sql =
"SELECT * FROM tag WHERE tag = '".pg_escape_string($tag_name).
"' LIMIT 1;";
77 $result = pg_query($PG_CONN, $sql);
79 if (pg_num_rows($result) < 1) {
80 pg_free_result($result);
81 $text = _(
"Failed to create tag.");
84 pg_free_result($result);
95 $VE = _(
"<h3>Current Tags:</h3>\n");
96 $sql =
"SELECT tag_pk, tag, tag_desc FROM tag ORDER BY tag_pk desc;";
97 $result = pg_query($PG_CONN, $sql);
99 if (pg_num_rows($result) > 0) {
100 $VE .=
"<table border=1>\n";
101 $text1 = _(
"Tag pk");
103 $text3 = _(
"Tag Description");
104 $VE .=
"<tr><th>$text1</th><th>$text2</th><th>$text3</th></tr>\n";
105 while ($row = pg_fetch_assoc($result)) {
106 $VE .=
"<tr><td align='center'>" . $row[
'tag_pk'] .
107 "</td><td align='center'>" . htmlspecialchars($row[
'tag']) .
108 "</td><td align='center'>" . htmlspecialchars($row[
'tag_desc']) .
111 $VE .=
"</table><p>\n";
113 pg_free_result($result);
123 $VC .= _(
"<h3>Create Tag:</h3>\n");
124 $VC.=
"<form name='form' method='POST' action='" .
Traceback_uri() .
"?mod=admin_tag'>\n";
127 $VC .=
"$text: <input type='text' id='tag_name' name='tag_name' maxlength='32' utocomplete='off'/> ";
129 $text = _(
"Tag description:");
130 $VC .=
"<p>$text <input type='text' name='tag_desc'/></p>";
132 $VC .=
"<input type='hidden' name='action' value='add'/>\n";
133 $VC .=
"<input type='submit' value='$text'>\n";
139 public function Output()
144 if ($action ==
'add') {
147 $text = _(
"Create Tag Failed");
150 $text = _(
"Create Tag Successful!");
161 $NewPlugin->Initialize();
Traceback_uri()
Get the URI without query to this location.
displayMessage($Message, $keep=null)
Display a message.
#define PLUGIN_DB_ADMIN
Plugin requires admin level permission on DB.
GetParm($parameterName, $parameterType)
This function will retrieve the variables and check data types.
ShowCreateTagPage()
Display the create tag page.
This is the Plugin class. All plugins should:
foreach($Options as $Option=> $OptVal) if(0==$reference_flag &&0==$nomos_flag) $PG_CONN
DBCheckResult($result, $sql, $filenm, $lineno)
Check the postgres result for unexpected errors. If found, treat them as fatal.
CreateTag()
Create Tag without tagging anything.
ShowExistTags()
Show all tags.