ACC SHELL

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

<?php
	// Author: Jakub Macek, CZ; Copyright: Poski.com s.r.o.; Code is 100% my work. Do not copy.

	class Action
	{
		public					$id									= null;
		public					$module								= null;
		public					$method								= '';

		public					$options							= array();
		public					$optionsUnsafe						= array('oid', 'pid', 'id');
		public					$mappings							= array();
		public					$context							= null;
		
		public static function find($action, $module = null)
		{
			if (!is_object($action))
			{
				if ($temp = strpos($action, '#'))
					$action = substr($action, 0, $temp);
				$temp = strpos($action, '/');
				$module = ($temp !== false) ? substr($action, 0, $temp) : $module;
				$action = ($temp !== false) ? substr($action, $temp + 1) : $action;
				if ($temp0 = m($module))
					$action = $temp0->action($action);
				else
					$action = null;
			}
			if (!($action instanceof Action))
				return null;
			return $action;
		}

		public function __construct($module, $id, $options = array())
		{
			$this->id = $id;
			$this->module = $module;
			$this->options = $options;
			$this->method = U::dashToUpper($this->id);
			$this->method = 'action' . strtoupper(substr($this->method, 0, 1)) . substr($this->method, 1);
			
			$this->mappings['pid'] = new E('return ((isset($parent) && $parent) ? $parent->oid : $invocation->get("pid"));');
			$this->mappings['oid'] = new E('return ((isset($object) && $object) ? $object->oid : $invocation->get("oid"));');
		}

		public function module()
		{
			return m($this->module);
		}

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

		public function icon()
		{
			if ($icon = $this->get('icon'))
				return $icon;
			foreach (array($this->id, $this->module.'_'.$this->id) as $icon)
				if (U::fef(($temp = 'web/_administration/icons/' . $icon . '.png')))
					return $icon;
			return null;
		}

		public function set($key, $value = null)
		{
			$this->options[$key] = $value;
		}

		public function get($key, $value = null)
		{
			$result = $this->module()->get($this->id . '-' . $key);
			if ($result !== null)
				return $result;
			return isset($this->options[$key]) ? $this->options[$key] : $value;
		}

		public function getS($key, $value = null)
		{
			return $this->module()->getS($this->id . '-' . $key, $value);
		}

		public function setS($key, $value)
		{
			$this->module()->setS($this->id . '-' . $key, $value);
		}

		public function getV($key, $value = null)
		{
			return $this->module()->getV($this->id . '-' . $key, $value);
		}
		
		public function setV($key, $value)
		{
			$this->module()->setV($this->id . '-' . $key, $value);
		}
		
		public function getUP($key, $value = null)
		{
			return $this->module()->getUP($this->id . '-' . $key, $value);
		}
		
		public function setUP($key, $value)
		{
			$this->module()->setUP($this->id . '-' . $key, $value);
		}

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

	function a($action, $module = null)
	{
		return Action::find($action, $module);
	}
	
?>

ACC SHELL 2018