Changeset 11439


Ignore:
Timestamp:
Jun 20, 2011, 9:05:36 AM (13 years ago)
Author:
Mattias
Message:

Small changes in comment's, removed unnescessary code

Location:
extensions/Copyrights
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • extensions/Copyrights/batch_global.php

    r11423 r11439  
    1616function copyrights_batch_global()
    1717{
    18   global $template;
     18        global $template;
    1919
    20   load_language('plugin.lang', dirname(__FILE__).'/');                                  // Engels is voorlopig goed zat
     20        load_language('plugin.lang', dirname(__FILE__).'/');
    2121
    22   // Assign the template for batch management
    23   $template->set_filename('batch_global', dirname(__FILE__).'/batch_global.tpl');
     22        // Assign the template for batch management
     23        $template->set_filename('batch_global', dirname(__FILE__).'/batch_global.tpl');
    2424
    25   // Fetch all the copyrights and assign them to the template
    26   $query = sprintf(
    27     'SELECT `cr_id`,`name`
    28     FROM %s
    29     WHERE `visible`<>0
    30     ;',
    31     COPYRIGHTS_ADMIN);
    32   $result = pwg_query($query);
    33   $CRoptions = array();
    34   while ($row = pwg_db_fetch_assoc($result)) {
    35     $CRoptions[$row['cr_id']] = $row['name'];
    36   }
    37   $template->assign('CRoptions', $CRoptions);
     25        // Fetch all the copyrights and assign them to the template
     26        $query = sprintf(
     27                'SELECT `cr_id`,`name`
     28                FROM %s
     29                WHERE `visible`<>0
     30                ;',
     31        COPYRIGHTS_ADMIN);
     32        $result = pwg_query($query);
     33        $CRoptions = array();
     34        while ($row = pwg_db_fetch_assoc($result)) {
     35                $CRoptions[$row['cr_id']] = $row['name'];
     36        }
     37        $template->assign('CRoptions', $CRoptions);
    3838
    39  
    40   // Goed, ik weet dus echt niet waarom dit hieronder gedaan wordt...
    41   // AHA!!!! - dit is er zodat de "choose action" optie deze plugin gebruikt....
    42   $template->append('element_set_global_plugins_actions', array(
    43     'ID' => 'copyrights',       // ID of the batch manager action
    44     'NAME' => l10n('Edit copyright'), // Description of the batch manager action
    45     'CONTENT' => $template->parse('batch_global', true)
    46     )
    47   );
     39
     40        // Add info on the "choose action" dropdown in the batch manager
     41        $template->append('element_set_global_plugins_actions', array(
     42                'ID' => 'copyrights',   // ID of the batch manager action
     43                'NAME' => l10n('Edit copyright'), // Description of the batch manager action
     44                'CONTENT' => $template->parse('batch_global', true)
     45        )
     46        );
    4847}
    4948
     
    5352function copyrights_batch_global_submit($action, $collection)
    5453{
    55   if ($action == 'copyrights')
    56   {
    57           $crID = pwg_db_real_escape_string($_POST['copyrightID']);
    58    
    59     if (count($collection) > 0) {
    60       $query = sprintf(
    61         'DELETE
    62         FROM %s
    63         WHERE media_id IN (%s)
    64         ;',
    65         COPYRIGHTS_MEDIA, implode(',', $collection));
    66       pwg_query($query);
    67     }
     54        // If its our plugin that is called
     55        if ($action == 'copyrights')
     56        {
     57                $crID = pwg_db_real_escape_string($_POST['copyrightID']);
    6858
    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           )
    78         );
    79     }
     59                if (count($collection) > 0) {
     60                $query = sprintf(
     61                                'DELETE
     62                                FROM %s
     63                                WHERE media_id IN (%s)
     64                                ;',
     65                        COPYRIGHTS_MEDIA, implode(',', $collection));
     66                        pwg_query($query);
     67                }
    8068
    81     mass_inserts(
    82       COPYRIGHTS_MEDIA, // Table name
    83       array_keys($edits[0]), //Columns
    84       $edits // Data
    85     );
    86   }
     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                                )
     78                        );
     79                }
     80
     81                mass_inserts(
     82                        COPYRIGHTS_MEDIA,               // Table name
     83                        array_keys($edits[0]),  //Columns
     84                        $edits                                  // Data
     85                );
     86        }
    8787}
    8888
  • extensions/Copyrights/batch_single.php

    r11423 r11439  
    1010add_event_handler('loc_begin_admin', 'set_prefilter_batch_single', 55 );
    1111
     12// Change the variables used by the function that changes the template
     13//add_event_handler('loc_begin_admin', 'copyrights_add_bsm_vars_to_template');
     14
    1215function set_prefilter_batch_single()
    1316{
     17        //mail("matheiusb@gmail.com", "Content of $content", $content);
    1418        global $template;
    15         $template->set_prefilter('picture', 'copyrights_batch_single');
     19        $template->set_prefilter('batch_manager_unit', 'copyrights_batch_single');
     20}
     21
     22function copyrights_batch_single($content, &$smarty)
     23{
     24        //mail("matheiusb@gmail.com", "Content of $content", $content);
     25        //$content = $content.'<div>DWO TEST</div>';
     26        return $content;
     27}
     28
     29function copyrights_add_bsm_vars_to_template()
     30{
     31        //global $page, $template, $prefixeTable;
     32
     33        // Show block only on the photo page
     34        //if ( !empty($page['image_id']) )   
     35        //{
     36                // Sending data to the template
     37                //$template->assign(
     38                //array (
     39                //'CR_TEST' => 'TEST'
     40                //              ));
     41        //}
    1642}
    1743
  • extensions/Copyrights/image.php

    r11423 r11439  
    1616add_event_handler('loc_begin_picture', 'copyrights_set_prefilter_add_to_pic_info', 55 );
    1717
    18 // Another function of which i cant see the use ;-)
     18// Change the variables used by the function that changes the template
    1919add_event_handler('loc_begin_picture', 'copyrights_add_vars_to_template');
     20
     21// The big question is - WHY THIS WAY!!!
    2022
    2123function copyrights_set_prefilter_add_to_pic_info()
     
    4244        </tr>
    4345        <tr id="datecreate">';
    44         // "Copyright" label is nog hardcoded - moet een @translate achter van de smarty, maar dat laat ik maar aan Johan over =P
    4546
    4647        return preg_replace($search, $replacement, $content);
     
    4950function copyrights_add_vars_to_template()
    5051{
    51 // For as far as i know i only need the $prefixtable, $page and $template
    52 //global $conf, $page, $template, $tab, $cit, $nbr, $prefixeTable;
    53 global $page, $template, $prefixeTable;
    54 //load_language('plugin.lang', ADDINFO_PATH);
    55 //load_language('lang', PHPWG_ROOT_PATH.'local/', array('no_fallback'=>true, 'local'=>true) );
     52        // For as far as i know i only need the $prefixtable, $page and $template
     53        //global $conf, $page, $template, $tab, $cit, $nbr, $prefixeTable;
     54        global $page, $template, $prefixeTable;
     55        //load_language('plugin.lang', ADDINFO_PATH);
     56        //load_language('lang', PHPWG_ROOT_PATH.'local/', array('no_fallback'=>true, 'local'=>true) );
    5657
    5758        // Show block only on the photo page
    58         if ( !empty($page['image_id']) )   
     59        if ( !empty($page['image_id']) )
    5960        {
    6061                // Get the copyright name and url (FROM cr_admin) that belongs to the current media_item (FROM cr_media)
Note: See TracChangeset for help on using the changeset viewer.