source: extensions/title/initadmin.php @ 9407

Last change on this file since 9407 was 9407, checked in by ddtddt, 13 years ago

[extensions] - title - new plugin

File size: 3.7 KB
Line 
1<?php
2if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
3
4
5//Add link menu
6add_event_handler('get_admin_plugin_menu_links', 'title_admin_menu');
7function title_admin_menu($menu)
8{
9  array_push($menu, array(
10        'NAME' => 'Title',
11    'URL' => get_admin_plugin_menu_link(TITLE_PATH . 'admin/admin.php')));
12  return $menu;
13}
14
15
16//add prefiltre photo
17add_event_handler('loc_begin_admin', 'titlePadminf',60);
18add_event_handler('loc_begin_admin', 'titlePadminA',60);
19
20function titlePadminf()
21        {
22        global $template;
23        $template->set_prefilter('picture_modify', 'titlePadminfT');
24        }
25
26function titlePadminfT($content, &$smarty)
27        {
28  $search = '#<form id="associations"#';
29 
30  $replacement = '
31        <div>
32                <form method="post" >
33                        <fieldset>
34                          <br>
35                                <legend>{\'Title - Plugin title\'|@translate}</legend>
36                                        {\'title_photo\'|@translate}&nbsp;:&nbsp;<input type="text" name="inser" value="{$titleCONTENT}" size="110" maxlenght="110">
37                                <br>   
38                                <br>
39                                        <div style="text-align:center;">
40                                        <input class="submit" name="subtitlephoto" type="submit" value="{\'title_insbase\'|@translate}" {$TAG_INPUT_ENABLED} />
41                                        </div>
42                        </fieldset>
43                </form>
44        </div> 
45  <form id="associations"';
46
47  return preg_replace($search, $replacement, $content);
48        }
49 
50function titlePadminA()
51        { 
52                load_language('plugin.lang', TITLE_PATH);
53if (isset($_GET['image_id']))
54 {
55        global $template, $prefixeTable;
56$query = '
57select id,title
58  FROM ' . TITLE_PHOTO_TABLE . '
59  WHERE id = '.$_GET['image_id'].'
60  ;';
61$result = pwg_query($query);
62$row = mysql_fetch_array($result);
63$titleP=$row['title'];
64
65  $template->assign(
66    array(
67      'titleCONTENT' => $titleP,
68      ));
69 }
70 
71if (isset($_POST['subtitlephoto']))
72 {
73        $query = '
74DELETE
75  FROM ' . TITLE_PHOTO_TABLE . '
76  WHERE id = '.$_GET['image_id'].'
77  ;';
78$result = pwg_query($query);
79        $q = '
80INSERT INTO ' . $prefixeTable . 'title_photo(id,title)VALUES ('.$_GET['image_id'].',"'.$_POST['inser'].'");';
81    pwg_query($q);
82 
83  $template->assign(
84    array(
85      'titleCONTENT' => $_POST['inser'],
86      ));
87  }
88        }
89       
90//add prefiltre album
91add_event_handler('loc_end_cat_modify', 'titleAadminf', 60);
92add_event_handler('loc_end_cat_modify', 'titleAadminA', 60);
93
94function titleAadminf()
95 {
96        global $template;
97        $template->set_prefilter('categories', 'titleAadminfT');
98 }
99
100function titleAadminfT($content, &$smarty)
101 {
102  $search = '#<fieldset id="options">#';
103 
104  $replacement = '
105        <div>
106                <form method="post" >
107                        <fieldset>
108                          <br>
109                                <legend>{\'Title - Plugin title\'|@translate}</legend>
110                                        {\'title_album\'|@translate}&nbsp;:&nbsp;<input type="text" name="inser" value="{$titleCONTENT}" size="110" maxlenght="110">
111                                <br>   
112                                <br>
113                                        <div style="text-align:center;">
114                                        <input class="submit" name="subtitlealbum" type="submit" value="{\'title_insbase\'|@translate}" {$TAG_INPUT_ENABLED} />
115                                        </div>
116                        </fieldset>
117                </form>
118        </div> 
119  <fieldset id="options">
120  ';
121
122  return preg_replace($search, $replacement, $content);
123 }
124
125 function titleAadminA()
126        { 
127                load_language('plugin.lang', meta_PATH);
128if (isset($_GET['cat_id']))
129 {
130        global $template, $prefixeTable;
131$query = '
132select id,title
133  FROM ' . TITLE_ALBUM_TABLE . '
134  WHERE id = '.$_GET['cat_id'].'
135  ;';
136$result = pwg_query($query);
137$row = mysql_fetch_array($result);
138$titleA=$row['title'];
139
140  $template->assign(
141    array(
142      'titleCONTENT' => $titleA,
143      ));
144 }
145 
146if (isset($_POST['subtitlealbum']))
147 {
148        $query = '
149DELETE
150  FROM ' . TITLE_ALBUM_TABLE . '
151  WHERE id = '.$_GET['cat_id'].'
152  ;';
153$result = pwg_query($query);
154        $q = '
155INSERT INTO ' . $prefixeTable . 'title_album(id,title)VALUES ('.$_GET['cat_id'].',"'.$_POST['inser'].'");';
156    pwg_query($q);
157               
158  $template->assign(
159    array(
160      'titleCONTENT' => $_POST['inser'],
161      ));
162  }
163        }
164
165?>
Note: See TracBrowser for help on using the repository browser.