'markup',
'#markup' => '
' . l(t('Help/Readme'), 'admin/help/field_hidden') . '
',
);
$form['field_hidden_instance_settings_hide_defval'] = array(
'#type' => 'checkbox',
'#title' => t('Do not display default value field in instance setting form'),
'#decription' => t('If checked, controlling/setting the default value in the field instance setting dialogue gets kind of hard.'),
'#default_value' => variable_get('field_hidden_instance_settings_hide_defval', FALSE),
'#required' => FALSE,
);
return system_settings_form($form);
}
/**
* Helper for field_hidden_help(), which implements hook_help().
*
* @param string $path
* @param unknown $arg
* - default: NULL
* @return string|void
*/
function _field_hidden_help($path, $arg = NULL) {
$css = str_replace('_', '-', $module = 'field_hidden');
if ($path != 'admin/help#' . $module) {
return;
}
$module_path = drupal_get_path('module', $module);
$primary_function = FALSE; //$module;
$content_main = '' . t('About') . '
'
. '' . t('The Field Hidden module defines five hidden field types - text, long text, integer, decimal, and floating-point.', array('@field-help' => url('admin/help/field')))
. '
'
. '' . t('Hidden field types reflect data types') . '
'
. '' . t('The only difference between text and long text is the database data type used - varchar versus text (MySQL: longtext).')
. '
' . t('Neither allow HTML nor PHP, only plain text.')
. '
'
. '' . t('The numeric types correspond to the data types integer, decimal and float.')
. '
' . t('Decimal is often the better choice when it comes to decimal/floating numbers because it usually allows for a higher number of precise digits (typically 14) than float/double database fields do.')
. '
'
. '' . t('Hidden - in what sense?') . '
'
. '' . t('A hidden field will always be hidden when editing a node/entity - an <input type="hidden" /> form element.')
. '
' . t('When a node/entity is displayed on a page, these hidden fields default to be fully hidden (kept out the page\'s HTML output entirely).')
. '
' . t('The value of a hidden field may however be displayed in output, if another format than <Hidden> is selected in the content type\'s \'@manage_display\' section.', array('@manage_display' => t('Manage Display')))
. '
';
drupal_add_css(
$module_path . '/' . $module . '.admin.css',
array('type' => 'file', 'group' => CSS_DEFAULT, 'preprocess' => FALSE, 'every_page' => FALSE)
);
$out = ''
. $content_main;
// Read primary function's documentation.
if ($primary_function && strlen($read_source = @file_get_contents($module_path . '/' . $module . '.module'))) {
$pos_end = strpos($read_source, "\nfunction " . $primary_function . '(');
$s_start = substr($read_source, 0, $pos_end);
$s_start = substr($s_start, strrpos($s_start, '/**'));
$s_end = substr($read_source, $pos_end);
$pos_end = strpos($s_end, ')');
$s = str_replace("\r", '', $s_start . substr($s_end, 0, $pos_end + 1) );
$s = preg_replace('/\n([^\n]+)$/', "\n" . '
$1 {...}',
preg_replace('/^([^\n]+)\n/', '
$1' . "\n",
str_replace("\n- ", "\n• ", // hyphen to bullet
str_replace("\n/", "\n", // comment end
preg_replace('/\n \*[ \t]*/', "\n", // comment line *
str_replace('/**', '', // comment start
$s))))));
$out .= '
'
. nl2br(
preg_replace('/\n\n/', '
', $s)
) . '
';
}
$out .= '
';
// Parse README.txt to html.
$out .= '
Readme
';
$readme = @file_get_contents(
substr(dirname(__FILE__), 0, -1 * (1 + strlen($module_path)))
. '/' . $module_path
. '/README.txt'
);
$func = '_' . $module . '_readme2html';
$out .= $func($readme)
. '
';
return $out;
}
/**
* Parse README.txt to html.
*
* Replacements:
* - formats headlines; line with no hyphens followed by all hyphens line
* - hyphen to bullet; newline+space+*+space becomes newline+space+bullet+space
* - emphasizes underscore fragments; _what ever_ becomes what ever
* - turns url into link, and http://your-drupal-site.tld/some-path becomes internal link to /some-path
* - turns mail address into mailto link
*
* Some replacements (like emphasizing) only works for ascii letters, not for letters line like ñ or ö.
* @param string $readme_txt
* @param string $headline_tag
* - default: h5
* @return string
*/
function _field_hidden_readme2html($readme_txt, $headline_tag = 'h5') {
if (!strlen($readme_txt)) {
return 'empty readme';
}
$ndls = array(
'/',
'/>/',
'/\r\n|\r/', // CR -> NL
'/[\x20\t]+\n/', // trailing spaces (in lines)
'/\n{3,}/', // 3 or more newlines to double
'/<([^>@]+@[^>@]+)>/', // mail addresses
'/([\n\x20])_([a-zA-Z\d][^\.,;\:\n\x20]*[a-zA-Z\d])_([\n\x20\.,;\:])/', // _emphasize_ -> emphasize
);
$rplcs = array(
'<',
'>',
"\n",
"\n",
"\n\n",
'<$1>',
'$1$2$3',
);
$s = preg_replace($ndls, $rplcs, $readme_txt);
// Insert links in CONTENTS OF THIS FILE.
if (strpos($s, 'CONTENTS OF THIS FILE') !== FALSE) {
$pos_start = strpos($s, ' * ');
$pos_end = strpos($s, "\n\n", $pos_start);
$s_toc = preg_replace('/[ ]+\n/', "\n", substr($s, $pos_start, ($pos_end - $pos_start) + 1) ); // remove trailing space(s)
//echo $s_toc; exit;
$s_toc = preg_replace_callback(
'/ \* ([^\n]+)\n/',
create_function(
'$ms',
'
return \' * \' . $ms[1] . \'\' . "\n";
'
),
$s_toc
);
$s_start = substr($s, 0, $pos_start);
$s_end = substr($s, $pos_end);
$s = str_replace('CONTENTS OF THIS FILE', 'CONTENTS', $s_start) . $s_toc . $s_end;
}
// Format headlines, and insert anchor.
$s = preg_replace_callback(
'/\n([^\n\-])([^\n]*[^\n\-])\n[\-]{2,}\n+/',
create_function(
'$ms',
'
return \'\'
. $ms[1]
. \'\' . $ms[2] . \'\';
'
),
$s
);
$s = str_replace('headlineTag', $headline_tag, $s);
$ndls = array(
'/^[^\n]*\n/', // remove first line
//'//',
);
$rplcs = array(
'',
//'',
);
$s = preg_replace($ndls, $rplcs, $s);
// Links may be followed by a punctuation marker, hard to detect without a callback.
// And http://your-drupal-site.tld/path should become /path
$s = preg_replace_callback(
'/(https?\:\/\/)(\S+)([\x20\t\n])/',
create_function(
'$ms',
'
$protocol = $ms[1];
$le = strlen($addr = $ms[2]);
$dot = \'\';
if (!preg_match(\'/[\/a-zA-Z\d]/\', $addr{$le - 1})) {
$dot = $addr{$le - 1};
$addr = substr($addr, 0, $le - 1);
}
if (strpos($addr, \'your-drupal-site.tld/\') === 0) {
$protocol = \'/\';
$addr = str_replace(\'your-drupal-site.tld/\', \'\', $addr);
}
return \'\' . $addr . \'\' . $dot . $ms[3];
'
),
$s
);
$ndls = array(
'/([\n>]) \* /', // \n * to \n bullet
'/^\n?<\/p>/', // first ending
added by headline (in total)
'/\n?$/', // trailing newlines (in total)
'/\n{2,}/',
//'//',
);
$rplcs = array(
'$1 • ',
'',
'',
'
',
//'',
);
return nl2br( preg_replace($ndls, $rplcs, $s) ) . '
';
}