Changeset 11678


Ignore:
Timestamp:
Jul 9, 2011, 4:43:05 PM (13 years ago)
Author:
J.Commelin
Message:

Finished adding comments to the code

Location:
extensions/Copyrights
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • extensions/Copyrights/TODO

    r11675 r11678  
    22-       Add Icon field to copyrights
    33-       Show the copyright when image is displayed
    4         It doesnt show a picture yet, but it does show the name of the copyright
     4  +     It doesnt show a picture yet, but it does show the name of the copyright
    55
    66=== Bugs ===
  • extensions/Copyrights/admin.tpl

    r11656 r11678  
    6868          {else}{'No'|@translate}{/if}
    6969        </td>
     70        <!-- Show nice Edit and Delete icons -->
    7071        <td>
    7172          <a href="{$COPYRIGHTS_PATH}-edit&id={$CR.cr_id}">
  • extensions/Copyrights/batch_global.php

    r11439 r11678  
    2121
    2222        // Assign the template for batch management
    23         $template->set_filename('batch_global', dirname(__FILE__).'/batch_global.tpl');
     23        $template->set_filename('CR_batch_global', dirname(__FILE__).'/batch_global.tpl');
    2424
    2525        // Fetch all the copyrights and assign them to the template
     
    3939
    4040        // 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
     41  $template->append('element_set_global_plugins_actions', array(
     42    'ID' => 'copyrights',       // ID of the batch manager action
    4343                'NAME' => l10n('Edit copyright'), // Description of the batch manager action
    44                 'CONTENT' => $template->parse('batch_global', true)
    45         )
     44    'CONTENT' => $template->parse('CR_batch_global', true)
     45  )
    4646        );
    4747}
    4848
    49 // * Deze functie wordt een keer aangeroepen, nadat de gebruiker submit.
    50 // * Fietst met een foreach loop over de geselecteerde fotos
    51 // * Rammelt alle toevoegingen in 1x met mass_updates naar de db.
     49// Process the submit action
    5250function copyrights_batch_global_submit($action, $collection)
    5351{
     
    5755                $crID = pwg_db_real_escape_string($_POST['copyrightID']);
    5856
    59                 if (count($collection) > 0) {
    60                 $query = sprintf(
     57    // Delete any previously assigned copyrights
     58    if (count($collection) > 0) {
     59        $query = sprintf(
    6160                                'DELETE
    6261                                FROM %s
     
    6766                }
    6867
     68    // Add the copyrights from the submit form to an array
    6969                $edits = array();
    7070                foreach ($collection as $image_id)
     
    7979                }
    8080
     81    // Insert the array into the database
    8182                mass_inserts(
    82                         COPYRIGHTS_MEDIA,               // Table name
    83                         array_keys($edits[0]),  //Columns
    84                         $edits                                  // Data
     83                        COPYRIGHTS_MEDIA,                   // Table name
     84                        array_keys($edits[0]),  // Columns
     85                        $edits                                          // Data
    8586                );
    8687        }
  • extensions/Copyrights/batch_global.tpl

    r11635 r11678  
     1<!-- Template for the copyright selector -->
    12<div id="copyrights">
    23        {'Copyright'|@translate}
  • extensions/Copyrights/batch_single.php

    r11635 r11678  
    11<?php
    22
    3 // Add a prefilter
     3// Add event handlers for the prefilter
    44add_event_handler('loc_end_element_set_unit', 'CR_set_prefilter_batch_single', 55 );
    55add_event_handler('loc_begin_element_set_unit', 'CR_batch_single_submit', 50 );
     
    88add_event_handler('loc_end_element_set_unit', 'CR_add_batch_single_vars_to_template');
    99
     10// Add a prefilter to the template
    1011function CR_set_prefilter_batch_single()
    1112{
     
    1415}
    1516
     17// Insert the copyright selector to the template
    1618function CR_batch_single($content, &$smarty)
    1719{
    18         $search = "#<td><strong>{'Creation date'#"; // Not ideal, but ok for now :)
     20        $search = "#<td><strong>{'Creation date'#";
    1921
    2022        // We use the <tr> from the Creation date, and give them a new <tr>
     
    3133                <td><strong>{\'Creation date\'';
    3234
    33     return preg_replace($search, $replacement, $content);
    34        
    35         // Dit is een interresant testje - deze functie word dus een aantal keren (3) aangeroepen,
    36         // en pas de laatste keer is bevat $content meer dan een aantal enters...
    37         // return $content.'<div id="dwo_test" style="display: none;">'.$content.'</div>';
     35  return preg_replace($search, $replacement, $content);
    3836}
    3937
     38// Assign the variables to the Smarty template
    4039function CR_add_batch_single_vars_to_template()
    4140{
     
    7069        while ($row = pwg_db_fetch_assoc($result)) {
    7170                $CRcopyrights[$row['media_id']] = $row['cr_id'];
    72         }
     71  }
     72
     73  // Assign the copyrights to the template
    7374        $template->assign('CRcopyrights', $CRcopyrights);
    7475}
    7576
     77// Catch the submit and update the copyrights tables
    7678function CR_batch_single_submit()
    7779{
     
    8183                $collection = explode(',', $_POST['element_ids']);
    8284
    83                 // Delete all existing id's of which the Copyright is going to be set
     85                // Delete all existing id's of which the copyright is going to be set
    8486                if (count($collection) > 0) {
    8587                        $query = sprintf(
     
    9092                                COPYRIGHTS_MEDIA, implode(',', $collection));
    9193                        pwg_query($query);
    92                 }
    93                 // Add all Copyrights to an array
     94    }
     95
     96                // Add all copyrights to an array
    9497                $edits = array();
    9598                foreach ($collection as $image_id) {
     
    105108                                )
    106109                        );
    107                 }
    108                 // Add the array to the database
     110    }
     111
     112                // Insert the array to the database
    109113                mass_inserts(
    110114                        COPYRIGHTS_MEDIA,        // Table name
  • extensions/Copyrights/image.php

    r11675 r11678  
    11<?php
    22
    3 // Add a prefilter
     3// Add an event handler for a prefilter
    44add_event_handler('loc_begin_picture', 'copyrights_set_prefilter_add_to_pic_info', 55 );
    55
     
    77add_event_handler('loc_begin_picture', 'copyrights_add_image_vars_to_template');
    88
     9// Add the prefilter to the template
    910function copyrights_set_prefilter_add_to_pic_info()
    1011{
     
    1314}
    1415
     16// Insert the template for the copyright display
    1517function copyrights_add_to_pic_info($content, &$smarty)
    1618{
     
    3234}
    3335
     36// Assign values to the variables in the template
    3437function copyrights_add_image_vars_to_template()
    3538{
     
    4043        {
    4144                // Get the copyright name, url and description that belongs to the current media_item
    42                 $query = '
     45                $query = sprintf('
    4346                  select name, url, descr
    44                   FROM '.COPYRIGHTS_ADMIN.' NATURAL JOIN '.COPYRIGHTS_MEDIA.'
    45                   WHERE media_id = '.$page['image_id'].'
     47                  FROM %s NATURAL JOIN %s
     48                  WHERE media_id = %s
    4649                  AND visible = 1
    47                   ;';
     50      ;',
     51      COPYRIGHTS_ADMIN, COPYRIGHTS_MEDIA, $page['image_id']);
    4852                $result = pwg_query($query);
    4953                $row = pwg_db_fetch_row($result);
     
    5862                       
    5963                // Sending data to the template
    60                 $template->assign(
    61                 array   (
    62                 'CR_INFO_NAME' => $name,
    63                 'CR_INFO_URL' => $url,
    64                 'CR_INFO_DESCR' => $descr
    65                                 ));
     64    $template->assign(
     65      array     (
     66        'CR_INFO_NAME' => $name,
     67        'CR_INFO_URL' => $url,
     68        'CR_INFO_DESCR' => $descr
     69      )
     70    );
    6671        }
    6772}
  • extensions/Copyrights/modify.php

    r11676 r11678  
    2121        $replacement = '<td><strong>{\'Copyright\'|@translate}</strong></td>
    2222                <td>
    23                         <select id="copyright_selector" name="copyright_selector">
     23                        <select id="copyrightID" name="copyrightID">
    2424                                <option value="0">--</option>
    2525                                {html_options options=$CRoptions selected=$CRid}
     
    8585                        // The data from the submit
    8686                        $image_id = $_GET['image_id'];
    87                         $CRid = $_POST['copyright_selector'];
     87                        $CRid = $_POST['copyrightID'];
    8888
    8989                        // Delete the Copyright if it allready exists
Note: See TracChangeset for help on using the changeset viewer.