danielebarchiesi@0: 'PHP code'))->fetchField(); danielebarchiesi@0: // Add a PHP code text format, if it does not exist. Do this only for the danielebarchiesi@0: // first install (or if the format has been manually deleted) as there is no danielebarchiesi@0: // reliable method to identify the format in an uninstall hook or in danielebarchiesi@0: // subsequent clean installs. danielebarchiesi@0: if (!$format_exists) { danielebarchiesi@0: $php_format = array( danielebarchiesi@0: 'format' => 'php_code', danielebarchiesi@0: 'name' => 'PHP code', danielebarchiesi@0: // 'Plain text' format is installed with a weight of 10 by default. Use a danielebarchiesi@0: // higher weight here to ensure that this format will not be the default danielebarchiesi@0: // format for anyone. danielebarchiesi@0: 'weight' => 11, danielebarchiesi@0: 'filters' => array( danielebarchiesi@0: // Enable the PHP evaluator filter. danielebarchiesi@0: 'php_code' => array( danielebarchiesi@0: 'weight' => 0, danielebarchiesi@0: 'status' => 1, danielebarchiesi@0: ), danielebarchiesi@0: ), danielebarchiesi@0: ); danielebarchiesi@0: $php_format = (object) $php_format; danielebarchiesi@0: filter_format_save($php_format); danielebarchiesi@0: danielebarchiesi@0: drupal_set_message(t('A PHP code text format has been created.', array('@php-code' => url('admin/config/content/formats/' . $php_format->format)))); danielebarchiesi@0: } danielebarchiesi@0: } danielebarchiesi@0: danielebarchiesi@0: /** danielebarchiesi@0: * Implements hook_disable(). danielebarchiesi@0: */ danielebarchiesi@0: function php_disable() { danielebarchiesi@0: drupal_set_message(t('The PHP module has been disabled. Any existing content that was using the PHP filter will now be visible in plain text. This might pose a security risk by exposing sensitive information, if any, used in the PHP code.')); danielebarchiesi@0: }