You are here

function geshifilter_filter_tips in GeSHi Filter for syntax highlighting 5

Same name and namespace in other branches
  1. 5.2 geshifilter.module \geshifilter_filter_tips()
  2. 6 geshifilter.module \geshifilter_filter_tips()
  3. 7 geshifilter.module \geshifilter_filter_tips()

Implementation of hook_filter_tips()

File

./geshifilter.module, line 42

Code

function geshifilter_filter_tips($delta, $format, $long = false) {
  $default_type = variable_get('geshifilter_default_type_' . $format, 0);
  $types = variable_get('geshifilter_types_' . $format, array());
  $start_param = variable_get('geshifilter_start_attribute', FALSE);
  $line_numbers = variable_get('geshifilter_line_numbers', GESHI_NO_LINE_NUMBERS);
  $inline_code = variable_get('geshifilter_inline_code_' . $format, FALSE);
  if ($long) {
    $text = t('<h3>Code:</h3>');

    //some language are allowed, type param is supported
    if (!$types[0]) {
      $text .= t('<p>To post highlighted code, surround it code with &lt;blockcode &#91;type=&quot;<em>language</em>&quot;&#93;&gt;...&lt;/blockcode&gt tags.</p><p>E.g. actionscript block code:<pre>&lt;blockcode type=&quot;<em>actionscript</em>&quot;&gt;<br />...<br />&lt;/blockcode&gt;</pre></p>');
      if ($inline_code) {
        $text .= t('<p>You may also post highlighted inline code surrounding it with &lt;code &#91;type=&quot;<em>language</em>&quot;&#93;&gt;...&lt;/code&gt tags.</p><p>E.g. highlight actionscript inline code:<pre>&lt;code type=&quot;<em>actionscript</em>&quot;&gt;...&lt;/code&gt;</pre></p>');
      }
      if ($default_type) {
        $text .= t('<p>If you don\'t use <em>type=&quot;language&quot;</em> param or specify an unsupported language, the code will be highlighted as %default-code code.</p>', array(
          '%default-code' => theme('placeholder', $default_type),
        ));
      }
      else {
        $text .= t('<p>If you don\'t use <em>type=&quot;language&quot;</em> param or specify an unsupported language, the code will not be highlighted.</p>');
      }
      $supported_types = array_keys($types, TRUE);
      $text .= t('<p>The following languages are supported for highlight:<br />%type_list.</p>', array(
        '%type_list' => theme('item_list', $supported_types),
      ));
    }
    else {
      $text .= t('<p>To post code, surround it with &lt;blockcode&gt;...&lt;/blockcode&gt tags.</p><p>E.g. <pre>&lt;blockcode&gt;<br />...<br />&lt;/blockcode&gt;</pre></p>');
      if ($inline_code) {
        $text .= t('<p>You may also post inline code surrounding it with &lt;code&gt;...&lt;/code&gt tags.</p><p>E.g.: <pre>&lt;code&gt;...&lt;/code&gt;</pre></p>');
      }
      if ($default_type) {
        $text .= t('<p>By default, the code will be highlighted as %default-code code.</p>', array(
          '%default-code' => theme('placeholder', $default_type),
        ));
      }
      else {
        $text .= t('<p>The code will not be highlighted.</p>');
      }
    }
    if ($line_numbers == GESHI_NORMAL_LINE_NUMBERS || $line_numbers == GESHI_FANCY_LINE_NUMBERS) {

      //line numbers
      if ($start_param) {
        $text .= ' ' . t('<p>The code will be numbered. You can make the line numbers start at any number using <em>start=number</em> param</p><p>E.g. highlight actionscript code and start line number at 5: <pre>&lt;blockcode type=&quot;<em>actionscript</em>&quot; start=&quot;<em>5</em>&quot;&gt;<br />...<br />&lt;/blockcode&gt;</pre></p>');
      }
      else {
        $text .= ' ' . t('<p>The code will be numbered.</p>');
      }
    }
    return $text;
  }
  else {
    $text = '';

    //some language are allowed, type param is supported
    if (!$types[0]) {
      $text .= t('You may post block code using &lt;blockcode &#91;type=&quot;<em>language</em>&quot;&#93;&gt;...&lt;/blockcode&gt; tags. ');
      if ($inline_code) {
        $text .= t('You may also post inline code using &lt;code &#91;type=&quot;<em>language</em>&quot;&#93;&gt;...&lt;/code&gt; tags.');
      }
    }
    else {
      $text .= t('You may post block code using &lt;blockcode&gt;...&lt;/blockcode&gt; tags. ');
      if ($inline_code) {
        $text .= t('You may also post inline code using &lt;code&gt;...&lt;/code&gt; tags.');
      }
    }
    return $text;
  }
}