| @@ -170,5 +170,51 @@ | ||
| 170 | 170 | } |
| 171 | 171 | return false; |
| 172 | 172 | } |
| 173 | 173 | |
| 174 | + /** | |
| 175 | + * Gets the type of chart that is being rendered. | |
| 176 | + * | |
| 177 | + * This is useful if some type-specific functionality needs to be added. | |
| 178 | + * | |
| 179 | + * @since ? | |
| 180 | + * | |
| 181 | + * @access protected | |
| 182 | + * @return string | |
| 183 | + */ | |
| 184 | + protected function get_chart_type( $with_library = false ) { | |
| 185 | + $lib_type = str_replace( 'Visualizer_Render_Sidebar_Type_', '', get_class( $this ) ); | |
| 186 | + if ( $with_library ) { | |
| 187 | + return $lib_type; | |
| 188 | + } | |
| 189 | + | |
| 190 | + $array = explode( '_', $lib_type ); | |
| 191 | + return end( $array ); | |
| 192 | + } | |
| 193 | + | |
| 194 | + /** | |
| 195 | + * Determines if the type of chart can have a particular action. | |
| 196 | + * | |
| 197 | + * @since ? | |
| 198 | + * | |
| 199 | + * @access protected | |
| 200 | + * @return bool | |
| 201 | + */ | |
| 202 | + protected function can_chart_have_action( $action, $chart_id = null ) { | |
| 203 | + $type = null; | |
| 204 | + if ( ! $chart_id ) { | |
| 205 | + $type = $this->get_chart_type( false ); | |
| 206 | + } else { | |
| 207 | + $type = get_post_meta( $chart_id, Visualizer_Plugin::CF_CHART_TYPE, true ); | |
| 208 | + $type = ucwords( $type ); | |
| 209 | + } | |
| 210 | + | |
| 211 | + switch ( $action ) { | |
| 212 | + case 'image': | |
| 213 | + return ! in_array( $type, array( 'Gauge', 'Tabular', 'DataTable', 'Table' ), true ); | |
| 214 | + } | |
| 215 | + | |
| 216 | + return true; | |
| 217 | + } | |
| 218 | + | |
| 219 | + | |
| 174 | 220 | } |