| [ Index ] |
PHP Cross Reference of Drupal 6 (gatewave) |
[Summary view] [Print] [Text view]
1 <?php 2 // $Id: swftools.admin.status.inc,v 1.5.2.4 2009/03/28 22:45:19 stuartgreenfield Exp $ 3 4 // The following message is used several times during iteration loops, so define it once for efficiency 5 define('SWFTOOLS_STATUS_DESCRIPTION', t('The specified player no longer appears to be available. Check the <a href="@modules">modules page</a> to ensure that the necessary module is enabled, or choose a different player on the <a href="@handling">file handling</a> page.', array('@modules' => url('admin/build/modules'), '@handling' => url('admin/settings/swftools/handling')))); 6 7 8 /** 9 * Generate a status report for SWF Tools methods / players / media defaults 10 */ 11 function swftools_status() { 12 13 // Pick up definitions for severity levels 14 include_once './includes/install.inc'; 15 16 // Begin html string to hold output 17 $html = t('<p>The following tables show the status of SWF Tools and its supporting modules. This information can help to diagnose an installation that is not working correctly. Warnings indicate an issue that may prevent SWF Tools from performing as expected but are not necessarily an immediate problem. Errors show that there is an issue that will prevent SWF Tools from working.</p>'); 18 19 // Get embedding status report 20 $html .= _swftools_status_embedding(); 21 22 // Get playback and player status report 23 $html .= _swftools_status_players(); 24 25 // Get zlib status 26 $html .= _swftools_zlib(); 27 28 // Return markup 29 return $html; 30 31 } 32 33 34 /** 35 * Generate a status report for embedding methods 36 * Called from swftools_status() and returns markup 37 */ 38 function _swftools_status_embedding() { 39 40 // Initialise requirements array 41 $requirements = array(); 42 43 // Initialise an empty array in position zero - will need this later. 44 $requirements[0] = array(); 45 46 // Get player directory 47 $player_directory = swftools_get_player_path() .'/'; 48 49 // Get list of available embedding methods 50 $methods = swftools_methods_available(SWFTOOLS_EMBED_METHOD); 51 52 // Retrieve current embedding method and initialise flag to track if we find it later 53 $current_method = variable_get(SWFTOOLS_EMBED_METHOD, SWFTOOLS_NOJAVASCRIPT); 54 $method_found = FALSE; 55 56 // Iterate through available methods 57 if (count($methods)) { 58 foreach ($methods AS $method => $info) { 59 60 // If method name is the current method then we found it, and it is available 61 if ($info['name'] == $current_method) { 62 $current_method = $info['title']; 63 $method_found = TRUE; 64 } 65 66 // If the method defines a shared file then check that it exists 67 if ($info['shared_file']) { 68 69 // If the file doesn't exist then indicate the shared file to be missing 70 if (!file_exists($player_directory . $info['shared_file'])) { 71 $requirements[] = array( 72 'title' => $info['title'], 73 'value' => t('Missing'), 74 'severity' => ($current_method == $info['title']) ? REQUIREMENT_ERROR : REQUIREMENT_WARNING, 75 'description' => t('<a href="@url">Download</a> the required supporting file and upload it to %path.', array('@url' => $info['download'], '%path' => $player_directory . $info['shared_file'])), 76 ); 77 78 // If the missing file relates to the current method set the default to a warning 79 if ($current_method == $info['title']) { 80 $requirements[0] = array( 81 'severity' => REQUIREMENT_ERROR, 82 'description' => t('The required supporting file is not available. See below for more information.'), 83 ); 84 } 85 } 86 else { 87 $requirements[] = array( 88 'title' => $info['title'], 89 'value' => t('OK'), 90 ); 91 } 92 } 93 } 94 } 95 96 // If the specified embedding method was found then set the default entry to show ok 97 if ($method_found) { 98 $requirements[0] += array( 99 'title' => t('Default method'), 100 'value' => $current_method, 101 'severity' => REQUIREMENT_OK, 102 ); 103 } 104 else { 105 $requirements[0] += array( 106 'title' => t('Default method'), 107 'value' => $current_method, 108 'severity' => REQUIREMENT_ERROR, 109 'description' => t('This method no longer appears to be available. Check the <a href="@modules">modules page</a> to ensure that the necessary module is enabled, or choose a different embedding method on the <a href="@settings">embedding settings</a> page.', array('@modules' => url('admin/build/modules'), '@settings' => url('admin/settings/swftools/embed'))), 110 ); 111 } 112 113 // Construct output string 114 $html = t('<h3>Embedding methods</h3>'); 115 $html .= t('<p>The current default and available methods are listed in the table below. A warning will be shown if the method is not ready for use, and an error will be shown if the method is not ready <em>and</em> it is currently set as the default embedding method. The default embedding method can be set on the <a href="@settings">embedding settings</a> page.</p>', array('@settings' => url('admin/settings/swftools/embed'))); 116 $html .= theme('status_report', $requirements); 117 118 // Try to generate some test content 119 $html .= _swftools_test_content($requirements[0]['severity'], $requirements[0]['value']); 120 121 return $html; 122 123 } 124 125 126 /** 127 * Generate a status report for the player modules and media defaults 128 * Called from swftools_status() and returns markup 129 */ 130 function _swftools_status_players() { 131 132 // Initialise requirements array for players and playback defaults 133 $player_requirements = array(); 134 $playback_defaults = array(); 135 136 // Get player directory 137 $player_directory = swftools_get_player_path() .'/'; 138 139 // Build an array of player methods 140 $types = array( 141 SWFTOOLS_FLV_DISPLAY => 'Single flv', 142 SWFTOOLS_FLV_DISPLAY_LIST => 'List of flvs', 143 SWFTOOLS_MP3_DISPLAY => 'Single mp3', 144 SWFTOOLS_MP3_DISPLAY_LIST => 'List of mp3s', 145 SWFTOOLS_MEDIA_DISPLAY_LIST => 'List of mixed media', 146 SWFTOOLS_SWF_DISPLAY => 'Single swf', 147 SWFTOOLS_IMAGE_DISPLAY_LIST => 'List of images', 148 ); 149 150 // Iterate each method type 151 foreach ($types as $type => $description) { 152 153 // Obtain list of players that support the given method type 154 $methods = swftools_methods_available($type); 155 156 // Get the current default player for this type and store it in the player defaults array 157 // To start with we assume it is missing, until we find the player module in a moment 158 $playback_defaults[$type] = array( 159 'title' => $types[$type], 160 'value' => swftools_get_player($type), 161 'description' => SWFTOOLS_STATUS_DESCRIPTION, 162 'severity' => REQUIREMENT_ERROR, 163 ); 164 165 // Reset 0 to text string none and clear warning - we assume playback of this type isn't required 166 if (!$playback_defaults[$type]['value']) { 167 $playback_defaults[$type]['value'] = t('None'); 168 $playback_defaults[$type]['severity'] = REQUIREMENT_OK; 169 $playback_defaults[$type]['description'] = ''; 170 } 171 172 // If methods were returned for this type 173 if (count($methods)) { 174 175 // Iterate through the available methods for this type 176 foreach ($methods as $method => $player) { 177 178 // Did we already process this player? 179 if (!isset($player_requirements[$player['title']])) { 180 181 // If this player file doesn't exist set a warning, otherwise set ok 182 if (!file_exists($player_directory . $player['shared_file'])) { 183 $player_requirements[$player['title']] = array( 184 'title' => $player['title'], 185 'value' => t('Missing'), 186 'description' => t('<a href="@url">Download</a> the required supporting file and upload it to %path.', array('@url' => $player['download'], '%path' => $player_directory . $player['shared_file'])), 187 'severity' => REQUIREMENT_WARNING, 188 ); 189 } 190 else { 191 $player_requirements[$player['title']] = array( 192 'title' => $player['title'], 193 'value' => t('OK'), 194 'severity' => REQUIREMENT_OK, 195 ); 196 } 197 } 198 199 // Is the current default method for this media type the method we currently have? 200 if ($playback_defaults[$type]['value'] == $method) { 201 202 // If yes, set name of this player as the value 203 $playback_defaults[$type]['value'] = $player['title']; 204 205 // Set the rest of the data for this player according to the status of the player file 206 if ($player_requirements[$player['title']]['severity'] == REQUIREMENT_OK) { 207 $playback_defaults[$type]['severity'] = REQUIREMENT_OK; 208 $playback_defaults[$type]['description'] = ''; 209 } 210 else { 211 $playback_defaults[$type]['severity'] = REQUIREMENT_ERROR; 212 $playback_defaults[$type]['description'] = $player_requirements[$player['title']]['description']; 213 $player_requirements[$player['title']]['severity'] = REQUIREMENT_ERROR; 214 } 215 } 216 } 217 } 218 } 219 220 // Sort list of players by name, since we used their title as the key 221 asort($player_requirements); 222 223 // Generate the output string and return it 224 $html = t('<h3>Playback defaults</h3>'); 225 $html .= t('<p>The table below shows the default methods that have been assigned to different types of media. An error indicates that a player has been specified but the supporting player file is not available, or the method cannot be found. Default playback methods can be configured on the <a href="@handling">file handling settings</a> page.</p>', array( '@handling' => url('admin/settings/swftools/handling'))); 226 $html .= theme('status_report', $playback_defaults); 227 228 $html .= t('<h3>Players</h3>'); 229 $html .= t('<p>This table shows which media players are currently enabled and ready for use. A warning is shown if the required supporting file is not available, and an error is shown if the supporting file is not available <em>and</em> the method is currently set as a playback default for any media type.</p>'); 230 $html .= theme('status_report', $player_requirements); 231 232 return $html; 233 234 } 235 236 237 function _swftools_test_content($severity, $method) { 238 239 // Generate the output string and return it 240 $html = t('<h3>Test content</h3>'); 241 242 if ($severity == REQUIREMENT_ERROR) { 243 $html .= t('<p>SWF Tools cannot currently generate test content as the chosen embedding method is not available. Refer to the table above for assistance in fixing the problem.</p>'); 244 } 245 else { 246 // Build file path to the test file 247 $file = url(drupal_get_path('module', 'swftools') .'/shared/swftools_test_file.swf', array('absolute' => TRUE)); 248 249 $html .= t('<p>SWF Tools is now trying to generate some flash content using the currrently configured embedding method (%current). If you can see an animation below then SWF Tools appears to be installed correctly.</p>', array('%current' => $method)); 250 $html .= swf($file, array('params' => array ('height' => 150, 'width' => 150))); 251 $html .= t('<p> If the animation does not appear then check that your browser has the necessary Flash plug-in, and that JavaScript is enabled (if required). Also try clearing your browser\'s cache.</p>'); 252 } 253 254 return $html; 255 } 256 257 /** 258 * Check for presence of the zlib library 259 * 260 * @return 261 * Markup string for inclusion in report 262 */ 263 function _swftools_zlib() { 264 265 $has_zlib = extension_loaded('zlib'); 266 267 $requirements['swftools'] = array( 268 'title' => t('Zlib library'), 269 'description' => '', 270 'value' => $has_zlib ? t('Enabled') : t('Not installed'), 271 'severity' => $has_zlib ? REQUIREMENT_OK : REQUIREMENT_WARNING, 272 ); 273 274 // Generate the output string and return it 275 $html = t('<h3>Zlib library</h3>'); 276 $html .= t('<p>SWF Tools requires the <a href="@url">zlib library</a> in order to automatically determine the dimensions of compressed swf files. If this library is not installed then SWF Tools will work but you may have to specify the size of swf content when it is produced, otherwise the content may not appear in some browsers.</p>', array('@url' => 'http://www.php.net/zlib')); 277 $html .= theme('status_report', $requirements); 278 279 return $html; 280 281 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Thu Mar 24 11:18:33 2011 | Cross-referenced by PHPXref 0.7 |