<?php

/* ========================================================================
 *
 * @license This source file is subject to version 3.01 of the PHP license,
 *              that is available at http://www.php.net/license/3_01.txt
 *              If you did not receive a copy of the PHP license and are unable 
 *              to obtain it through the world-wide-web, please send a note to 
 *              license@php.net so we can mail you a copy immediately.  
 *
 * @category   Application of MyNETS
 * @project    OpenPNE UsagiProject 2006-2007
 * @package    MyNETS
 * @author     UsagiProject <info@usagi.mynets.jp>
 * @copyright  2006-2007 UsagiProject <author member ad http://usagi.mynets.jp/member.html>
 * @version    MyNETS,v 1.0.1
 * @since      File available since Release 1.0.1 Nighty
 * @chengelog  [2007/04/14] Ver1.0.1Nighty package
 * ======================================================================== 
 */

/**
 * Aaketo
 *
 * @param  string $param[option]
 * @param  string $body
 * @return
 */

function cmd_anketo_main($param,$body) {
  global $anketo_count;
  $anketo_count = 0;
  $regexp = '/^-(.+)$/m';
  $body = preg_replace_callback($regexp, 'cmd_anketo_callback1', $body);
  $regexp = '/\{([^\}]+)\}/s';

  $result = preg_replace_callback($regexp, 'cmd_anketo_callback2', $body);
  return '<form method="POST" action="" enctype="multipart/form-data">' . $result
. '<br /><input type="submit" value="投稿する"/></form>';

}

/* 項目行の処理 */
function cmd_anketo_callback1($matches) {
  return '<span style="font-weight:bold;font-size:11pt;">' . $matches[1] . '</span>';
}

/* 1項目の処理*/
function cmd_anketo_callback2($matches) {
  global $anketo_count;
  $anketo_count++;
  $tmp=split("[ ,\n]",$matches[1]);
  $result = '';

  foreach($tmp as $value) {
    if( $value == '' ) continue;
    $result .= '<input type="checkbox" name="anketo' . $anketo_count . '" value="' . $value . '" />' . $value . ' ';
  }
  return $result;
  return '<font color="red">' . $matches[1] . '</font>';
}
?>
