Changeset 11423
- Timestamp:
- Jun 18, 2011, 9:16:29 PM (13 years ago)
- Location:
- extensions/Copyrights
- Files:
-
- 3 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/Copyrights/TODO
r11422 r11423 1 1 === TODO === 2 2 - Implement single mode Batch Manager 3 Probably use prefilters combined with loc_begin_element_set_unit 3 Probably use prefilters combined with "loc_begin_element_set_unit" (found in event tracer) 4 SOURCES: "loc_begin_admin": http://piwigo.org/forum/viewtopic.php?id=17468 5 "use prefilters": http://piwigo.org/forum/viewtopic.php?id=17551&p=2 4 6 - Add Icon field to copyrights 5 7 - Show the copyright when image is displayed … … 9 11 - If you create a new copyright with a name that's already used 10 12 - Description doesnt show with the copyright info (on the admin page) 13 - The warning triangle saying our plugin does not seem compatible - no clue -
extensions/Copyrights/image.php
r11292 r11423 9 9 */ 10 10 11 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 12 14 13 15 // Add a prefilter - whatever a prefilter may be 14 add_event_handler('loc_begin_picture', ' set_prefilter_add_to_pic_info', 55 );16 add_event_handler('loc_begin_picture', 'copyrights_set_prefilter_add_to_pic_info', 55 ); 15 17 16 function set_prefilter_add_to_pic_info() 18 // Another function of which i cant see the use ;-) 19 add_event_handler('loc_begin_picture', 'copyrights_add_vars_to_template'); 20 21 function copyrights_set_prefilter_add_to_pic_info() 17 22 { 18 23 global $template; 19 $template->set_prefilter('picture', ' add_to_pic_info');24 $template->set_prefilter('picture', 'copyrights_add_to_pic_info'); 20 25 } 21 26 22 27 23 28 // This function is called by the set_prefilter_add_to_pic_info function. It has something to do with the prefilter stuff, whatever it may be :p 24 function add_to_pic_info($content, &$smarty)29 function copyrights_add_to_pic_info($content, &$smarty) 25 30 { 26 31 // Voeg de informatie toe na de auteur - dus voor de datum dat ie gemaakt is... … … 42 47 } 43 48 44 // Another function of which i cant see the use ;-) 45 add_event_handler('loc_begin_picture', 'add_vars_to_template'); 46 47 function add_vars_to_template() 49 function copyrights_add_vars_to_template() 48 50 { 49 51 // For as far as i know i only need the $prefixtable, $page and $template 50 global $conf, $page, $template, $tab, $cit, $nbr, $prefixeTable; 52 //global $conf, $page, $template, $tab, $cit, $nbr, $prefixeTable; 53 global $page, $template, $prefixeTable; 51 54 //load_language('plugin.lang', ADDINFO_PATH); 52 55 //load_language('lang', PHPWG_ROOT_PATH.'local/', array('no_fallback'=>true, 'local'=>true) ); -
extensions/Copyrights/main.inc.php
r11422 r11423 32 32 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); 33 33 34 define('COPYRIGHTS_PATH', PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)) . '/'); // The plugin path 35 define('COPYRIGHTS_WEB_PATH', get_root_url().'admin.php?page=plugin-Copyrights'); 36 // Whats the difference between "COPYRIGHTS_PATH" and "COPYRIGHTS_WEB_PATH" ??? 34 define('COPYRIGHTS_PATH', PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)) . '/'); // The plugin path 35 define('COPYRIGHTS_WEB_PATH', get_root_url().'admin.php?page=plugin-Copyrights'); // The path used in admin.php 37 36 38 37 global $prefixeTable; … … 48 47 49 48 49 // Add to the menu, dont do anything right now 50 50 add_event_handler('get_admin_plugin_menu_links', 'copyrights_admin_menu'); 51 51 function copyrights_admin_menu($menu) { … … 66 66 67 67 68 // if (script_basename() == 'picture') // Why should i want this here?68 // Add information to the picture's description (The copyright's name) 69 69 include_once(dirname(__FILE__).'/image.php'); 70 70 … … 74 74 * +-----------------------------------------------------------------------+ */ 75 75 76 77 // Global mode 78 include_once(dirname(__FILE__).'/batch_global.php'); 76 79 77 // @Johan: Misschien een goed idee om dit ook in een apart php scriptje te zetten, voor de overzichtelijkheid. 78 // En om deze reden (Citaat uit de piwigo docs http://piwigo.org/doc/doku.php?id=en:plugins): 79 // Code size 80 // When PWG loads the plugins, it will include every main.inc.php. 81 // Don't put in your main.inc.php 3000 lines of code just to add a page on the administration menu. 82 // 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. 83 84 85 // Add copyrights drop down menu to the batch manager 86 add_event_handler('loc_end_element_set_global', 'copyrights_batch'); 87 // Add handler to the submit event of the batch manager 88 add_event_handler('element_set_global_action', 'copyrights_batch_submit', 50, 2); 89 90 function copyrights_batch() 91 { 92 global $template; 93 94 load_language('plugin.lang', dirname(__FILE__).'/'); // Engels is voorlopig goed zat 95 96 // Assign the template for batch management 97 $template->set_filename('batch', dirname(__FILE__).'/batch.tpl'); 98 99 // Fetch all the copyrights and assign them to the template 100 $query = sprintf( 101 'SELECT `cr_id`,`name` 102 FROM %s 103 WHERE `visible`<>0 104 ;', 105 COPYRIGHTS_ADMIN); 106 $result = pwg_query($query); 107 $CRoptions = array(); 108 while ($row = pwg_db_fetch_assoc($result)) { 109 $CRoptions[$row['cr_id']] = $row['name']; 110 } 111 $template->assign('CRoptions', $CRoptions); 112 113 114 // Goed, ik weet dus echt niet waarom dit hieronder gedaan wordt... 115 // AHA!!!! - dit is er zodat de "choose action" optie deze plugin gebruikt.... 116 $template->append('element_set_global_plugins_actions', array( 117 'ID' => 'copyrights', // ID of the batch manager action 118 'NAME' => l10n('Edit copyright'), // Description of the batch manager action 119 'CONTENT' => $template->parse('batch', true) 120 ) 121 ); 122 } 123 124 // * Deze functie wordt een keer aangeroepen, nadat de gebruiker submit. 125 // * Fietst met een foreach loop over de geselecteerde fotos 126 // * Rammelt alle toevoegingen in 1x met mass_updates naar de db. 127 function copyrights_batch_submit($action, $collection) 128 { 129 if ($action == 'copyrights') 130 { 131 $crID = pwg_db_real_escape_string($_POST['copyrightID']); 132 133 if (count($collection) > 0) { 134 $query = sprintf( 135 'DELETE 136 FROM %s 137 WHERE media_id IN (%s) 138 ;', 139 COPYRIGHTS_MEDIA, implode(',', $collection)); 140 pwg_query($query); 141 } 142 143 $edits = array(); 144 foreach ($collection as $image_id) 145 { 146 array_push( 147 $edits, 148 array( 149 'media_id' => $image_id, 150 'cr_id' => $crID, 151 ) 152 ); 153 } 154 155 mass_inserts( 156 COPYRIGHTS_MEDIA, // Table name 157 array_keys($edits[0]), //Columns 158 $edits // Data 159 ); 160 } 161 } 80 // Single mode - TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST 81 // should become a include_once !!! 82 include(dirname(__FILE__).'/batch_single.php'); 162 83 163 84 ?>
Note: See TracChangeset
for help on using the changeset viewer.