Changeset 11656
- Timestamp:
- Jul 7, 2011, 1:27:50 PM (13 years ago)
- Location:
- extensions/Copyrights
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/Copyrights/admin.php
r11635 r11656 32 32 check_status(ACCESS_ADMINISTRATOR); 33 33 34 // Default is to create , if changed to 1, showedit page34 // Default is to create a copyright, if changed to 1, show the edit page 35 35 $edit = 0; 36 36 … … 44 44 // Do managing of copyrights 45 45 if (isset($_GET['tab'])) { 46 // Create a new copyright 46 47 if ($_GET['tab'] == 'create') { 48 // Fetch the values from the form 47 49 $name = pwg_db_real_escape_string($_REQUEST['name']); 48 50 $url = pwg_db_real_escape_string($_REQUEST['url']); 49 51 $descr = pwg_db_real_escape_string($_REQUEST['descr']); 50 52 $visible = (isset($_REQUEST['visible']) ? 1 : 0); 53 54 // Check whether a copyright with such a name exists 55 // Therefore count the number of copyrights with that name 51 56 $query = sprintf( 52 57 'SELECT COUNT(*) … … 56 61 COPYRIGHTS_ADMIN, $name); 57 62 list($counter) = pwg_db_fetch_row(pwg_query($query)); 58 if ($counter != 0) { 63 64 if ($counter != 0) { // The copyright exists already 59 65 array_push($page['errors'], l10n('This copyright already exists')); 60 } else { 66 } else { // The copyright did not yet exist 67 // Compose a query to insert the copyright 61 68 $query = sprintf( 62 69 'INSERT INTO %s … … 65 72 ;', 66 73 COPYRIGHTS_ADMIN, $name, $url, $descr, $visible); 67 pwg_query($query); 74 pwg_query($query); // Execute the query 68 75 } 69 76 } 70 77 78 // Edit an existing copyright 71 79 if ($_GET['tab'] == 'edit') { 72 $edit = 1; 73 $CRid = $_REQUEST['id']; 80 $edit = 1; // Show the edit page 81 $CRid = $_REQUEST['id']; // Fetch the id of the copyright to be edited 82 83 // Fetch the current attributes to the copyright 74 84 $query = sprintf( 75 85 'SELECT * … … 80 90 $result = pwg_query($query); 81 91 $row = pwg_db_fetch_assoc($result); 92 93 // Save the attributes in convenient variables 82 94 $CRname = $row['name']; 83 95 $CRurl = $row['url']; … … 86 98 } 87 99 100 // Update an existing copyright 88 101 if ($_GET['tab'] == 'update') { 102 // Fetch the values from the edit form 89 103 $id = pwg_db_real_escape_string($_REQUEST['id']); 90 104 $name = pwg_db_real_escape_string($_REQUEST['name']); … … 92 106 $descr= pwg_db_real_escape_string($_REQUEST['descr']); 93 107 $visible = (isset($_REQUEST['visible']) ? 1 : 0); 108 109 // Compose a query to update the copyright 94 110 $query = sprintf( 95 111 'UPDATE %s … … 98 114 ;', 99 115 COPYRIGHTS_ADMIN, $name, $url, $descr, $visible, $id); 100 pwg_query($query); 116 pwg_query($query); // Execute the query 101 117 } 102 118 119 // Delete an existing copyright 103 120 if ($_GET['tab'] == 'delete') { 104 $id = $_REQUEST['id']; 121 $id = $_REQUEST['id']; // Fetch the id of the copyright to be deleted 122 123 // Compose a query to delete the copyright 105 124 $query = sprintf( 106 125 'DELETE FROM %s … … 108 127 ;', 109 128 COPYRIGHTS_ADMIN, $id); 110 pwg_query($query); 129 pwg_query($query); // Execute the query 111 130 } 112 131 } 113 132 114 / / Create page template133 /* Assign variables to the template */ 115 134 global $template; 116 135 136 // Add the admin.tpl template 117 137 $template->set_filenames( 118 138 array( … … 121 141 ); 122 142 143 // Select the existing copyrights 123 144 $query = sprintf( 124 145 'SELECT * … … 128 149 $result = pwg_query($query); 129 150 151 // Append the copyrights to the Smarty array 130 152 while ($row = pwg_db_fetch_assoc($result)) { 131 153 $template->append( … … 141 163 } 142 164 165 // Assign the path for URL forming 143 166 $template->assign( 144 167 'COPYRIGHTS_PATH', … … 146 169 ); 147 170 171 // Assign all the variables we constructed above 148 172 $template->assign('edit', $edit); 149 173 $template->assign('CRid', $CRid); … … 153 177 $template->assign('CRvisible', $CRvisible); 154 178 179 // Get it up and running 155 180 $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); 156 181 -
extensions/Copyrights/admin.tpl
r11624 r11656 3 3 </div> 4 4 5 <!-- Create the form for creating and editing copyrights --> 5 6 <form action='{$COPYRIGHTS_PATH}-{if $edit == 0}create{else}update{/if}' 6 7 method='POST'> … … 8 9 <legend>{if $edit == 0}{'Create copyright'|@translate} 9 10 {else}{'Update copyright'|@translate}{/if}</legend> 11 <!-- If $edit != 0 we should remember the id of the copyright that is 12 edited --> 10 13 {if $edit != 0}<input type='hidden' name='id' id='id' value='{$CRid}' />{/if} 14 <!-- Put all the attributes of the copyright in a nice table --> 11 15 <table> 12 16 <tr> … … 37 41 </fieldset> 38 42 </form> 43 44 <!-- If we are on the 'homepage', show a table of all copyrights --> 39 45 {if $edit == 0} 40 46 <form> … … 43 49 <table> 44 50 <tr> 51 <!-- Create a nice header row --> 45 52 <th>{'Name'|@translate}</th> 46 53 <th>{'URL'|@translate}</th> … … 49 56 <th>{'Actions'|@translate}</th> 50 57 </tr> 58 <!-- Loop over all copyrights --> 51 59 {if not empty($CRs)} 52 60 {foreach from=$CRs item=CR} 53 61 {strip} 54 <tr class="{cycle values="row1,row2"}"> 62 <tr class="{cycle values="row1,row2"}"> <!-- This gives nicely colored 63 table rows --> 55 64 <td>{$CR.name}</td> 56 65 <td><a href="{$CR.url}">{$CR.url}</a></td> -
extensions/Copyrights/image.php
r11635 r11656 3 3 This php file will insert the names of the copyrights into the images description, 4 4 so you can see below the image what copyright it has. 5 6 Mattias7 8 thanks to the AddInfo plugin by ddtddt!9 5 */ 10 6 11 // What do these prefilters do? 12 // First they use loc_begin_picture to set some template variables 13 // Then they use the same event to set a prefilter, who on his turn will change the content 14 15 // Add a prefilter - whatever a prefilter may be 7 // Add a prefilter 16 8 add_event_handler('loc_begin_picture', 'copyrights_set_prefilter_add_to_pic_info', 55 ); 17 9 -
extensions/Copyrights/main.inc.php
r11638 r11656 46 46 * +-----------------------------------------------------------------------+ */ 47 47 48 49 // Add to the menu, dont do anything right now 48 // Add an entry to the plugins menu 50 49 add_event_handler('get_admin_plugin_menu_links', 'copyrights_admin_menu'); 51 50 function copyrights_admin_menu($menu) { … … 88 87 * +-----------------------------------------------------------------------+ */ 89 88 90 // Add Copyrights dropdown menu to picture_modify89 // Add the Copyrights dropdown menu to picture_modify 91 90 include_once(dirname(__FILE__).'/modify.php'); 92 91
Note: See TracChangeset
for help on using the changeset viewer.