$options=array(t('Show on every page except the listed pages.'),t('Show on only the listed pages.'));
$description=t("Enter one page per line as Drupal paths. The '*' character is a wildcard. Example paths are %blog for the blog page and %blog-wildcard for every personal blog. %front is the front page.",array('%blog'=>'blog','%blog-wildcard'=>'blog/*','%front'=>'<front>'));
if($access){
if(module_exists('php')&&$access){
$options[]=t('Show if the following PHP code returns <code>TRUE</code> (PHP-mode, experts only).');
$description.=' '.t('If the PHP-mode is chosen, enter PHP code between %php. Note that executing incorrect PHP-code can break your Drupal site.',array('%php'=>'<?php ?>'));
'description'=>t('Select which blocks are displayed, and arrange them on the page.'),
),
'use PHP for block visibility'=>array(
'title'=>t('Use PHP for block visibility'),
'description'=>t('Enter PHP code in the field for block visibility settings. %warning',array('%warning'=>t('Warning: Give to trusted roles only; this permission has security implications.'))),
),
);
}
...
...
@@ -608,8 +604,11 @@ function _block_load_blocks() {
// is displayed only on those pages listed in $block->pages.
@@ -21,6 +21,62 @@ function php_help($path, $arg) {
}
}
/**
* Implementation of hook_perm().
*/
functionphp_perm(){
returnarray(
'use PHP for settings'=>array(
'title'=>t('Use PHP for settings'),
'description'=>t('Enter PHP in settings fields where PHP is allowed. %warning',array('%warning'=>t('Warning: Give to trusted roles only; this permission has security implications.'))),
),
);
}
/**
* Evaluate a string of PHP code.
*
* This is a wrapper around PHP's eval(). It uses output buffering to capture both
* returned and printed text. Unlike eval(), we require code to be surrounded by
* <?php ?> tags; in other words, we evaluate the code as if it were a stand-alone
* PHP file.
*
* Using this wrapper also ensures that the PHP code which is evaluated can not
* overwrite any variables in the calling code, unlike a regular eval() call.
*
* @param $code
* The code to evaluate.
* @return
* A string containing the printed output of the code, followed by the returned
* output of the code.
*/
functionphp_eval($code){
global$theme_path,$theme_info,$conf;
// Store current theme path.
$old_theme_path=$theme_path;
// Restore theme_path to the theme, as long as php_eval() executes,
// so code evaluated will not see the caller module as the current theme.
// If theme info is not initialized get the path from theme_default.