ACC SHELL

Path : /srv/www/vhosts/alfa-com/engine/
File Upload :
Current File : /srv/www/vhosts/alfa-com/engine/Setting.php

<?php
	// Author: Jakub Macek, CZ; Copyright: Poski.com s.r.o.; Code is 100% my work. Do not copy.
	
	class Setting
	{
		public static 			$_									= array();

		public					$module								= '';
		public					$field								= null;
		public					$name								= null;

		public function __construct($module, $field)
		{
			$this->module = $module;
			$this->field = $field;
		}

		public function id()
		{
			return ($this->module . '-' . $this->field->id);
		}

		public function name()
		{
			if ($this->module == '@core')
				$module_name = __('@core', '@core');
			else
				$module_name = __('module-name', $this->module);
			return $module_name . ': ' . $this->nameShort();
		}

		public function nameShort()
		{
			if ($this->name !== null)
				return $this->name;
			else
				return __('setting-' . $this->field->id, $this->module, false);
		}

		public function get($postfix = '')
		{
			if (isset($GLOBALS['settings']['modules'][$this->module]) && isset($GLOBALS['settings']['modules'][$this->module][$this->field->id . $postfix]))
				return $GLOBALS['settings']['modules'][$this->module][$this->field->id . $postfix];
			else
				return $this->field->default;
		}

		public function set($value = null, $postfix = '')
		{
			if (isset($GLOBALS['settings']['modules'][$this->module]))
			{
				if ($value === null)
					unset($GLOBALS['settings']['modules'][$this->module][$this->field->id . $postfix]);
				else
					$GLOBALS['settings']['modules'][$this->module][$this->field->id . $postfix] = $value;
			}
		}

		public static function register($setting)
		{
			self::$_[$setting->id()] = $setting;
			return $setting;
		}
	}
?>

ACC SHELL 2018