X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fmodules%2Fcontrib%2Fphp%2Fsrc%2FPlugin%2FFilter%2FPhp.php;fp=web%2Fmodules%2Fcontrib%2Fphp%2Fsrc%2FPlugin%2FFilter%2FPhp.php;h=496bce83582acbdc83b942c838cc48f44af0082e;hp=0000000000000000000000000000000000000000;hb=8acec36f19c470dfcda1ae2336826a782f41874c;hpb=e0411c4e83ba0d079034db83c3f7f55be24a0e35 diff --git a/web/modules/contrib/php/src/Plugin/Filter/Php.php b/web/modules/contrib/php/src/Plugin/Filter/Php.php new file mode 100644 index 000000000..496bce835 --- /dev/null +++ b/web/modules/contrib/php/src/Plugin/Filter/Php.php @@ -0,0 +1,74 @@ +' . t('Using custom PHP code') . ''; + $output .= '
' . t('Custom PHP code may be embedded in some types of site content, including posts and blocks. While embedding PHP code inside a post or block is a powerful and flexible feature when used by a trusted user with PHP experience, it is a significant and dangerous security risk when used improperly. Even a small mistake when posting PHP code may accidentally compromise your site.') . '
'; + $output .= '' . t('If you are unfamiliar with PHP, SQL, or Drupal, avoid using custom PHP code within posts. Experimenting with PHP may corrupt your database, render your site inoperable, or significantly compromise security.') . '
'; + $output .= '' . t('Notes:') . '
'; + $output .= 'register_globals
is turned off. If you need to use forms, understand and use the functions in the Drupal Form API.', [':formapi' => 'http://api.drupal.org/api/group/form_api/8']) . 'print
or return
statement in your code to output content.') . '' . t('A basic example: Creating a "Welcome" block that greets visitors with a simple message.') . '
'; + $output .= 'Add a custom block to your site, named "Welcome". With its text format set to "PHP code" (or another format supporting PHP input), add the following in the Block body:
++ print t(\'Welcome visitor! Thank you for visiting.\'); +') . '
To display the name of a registered user, use this instead:
++ $account = \Drupal::currentUser(); + if ($account->isAuthenticated()) { + print t(\'Welcome @name! Thank you for visiting.\', [\'@name\' => $account->getDisplayName()]); + } + else { + print t(\'Welcome visitor! Thank you for visiting.\'); + } +') . '
' . t('Drupal.org offers some example PHP snippets, or you can create your own with some PHP experience and knowledge of the Drupal system.', [':drupal' => 'http://drupal.org', ':php-snippets' => 'http://drupal.org/documentation/customization/php-snippets']) . '
'; + return $output; + } + else { + return t('You may post PHP code. You should include <?php ?> tags.'); + } + } + +}