array('administer GD chart'), 'description' => 'Set the filepath to use for generated images and setup cleaning up', 'file' => 'gd_image_chart.admin.inc', 'page callback' => 'drupal_get_form', 'page arguments' => array('_gd_image_chart_settings_page'), 'title' => 'GD Image chart' ); return $items; } /** * Implementation of hook_charts_info(). * * Its a Charts module hook. It defines almost all aspects * of a chart provider, like its name, what types of charts * it can perform and what are the restrictions. */ function gd_image_chart_charts_info() { return array( 'gd_image_chart' => array( 'file' => drupal_get_path('module', 'gd_image_chart') .'/gd_image_chart.inc', 'name' => t('GD Image Chart'), 'render' => '_gd_image_chart_charts_render', 'types' => array('vbar2D', 'line2D'), ), ); } /** * Implementation of hook_cron(). * * Delete the images created by this module after a certain time specified by the admin */ function gd_image_chart_cron() { if (variable_get('gd_image_chart_keep_files', '86400') > 0) { $path = file_directory_path() ."/". variable_get('gd_image_chart_path', 'gd_image_chart'); file_scan_directory($path, '\.png$', array('.', '..', 'CVS'), '_gd_image_chart_delete_old_images', TRUE); } } /** * Search and destroy images */ function _gd_image_chart_delete_old_images($file_name) { $now = time(); $seconds_to_live = variable_get('gd_image_chart_keep_files', '86400'); if (file_exists($file_name)) { if ($now - filemtime($file_name) > $seconds_to_live) { file_delete($file_name); } } }