コード例 #1
0
ファイル: plugin.php プロジェクト: optimosolution/marhk
 /**
  * Get a parameter by key
  * 
  * @access 	public
  * @param 	string $key Parameter key eg: editor.width
  * @param 	mixed $fallback Fallback value
  * @param 	mixed $default Default value
  * @param 	string $type Variable type eg: string, boolean, integer, array
  * @param 	bool $allowempty
  * @return 	mixed
  */
 public function getParam($key, $fallback = '', $default = '', $type = 'string', $allowempty = true)
 {
     // get plugin name
     $name = $this->getName();
     // get all keys
     $keys = explode('.', $key);
     // root key set
     if ($keys[0] === 'editor' || $keys[0] === $name) {
         return parent::getParam($key, $fallback, $default, $type, $allowempty);
         // no root key set, treat as shared param
     } else {
         // get all params
         $params = parent::getParams();
         // check plugin param and fallback to editor param
         $param = $params->get($name . '.' . $key, $params->get('editor.' . $key, $fallback, $allowempty), $allowempty);
         if (is_string($param) && $type === 'string') {
             $param = self::cleanParam($param);
         }
         if (is_numeric($default)) {
             $default = intval($default);
         }
         if (is_numeric($param)) {
             $param = intval($param);
         }
         if ($param === $default) {
             return '';
         }
         if ($type === 'boolean') {
             $param = (bool) $param;
         }
         return $param;
     }
 }