/** * @param array $args */ function __construct($args = array()) { if (!isset(self::$_is_php53)) { self::$_is_php53 = version_compare(PHP_VERSION, '5.3.0', '>='); } $this_class = get_class($this); if (isset(self::$_instances[$this_class])) { $message = __('%s is a singleton class and cannot be instantiated more than once.', 'sidecar'); Sidecar::show_error($message, self::_get_called_class()); exit; } self::$_instances[$this_class] =& $this; if (method_exists($this, 'on_load')) { $this->on_load($args); } }
/** * @param $property_name * @return bool|string */ function __get($property_name) { $value = false; if (preg_match('#^(.+?)_tab_url$#', $property_name, $match) && $this->has_tab($match[1])) { /** * Allows magic property syntax for any registered URL * @example: $this->foobar_url calls $this-get_url( 'foobar' ) * Enables embedding in a HEREDOC or other doublequoted string * without requiring an intermediate variable. */ $value = call_user_func(array($this, "get_tab_url"), $match[1]); } else { Sidecar::show_error('No property named %s on %s class.', $property_name, get_class($this)); } return $value; }
/** * @param $property_name * @return bool|string */ function __get($property_name) { $value = false; if (preg_match('#^(.*?_(icon|image|photo))_url$#', $property_name, $match) && $this->has_image($match[1])) { $value = call_user_func(array($this, "get_image_url"), $match[1]); } else { if (preg_match('#^(.*?)_url$#', $property_name, $match) && $this->has_url($match[1])) { /** * Allows magic property syntax for any registered URL * @example: $this->foobar_url calls $this-get_url( 'foobar' ) * Enables embedding in a HEREDOC or other doublequoted string * without requiring an intermediate variable. */ $value = $this->get_url($match[1]); } else { if (preg_match('#^(.*?)_link$#', $property_name, $match) && $this->has_url($match[1])) { /** * Same kind of this as _url above. */ $url = $this->get_url($match[1]); $link_text = $this->get_link_text($match[1]); $class = $this->get_link_class($match[1]); $value = "<a target=\"_blank\"{$class} href=\"{$url}\">{$link_text}</A>"; } else { Sidecar::show_error('No property named %s on %s class.', $property_name, get_class($this)); } } } return $value; }