Пример #1
0
 public static function newSet($val)
 {
     $itemset = new self();
     $itemset->ID = $val['ID'];
     $itemset->ownerID = $val['OwnerID'];
     $itemset->title = $val['Title'];
     $itemset->type = $val['Type'];
     $itemset->map = $val['Map'];
     $itemset->mode = $val['Mode'];
     $itemset->sortrank = $val['Sortrank'];
     $itemset->champion = $val['Champion'];
     $itemset->rating = $val["Rating"];
     $itemset->blocks = recursiveArrayObject($val["Blocks"], ArrayObject::ARRAY_AS_PROPS);
     //prettyPrint($itemset->blocks);
     $itemset->complete = true;
     return $itemset;
 }
Пример #2
0
        array_push($ret, $row);
    }
    $stmt3->free_result();
    $stmt3->close();
    $itemset = ItemSet::newSet(collapseResultArray($ret)[$_GET["copy"]]);
}
//HTML Template for the user-specific part on the website
$userTemplate = new Template("www/templates/loggedin_template.html");
//Give the template the possibility to use the UserAuthentification class.
$userTemplate->setVar("UserAuthentification", $userAuth);
//Array mapping a champion name to its icon. Array ( ["ChampionName"] => "Icon", ["ChampionName2"] => "Icon2" )
$champJson = cURL("https://global.api.pvp.net/api/lol/static-data/euw/v1.2/champion?champData=image&api_key=" . $apiKey);
$championData = parseChampJSON($champJson, array("Champion" => new ArrayObject(array("img" => "www/any.png", "name" => "Any Champion", "key" => "Champion"), ArrayObject::ARRAY_AS_PROPS)));
//$spellData = parseSpellJSON(cURL("https://global.api.pvp.net/api/lol/static-data/euw/v1.2/summoner-spell?spellData=image,key&api_key=" . $apiKey));
//Get all those items...
$itemdata = recursiveArrayObject(collapseResultArray2($database->query("SELECT i.ID AS ItemID, i.Gold, i.Name AS ItemName, i.Description, ibi.BuildsIntoID, ibf.BuildsFromID, it.Tag FROM `Items` i LEFT JOIN `ItemBuildsFrom` ibf ON i.ID = ibf.ItemID LEFT JOIN `ItemBuildsInto` ibi ON i.ID = ibi.ItemID LEFT JOIN `ItemTags` it ON i.ID = it.ItemID"), true, true, true), ArrayObject::ARRAY_AS_PROPS);
$headerTemplate = new Template("www/templates/header_template.html");
$headerTemplate->setVar("UserTemplate", $userTemplate);
$headerTemplate->setVar("buttons", array(new ArrayObject(array("name" => "Home", "href" => "index.php"), ArrayObject::ARRAY_AS_PROPS), new ArrayObject(array("name" => "My Sets", "href" => "mysets.php"), ArrayObject::ARRAY_AS_PROPS)));
//And then, printerino!
$csTemplate = new Template("www/templates/createset_template.html");
$csTemplate->setVar("ChampionData", $championData);
$csTemplate->setVar("ItemSet", $itemset);
//$csTemplate->setVar("SpellData", $spellData);
$csTemplate->setVar("Items", $itemdata);
$csTemplate->setVar("i", 1);
$csTemplate->setVar("TypusMaximusWaddafakius", $type);
$csTemplate->setVar("ChampionData", $championData);
$footerTemplate = new Template("www/templates/footer_template.html");
$userTemplate->prepare();
$headerTemplate->prepare();
/**
 * Recursively searches for Arrays in an array, in order to convert them to PHP ArrayObjects
 * @param $array
 * @param int $flags
 * @return ArrayObject
 */
function recursiveArrayObject($array, $flags = 0)
{
    foreach ($array as $k => $val) {
        if (is_array($val)) {
            $array[$k] = recursiveArrayObject($val, $flags);
        }
    }
    return new ArrayObject($array, $flags);
}