Complex classes like File often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use File, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 93 | class File extends DataObject implements ShortcodeHandler, AssetContainer, Thumbnail, CMSPreviewable |
||
| 94 | { |
||
| 95 | |||
| 96 | use ImageManipulation; |
||
| 97 | |||
| 98 | private static $default_sort = "\"Name\""; |
||
| 99 | |||
| 100 | /** |
||
| 101 | * @config |
||
| 102 | * @var string |
||
| 103 | */ |
||
| 104 | private static $singular_name = "File"; |
||
| 105 | |||
| 106 | private static $plural_name = "Files"; |
||
| 107 | |||
| 108 | /** |
||
| 109 | * Permissions necessary to view files outside of the live stage (e.g. archive / draft stage). |
||
| 110 | * |
||
| 111 | * @config |
||
| 112 | * @var array |
||
| 113 | */ |
||
| 114 | private static $non_live_permissions = array('CMS_ACCESS_LeftAndMain', 'CMS_ACCESS_AssetAdmin', 'VIEW_DRAFT_CONTENT'); |
||
| 115 | |||
| 116 | private static $db = array( |
||
| 117 | "Name" => "Varchar(255)", |
||
| 118 | "Title" => "Varchar(255)", |
||
| 119 | "File" => "DBFile", |
||
| 120 | // Only applies to files, doesn't inherit for folder |
||
| 121 | 'ShowInSearch' => 'Boolean(1)', |
||
| 122 | ); |
||
| 123 | |||
| 124 | private static $has_one = array( |
||
| 125 | "Parent" => "SilverStripe\\Assets\\File", |
||
| 126 | "Owner" => "SilverStripe\\Security\\Member" |
||
| 127 | ); |
||
| 128 | |||
| 129 | private static $defaults = array( |
||
| 130 | "ShowInSearch" => 1, |
||
| 131 | ); |
||
| 132 | |||
| 133 | private static $extensions = array( |
||
| 134 | "SilverStripe\\ORM\\Hierarchy\\Hierarchy", |
||
| 135 | "SilverStripe\\ORM\\Versioning\\Versioned" |
||
| 136 | ); |
||
| 137 | |||
| 138 | private static $casting = array ( |
||
| 139 | 'TreeTitle' => 'HTMLFragment' |
||
| 140 | ); |
||
| 141 | |||
| 142 | private static $table_name = 'File'; |
||
| 143 | |||
| 144 | /** |
||
| 145 | * @config |
||
| 146 | * @var array List of allowed file extensions, enforced through {@link validate()}. |
||
| 147 | * |
||
| 148 | * Note: if you modify this, you should also change a configuration file in the assets directory. |
||
| 149 | * Otherwise, the files will be able to be uploaded but they won't be able to be served by the |
||
| 150 | * webserver. |
||
| 151 | * |
||
| 152 | * - If you are running Apache you will need to change assets/.htaccess |
||
| 153 | * - If you are running IIS you will need to change assets/web.config |
||
| 154 | * |
||
| 155 | * Instructions for the change you need to make are included in a comment in the config file. |
||
| 156 | */ |
||
| 157 | private static $allowed_extensions = array( |
||
| 158 | '', 'ace', 'arc', 'arj', 'asf', 'au', 'avi', 'bmp', 'bz2', 'cab', 'cda', 'css', 'csv', 'dmg', 'doc', |
||
| 159 | 'docx', 'dotx', 'dotm', 'flv', 'gif', 'gpx', 'gz', 'hqx', 'ico', 'jar', 'jpeg', 'jpg', 'js', 'kml', |
||
| 160 | 'm4a', 'm4v', 'mid', 'midi', 'mkv', 'mov', 'mp3', 'mp4', 'mpa', 'mpeg', 'mpg', 'ogg', 'ogv', 'pages', |
||
| 161 | 'pcx', 'pdf', 'png', 'pps', 'ppt', 'pptx', 'potx', 'potm', 'ra', 'ram', 'rm', 'rtf', 'sit', 'sitx', |
||
| 162 | 'tar', 'tgz', 'tif', 'tiff', 'txt', 'wav', 'webm', 'wma', 'wmv', 'xls', 'xlsx', 'xltx', 'xltm', 'zip', |
||
| 163 | 'zipx', |
||
| 164 | ); |
||
| 165 | |||
| 166 | /** |
||
| 167 | * @config |
||
| 168 | * @var array Category identifiers mapped to commonly used extensions. |
||
| 169 | */ |
||
| 170 | private static $app_categories = array( |
||
| 171 | 'archive' => array( |
||
| 172 | 'ace', 'arc', 'arj', 'bz', 'bz2', 'cab', 'dmg', 'gz', 'hqx', 'jar', 'rar', 'sit', 'sitx', 'tar', 'tgz', |
||
| 173 | 'zip', 'zipx', |
||
| 174 | ), |
||
| 175 | 'audio' => array( |
||
| 176 | 'aif', 'aifc', 'aiff', 'apl', 'au', 'avr', 'cda', 'm4a', 'mid', 'midi', 'mp3', 'ogg', 'ra', |
||
| 177 | 'ram', 'rm', 'snd', 'wav', 'wma', |
||
| 178 | ), |
||
| 179 | 'document' => array( |
||
| 180 | 'css', 'csv', 'doc', 'docx', 'dotm', 'dotx', 'htm', 'html', 'gpx', 'js', 'kml', 'pages', 'pdf', |
||
| 181 | 'potm', 'potx', 'pps', 'ppt', 'pptx', 'rtf', 'txt', 'xhtml', 'xls', 'xlsx', 'xltm', 'xltx', 'xml', |
||
| 182 | ), |
||
| 183 | 'image' => array( |
||
| 184 | 'alpha', 'als', 'bmp', 'cel', 'gif', 'ico', 'icon', 'jpeg', 'jpg', 'pcx', 'png', 'ps', 'tif', 'tiff', |
||
| 185 | ), |
||
| 186 | 'image/supported' => array( |
||
| 187 | 'gif', 'jpeg', 'jpg', 'png' |
||
| 188 | ), |
||
| 189 | 'flash' => array( |
||
| 190 | 'fla', 'swf' |
||
| 191 | ), |
||
| 192 | 'video' => array( |
||
| 193 | 'asf', 'avi', 'flv', 'ifo', 'm1v', 'm2v', 'm4v', 'mkv', 'mov', 'mp2', 'mp4', 'mpa', 'mpe', 'mpeg', |
||
| 194 | 'mpg', 'ogv', 'qt', 'vob', 'webm', 'wmv', |
||
| 195 | ), |
||
| 196 | ); |
||
| 197 | |||
| 198 | /** |
||
| 199 | * Map of file extensions to class type |
||
| 200 | * |
||
| 201 | * @config |
||
| 202 | * @var |
||
| 203 | */ |
||
| 204 | private static $class_for_file_extension = array( |
||
| 205 | '*' => 'SilverStripe\\Assets\\File', |
||
| 206 | 'jpg' => 'SilverStripe\\Assets\\Image', |
||
| 207 | 'jpeg' => 'SilverStripe\\Assets\\Image', |
||
| 208 | 'png' => 'SilverStripe\\Assets\\Image', |
||
| 209 | 'gif' => 'SilverStripe\\Assets\\Image', |
||
| 210 | ); |
||
| 211 | |||
| 212 | /** |
||
| 213 | * @config |
||
| 214 | * @var bool If this is true, then restrictions set in {@link $allowed_max_file_size} and |
||
| 215 | * {@link $allowed_extensions} will be applied to users with admin privileges as |
||
| 216 | * well. |
||
| 217 | */ |
||
| 218 | private static $apply_restrictions_to_admin = true; |
||
| 219 | |||
| 220 | /** |
||
| 221 | * If enabled, legacy file dataobjects will be automatically imported into the APL |
||
| 222 | * |
||
| 223 | * @config |
||
| 224 | * @var bool |
||
| 225 | */ |
||
| 226 | private static $migrate_legacy_file = false; |
||
| 227 | |||
| 228 | /** |
||
| 229 | * @config |
||
| 230 | * @var boolean |
||
| 231 | */ |
||
| 232 | private static $update_filesystem = true; |
||
| 233 | |||
| 234 | public static function get_shortcodes() |
||
| 238 | |||
| 239 | /** |
||
| 240 | * Replace "[file_link id=n]" shortcode with an anchor tag or link to the file. |
||
| 241 | * |
||
| 242 | * @param array $arguments Arguments passed to the parser |
||
| 243 | * @param string $content Raw shortcode |
||
| 244 | * @param ShortcodeParser $parser Parser |
||
| 245 | * @param string $shortcode Name of shortcode used to register this handler |
||
| 246 | * @param array $extra Extra arguments |
||
| 247 | * @return string Result of the handled shortcode |
||
| 248 | */ |
||
| 249 | public static function handle_shortcode($arguments, $content, $parser, $shortcode, $extra = array()) |
||
| 279 | |||
| 280 | /** |
||
| 281 | * Find the record to use for a given shortcode. |
||
| 282 | * |
||
| 283 | * @param array $args Array of input shortcode arguments |
||
| 284 | * @param int $errorCode If the file is not found, or is inaccessible, this will be assigned to a HTTP error code. |
||
| 285 | * @return File|null The File DataObject, if it can be found. |
||
| 286 | */ |
||
| 287 | public static function find_shortcode_record($args, &$errorCode = null) |
||
| 311 | |||
| 312 | /** |
||
| 313 | * Given a HTTP Error, find an appropriate substitute File or SiteTree data object instance. |
||
| 314 | * |
||
| 315 | * @param int $errorCode HTTP Error value |
||
| 316 | * @return File|SiteTree File or SiteTree object to use for the given error |
||
| 317 | */ |
||
| 318 | protected static function find_error_record($errorCode) |
||
| 327 | |||
| 328 | /** |
||
| 329 | * A file only exists if the file_exists() and is in the DB as a record |
||
| 330 | * |
||
| 331 | * Use $file->isInDB() to only check for a DB record |
||
| 332 | * Use $file->File->exists() to only check if the asset exists |
||
| 333 | * |
||
| 334 | * @return bool |
||
| 335 | */ |
||
| 336 | public function exists() |
||
| 340 | |||
| 341 | /** |
||
| 342 | * Find a File object by the given filename. |
||
| 343 | * |
||
| 344 | * @param string $filename Filename to search for, including any custom parent directories. |
||
| 345 | * @return File |
||
| 346 | */ |
||
| 347 | public static function find($filename) |
||
| 367 | |||
| 368 | /** |
||
| 369 | * Just an alias function to keep a consistent API with SiteTree |
||
| 370 | * |
||
| 371 | * @return string The link to the file |
||
| 372 | */ |
||
| 373 | public function Link() |
||
| 377 | |||
| 378 | /** |
||
| 379 | * @deprecated 4.0 |
||
| 380 | */ |
||
| 381 | public function RelativeLink() |
||
| 386 | |||
| 387 | /** |
||
| 388 | * Just an alias function to keep a consistent API with SiteTree |
||
| 389 | * |
||
| 390 | * @return string The absolute link to the file |
||
| 391 | */ |
||
| 392 | public function AbsoluteLink() |
||
| 396 | |||
| 397 | /** |
||
| 398 | * @return string |
||
| 399 | */ |
||
| 400 | public function getTreeTitle() |
||
| 404 | |||
| 405 | /** |
||
| 406 | * @param Member $member |
||
| 407 | * @return bool |
||
| 408 | */ |
||
| 409 | public function canView($member = null) |
||
| 422 | |||
| 423 | /** |
||
| 424 | * Check if this file can be modified |
||
| 425 | * |
||
| 426 | * @param Member $member |
||
| 427 | * @return boolean |
||
| 428 | */ |
||
| 429 | public function canEdit($member = null) |
||
| 442 | |||
| 443 | /** |
||
| 444 | * Check if a file can be created |
||
| 445 | * |
||
| 446 | * @param Member $member |
||
| 447 | * @param array $context |
||
| 448 | * @return boolean |
||
| 449 | */ |
||
| 450 | public function canCreate($member = null, $context = array()) |
||
| 463 | |||
| 464 | /** |
||
| 465 | * Check if this file can be deleted |
||
| 466 | * |
||
| 467 | * @param Member $member |
||
| 468 | * @return boolean |
||
| 469 | */ |
||
| 470 | public function canDelete($member = null) |
||
| 483 | |||
| 484 | /** |
||
| 485 | * Returns the fields to power the edit screen of files in the CMS. |
||
| 486 | * You can modify this FieldList by subclassing folder, or by creating a {@link DataExtension} |
||
| 487 | * and implementing updateCMSFields(FieldList $fields) on that extension. |
||
| 488 | * |
||
| 489 | * @return FieldList |
||
| 490 | */ |
||
| 491 | public function getCMSFields() |
||
| 541 | |||
| 542 | /** |
||
| 543 | * Get title for current file status |
||
| 544 | * |
||
| 545 | * @return string |
||
| 546 | */ |
||
| 547 | public function getStatusTitle() |
||
| 557 | |||
| 558 | /** |
||
| 559 | * Returns a category based on the file extension. |
||
| 560 | * This can be useful when grouping files by type, |
||
| 561 | * showing icons on filelinks, etc. |
||
| 562 | * Possible group values are: "audio", "mov", "zip", "image". |
||
| 563 | * |
||
| 564 | * @param string $ext Extension to check |
||
| 565 | * @return string |
||
| 566 | */ |
||
| 567 | public static function get_app_category($ext) |
||
| 577 | |||
| 578 | /** |
||
| 579 | * For a category or list of categories, get the list of file extensions |
||
| 580 | * |
||
| 581 | * @param array|string $categories List of categories, or single category |
||
| 582 | * @return array |
||
| 583 | */ |
||
| 584 | public static function get_category_extensions($categories) |
||
| 613 | |||
| 614 | /** |
||
| 615 | * Returns a category based on the file extension. |
||
| 616 | * |
||
| 617 | * @return string |
||
| 618 | */ |
||
| 619 | public function appCategory() |
||
| 623 | |||
| 624 | |||
| 625 | /** |
||
| 626 | * Should be called after the file was uploaded |
||
| 627 | */ |
||
| 628 | public function onAfterUpload() |
||
| 632 | |||
| 633 | /** |
||
| 634 | * Make sure the file has a name |
||
| 635 | */ |
||
| 636 | protected function onBeforeWrite() |
||
| 706 | |||
| 707 | /** |
||
| 708 | * This will check if the parent record and/or name do not match the name on the underlying |
||
| 709 | * DBFile record, and if so, copy this file to the new location, and update the record to |
||
| 710 | * point to this new file. |
||
| 711 | * |
||
| 712 | * This method will update the File {@see DBFile} field value on success, so it must be called |
||
| 713 | * before writing to the database |
||
| 714 | * |
||
| 715 | * @return bool True if changed |
||
| 716 | */ |
||
| 717 | public function updateFilesystem() |
||
| 746 | |||
| 747 | /** |
||
| 748 | * Collate selected descendants of this page. |
||
| 749 | * $condition will be evaluated on each descendant, and if it is succeeds, that item will be added |
||
| 750 | * to the $collator array. |
||
| 751 | * |
||
| 752 | * @param string $condition The PHP condition to be evaluated. The page will be called $item |
||
| 753 | * @param array $collator An array, passed by reference, to collect all of the matching descendants. |
||
| 754 | * @return true|null |
||
| 755 | */ |
||
| 756 | public function collateDescendants($condition, &$collator) |
||
| 770 | |||
| 771 | /** |
||
| 772 | * Get an asset renamer for the given filename. |
||
| 773 | * |
||
| 774 | * @param string $filename Path name |
||
| 775 | * @return AssetNameGenerator |
||
| 776 | */ |
||
| 777 | protected function getNameGenerator($filename) |
||
| 781 | |||
| 782 | /** |
||
| 783 | * Gets the URL of this file |
||
| 784 | * |
||
| 785 | * @return string |
||
| 786 | */ |
||
| 787 | public function getAbsoluteURL() |
||
| 795 | |||
| 796 | /** |
||
| 797 | * Gets the URL of this file |
||
| 798 | * |
||
| 799 | * @uses Director::baseURL() |
||
| 800 | * @param bool $grant Ensures that the url for any protected assets is granted for the current user. |
||
| 801 | * @return string |
||
| 802 | */ |
||
| 803 | public function getURL($grant = true) |
||
| 810 | |||
| 811 | /** |
||
| 812 | * Get URL, but without resampling. |
||
| 813 | * |
||
| 814 | * @param bool $grant Ensures that the url for any protected assets is granted for the current user. |
||
| 815 | * @return string |
||
| 816 | */ |
||
| 817 | public function getSourceURL($grant = true) |
||
| 824 | |||
| 825 | /** |
||
| 826 | * @todo Coupling with cms module, remove this method. |
||
| 827 | * |
||
| 828 | * @return string |
||
| 829 | */ |
||
| 830 | public function DeleteLink() |
||
| 839 | |||
| 840 | /** |
||
| 841 | * Get expected value of Filename tuple value. Will be used to trigger |
||
| 842 | * a file move on draft stage. |
||
| 843 | * |
||
| 844 | * @return string |
||
| 845 | */ |
||
| 846 | public function generateFilename() |
||
| 855 | |||
| 856 | /** |
||
| 857 | * Ensure that parent folders are published before this one is published |
||
| 858 | * |
||
| 859 | * @todo Solve this via triggered publishing / ownership in the future |
||
| 860 | */ |
||
| 861 | public function onBeforePublish() |
||
| 869 | |||
| 870 | /** |
||
| 871 | * Update the ParentID and Name for the given filename. |
||
| 872 | * |
||
| 873 | * On save, the underlying DBFile record will move the underlying file to this location. |
||
| 874 | * Thus it will not update the underlying Filename value until this is done. |
||
| 875 | * |
||
| 876 | * @param string $filename |
||
| 877 | * @return $this |
||
| 878 | */ |
||
| 879 | public function setFilename($filename) |
||
| 903 | |||
| 904 | /** |
||
| 905 | * Returns the file extension |
||
| 906 | * |
||
| 907 | * @return string |
||
| 908 | */ |
||
| 909 | public function getExtension() |
||
| 913 | |||
| 914 | /** |
||
| 915 | * Gets the extension of a filepath or filename, |
||
| 916 | * by stripping away everything before the last "dot". |
||
| 917 | * Caution: Only returns the last extension in "double-barrelled" |
||
| 918 | * extensions (e.g. "gz" for "tar.gz"). |
||
| 919 | * |
||
| 920 | * Examples: |
||
| 921 | * - "myfile" returns "" |
||
| 922 | * - "myfile.txt" returns "txt" |
||
| 923 | * - "myfile.tar.gz" returns "gz" |
||
| 924 | * |
||
| 925 | * @param string $filename |
||
| 926 | * @return string |
||
| 927 | */ |
||
| 928 | public static function get_file_extension($filename) |
||
| 932 | |||
| 933 | /** |
||
| 934 | * Given an extension, determine the icon that should be used |
||
| 935 | * |
||
| 936 | * @param string $extension |
||
| 937 | * @return string Icon filename relative to base url |
||
| 938 | */ |
||
| 939 | public static function get_icon_for_extension($extension) |
||
| 955 | |||
| 956 | /** |
||
| 957 | * Return the type of file for the given extension |
||
| 958 | * on the current file name. |
||
| 959 | * |
||
| 960 | * @return string |
||
| 961 | */ |
||
| 962 | public function getFileType() |
||
| 966 | |||
| 967 | /** |
||
| 968 | * Get descriptive type of file based on filename |
||
| 969 | * |
||
| 970 | * @param string $filename |
||
| 971 | * @return string Description of file |
||
| 972 | */ |
||
| 973 | public static function get_file_type($filename) |
||
| 1003 | |||
| 1004 | /** |
||
| 1005 | * Returns the size of the file type in an appropriate format. |
||
| 1006 | * |
||
| 1007 | * @return string|false String value, or false if doesn't exist |
||
| 1008 | */ |
||
| 1009 | public function getSize() |
||
| 1017 | |||
| 1018 | /** |
||
| 1019 | * Formats a file size (eg: (int)42 becomes string '42 bytes') |
||
| 1020 | * |
||
| 1021 | * @param int $size |
||
| 1022 | * @return string |
||
| 1023 | */ |
||
| 1024 | public static function format_size($size) |
||
| 1043 | |||
| 1044 | /** |
||
| 1045 | * Convert a php.ini value (eg: 512M) to bytes |
||
| 1046 | * |
||
| 1047 | * @param string $iniValue |
||
| 1048 | * @return int |
||
| 1049 | */ |
||
| 1050 | public static function ini2bytes($iniValue) |
||
| 1071 | |||
| 1072 | /** |
||
| 1073 | * Return file size in bytes. |
||
| 1074 | * |
||
| 1075 | * @return int |
||
| 1076 | */ |
||
| 1077 | public function getAbsoluteSize() |
||
| 1081 | |||
| 1082 | public function validate() |
||
| 1089 | |||
| 1090 | /** |
||
| 1091 | * Maps a {@link File} subclass to a specific extension. |
||
| 1092 | * By default, files with common image extensions will be created |
||
| 1093 | * as {@link Image} instead of {@link File} when using |
||
| 1094 | * {@link Folder::constructChild}, {@link Folder::addUploadToFolder}), |
||
| 1095 | * and the {@link Upload} class (either directly or through {@link FileField}). |
||
| 1096 | * For manually instanciated files please use this mapping getter. |
||
| 1097 | * |
||
| 1098 | * Caution: Changes to mapping doesn't apply to existing file records in the database. |
||
| 1099 | * Also doesn't hook into {@link Object::getCustomClass()}. |
||
| 1100 | * |
||
| 1101 | * @param String File extension, without dot prefix. Use an asterisk ('*') |
||
| 1102 | * to specify a generic fallback if no mapping is found for an extension. |
||
| 1103 | * @return String Classname for a subclass of {@link File} |
||
| 1104 | */ |
||
| 1105 | public static function get_class_for_file_extension($ext) |
||
| 1110 | |||
| 1111 | /** |
||
| 1112 | * See {@link get_class_for_file_extension()}. |
||
| 1113 | * |
||
| 1114 | * @param String|array |
||
| 1115 | * @param String |
||
| 1116 | */ |
||
| 1117 | public static function set_class_for_file_extension($exts, $class) |
||
| 1131 | |||
| 1132 | public function getMetaData() |
||
| 1139 | |||
| 1140 | public function getMimeType() |
||
| 1147 | |||
| 1148 | public function getStream() |
||
| 1155 | |||
| 1156 | public function getString() |
||
| 1163 | |||
| 1164 | public function setFromLocalFile($path, $filename = null, $hash = null, $variant = null, $config = array()) |
||
| 1174 | |||
| 1175 | public function setFromStream($stream, $filename, $hash = null, $variant = null, $config = array()) |
||
| 1185 | |||
| 1186 | public function setFromString($data, $filename, $hash = null, $variant = null, $config = array()) |
||
| 1196 | |||
| 1197 | public function getIsImage() |
||
| 1201 | |||
| 1202 | public function getFilename() |
||
| 1206 | |||
| 1207 | public function getHash() |
||
| 1211 | |||
| 1212 | public function getVariant() |
||
| 1216 | |||
| 1217 | /** |
||
| 1218 | * Return a html5 tag of the appropriate for this file (normally img or a) |
||
| 1219 | * |
||
| 1220 | * @return string |
||
| 1221 | */ |
||
| 1222 | public function forTemplate() |
||
| 1226 | |||
| 1227 | /** |
||
| 1228 | * Return a html5 tag of the appropriate for this file (normally img or a) |
||
| 1229 | * |
||
| 1230 | * @return string |
||
| 1231 | */ |
||
| 1232 | public function getTag() |
||
| 1240 | |||
| 1241 | public function requireDefaultRecords() |
||
| 1255 | |||
| 1256 | /** |
||
| 1257 | * Joins one or more segments together to build a Filename identifier. |
||
| 1258 | * |
||
| 1259 | * Note that the result will not have a leading slash, and should not be used |
||
| 1260 | * with local file paths. |
||
| 1261 | * |
||
| 1262 | * @param string $part,... Parts |
||
| 1263 | * @return string |
||
| 1264 | */ |
||
| 1265 | public static function join_paths($part = null) |
||
| 1282 | |||
| 1283 | public function deleteFile() |
||
| 1287 | |||
| 1288 | public function getVisibility() |
||
| 1292 | |||
| 1293 | public function publishFile() |
||
| 1297 | |||
| 1298 | public function protectFile() |
||
| 1302 | |||
| 1303 | public function grantFile() |
||
| 1307 | |||
| 1308 | public function revokeFile() |
||
| 1312 | |||
| 1313 | public function canViewFile() |
||
| 1317 | |||
| 1318 | public function CMSEditLink() |
||
| 1324 | |||
| 1325 | public function PreviewLink($action = null) |
||
| 1336 | } |
||
| 1337 |
In PHP, under loose comparison (like
==, or!=, orswitchconditions), values of different types might be equal.For
integervalues, zero is a special case, in particular the following results might be unexpected: