Changeset 6006
- Timestamp:
- 10/07/2017 01:23:36 PM (7 years ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content/plugins
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-customizations/templates/consistency.php
r3117 r6006 11 11 12 12 13 <form action="" method="get" class="consistency-form"> 14 <p> 15 <input type="text" name="search" required value="<?php echo gp_esc_attr_with_entities( $search ); ?>" class="consistency-form-search" placeholder="Enter original to search for…"> 16 <?php 17 $options = []; 18 $options[''] = 'Select a locale'; 19 $options = array_merge( $options, $sets ); 20 echo gp_select( 'set', $options, $set, [ 'class' => 'consistency-form-locale', 'required' => 'required' ] ); 21 ?> 22 <button type="submit" class="consistency-form-submit">Search</button> 13 <form action="/consistency" method="get" class="consistency-form"> 14 <p class="consistency-fields"> 15 <span class="consistency-field"> 16 <label for="original">Original</label> 17 <input id="original" type="text" name="search" required value="<?php echo gp_esc_attr_with_entities( $search ); ?>" class="consistency-form-search" placeholder="Enter original to search for…"> 18 </span> 19 20 <span class="consistency-field"> 21 <label for="set">Locale</label> 22 <?php 23 $locale_options = [ 24 '' => 'Select a locale', 25 ]; 26 $locale_options = array_merge( $locale_options, $sets ); 27 echo gp_select( 28 'set', 29 $locale_options, 30 $set, 31 [ 32 'class' => 'consistency-form-locale', 33 'required' => 'required', 34 ] 35 ); 36 ?> 37 </span> 38 39 <span class="consistency-field"> 40 <label for="project">Project</label> 41 <?php 42 $project_options = [ 43 '' => 'All Projects', 44 ]; 45 $project_options = $project_options + $projects; 46 echo gp_select( 47 'project', 48 $project_options, 49 $project, 50 [ 51 'class' => 'consistency-form-project', 52 ] 53 ); 54 ?> 55 </span> 23 56 </p> 24 57 25 <p class="consistency-form-filters">58 <p> 26 59 <label> 27 60 <input type="checkbox" name="search_case_sensitive" value="1"<?php checked( $search_case_sensitive ); ?>> … … 30 63 </p> 31 64 65 <p> 66 <button type="submit" class="consistency-form-submit">Analyze</button> 67 </p> 32 68 </form> 33 69 … … 38 74 } elseif ( $performed_search && $results ) { 39 75 $translations_unique_count = count( $translations_unique ); 40 if ( 1 === $translations_unique_count ) { 76 $has_different_translations = $translations_unique_count > 1; 77 if ( ! $has_different_translations ) { 41 78 echo '<p class="notice">All originals have the same translations</p>'; 42 79 } else { 43 echo '<div class="notice wporg-notice-warning"><p>There are ' . $translations_unique_count . ' different translations. <a id="toggle-translations-unique" href="#show">View</a></p>';80 echo '<div id="translations-overview" class="notice wporg-notice-warning"><p>There are ' . $translations_unique_count . ' different translations. <a id="toggle-translations-unique" href="#show">View</a></p>'; 44 81 echo '<ul class="translations-unique hidden">'; 45 82 foreach ( $translations_unique as $translation ) { 46 83 printf( 47 '<li data-id="%s">%s</li>',48 md5( $translation),49 str_replace( ' ', '<span class="space"> </span>', esc_translation($translation ) )84 '<li>%s <a href="#%s">↓</a></li>', 85 str_replace( ' ', '<span class="space"> </span>', esc_translation( $translation ) ), 86 esc_attr( sanitize_title( 't-' . $translation ) ) 50 87 ); 51 88 } … … 62 99 <tbody> 63 100 <?php 101 $previous_translation = ''; 102 64 103 foreach ( $results as $result ) { 65 104 $project_name = $result->project_name; … … 76 115 ' <span class="context">%s</span>', 77 116 esc_translation( $result->original_context ) 117 ); 118 } 119 120 if ( $has_different_translations && $previous_translation !== $result->translation ) { 121 $previous_translation = $result->translation; 122 printf( 123 '<tr id="%s" class="new-translation"><td colspan="2"><strong>%s</strong> <a href="#translations-overview">↑</a></td></tr>', 124 esc_attr( sanitize_title( 't-' . $result->translation ) ), 125 esc_translation( $result->translation ) 78 126 ); 79 127 } -
sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-customizations/templates/style.css
r5031 r6006 1750 1750 } 1751 1751 1752 .consistency-form-search, 1753 .consistency-form-locale { 1752 .consistency-form p { 1753 margin-bottom: 1em; 1754 } 1755 1756 .gp-content .consistency-form-search, 1757 .consistency-form-locale, 1758 .consistency-form-project { 1754 1759 height: 30px; 1755 1760 padding: 3px; 1756 color: #666;1757 1761 -webkit-box-sizing: border-box; 1758 1762 -moz-box-sizing: border-box; … … 1766 1770 outline-offset: 0; 1767 1771 margin: 0 3px; 1772 vertical-align: middle; 1773 } 1774 1775 .consistency-form-search:focus, 1776 .consistency-form-locale:focus, 1777 .consistency-form-project:focus { 1778 outline: 1px solid #5b9dd9; 1779 -webkit-box-shadow: 0 0 2px rgba(30,140,190,.8); 1780 box-shadow: 0 0 2px rgba(30,128,190,.8); 1768 1781 } 1769 1782 … … 1776 1789 } 1777 1790 1791 .consistency-form-project { 1792 width: 120px; 1793 } 1794 1778 1795 .consistency-form-submit { 1779 font-weight: 200; 1796 background: #0085ba; 1797 border-color: #0073aa #006799 #006799; 1798 box-shadow: 0 1px 0 #006799; 1799 color: #fff; 1800 height: 30px; 1801 line-height: 1; 1802 padding: 0 16px; 1803 vertical-align: top; 1804 box-sizing: border-box; 1805 cursor: pointer; 1806 display: inline-block; 1780 1807 font-size: 15px; 1781 line-height: 1; 1782 height: 30px; 1783 background-color: #21759b; 1784 background-image: -webkit-gradient(linear, left top, left bottom, from(#2a95c5), to(#21759b)); 1785 background-image: -webkit-linear-gradient(top, #2a95c5, #21759b); 1786 background-image: linear-gradient(to bottom, #2a95c5, #21759b); 1787 border: 1px solid #21759b; 1788 border-bottom-color: #1e6a8d; 1789 -webkit-box-shadow: inset 0 1px 0 rgba(120, 200, 230, 0.5); 1790 box-shadow: inset 0 1px 0 rgba(120, 200, 230, 0.5); 1808 } 1809 1810 .consistency-form-submit:hover, 1811 .consistency-form-submit:focus { 1812 background: #008ec2; 1813 border-color: #006799; 1814 box-shadow: 0 1px 0 #006799; 1791 1815 color: #fff; 1792 text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.3); 1793 padding: 3px 10px; 1794 cursor: pointer; 1795 } 1796 1797 .consistency-form-submit:hover { 1798 background-color: #278ab7; 1799 background-image: -webkit-gradient(linear, left top, left bottom, from(#2e9fd2), to(#21759b)); 1800 background-image: -webkit-linear-gradient(top, #2e9fd2, #21759b); 1801 background-image: linear-gradient(to bottom, #2e9fd2, #21759b); 1802 border-color: #1b607f; 1803 -webkit-box-shadow: inset 0 1px 0 rgba(120, 200, 230, 0.6); 1804 box-shadow: inset 0 1px 0 rgba(120, 200, 230, 0.6); 1805 } 1806 1807 .consistency-form-filters { 1808 margin-top: 8px; 1809 } 1810 1811 .consistency-form-filters label { 1812 border-right: 1px solid #ccc; 1813 padding: 0 15px 0 10px; 1816 } 1817 1818 .consistency-form-submit:focus { 1819 box-shadow: 0 1px 0 #0073aa, 0 0 2px 1px #33b3db; 1820 } 1821 1822 .consistency-form-submit:active { 1823 background: #0073aa; 1824 border-color: #006799; 1825 -webkit-box-shadow: inset 0 2px 0 #006799; 1826 box-shadow: inset 0 2px 0 #006799; 1827 } 1828 1829 .consistency-field { 1814 1830 display: inline-block; 1815 1831 } 1816 1832 1817 .consistency-form-filters label:last-child { 1818 border: none; 1833 .consistency-field label { 1834 display: block; 1835 margin: 0 3px; 1836 font-size: 13px; 1837 text-align: left; 1819 1838 } 1820 1839 … … 1837 1856 } 1838 1857 1858 .consistency-table tr.new-translation { 1859 border-bottom-width: 3px; 1860 } 1861 1839 1862 .consistency-table td { 1840 1863 padding: 10px 5px 0 0; 1841 1864 vertical-align: top; 1865 } 1866 1867 .consistency-table tr.new-translation td { 1868 padding: 40px 0 10px; 1842 1869 } 1843 1870 -
sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-routes/inc/routes/class-consistency.php
r3013 r6006 3 3 namespace WordPressdotorg\GlotPress\Routes\Routes; 4 4 5 use GP; 5 6 use GP_Locales; 6 7 use GP_Route; … … 15 16 private $cache_group = 'wporg-translate'; 16 17 18 const PROJECTS = [ 19 1 => 'WordPress', 20 523 => 'Themes', 21 17 => 'Plugins', 22 487 => 'Meta', 23 281 => 'Apps', 24 ]; 25 17 26 /** 18 27 * Prints a search form and the search results for a consistency view. … … 21 30 $sets = $this->get_translation_sets(); 22 31 23 $search = $set = '';24 $search_case_sensitive = true;32 $search = $set = $project = ''; 33 $search_case_sensitive = false; 25 34 26 35 if ( ! empty( $_REQUEST['search'] ) ) { … … 35 44 } 36 45 37 if ( ! empty( $_REQUEST ) && empty( $_REQUEST['search_case_sensitive'] ) ) { 38 $search_case_sensitive = false; 46 if ( ! empty( $_REQUEST['search_case_sensitive'] ) ) { 47 $search_case_sensitive = true; 48 } 49 50 if ( ! empty( $_REQUEST['project'] ) && isset( self::PROJECTS[ $_REQUEST['project'] ] ) ) { 51 $project = $_REQUEST['project']; 39 52 } 40 53 … … 53 66 'set' => $set, 54 67 'case_sensitive' => $search_case_sensitive, 68 'project' => $project, 55 69 ] ); 56 70 … … 58 72 $translations_unique = array_unique( $translations ); 59 73 } 74 75 $projects = self::PROJECTS; 60 76 61 77 $this->tmpl( 'consistency', get_defined_vars() ); … … 109 125 $slug = $wpdb->prepare( '%s', $slug ); 110 126 127 $project_where = ''; 128 if ( $args['project'] ) { 129 $project = GP::$project->get( $args['project'] ); 130 $project_where = $wpdb->prepare( 'AND p.path LIKE %s', $wpdb->esc_like( $project->path ) . '/%' ); 131 } 132 111 133 $results = $wpdb->get_results( " 112 134 SELECT … … 134 156 AND o.status = '+active' AND o.singular {$search} 135 157 AND ts.locale = {$locale} AND ts.slug = {$slug} 158 {$project_where} 136 159 LIMIT 0, 500 137 160 " ); … … 148 171 149 172 public function _sort_callback( $a, $b ) { 150 return strnatc mp( $a->translation, $b->translation );173 return strnatcasecmp( $a->translation, $b->translation ); 151 174 } 152 175 }
Note: See TracChangeset
for help on using the changeset viewer.