Changeset 11794
- Timestamp:
- Jul 21, 2011, 11:43:45 AM (13 years ago)
- Location:
- extensions/Copyrights
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/Copyrights/admin.php
r11675 r11794 145 145 'SELECT * 146 146 FROM %s 147 WHERE cr_id <> -1 148 ORDER BY cr_id ASC 147 149 ;', 148 150 COPYRIGHTS_ADMIN); -
extensions/Copyrights/batch_global.php
r11678 r11794 1 1 <?php 2 3 // @Johan: Misschien een goed idee om dit ook in een apart php scriptje te zetten, voor de overzichtelijkheid.4 // En om deze reden (Citaat uit de piwigo docs http://piwigo.org/doc/doku.php?id=en:plugins):5 // Code size6 // When PWG loads the plugins, it will include every main.inc.php.7 // Don't put in your main.inc.php 3000 lines of code just to add a page on the administration menu.8 // Split you main.inc.php in several files and feel free to add include_once inside functions defined in main.inc.php as much as you want.9 10 2 11 3 // Add copyrights drop down menu to the batch manager … … 28 20 FROM %s 29 21 WHERE `visible`<>0 22 ORDER BY cr_id ASC 30 23 ;', 31 24 COPYRIGHTS_ADMIN); … … 39 32 40 33 // Add info on the "choose action" dropdown in the batch manager 41 42 'ID' => 'copyrights',// ID of the batch manager action43 'NAME' => l10n('Edit copyright'), 44 45 34 $template->append('element_set_global_plugins_actions', array( 35 'ID' => 'copyrights', // ID of the batch manager action 36 'NAME' => l10n('Edit copyright'), // Description of the batch manager action 37 'CONTENT' => $template->parse('CR_batch_global', true) 38 ) 46 39 ); 47 40 } … … 55 48 $crID = pwg_db_real_escape_string($_POST['copyrightID']); 56 49 57 58 59 50 // Delete any previously assigned copyrights 51 if (count($collection) > 0) { 52 $query = sprintf( 60 53 'DELETE 61 54 FROM %s … … 66 59 } 67 60 68 // Add the copyrights from the submit form to an array 69 $edits = array(); 70 foreach ($collection as $image_id) 71 { 72 array_push( 73 $edits, 74 array( 75 'media_id' => $image_id, 76 'cr_id' => $crID, 77 ) 61 // If you assign no copyright, dont put them in the table 62 if ($crID != '') { 63 // Add the copyrights from the submit form to an array 64 $edits = array(); 65 foreach ($collection as $image_id) { 66 array_push( 67 $edits, 68 array( 69 'media_id' => $image_id, 70 'cr_id' => $crID, 71 ) 72 ); 73 } 74 75 // Insert the array into the database 76 mass_inserts( 77 COPYRIGHTS_MEDIA, // Table name 78 array_keys($edits[0]), // Columns 79 $edits // Data 78 80 ); 79 81 } 80 81 // Insert the array into the database82 mass_inserts(83 COPYRIGHTS_MEDIA, // Table name84 array_keys($edits[0]), // Columns85 $edits // Data86 );87 82 } 88 83 } -
extensions/Copyrights/batch_global.tpl
r11678 r11794 3 3 {'Copyright'|@translate} 4 4 <select name="copyrightID"> 5 <option value=" 0">--</option>5 <option value="">--</option> 6 6 {html_options options=$CRoptions} 7 7 </select> -
extensions/Copyrights/batch_single.php
r11678 r11794 24 24 <td> 25 25 <select id="copyright-{$element.ID}" name="copyright-{$element.ID}"> 26 <option value=" 0">--</option>26 <option value="">--</option> 27 27 {html_options options=$CRoptions selected=$CRcopyrights[$element.ID]} 28 28 </select> … … 48 48 FROM %s 49 49 WHERE `visible`<>0 50 ORDER BY cr_id ASC 50 51 ;', 51 52 COPYRIGHTS_ADMIN); … … 92 93 COPYRIGHTS_MEDIA, implode(',', $collection)); 93 94 pwg_query($query); 94 95 } 95 96 96 97 // Add all copyrights to an array … … 100 101 $crID = pwg_db_real_escape_string($_POST['copyright-'.$image_id]); 101 102 102 array_push( 103 $edits, 104 array( 105 'media_id' => $image_id, 106 107 'cr_id' => $crID, 108 ) 103 // If you assign no copyright, dont put them in the table 104 if ($crID != '') { 105 array_push( 106 $edits, 107 array( 108 'media_id' => $image_id, 109 'cr_id' => $crID, 110 ) 111 ); 112 } 113 } 114 115 if (count($edits) > 0) { 116 // Insert the array to the database 117 mass_inserts( 118 COPYRIGHTS_MEDIA, // Table name 119 array_keys($edits[0]), // Columns 120 $edits // Data 109 121 ); 110 } 111 112 // Insert the array to the database 113 mass_inserts( 114 COPYRIGHTS_MEDIA, // Table name 115 array_keys($edits[0]), // Columns 116 $edits // Data 117 ); 122 } 118 123 } 119 124 } -
extensions/Copyrights/image.php
r11678 r11794 44 44 // Get the copyright name, url and description that belongs to the current media_item 45 45 $query = sprintf(' 46 select name, url, descr46 select cr_id, name, url, descr 47 47 FROM %s NATURAL JOIN %s 48 48 WHERE media_id = %s 49 49 AND visible = 1 50 51 50 ;', 51 COPYRIGHTS_ADMIN, COPYRIGHTS_MEDIA, $page['image_id']); 52 52 $result = pwg_query($query); 53 $row = pwg_db_fetch_ row($result);53 $row = pwg_db_fetch_assoc($result); 54 54 $name = ''; 55 55 $url = ''; 56 56 $descr = ''; 57 if(count($row) > 0) { 58 $name = $row[0]; 59 $url = $row[1]; 60 $descr = $row[2]; 57 if (count($row) > 0) { 58 if ($row['cr_id'] == -1) { 59 $query = sprintf(' 60 SELECT name, url, descr 61 FROM %s 62 WHERE cr_id IN ( 63 SELECT a.copyright 64 FROM '.$prefixeTable.'images i, '.$prefixeTable.'author_extended a 65 WHERE i.id = %d 66 AND i.author = a.name 67 ) 68 ;', 69 COPYRIGHTS_ADMIN, $page['image_id']); 70 $result = pwg_query($query); 71 $row = pwg_db_fetch_assoc($result); 72 } 73 } 74 if (count($row) > 0) { 75 $name = $row['name']; 76 $url = $row['url']; 77 $descr = $row['descr']; 61 78 } 62 79 -
extensions/Copyrights/modify.php
r11678 r11794 3 3 // Add a prefilter 4 4 add_event_handler('loc_begin_admin', 'CR_set_prefilter_modify', 50 ); 5 add_event_handler('loc_begin_admin', 'CR_modify_submit', 50);5 add_event_handler('loc_begin_admin', 'CR_modify_submit', 45 ); 6 6 7 7 // Change the variables used by the function that changes the template … … 22 22 <td> 23 23 <select id="copyrightID" name="copyrightID"> 24 <option value=" 0">--</option>24 <option value="">--</option> 25 25 {html_options options=$CRoptions selected=$CRid} 26 26 </select> … … 48 48 FROM %s 49 49 WHERE `visible`<>0 50 ORDER BY cr_id ASC 50 51 ;', 51 52 COPYRIGHTS_ADMIN); … … 96 97 pwg_query($query); 97 98 98 // Insert the Copyright 99 $query = sprintf( 100 'INSERT INTO %s 101 VALUES (%d, %d) 102 ;', 103 COPYRIGHTS_MEDIA, $image_id, $CRid); 104 pwg_query($query); 99 // If you assign no copyright, dont put it in the table 100 if ($CRid != '') { 101 // Insert the Copyright 102 $query = sprintf( 103 'INSERT INTO %s 104 VALUES (%d, %d) 105 ;', 106 COPYRIGHTS_MEDIA, $image_id, $CRid); 107 pwg_query($query); 108 } 105 109 } 106 110 }
Note: See TracChangeset
for help on using the changeset viewer.