Ejemplo n.º 1
0
 /**
  * getItemData
  *
  * Attempts to fetch a cached version of the requested
  * item. Otherwise, it calls the parent function.
  *
  * @return string[]                  An associative array
  * @param integer    $itemID         The ID of the item
  */
 public function getItemData($itemID)
 {
     $this->cacheID = "i" . md5($itemID);
     $cached = $this->cacheFetch($this->cacheID);
     if (!is_array($cached)) {
         $cached = parent::getItemData($itemID);
         if ($this->cacheID) {
             $scached = serialize($cached);
             $this->cacheSave($this->cacheID, $scached);
             unset($this->cacheID);
         }
         return $cached;
     } else {
         return $cached;
     }
 }
Ejemplo n.º 2
0
<?php

/**
 * phpArmory5 test case
 *
 * A test case to derive a new class object from the phpArmory5 class.
 * @package phpArmory
 * @subpackage tests
 */
// Include the phpArmory class library
require_once '../phpArmory.class.php';
$areaName = 'eu';
$itemID = 19990;
$sapi_type = substr(php_sapi_name(), 0, 3);
// Instantiate the class library
if ($armory = new phpArmory5($areaName = $areaName)) {
    $itemIDData = $armory->getItemData($itemID);
    if ($sapi_type == 'cli') {
        var_dump($itemIDData);
    } else {
        $string = print_r($itemIDData, 1);
        $string = str_replace(array(" ", "\n"), array("&nbsp;", "<br />\n"), $string);
        echo "\$item = " . $string;
    }
} else {
    echo "Failed to create a phpArmory5 instance.\n";
}