@@ -8,7 +8,8 @@ |
||
| 8 | 8 | <div class="sectionBody"> |
| 9 | 9 | <?php |
| 10 | 10 | $changeLog = MODX_BASE_PATH . 'assets/docs/changelog.txt'; |
| 11 | - if(is_readable($changeLog)) |
|
| 12 | - echo str_replace("\n",'<br>',file_get_contents($changeLog)); |
|
| 13 | -?> |
|
| 11 | + if(is_readable($changeLog)) { |
|
| 12 | + echo str_replace("\n",'<br>',file_get_contents($changeLog)); |
|
| 13 | + } |
|
| 14 | + ?> |
|
| 14 | 15 | </div> |
@@ -1,8 +1,8 @@ |
||
| 1 | 1 | <?php |
| 2 | -if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
|
|
| 2 | +if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
| 3 | 3 | die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
|
| 4 | 4 | } |
| 5 | -if(!$modx->hasPermission('change_password')) {
|
|
| 5 | +if(!$modx->hasPermission('change_password')) { |
|
| 6 | 6 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
| 7 | 7 | } |
| 8 | 8 | ?> |
@@ -6,26 +6,22 @@ discard block |
||
| 6 | 6 | die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
| 7 | 7 | } |
| 8 | 8 | |
| 9 | -if( isset( $_REQUEST[$cm->get('request_key')]['ajax'] ) ) |
|
| 10 | -{ |
|
| 9 | +if( isset( $_REQUEST[$cm->get('request_key')]['ajax'] ) ) { |
|
| 11 | 10 | $_data = $_REQUEST[$cm->get('request_key')]; |
| 12 | 11 | $output = ''; |
| 13 | 12 | $task = $_data['task']; |
| 14 | - switch( $task ) |
|
| 15 | - { |
|
| 13 | + switch( $task ) { |
|
| 16 | 14 | /** |
| 17 | 15 | * get categories |
| 18 | 16 | */ |
| 19 | 17 | case 'categorize_load_elements': |
| 20 | 18 | $elements = $_data['elements']; |
| 21 | 19 | |
| 22 | - if( $uncategorized_elements = $cm->getAssignedElements( 0, $_data['elements'] ) ) |
|
| 23 | - { |
|
| 20 | + if( $uncategorized_elements = $cm->getAssignedElements( 0, $_data['elements'] ) ) { |
|
| 24 | 21 | $output .= $cm->renderView('chunks/categorize/uncategorized_elements', $uncategorized_elements); |
| 25 | 22 | } |
| 26 | 23 | |
| 27 | - foreach( $cm->getCategories() as $category ) |
|
| 28 | - { |
|
| 24 | + foreach( $cm->getCategories() as $category ) { |
|
| 29 | 25 | $category['elements'] = $cm->getAssignedElements( $category['id'], $_data['elements'] ); |
| 30 | 26 | $output .= $cm->renderView('chunks/categorize/category', $category); |
| 31 | 27 | } |
@@ -41,8 +37,7 @@ discard block |
||
| 41 | 37 | * @see http://modxcms.com/forums/index.php/topic,40430.msg251476.html#msg251476 |
| 42 | 38 | * |
| 43 | 39 | */ |
| 44 | -if( isset( $_POST[$cm->get('request_key')]['categorize']['submit'] ) ) |
|
| 45 | -{ |
|
| 40 | +if( isset( $_POST[$cm->get('request_key')]['categorize']['submit'] ) ) { |
|
| 46 | 41 | $_data = $_POST[$cm->get('request_key')]['categorize']; |
| 47 | 42 | $_changes = 0; |
| 48 | 43 | |
@@ -54,16 +49,13 @@ discard block |
||
| 54 | 49 | 'categorize' |
| 55 | 50 | ); |
| 56 | 51 | |
| 57 | - if( !isset( $_data['elements'] ) ) |
|
| 58 | - { |
|
| 52 | + if( !isset( $_data['elements'] ) ) { |
|
| 59 | 53 | $cm->addMessage( $cm->txt('cm_unknown_error'), 'categorize' ); |
| 60 | 54 | return; |
| 61 | 55 | } |
| 62 | 56 | |
| 63 | - foreach( $_data['elements'] as $element_id => $data ) |
|
| 64 | - { |
|
| 65 | - if( $cm->updateElement( $_data['elementsgroup'], $element_id, $data['category_id'] ) ) |
|
| 66 | - { |
|
| 57 | + foreach( $_data['elements'] as $element_id => $data ) { |
|
| 58 | + if( $cm->updateElement( $_data['elementsgroup'], $element_id, $data['category_id'] ) ) { |
|
| 67 | 59 | $cm->addMessage( |
| 68 | 60 | sprintf( |
| 69 | 61 | $cm->txt('cm_x_assigned_to_category_y'), |
@@ -78,13 +70,10 @@ discard block |
||
| 78 | 70 | } |
| 79 | 71 | } |
| 80 | 72 | |
| 81 | - if( $_changes === 0 ) |
|
| 82 | - { |
|
| 73 | + if( $_changes === 0 ) { |
|
| 83 | 74 | $cm->addMessage( $cm->txt('cm_no_categorization'), 'categorize' ); |
| 84 | 75 | return; |
| 85 | - } |
|
| 86 | - else |
|
| 87 | - { |
|
| 76 | + } else { |
|
| 88 | 77 | $cm->addMessage( |
| 89 | 78 | sprintf( |
| 90 | 79 | $cm->txt('cm_x_changes_made'), |
@@ -98,26 +87,22 @@ discard block |
||
| 98 | 87 | /** |
| 99 | 88 | * Add a new category |
| 100 | 89 | */ |
| 101 | -if( isset( $_POST[$cm->get('request_key')]['add']['submit'] ) ) |
|
| 102 | -{ |
|
| 90 | +if( isset( $_POST[$cm->get('request_key')]['add']['submit'] ) ) { |
|
| 103 | 91 | $_data = $_POST[$cm->get('request_key')]['add']['data']; |
| 104 | 92 | $category = trim( html_entity_decode($_data['name']) ); |
| 105 | 93 | $rank = (int) $_data['rank']; |
| 106 | 94 | |
| 107 | - if( empty( $category ) ) |
|
| 108 | - { |
|
| 95 | + if( empty( $category ) ) { |
|
| 109 | 96 | $cm->addMessage( $cm->txt('cm_enter_name_for_category'), 'add' ); |
| 110 | 97 | return; |
| 111 | 98 | } |
| 112 | 99 | |
| 113 | - if( $cm->isCategoryExists( $category ) ) |
|
| 114 | - { |
|
| 100 | + if( $cm->isCategoryExists( $category ) ) { |
|
| 115 | 101 | $cm->addMessage( sprintf( $cm->txt('cm_category_x_exists'), $category ), 'add' ); |
| 116 | 102 | return; |
| 117 | 103 | } |
| 118 | 104 | |
| 119 | - if( $cm->addCategory( $category, $rank ) !== 0 ) |
|
| 120 | - { |
|
| 105 | + if( $cm->addCategory( $category, $rank ) !== 0 ) { |
|
| 121 | 106 | $cm->addMessage( |
| 122 | 107 | sprintf( |
| 123 | 108 | $cm->txt( 'cm_category_x_saved_at_position_y' ), |
@@ -126,9 +111,7 @@ discard block |
||
| 126 | 111 | ), |
| 127 | 112 | 'add' |
| 128 | 113 | ); |
| 129 | - } |
|
| 130 | - else |
|
| 131 | - { |
|
| 114 | + } else { |
|
| 132 | 115 | $cm->addMessage( $cm->txt('cm_unknown_error'), 'add' ); |
| 133 | 116 | } |
| 134 | 117 | } |
@@ -136,20 +119,17 @@ discard block |
||
| 136 | 119 | /** |
| 137 | 120 | * Sort categories |
| 138 | 121 | */ |
| 139 | -if( isset( $_POST[$cm->get('request_key')]['sort']['submit'] ) ) |
|
| 140 | -{ |
|
| 122 | +if( isset( $_POST[$cm->get('request_key')]['sort']['submit'] ) ) { |
|
| 141 | 123 | $categories = $_POST[$cm->get('request_key')]['sort']['data']; |
| 142 | 124 | $_changes = 0; |
| 143 | 125 | |
| 144 | - foreach( $categories as $category_id => $_data ) |
|
| 145 | - { |
|
| 126 | + foreach( $categories as $category_id => $_data ) { |
|
| 146 | 127 | $data = array( |
| 147 | 128 | 'category' => urldecode( $_data['category'] ), |
| 148 | 129 | 'rank' => $_data['rank'] |
| 149 | 130 | ); |
| 150 | 131 | |
| 151 | - if( $cm->updateCategory( $category_id, $data ) ) |
|
| 152 | - { |
|
| 132 | + if( $cm->updateCategory( $category_id, $data ) ) { |
|
| 153 | 133 | $cm->addMessage( |
| 154 | 134 | sprintf( |
| 155 | 135 | $cm->txt('cm_category_x_moved_to_position_y'), |
@@ -162,12 +142,9 @@ discard block |
||
| 162 | 142 | } |
| 163 | 143 | } |
| 164 | 144 | |
| 165 | - if( $_changes === 0 ) |
|
| 166 | - { |
|
| 145 | + if( $_changes === 0 ) { |
|
| 167 | 146 | $cm->addMessage( $cm->txt( 'cm_no_changes' ), 'sort'); |
| 168 | - } |
|
| 169 | - else |
|
| 170 | - { |
|
| 147 | + } else { |
|
| 171 | 148 | $cm->addMessage( |
| 172 | 149 | sprintf( |
| 173 | 150 | $cm->txt('cm_x_changes_made'), |
@@ -181,17 +158,13 @@ discard block |
||
| 181 | 158 | /** |
| 182 | 159 | * Edit categories |
| 183 | 160 | */ |
| 184 | -if( isset( $_POST[$cm->get('request_key')]['edit']['submit'] ) ) |
|
| 185 | -{ |
|
| 161 | +if( isset( $_POST[$cm->get('request_key')]['edit']['submit'] ) ) { |
|
| 186 | 162 | $categories = $_POST[$cm->get('request_key')]['edit']['data']; |
| 187 | 163 | $_changes = 0; |
| 188 | 164 | |
| 189 | - foreach( $categories as $category_id => $_data ) |
|
| 190 | - { |
|
| 191 | - if( isset( $_data['delete'] ) ) |
|
| 192 | - { |
|
| 193 | - if( $cm->deleteCategory( $category_id ) ) |
|
| 194 | - { |
|
| 165 | + foreach( $categories as $category_id => $_data ) { |
|
| 166 | + if( isset( $_data['delete'] ) ) { |
|
| 167 | + if( $cm->deleteCategory( $category_id ) ) { |
|
| 195 | 168 | $cm->addMessage( |
| 196 | 169 | sprintf( |
| 197 | 170 | $cm->txt('cm_category_x_deleted'), |
@@ -209,8 +182,7 @@ discard block |
||
| 209 | 182 | 'rank' => $_data['rank'] |
| 210 | 183 | ); |
| 211 | 184 | |
| 212 | - if( $cm->updateCategory( $category_id, $data ) ) |
|
| 213 | - { |
|
| 185 | + if( $cm->updateCategory( $category_id, $data ) ) { |
|
| 214 | 186 | $cm->addMessage( |
| 215 | 187 | sprintf( |
| 216 | 188 | $cm->txt('cm_category_x_renamed_to_y'), |
@@ -223,8 +195,7 @@ discard block |
||
| 223 | 195 | } |
| 224 | 196 | } |
| 225 | 197 | |
| 226 | - if( $_changes === 0 ) |
|
| 227 | - { |
|
| 198 | + if( $_changes === 0 ) { |
|
| 228 | 199 | $cm->addMessage( $cm->txt( 'cm_no_changes' ), 'edit'); |
| 229 | 200 | } |
| 230 | 201 | } |
@@ -233,12 +204,10 @@ discard block |
||
| 233 | 204 | * Delete singel category by $_GET |
| 234 | 205 | */ |
| 235 | 206 | if( isset( $_GET[$cm->get('request_key')]['delete'] ) |
| 236 | - && !empty( $_GET[$cm->get('request_key')]['delete'] ) ) |
|
| 237 | -{ |
|
| 207 | + && !empty( $_GET[$cm->get('request_key')]['delete'] ) ) { |
|
| 238 | 208 | $category_id = (int)$_GET[$cm->get('request_key')]['delete']; |
| 239 | 209 | |
| 240 | - if( $cm->deleteCategory( $category_id ) ) |
|
| 241 | - { |
|
| 210 | + if( $cm->deleteCategory( $category_id ) ) { |
|
| 242 | 211 | $cm->addMessage( |
| 243 | 212 | sprintf( |
| 244 | 213 | $cm->txt('cm_category_x_deleted'), |
@@ -251,16 +220,13 @@ discard block |
||
| 251 | 220 | /** |
| 252 | 221 | * Translate phrases |
| 253 | 222 | */ |
| 254 | -if( isset( $_POST[$cm->get('request_key')]['translate']['submit'] ) ) |
|
| 255 | -{ |
|
| 223 | +if( isset( $_POST[$cm->get('request_key')]['translate']['submit'] ) ) { |
|
| 256 | 224 | $translations = $_POST[$cm->get('request_key')]['translate']['data']; |
| 257 | 225 | |
| 258 | - foreach( $translations as $native_phrase => $translation ) |
|
| 259 | - { |
|
| 226 | + foreach( $translations as $native_phrase => $translation ) { |
|
| 260 | 227 | $native_phrase = urldecode( $native_phrase ); |
| 261 | 228 | |
| 262 | - if( empty( $translation ) ) |
|
| 263 | - { |
|
| 229 | + if( empty( $translation ) ) { |
|
| 264 | 230 | $translation = $native_phrase; |
| 265 | 231 | |
| 266 | 232 | $cm->addMessage( |
@@ -117,7 +117,7 @@ |
||
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | // secure web documents - flag as private |
| 120 | -if($updategroupaccess==true){ |
|
| 120 | +if($updategroupaccess==true) { |
|
| 121 | 121 | include MODX_MANAGER_PATH."includes/secure_web_documents.inc.php"; |
| 122 | 122 | secureWebDocument(); |
| 123 | 123 | |
@@ -25,7 +25,10 @@ |
||
| 25 | 25 | |
| 26 | 26 | $id = $row['id']; |
| 27 | 27 | |
| 28 | - if(in_array($id,$latestIds)) continue; // Keep latest version of disabled plugins |
|
| 28 | + if(in_array($id,$latestIds)) { |
|
| 29 | + continue; |
|
| 30 | + } |
|
| 31 | + // Keep latest version of disabled plugins |
|
| 29 | 32 | |
| 30 | 33 | // invoke OnBeforePluginFormDelete event |
| 31 | 34 | $modx->invokeEvent('OnBeforePluginFormDelete', array('id'=> $id)); |
@@ -10,11 +10,11 @@ |
||
| 10 | 10 | $pass1 = $_POST['pass1']; |
| 11 | 11 | $pass2 = $_POST['pass2']; |
| 12 | 12 | |
| 13 | -if($pass1!=$pass2){ |
|
| 13 | +if($pass1!=$pass2) { |
|
| 14 | 14 | $modx->webAlertAndQuit("Passwords don't match!"); |
| 15 | 15 | } |
| 16 | 16 | |
| 17 | -if(strlen($pass1)<6){ |
|
| 17 | +if(strlen($pass1)<6) { |
|
| 18 | 18 | $modx->webAlertAndQuit("Password is too short. Please specify a password of at least 6 characters."); |
| 19 | 19 | } |
| 20 | 20 | |
@@ -119,7 +119,7 @@ |
||
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | // secure manager documents - flag as private |
| 122 | -if($updategroupaccess==true){ |
|
| 122 | +if($updategroupaccess==true) { |
|
| 123 | 123 | include MODX_MANAGER_PATH."includes/secure_mgr_documents.inc.php"; |
| 124 | 124 | secureMgrDocument(); |
| 125 | 125 | |
@@ -61,9 +61,13 @@ discard block |
||
| 61 | 61 | $mgr_dir = substr($self_dir,strrpos($self_dir,'/')+1); |
| 62 | 62 | $base_path = str_replace($mgr_dir . '/index.php','',$self); |
| 63 | 63 | $site_mgr_path = $base_path . 'assets/cache/siteManager.php'; |
| 64 | -if(is_file($site_mgr_path)) include_once($site_mgr_path); |
|
| 64 | +if(is_file($site_mgr_path)) { |
|
| 65 | + include_once($site_mgr_path); |
|
| 66 | +} |
|
| 65 | 67 | $site_hostnames_path = $base_path . 'assets/cache/siteHostnames.php'; |
| 66 | -if(is_file($site_hostnames_path)) include_once($site_hostnames_path); |
|
| 68 | +if(is_file($site_hostnames_path)) { |
|
| 69 | + include_once($site_hostnames_path); |
|
| 70 | +} |
|
| 67 | 71 | if(!defined('MGR_DIR') || MGR_DIR!==$mgr_dir) { |
| 68 | 72 | $src = "<?php\n"; |
| 69 | 73 | $src .= "define('MGR_DIR', '{$mgr_dir}');\n"; |
@@ -117,9 +121,15 @@ discard block |
||
| 117 | 121 | $incPath = str_replace("\\","/",dirname(__FILE__)."/includes/"); // Mod by Raymond |
| 118 | 122 | set_include_path(get_include_path() . PATH_SEPARATOR . $incPath); |
| 119 | 123 | |
| 120 | -if (!defined('ENT_COMPAT')) define('ENT_COMPAT', 2); |
|
| 121 | -if (!defined('ENT_NOQUOTES')) define('ENT_NOQUOTES', 0); |
|
| 122 | -if (!defined('ENT_QUOTES')) define('ENT_QUOTES', 3); |
|
| 124 | +if (!defined('ENT_COMPAT')) { |
|
| 125 | + define('ENT_COMPAT', 2); |
|
| 126 | +} |
|
| 127 | +if (!defined('ENT_NOQUOTES')) { |
|
| 128 | + define('ENT_NOQUOTES', 0); |
|
| 129 | +} |
|
| 130 | +if (!defined('ENT_QUOTES')) { |
|
| 131 | + define('ENT_QUOTES', 3); |
|
| 132 | +} |
|
| 123 | 133 | |
| 124 | 134 | // set the document_root :| |
| 125 | 135 | if(!isset($_SERVER['DOCUMENT_ROOT']) || empty($_SERVER['DOCUMENT_ROOT'])) { |
@@ -182,10 +192,11 @@ discard block |
||
| 182 | 192 | |
| 183 | 193 | $s = array('[+MGR_DIR+]'); |
| 184 | 194 | $r = array(MGR_DIR); |
| 185 | -foreach($_lang as $k=>$v) |
|
| 186 | -{ |
|
| 187 | - if(strpos($v,'[+')!==false) $_lang[$k] = str_replace($s, $r, $v); |
|
| 188 | -} |
|
| 195 | +foreach($_lang as $k=>$v) { |
|
| 196 | + if(strpos($v,'[+')!==false) { |
|
| 197 | + $_lang[$k] = str_replace($s, $r, $v); |
|
| 198 | + } |
|
| 199 | + } |
|
| 189 | 200 | |
| 190 | 201 | // send the charset header |
| 191 | 202 | header('Content-Type: text/html; charset='.$modx_manager_charset); |
@@ -198,7 +209,7 @@ discard block |
||
| 198 | 209 | include_once "accesscontrol.inc.php"; |
| 199 | 210 | |
| 200 | 211 | // double check the session |
| 201 | -if(!isset($_SESSION['mgrValidated'])){ |
|
| 212 | +if(!isset($_SESSION['mgrValidated'])) { |
|
| 202 | 213 | echo "Not Logged In!"; |
| 203 | 214 | exit; |
| 204 | 215 | } |
@@ -215,7 +226,9 @@ discard block |
||
| 215 | 226 | } |
| 216 | 227 | |
| 217 | 228 | // Initialize System Alert Message Queque |
| 218 | -if (!isset($_SESSION['SystemAlertMsgQueque'])) $_SESSION['SystemAlertMsgQueque'] = array(); |
|
| 229 | +if (!isset($_SESSION['SystemAlertMsgQueque'])) { |
|
| 230 | + $_SESSION['SystemAlertMsgQueque'] = array(); |
|
| 231 | +} |
|
| 219 | 232 | $SystemAlertMsgQueque = &$_SESSION['SystemAlertMsgQueque']; |
| 220 | 233 | |
| 221 | 234 | // first we check to see if this is a frameset request |
@@ -223,7 +236,7 @@ discard block |
||
| 223 | 236 | // this looks to be a top-level frameset request, so let's serve up a frameset |
| 224 | 237 | if(is_file(MODX_MANAGER_PATH."media/style/".$manager_theme."/frames/1.php")) { |
| 225 | 238 | include_once "media/style/".$manager_theme."/frames/1.php"; |
| 226 | - }else{ |
|
| 239 | + } else { |
|
| 227 | 240 | include_once "frames/1.php"; |
| 228 | 241 | } |
| 229 | 242 | exit; |
@@ -231,10 +244,15 @@ discard block |
||
| 231 | 244 | |
| 232 | 245 | // OK, let's retrieve the action directive from the request |
| 233 | 246 | $option = array('min_range'=>1,'max_range'=>2000); |
| 234 | -if(isset($_GET['a']) && isset($_POST['a'])) $modx->webAlertAndQuit($_lang['error_double_action']); |
|
| 235 | -elseif(isset($_GET['a'])) $action = filter_input(INPUT_GET, 'a',FILTER_VALIDATE_INT,$option); |
|
| 236 | -elseif(isset($_POST['a'])) $action = filter_input(INPUT_POST,'a',FILTER_VALIDATE_INT,$option); |
|
| 237 | -else $action = null; |
|
| 247 | +if(isset($_GET['a']) && isset($_POST['a'])) { |
|
| 248 | + $modx->webAlertAndQuit($_lang['error_double_action']); |
|
| 249 | +} elseif(isset($_GET['a'])) { |
|
| 250 | + $action = filter_input(INPUT_GET, 'a',FILTER_VALIDATE_INT,$option); |
|
| 251 | +} elseif(isset($_POST['a'])) { |
|
| 252 | + $action = filter_input(INPUT_POST,'a',FILTER_VALIDATE_INT,$option); |
|
| 253 | +} else { |
|
| 254 | + $action = null; |
|
| 255 | +} |
|
| 238 | 256 | |
| 239 | 257 | if (isset($_POST['updateMsgCount']) && $modx->hasPermission('messages')) { |
| 240 | 258 | include_once 'messageCount.inc.php'; |
@@ -264,11 +282,12 @@ discard block |
||
| 264 | 282 | $modx->invokeEvent("OnManagerPageInit", array("action" => $action)); |
| 265 | 283 | |
| 266 | 284 | // return element filepath |
| 267 | -function includeFileProcessor ($filepath,$manager_theme) { |
|
| 285 | +function includeFileProcessor ($filepath,$manager_theme) |
|
| 286 | +{ |
|
| 268 | 287 | $element = ""; |
| 269 | 288 | if(is_file(MODX_MANAGER_PATH."media/style/".$manager_theme."/".$filepath)) { |
| 270 | 289 | $element = MODX_MANAGER_PATH."media/style/".$manager_theme."/".$filepath; |
| 271 | - }else{ |
|
| 290 | + } else { |
|
| 272 | 291 | $element = $filepath; |
| 273 | 292 | } |
| 274 | 293 | return $element; |
@@ -31,7 +31,8 @@ discard block |
||
| 31 | 31 | * see: rss_fetch.inc for a simpler interface with integrated caching support |
| 32 | 32 | * |
| 33 | 33 | */ |
| 34 | -class MagpieRSS { |
|
| 34 | +class MagpieRSS |
|
| 35 | +{ |
|
| 35 | 36 | var $parser; |
| 36 | 37 | |
| 37 | 38 | var $current_item = array(); // item currently being parsed |
@@ -143,7 +144,8 @@ discard block |
||
| 143 | 144 | $this->normalize(); |
| 144 | 145 | } |
| 145 | 146 | |
| 146 | - function feed_start_element($p, $element, &$attrs) { |
|
| 147 | + function feed_start_element($p, $element, &$attrs) |
|
| 148 | + { |
|
| 147 | 149 | $el = $element = strtolower($element); |
| 148 | 150 | $attrs = array_change_key_case($attrs, CASE_LOWER); |
| 149 | 151 | |
@@ -163,12 +165,10 @@ discard block |
||
| 163 | 165 | if ( $el == 'rdf' ) { |
| 164 | 166 | $this->feed_type = RSS; |
| 165 | 167 | $this->feed_version = '1.0'; |
| 166 | - } |
|
| 167 | - elseif ( $el == 'rss' ) { |
|
| 168 | + } elseif ( $el == 'rss' ) { |
|
| 168 | 169 | $this->feed_type = RSS; |
| 169 | 170 | $this->feed_version = $attrs['version']; |
| 170 | - } |
|
| 171 | - elseif ( $el == 'feed' ) { |
|
| 171 | + } elseif ( $el == 'feed' ) { |
|
| 172 | 172 | $this->feed_type = ATOM; |
| 173 | 173 | $this->feed_version = $attrs['version']; |
| 174 | 174 | $this->inchannel = true; |
@@ -176,12 +176,9 @@ discard block |
||
| 176 | 176 | return; |
| 177 | 177 | } |
| 178 | 178 | |
| 179 | - if ( $el == 'channel' ) |
|
| 180 | - { |
|
| 179 | + if ( $el == 'channel' ) { |
|
| 181 | 180 | $this->inchannel = true; |
| 182 | - } |
|
| 183 | - elseif ($el == 'item' or $el == 'entry' ) |
|
| 184 | - { |
|
| 181 | + } elseif ($el == 'item' or $el == 'entry' ) { |
|
| 185 | 182 | $this->initem = true; |
| 186 | 183 | if ( isset($attrs['rdf:about']) ) { |
| 187 | 184 | $this->current_item['about'] = $attrs['rdf:about']; |
@@ -193,22 +190,17 @@ discard block |
||
| 193 | 190 | elseif ( |
| 194 | 191 | $this->feed_type == RSS and |
| 195 | 192 | $this->current_namespace == '' and |
| 196 | - $el == 'textinput' ) |
|
| 197 | - { |
|
| 193 | + $el == 'textinput' ) { |
|
| 198 | 194 | $this->intextinput = true; |
| 199 | - } |
|
| 200 | - |
|
| 201 | - elseif ( |
|
| 195 | + } elseif ( |
|
| 202 | 196 | $this->feed_type == RSS and |
| 203 | 197 | $this->current_namespace == '' and |
| 204 | - $el == 'image' ) |
|
| 205 | - { |
|
| 198 | + $el == 'image' ) { |
|
| 206 | 199 | $this->inimage = true; |
| 207 | 200 | } |
| 208 | 201 | |
| 209 | 202 | # handle atom content constructs |
| 210 | - elseif ( $this->feed_type == ATOM and in_array($el, $this->_CONTENT_CONSTRUCTS) ) |
|
| 211 | - { |
|
| 203 | + elseif ( $this->feed_type == ATOM and in_array($el, $this->_CONTENT_CONSTRUCTS) ) { |
|
| 212 | 204 | // avoid clashing w/ RSS mod_content |
| 213 | 205 | if ($el == 'content' ) { |
| 214 | 206 | $el = 'atom_content'; |
@@ -220,8 +212,7 @@ discard block |
||
| 220 | 212 | } |
| 221 | 213 | |
| 222 | 214 | // if inside an Atom content construct (e.g. content or summary) field treat tags as text |
| 223 | - elseif ($this->feed_type == ATOM and $this->incontent ) |
|
| 224 | - { |
|
| 215 | + elseif ($this->feed_type == ATOM and $this->incontent ) { |
|
| 225 | 216 | // if tags are inlined, then flatten |
| 226 | 217 | $attrs_str = implode(' ', |
| 227 | 218 | array_map('map_attrs', |
@@ -237,13 +228,10 @@ discard block |
||
| 237 | 228 | // Magpie treats link elements of type rel='alternate' |
| 238 | 229 | // as being equivalent to RSS's simple link element. |
| 239 | 230 | // |
| 240 | - elseif ($this->feed_type == ATOM and $el == 'link' ) |
|
| 241 | - { |
|
| 242 | - if ( isset($attrs['rel']) and $attrs['rel'] == 'alternate' ) |
|
| 243 | - { |
|
| 231 | + elseif ($this->feed_type == ATOM and $el == 'link' ) { |
|
| 232 | + if ( isset($attrs['rel']) and $attrs['rel'] == 'alternate' ) { |
|
| 244 | 233 | $link_el = 'link'; |
| 245 | - } |
|
| 246 | - else { |
|
| 234 | + } else { |
|
| 247 | 235 | $link_el = 'link_' . $attrs['rel']; |
| 248 | 236 | } |
| 249 | 237 | |
@@ -257,63 +245,51 @@ discard block |
||
| 257 | 245 | |
| 258 | 246 | |
| 259 | 247 | |
| 260 | - function feed_cdata ($p, $text) { |
|
| 261 | - if ($this->feed_type == ATOM and $this->incontent) |
|
| 262 | - { |
|
| 248 | + function feed_cdata ($p, $text) |
|
| 249 | + { |
|
| 250 | + if ($this->feed_type == ATOM and $this->incontent) { |
|
| 263 | 251 | $this->append_content( $text ); |
| 264 | - } |
|
| 265 | - else { |
|
| 252 | + } else { |
|
| 266 | 253 | $current_el = implode('_', array_reverse($this->stack)); |
| 267 | 254 | $this->append($current_el, $text); |
| 268 | 255 | } |
| 269 | 256 | } |
| 270 | 257 | |
| 271 | - function feed_end_element ($p, $el) { |
|
| 258 | + function feed_end_element ($p, $el) |
|
| 259 | + { |
|
| 272 | 260 | $el = strtolower($el); |
| 273 | 261 | |
| 274 | - if ( $el == 'item' or $el == 'entry' ) |
|
| 275 | - { |
|
| 262 | + if ( $el == 'item' or $el == 'entry' ) { |
|
| 276 | 263 | $this->items[] = $this->current_item; |
| 277 | 264 | $this->current_item = array(); |
| 278 | 265 | $this->initem = false; |
| 279 | - } |
|
| 280 | - elseif ($this->feed_type == RSS and $this->current_namespace == '' and $el == 'textinput' ) |
|
| 281 | - { |
|
| 266 | + } elseif ($this->feed_type == RSS and $this->current_namespace == '' and $el == 'textinput' ) { |
|
| 282 | 267 | $this->intextinput = false; |
| 283 | - } |
|
| 284 | - elseif ($this->feed_type == RSS and $this->current_namespace == '' and $el == 'image' ) |
|
| 285 | - { |
|
| 268 | + } elseif ($this->feed_type == RSS and $this->current_namespace == '' and $el == 'image' ) { |
|
| 286 | 269 | $this->inimage = false; |
| 287 | - } |
|
| 288 | - elseif ($this->feed_type == ATOM and in_array($el, $this->_CONTENT_CONSTRUCTS) ) |
|
| 289 | - { |
|
| 270 | + } elseif ($this->feed_type == ATOM and in_array($el, $this->_CONTENT_CONSTRUCTS) ) { |
|
| 290 | 271 | $this->incontent = false; |
| 291 | - } |
|
| 292 | - elseif ($el == 'channel' or $el == 'feed' ) |
|
| 293 | - { |
|
| 272 | + } elseif ($el == 'channel' or $el == 'feed' ) { |
|
| 294 | 273 | $this->inchannel = false; |
| 295 | - } |
|
| 296 | - elseif ($this->feed_type == ATOM and $this->incontent ) { |
|
| 274 | + } elseif ($this->feed_type == ATOM and $this->incontent ) { |
|
| 297 | 275 | // balance tags properly |
| 298 | 276 | // note: i don't think this is actually neccessary |
| 299 | - if ( $this->stack[0] == $el ) |
|
| 300 | - { |
|
| 277 | + if ( $this->stack[0] == $el ) { |
|
| 301 | 278 | $this->append_content("</$el>"); |
| 302 | - } |
|
| 303 | - else { |
|
| 279 | + } else { |
|
| 304 | 280 | $this->append_content("<$el />"); |
| 305 | 281 | } |
| 306 | 282 | |
| 307 | 283 | array_shift( $this->stack ); |
| 308 | - } |
|
| 309 | - else { |
|
| 284 | + } else { |
|
| 310 | 285 | array_shift( $this->stack ); |
| 311 | 286 | } |
| 312 | 287 | |
| 313 | 288 | $this->current_namespace = false; |
| 314 | 289 | } |
| 315 | 290 | |
| 316 | - function concat (&$str1, $str2="") { |
|
| 291 | + function concat (&$str1, $str2="") |
|
| 292 | + { |
|
| 317 | 293 | if (!isset($str1) ) { |
| 318 | 294 | $str1=""; |
| 319 | 295 | } |
@@ -322,53 +298,46 @@ discard block |
||
| 322 | 298 | |
| 323 | 299 | |
| 324 | 300 | |
| 325 | - function append_content($text) { |
|
| 301 | + function append_content($text) |
|
| 302 | + { |
|
| 326 | 303 | if ( $this->initem ) { |
| 327 | 304 | $this->concat( $this->current_item[ $this->incontent ], $text ); |
| 328 | - } |
|
| 329 | - elseif ( $this->inchannel ) { |
|
| 305 | + } elseif ( $this->inchannel ) { |
|
| 330 | 306 | $this->concat( $this->channel[ $this->incontent ], $text ); |
| 331 | 307 | } |
| 332 | 308 | } |
| 333 | 309 | |
| 334 | 310 | // smart append - field and namespace aware |
| 335 | - function append($el, $text) { |
|
| 311 | + function append($el, $text) |
|
| 312 | + { |
|
| 336 | 313 | if (!$el) { |
| 337 | 314 | return; |
| 338 | 315 | } |
| 339 | - if ( $this->current_namespace ) |
|
| 340 | - { |
|
| 316 | + if ( $this->current_namespace ) { |
|
| 341 | 317 | if ( $this->initem ) { |
| 342 | 318 | $this->concat( |
| 343 | 319 | $this->current_item[ $this->current_namespace ][ $el ], $text); |
| 344 | - } |
|
| 345 | - elseif ($this->inchannel) { |
|
| 320 | + } elseif ($this->inchannel) { |
|
| 346 | 321 | $this->concat( |
| 347 | 322 | $this->channel[ $this->current_namespace][ $el ], $text ); |
| 348 | - } |
|
| 349 | - elseif ($this->intextinput) { |
|
| 323 | + } elseif ($this->intextinput) { |
|
| 350 | 324 | $this->concat( |
| 351 | 325 | $this->textinput[ $this->current_namespace][ $el ], $text ); |
| 352 | - } |
|
| 353 | - elseif ($this->inimage) { |
|
| 326 | + } elseif ($this->inimage) { |
|
| 354 | 327 | $this->concat( |
| 355 | 328 | $this->image[ $this->current_namespace ][ $el ], $text ); |
| 356 | 329 | } |
| 357 | - } |
|
| 358 | - else { |
|
| 330 | + } else { |
|
| 359 | 331 | if ( $this->initem ) { |
| 360 | 332 | $this->concat( |
| 361 | 333 | $this->current_item[ $el ], $text); |
| 362 | - } |
|
| 363 | - elseif ($this->intextinput) { |
|
| 334 | + } elseif ($this->intextinput) { |
|
| 364 | 335 | $this->concat( |
| 365 | 336 | $this->textinput[ $el ], $text ); |
| 366 | - } |
|
| 367 | - elseif ($this->inimage) { |
|
| 337 | + } elseif ($this->inimage) { |
|
| 368 | 338 | $this->concat( |
| 369 | 339 | $this->image[ $el ], $text ); |
| 370 | - } |
|
| 371 | - elseif ($this->inchannel) { |
|
| 340 | + } elseif ($this->inchannel) { |
|
| 372 | 341 | $this->concat( |
| 373 | 342 | $this->channel[ $el ], $text ); |
| 374 | 343 | } |
@@ -376,16 +345,19 @@ discard block |
||
| 376 | 345 | } |
| 377 | 346 | } |
| 378 | 347 | |
| 379 | - function normalize () { |
|
| 348 | + function normalize () |
|
| 349 | + { |
|
| 380 | 350 | // if atom populate rss fields |
| 381 | 351 | if ( $this->is_atom() ) { |
| 382 | 352 | $this->channel['description'] = $this->channel['tagline']; |
| 383 | 353 | for ( $i = 0; $i < count($this->items); $i++) { |
| 384 | 354 | $item = $this->items[$i]; |
| 385 | - if ( isset($item['summary']) ) |
|
| 386 | - $item['description'] = $item['summary']; |
|
| 387 | - if ( isset($item['atom_content'])) |
|
| 388 | - $item['content']['encoded'] = $item['atom_content']; |
|
| 355 | + if ( isset($item['summary']) ) { |
|
| 356 | + $item['description'] = $item['summary']; |
|
| 357 | + } |
|
| 358 | + if ( isset($item['atom_content'])) { |
|
| 359 | + $item['content']['encoded'] = $item['atom_content']; |
|
| 360 | + } |
|
| 389 | 361 | |
| 390 | 362 | $atom_date = (isset($item['issued']) ) ? $item['issued'] : $item['modified']; |
| 391 | 363 | if ( $atom_date ) { |
@@ -397,23 +369,23 @@ discard block |
||
| 397 | 369 | |
| 398 | 370 | $this->items[$i] = $item; |
| 399 | 371 | } |
| 400 | - } |
|
| 401 | - elseif ( $this->is_rss() ) { |
|
| 372 | + } elseif ( $this->is_rss() ) { |
|
| 402 | 373 | $this->channel['tagline'] = $this->channel['description']; |
| 403 | 374 | for ( $i = 0; $i < count($this->items); $i++) { |
| 404 | 375 | $item = $this->items[$i]; |
| 405 | - if ( isset($item['description'])) |
|
| 406 | - $item['summary'] = $item['description']; |
|
| 407 | - if ( isset($item['content']['encoded'] ) ) |
|
| 408 | - $item['atom_content'] = $item['content']['encoded']; |
|
| 376 | + if ( isset($item['description'])) { |
|
| 377 | + $item['summary'] = $item['description']; |
|
| 378 | + } |
|
| 379 | + if ( isset($item['content']['encoded'] ) ) { |
|
| 380 | + $item['atom_content'] = $item['content']['encoded']; |
|
| 381 | + } |
|
| 409 | 382 | |
| 410 | 383 | if ( $this->is_rss() == '1.0' and isset($item['dc']['date']) ) { |
| 411 | 384 | $epoch = @parse_w3cdtf($item['dc']['date']); |
| 412 | 385 | if ($epoch and $epoch > 0) { |
| 413 | 386 | $item['date_timestamp'] = $epoch; |
| 414 | 387 | } |
| 415 | - } |
|
| 416 | - elseif ( isset($item['pubdate']) ) { |
|
| 388 | + } elseif ( isset($item['pubdate']) ) { |
|
| 417 | 389 | $epoch = @strtotime($item['pubdate']); |
| 418 | 390 | if ($epoch > 0) { |
| 419 | 391 | $item['date_timestamp'] = $epoch; |
@@ -426,20 +398,20 @@ discard block |
||
| 426 | 398 | } |
| 427 | 399 | |
| 428 | 400 | |
| 429 | - function is_rss () { |
|
| 401 | + function is_rss () |
|
| 402 | + { |
|
| 430 | 403 | if ( $this->feed_type == RSS ) { |
| 431 | 404 | return $this->feed_version; |
| 432 | - } |
|
| 433 | - else { |
|
| 405 | + } else { |
|
| 434 | 406 | return false; |
| 435 | 407 | } |
| 436 | 408 | } |
| 437 | 409 | |
| 438 | - function is_atom() { |
|
| 410 | + function is_atom() |
|
| 411 | + { |
|
| 439 | 412 | if ( $this->feed_type == ATOM ) { |
| 440 | 413 | return $this->feed_version; |
| 441 | - } |
|
| 442 | - else { |
|
| 414 | + } else { |
|
| 443 | 415 | return false; |
| 444 | 416 | } |
| 445 | 417 | } |
@@ -448,11 +420,11 @@ discard block |
||
| 448 | 420 | * return XML parser, and possibly re-encoded source |
| 449 | 421 | * |
| 450 | 422 | */ |
| 451 | - function create_parser($source, $out_enc, $in_enc, $detect) { |
|
| 423 | + function create_parser($source, $out_enc, $in_enc, $detect) |
|
| 424 | + { |
|
| 452 | 425 | if ( substr(phpversion(),0,1) == 5) { |
| 453 | 426 | $parser = $this->php5_create_parser($in_enc, $detect); |
| 454 | - } |
|
| 455 | - else { |
|
| 427 | + } else { |
|
| 456 | 428 | list($parser, $source) = $this->php4_create_parser($source, $in_enc, $detect); |
| 457 | 429 | } |
| 458 | 430 | if ($out_enc) { |
@@ -472,12 +444,12 @@ discard block |
||
| 472 | 444 | * All hail libxml2! |
| 473 | 445 | * |
| 474 | 446 | */ |
| 475 | - function php5_create_parser($in_enc, $detect) { |
|
| 447 | + function php5_create_parser($in_enc, $detect) |
|
| 448 | + { |
|
| 476 | 449 | // by default php5 does a fine job of detecting input encodings |
| 477 | 450 | if(!$detect && $in_enc) { |
| 478 | 451 | return xml_parser_create($in_enc); |
| 479 | - } |
|
| 480 | - else { |
|
| 452 | + } else { |
|
| 481 | 453 | return xml_parser_create(''); |
| 482 | 454 | } |
| 483 | 455 | } |
@@ -497,7 +469,8 @@ discard block |
||
| 497 | 469 | * @see http://minutillo.com/steve/weblog/2004/6/17/php-xml-and-character-encodings-a-tale-of-sadness-rage-and-data-loss |
| 498 | 470 | * |
| 499 | 471 | */ |
| 500 | - function php4_create_parser($source, $in_enc, $detect) { |
|
| 472 | + function php4_create_parser($source, $in_enc, $detect) |
|
| 473 | + { |
|
| 501 | 474 | if ( !$detect ) { |
| 502 | 475 | return array(xml_parser_create($in_enc), $source); |
| 503 | 476 | } |
@@ -506,8 +479,7 @@ discard block |
||
| 506 | 479 | if (preg_match('/<?xml.*encoding=[\'"](.*?)[\'"].*?>/m', $source, $m)) { |
| 507 | 480 | $in_enc = strtoupper($m[1]); |
| 508 | 481 | $this->source_encoding = $in_enc; |
| 509 | - } |
|
| 510 | - else { |
|
| 482 | + } else { |
|
| 511 | 483 | $in_enc = 'UTF-8'; |
| 512 | 484 | } |
| 513 | 485 | } |
@@ -522,7 +494,7 @@ discard block |
||
| 522 | 494 | // cast the XML to a known encoding |
| 523 | 495 | // @see http://php.net/iconv |
| 524 | 496 | |
| 525 | - if (function_exists('iconv')) { |
|
| 497 | + if (function_exists('iconv')) { |
|
| 526 | 498 | $encoded_source = iconv($in_enc,'UTF-8', $source); |
| 527 | 499 | if ($encoded_source) { |
| 528 | 500 | return array(xml_parser_create('UTF-8'), $encoded_source); |
@@ -546,25 +518,25 @@ discard block |
||
| 546 | 518 | return array(xml_parser_create(), $source); |
| 547 | 519 | } |
| 548 | 520 | |
| 549 | - function known_encoding($enc) { |
|
| 521 | + function known_encoding($enc) |
|
| 522 | + { |
|
| 550 | 523 | $enc = strtoupper($enc); |
| 551 | 524 | if ( in_array($enc, $this->_KNOWN_ENCODINGS) ) { |
| 552 | 525 | return $enc; |
| 553 | - } |
|
| 554 | - else { |
|
| 526 | + } else { |
|
| 555 | 527 | return false; |
| 556 | 528 | } |
| 557 | 529 | } |
| 558 | 530 | |
| 559 | - function error ($errormsg, $lvl=E_USER_WARNING) { |
|
| 531 | + function error ($errormsg, $lvl=E_USER_WARNING) |
|
| 532 | + { |
|
| 560 | 533 | // append PHP's error message if track_errors enabled |
| 561 | 534 | if ( isset($php_errormsg) ) { |
| 562 | 535 | $errormsg .= " ($php_errormsg)"; |
| 563 | 536 | } |
| 564 | 537 | if ( MAGPIE_DEBUG ) { |
| 565 | 538 | trigger_error( $errormsg, $lvl); |
| 566 | - } |
|
| 567 | - else { |
|
| 539 | + } else { |
|
| 568 | 540 | error_log( $errormsg, 0); |
| 569 | 541 | } |
| 570 | 542 | |
@@ -579,7 +551,8 @@ discard block |
||
| 579 | 551 | |
| 580 | 552 | } // end class RSS |
| 581 | 553 | |
| 582 | -function map_attrs($k, $v) { |
|
| 554 | +function map_attrs($k, $v) |
|
| 555 | +{ |
|
| 583 | 556 | return "$k=\"$v\""; |
| 584 | 557 | } |
| 585 | 558 | |
@@ -591,9 +564,10 @@ discard block |
||
| 591 | 564 | define('CASE_LOWER', 0); |
| 592 | 565 | |
| 593 | 566 | |
| 594 | - function array_change_key_case($array, $case=CASE_LOWER) { |
|
| 567 | + function array_change_key_case($array, $case=CASE_LOWER) |
|
| 568 | + { |
|
| 595 | 569 | $output = array(); |
| 596 | - switch($case){ |
|
| 570 | + switch($case) { |
|
| 597 | 571 | case CASE_LOWER: |
| 598 | 572 | $cmd='strtolower'; |
| 599 | 573 | break; |