Changeset 3512
- Timestamp:
- 06/20/2016 05:50:53 PM (9 years ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/tools/class-filesystem.php
r3033 r3512 8 8 */ 9 9 class Filesystem { 10 11 /** 12 * Path to temporary directory. 13 * 14 * @var string 15 */ 10 16 const TMP_DIR = '/tmp/plugin-directory/'; 11 17 … … 15 21 * The temporary directory returned will be removed upon script termination. 16 22 * 17 * @ param string $prefix The prefix for the directory, 'hello-dolly' for example. Optional.23 * @static 18 24 * 25 * @param string $prefix Optional. The prefix for the directory, 'hello-dolly' for example. Default: empty string. 19 26 * @return string The temporary directory. 20 27 */ … … 24 31 } 25 32 26 // Generate a unique filename 33 // Generate a unique filename. 27 34 $tmp_dir = tempnam( self::TMP_DIR, $prefix ); 28 35 29 // Replace that filename with a directory 36 // Replace that filename with a directory. 30 37 unlink( $tmp_dir ); 31 38 mkdir( $tmp_dir, 0777 ); … … 40 47 * Extract a ZIP file to a directory. 41 48 * 49 * @static 50 * 42 51 * @param string $zip_file The ZIP file to extract. 43 * @param string $directory The Directory to extract the ZIP to. Optional. Default: A Temporary directory. 44 * 52 * @param string $directory Optional. The Directory to extract the ZIP to. Default: A Temporary directory. 45 53 * @return string The directory the ZIP was extracted to. 46 54 */ … … 68 76 * Returns all (usable) files of a given directory. 69 77 * 78 * @static 79 * 70 80 * @param string $directory Path to directory to search. 71 * @param bool $recursive Whether to recurse into subdirectories. Default: false. 72 * @param string $pattern A regular expression to match files against. Optional. 73 * 81 * @param bool $recursive Optional. Whether to recurse into subdirectories. Default: false. 82 * @param string $pattern Optional. A regular expression to match files against. Default: null. 74 83 * @return array All files within the passed directory. 75 84 */ … … 104 113 * Forcibly remove a directory recursively. 105 114 * 115 * @static 116 * 106 117 * @param string $dir The directory to remove. 107 *108 118 * @return bool Whether the directory was removed. 109 119 */ -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/tools/class-svn.php
r3370 r3512 12 12 * Import a local directory to a SVN path. 13 13 * 14 * @param string $path The local folder to import into SVN. 15 * @param string $url The URL to import to. 16 * @param string $message The commit message. 17 * 14 * @static 15 * 16 * @param string $path The local folder to import into SVN. 17 * @param string $url The URL to import to. 18 * @param string $message The commit message. 18 19 * @return array { 19 * @type bool $result The result of the operation.20 * @type int $revision The revision imported.20 * @type bool $result The result of the operation. 21 * @type int $revision The revision imported. 21 22 * } 22 23 */ 23 24 public static function import( $path, $url, $message ) { 24 $options = array(25 $options = array( 25 26 'non-interactive', 26 'm' => $message,27 'm' => $message, 27 28 'user' => PLUGIN_SVN_MANAGEMENT_USER, 28 29 'pass' => PLUGIN_SVN_MANAGEMENT_PASS, … … 48 49 * Create an SVN Export of a URL to a local directory. 49 50 * 51 * @static 52 * 50 53 * @param string $url The URL to export. 51 54 * @param string $destination The local folder to export into. 52 * @param array $options A list of options to pass to SVN. Optional. 53 * 55 * @param array $options Optional. A list of options to pass to SVN. Default: empty array. 54 56 * @return array { 55 * @type bool $result The result of the operation.56 * @type int $revision The revision exported.57 * @type bool $result The result of the operation. 58 * @type int $revision The revision exported. 57 59 * } 58 60 */ 59 61 public static function export( $url, $destination, $options = array() ) { 60 $options[] = 'non-interactive';62 $options[] = 'non-interactive'; 61 63 $esc_options = self::parse_esc_parameters( $options ); 62 64 63 $esc_url = escapeshellarg( $url );65 $esc_url = escapeshellarg( $url ); 64 66 $esc_destination = escapeshellarg( $destination ); 65 67 … … 67 69 if ( preg_match( '/Exported revision (?P<revision>\d+)[.]/i', $output, $m ) ) { 68 70 $revision = (int) $m['revision']; 69 $result = true;71 $result = true; 70 72 } else { 71 73 $result = false; … … 79 81 * List the files in a remote SVN destination. 80 82 * 83 * @static 84 * 81 85 * @param string $url The URL to export. 82 * @param bool $verbose Whether to list the files verbosely with extra metadata.83 * 84 * @return array If non-verbose a list of files, if verbose an array of items containing the filename, date,filesize, author and revision.86 * @param bool $verbose Optional. Whether to list the files verbosely with extra metadata. Default: false. 87 * @return array If non-verbose a list of files, if verbose an array of items containing the filename, date, 88 * filesize, author and revision. 85 89 */ 86 90 public static function ls( $url, $verbose = false ) { 87 91 $options = array( 88 'non-interactive' 92 'non-interactive', 89 93 ); 90 94 if ( $verbose ) { … … 92 96 } 93 97 $esc_options = self::parse_esc_parameters( $options ); 94 $esc_url = escapeshellarg( $url );98 $esc_url = escapeshellarg( $url ); 95 99 96 100 $output = self::shell_exec( "svn ls $esc_options $esc_url 2>&1" ); 97 98 101 $errors = self::parse_svn_errors( $output ); 99 102 if ( $errors ) { … … 104 107 return array_filter( array_map( 'trim', explode( "\n", $output ) ) ); 105 108 } else { 106 // Parse SVN verbose output. 107 // ^revision author [filesize] date filename$ 109 110 /* 111 * Parse SVN verbose output. 112 * ^revision author [filesize] date filename$ 113 */ 108 114 preg_match_all( '!^\s*(?P<revision>\d+)\s(?P<author>\S+)\s*(?P<filesize>\d+)?\s*(?P<date>.+?)\s*(?P<filename>\S+)\s*$!im', $output, $files, PREG_SET_ORDER ); 109 115 110 // Remove numeric keys from output 111 $files = array_map( function ( $item ) {116 // Remove numeric keys from output. 117 $files = array_map( function ( $item ) { 112 118 return array_filter( $item, 'is_string', ARRAY_FILTER_USE_KEY ); 113 119 }, $files ); … … 120 126 * Fetch SVN revisions for a given revision or range of revisions. 121 127 * 128 * @static 129 * 122 130 * @param string $url The URL to fetch. 123 * @param string|array $revision The revision to get information about. Default HEAD. 124 * @param array $options A list of options to pass to SVN. Optional. 125 * 131 * @param string|array $revision Optional. The revision to get information about. Default HEAD. 132 * @param array $options Optional. A list of options to pass to SVN. Default: empty array. 126 133 * @return array { 127 * @type array|false $errorsWhether any errors or warnings were encountered.128 * @type array $logThe SVN log data struct.134 * @type array|false $errors Whether any errors or warnings were encountered. 135 * @type array $log The SVN log data struct. 129 136 * } 130 137 */ 131 138 public static function log( $url, $revision = 'HEAD', $options = array() ) { 132 $options[] = 'non-interactive';133 $options[] = 'verbose';134 $options[] = 'xml';139 $options[] = 'non-interactive'; 140 $options[] = 'verbose'; 141 $options[] = 'xml'; 135 142 $options['revision'] = is_array( $revision ) ? "{$revision[0]}:{$revision[1]}" : $revision; 136 $esc_options = self::parse_esc_parameters( $options );143 $esc_options = self::parse_esc_parameters( $options ); 137 144 138 145 $esc_url = escapeshellarg( $url ); 139 146 140 147 $output = self::shell_exec( "svn log $esc_options $esc_url 2>&1" ); 141 142 148 $errors = self::parse_svn_errors( $output ); 143 149 144 150 $log = array(); 145 151 146 // We use funky string mangling here to extract the XML as it may have been truncated by a SVN error, or suffixed by a SVN warning 152 /* 153 * We use funky string mangling here to extract the XML as it may have been truncated by a SVN error, 154 * or suffixed by a SVN warning. 155 */ 147 156 $xml = substr( $output, $start = stripos( $output, '<?xml' ), $end = ( strripos( $output, '</log>' ) - $start + 6 ) ); 148 157 if ( $xml && false !== $start && false !== $end ) { 149 158 150 159 $user_errors = libxml_use_internal_errors( true ); 151 $simple_xml = simplexml_load_string( $xml );160 $simple_xml = simplexml_load_string( $xml ); 152 161 libxml_use_internal_errors( $user_errors ); 153 162 … … 157 166 foreach ( $simple_xml->logentry as $entry ) { 158 167 $revision = (int) $entry->attributes()['revision']; 159 $paths = array(); 160 foreach ( $entry->paths->children() as $p ) { 161 $paths[] = (string) $p; 168 $paths = array(); 169 170 foreach ( $entry->paths->children() as $child_path ) { 171 $paths[] = (string) $child_path; 162 172 } 163 173 … … 182 192 * prefixed with -, it'll be prefixed with 1 or 2 dashes as appropriate. 183 193 * 194 * @static 195 * @access protected 196 * 184 197 * @param array $params The array of parameters provided. 185 *186 198 * @return string The parameters formatted and escaped for CLI usage. 187 199 */ 188 200 protected static function parse_esc_parameters( $params ) { 189 201 $result = array(); 202 190 203 foreach ( $params as $key => $value ) { 191 204 $no_parameters = is_numeric( $key ); … … 193 206 $key = $value; 194 207 } 195 // Prefix options with `-` or `--` if they're longer than 2 characters 208 209 // Prefix options with `-` or `--` if they're longer than 2 characters. 196 210 if ( '-' != substr( $key, 0, 1 ) ) { 197 211 $key = '-' . ( strlen( $key ) > 2 ? '-' : '' ) . $key; … … 207 221 * Parses SVN output to detect SVN errors and throw an exception. 208 222 * 223 * @static 224 * @access protected 225 * 209 226 * @param string $output The output from SVN. 210 * 211 * @return false|array False if no errors/warnings detected in output, An array of arrays containingwarning/error_code/error_message if detected.227 * @return false|array False if no errors/warnings detected in output, An array of arrays containing 228 * warning/error_code/error_message if detected. 212 229 */ 213 230 protected static function parse_svn_errors( $output ) { 214 231 if ( preg_match_all( '!^svn: (?P<warning>warning:)?\s*(?<error_code>[EW]\d+):\s*(?P<error_message>.+)$!im', $output, $messages, PREG_SET_ORDER ) ) { 232 215 233 // We only want the string keys - strip out the numeric keys 216 $messages = array_map( function ( $item ) {234 $messages = array_map( function ( $item ) { 217 235 return array_filter( $item, 'is_string', ARRAY_FILTER_USE_KEY ); 218 236 }, $messages ); 237 219 238 return $messages; 220 239 } … … 228 247 * 229 248 * WordPress.org uses the en_US.UTF-8 locale. 249 * 250 * @static 251 * @access protected 252 * 253 * @param string $command The command to be executed. 254 * @return mixed The output from the executed command or NULL if an error occurred or the command produces no 255 * output. 230 256 */ 231 257 protected static function shell_exec( $command ) { -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/widgets/class-donate.php
r3422 r3512 36 36 37 37 <p class="aside"><?php _e( 'Would you like to support the advancement of this plugin?', 'wporg-plugins' ); ?></p> 38 <p><a class="button button-secondary" href="<?php echo esc_url( $donate_link ); ?>" rel="nofollow"><?php _e( 'Donate to this plugin', 'wporg-plugins' ); ?></a></p> 38 <p> 39 <a class="button button-secondary" href="<?php echo esc_url( $donate_link ); ?>" rel="nofollow"> 40 <?php _e( 'Donate to this plugin', 'wporg-plugins' ); ?> 41 </a> 42 </p> 39 43 40 44 <?php -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/widgets/class-ratings.php
r3426 r3512 64 64 65 65 <?php else : ?> 66 66 67 67 <div class="rating"> 68 68 <p><?php _e( 'This plugin has not been rated yet.', 'wporg-plugins' ); ?></p> … … 75 75 <a class="button button-secondary" href="<?php echo esc_url( 'https://wordpress.org/support/view/plugin-reviews/' . $post->post_name . '#postform' ); ?>"><?php _e( 'Add your review', 'wporg-plugins' ); ?></a> 76 76 </div> 77 <?php77 <?php 78 78 endif; 79 79 -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/widgets/class-support.php
r3423 r3512 59 59 <?php 60 60 /* Translators: 1: AMount of resolved threads; 2: Amount of total threads; */ 61 printf( __( '%1$s out of %2$s' ), $resolved, $threads );61 printf( __( '%1$s out of %2$s' ), $resolved, $threads ); 62 62 ?> 63 63 </span>
Note: See TracChangeset
for help on using the changeset viewer.