Exemple #1
0
function plugin_attachref_inline()
{
    global $vars, $digest;
    global $_attachref_messages;
    #	static $numbers = array();
    #	static $no_flag = 0;
    #	if (!array_key_exists($vars['page'],$numbers))
    #	{
    #		$numbers[$vars['page']] = 0;
    #	}
    #	$attachref_no = $numbers[$vars['page']]++;
    $ret = '';
    $dispattach = 1;
    $extra_options = array();
    $args = func_get_args();
    $btn_text = array_pop($args);
    $btn_text = $btn_text ? $btn_text : $_attachref_messages['btn_submit'];
    $options = plugin_attachref_options($extra_options, $args);
    $button = $extra_options['button'];
    $attachref_no = $extra_options['refnum'];
    $btn_text .= $extra_options['text'];
    #	$button = 0;
    $args = func_get_args();
    #   $btn_text = array_pop($args);
    #   $btn_text = $btn_text ? $btn_text : $_attachref_messages['btn_submit'];
    #   $options = array();
    #   foreach ( $args as $opt ){
    #	    if ( $opt === 'button' ){
    #	        $button = 1;
    #	    }
    #	    else if ( $opt === 'number' ){
    #		$no_flag = 1;
    #	    }
    #	    else if ( $opt === 'nonumber' ){
    #		$no_flag = 0;
    #	    }
    #	    else {
    #	        array_push($options, $opt);
    #	    }
    #	}
    #   $btn_text .= ( $no_flag == 1 ) ? "[$attachref_no]" : '';
    $args = $options;
    if (count($args) && $args[0] != '') {
        require_once PLUGIN_DIR . 'ref.inc.php';
        $params = plugin_ref_body($args, $vars['page']);
        if (isset($params['_error'])) {
            $ret = $params['_error'];
            $dispattach = 1;
        } else {
            $ret = $params['_body'];
            $dispattach = 0;
        }
    }
    if ($dispattach) {
        // Escape foreign value
        $s_args = trim(join(",", $args));
        if ($button) {
            $script = Router::get_script_uri();
            $s_args .= ',button';
            $f_page = Utility::htmlsc($vars['page']);
            $f_args = Utility::htmlsc($s_args);
            $ret = <<<EOD
<form action="{$script}" method="post" class="plugin-attacherf-form">
\t<input type="hidden" name="attachref_no" value="{$attachref_no}" />
\t<input type="hidden" name="attachref_opt" value="{$f_args}" />
\t<input type="hidden" name="digest" value="{$digest}" />
\t<input type="hidden" name="cmd" value="attachref" />
\t<input type="hidden" name="refer" value="{$f_page}" />
\t{$ret}
\t<input class="btn btn-secondary" type="submit" value="{$btn_text}" />
</form>
EOD;
        } else {
            $f_btn_text = preg_replace('/<[^<>]+>/', '', $btn_text);
            $btn_url = get_cmd_uri('attachref', $vars['page'], '', array('attachref_no' => $attachref_no, 'attachref_opt' => $s_args, 'refer' => $vars['page'], 'digest' => $digest));
            $ret .= '<a href="' . $btn_url . '" title="' . $f_btn_text . '"><small><span class="fa fa-paperclip">' . $btn_text . '</span></small></a>';
        }
    }
    return $ret;
}
function plugin_attachref_inline()
{
    global $script, $vars, $digest;
    global $_attachref_messages;
    #	static $numbers = array();
    #	static $no_flag = 0;
    #	if (!array_key_exists($vars['page'],$numbers))
    #	{
    #		$numbers[$vars['page']] = 0;
    #	}
    #	$attachref_no = $numbers[$vars['page']]++;
    $ret = '';
    $dispattach = 1;
    $extra_options = array();
    $args = func_get_args();
    $btn_text = array_pop($args);
    $btn_text = $btn_text ? $btn_text : $_attachref_messages['btn_submit'];
    $options = plugin_attachref_options($extra_options, $args);
    $button = $extra_options['button'];
    $attachref_no = $extra_options['refnum'];
    $btn_text .= $extra_options['text'];
    #	$button = 0;
    #	$args = func_get_args();
    #   $btn_text = array_pop($args);
    #   $btn_text = $btn_text ? $btn_text : $_attachref_messages['btn_submit'];
    #   $options = array();
    #   foreach ( $args as $opt ){
    #	    if ( $opt === 'button' ){
    #	        $button = 1;
    #	    }
    #	    else if ( $opt === 'number' ){
    #		$no_flag = 1;
    #	    }
    #	    else if ( $opt === 'nonumber' ){
    #		$no_flag = 0;
    #	    }
    #	    else {
    #	        array_push($options, $opt);
    #	    }
    #	}
    #   if ( $no_flag == 1 ) $btn_text .= "[$attachref_no]";
    $args = $options;
    if (count($args) && $args[0] != '') {
        require_once PLUGIN_DIR . 'ref.inc.php';
        $params = plugin_ref_body($args, $vars['page']);
        if ($params['_error'] != '') {
            $ret = $params['_error'];
            $dispattach = 1;
        } else {
            $ret = $params['_body'];
            $dispattach = 0;
        }
    }
    if ($dispattach) {
        // Escape foreign value
        $s_args = trim(join(",", $args));
        if ($button) {
            $s_args .= ',button';
            $f_page = htmlspecialchars($vars['page']);
            $f_args = htmlspecialchars($s_args);
            $ret = <<<EOD
  <form action="{$script}" method="post">
  <div>
  <input type="hidden" name="encode_hint" value="ぷ" />
  <input type="hidden" name="attachref_no" value="{$attachref_no}" />
  <input type="hidden" name="attachref_opt" value="{$f_args}" />
  <input type="hidden" name="digest" value="{$digest}" />
  <input type="hidden" name="plugin" value="attachref" />
  <input type="hidden" name="refer" value="{$f_page}" />
  {$ret}
  <input type="submit" value="{$btn_text}" />
  </div>
  </form>
EOD;
        } else {
            $f_btn_text = preg_replace('/<[^<>]+>/', '', $btn_text);
            $f_page = rawurlencode($vars['page']);
            $f_args = rawurlencode($s_args);
            $ret = <<<EOD
  {$ret}<a href="{$script}?plugin=attachref&amp;attachref_no={$attachref_no}&amp;attachref_opt={$f_args}&amp;refer={$f_page}&amp;digest={$digest}" title="{$f_btn_text}">{$btn_text}</a>
EOD;
        }
    }
    return $ret;
}