| 1 |
<?php |
| 2 |
namespace Imagify\Context; |
| 3 |
|
| 4 |
use \Imagify\Traits\InstanceGetterTrait; |
| 5 |
|
| 6 |
/** |
| 7 |
* Fallback class for contexts. |
| 8 |
* |
| 9 |
* @since 1.9 |
| 10 |
* @author Grégory Viguier |
| 11 |
*/ |
| 12 |
class Noop implements ContextInterface { |
| 13 |
use InstanceGetterTrait; |
| 14 |
|
| 15 |
/** |
| 16 |
* Get the context "short name". |
| 17 |
* |
| 18 |
* @since 1.9 |
| 19 |
* @author Grégory Viguier |
| 20 |
* |
| 21 |
* @return string |
| 22 |
*/ |
| 23 |
public function get_name() { |
| 24 |
return 'noop'; |
| 25 |
} |
| 26 |
|
| 27 |
/** |
| 28 |
* Tell if the context is network-wide. |
| 29 |
* |
| 30 |
* @since 1.9 |
| 31 |
* @author Grégory Viguier |
| 32 |
* |
| 33 |
* @return bool |
| 34 |
*/ |
| 35 |
public function is_network_wide() { |
| 36 |
return false; |
| 37 |
} |
| 38 |
|
| 39 |
/** |
| 40 |
* Get the type of files this context allows. |
| 41 |
* |
| 42 |
* @since 1.9 |
| 43 |
* @see imagify_get_mime_types() |
| 44 |
* @author Grégory Viguier |
| 45 |
* |
| 46 |
* @return string Possible values are: |
| 47 |
* - 'all' to allow all types. |
| 48 |
* - 'image' to allow only images. |
| 49 |
* - 'not-image' to allow only pdf files. |
| 50 |
*/ |
| 51 |
public function get_allowed_mime_types() { |
| 52 |
return 'all'; |
| 53 |
} |
| 54 |
|
| 55 |
/** |
| 56 |
* Get the thumbnail sizes for this context, except the full size. |
| 57 |
* |
| 58 |
* @since 1.9 |
| 59 |
* @author Grégory Viguier |
| 60 |
* |
| 61 |
* @return array { |
| 62 |
* Data for the currently registered thumbnail sizes. |
| 63 |
* Size names are used as array keys. |
| 64 |
* |
| 65 |
* @type int $width The image width. |
| 66 |
* @type int $height The image height. |
| 67 |
* @type bool $crop True to crop, false to resize. |
| 68 |
* @type string $name The size name. |
| 69 |
* } |
| 70 |
*/ |
| 71 |
public function get_thumbnail_sizes() { |
| 72 |
return []; |
| 73 |
} |
| 74 |
|
| 75 |
/** |
| 76 |
* Get images max width for this context. This is used when resizing. |
| 77 |
* 0 means to not resize. |
| 78 |
* |
| 79 |
* @since 1.9.8 |
| 80 |
* @author Grégory Viguier |
| 81 |
* |
| 82 |
* @return int |
| 83 |
*/ |
| 84 |
public function get_resizing_threshold() { |
| 85 |
return 0; |
| 86 |
} |
| 87 |
|
| 88 |
/** |
| 89 |
* Tell if the optimization process is allowed resize in this context. |
| 90 |
* |
| 91 |
* @since 1.9 |
| 92 |
* @author Grégory Viguier |
| 93 |
* |
| 94 |
* @return bool |
| 95 |
*/ |
| 96 |
public function can_resize() { |
| 97 |
return false; |
| 98 |
} |
| 99 |
|
| 100 |
/** |
| 101 |
* Tell if the optimization process is allowed to backup in this context. |
| 102 |
* |
| 103 |
* @since 1.9 |
| 104 |
* @author Grégory Viguier |
| 105 |
* |
| 106 |
* @return bool |
| 107 |
*/ |
| 108 |
public function can_backup() { |
| 109 |
return false; |
| 110 |
} |
| 111 |
|
| 112 |
/** |
| 113 |
* Tell if the current user is allowed to operate Imagify in this context. |
| 114 |
* |
| 115 |
* @since 1.9 |
| 116 |
* @author Grégory Viguier |
| 117 |
* |
| 118 |
* @param string $describer Capacity describer. See $this->get_capacity() for possible values. Can also be a "real" user capacity. |
| 119 |
* @param int $media_id A media ID. |
| 120 |
* @return bool |
| 121 |
*/ |
| 122 |
public function current_user_can( $describer, $media_id = null ) { |
| 123 |
return false; |
| 124 |
} |
| 125 |
|
| 126 |
/** |
| 127 |
* Tell if a user is allowed to operate Imagify in this context. |
| 128 |
* |
| 129 |
* @since 1.9 |
| 130 |
* @author Grégory Viguier |
| 131 |
* |
| 132 |
* @param int $user_id A user ID. |
| 133 |
* @param string $describer Capacity describer. See $this->get_capacity() for possible values. Can also be a "real" user capacity. |
| 134 |
* @param int $media_id A media ID. |
| 135 |
* @return bool |
| 136 |
*/ |
| 137 |
public function user_can( $user_id, $describer, $media_id = null ) { |
| 138 |
return false; |
| 139 |
} |
| 140 |
|
| 141 |
/** |
| 142 |
* Get user capacity to operate Imagify in this context. |
| 143 |
* |
| 144 |
* @since 1.9 |
| 145 |
* @author Grégory Viguier |
| 146 |
* |
| 147 |
* @param string $describer Capacity describer. Possible values are like 'manage', 'bulk-optimize', 'manual-optimize', 'auto-optimize'. |
| 148 |
* @return string |
| 149 |
*/ |
| 150 |
public function get_capacity( $describer ) { |
| 151 |
return 'noop'; |
| 152 |
} |
| 153 |
} |
| 154 |
|