Changeset 11621


Ignore:
Timestamp:
Jul 4, 2011, 2:17:12 PM (10 years ago)
Author:
Mattias
Message:

Updates batch_single.php and some minor changes in image.php (mostly comments)

Location:
extensions/Copyrights
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • extensions/Copyrights/TODO

    r11615 r11621  
    66- Add Icon field to copyrights
    77- Show the copyright when image is displayed
    8     (It doesnt show the picture, but it does show the name of the copyright)
     8    (It doesnt show a picture yet, but it does show the name of the copyright)
    99
    1010=== Bugs ===
    1111        - If you create a new copyright with a name that's already used
    1212        - Description doesnt show with the copyright info (on the admin page)
    13         - The warning triangle saying our plugin does not seem compatible
     13        - The warning triangle saying our plugin does not seem compatible (version: ...)
    1414        - Cannot create a new copyright???
  • extensions/Copyrights/batch_single.php

    r11619 r11621  
    22
    33// Add a prefilter
    4 add_event_handler('loc_end_element_set_unit', 'set_prefilter_batch_single', 55 );
     4add_event_handler('loc_end_element_set_unit', 'CR_set_prefilter_batch_single', 55 );
    55add_event_handler('loc_end_element_set_unit', 'CR_batch_single_submit', 55 );
    66
    77// Change the variables used by the function that changes the template
    8 //add_event_handler('loc_begin_admin', 'CR_add_bsm_vars_to_template');
     8add_event_handler('loc_begin_admin', 'CR_add_batch_single_vars_to_template');
    99
    10 function set_prefilter_batch_single()
     10function CR_set_prefilter_batch_single()
    1111{
    1212        global $template;
     
    1616function CR_batch_single($content, &$smarty)
    1717{
    18   $search = "#<td><strong>{'Creation date'#"; // Not ideal, but ok for now :)
     18        $search = "#<td><strong>{'Creation date'#"; // Not ideal, but ok for now :)
    1919
    20   // We use the <tr> from the Creation date, and give them a new <tr>
    21   $replacement = '<td><strong>DWO TESTJE</strong></td>
     20        // We use the <tr> from the Creation date, and give them a new <tr>
     21        $replacement = '<td><strong>{\'Copyright\'|@translate}</strong></td>
    2222                <td>
    23                         DWO TESTJE
     23                        {html_options name=copyright-{$element.ID} options=$CRoptions}
    2424                </td>
    2525        </tr>
     
    3232        // Dit is een interresant testje - deze functie word dus een aantal keren (3) aangeroepen,
    3333        // en pas de laatste keer is bevat $content meer dan een aantal enters...
    34         //return $content.'<div id="dwo_test" style="display: none;">'.$content.'</div>';
     34        // return $content.'<div id="dwo_test" style="display: none;">'.$content.'</div>';
    3535}
    3636
    37 function CR_add_bsm_vars_to_template()
     37function CR_add_batch_single_vars_to_template()
    3838{
    39   // set template variables ($CRoptions)
    40   global $template;
    41   load_language('plugin.lang', dirname(__FILE__).'/');
    42   // Fetch all the copyrights and assign them to the template
    43   $query = sprintf(
    44     'SELECT `cr_id`,`name`
    45     FROM %s
    46     WHERE `visible`<>0
    47     ;',
    48   COPYRIGHTS_ADMIN);
    49   $result = pwg_query($query);
    50   $CRoptions = array();
    51   while ($row = pwg_db_fetch_assoc($result)) {
    52     $CRoptions[$row['cr_id']] = $row['name'];
    53   }
    54   $template->assign('CRoptions', $CRoptions);
     39        global $template;
     40
     41        load_language('plugin.lang', dirname(__FILE__).'/');
     42
     43        // Fetch all the copyrights and assign them to the template
     44        $query = sprintf(
     45                'SELECT `cr_id`,`name`
     46                FROM %s
     47                WHERE `visible`<>0
     48                ;',
     49                COPYRIGHTS_ADMIN);
     50        $result = pwg_query($query);
     51
     52        $CRoptions = array();
     53        while ($row = pwg_db_fetch_assoc($result)) {
     54                $CRoptions[$row['cr_id']] = $row['name'];
     55        }
     56        $template->assign('CRoptions', $CRoptions);
    5557}
    5658
    5759function CR_batch_single_submit()
    5860{
    59   // The image id's:
    60   $collection = explode(',', $_POST['element_ids']);
    61  
    62   // Delete all existing id's of which the Copyright is going to be set
    63   if (count($collection) > 0) {
    64   $query = sprintf(
    65       'DELETE
    66       FROM %s
    67       WHERE media_id IN (%s)
    68       ;',
    69     COPYRIGHTS_MEDIA, implode(',', $collection));
    70     pwg_query($query);
    71   }
    72   $edits = array();
    73   foreach ($collection as $image_id)
    74   {
    75     // The copyright id's
    76     $crID = pwg_db_real_escape_string($_POST['copyrightID-'.$image_id]);
    77    
    78     array_push(
    79       $edits,
    80       array(
    81         'media_id' => $image_id,
    82         'cr_id' => $crID,
    83       )
    84     );
    85   }
    86   mass_inserts(
    87     COPYRIGHTS_MEDIA,        // Table name
    88     array_keys($edits[0]),   // Columns
    89     $edits                   // Data
    90   );
     61        // The image id's:
     62        $collection = explode(',', $_POST['element_ids']);
     63
     64        // Delete all existing id's of which the Copyright is going to be set
     65        if (count($collection) > 0) {
     66                $query = sprintf(
     67                        'DELETE
     68                        FROM %s
     69                        WHERE media_id IN (%s)
     70                        ;',
     71                        COPYRIGHTS_MEDIA, implode(',', $collection));
     72                pwg_query($query);
     73        }
     74        // Add all Copyrights to an array
     75        $edits = array();
     76        foreach ($collection as $image_id) {
     77                // The copyright id's
     78                $crID = pwg_db_real_escape_string($_POST['copyrightID-'.$image_id]);
     79
     80                array_push(
     81                        $edits,
     82                        array(
     83                                'media_id' => $image_id,
     84                                'cr_id' => $crID,
     85                        )
     86                );
     87        }
     88        // Add the array to the database
     89        mass_inserts(
     90                COPYRIGHTS_MEDIA,        // Table name
     91                array_keys($edits[0]),   // Columns
     92                $edits                   // Data
     93        );
    9194}
    9295
  • extensions/Copyrights/image.php

    r11505 r11621  
    1717
    1818// Change the variables used by the function that changes the template
    19 add_event_handler('loc_begin_picture', 'copyrights_add_vars_to_template');
     19add_event_handler('loc_begin_picture', 'copyrights_add_image_vars_to_template');
    2020
    2121function copyrights_set_prefilter_add_to_pic_info()
     
    2424        $template->set_prefilter('picture', 'copyrights_add_to_pic_info');
    2525}
    26  
    2726
    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
    2927function copyrights_add_to_pic_info($content, &$smarty)
    3028{
    31         // Voeg de informatie toe na de auteur - dus voor de datum dat ie gemaakt is...
     29        // Add the information after the author - so before the createdate
    3230        $search = '#<tr id="datecreate">#';
    3331       
     
    4644}
    4745
    48 function copyrights_add_vars_to_template()
     46function copyrights_add_image_vars_to_template()
    4947{
    5048        // For as far as i know i only need the $prefixtable, $page and $template
Note: See TracChangeset for help on using the changeset viewer.