<?php
/**
 * projBop_Controller.php
 *
 * @author BoBpp < bobpp@users.sourceforge.jp >
 * @package projBop.Ethna
 */

/**
 * 新しいURLコントローラ
 *
 * @author BoBpp < bobpp@users.sourceforge.jp >	
 * @access public
 * @package projBop.Ethna
 */
class projBop_newURL_Controller extends Ethna_Controller
{
	/**
	 * アクション名決定部分
	 */
	function _getActionName_Form()
	{
		// ここに拡張子として渡してよい文字列を配列で記述
		$allowFile = array(
			'html', 'php', 'htm',
		);
		
		$action = parent::_getActionName_Form();
		
		if (is_null($action) === false) {
			return $action;
		}
		
		// PathInfoによるアクション名取得
		if(isset($_SERVER['PATH_INFO'])) {
			$paths = explode("/", $_SERVER['PATH_INFO']);
			
			// Action名構成に必要なデータを取得
			$actions = array();
			foreach ($paths as $act) {
				if ($act === "") continue;
				$actions[] = $act;
			}
			
			// 最終項目 ファイル拡張子のチェック
			$last = count($actions) - 1;
			$file = explode(".", $actions[$last]);
			if (count($file) === 2 && in_array(strtolower($file[1]), $allowFile)) {
				$actions[$last] = $file[0];
			}
			
			// アクション名生成
			$action = implode("_", $actions);
		}
		
		return $action;
	}
}
?>