Plugin Directory

Changeset 755014


Ignore:
Timestamp:
08/12/2013 09:44:19 AM (13 years ago)
Author:
Name.ly
Message:

version 0.0.8

Location:
quick-localization/tags/0.0.8
Files:
13 copied

Legend:

Unmodified
Added
Removed
  • quick-localization/tags/0.0.8/index.php

    r755009 r755014  
    22/*
    33 * Plugin Name:   Quick Localization (Quick Localisation)
    4  * Version:       0.0.7
     4 * Version:       0.0.9
    55 * Plugin URI:    http://name.ly/plugins/
    66 * Description:   Quick Localisation allows site admins to patch Wordpress translations of any theme and any plugin without leaving the control panel
     
    2222
    2323global $ql_options;
     24// $ql_options are checked [and saved when needed] when creating $QLC but are not propaged; we load them globally here
    2425$ql_options = get_option ( 'ql_options' );
    2526
  • quick-localization/tags/0.0.8/ql_class.php

    r542581 r755014  
    2727//  0.0.5           0.0.1
    2828//  0.0.6           0.0.1
     29//  0.0.7           0.0.1
     30//  0.0.8           0.0.1
     31//  0.0.9           0.0.1
    2932
    3033
     
    6265
    6366        $ql_options = get_option ( 'ql_options' );
     67        $saveaftercheck = false;
    6468
    6569        // here, in the future, we can check for previous versions, and if such, upgrade the table accordingly
     
    6872            $ql_options = array ();
    6973            $ql_options [ "version" ] = QL_VERSION;
     74            add_option ( "ql_options", $ql_options );
     75        }
     76
     77        if ( ! isset ( $ql_options [ "warn_on_duplicates" ] ) ) {
    7078            $ql_options [ "warn_on_duplicates" ] = "yes";
     79            $saveaftercheck = true;
     80        }
     81        if ( ! isset ( $ql_options [ "default_order_by" ] ) ) {
    7182            $ql_options [ "default_order_by" ] = "id";
    72             add_option ( "ql_options", $ql_options );
    73         }
    74 
    75         if ( isset ( $ql_options ['table'] ) && $ql_options ['table'] ) {
    76             $this -> table = $ql_options ['table'];
     83            $saveaftercheck = true;
     84        }
     85        if ( ! isset ( $ql_options [ "collect_draft_translations_fe" ] ) ) {
     86            $ql_options [ "collect_draft_translations_fe" ] = "no";
     87            $saveaftercheck = true;
     88        }
     89        if ( ! isset ( $ql_options [ "collect_draft_translations_be" ] ) ) {
     90            $ql_options [ "collect_draft_translations_be" ] = "no";
     91            $saveaftercheck = true;
     92        }
     93        if ( ! isset ( $ql_options [ "only_unknown" ] ) ) {
     94            $ql_options [ "only_unknown" ] = "no";
     95            $saveaftercheck = true;
     96        }
     97        if ( ! isset ( $ql_options [ "footer_textarea" ] ) ) {
     98            $ql_options [ "footer_textarea" ] = "no";
     99            $saveaftercheck = true;
     100        }
     101        if ( ! isset ( $ql_options [ "only_superadmins" ] ) ) {
     102            $ql_options [ "only_superadmins" ] = "no";
     103            $saveaftercheck = true;
     104        }
     105
     106        if ( $saveaftercheck ) {
     107            update_option ( "ql_options", $ql_options );
     108        }
     109
     110        if ( isset ( $ql_options [ 'table' ] ) && $ql_options [ 'table' ] ) {
     111            $this -> table = $ql_options [ 'table' ];
    77112        } else {
    78113            $this -> createtable ();
     
    124159        global $wpdb;
    125160        $ql_options = get_option ( 'ql_options' );
    126         $table = $ql_options ['table'];
     161        $table = $ql_options [ 'table' ];
    127162        if ( $table ) {
    128163            $wpdb -> query("DROP TABLE {$table} ");
  • quick-localization/tags/0.0.8/ql_edit.php

    r542581 r755014  
    11<?php
     2
     3
     4
     5define ( "QLC_BULK_EDIT_MAX_ITEMS", 50 );
    26
    37
     
    711}
    812
    9 function ql_print_main ( $domain = '', $order_by = '' ) {
     13function ql_print_main ( $domain = '', $order_by = '', $pageset = null ) {
    1014    global $QLC;
    1115
     
    1317    $warn_on_duplicates = "yes" == $ql_options [ 'warn_on_duplicates' ];
    1418
     19    $ql_all = $QLC -> get_from_db ( $domain, $order_by );
     20    $ql_all_ok = $ql_all && is_array ( $ql_all );
     21
     22    if ( $ql_all_ok && ! $pageset ) {
     23        $allow_bulk_edit = count ( $ql_all ) <= QLC_BULK_EDIT_MAX_ITEMS;
     24        $input_disabled = $allow_bulk_edit ? '' : ' disabled';
     25    } else {
     26        $allow_bulk_edit = true;
     27        $input_disabled = '';
     28    } // end of if ( $ql_all_ok )
     29
     30    if ( ! $allow_bulk_edit ) {
     31        echo "<p>" . sprintf ( __ ( 'N.B. Bulk edit is only possible for up to %d items. Please use individual paged view first by clicking on the numbered links above or below.', "QL" ), QLC_BULK_EDIT_MAX_ITEMS ) . "</p>";
     32    }
     33
    1534?>
    1635<table width="70%" id="ql">
    1736    <thead><tr><td></td><td><strong><?php _e ( "Old", "QL" ); ?></strong></td><td><strong><?php _e ( "New", "QL" ); ?></strong></td><td><strong><?php _e ( "Domain", "QL" ); ?></strong></td><td><strong><?php _e ( "Action(s)", "QL" ); ?></strong></td></tr></thead>
    1837<?php
    19     $ql_all = $QLC -> get_from_db ( $domain, $order_by );
    2038    $x = 1;
    21     if ( $ql_all && is_array ( $ql_all ) ) {
     39    if ( $ql_all_ok ) {
    2240        // work-around for PHP 5.2 not handling the "new" property correctly
    2341        $newfield = "new";
    24         foreach ( $ql_all as $row ) {
     42        foreach ( $ql_all as $index => $row ) {
     43            if ( $pageset ) {
     44                if ( $index < ($pageset-1)*QLC_BULK_EDIT_MAX_ITEMS || $index >= $pageset*QLC_BULK_EDIT_MAX_ITEMS ) {
     45                    continue;
     46                }
     47            }
    2548            $is_draft_domain = $QLC -> is_draft_domain ( $row->domain );
    2649            $undrafted_domain = $is_draft_domain ? $QLC -> undraft_domain ( $row -> domain ) : $row -> domain;
    27             $draft_domain_message = $is_draft_domain ? "<br /><a onclick='document.getElementById(\"ql_domain_$x\").value=\"{$undrafted_domain}\";if(\"\"==document.getElementById(\"ql_new_$x\").value){document.getElementById(\"ql_new_$x\").value=document.getElementById(\"ql_old_$x\").value;}'>" . __ ( "Undraft", "QL" ) . "</a>" : "" ;
     50            $draft_domain_message = $is_draft_domain && $allow_bulk_edit ? "<br /><a onclick='document.getElementById(\"ql_domain_$x\").value=\"{$undrafted_domain}\";if(\"\"==document.getElementById(\"ql_new_$x\").value){document.getElementById(\"ql_new_$x\").value=document.getElementById(\"ql_old_$x\").value;}'>" . __ ( "Undraft", "QL" ) . "</a>" : "" ;
    2851            if ( $warn_on_duplicates ) {
    2952                $did = $QLC -> find_id ( $row->old, $row->domain );
     
    3457                }
    3558            }
     59            $ps = QLC_BULK_EDIT_MAX_ITEMS > 0 ? ceil ( ( $index + 1 ) / QLC_BULK_EDIT_MAX_ITEMS ) : null;
     60            $empty_message = $allow_bulk_edit ? "<a onclick='ql_mark2delete($x);'>" . __ ( "Empty", "QL" ) . "</a> " . __ ( "(mark to delete)", "QL" ) : ( QLC_BULK_EDIT_MAX_ITEMS > 0 ? sprintf ( __ ( 'Switch to <a href="admin.php?page=ql-home' . ( $domain ? "&domain=" . urlencode ( $domain ) : "" ) . ( $order_by ? "&order_by=" . urlencode ( $order_by ) : "" ) . ( $ps ? "&pageset=" . $ps : "" ) . '#%d">page %d</a> to edit', "QL" ), $row->id, ceil ( ( $index + 1 ) / QLC_BULK_EDIT_MAX_ITEMS ) ) : "" );
    3661            $oldi = esc_textarea ( $row -> old );
    3762            $newi = esc_textarea ( $row -> $newfield );
     
    4065            <tr>
    4166            <td><input type='hidden' value='{$row->id}' name='ql[$x][id]' id='ql_id_$x' /></td>
    42             <td><a name='{$row->id}'></a><textarea style='width:90%;' size='50' name='ql[$x][old]' id='ql_old_$x' >{$oldi}</textarea></td>
    43             <td><textarea style='width:90%;' size='50' name='ql[$x][new]' id='ql_new_$x' >{$newi}</textarea></td>
    44             <td><input type='text' style='width:90%;' size='10' value='{$domaini}' name='ql[$x][domain]' id='ql_domain_$x' /></td>
    45             <td>{$duplicate_message}{$undrafted_duplicate_message}<a onclick='ql_mark2delete($x);'>" . __ ( "Empty", "QL" ) . "</a> " . __ ( "(mark to delete)", "QL" ) . "$draft_domain_message</td>
     67            <td><a name='{$row->id}'></a><textarea style='width:90%;' size='50' name='ql[$x][old]' id='ql_old_$x'" . $input_disabled . ">{$oldi}</textarea></td>
     68            <td><textarea style='width:90%;' size='50' name='ql[$x][new]' id='ql_new_$x'" . $input_disabled . ">{$newi}</textarea></td>
     69            <td><input type='text' style='width:90%;' size='10' value='{$domaini}' name='ql[$x][domain]' id='ql_domain_$x'" . $input_disabled . "/></td>
     70            <td>{$duplicate_message}{$undrafted_duplicate_message}{$empty_message}{$draft_domain_message}</td>
    4671            </tr>";
    4772            $x++;
     
    93118    $order_by = $order_by ? $order_by : "id";
    94119    $order_by_url = null === $order_by ? "" : "&order_by=" . urlencode ( $order_by );
     120    $pageset = isset ( $_GET [ 'pageset' ] ) ? (int) $_GET [ 'pageset' ] : null;
     121    $pageset_url = null === $pageset ? "" : "&pageset=" . $pageset;
    95122
    96123    if ( wp_verify_nonce ( $_POST [ 'qlenonce' ], 'qle' ) ) {
     
    135162<p><?php _e ( "Filter by domain:", "QL" ); ?>
    136163<?php
     164    $row_count = 0;
    137165    $list_of_saved_domains = $QLC -> get_list_of_saved_domains ();
    138166    $filter_line = "";
     
    140168    foreach ( $list_of_saved_domains as $row ) {
    141169        $filter_line .= " | ";
    142         $filter_line .= $domain === $row->domain ? ( $row->domain ? $row->domain : "empty" ) : '<a href="admin.php?page=ql-home&domain=' . urlencode ( $row->domain )  . $order_by_url . '">' . ( $row->domain ? $row->domain : "empty" ) . '</a>';
     170        $filter_line .= $domain === $row->domain ? ( $row->domain ? $row->domain : "empty" ) : '<a href="admin.php?page=ql-home&domain=' . urlencode ( $row->domain ) . $order_by_url . $pageset_url . '">' . ( $row->domain ? $row->domain : "empty" ) . '</a>';
    143171        $filter_line .= " (" . $row->count . ")";
    144172        $all_count += $row->count;
     173        if ( $domain === $row->domain ) {
     174            $row_count = $row->count;
     175        }
     176    }
     177    if ( ! $row_count && ! $domain ) {
     178        $row_count = $all_count;
    145179    }
    146180
    147181    $filter_line = ( null === $domain ? __ ( 'All', "QL" ) : '<a href="admin.php?page=ql-home' . $order_by_url . '">' . __ ( 'All', "QL" ) . '</a>' ) . " (" . $all_count . ")" . $filter_line;
    148182    echo $filter_line;
    149 ?>
    150 <br />
    151 <?php _e ( "Sort by:", "QL" );
    152     echo " " . ( "id" == $order_by || ! $order_by ? __ ( 'Addition time', "QL" ) : '<a href="admin.php?page=ql-home' . $domain_url . '&order_by=id">' . __ ( 'Addition time', "QL" ) . '</a>' );
    153     echo " | " . ( "old" == $order_by ? __ ( 'Old', "QL" ) : '<a href="admin.php?page=ql-home' . $domain_url . '&order_by=old">' . __ ( 'Old', "QL" ) . '</a>' );
    154     echo " | " . ( "new" == $order_by ? __ ( 'New', "QL" ) : '<a href="admin.php?page=ql-home' . $domain_url . '&order_by=new">' . __ ( 'New', "QL" ) . '</a>' );
     183    // Pages
     184    $number_of_pages = QLC_BULK_EDIT_MAX_ITEMS > 0 ? ceil ( $row_count / QLC_BULK_EDIT_MAX_ITEMS ) : 1 ;
     185    if ( $number_of_pages > 1 ) {
     186        echo "<br />";
     187        _e ( "Pages:", "QL" );
     188        echo " " . ( ! $pageset ? __ ( 'All', "QL" ) : '<a href="admin.php?page=ql-home' . $domain_url . $order_by_url . '">' . __ ( 'All', "QL" ) . '</a>' );
     189        for ( $index = 1; $index <= $number_of_pages; $index++ ) {
     190            echo " | " . ( $pageset == $index ? $index : '<a href="admin.php?page=ql-home' . $domain_url . $order_by_url . '&pageset=' . $index . '">' . $index . '</a>' );
     191        }
     192    }
     193    // Sorting
     194    echo "<br />";
     195    _e ( "Sort by:", "QL" );
     196    echo " " . ( "id" == $order_by || ! $order_by ? __ ( 'Addition time', "QL" ) : '<a href="admin.php?page=ql-home' . $domain_url . '&order_by=id' . $pageset_url . '">' . __ ( 'Addition time', "QL" ) . '</a>' );
     197    echo " | " . ( "old" == $order_by ? __ ( 'Old', "QL" ) : '<a href="admin.php?page=ql-home' . $domain_url . '&order_by=old' . $pageset_url . '">' . __ ( 'Old', "QL" ) . '</a>' );
     198    echo " | " . ( "new" == $order_by ? __ ( 'New', "QL" ) : '<a href="admin.php?page=ql-home' . $domain_url . '&order_by=new' . $pageset_url . '">' . __ ( 'New', "QL" ) . '</a>' );
    155199?>
    156200</p>
    157 <?php ql_print_main ( $domain, $order_by ); ?>
     201<?php ql_print_main ( $domain, $order_by, $pageset ); ?>
    158202<p><a href="#" onclick="ql_one_more_row(); return false;"><?php _e ( "Add another one", "QL" ); ?></a></p>
    159203
  • quick-localization/tags/0.0.8/ql_settings.php

    r700754 r755014  
    88    global $ql_options;
    99
    10     if ( wp_verify_nonce ( $_POST [ 'qlsnonce' ], 'qls' ) ) {
     10    if ( isset ( $_POST [ 'qlsnonce' ] ) && wp_verify_nonce ( $_POST [ 'qlsnonce' ], 'qls' ) ) {
    1111        if ( isset ( $_POST [ 'ql_save' ] ) ) {
    1212            //
  • quick-localization/tags/0.0.8/readme.txt

    r700754 r755014  
    7676== Changelog ==
    7777
     78= 0.0.9 =
     79
     80* Fixed warnings generated when WP_DEBUG is set to true
     81
     82= 0.0.8 =
     83
     84* Fixed bulk edit of many items, which did not work above some limit
     85* Added individual edit screens
     86
    7887= 0.0.7 =
    7988
Note: See TracChangeset for help on using the changeset viewer.