@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | /** |
| 126 | - * @return array |
|
| 126 | + * @return string[] |
|
| 127 | 127 | */ |
| 128 | 128 | public static function getValidExtraFieldTypes() |
| 129 | 129 | { |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | |
| 200 | 200 | /** |
| 201 | 201 | * @param array $conditions |
| 202 | - * @param null $order_field_options_by |
|
| 202 | + * @param string $order_field_options_by |
|
| 203 | 203 | * |
| 204 | 204 | * @return array |
| 205 | 205 | */ |
@@ -237,7 +237,7 @@ discard block |
||
| 237 | 237 | /** |
| 238 | 238 | * @param string $variable |
| 239 | 239 | * |
| 240 | - * @return array|bool |
|
| 240 | + * @return integer |
|
| 241 | 241 | */ |
| 242 | 242 | public function get_handler_field_info_by_field_variable($variable) |
| 243 | 243 | { |
@@ -319,7 +319,7 @@ discard block |
||
| 319 | 319 | /** |
| 320 | 320 | * @param string $handler |
| 321 | 321 | * |
| 322 | - * @return array |
|
| 322 | + * @return string[] |
|
| 323 | 323 | */ |
| 324 | 324 | public static function get_extra_fields_by_handler($handler) |
| 325 | 325 | { |
@@ -496,7 +496,7 @@ discard block |
||
| 496 | 496 | } |
| 497 | 497 | |
| 498 | 498 | /** |
| 499 | - * @return array |
|
| 499 | + * @return string[] |
|
| 500 | 500 | */ |
| 501 | 501 | public function get_field_types() |
| 502 | 502 | { |
@@ -506,7 +506,7 @@ discard block |
||
| 506 | 506 | /** |
| 507 | 507 | * @param int $id |
| 508 | 508 | * |
| 509 | - * @return null |
|
| 509 | + * @return string|null |
|
| 510 | 510 | */ |
| 511 | 511 | public function get_field_type_by_id($id) |
| 512 | 512 | { |
@@ -691,7 +691,6 @@ discard block |
||
| 691 | 691 | * @param FormValidator $form |
| 692 | 692 | * @param array $extraData |
| 693 | 693 | * @param bool $admin_permissions |
| 694 | - * @param int $user_id |
|
| 695 | 694 | * @param array $extra |
| 696 | 695 | * @param int $itemId |
| 697 | 696 | * @param array $exclude variables of extra field to exclude |
@@ -1592,7 +1591,7 @@ discard block |
||
| 1592 | 1591 | } |
| 1593 | 1592 | |
| 1594 | 1593 | /** |
| 1595 | - * @return array |
|
| 1594 | + * @return string[] |
|
| 1596 | 1595 | */ |
| 1597 | 1596 | public function getJqgridColumnNames() |
| 1598 | 1597 | { |
@@ -1832,7 +1831,7 @@ discard block |
||
| 1832 | 1831 | } |
| 1833 | 1832 | |
| 1834 | 1833 | /** |
| 1835 | - * @param array $columns |
|
| 1834 | + * @param string[] $columns |
|
| 1836 | 1835 | * @param array $column_model |
| 1837 | 1836 | * @param array $extraFields |
| 1838 | 1837 | * @return array |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | 'changeable', |
| 20 | 20 | 'filter', |
| 21 | 21 | 'extra_field_type', |
| 22 | - /* Enable this when field_loggeable is introduced as a table field (2.0) |
|
| 22 | + /* Enable this when field_loggeable is introduced as a table field (2.0) |
|
| 23 | 23 | 'field_loggeable', |
| 24 | 24 | */ |
| 25 | 25 | 'created_at' |
@@ -523,7 +523,7 @@ discard block |
||
| 523 | 523 | * France:Paris;Bretagne;Marseilles;Lyon|Belgique:Bruxelles;Namur;Liège;Bruges|Peru:Lima;Piura; |
| 524 | 524 | * into |
| 525 | 525 | * array( |
| 526 | - * 'France' => |
|
| 526 | + * 'France' => |
|
| 527 | 527 | * array('Paris', 'Bregtane', 'Marseilles'), |
| 528 | 528 | * 'Belgique' => |
| 529 | 529 | * array('Namur', 'Liège') |
@@ -1184,7 +1184,7 @@ discard block |
||
| 1184 | 1184 | |
| 1185 | 1185 | if ($this->type == 'user') { |
| 1186 | 1186 | |
| 1187 | - /* //the magic should be here |
|
| 1187 | + /* //the magic should be here |
|
| 1188 | 1188 | $user_tags = UserManager::get_user_tags($user_id, $field_details[0]); |
| 1189 | 1189 | |
| 1190 | 1190 | $tag_list = ''; |
@@ -26,19 +26,19 @@ discard block |
||
| 26 | 26 | ); |
| 27 | 27 | |
| 28 | 28 | public $ops = array( |
| 29 | - 'eq' => '=', //equal |
|
| 30 | - 'ne' => '<>', //not equal |
|
| 31 | - 'lt' => '<', //less than |
|
| 32 | - 'le' => '<=', //less than or equal |
|
| 33 | - 'gt' => '>', //greater than |
|
| 34 | - 'ge' => '>=', //greater than or equal |
|
| 35 | - 'bw' => 'LIKE', //begins with |
|
| 29 | + 'eq' => '=', //equal |
|
| 30 | + 'ne' => '<>', //not equal |
|
| 31 | + 'lt' => '<', //less than |
|
| 32 | + 'le' => '<=', //less than or equal |
|
| 33 | + 'gt' => '>', //greater than |
|
| 34 | + 'ge' => '>=', //greater than or equal |
|
| 35 | + 'bw' => 'LIKE', //begins with |
|
| 36 | 36 | 'bn' => 'NOT LIKE', //doesn't begin with |
| 37 | - 'in' => 'LIKE', //is in |
|
| 37 | + 'in' => 'LIKE', //is in |
|
| 38 | 38 | 'ni' => 'NOT LIKE', //is not in |
| 39 | - 'ew' => 'LIKE', //ends with |
|
| 39 | + 'ew' => 'LIKE', //ends with |
|
| 40 | 40 | 'en' => 'NOT LIKE', //doesn't end with |
| 41 | - 'cn' => 'LIKE', //contains |
|
| 41 | + 'cn' => 'LIKE', //contains |
|
| 42 | 42 | 'nc' => 'NOT LIKE' //doesn't contain |
| 43 | 43 | ); |
| 44 | 44 | |
@@ -323,7 +323,7 @@ discard block |
||
| 323 | 323 | */ |
| 324 | 324 | public static function get_extra_fields_by_handler($handler) |
| 325 | 325 | { |
| 326 | - $types= array(); |
|
| 326 | + $types = array(); |
|
| 327 | 327 | $types[self::FIELD_TYPE_TEXT] = get_lang('FieldTypeText'); |
| 328 | 328 | $types[self::FIELD_TYPE_TEXTAREA] = get_lang('FieldTypeTextarea'); |
| 329 | 329 | $types[self::FIELD_TYPE_RADIO] = get_lang('FieldTypeRadio'); |
@@ -962,7 +962,7 @@ discard block |
||
| 962 | 962 | // chzn-select doesn't work for sessions?? |
| 963 | 963 | $form->addElement( |
| 964 | 964 | 'select', |
| 965 | - 'extra_' . $field_details['variable'], |
|
| 965 | + 'extra_'.$field_details['variable'], |
|
| 966 | 966 | $field_details['display_text'], |
| 967 | 967 | $options, |
| 968 | 968 | array('id' => 'extra_'.$field_details['variable']) |
@@ -1021,7 +1021,7 @@ discard block |
||
| 1021 | 1021 | |
| 1022 | 1022 | if (!$admin_permissions) { |
| 1023 | 1023 | if ($field_details['visible'] == 0) { |
| 1024 | - $form->freeze('extra_' . $field_details['variable']); |
|
| 1024 | + $form->freeze('extra_'.$field_details['variable']); |
|
| 1025 | 1025 | } |
| 1026 | 1026 | } |
| 1027 | 1027 | break; |
@@ -1369,9 +1369,9 @@ discard block |
||
| 1369 | 1369 | |
| 1370 | 1370 | if (is_array($extraData) && array_key_exists($fieldVariable, $extraData)) { |
| 1371 | 1371 | |
| 1372 | - if (file_exists(api_get_path(SYS_UPLOAD_PATH) . $extraData[$fieldVariable])) { |
|
| 1372 | + if (file_exists(api_get_path(SYS_UPLOAD_PATH).$extraData[$fieldVariable])) { |
|
| 1373 | 1373 | $fieldTexts[] = Display::img( |
| 1374 | - api_get_path(WEB_UPLOAD_PATH) . $extraData[$fieldVariable], |
|
| 1374 | + api_get_path(WEB_UPLOAD_PATH).$extraData[$fieldVariable], |
|
| 1375 | 1375 | $field_details['display_text'], |
| 1376 | 1376 | array('width' => '300') |
| 1377 | 1377 | ); |
@@ -1388,10 +1388,10 @@ discard block |
||
| 1388 | 1388 | $form->applyFilter('extra_'.$field_details['variable'], 'stripslashes'); |
| 1389 | 1389 | $form->applyFilter('extra_'.$field_details['variable'], 'trim'); |
| 1390 | 1390 | |
| 1391 | - $allowed_picture_types = array ('jpg', 'jpeg', 'png', 'gif'); |
|
| 1391 | + $allowed_picture_types = array('jpg', 'jpeg', 'png', 'gif'); |
|
| 1392 | 1392 | $form->addRule( |
| 1393 | 1393 | 'extra_'.$field_details['variable'], |
| 1394 | - get_lang('OnlyImagesAllowed') . ' ('.implode(',', $allowed_picture_types).')', |
|
| 1394 | + get_lang('OnlyImagesAllowed').' ('.implode(',', $allowed_picture_types).')', |
|
| 1395 | 1395 | 'filetype', |
| 1396 | 1396 | $allowed_picture_types |
| 1397 | 1397 | ); |
@@ -1433,10 +1433,10 @@ discard block |
||
| 1433 | 1433 | if (is_array($extraData) && |
| 1434 | 1434 | array_key_exists($fieldVariable, $extraData) |
| 1435 | 1435 | ) { |
| 1436 | - if (file_exists(api_get_path(SYS_UPLOAD_PATH) . $extraData[$fieldVariable])) { |
|
| 1436 | + if (file_exists(api_get_path(SYS_UPLOAD_PATH).$extraData[$fieldVariable])) { |
|
| 1437 | 1437 | $fieldTexts[] = Display::url( |
| 1438 | - api_get_path(WEB_UPLOAD_PATH) . $extraData[$fieldVariable], |
|
| 1439 | - api_get_path(WEB_UPLOAD_PATH) . $extraData[$fieldVariable], |
|
| 1438 | + api_get_path(WEB_UPLOAD_PATH).$extraData[$fieldVariable], |
|
| 1439 | + api_get_path(WEB_UPLOAD_PATH).$extraData[$fieldVariable], |
|
| 1440 | 1440 | array( |
| 1441 | 1441 | 'title' => $field_details['display_text'], |
| 1442 | 1442 | 'target' => '_blank' |
@@ -1486,12 +1486,12 @@ discard block |
||
| 1486 | 1486 | "extra_{$field_details['variable']}", |
| 1487 | 1487 | $field_details['display_text'] |
| 1488 | 1488 | ); |
| 1489 | - $form->applyFilter('extra_' . $field_details['variable'], 'stripslashes'); |
|
| 1489 | + $form->applyFilter('extra_'.$field_details['variable'], 'stripslashes'); |
|
| 1490 | 1490 | |
| 1491 | 1491 | if (!$admin_permissions) { |
| 1492 | 1492 | if ($field_details['visible'] == 0) { |
| 1493 | 1493 | $form->freeze( |
| 1494 | - 'extra_' . $field_details['variable'] |
|
| 1494 | + 'extra_'.$field_details['variable'] |
|
| 1495 | 1495 | ); |
| 1496 | 1496 | } |
| 1497 | 1497 | } |
@@ -1502,13 +1502,13 @@ discard block |
||
| 1502 | 1502 | $field_details['display_text'] |
| 1503 | 1503 | ); |
| 1504 | 1504 | $form->applyFilter( |
| 1505 | - 'extra_' . $field_details['variable'], |
|
| 1505 | + 'extra_'.$field_details['variable'], |
|
| 1506 | 1506 | 'stripslashes' |
| 1507 | 1507 | ); |
| 1508 | 1508 | if (!$admin_permissions) { |
| 1509 | 1509 | if ($field_details['visible'] == 0) { |
| 1510 | 1510 | $form->freeze( |
| 1511 | - 'extra_' . $field_details['variable'] |
|
| 1511 | + 'extra_'.$field_details['variable'] |
|
| 1512 | 1512 | ); |
| 1513 | 1513 | } |
| 1514 | 1514 | } |
@@ -1518,12 +1518,12 @@ discard block |
||
| 1518 | 1518 | "extra_{$field_details['variable']}", |
| 1519 | 1519 | $field_details['display_text'] |
| 1520 | 1520 | ); |
| 1521 | - $form->applyFilter('extra_' . $field_details['variable'], 'stripslashes'); |
|
| 1521 | + $form->applyFilter('extra_'.$field_details['variable'], 'stripslashes'); |
|
| 1522 | 1522 | |
| 1523 | 1523 | if (!$admin_permissions) { |
| 1524 | 1524 | if ($field_details['visible'] == 0) { |
| 1525 | 1525 | $form->freeze( |
| 1526 | - 'extra_' . $field_details['variable'] |
|
| 1526 | + 'extra_'.$field_details['variable'] |
|
| 1527 | 1527 | ); |
| 1528 | 1528 | } |
| 1529 | 1529 | } |
@@ -1534,13 +1534,13 @@ discard block |
||
| 1534 | 1534 | $field_details['display_text'] |
| 1535 | 1535 | ); |
| 1536 | 1536 | $form->applyFilter( |
| 1537 | - 'extra_' . $field_details['variable'], |
|
| 1537 | + 'extra_'.$field_details['variable'], |
|
| 1538 | 1538 | 'stripslashes' |
| 1539 | 1539 | ); |
| 1540 | 1540 | if (!$admin_permissions) { |
| 1541 | 1541 | if ($field_details['visible'] == 0) { |
| 1542 | 1542 | $form->freeze( |
| 1543 | - 'extra_' . $field_details['variable'] |
|
| 1543 | + 'extra_'.$field_details['variable'] |
|
| 1544 | 1544 | ); |
| 1545 | 1545 | } |
| 1546 | 1546 | } |
@@ -2221,19 +2221,19 @@ discard block |
||
| 2221 | 2221 | break; |
| 2222 | 2222 | } |
| 2223 | 2223 | |
| 2224 | - if (!file_exists(api_get_path(SYS_UPLOAD_PATH) . $valueData['value'])) { |
|
| 2224 | + if (!file_exists(api_get_path(SYS_UPLOAD_PATH).$valueData['value'])) { |
|
| 2225 | 2225 | break; |
| 2226 | 2226 | } |
| 2227 | 2227 | |
| 2228 | 2228 | $image = Display::img( |
| 2229 | - api_get_path(WEB_UPLOAD_PATH) . $valueData['value'], |
|
| 2229 | + api_get_path(WEB_UPLOAD_PATH).$valueData['value'], |
|
| 2230 | 2230 | $field['display_text'], |
| 2231 | 2231 | array('width' => '300') |
| 2232 | 2232 | ); |
| 2233 | 2233 | |
| 2234 | 2234 | $displayedValue = Display::url( |
| 2235 | 2235 | $image, |
| 2236 | - api_get_path(WEB_UPLOAD_PATH) . $valueData['value'], |
|
| 2236 | + api_get_path(WEB_UPLOAD_PATH).$valueData['value'], |
|
| 2237 | 2237 | array('target' => '_blank') |
| 2238 | 2238 | ); |
| 2239 | 2239 | break; |
@@ -2242,13 +2242,13 @@ discard block |
||
| 2242 | 2242 | break; |
| 2243 | 2243 | } |
| 2244 | 2244 | |
| 2245 | - if (!file_exists(api_get_path(SYS_UPLOAD_PATH) . $valueData['value'])) { |
|
| 2245 | + if (!file_exists(api_get_path(SYS_UPLOAD_PATH).$valueData['value'])) { |
|
| 2246 | 2246 | break; |
| 2247 | 2247 | } |
| 2248 | 2248 | |
| 2249 | 2249 | $displayedValue = Display::url( |
| 2250 | 2250 | get_lang('Download'), |
| 2251 | - api_get_path(WEB_UPLOAD_PATH) . $valueData['value'], |
|
| 2251 | + api_get_path(WEB_UPLOAD_PATH).$valueData['value'], |
|
| 2252 | 2252 | array( |
| 2253 | 2253 | 'title' => $field['display_text'], |
| 2254 | 2254 | 'target' => '_blank' |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | /** |
| 46 | - * @return ExtraField |
|
| 46 | + * @return string |
|
| 47 | 47 | */ |
| 48 | 48 | public function getExtraField() |
| 49 | 49 | { |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | * This function is used with $extraField->addElements() |
| 73 | 73 | * @param array $params array for the insertion into the *_field_values table |
| 74 | 74 | * |
| 75 | - * @return mixed false on empty params, void otherwise |
|
| 75 | + * @return false|null false on empty params, void otherwise |
|
| 76 | 76 | * @assert (array()) === false |
| 77 | 77 | */ |
| 78 | 78 | public function saveFieldValues($params) |
@@ -500,7 +500,7 @@ discard block |
||
| 500 | 500 | * @param int $item_id Item ID (It could be a session_id, course_id or user_id) |
| 501 | 501 | * @param int $field_id Field ID (the ID from the *_field table) |
| 502 | 502 | * @param bool $transform Whether to transform the result to a human readable strings |
| 503 | - * @return mixed A structured array with the field_id and field_value, or false on error |
|
| 503 | + * @return string A structured array with the field_id and field_value, or false on error |
|
| 504 | 504 | * @assert (-1,-1) === false |
| 505 | 505 | */ |
| 506 | 506 | public function get_values_by_handler_and_field_id($item_id, $field_id, $transform = false) |
@@ -593,7 +593,7 @@ discard block |
||
| 593 | 593 | * @param int $item_id Item ID from the original table |
| 594 | 594 | * @param string $field_variable The name of the field we are looking for |
| 595 | 595 | * @param bool $transform |
| 596 | - * @param bool $allVisibility |
|
| 596 | + * @param bool $visibility |
|
| 597 | 597 | * |
| 598 | 598 | * @return mixed Array of results, or false on error or not found |
| 599 | 599 | * @assert (-1,'') === false |
@@ -720,11 +720,11 @@ discard block |
||
| 720 | 720 | return false; |
| 721 | 721 | } |
| 722 | 722 | |
| 723 | - /** |
|
| 724 | - * @param int $itemId |
|
| 725 | - * @param int $fieldId |
|
| 726 | - * @return array |
|
| 727 | - */ |
|
| 723 | + /** |
|
| 724 | + * @param int $itemId |
|
| 725 | + * @param int $fieldId |
|
| 726 | + * @return array |
|
| 727 | + */ |
|
| 728 | 728 | public function getAllValuesByItemAndField($itemId, $fieldId) |
| 729 | 729 | { |
| 730 | 730 | $fieldId = intval($fieldId); |
@@ -847,7 +847,6 @@ discard block |
||
| 847 | 847 | /** |
| 848 | 848 | * Deletes all values from an item |
| 849 | 849 | * @param int $itemId (session id, course id, etc) |
| 850 | - |
|
| 851 | 850 | * @assert (-1,-1) == null |
| 852 | 851 | */ |
| 853 | 852 | public function deleteValuesByItem($itemId) |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | break; |
| 210 | 210 | } |
| 211 | 211 | |
| 212 | - $fileName = ExtraField::FIELD_TYPE_FILE_IMAGE . "_{$params['item_id']}.png"; |
|
| 212 | + $fileName = ExtraField::FIELD_TYPE_FILE_IMAGE."_{$params['item_id']}.png"; |
|
| 213 | 213 | |
| 214 | 214 | if (!file_exists($fileDir)) { |
| 215 | 215 | mkdir($fileDir, $dirPermissions, true); |
@@ -217,11 +217,11 @@ discard block |
||
| 217 | 217 | |
| 218 | 218 | if ($value['error'] == 0) { |
| 219 | 219 | $imageExtraField = new Image($value['tmp_name']); |
| 220 | - $imageExtraField->send_image($fileDir . $fileName, -1, 'png'); |
|
| 220 | + $imageExtraField->send_image($fileDir.$fileName, -1, 'png'); |
|
| 221 | 221 | $newParams = array( |
| 222 | 222 | 'item_id' => $params['item_id'], |
| 223 | 223 | 'field_id' => $extraFieldInfo['id'], |
| 224 | - 'value' => $fileDirStored . $fileName, |
|
| 224 | + 'value' => $fileDirStored.$fileName, |
|
| 225 | 225 | 'comment' => $comment |
| 226 | 226 | ); |
| 227 | 227 | |
@@ -247,18 +247,18 @@ discard block |
||
| 247 | 247 | } |
| 248 | 248 | |
| 249 | 249 | $cleanedName = api_replace_dangerous_char($value['name']); |
| 250 | - $fileName = ExtraField::FIELD_TYPE_FILE . "_{$params['item_id']}_$cleanedName"; |
|
| 250 | + $fileName = ExtraField::FIELD_TYPE_FILE."_{$params['item_id']}_$cleanedName"; |
|
| 251 | 251 | if (!file_exists($fileDir)) { |
| 252 | 252 | mkdir($fileDir, $dirPermissions, true); |
| 253 | 253 | } |
| 254 | 254 | |
| 255 | 255 | if ($value['error'] == 0) { |
| 256 | - moveUploadedFile($value, $fileDir . $fileName); |
|
| 256 | + moveUploadedFile($value, $fileDir.$fileName); |
|
| 257 | 257 | |
| 258 | 258 | $new_params = array( |
| 259 | 259 | 'item_id' => $params['item_id'], |
| 260 | 260 | 'field_id' => $extraFieldInfo['id'], |
| 261 | - 'value' => $fileDirStored . $fileName |
|
| 261 | + 'value' => $fileDirStored.$fileName |
|
| 262 | 262 | ); |
| 263 | 263 | |
| 264 | 264 | if ($this->type !== 'session' && $this->type !== 'course') { |
@@ -380,7 +380,7 @@ discard block |
||
| 380 | 380 | */ |
| 381 | 381 | if (false) { |
| 382 | 382 | global $app; |
| 383 | - switch($this->type) { |
|
| 383 | + switch ($this->type) { |
|
| 384 | 384 | case 'question': |
| 385 | 385 | $extraFieldValue = new ChamiloLMS\Entity\QuestionFieldValues(); |
| 386 | 386 | $extraFieldValue->setUserId(api_get_user_id()); |
@@ -442,7 +442,7 @@ discard block |
||
| 442 | 442 | */ |
| 443 | 443 | if (false) { |
| 444 | 444 | global $app; |
| 445 | - switch($this->type) { |
|
| 445 | + switch ($this->type) { |
|
| 446 | 446 | case 'question': |
| 447 | 447 | $extraFieldValue = $app['orm.ems']['db_write']->getRepository('ChamiloLMS\Entity\QuestionFieldValues')->find($field_values['id']); |
| 448 | 448 | $extraFieldValue->setUserId(api_get_user_id()); |
@@ -13,6 +13,8 @@ discard block |
||
| 13 | 13 | * @param - action (string) - action type require : 'delete' or 'update' |
| 14 | 14 | * @param - old_path (string) - old path info stored to change |
| 15 | 15 | * @param - new_path (string) - new path info to substitute |
| 16 | + * @param string $action |
|
| 17 | + * @param string $old_path |
|
| 16 | 18 | * @desc Update the file or directory path in the document db document table |
| 17 | 19 | * |
| 18 | 20 | */ |
@@ -76,8 +78,8 @@ discard block |
||
| 76 | 78 | * Deletes a file or a directory |
| 77 | 79 | * |
| 78 | 80 | * @author - Hugues Peeters |
| 79 | - * @param $file (String) - the path of file or directory to delete |
|
| 80 | - * @return boolean - true if the delete succeed, false otherwise. |
|
| 81 | + * @param string $file (String) - the path of file or directory to delete |
|
| 82 | + * @return boolean|null - true if the delete succeed, false otherwise. |
|
| 81 | 83 | * @see - delete() uses check_name_exist() and removeDir() functions |
| 82 | 84 | */ |
| 83 | 85 | function my_delete($file) |
@@ -162,9 +164,9 @@ discard block |
||
| 162 | 164 | * Renames a file or a directory |
| 163 | 165 | * |
| 164 | 166 | * @author - Hugues Peeters <[email protected]> |
| 165 | - * @param - $file_path (string) - complete path of the file or the directory |
|
| 166 | - * @param - $new_file_name (string) - new name for the file or the directory |
|
| 167 | - * @return - boolean - true if succeed |
|
| 167 | + * @param string $file_path (string) - complete path of the file or the directory |
|
| 168 | + * @param string $new_file_name (string) - new name for the file or the directory |
|
| 169 | + * @return string boolean - true if succeed |
|
| 168 | 170 | * - boolean - false otherwise |
| 169 | 171 | * @see - rename() uses the check_name_exist() and php2phps() functions |
| 170 | 172 | */ |
@@ -327,7 +329,6 @@ discard block |
||
| 327 | 329 | * Calculation size of a directory |
| 328 | 330 | * |
| 329 | 331 | * @returns integer size |
| 330 | - * @param string $path path to size |
|
| 331 | 332 | * @param boolean $recursive if true , include subdir in total |
| 332 | 333 | */ |
| 333 | 334 | function dirsize($root, $recursive = true) { |
@@ -225,9 +225,9 @@ discard block |
||
| 225 | 225 | /* File case */ |
| 226 | 226 | if (is_file($source)) { |
| 227 | 227 | if ($forceMove && !$isWindowsOS && $canExec) { |
| 228 | - exec('mv ' . $source . ' ' . $target . '/' . $file_name); |
|
| 228 | + exec('mv '.$source.' '.$target.'/'.$file_name); |
|
| 229 | 229 | } else { |
| 230 | - copy($source, $target . '/' . $file_name); |
|
| 230 | + copy($source, $target.'/'.$file_name); |
|
| 231 | 231 | unlink($source); |
| 232 | 232 | } |
| 233 | 233 | return true; |
@@ -278,7 +278,7 @@ discard block |
||
| 278 | 278 | } |
| 279 | 279 | $destination_trail = $destination.'/'.$dir_name; |
| 280 | 280 | if (is_dir($destination)) { |
| 281 | - chdir($orig_dir_path) ; |
|
| 281 | + chdir($orig_dir_path); |
|
| 282 | 282 | $handle = opendir($orig_dir_path); |
| 283 | 283 | |
| 284 | 284 | while ($element = readdir($handle)) { |
@@ -288,14 +288,14 @@ discard block |
||
| 288 | 288 | copy($element, $destination_trail.'/'.$element); |
| 289 | 289 | |
| 290 | 290 | if ($move) { |
| 291 | - unlink($element) ; |
|
| 291 | + unlink($element); |
|
| 292 | 292 | } |
| 293 | 293 | } elseif (is_dir($element)) { |
| 294 | 294 | $dir_to_copy[] = $orig_dir_path.'/'.$element; |
| 295 | 295 | } |
| 296 | 296 | } |
| 297 | 297 | |
| 298 | - closedir($handle) ; |
|
| 298 | + closedir($handle); |
|
| 299 | 299 | |
| 300 | 300 | if (sizeof($dir_to_copy) > 0) { |
| 301 | 301 | foreach ($dir_to_copy as $this_dir) { |
@@ -304,7 +304,7 @@ discard block |
||
| 304 | 304 | } |
| 305 | 305 | |
| 306 | 306 | if ($move) { |
| 307 | - rmdir($orig_dir_path) ; |
|
| 307 | + rmdir($orig_dir_path); |
|
| 308 | 308 | } |
| 309 | 309 | chdir($save_dir); |
| 310 | 310 | } |
@@ -389,17 +389,17 @@ discard block |
||
| 389 | 389 | // Recursive operation if subdirectories exist |
| 390 | 390 | $dir_number = sizeof($dir_array); |
| 391 | 391 | if ($dir_number > 0) { |
| 392 | - for ($i = 0 ; $i < $dir_number ; $i++) { |
|
| 392 | + for ($i = 0; $i < $dir_number; $i++) { |
|
| 393 | 393 | $sub_dir_array = FileManager::list_all_directories($dir_array[$i]); // Function recursivity |
| 394 | 394 | if (is_array($dir_array) && is_array($sub_dir_array)) { |
| 395 | - $dir_array = array_merge($dir_array, $sub_dir_array); // Data merge |
|
| 395 | + $dir_array = array_merge($dir_array, $sub_dir_array); // Data merge |
|
| 396 | 396 | } |
| 397 | 397 | } |
| 398 | 398 | } |
| 399 | - $result_array = $dir_array; |
|
| 400 | - chdir($save_dir) ; |
|
| 399 | + $result_array = $dir_array; |
|
| 400 | + chdir($save_dir); |
|
| 401 | 401 | } |
| 402 | - return $result_array ; |
|
| 402 | + return $result_array; |
|
| 403 | 403 | } |
| 404 | 404 | |
| 405 | 405 | /** |
@@ -444,8 +444,8 @@ discard block |
||
| 444 | 444 | $buffer = ''; |
| 445 | 445 | if (file_exists($file_name)) { |
| 446 | 446 | $fp = fopen($file_name, 'rb'); |
| 447 | - $buffer = fread ($fp, filesize($file_name)); |
|
| 448 | - fclose ($fp); |
|
| 447 | + $buffer = fread($fp, filesize($file_name)); |
|
| 448 | + fclose($fp); |
|
| 449 | 449 | } |
| 450 | 450 | return $buffer; |
| 451 | 451 | } |
@@ -33,7 +33,9 @@ discard block |
||
| 33 | 33 | Database::query($query); |
| 34 | 34 | break; |
| 35 | 35 | case 'update': |
| 36 | - if ($new_path[0] == '.') $new_path = substr($new_path, 1); |
|
| 36 | + if ($new_path[0] == '.') { |
|
| 37 | + $new_path = substr($new_path, 1); |
|
| 38 | + } |
|
| 37 | 39 | $new_path = str_replace('//', '/', $new_path); |
| 38 | 40 | |
| 39 | 41 | // Attempt to update - tested & working for root dir |
@@ -379,7 +381,9 @@ discard block |
||
| 379 | 381 | chdir($path); |
| 380 | 382 | $handle = opendir($path); |
| 381 | 383 | while ($element = readdir($handle)) { |
| 382 | - if ($element == '.' || $element == '..') continue; |
|
| 384 | + if ($element == '.' || $element == '..') { |
|
| 385 | + continue; |
|
| 386 | + } |
|
| 383 | 387 | // Skip the current and parent directories |
| 384 | 388 | if (is_dir($element)) { |
| 385 | 389 | $dir_array[] = $path.'/'.$element; |
@@ -419,7 +423,9 @@ discard block |
||
| 419 | 423 | chdir($directory); |
| 420 | 424 | $handle = opendir($directory); |
| 421 | 425 | while ($element = readdir($handle)) { |
| 422 | - if ($element == '.' || $element == '..' || $element == '.htaccess') continue; |
|
| 426 | + if ($element == '.' || $element == '..' || $element == '.htaccess') { |
|
| 427 | + continue; |
|
| 428 | + } |
|
| 423 | 429 | // Skip the current and parent directories |
| 424 | 430 | if (!is_dir($element)) { |
| 425 | 431 | $element_array[] = $directory.'/'.$element; |
@@ -469,7 +475,9 @@ discard block |
||
| 469 | 475 | */ |
| 470 | 476 | function set_default_settings($upload_path, $filename, $filetype = 'file', $glued_table, $default_visibility = 'v') |
| 471 | 477 | { |
| 472 | - if (!$default_visibility) $default_visibility = 'v'; |
|
| 478 | + if (!$default_visibility) { |
|
| 479 | + $default_visibility = 'v'; |
|
| 480 | + } |
|
| 473 | 481 | |
| 474 | 482 | // Make sure path is not wrongly formed |
| 475 | 483 | $upload_path = !empty($upload_path) ? "/$upload_path" : ''; |
@@ -170,37 +170,37 @@ discard block |
||
| 170 | 170 | */ |
| 171 | 171 | function my_rename($file_path, $new_file_name) { |
| 172 | 172 | |
| 173 | - $save_dir = getcwd(); |
|
| 174 | - $path = dirname($file_path); |
|
| 175 | - $old_file_name = basename($file_path); |
|
| 176 | - $new_file_name = api_replace_dangerous_char($new_file_name); |
|
| 177 | - |
|
| 178 | - // If no extension, take the old one |
|
| 179 | - if ((strpos($new_file_name, '.') === false) && ($dotpos = strrpos($old_file_name, '.'))) { |
|
| 180 | - $new_file_name .= substr($old_file_name, $dotpos); |
|
| 181 | - } |
|
| 182 | - |
|
| 183 | - // Note: still possible: 'xx.yy' -rename-> '.yy' -rename-> 'zz' |
|
| 184 | - // This is useful for folder names, where otherwise '.' would be sticky |
|
| 185 | - |
|
| 186 | - // Extension PHP is not allowed, change to PHPS |
|
| 187 | - $new_file_name = php2phps($new_file_name); |
|
| 188 | - |
|
| 189 | - if ($new_file_name == $old_file_name) { |
|
| 190 | - return $old_file_name; |
|
| 191 | - } |
|
| 192 | - |
|
| 193 | - if (strtolower($new_file_name) != strtolower($old_file_name) && check_name_exist($path.'/'.$new_file_name)) { |
|
| 194 | - return false; |
|
| 195 | - } |
|
| 196 | - // On a Windows server, it would be better not to do the above check |
|
| 197 | - // because it succeeds for some new names resembling the old name. |
|
| 198 | - // But on Unix/Linux the check must be done because rename overwrites. |
|
| 199 | - |
|
| 200 | - chdir($path); |
|
| 201 | - $res = rename($old_file_name, $new_file_name) ? $new_file_name : false; |
|
| 202 | - chdir($save_dir); |
|
| 203 | - return $res; |
|
| 173 | + $save_dir = getcwd(); |
|
| 174 | + $path = dirname($file_path); |
|
| 175 | + $old_file_name = basename($file_path); |
|
| 176 | + $new_file_name = api_replace_dangerous_char($new_file_name); |
|
| 177 | + |
|
| 178 | + // If no extension, take the old one |
|
| 179 | + if ((strpos($new_file_name, '.') === false) && ($dotpos = strrpos($old_file_name, '.'))) { |
|
| 180 | + $new_file_name .= substr($old_file_name, $dotpos); |
|
| 181 | + } |
|
| 182 | + |
|
| 183 | + // Note: still possible: 'xx.yy' -rename-> '.yy' -rename-> 'zz' |
|
| 184 | + // This is useful for folder names, where otherwise '.' would be sticky |
|
| 185 | + |
|
| 186 | + // Extension PHP is not allowed, change to PHPS |
|
| 187 | + $new_file_name = php2phps($new_file_name); |
|
| 188 | + |
|
| 189 | + if ($new_file_name == $old_file_name) { |
|
| 190 | + return $old_file_name; |
|
| 191 | + } |
|
| 192 | + |
|
| 193 | + if (strtolower($new_file_name) != strtolower($old_file_name) && check_name_exist($path.'/'.$new_file_name)) { |
|
| 194 | + return false; |
|
| 195 | + } |
|
| 196 | + // On a Windows server, it would be better not to do the above check |
|
| 197 | + // because it succeeds for some new names resembling the old name. |
|
| 198 | + // But on Unix/Linux the check must be done because rename overwrites. |
|
| 199 | + |
|
| 200 | + chdir($path); |
|
| 201 | + $res = rename($old_file_name, $new_file_name) ? $new_file_name : false; |
|
| 202 | + chdir($save_dir); |
|
| 203 | + return $res; |
|
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | /** |
@@ -217,38 +217,38 @@ discard block |
||
| 217 | 217 | */ |
| 218 | 218 | function move($source, $target, $forceMove = false, $moveContent = false) |
| 219 | 219 | { |
| 220 | - if (check_name_exist($source)) { |
|
| 221 | - $file_name = basename($source); |
|
| 220 | + if (check_name_exist($source)) { |
|
| 221 | + $file_name = basename($source); |
|
| 222 | 222 | $isWindowsOS = api_is_windows_os(); |
| 223 | 223 | $canExec = function_exists('exec'); |
| 224 | 224 | |
| 225 | - /* File case */ |
|
| 226 | - if (is_file($source)) { |
|
| 227 | - if ($forceMove && !$isWindowsOS && $canExec) { |
|
| 228 | - exec('mv ' . $source . ' ' . $target . '/' . $file_name); |
|
| 229 | - } else { |
|
| 230 | - copy($source, $target . '/' . $file_name); |
|
| 231 | - unlink($source); |
|
| 232 | - } |
|
| 233 | - return true; |
|
| 234 | - } elseif (is_dir($source)) { |
|
| 235 | - /* Directory */ |
|
| 236 | - if ($forceMove && !$isWindowsOS && $canExec) { |
|
| 237 | - if ($moveContent) { |
|
| 238 | - $base = basename($source); |
|
| 239 | - exec('mv '.$source.'/* '.$target.$base.'/'); |
|
| 240 | - exec('rm -rf '.$source); |
|
| 241 | - } else { |
|
| 242 | - exec('mv $source $target'); |
|
| 243 | - } |
|
| 244 | - } else { |
|
| 245 | - copyDirTo($source, $target); |
|
| 246 | - } |
|
| 247 | - return true; |
|
| 248 | - } |
|
| 249 | - } else { |
|
| 250 | - return false; |
|
| 251 | - } |
|
| 225 | + /* File case */ |
|
| 226 | + if (is_file($source)) { |
|
| 227 | + if ($forceMove && !$isWindowsOS && $canExec) { |
|
| 228 | + exec('mv ' . $source . ' ' . $target . '/' . $file_name); |
|
| 229 | + } else { |
|
| 230 | + copy($source, $target . '/' . $file_name); |
|
| 231 | + unlink($source); |
|
| 232 | + } |
|
| 233 | + return true; |
|
| 234 | + } elseif (is_dir($source)) { |
|
| 235 | + /* Directory */ |
|
| 236 | + if ($forceMove && !$isWindowsOS && $canExec) { |
|
| 237 | + if ($moveContent) { |
|
| 238 | + $base = basename($source); |
|
| 239 | + exec('mv '.$source.'/* '.$target.$base.'/'); |
|
| 240 | + exec('rm -rf '.$source); |
|
| 241 | + } else { |
|
| 242 | + exec('mv $source $target'); |
|
| 243 | + } |
|
| 244 | + } else { |
|
| 245 | + copyDirTo($source, $target); |
|
| 246 | + } |
|
| 247 | + return true; |
|
| 248 | + } |
|
| 249 | + } else { |
|
| 250 | + return false; |
|
| 251 | + } |
|
| 252 | 252 | } |
| 253 | 253 | |
| 254 | 254 | /** |
@@ -261,54 +261,54 @@ discard block |
||
| 261 | 261 | */ |
| 262 | 262 | function copyDirTo($orig_dir_path, $destination, $move = true) |
| 263 | 263 | { |
| 264 | - if ($orig_dir_path == $destination) { |
|
| 265 | - return false; |
|
| 266 | - } |
|
| 264 | + if ($orig_dir_path == $destination) { |
|
| 265 | + return false; |
|
| 266 | + } |
|
| 267 | 267 | |
| 268 | - $save_dir = getcwd(); |
|
| 269 | - // Extract directory name - create it at destination - update destination trail |
|
| 270 | - $dir_name = basename($orig_dir_path); |
|
| 268 | + $save_dir = getcwd(); |
|
| 269 | + // Extract directory name - create it at destination - update destination trail |
|
| 270 | + $dir_name = basename($orig_dir_path); |
|
| 271 | 271 | $dir_to_copy = array(); |
| 272 | - if (is_dir($orig_dir_path)) { |
|
| 273 | - if (!is_dir($destination.'/'.$dir_name)) { |
|
| 274 | - mkdir( |
|
| 275 | - $destination.'/'.$dir_name, |
|
| 276 | - api_get_permissions_for_new_directories() |
|
| 277 | - ); |
|
| 278 | - } |
|
| 279 | - $destination_trail = $destination.'/'.$dir_name; |
|
| 280 | - if (is_dir($destination)) { |
|
| 281 | - chdir($orig_dir_path) ; |
|
| 282 | - $handle = opendir($orig_dir_path); |
|
| 283 | - |
|
| 284 | - while ($element = readdir($handle)) { |
|
| 285 | - if ($element == '.' || $element == '..') { |
|
| 286 | - continue; // Skip the current and parent directories |
|
| 287 | - } elseif (is_file($element)) { |
|
| 288 | - copy($element, $destination_trail.'/'.$element); |
|
| 289 | - |
|
| 290 | - if ($move) { |
|
| 291 | - unlink($element) ; |
|
| 292 | - } |
|
| 293 | - } elseif (is_dir($element)) { |
|
| 294 | - $dir_to_copy[] = $orig_dir_path.'/'.$element; |
|
| 295 | - } |
|
| 296 | - } |
|
| 297 | - |
|
| 298 | - closedir($handle) ; |
|
| 299 | - |
|
| 300 | - if (sizeof($dir_to_copy) > 0) { |
|
| 301 | - foreach ($dir_to_copy as $this_dir) { |
|
| 302 | - copyDirTo($this_dir, $destination_trail, $move); // Recursivity |
|
| 303 | - } |
|
| 304 | - } |
|
| 305 | - |
|
| 306 | - if ($move) { |
|
| 307 | - rmdir($orig_dir_path) ; |
|
| 308 | - } |
|
| 309 | - chdir($save_dir); |
|
| 310 | - } |
|
| 311 | - } |
|
| 272 | + if (is_dir($orig_dir_path)) { |
|
| 273 | + if (!is_dir($destination.'/'.$dir_name)) { |
|
| 274 | + mkdir( |
|
| 275 | + $destination.'/'.$dir_name, |
|
| 276 | + api_get_permissions_for_new_directories() |
|
| 277 | + ); |
|
| 278 | + } |
|
| 279 | + $destination_trail = $destination.'/'.$dir_name; |
|
| 280 | + if (is_dir($destination)) { |
|
| 281 | + chdir($orig_dir_path) ; |
|
| 282 | + $handle = opendir($orig_dir_path); |
|
| 283 | + |
|
| 284 | + while ($element = readdir($handle)) { |
|
| 285 | + if ($element == '.' || $element == '..') { |
|
| 286 | + continue; // Skip the current and parent directories |
|
| 287 | + } elseif (is_file($element)) { |
|
| 288 | + copy($element, $destination_trail.'/'.$element); |
|
| 289 | + |
|
| 290 | + if ($move) { |
|
| 291 | + unlink($element) ; |
|
| 292 | + } |
|
| 293 | + } elseif (is_dir($element)) { |
|
| 294 | + $dir_to_copy[] = $orig_dir_path.'/'.$element; |
|
| 295 | + } |
|
| 296 | + } |
|
| 297 | + |
|
| 298 | + closedir($handle) ; |
|
| 299 | + |
|
| 300 | + if (sizeof($dir_to_copy) > 0) { |
|
| 301 | + foreach ($dir_to_copy as $this_dir) { |
|
| 302 | + copyDirTo($this_dir, $destination_trail, $move); // Recursivity |
|
| 303 | + } |
|
| 304 | + } |
|
| 305 | + |
|
| 306 | + if ($move) { |
|
| 307 | + rmdir($orig_dir_path) ; |
|
| 308 | + } |
|
| 309 | + chdir($save_dir); |
|
| 310 | + } |
|
| 311 | + } |
|
| 312 | 312 | } |
| 313 | 313 | |
| 314 | 314 | |
@@ -319,8 +319,8 @@ discard block |
||
| 319 | 319 | * @param string $filename filename |
| 320 | 320 | */ |
| 321 | 321 | function getextension($filename) { |
| 322 | - $bouts = explode('.', $filename); |
|
| 323 | - return array(array_pop($bouts), implode('.', $bouts)); |
|
| 322 | + $bouts = explode('.', $filename); |
|
| 323 | + return array(array_pop($bouts), implode('.', $bouts)); |
|
| 324 | 324 | } |
| 325 | 325 | |
| 326 | 326 | /** |
@@ -331,19 +331,19 @@ discard block |
||
| 331 | 331 | * @param boolean $recursive if true , include subdir in total |
| 332 | 332 | */ |
| 333 | 333 | function dirsize($root, $recursive = true) { |
| 334 | - $dir = @opendir($root); |
|
| 335 | - $size = 0; |
|
| 336 | - while ($file = @readdir($dir)) { |
|
| 337 | - if (!in_array($file, array('.', '..'))) { |
|
| 338 | - if (is_dir($root.'/'.$file)) { |
|
| 339 | - $size += $recursive ? dirsize($root.'/'.$file) : 0; |
|
| 340 | - } else { |
|
| 341 | - $size += @filesize($root.'/'.$file); |
|
| 342 | - } |
|
| 343 | - } |
|
| 344 | - } |
|
| 345 | - @closedir($dir); |
|
| 346 | - return $size; |
|
| 334 | + $dir = @opendir($root); |
|
| 335 | + $size = 0; |
|
| 336 | + while ($file = @readdir($dir)) { |
|
| 337 | + if (!in_array($file, array('.', '..'))) { |
|
| 338 | + if (is_dir($root.'/'.$file)) { |
|
| 339 | + $size += $recursive ? dirsize($root.'/'.$file) : 0; |
|
| 340 | + } else { |
|
| 341 | + $size += @filesize($root.'/'.$file); |
|
| 342 | + } |
|
| 343 | + } |
|
| 344 | + } |
|
| 345 | + @closedir($dir); |
|
| 346 | + return $size; |
|
| 347 | 347 | } |
| 348 | 348 | |
| 349 | 349 | /* CLASS FileManager */ |
@@ -362,7 +362,7 @@ discard block |
||
| 362 | 362 | */ |
| 363 | 363 | class FileManager |
| 364 | 364 | { |
| 365 | - /** |
|
| 365 | + /** |
|
| 366 | 366 | Returns a list of all directories, except the base dir, |
| 367 | 367 | of the current course. This function uses recursion. |
| 368 | 368 | |
@@ -370,131 +370,130 @@ discard block |
||
| 370 | 370 | |
| 371 | 371 | @author Roan Embrechts |
| 372 | 372 | @version 1.0.1 |
| 373 | - */ |
|
| 374 | - function list_all_directories($path) |
|
| 373 | + */ |
|
| 374 | + function list_all_directories($path) |
|
| 375 | 375 | { |
| 376 | - $result_array = array(); |
|
| 377 | - if (is_dir($path)) { |
|
| 378 | - $save_dir = getcwd(); |
|
| 379 | - chdir($path); |
|
| 380 | - $handle = opendir($path); |
|
| 381 | - while ($element = readdir($handle)) { |
|
| 382 | - if ($element == '.' || $element == '..') continue; |
|
| 376 | + $result_array = array(); |
|
| 377 | + if (is_dir($path)) { |
|
| 378 | + $save_dir = getcwd(); |
|
| 379 | + chdir($path); |
|
| 380 | + $handle = opendir($path); |
|
| 381 | + while ($element = readdir($handle)) { |
|
| 382 | + if ($element == '.' || $element == '..') continue; |
|
| 383 | 383 | // Skip the current and parent directories |
| 384 | - if (is_dir($element)) { |
|
| 385 | - $dir_array[] = $path.'/'.$element; |
|
| 386 | - } |
|
| 387 | - } |
|
| 388 | - closedir($handle); |
|
| 389 | - // Recursive operation if subdirectories exist |
|
| 390 | - $dir_number = sizeof($dir_array); |
|
| 391 | - if ($dir_number > 0) { |
|
| 392 | - for ($i = 0 ; $i < $dir_number ; $i++) { |
|
| 393 | - $sub_dir_array = FileManager::list_all_directories($dir_array[$i]); // Function recursivity |
|
| 394 | - if (is_array($dir_array) && is_array($sub_dir_array)) { |
|
| 395 | - $dir_array = array_merge($dir_array, $sub_dir_array); // Data merge |
|
| 396 | - } |
|
| 397 | - } |
|
| 398 | - } |
|
| 399 | - $result_array = $dir_array; |
|
| 400 | - chdir($save_dir) ; |
|
| 401 | - } |
|
| 402 | - return $result_array ; |
|
| 403 | - } |
|
| 404 | - |
|
| 405 | - /** |
|
| 384 | + if (is_dir($element)) { |
|
| 385 | + $dir_array[] = $path.'/'.$element; |
|
| 386 | + } |
|
| 387 | + } |
|
| 388 | + closedir($handle); |
|
| 389 | + // Recursive operation if subdirectories exist |
|
| 390 | + $dir_number = sizeof($dir_array); |
|
| 391 | + if ($dir_number > 0) { |
|
| 392 | + for ($i = 0 ; $i < $dir_number ; $i++) { |
|
| 393 | + $sub_dir_array = FileManager::list_all_directories($dir_array[$i]); // Function recursivity |
|
| 394 | + if (is_array($dir_array) && is_array($sub_dir_array)) { |
|
| 395 | + $dir_array = array_merge($dir_array, $sub_dir_array); // Data merge |
|
| 396 | + } |
|
| 397 | + } |
|
| 398 | + } |
|
| 399 | + $result_array = $dir_array; |
|
| 400 | + chdir($save_dir) ; |
|
| 401 | + } |
|
| 402 | + return $result_array ; |
|
| 403 | + } |
|
| 404 | + |
|
| 405 | + /** |
|
| 406 | 406 | This function receives a list of directories. |
| 407 | 407 | It returns a list of all files in these directories |
| 408 | 408 | |
| 409 | 409 | @author Roan Embrechts |
| 410 | 410 | @version 1.0 |
| 411 | - */ |
|
| 412 | - function list_all_files($dir_array) |
|
| 411 | + */ |
|
| 412 | + function list_all_files($dir_array) |
|
| 413 | 413 | { |
| 414 | - $element_array = array(); |
|
| 415 | - if (is_dir($dir_array)) { |
|
| 416 | - |
|
| 417 | - $save_dir = getcwd(); |
|
| 418 | - foreach ($dir_array as $directory) { |
|
| 419 | - chdir($directory); |
|
| 420 | - $handle = opendir($directory); |
|
| 421 | - while ($element = readdir($handle)) { |
|
| 422 | - if ($element == '.' || $element == '..' || $element == '.htaccess') continue; |
|
| 414 | + $element_array = array(); |
|
| 415 | + if (is_dir($dir_array)) { |
|
| 416 | + |
|
| 417 | + $save_dir = getcwd(); |
|
| 418 | + foreach ($dir_array as $directory) { |
|
| 419 | + chdir($directory); |
|
| 420 | + $handle = opendir($directory); |
|
| 421 | + while ($element = readdir($handle)) { |
|
| 422 | + if ($element == '.' || $element == '..' || $element == '.htaccess') continue; |
|
| 423 | 423 | // Skip the current and parent directories |
| 424 | - if (!is_dir($element)) { |
|
| 425 | - $element_array[] = $directory.'/'.$element; |
|
| 426 | - } |
|
| 427 | - } |
|
| 428 | - closedir($handle); |
|
| 429 | - chdir('..'); |
|
| 430 | - chdir($save_dir); |
|
| 431 | - } |
|
| 432 | - } |
|
| 433 | - |
|
| 434 | - return $element_array; |
|
| 435 | - } |
|
| 436 | - |
|
| 437 | - /** |
|
| 424 | + if (!is_dir($element)) { |
|
| 425 | + $element_array[] = $directory.'/'.$element; |
|
| 426 | + } |
|
| 427 | + } |
|
| 428 | + closedir($handle); |
|
| 429 | + chdir('..'); |
|
| 430 | + chdir($save_dir); |
|
| 431 | + } |
|
| 432 | + } |
|
| 433 | + |
|
| 434 | + return $element_array; |
|
| 435 | + } |
|
| 436 | + |
|
| 437 | + /** |
|
| 438 | 438 | Loads contents of file $filename into memory and returns them as a string. |
| 439 | 439 | Function kept for compatibility with older PHP versions. |
| 440 | 440 | Function is binary safe (is needed on Windows) |
| 441 | - */ |
|
| 442 | - function compat_load_file($file_name) |
|
| 441 | + */ |
|
| 442 | + function compat_load_file($file_name) |
|
| 443 | 443 | { |
| 444 | - $buffer = ''; |
|
| 445 | - if (file_exists($file_name)) { |
|
| 446 | - $fp = fopen($file_name, 'rb'); |
|
| 447 | - $buffer = fread ($fp, filesize($file_name)); |
|
| 448 | - fclose ($fp); |
|
| 449 | - } |
|
| 450 | - return $buffer; |
|
| 451 | - } |
|
| 452 | - |
|
| 453 | - /** |
|
| 454 | - * Adds file/folder to document table in database |
|
| 455 | - * improvement from set_default_settings (see below): |
|
| 456 | - * take all info from function parameters |
|
| 457 | - * no global variables needed |
|
| 458 | - * |
|
| 459 | - * NOTE $glued_table should already have backticks around it |
|
| 460 | - * (get it from the database library, and it is done automatically) |
|
| 461 | - * |
|
| 462 | - * @param path, filename, filetype, |
|
| 463 | - $glued_table, default_visibility |
|
| 444 | + $buffer = ''; |
|
| 445 | + if (file_exists($file_name)) { |
|
| 446 | + $fp = fopen($file_name, 'rb'); |
|
| 447 | + $buffer = fread ($fp, filesize($file_name)); |
|
| 448 | + fclose ($fp); |
|
| 449 | + } |
|
| 450 | + return $buffer; |
|
| 451 | + } |
|
| 464 | 452 | |
| 465 | - * action: Adds an entry to the document table with the default settings. |
|
| 466 | - * @author Olivier Cauberghe <[email protected]> |
|
| 467 | - * @author Roan Embrechts |
|
| 468 | - * @version 1.2 |
|
| 469 | - */ |
|
| 470 | - function set_default_settings($upload_path, $filename, $filetype = 'file', $glued_table, $default_visibility = 'v') |
|
| 453 | + /** |
|
| 454 | + * Adds file/folder to document table in database |
|
| 455 | + * improvement from set_default_settings (see below): |
|
| 456 | + * take all info from function parameters |
|
| 457 | + * no global variables needed |
|
| 458 | + * |
|
| 459 | + * NOTE $glued_table should already have backticks around it |
|
| 460 | + * (get it from the database library, and it is done automatically) |
|
| 461 | + * |
|
| 462 | + * @param path, filename, filetype, |
|
| 463 | + $glued_table, default_visibility |
|
| 464 | + * action: Adds an entry to the document table with the default settings. |
|
| 465 | + * @author Olivier Cauberghe <[email protected]> |
|
| 466 | + * @author Roan Embrechts |
|
| 467 | + * @version 1.2 |
|
| 468 | + */ |
|
| 469 | + function set_default_settings($upload_path, $filename, $filetype = 'file', $glued_table, $default_visibility = 'v') |
|
| 471 | 470 | { |
| 472 | - if (!$default_visibility) $default_visibility = 'v'; |
|
| 473 | - |
|
| 474 | - // Make sure path is not wrongly formed |
|
| 475 | - $upload_path = !empty($upload_path) ? "/$upload_path" : ''; |
|
| 476 | - |
|
| 477 | - $endchar = substr($filename, strlen($filename) - 1, 1); |
|
| 478 | - if ($endchar == "\\" || $endchar == '/') { |
|
| 479 | - $filename = substr($filename, 0, strlen($filename) - 1); |
|
| 480 | - } |
|
| 481 | - |
|
| 482 | - $full_file_name = $upload_path.'/'.$filename; |
|
| 483 | - $full_file_name = str_replace("//", '/', $full_file_name); |
|
| 484 | - |
|
| 485 | - $sql_query = "SELECT count(*) as number_existing FROM $glued_table WHERE path='$full_file_name'"; |
|
| 486 | - $sql_result = Database::query($sql_query); |
|
| 487 | - $result = Database::fetch_array($sql_result); |
|
| 488 | - // Determine which query to execute |
|
| 489 | - if ($result['number_existing'] > 0) { |
|
| 490 | - // Entry exists, update |
|
| 491 | - $query = "UPDATE $glued_table SET path='$full_file_name',visibility='$default_visibility', filetype='$filetype' |
|
| 471 | + if (!$default_visibility) $default_visibility = 'v'; |
|
| 472 | + |
|
| 473 | + // Make sure path is not wrongly formed |
|
| 474 | + $upload_path = !empty($upload_path) ? "/$upload_path" : ''; |
|
| 475 | + |
|
| 476 | + $endchar = substr($filename, strlen($filename) - 1, 1); |
|
| 477 | + if ($endchar == "\\" || $endchar == '/') { |
|
| 478 | + $filename = substr($filename, 0, strlen($filename) - 1); |
|
| 479 | + } |
|
| 480 | + |
|
| 481 | + $full_file_name = $upload_path.'/'.$filename; |
|
| 482 | + $full_file_name = str_replace("//", '/', $full_file_name); |
|
| 483 | + |
|
| 484 | + $sql_query = "SELECT count(*) as number_existing FROM $glued_table WHERE path='$full_file_name'"; |
|
| 485 | + $sql_result = Database::query($sql_query); |
|
| 486 | + $result = Database::fetch_array($sql_result); |
|
| 487 | + // Determine which query to execute |
|
| 488 | + if ($result['number_existing'] > 0) { |
|
| 489 | + // Entry exists, update |
|
| 490 | + $query = "UPDATE $glued_table SET path='$full_file_name',visibility='$default_visibility', filetype='$filetype' |
|
| 492 | 491 | WHERE path='$full_file_name'"; |
| 493 | - } else { |
|
| 494 | - // No entry exists, create new one |
|
| 495 | - $query = "INSERT INTO $glued_table (path,visibility,filetype) |
|
| 492 | + } else { |
|
| 493 | + // No entry exists, create new one |
|
| 494 | + $query = "INSERT INTO $glued_table (path,visibility,filetype) |
|
| 496 | 495 | VALUES ('$full_file_name','$default_visibility','$filetype')"; |
| 497 | - } |
|
| 498 | - Database::query($query); |
|
| 499 | - } |
|
| 496 | + } |
|
| 497 | + Database::query($query); |
|
| 498 | + } |
|
| 500 | 499 | } |
@@ -17,6 +17,7 @@ discard block |
||
| 17 | 17 | * |
| 18 | 18 | * @author - Hugues Peeters <[email protected]> |
| 19 | 19 | * @param - file_name (string) name of a file |
| 20 | + * @param string $file_name |
|
| 20 | 21 | * @return - the filenam phps'ized |
| 21 | 22 | */ |
| 22 | 23 | function php2phps($file_name) { |
@@ -73,7 +74,7 @@ discard block |
||
| 73 | 74 | * Returns the name without extension, used for the title |
| 74 | 75 | * |
| 75 | 76 | * @param string $name |
| 76 | - * @return name without the extension |
|
| 77 | + * @return string without the extension |
|
| 77 | 78 | */ |
| 78 | 79 | function get_document_title($name) { |
| 79 | 80 | // If they upload .htaccess... |
@@ -86,7 +87,7 @@ discard block |
||
| 86 | 87 | * This function checks if the upload succeeded |
| 87 | 88 | * |
| 88 | 89 | * @param array $uploaded_file ($_FILES) |
| 89 | - * @return true if upload succeeded |
|
| 90 | + * @return boolean if upload succeeded |
|
| 90 | 91 | */ |
| 91 | 92 | function process_uploaded_file($uploaded_file, $show_output = true) |
| 92 | 93 | { |
@@ -698,6 +699,8 @@ discard block |
||
| 698 | 699 | * @param - dir (string) - Path of the directory |
| 699 | 700 | * whe the file should be added |
| 700 | 701 | * @param - max_dir_space (int) - maximum size of the diretory in byte |
| 702 | + * @param string $dir |
|
| 703 | + * @param integer $max_dir_space |
|
| 701 | 704 | * @return - boolean true if there is enough space, |
| 702 | 705 | * boolean false otherwise |
| 703 | 706 | * |
@@ -1022,7 +1025,7 @@ discard block |
||
| 1022 | 1025 | * @param array $courseInfo |
| 1023 | 1026 | * @param array $userInfo |
| 1024 | 1027 | * @param array $uploaded_file - follows the $_FILES Structure |
| 1025 | - * @param string $upload_path - destination of the upload. |
|
| 1028 | + * @param string $uploadPath - destination of the upload. |
|
| 1026 | 1029 | * This path is to append to $base_work_dir |
| 1027 | 1030 | * @param string $base_work_dir - base working directory of the module |
| 1028 | 1031 | * @param int $maxFilledSpace - amount of bytes to not exceed in the base |
@@ -1201,7 +1204,7 @@ discard block |
||
| 1201 | 1204 | * @param bool $save_visibility |
| 1202 | 1205 | * @param int $group_id |
| 1203 | 1206 | * @param int $session_id Session ID, if any |
| 1204 | - * @return int id if inserted document |
|
| 1207 | + * @return string|false id if inserted document |
|
| 1205 | 1208 | */ |
| 1206 | 1209 | function add_document( |
| 1207 | 1210 | $_course, |
@@ -1337,7 +1340,7 @@ discard block |
||
| 1337 | 1340 | * |
| 1338 | 1341 | * @author Olivier Cauberghe <[email protected]> |
| 1339 | 1342 | * @param path+filename eg: /main/document/document.php |
| 1340 | - * @return The directory depth |
|
| 1343 | + * @return integer directory depth |
|
| 1341 | 1344 | */ |
| 1342 | 1345 | function get_levels($filename) { |
| 1343 | 1346 | $levels = explode('/', $filename); |
@@ -1354,6 +1357,7 @@ discard block |
||
| 1354 | 1357 | * @author Olivier Cauberghe <[email protected]> |
| 1355 | 1358 | * @param path,filename |
| 1356 | 1359 | * action: Adds an entry to the document table with the default settings. |
| 1360 | + * @param string $upload_path |
|
| 1357 | 1361 | */ |
| 1358 | 1362 | function set_default_settings($upload_path, $filename, $filetype = 'file') |
| 1359 | 1363 | { |
@@ -1778,6 +1782,7 @@ discard block |
||
| 1778 | 1782 | |
| 1779 | 1783 | @author Roan Embrechts |
| 1780 | 1784 | @version 0.6 |
| 1785 | + * @param string $buffer |
|
| 1781 | 1786 | */ |
| 1782 | 1787 | function api_replace_links_in_string($upload_path, $buffer) { |
| 1783 | 1788 | // Search for hyperlinks |
@@ -2013,7 +2018,6 @@ discard block |
||
| 2013 | 2018 | * @param int $groupId |
| 2014 | 2019 | * @param bool $output |
| 2015 | 2020 | * @param array $parent |
| 2016 | - * @param string $uploadPath |
|
| 2017 | 2021 | * |
| 2018 | 2022 | */ |
| 2019 | 2023 | function add_all_documents_in_folder_to_database( |
@@ -993,7 +993,9 @@ |
||
| 993 | 993 | if ($file != '.' && $file != '..') { |
| 994 | 994 | |
| 995 | 995 | $filetype = 'file'; |
| 996 | - if (is_dir($base_work_dir.$upload_path.'/'.$file)) $filetype = 'folder'; |
|
| 996 | + if (is_dir($base_work_dir.$upload_path.'/'.$file)) { |
|
| 997 | + $filetype = 'folder'; |
|
| 998 | + } |
|
| 997 | 999 | |
| 998 | 1000 | $safe_file = api_replace_dangerous_char($file, 'strict'); |
| 999 | 1001 | @rename($base_work_dir.$upload_path.'/'.$file,$base_work_dir.$upload_path.'/'.$safe_file); |
@@ -63,10 +63,10 @@ discard block |
||
| 63 | 63 | $name_no_ext = substr($name, 0, strlen($name) - strlen(strstr($name, $ext))); |
| 64 | 64 | $n = 0; |
| 65 | 65 | $unique = ''; |
| 66 | - while (file_exists($path . $name_no_ext . $unique . $ext)) { |
|
| 67 | - $unique = '_' . ++$n; |
|
| 66 | + while (file_exists($path.$name_no_ext.$unique.$ext)) { |
|
| 67 | + $unique = '_'.++$n; |
|
| 68 | 68 | } |
| 69 | - return $name_no_ext . $unique . $ext; |
|
| 69 | + return $name_no_ext.$unique.$ext; |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | /** |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | // Not used at the moment, but could be handy if we want to limit the size of an upload (e.g. image upload in html editor). |
| 106 | 106 | $max_file_size = intval($_POST['MAX_FILE_SIZE']); |
| 107 | 107 | if ($show_output) { |
| 108 | - Display::display_error_message(get_lang('UplExceedMaxPostSize'). format_file_size($max_file_size)); |
|
| 108 | + Display::display_error_message(get_lang('UplExceedMaxPostSize').format_file_size($max_file_size)); |
|
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | return false; |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | case 4: |
| 120 | 120 | // No file was uploaded. |
| 121 | 121 | if ($show_output) { |
| 122 | - Display::display_error_message(get_lang('UplNoFileUploaded').' '. get_lang('UplSelectFileFirst')); |
|
| 122 | + Display::display_error_message(get_lang('UplNoFileUploaded').' '.get_lang('UplSelectFileFirst')); |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | return false; |
@@ -460,7 +460,7 @@ discard block |
||
| 460 | 460 | if ($output) { |
| 461 | 461 | Display::addFlash( |
| 462 | 462 | Display::return_message( |
| 463 | - get_lang('UplUploadSucceeded') . '<br /> ' . $documentTitle . ' ' . get_lang('UplFileOverwritten'), |
|
| 463 | + get_lang('UplUploadSucceeded').'<br /> '.$documentTitle.' '.get_lang('UplFileOverwritten'), |
|
| 464 | 464 | 'confirmation', |
| 465 | 465 | false |
| 466 | 466 | ) |
@@ -600,7 +600,7 @@ discard block |
||
| 600 | 600 | |
| 601 | 601 | Display::addFlash( |
| 602 | 602 | Display::return_message( |
| 603 | - get_lang('UplUploadSucceeded') . '<br />' . get_lang('UplFileSavedAs') .' '.$documentTitle, |
|
| 603 | + get_lang('UplUploadSucceeded').'<br />'.get_lang('UplFileSavedAs').' '.$documentTitle, |
|
| 604 | 604 | 'confirmation', |
| 605 | 605 | false |
| 606 | 606 | ) |
@@ -770,12 +770,12 @@ discard block |
||
| 770 | 770 | function dir_total_space($dir_path) |
| 771 | 771 | { |
| 772 | 772 | $save_dir = getcwd(); |
| 773 | - chdir($dir_path) ; |
|
| 773 | + chdir($dir_path); |
|
| 774 | 774 | $handle = opendir($dir_path); |
| 775 | 775 | $sumSize = 0; |
| 776 | 776 | $dirList = array(); |
| 777 | 777 | while ($element = readdir($handle)) { |
| 778 | - if ( $element == '.' || $element == '..') { |
|
| 778 | + if ($element == '.' || $element == '..') { |
|
| 779 | 779 | continue; // Skip the current and parent directories |
| 780 | 780 | } |
| 781 | 781 | if (is_file($element)) { |
@@ -786,11 +786,11 @@ discard block |
||
| 786 | 786 | } |
| 787 | 787 | } |
| 788 | 788 | |
| 789 | - closedir($handle) ; |
|
| 789 | + closedir($handle); |
|
| 790 | 790 | |
| 791 | 791 | if (sizeof($dirList) > 0) { |
| 792 | 792 | foreach ($dirList as $j) { |
| 793 | - $sizeDir = dir_total_space($j); // Recursivity |
|
| 793 | + $sizeDir = dir_total_space($j); // Recursivity |
|
| 794 | 794 | $sumSize += $sizeDir; |
| 795 | 795 | } |
| 796 | 796 | } |
@@ -824,63 +824,63 @@ discard block |
||
| 824 | 824 | |
| 825 | 825 | static $mime_type = array(); |
| 826 | 826 | |
| 827 | - $mime_type[] = 'application/msword'; $extension[] = '.doc'; |
|
| 828 | - $mime_type[] = 'application/rtf'; $extension[] = '.rtf'; |
|
| 829 | - $mime_type[] = 'application/vnd.ms-powerpoint'; $extension[] = '.ppt'; |
|
| 830 | - $mime_type[] = 'application/vnd.ms-excel'; $extension[] = '.xls'; |
|
| 831 | - $mime_type[] = 'application/pdf'; $extension[] = '.pdf'; |
|
| 832 | - $mime_type[] = 'application/postscript'; $extension[] = '.ps'; |
|
| 833 | - $mime_type[] = 'application/mac-binhex40'; $extension[] = '.hqx'; |
|
| 834 | - $mime_type[] = 'application/x-gzip'; $extension[] = 'tar.gz'; |
|
| 835 | - $mime_type[] = 'application/x-shockwave-flash'; $extension[] = '.swf'; |
|
| 836 | - $mime_type[] = 'application/x-stuffit'; $extension[] = '.sit'; |
|
| 837 | - $mime_type[] = 'application/x-tar'; $extension[] = '.tar'; |
|
| 838 | - $mime_type[] = 'application/zip'; $extension[] = '.zip'; |
|
| 839 | - $mime_type[] = 'application/x-tar'; $extension[] = '.tar'; |
|
| 840 | - $mime_type[] = 'text/html'; $extension[] = '.html'; |
|
| 841 | - $mime_type[] = 'text/plain'; $extension[] = '.txt'; |
|
| 842 | - $mime_type[] = 'text/rtf'; $extension[] = '.rtf'; |
|
| 843 | - $mime_type[] = 'img/gif'; $extension[] = '.gif'; |
|
| 844 | - $mime_type[] = 'img/jpeg'; $extension[] = '.jpg'; |
|
| 845 | - $mime_type[] = 'img/png'; $extension[] = '.png'; |
|
| 846 | - $mime_type[] = 'audio/midi'; $extension[] = '.mid'; |
|
| 847 | - $mime_type[] = 'audio/mpeg'; $extension[] = '.mp3'; |
|
| 848 | - $mime_type[] = 'audio/x-aiff'; $extension[] = '.aif'; |
|
| 849 | - $mime_type[] = 'audio/x-pn-realaudio'; $extension[] = '.rm'; |
|
| 850 | - $mime_type[] = 'audio/x-pn-realaudio-plugin'; $extension[] = '.rpm'; |
|
| 851 | - $mime_type[] = 'audio/x-wav'; $extension[] = '.wav'; |
|
| 852 | - $mime_type[] = 'video/mpeg'; $extension[] = '.mpg'; |
|
| 853 | - $mime_type[] = 'video/mpeg4-generic'; $extension[] = '.mp4'; |
|
| 854 | - $mime_type[] = 'video/quicktime'; $extension[] = '.mov'; |
|
| 855 | - $mime_type[] = 'video/x-msvideo'; $extension[] = '.avi'; |
|
| 856 | - |
|
| 857 | - $mime_type[] = 'video/x-ms-wmv'; $extension[] = '.wmv'; |
|
| 858 | - $mime_type[] = 'video/x-flv'; $extension[] = '.flv'; |
|
| 859 | - $mime_type[] = 'image/svg+xml'; $extension[] = '.svg'; |
|
| 860 | - $mime_type[] = 'image/svg+xml'; $extension[] = '.svgz'; |
|
| 861 | - $mime_type[] = 'video/ogg'; $extension[] = '.ogv'; |
|
| 862 | - $mime_type[] = 'audio/ogg'; $extension[] = '.oga'; |
|
| 863 | - $mime_type[] = 'application/ogg'; $extension[] = '.ogg'; |
|
| 864 | - $mime_type[] = 'application/ogg'; $extension[] = '.ogx'; |
|
| 865 | - $mime_type[] = 'application/x-freemind'; $extension[] = '.mm'; |
|
| 866 | - |
|
| 867 | - $mime_type[] = 'application/vnd.ms-word.document.macroEnabled.12'; $extension[] = '.docm'; |
|
| 868 | - $mime_type[] = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'; $extension[] = '.docx'; |
|
| 869 | - $mime_type[] = 'application/vnd.ms-word.template.macroEnabled.12'; $extension[] = '.dotm'; |
|
| 870 | - $mime_type[] = 'application/vnd.openxmlformats-officedocument.wordprocessingml.template'; $extension[] = '.dotx'; |
|
| 871 | - $mime_type[] = 'application/vnd.ms-powerpoint.template.macroEnabled.12'; $extension[] = '.potm'; |
|
| 872 | - $mime_type[] = 'application/vnd.openxmlformats-officedocument.presentationml.template'; $extension[] = '.potx'; |
|
| 873 | - $mime_type[] = 'application/vnd.ms-powerpoint.addin.macroEnabled.12'; $extension[] = '.ppam'; |
|
| 874 | - $mime_type[] = 'application/vnd.ms-powerpoint.slideshow.macroEnabled.12'; $extension[] = '.ppsm'; |
|
| 875 | - $mime_type[] = 'application/vnd.openxmlformats-officedocument.presentationml.slideshow'; $extension[] = '.ppsx'; |
|
| 876 | - $mime_type[] = 'application/vnd.ms-powerpoint.presentation.macroEnabled.12'; $extension[] = '.pptm'; |
|
| 877 | - $mime_type[] = 'application/vnd.openxmlformats-officedocument.presentationml.presentation'; $extension[] = '.pptx'; |
|
| 878 | - $mime_type[] = 'application/vnd.ms-excel.addin.macroEnabled.12'; $extension[] = '.xlam'; |
|
| 879 | - $mime_type[] = 'application/vnd.ms-excel.sheet.binary.macroEnabled.12'; $extension[] = '.xlsb'; |
|
| 880 | - $mime_type[] = 'application/vnd.ms-excel.sheet.macroEnabled.12'; $extension[] = '.xlsm'; |
|
| 881 | - $mime_type[] = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'; $extension[] = '.xlsx'; |
|
| 882 | - $mime_type[] = 'application/vnd.ms-excel.template.macroEnabled.12'; $extension[] = '.xltm'; |
|
| 883 | - $mime_type[] = 'application/vnd.openxmlformats-officedocument.spreadsheetml.template'; $extension[] = '.xltx'; |
|
| 827 | + $mime_type[] = 'application/msword'; $extension[] = '.doc'; |
|
| 828 | + $mime_type[] = 'application/rtf'; $extension[] = '.rtf'; |
|
| 829 | + $mime_type[] = 'application/vnd.ms-powerpoint'; $extension[] = '.ppt'; |
|
| 830 | + $mime_type[] = 'application/vnd.ms-excel'; $extension[] = '.xls'; |
|
| 831 | + $mime_type[] = 'application/pdf'; $extension[] = '.pdf'; |
|
| 832 | + $mime_type[] = 'application/postscript'; $extension[] = '.ps'; |
|
| 833 | + $mime_type[] = 'application/mac-binhex40'; $extension[] = '.hqx'; |
|
| 834 | + $mime_type[] = 'application/x-gzip'; $extension[] = 'tar.gz'; |
|
| 835 | + $mime_type[] = 'application/x-shockwave-flash'; $extension[] = '.swf'; |
|
| 836 | + $mime_type[] = 'application/x-stuffit'; $extension[] = '.sit'; |
|
| 837 | + $mime_type[] = 'application/x-tar'; $extension[] = '.tar'; |
|
| 838 | + $mime_type[] = 'application/zip'; $extension[] = '.zip'; |
|
| 839 | + $mime_type[] = 'application/x-tar'; $extension[] = '.tar'; |
|
| 840 | + $mime_type[] = 'text/html'; $extension[] = '.html'; |
|
| 841 | + $mime_type[] = 'text/plain'; $extension[] = '.txt'; |
|
| 842 | + $mime_type[] = 'text/rtf'; $extension[] = '.rtf'; |
|
| 843 | + $mime_type[] = 'img/gif'; $extension[] = '.gif'; |
|
| 844 | + $mime_type[] = 'img/jpeg'; $extension[] = '.jpg'; |
|
| 845 | + $mime_type[] = 'img/png'; $extension[] = '.png'; |
|
| 846 | + $mime_type[] = 'audio/midi'; $extension[] = '.mid'; |
|
| 847 | + $mime_type[] = 'audio/mpeg'; $extension[] = '.mp3'; |
|
| 848 | + $mime_type[] = 'audio/x-aiff'; $extension[] = '.aif'; |
|
| 849 | + $mime_type[] = 'audio/x-pn-realaudio'; $extension[] = '.rm'; |
|
| 850 | + $mime_type[] = 'audio/x-pn-realaudio-plugin'; $extension[] = '.rpm'; |
|
| 851 | + $mime_type[] = 'audio/x-wav'; $extension[] = '.wav'; |
|
| 852 | + $mime_type[] = 'video/mpeg'; $extension[] = '.mpg'; |
|
| 853 | + $mime_type[] = 'video/mpeg4-generic'; $extension[] = '.mp4'; |
|
| 854 | + $mime_type[] = 'video/quicktime'; $extension[] = '.mov'; |
|
| 855 | + $mime_type[] = 'video/x-msvideo'; $extension[] = '.avi'; |
|
| 856 | + |
|
| 857 | + $mime_type[] = 'video/x-ms-wmv'; $extension[] = '.wmv'; |
|
| 858 | + $mime_type[] = 'video/x-flv'; $extension[] = '.flv'; |
|
| 859 | + $mime_type[] = 'image/svg+xml'; $extension[] = '.svg'; |
|
| 860 | + $mime_type[] = 'image/svg+xml'; $extension[] = '.svgz'; |
|
| 861 | + $mime_type[] = 'video/ogg'; $extension[] = '.ogv'; |
|
| 862 | + $mime_type[] = 'audio/ogg'; $extension[] = '.oga'; |
|
| 863 | + $mime_type[] = 'application/ogg'; $extension[] = '.ogg'; |
|
| 864 | + $mime_type[] = 'application/ogg'; $extension[] = '.ogx'; |
|
| 865 | + $mime_type[] = 'application/x-freemind'; $extension[] = '.mm'; |
|
| 866 | + |
|
| 867 | + $mime_type[] = 'application/vnd.ms-word.document.macroEnabled.12'; $extension[] = '.docm'; |
|
| 868 | + $mime_type[] = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'; $extension[] = '.docx'; |
|
| 869 | + $mime_type[] = 'application/vnd.ms-word.template.macroEnabled.12'; $extension[] = '.dotm'; |
|
| 870 | + $mime_type[] = 'application/vnd.openxmlformats-officedocument.wordprocessingml.template'; $extension[] = '.dotx'; |
|
| 871 | + $mime_type[] = 'application/vnd.ms-powerpoint.template.macroEnabled.12'; $extension[] = '.potm'; |
|
| 872 | + $mime_type[] = 'application/vnd.openxmlformats-officedocument.presentationml.template'; $extension[] = '.potx'; |
|
| 873 | + $mime_type[] = 'application/vnd.ms-powerpoint.addin.macroEnabled.12'; $extension[] = '.ppam'; |
|
| 874 | + $mime_type[] = 'application/vnd.ms-powerpoint.slideshow.macroEnabled.12'; $extension[] = '.ppsm'; |
|
| 875 | + $mime_type[] = 'application/vnd.openxmlformats-officedocument.presentationml.slideshow'; $extension[] = '.ppsx'; |
|
| 876 | + $mime_type[] = 'application/vnd.ms-powerpoint.presentation.macroEnabled.12'; $extension[] = '.pptm'; |
|
| 877 | + $mime_type[] = 'application/vnd.openxmlformats-officedocument.presentationml.presentation'; $extension[] = '.pptx'; |
|
| 878 | + $mime_type[] = 'application/vnd.ms-excel.addin.macroEnabled.12'; $extension[] = '.xlam'; |
|
| 879 | + $mime_type[] = 'application/vnd.ms-excel.sheet.binary.macroEnabled.12'; $extension[] = '.xlsb'; |
|
| 880 | + $mime_type[] = 'application/vnd.ms-excel.sheet.macroEnabled.12'; $extension[] = '.xlsm'; |
|
| 881 | + $mime_type[] = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'; $extension[] = '.xlsx'; |
|
| 882 | + $mime_type[] = 'application/vnd.ms-excel.template.macroEnabled.12'; $extension[] = '.xltm'; |
|
| 883 | + $mime_type[] = 'application/vnd.openxmlformats-officedocument.spreadsheetml.template'; $extension[] = '.xltx'; |
|
| 884 | 884 | |
| 885 | 885 | // Test on PC (files with no extension get application/octet-stream) |
| 886 | 886 | //$mime_type[] = 'application/octet-stream'; $extension[] = '.ext'; |
@@ -889,7 +889,7 @@ discard block |
||
| 889 | 889 | |
| 890 | 890 | foreach ($mime_type as $key => & $type) { |
| 891 | 891 | if ($type == $file_type) { |
| 892 | - $file_name .= $extension[$key]; |
|
| 892 | + $file_name .= $extension[$key]; |
|
| 893 | 893 | break; |
| 894 | 894 | } |
| 895 | 895 | } |
@@ -997,12 +997,12 @@ discard block |
||
| 997 | 997 | } |
| 998 | 998 | |
| 999 | 999 | // It happens on Linux that $upload_path sometimes doesn't start with '/' |
| 1000 | - if ($upload_path[0] != '/' && substr($base_work_dir,-1,1) != '/') { |
|
| 1000 | + if ($upload_path[0] != '/' && substr($base_work_dir, -1, 1) != '/') { |
|
| 1001 | 1001 | $upload_path = '/'.$upload_path; |
| 1002 | 1002 | } |
| 1003 | 1003 | |
| 1004 | 1004 | if ($upload_path[strlen($upload_path) - 1] == '/') { |
| 1005 | - $upload_path=substr($upload_path, 0, -1); |
|
| 1005 | + $upload_path = substr($upload_path, 0, -1); |
|
| 1006 | 1006 | } |
| 1007 | 1007 | |
| 1008 | 1008 | /* Uncompressing phase */ |
@@ -1014,15 +1014,15 @@ discard block |
||
| 1014 | 1014 | - add it to the database |
| 1015 | 1015 | - parse & change relative html links |
| 1016 | 1016 | */ |
| 1017 | - if (PHP_OS == 'Linux' && ! get_cfg_var('safe_mode') && false) { // *** UGent, changed by OC *** |
|
| 1017 | + if (PHP_OS == 'Linux' && !get_cfg_var('safe_mode') && false) { // *** UGent, changed by OC *** |
|
| 1018 | 1018 | // Shell Method - if this is possible, it gains some speed |
| 1019 | - exec("unzip -d \"".$base_work_dir.$upload_path."/\"".$uploaded_file['name']." " .$uploaded_file['tmp_name']); |
|
| 1019 | + exec("unzip -d \"".$base_work_dir.$upload_path."/\"".$uploaded_file['name']." ".$uploaded_file['tmp_name']); |
|
| 1020 | 1020 | } else { |
| 1021 | 1021 | // PHP method - slower... |
| 1022 | 1022 | $save_dir = getcwd(); |
| 1023 | 1023 | chdir($base_work_dir.$upload_path); |
| 1024 | 1024 | $unzippingState = $zip_file->extract(); |
| 1025 | - for ($j=0; $j < count($unzippingState); $j++) { |
|
| 1025 | + for ($j = 0; $j < count($unzippingState); $j++) { |
|
| 1026 | 1026 | $state = $unzippingState[$j]; |
| 1027 | 1027 | |
| 1028 | 1028 | // Fix relative links in html files |
@@ -1036,8 +1036,8 @@ discard block |
||
| 1036 | 1036 | if (is_dir($base_work_dir.$upload_path.'/'.$file)) $filetype = 'folder'; |
| 1037 | 1037 | |
| 1038 | 1038 | $safe_file = api_replace_dangerous_char($file, 'strict'); |
| 1039 | - @rename($base_work_dir.$upload_path.'/'.$file,$base_work_dir.$upload_path.'/'.$safe_file); |
|
| 1040 | - set_default_settings($upload_path, $safe_file,$filetype); |
|
| 1039 | + @rename($base_work_dir.$upload_path.'/'.$file, $base_work_dir.$upload_path.'/'.$safe_file); |
|
| 1040 | + set_default_settings($upload_path, $safe_file, $filetype); |
|
| 1041 | 1041 | } |
| 1042 | 1042 | } |
| 1043 | 1043 | |
@@ -1087,7 +1087,7 @@ discard block |
||
| 1087 | 1087 | $zip = new PclZip($uploaded_file['tmp_name']); |
| 1088 | 1088 | |
| 1089 | 1089 | // Check the zip content (real size and file extension) |
| 1090 | - $zip_content_array = (array)$zip->listContent(); |
|
| 1090 | + $zip_content_array = (array) $zip->listContent(); |
|
| 1091 | 1091 | |
| 1092 | 1092 | $realSize = 0; |
| 1093 | 1093 | foreach ($zip_content_array as & $this_content) { |
@@ -1183,7 +1183,7 @@ discard block |
||
| 1183 | 1183 | function filter_extension(&$filename) |
| 1184 | 1184 | { |
| 1185 | 1185 | if (substr($filename, -1) == '/') { |
| 1186 | - return 1; // Authorize directories |
|
| 1186 | + return 1; // Authorize directories |
|
| 1187 | 1187 | } |
| 1188 | 1188 | $blacklist = api_get_setting('upload_extensions_list_type'); |
| 1189 | 1189 | if ($blacklist != 'whitelist') { // if = blacklist |
@@ -1409,9 +1409,9 @@ discard block |
||
| 1409 | 1409 | $upload_path = str_replace('//', '/', $upload_path); |
| 1410 | 1410 | |
| 1411 | 1411 | if ($upload_path == '/') { |
| 1412 | - $upload_path=''; |
|
| 1412 | + $upload_path = ''; |
|
| 1413 | 1413 | } elseif (!empty($upload_path) && $upload_path[0] != '/') { |
| 1414 | - $upload_path="/$upload_path"; |
|
| 1414 | + $upload_path = "/$upload_path"; |
|
| 1415 | 1415 | } |
| 1416 | 1416 | |
| 1417 | 1417 | $endchar = substr($filename, strlen($filename) - 1, 1); |
@@ -1449,7 +1449,7 @@ discard block |
||
| 1449 | 1449 | $img_path_list = array(); |
| 1450 | 1450 | |
| 1451 | 1451 | if (!$fp = fopen($html_file, 'r')) { |
| 1452 | - return ; |
|
| 1452 | + return; |
|
| 1453 | 1453 | } |
| 1454 | 1454 | |
| 1455 | 1455 | // Aearch and store occurences of the <img> tag in an array |
@@ -1469,7 +1469,7 @@ discard block |
||
| 1469 | 1469 | $img_tag_list = $matches[0]; |
| 1470 | 1470 | } |
| 1471 | 1471 | |
| 1472 | - fclose ($fp); |
|
| 1472 | + fclose($fp); |
|
| 1473 | 1473 | unset($buffer); |
| 1474 | 1474 | |
| 1475 | 1475 | // Search the image file path from all the <IMG> tag detected |
@@ -1569,7 +1569,7 @@ discard block |
||
| 1569 | 1569 | |
| 1570 | 1570 | if (!is_dir($base_work_dir.$systemFolderName)) { |
| 1571 | 1571 | $result = mkdir( |
| 1572 | - $base_work_dir . $systemFolderName, |
|
| 1572 | + $base_work_dir.$systemFolderName, |
|
| 1573 | 1573 | api_get_permissions_for_new_directories(), |
| 1574 | 1574 | true |
| 1575 | 1575 | ); |
@@ -1582,7 +1582,7 @@ discard block |
||
| 1582 | 1582 | WHERE |
| 1583 | 1583 | c_id = $course_id AND |
| 1584 | 1584 | ( |
| 1585 | - path = '" . Database::escape_string($systemFolderName). "' |
|
| 1585 | + path = '".Database::escape_string($systemFolderName)."' |
|
| 1586 | 1586 | ) |
| 1587 | 1587 | "; |
| 1588 | 1588 | |
@@ -1733,7 +1733,7 @@ discard block |
||
| 1733 | 1733 | |
| 1734 | 1734 | // Fix the image tags |
| 1735 | 1735 | |
| 1736 | - for ($i = 0, $fileNb = count($original_img_path); $i < $fileNb ; $i++) { |
|
| 1736 | + for ($i = 0, $fileNb = count($original_img_path); $i < $fileNb; $i++) { |
|
| 1737 | 1737 | $replace_what = $original_img_path[$i]; |
| 1738 | 1738 | // We only need the directory and the filename /path/to/file_html_files/missing_file.gif -> file_html_files/missing_file.gif |
| 1739 | 1739 | $exploded_file_path = explode('/', $new_img_path[$i]); |
@@ -1774,7 +1774,7 @@ discard block |
||
| 1774 | 1774 | .'</body>' |
| 1775 | 1775 | .'</html>'; |
| 1776 | 1776 | if (file_exists($file_path)) { |
| 1777 | - if (!($fp = fopen ($file_path, 'w'))) { |
|
| 1777 | + if (!($fp = fopen($file_path, 'w'))) { |
|
| 1778 | 1778 | return false; |
| 1779 | 1779 | } |
| 1780 | 1780 | return fwrite($fp, $file_content); |
@@ -1794,7 +1794,7 @@ discard block |
||
| 1794 | 1794 | // Open the file |
| 1795 | 1795 | if (file_exists($full_file_name)) { |
| 1796 | 1796 | $fp = fopen($full_file_name, 'r'); |
| 1797 | - $buffer = fread ($fp, filesize ($full_file_name)); |
|
| 1797 | + $buffer = fread($fp, filesize($full_file_name)); |
|
| 1798 | 1798 | |
| 1799 | 1799 | // Parse the contents |
| 1800 | 1800 | $new_html_content = api_replace_links_in_string($upload_path, $buffer); |
@@ -1937,7 +1937,7 @@ discard block |
||
| 1937 | 1937 | |
| 1938 | 1938 | foreach ($tag_list as & $this_tag) { |
| 1939 | 1939 | //Display::display_normal_message(htmlentities($this_tag)); //debug |
| 1940 | - if ( preg_match("~".$param_name."[\s]*=[\s]*[\"]{1}([^\"]+)[\"]{1}~i", $this_tag, $matches)) { |
|
| 1940 | + if (preg_match("~".$param_name."[\s]*=[\s]*[\"]{1}([^\"]+)[\"]{1}~i", $this_tag, $matches)) { |
|
| 1941 | 1941 | $file_path_list[] = $matches[1]; // older |
| 1942 | 1942 | $href_list[] = $matches[0]; // to also add target="_self" |
| 1943 | 1943 | } |
@@ -1958,9 +1958,9 @@ discard block |
||
| 1958 | 1958 | |
| 1959 | 1959 | // Fix the link to use download.php or showinframes.php |
| 1960 | 1960 | if (preg_match("/<a([\s]*[\"\/:'=a-z0-9]*){5}href[^<]*>/i", $tag_list[$count])) { |
| 1961 | - $replace_by[$count] = " $param_name =\"showinframes.php?file=" . $upload_path.$file_path_list[$count]."\" target=\"_self\" "; |
|
| 1961 | + $replace_by[$count] = " $param_name =\"showinframes.php?file=".$upload_path.$file_path_list[$count]."\" target=\"_self\" "; |
|
| 1962 | 1962 | } else { |
| 1963 | - $replace_by[$count] = " $param_name =\"download.php?doc_url=" . $upload_path.$file_path_list[$count]."\" "; |
|
| 1963 | + $replace_by[$count] = " $param_name =\"download.php?doc_url=".$upload_path.$file_path_list[$count]."\" "; |
|
| 1964 | 1964 | } |
| 1965 | 1965 | } else { |
| 1966 | 1966 | // "mailto" or url already fixed, leave as is |
@@ -1969,7 +1969,7 @@ discard block |
||
| 1969 | 1969 | } |
| 1970 | 1970 | } elseif ($is_absolute_hyperlink) { |
| 1971 | 1971 | //$message .= "Absolute hyperlink, don't change, add target=_self: "; |
| 1972 | - $replace_by[$count] = " $param_name=\"" . $file_path_list[$count] . "\" target =\"_self\""; |
|
| 1972 | + $replace_by[$count] = " $param_name=\"".$file_path_list[$count]."\" target =\"_self\""; |
|
| 1973 | 1973 | } else { |
| 1974 | 1974 | // Don't change anything |
| 1975 | 1975 | //$message .= "Local anchor, don't change: "; |
@@ -2014,7 +2014,7 @@ discard block |
||
| 2014 | 2014 | { |
| 2015 | 2015 | // Do we need a / or not? |
| 2016 | 2016 | $added_slash = ($upload_path == '/') ? '' : '/'; |
| 2017 | - $folder_id = DocumentManager::get_document_id(api_get_course_info(), $upload_path); |
|
| 2017 | + $folder_id = DocumentManager::get_document_id(api_get_course_info(), $upload_path); |
|
| 2018 | 2018 | // Build the form |
| 2019 | 2019 | $form = "<p><strong>".get_lang('MissingImagesDetected')."</strong></p>" |
| 2020 | 2020 | ."<form method=\"post\" action=\"".api_get_self()."\" enctype=\"multipart/form-data\">" |
@@ -2110,7 +2110,7 @@ |
||
| 2110 | 2110 | $newFolderData = DocumentManager::get_document_data_by_id($documentId, $courseInfo, false, $sessionId); |
| 2111 | 2111 | } |
| 2112 | 2112 | } else { |
| 2113 | - $newFolderData = create_unexisting_directory( |
|
| 2113 | + $newFolderData = create_unexisting_directory( |
|
| 2114 | 2114 | $courseInfo, |
| 2115 | 2115 | $userId, |
| 2116 | 2116 | $sessionId, |
@@ -145,6 +145,7 @@ |
||
| 145 | 145 | |
| 146 | 146 | /** |
| 147 | 147 | * @param array $dates result of parseDateRange() |
| 148 | + * @param string $format |
|
| 148 | 149 | * |
| 149 | 150 | * @return bool |
| 150 | 151 | */ |
@@ -7,8 +7,8 @@ discard block |
||
| 7 | 7 | class DateRangePicker extends HTML_QuickForm_text |
| 8 | 8 | { |
| 9 | 9 | /** |
| 10 | - * Constructor |
|
| 11 | - */ |
|
| 10 | + * Constructor |
|
| 11 | + */ |
|
| 12 | 12 | public function __construct($elementName = null, $elementLabel = null, $attributes = null) |
| 13 | 13 | { |
| 14 | 14 | if (!isset($attributes['id'])) { |
@@ -144,10 +144,10 @@ discard block |
||
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | /** |
| 147 | - * @param array $dates result of parseDateRange() |
|
| 148 | - * |
|
| 149 | - * @return bool |
|
| 150 | - */ |
|
| 147 | + * @param array $dates result of parseDateRange() |
|
| 148 | + * |
|
| 149 | + * @return bool |
|
| 150 | + */ |
|
| 151 | 151 | public function validateDates($dates, $format = null) |
| 152 | 152 | { |
| 153 | 153 | if (empty($dates['start']) || empty($dates['end'])) { |
@@ -88,7 +88,7 @@ |
||
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | $timePicker = 'true'; |
| 91 | - $timePickerValue = $this->getAttribute('timePicker'); |
|
| 91 | + $timePickerValue = $this->getAttribute('timePicker'); |
|
| 92 | 92 | if (!empty($timePickerValue)) { |
| 93 | 93 | $timePicker = $timePickerValue; |
| 94 | 94 | } |
@@ -213,7 +213,7 @@ discard block |
||
| 213 | 213 | * @param string $label |
| 214 | 214 | * @param array $attributes |
| 215 | 215 | * |
| 216 | - * @return mixed |
|
| 216 | + * @return HTML_QuickForm_element |
|
| 217 | 217 | */ |
| 218 | 218 | public function addDatePicker($name, $label, $attributes = []) |
| 219 | 219 | { |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | * @param string $label |
| 226 | 226 | * @param array $attributes |
| 227 | 227 | * |
| 228 | - * @return mixed |
|
| 228 | + * @return HTML_QuickForm_element |
|
| 229 | 229 | */ |
| 230 | 230 | public function addDateTimePicker($name, $label, $attributes = []) |
| 231 | 231 | { |
@@ -688,7 +688,7 @@ discard block |
||
| 688 | 688 | * @param array $options |
| 689 | 689 | * @param array $attributes |
| 690 | 690 | * |
| 691 | - * @return HTML_QuickForm_radio |
|
| 691 | + * @return HTML_QuickForm_group |
|
| 692 | 692 | */ |
| 693 | 693 | public function addRadio($name, $label, $options = array(), $attributes = array()) |
| 694 | 694 | { |
@@ -817,7 +817,7 @@ discard block |
||
| 817 | 817 | * @param string $name |
| 818 | 818 | * @param string $label |
| 819 | 819 | * |
| 820 | - * @return mixed |
|
| 820 | + * @return HTML_QuickForm_element |
|
| 821 | 821 | */ |
| 822 | 822 | public function addButtonAdvancedSettings($name, $label = '') |
| 823 | 823 | { |
@@ -914,7 +914,7 @@ discard block |
||
| 914 | 914 | /** |
| 915 | 915 | * This function has been created for avoiding changes directly within QuickForm class. |
| 916 | 916 | * When we use it, the element is threated as 'required' to be dealt during validation. |
| 917 | - * @param array $element The array of elements |
|
| 917 | + * @param array $elements The array of elements |
|
| 918 | 918 | * @param string $message The message displayed |
| 919 | 919 | */ |
| 920 | 920 | public function add_multiple_required_rule($elements, $message) |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | $renderer->setHeaderTemplate('<legend>{header}</legend>'); |
| 102 | 102 | |
| 103 | 103 | //Set required field template |
| 104 | - $this->setRequiredNote('<span class="form_required">*</span> <small>' . get_lang('ThisFieldIsRequired') . '</small>'); |
|
| 104 | + $this->setRequiredNote('<span class="form_required">*</span> <small>'.get_lang('ThisFieldIsRequired').'</small>'); |
|
| 105 | 105 | $noteTemplate = <<<EOT |
| 106 | 106 | <div class="form-group"> |
| 107 | 107 | <div class="col-sm-offset-2 col-sm-10">{requiredNote}</div> |
@@ -853,9 +853,9 @@ discard block |
||
| 853 | 853 | $label = get_lang('PleaseStandBy'); |
| 854 | 854 | } |
| 855 | 855 | $this->with_progress_bar = true; |
| 856 | - $this->updateAttributes("onsubmit=\"javascript: myUpload.start('dynamic_div','".Display::returnIconPath('progress_bar.gif')."','" . $label . "','" . $this->getAttribute('id') . "')\""); |
|
| 857 | - $this->addElement('html', '<script language="javascript" src="' . api_get_path(WEB_LIBRARY_PATH) . 'javascript/upload.js" type="text/javascript"></script>'); |
|
| 858 | - $this->addElement('html', '<script type="text/javascript">var myUpload = new upload(' . (abs(intval($delay)) * 1000) . ');</script>'); |
|
| 856 | + $this->updateAttributes("onsubmit=\"javascript: myUpload.start('dynamic_div','".Display::returnIconPath('progress_bar.gif')."','".$label."','".$this->getAttribute('id')."')\""); |
|
| 857 | + $this->addElement('html', '<script language="javascript" src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/upload.js" type="text/javascript"></script>'); |
|
| 858 | + $this->addElement('html', '<script type="text/javascript">var myUpload = new upload('.(abs(intval($delay)) * 1000).');</script>'); |
|
| 859 | 859 | } |
| 860 | 860 | |
| 861 | 861 | /** |
@@ -872,11 +872,11 @@ discard block |
||
| 872 | 872 | return; |
| 873 | 873 | } |
| 874 | 874 | |
| 875 | - $xajax_upload = new xajax(api_get_path(WEB_LIBRARY_PATH) . 'upload.xajax.php'); |
|
| 875 | + $xajax_upload = new xajax(api_get_path(WEB_LIBRARY_PATH).'upload.xajax.php'); |
|
| 876 | 876 | |
| 877 | 877 | $xajax_upload->registerFunction('updateProgress'); |
| 878 | 878 | // IMPORTANT : must be the first element of the form |
| 879 | - $el = $this->insertElementBefore(FormValidator::createElement('html', '<input type="hidden" name="UPLOAD_IDENTIFIER" value="' . $upload_id . '" />'), $element_after); |
|
| 879 | + $el = $this->insertElementBefore(FormValidator::createElement('html', '<input type="hidden" name="UPLOAD_IDENTIFIER" value="'.$upload_id.'" />'), $element_after); |
|
| 880 | 880 | |
| 881 | 881 | $this->addElement('html', '<br />'); |
| 882 | 882 | |
@@ -884,7 +884,7 @@ discard block |
||
| 884 | 884 | $this->addElement( |
| 885 | 885 | 'html', |
| 886 | 886 | '<div id="dynamic_div_container" style="display:none"> |
| 887 | - <div id="dynamic_div_label">' . get_lang('UploadFile') . '</div> |
|
| 887 | + <div id="dynamic_div_label">' . get_lang('UploadFile').'</div> |
|
| 888 | 888 | <div id="dynamic_div_frame" style="width:214px; height:12px; border:1px solid grey; background-image:url(' . Display::returnIconPath('real_upload_frame.gif').');"> |
| 889 | 889 | <div id="dynamic_div_filled" style="width:0%;height:100%;background-image:url(' . Display::returnIconPath('real_upload_step.gif').');background-repeat:repeat-x;background-position:center;"></div> |
| 890 | 890 | </div> |
@@ -895,7 +895,7 @@ discard block |
||
| 895 | 895 | $this->addElement('html', ' |
| 896 | 896 | <div id="dynamic_div_waiter_container" style="display:none"> |
| 897 | 897 | <div id="dynamic_div_waiter_label"> |
| 898 | - ' . get_lang('SlideshowConversion') . ' |
|
| 898 | + ' . get_lang('SlideshowConversion').' |
|
| 899 | 899 | </div> |
| 900 | 900 | <div id="dynamic_div_waiter_frame"> |
| 901 | 901 | '.Display::return_icon('real_upload_frame.gif').' |
@@ -905,18 +905,18 @@ discard block |
||
| 905 | 905 | } |
| 906 | 906 | |
| 907 | 907 | // Get the xajax code |
| 908 | - $this->addElement('html', $xajax_upload->getJavascript(api_get_path(WEB_LIBRARY_PATH) . 'xajax')); |
|
| 908 | + $this->addElement('html', $xajax_upload->getJavascript(api_get_path(WEB_LIBRARY_PATH).'xajax')); |
|
| 909 | 909 | |
| 910 | 910 | // Get the upload code |
| 911 | - $this->addElement('html', '<script language="javascript" src="' . api_get_path(WEB_LIBRARY_PATH) . 'javascript/upload.js" type="text/javascript"></script>'); |
|
| 912 | - $this->addElement('html', '<script type="text/javascript">var myUpload = new upload(' . (abs(intval($delay)) * 1000) . ');</script>'); |
|
| 911 | + $this->addElement('html', '<script language="javascript" src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/upload.js" type="text/javascript"></script>'); |
|
| 912 | + $this->addElement('html', '<script type="text/javascript">var myUpload = new upload('.(abs(intval($delay)) * 1000).');</script>'); |
|
| 913 | 913 | |
| 914 | 914 | if (!$wait_after_upload) { |
| 915 | 915 | $wait_after_upload = 0; |
| 916 | 916 | } |
| 917 | 917 | |
| 918 | 918 | // Add the upload event |
| 919 | - $this->updateAttributes("onsubmit=\"javascript: myUpload.startRealUpload('dynamic_div','" . $upload_id . "','" . $this->getAttribute('id') . "'," . $wait_after_upload . ")\""); |
|
| 919 | + $this->updateAttributes("onsubmit=\"javascript: myUpload.startRealUpload('dynamic_div','".$upload_id."','".$this->getAttribute('id')."',".$wait_after_upload.")\""); |
|
| 920 | 920 | } |
| 921 | 921 | |
| 922 | 922 | /** |
@@ -1388,7 +1388,7 @@ discard block |
||
| 1388 | 1388 | .prepend(file.preview); |
| 1389 | 1389 | node |
| 1390 | 1390 | .append('<br>') |
| 1391 | - .append($('<span class=\"text-success\"/>').text('" . addslashes(get_lang('UplUploadSucceeded')). "')); |
|
| 1391 | + .append($('<span class=\"text-success\"/>').text('" . addslashes(get_lang('UplUploadSucceeded'))."')); |
|
| 1392 | 1392 | } |
| 1393 | 1393 | if (file.error) { |
| 1394 | 1394 | node |
@@ -1423,7 +1423,7 @@ discard block |
||
| 1423 | 1423 | }); |
| 1424 | 1424 | }).on('fileuploadfail', function (e, data) { |
| 1425 | 1425 | $.each(data.files, function (index) { |
| 1426 | - var failedMessage = '" . addslashes(get_lang('UplUploadFailed')) . "'; |
|
| 1426 | + var failedMessage = '" . addslashes(get_lang('UplUploadFailed'))."'; |
|
| 1427 | 1427 | var error = $('<span class=\"text-danger\"/>').text(failedMessage); |
| 1428 | 1428 | $(data.context.children()[index]) |
| 1429 | 1429 | .append('<br>') |
@@ -25,8 +25,7 @@ |
||
| 25 | 25 | * Get allowed tags |
| 26 | 26 | * @param int $mode NO_HTML, STUDENT_HTML, TEACHER_HTML, |
| 27 | 27 | * STUDENT_HTML_FULLPAGE or TEACHER_HTML_FULLPAGE |
| 28 | - * @param boolean $fullpage If true, the allowed tags for full-page editing |
|
| 29 | - * are returned. |
|
| 28 | + * @return string |
|
| 30 | 29 | */ |
| 31 | 30 | static function get_allowed_tags($mode) |
| 32 | 31 | { |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | */ |
| 17 | 17 | function validate($html, $mode = NO_HTML) |
| 18 | 18 | { |
| 19 | - $allowed_tags = self::get_allowed_tags ($mode, $fullpage); |
|
| 19 | + $allowed_tags = self::get_allowed_tags($mode, $fullpage); |
|
| 20 | 20 | $cleaned_html = kses($html, $allowed_tags); |
| 21 | 21 | return $html == $cleaned_html; |
| 22 | 22 | } |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | // Include the allowed tags. |
| 34 | 34 | //include(dirname(__FILE__).'/allowed_tags.inc.php'); |
| 35 | 35 | global $allowed_tags_student, $allowed_tags_student_full_page, $allowed_tags_teacher, $allowed_tags_teacher_full_page; |
| 36 | - switch($mode) |
|
| 36 | + switch ($mode) |
|
| 37 | 37 | { |
| 38 | 38 | case NO_HTML: |
| 39 | 39 | return array(); |
@@ -9,7 +9,6 @@ |
||
| 9 | 9 | { |
| 10 | 10 | /** |
| 11 | 11 | * @param $value array Uploaded file info (from $_FILES) |
| 12 | - * @param null $options |
|
| 13 | 12 | * @return bool |
| 14 | 13 | */ |
| 15 | 14 | public function validate($elementValue, $maxSize) |
@@ -7,22 +7,22 @@ |
||
| 7 | 7 | */ |
| 8 | 8 | class HTML_QuickForm_Rule_MaxFileSize extends HTML_QuickForm_Rule |
| 9 | 9 | { |
| 10 | - /** |
|
| 11 | - * @param $value array Uploaded file info (from $_FILES) |
|
| 12 | - * @param null $options |
|
| 13 | - * @return bool |
|
| 14 | - */ |
|
| 15 | - public function validate($elementValue, $maxSize) |
|
| 16 | - { |
|
| 17 | - if (!empty($elementValue['error']) && |
|
| 18 | - (UPLOAD_ERR_FORM_SIZE == $elementValue['error'] || UPLOAD_ERR_INI_SIZE == $elementValue['error']) |
|
| 19 | - ) { |
|
| 20 | - return false; |
|
| 21 | - } |
|
| 22 | - if (!HTML_QuickForm_file::_ruleIsUploadedFile($elementValue)) { |
|
| 23 | - return true; |
|
| 24 | - } |
|
| 10 | + /** |
|
| 11 | + * @param $value array Uploaded file info (from $_FILES) |
|
| 12 | + * @param null $options |
|
| 13 | + * @return bool |
|
| 14 | + */ |
|
| 15 | + public function validate($elementValue, $maxSize) |
|
| 16 | + { |
|
| 17 | + if (!empty($elementValue['error']) && |
|
| 18 | + (UPLOAD_ERR_FORM_SIZE == $elementValue['error'] || UPLOAD_ERR_INI_SIZE == $elementValue['error']) |
|
| 19 | + ) { |
|
| 20 | + return false; |
|
| 21 | + } |
|
| 22 | + if (!HTML_QuickForm_file::_ruleIsUploadedFile($elementValue)) { |
|
| 23 | + return true; |
|
| 24 | + } |
|
| 25 | 25 | |
| 26 | - return ($maxSize >= @filesize($elementValue['tmp_name'])); |
|
| 27 | - } |
|
| 26 | + return ($maxSize >= @filesize($elementValue['tmp_name'])); |
|
| 27 | + } |
|
| 28 | 28 | } |
@@ -16,7 +16,7 @@ |
||
| 16 | 16 | * |
| 17 | 17 | * @param string Mobile phone number to be validated |
| 18 | 18 | * @param string Not using it. Just to respect the declaration |
| 19 | - * @return boolean Returns true if valid, false otherwise. |
|
| 19 | + * @return integer Returns true if valid, false otherwise. |
|
| 20 | 20 | */ |
| 21 | 21 | function validate($mobilePhoneNumber, $options = null) |
| 22 | 22 | { |