source: extensions/Extended_author/batch_global.php @ 13616

Last change on this file since 13616 was 11819, checked in by Mattias, 13 years ago

Added all files to the svn repository

File size: 1.7 KB
Line 
1<?php
2
3// Add event handlers for the prefilter
4add_event_handler('loc_end_element_set_global', 'EA_set_prefilter_batch_global', 55 );
5
6// Change the variables used by the function that changes the template
7add_event_handler('loc_end_element_set_global', 'EA_add_batch_single_vars_to_template');
8add_event_handler('element_set_global_action', 'EA_batch_global_submit', 50, 2);
9
10// Add a prefilter to the template
11function EA_set_prefilter_batch_global()
12{
13        global $template;
14        $template->set_prefilter('batch_manager_global', 'EA_batch_global');
15}
16
17// Insert the copyright selector to the template
18function EA_batch_global($content, &$smarty)
19{
20        // Replace the piwigo author by our own author stuff
21        $search = '/<div id="action_author".*?<\/div>/is';
22
23        // Tarkista jos ei ole toista <div> Välillä kirjailija divs
24        preg_match($search, $content, $result);
25        if (substr_count($result[0], '<div') > 1) {
26                global $page;
27                array_push($page['errors'], 'Error, someone added a <div> between the author <div>\'s. You can fix this long forseen bug in: extended_author plugin - batch_global.php - EA_batch_global - the regex expression ($search) :).');
28        }
29
30        $replacement = '<div id="action_author" class="bulkAction">
31                        {\'Author\'|@translate}:
32                        <select id="author" name="author">
33                                <option value="">--</option>
34                        {foreach from=$EAoptions item=option}
35                                <option value="{$option}">
36                                        {$option}
37                                </option>
38                        {/foreach}
39                        </select>
40                </div>';
41
42        $tempReturn = preg_replace($search, $replacement, $content);
43       
44        return $tempReturn;
45}
46
47// Process the submit action
48function EA_batch_global_submit($action, $collection)
49{
50        // If its our plugin that is called
51        if ($action == 'author') {
52                $name = pwg_db_real_escape_string($_POST['author']);
53                insert_default_CR($name);
54        }
55}
56
57?>
Note: See TracBrowser for help on using the repository browser.