Changeset 11675


Ignore:
Timestamp:
Jul 9, 2011, 3:30:34 PM (13 years ago)
Author:
Mattias
Message:

Fixed bugs in modify.php, it works now, though it still looks awfull :-/
Added language for the error message in admin.php

Location:
extensions/Copyrights
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • extensions/Copyrights/TODO

    r11635 r11675  
    66=== Bugs ===
    77-       We don't check if the CR url has 'http://' (or is this a TODO?)
    8 -       Go to "unit mode", click "information", and you wont see the copyright...
     8-       Modify php, the copyrights select box is aligned center, and has a weird height, everythings works though
  • extensions/Copyrights/admin.php

    r11656 r11675  
    6363
    6464    if ($counter != 0) { // The copyright exists already
    65       array_push($page['errors'], l10n('This copyright already exists'));
     65      array_push($page['errors'], l10n('This copyright already exists.'));
    6666    } else { // The copyright did not yet exist
    6767      // Compose a query to insert the copyright
  • extensions/Copyrights/image.php

    r11656 r11675  
    11<?php
    2 /*
    3 This php file will insert the names of the copyrights into the images description,
    4 so you can see below the image what copyright it has.
    5 */
    62
    73// Add a prefilter
     
    3834function copyrights_add_image_vars_to_template()
    3935{
    40         // For as far as i know i only need the $prefixtable, $page and $template
    41         //global $conf, $page, $template, $tab, $cit, $nbr, $prefixeTable;
    4236        global $page, $template, $prefixeTable;
    43         //load_language('plugin.lang', ADDINFO_PATH);
    44         //load_language('lang', PHPWG_ROOT_PATH.'local/', array('no_fallback'=>true, 'local'=>true) );
    4537
    4638        // Show block only on the photo page
    4739        if ( !empty($page['image_id']) )
    4840        {
    49                 // Get the copyright name and url (FROM cr_admin) that belongs to the current media_item (FROM cr_media)
     41                // Get the copyright name, url and description that belongs to the current media_item
    5042                $query = '
    5143                  select name, url, descr
  • extensions/Copyrights/language/en_UK/plugin.lang.php

    r11292 r11675  
    88$lang['Delete copyright'] = 'Delete copyright';
    99$lang['Visible'] = 'Visible';
    10 
    11 // Isnt it smarter to translate them seperate - so you dont have to put so many entries in here...
     10$lang['This copyright already exists.'] = 'This copyright already exists.';
    1211
    1312?>
  • extensions/Copyrights/language/nl_NL/plugin.lang.php

    r11292 r11675  
    88$lang['Delete copyright'] = 'Verwijder copyright';
    99$lang['Visible'] = 'Zichtbaar';
     10$lang['This copyright already exists.'] = 'Deze copyright bestaat al.';
    1011
    1112?>
  • extensions/Copyrights/modify.php

    r11638 r11675  
    33// Add a prefilter
    44add_event_handler('loc_begin_admin', 'CR_set_prefilter_modify', 50 );
    5 add_event_handler('loc_end_admin', 'CR_modify_submit', 50 );
     5add_event_handler('loc_begin_admin', 'CR_modify_submit', 50 );
    66
    77// Change the variables used by the function that changes the template
    8 add_event_handler('loc_end_admin', 'CR_add_modify_vars_to_template');
     8add_event_handler('loc_begin_admin', 'CR_add_modify_vars_to_template');
    99
    1010function CR_set_prefilter_modify()
     
    2323                        <select id="copyright" name="copyright">
    2424                                <option value="0">--</option>
    25                                 {html_options options=$CRoptions selected=$CRcopyrights[$CRid]}
     25                                {html_options options=$CRoptions selected=$CRid}
    2626                        </select>
    2727                </td>
     
    3636function CR_add_modify_vars_to_template()
    3737{
    38         global $template;
     38        // Check if we are at the modify page (the problem is that this will send the stuff to every admin page that has an ?image_id...
     39        if (isset($_GET['image_id']))
     40        {
     41                global $template;
    3942
    40         load_language('plugin.lang', dirname(__FILE__).'/');
     43                load_language('plugin.lang', dirname(__FILE__).'/');
    4144
    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);
     45                // Fetch all the copyrights and assign them to the template
     46                $query = sprintf(
     47                        'SELECT `cr_id`,`name`
     48                        FROM %s
     49                        WHERE `visible`<>0
     50                        ;',
     51                        COPYRIGHTS_ADMIN);
     52                $result = pwg_query($query);
    5053
    51         $CRoptions = array();
    52         while ($row = pwg_db_fetch_assoc($result)) {
    53                 $CRoptions[$row['cr_id']] = $row['name'];
     54                $CRoptions = array();
     55                while ($row = pwg_db_fetch_assoc($result)) {
     56                        $CRoptions[$row['cr_id']] = $row['name'];
     57                }
     58                $template->assign('CRoptions', $CRoptions);
     59               
     60                // Get the current Copyright
     61                $image_id = $_GET['image_id'];
     62                $query = sprintf(
     63                        'SELECT `media_id`, `cr_id`
     64                        FROM %s
     65                        WHERE `media_id` = %d
     66                        ;',
     67                        COPYRIGHTS_MEDIA, $image_id);
     68                $result = pwg_query($query);
     69               
     70                $CRid = 0; // Default is '--'
     71                while ($row = pwg_db_fetch_assoc($result)) {
     72                        $CRid = $row['cr_id'];
     73                }
     74                $template->assign('CRid', $CRid);
    5475        }
    55         $template->assign('CRoptions', $CRoptions);
    56        
    57         // Get the current Copyright
    58         $image_id = $_GET['image_id']);
    59         $query = sprintf(
    60                 'SELECT `media_id`, `cr_id`
    61                 FROM %s
    62     WHERE `media_id` = %d
    63                 ;',
    64                 COPYRIGHTS_MEDIA, $image_id);
    65         $result = pwg_query($query);
    66        
    67   $CRid = 0; // Default is '--'
    68         while ($row = pwg_db_fetch_assoc($result)) {
    69                 $CRid = $row['cr_id'];
    70         }
    71         $template->assign('CRid', $CRid);
    7276}
    7377
    7478function CR_modify_submit()
    7579{
    76         if (isset($_POST['submit']))
     80        // Check if we are at the modify page (the problem is that this will send the stuff to every admin page that has an ?image_id...
     81        if (isset($_GET['image_id']))
    7782        {
    78                 // The data from the submit
    79                 $image_id = $_GET['image_id']);
    80     $CRid = $_POST['copyright'];
     83                if (isset($_POST['submit']))
     84                {
     85                        // The data from the submit
     86                        $image_id = $_GET['image_id'];
     87                        $CRid = $_POST['copyright'];
    8188
    82                 // Delete the Copyright if it allready exists
     89                        // Delete the Copyright if it allready exists
     90                        $query = sprintf(
     91                                'DELETE
     92                                FROM %s
     93                                WHERE `media_id` = %d
     94                                ;',
     95                                COPYRIGHTS_MEDIA, $image_id);
     96                        pwg_query($query);
     97
     98                // Insert the Copyright
    8399                $query = sprintf(
    84                         'DELETE
    85                         FROM %s
    86                         WHERE `media_id` = %d
    87                         ;',
    88                         COPYRIGHTS_MEDIA, $image_id);
     100                  'INSERT INTO %s
     101                  VALUES (%d, %d)
     102                  ;',
     103                  COPYRIGHTS_MEDIA, $image_id, $CRid);
    89104                pwg_query($query);
    90 
    91     // Insert the Copyright
    92     $query = sprintf(
    93       'INSERT INTO %s
    94       VALUES (%d, %d)
    95       ;',
    96       COPYRIGHTS_MEDIA, $image_id, $CRid);
    97     pwg_query($query);
     105                }
    98106        }
    99107}
Note: See TracChangeset for help on using the changeset viewer.