| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- <?php
- /**
- * App helper file.
- *
- * Provides a helper to perform app related operations.
- *
- * @category Helper.
- */
- /**
- * Require dependent files if not present.
- */
- require_once(PATH::HELPER . "Helper.php");
- /**
- * Application helper.
- *
- * Contains app-related utilities.
- *
- * @category Helper.
- */
- final class APPLICATION extends Helper{
- /**
- * Checks if a value is a valid one in a constant class.
- *
- * It will intentionally fail when used for a non constant class.
- *
- * @param string $class Name of the class.
- * @param int $value Value to check.
- * @return bool True if the value is defined, false otherwise.
- */
- public static function valid_id($class, $value){
- if (strtoupper($class) != $class){
- return false;
- }
- if (!class_exists($class, false)){
- return false;
- }
- $reflect = new ReflectionClass($class);
- if (in_array($value, $reflect->getConstants())){
- return true;
- }
- else{
- return false;
- }
- }
- /**
- * Forms an image URL.
- *
- * It will intentionally fail when used for a non constant class.
- *
- * @param string $type Image type. valid values are:
- * ICON, LOGO, CURRENCY, UNIT,
- * AREA, SKILL, ESSENCE, RUNE,
- * GRIND, ELEMENT, SKILL_GUILD, DECORATION,
- * SOURCE, SKILL_LEADER, INVENTORY, EFFECT,
- * BUILDING
- * @param string|int $name Filename, with no path or extension. It can also
- * skip the padding. An id can be used.
- * @return string URL if found. If not, the URL to an 'unknown' icon.
- */
- public static function img($type, $name){
- $pad = 1;
- $url = URL::IMG["UNKNOWN"];
- while ($pad < 10){
- if (isset(PATH::IMG[$type]) && file_exists(PATH::IMG[$type] . str_pad($name, $pad, '0', STR_PAD_LEFT) . ".png")){
- $url = URL::IMG[$type] . str_pad($name, $pad, '0', STR_PAD_LEFT) . ".png";
- break;
- }
- $pad ++;
- }
- return $url;
- }
- }
- ?>
|