本文整理汇总了PHP中Util::toJSON方法的典型用法代码示例。如果您正苦于以下问题:PHP Util::toJSON方法的具体用法?PHP Util::toJSON怎么用?PHP Util::toJSON使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Util
的用法示例。
在下文中一共展示了Util::toJSON方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: realmMenu
function realmMenu()
{
$subEU = [];
$subUS = [];
$set = 0x0;
$menu = [['us', 'US & Oceanic', null, [[Util::urlize(CFG_BATTLEGROUP), CFG_BATTLEGROUP, null, &$subEU]]], ['eu', 'Europe', null, [[Util::urlize(CFG_BATTLEGROUP), CFG_BATTLEGROUP, null, &$subUS]]]];
if (DB::isConnectable(DB_AUTH)) {
$rows = DB::Auth()->select('SELECT name, IF(timezone IN (8, 9, 10, 11, 12), "eu", "us") AS region FROM realmlist WHERE allowedSecurityLevel = 0 AND gamebuild = ?d', WOW_VERSION);
foreach ($rows as $row) {
if ($row['region'] == 'eu') {
$set |= 0x1;
$subEU[] = [Util::urlize($row['name']), $row['name']];
} else {
if ($row['region'] == 'us') {
$set |= 0x2;
$subUS[] = [Util::urlize($row['name']), $row['name']];
}
}
}
} else {
CLISetup::log(' - realmMenu: Auth-DB not set up .. menu will be empty', CLISetup::LOG_WARN);
}
if (!($set & 0x1)) {
array_shift($menu);
}
if (!($set & 0x2)) {
array_pop($menu);
}
return Util::toJSON($menu);
}
示例2: realmMenu
function realmMenu()
{
$subEU = [];
$subUS = [];
$set = 0x0;
$menu = [['us', 'US & Oceanic', null, [[Util::urlize(CFG_BATTLEGROUP), CFG_BATTLEGROUP, null, &$subUS]]], ['eu', 'Europe', null, [[Util::urlize(CFG_BATTLEGROUP), CFG_BATTLEGROUP, null, &$subEU]]]];
foreach (Util::getRealms() as $row) {
if ($row['region'] == 'eu') {
$set |= 0x1;
$subEU[] = [Util::urlize($row['name']), $row['name']];
} else {
if ($row['region'] == 'us') {
$set |= 0x2;
$subUS[] = [Util::urlize($row['name']), $row['name']];
}
}
}
if (!$set) {
CLISetup::log(' - realmMenu: Auth-DB not set up .. menu will be empty', CLISetup::LOG_WARN);
}
if (!($set & 0x1)) {
array_pop($menu);
}
if (!($set & 0x2)) {
array_shift($menu);
}
return Util::toJSON($menu);
}
示例3: itemScalingSD
function itemScalingSD()
{
$data = DB::Aowow()->select('SELECT *, Id AS ARRAY_KEY FROM dbc_scalingstatdistribution');
foreach ($data as &$row) {
$row = array_values($row);
array_splice($row, 0, 1);
}
return CFG_DEBUG ? debugify($data) : Util::toJSON($data);
}
示例4: realms
function realms()
{
$realms = [];
if (DB::isConnectable(DB_AUTH)) {
$realms = DB::Auth()->select('SELECT id AS ARRAY_KEY, name, ? AS battlegroup, IF(timezone IN (8, 9, 10, 11, 12), "eu", "us") AS region FROM realmlist WHERE allowedSecurityLevel = 0 AND gamebuild = ?d', CFG_BATTLEGROUP, WOW_VERSION);
} else {
CLISetup::log(' - realms: Auth-DB not set up .. static data g_realms will be empty', CLISetup::LOG_WARN);
}
$toFile = "var g_realms = " . Util::toJSON($realms) . ";";
$file = 'datasets/realms';
return CLISetup::writeFile($file, $toFile);
}
示例5: gems
function gems()
{
// sketchy, but should work
// Id < 36'000 || ilevel < 70 ? BC : WOTLK
$gems = DB::Aowow()->Select('SELECT i.id AS itemId,
i.name_loc0, i.name_loc2, i.name_loc3, i.name_loc4, i.name_loc6, i.name_loc8,
IF (i.id < 36000 OR i.itemLevel < 70, 1 , 2) AS expansion,
i.quality,
ic.iconString AS icon,
i.gemEnchantmentId AS enchId,
i.gemColorMask AS colors
FROM ?_items i
JOIN ?_icons ic ON ic.id = -i.displayId
WHERE i.gemEnchantmentId <> 0
ORDER BY i.id DESC');
$success = true;
// check directory-structure
foreach (Util::$localeStrings as $dir) {
if (!CLISetup::writeDir('datasets/' . $dir)) {
$success = false;
}
}
$enchIds = [];
foreach ($gems as $pop) {
$enchIds[] = $pop['enchId'];
}
$enchantments = new EnchantmentList(array(['id', $enchIds], CFG_SQL_LIMIT_NONE));
if ($enchantments->error) {
CLISetup::log('Required table ?_itemenchantment seems to be empty! Leaving gems()...', CLISetup::LOG_ERROR);
CLISetup::log();
return false;
}
foreach (CLISetup::$localeIds as $lId) {
set_time_limit(5);
User::useLocale($lId);
Lang::load(Util::$localeStrings[$lId]);
$gemsOut = [];
foreach ($gems as $pop) {
if (!$enchantments->getEntry($pop['enchId'])) {
CLISetup::log(' * could not find enchantment #' . $pop['enchId'] . ' referenced by item #' . $gem['itemId'], CLISetup::LOG_WARN);
continue;
}
$gemsOut[$pop['itemId']] = array('name' => Util::localizedString($pop, 'name'), 'quality' => $pop['quality'], 'icon' => strToLower($pop['icon']), 'enchantment' => $enchantments->getField('name', true), 'jsonequip' => $enchantments->getStatGain(), 'colors' => $pop['colors'], 'expansion' => $pop['expansion']);
}
$toFile = "var g_gems = " . Util::toJSON($gemsOut) . ";";
$file = 'datasets/' . User::$localeString . '/gems';
if (!CLISetup::writeFile($file, $toFile)) {
$success = false;
}
}
return $success;
}
示例6: realms
function realms()
{
$realms = Util::getRealms();
if (!$realms) {
CLISetup::log(' - realms: Auth-DB not set up .. static data g_realms will be empty', CLISetup::LOG_WARN);
} else {
foreach ($realms as &$r) {
$r['battlegroup'] = CFG_BATTLEGROUP;
}
}
$toFile = "var g_realms = " . Util::toJSON($realms) . ";";
$file = 'datasets/realms';
return CLISetup::writeFile($file, $toFile);
}
示例7: glyphs
function glyphs()
{
$success = true;
$glyphList = DB::Aowow()->Select('SELECT i.id AS itemId,
i.*,
IF (g.typeFlags & 0x1, 2, 1) AS type,
i.subclass AS classs,
i.requiredLevel AS level,
s1.Id AS glyphSpell,
ic.iconString AS icon,
s1.skillLine1 AS skillId,
s2.Id AS glyphEffect,
s2.Id AS ARRAY_KEY
FROM ?_items i
JOIN ?_spell s1 ON s1.Id = i.spellid1
JOIN ?_glyphproperties g ON g.Id = s1.effect1MiscValue
JOIN ?_spell s2 ON s2.Id = g.spellId
JOIN ?_icons ic ON ic.Id = s1.iconIdAlt
WHERE i.classBak = 16');
// check directory-structure
foreach (Util::$localeStrings as $dir) {
if (!CLISetup::writeDir('datasets/' . $dir)) {
$success = false;
}
}
$glyphSpells = new SpellList(array(['s.id', array_keys($glyphList)], CFG_SQL_LIMIT_NONE));
foreach (CLISetup::$localeIds as $lId) {
set_time_limit(30);
User::useLocale($lId);
Lang::load(Util::$localeStrings[$lId]);
$glyphsOut = [];
foreach ($glyphSpells->iterate() as $__) {
$pop = $glyphList[$glyphSpells->id];
if (!$pop['glyphEffect']) {
continue;
}
if ($glyphSpells->getField('effect1Id') != 6 && $glyphSpells->getField('effect2Id') != 6 && $glyphSpells->getField('effect3Id') != 6) {
continue;
}
$glyphsOut[$pop['itemId']] = array('name' => Util::localizedString($pop, 'name'), 'description' => $glyphSpells->parseText()[0], 'icon' => $pop['icon'], 'type' => $pop['type'], 'classs' => $pop['classs'], 'skill' => $pop['skillId'], 'level' => $pop['level']);
}
$toFile = "var g_glyphs = " . Util::toJSON($glyphsOut) . ";";
$file = 'datasets/' . User::$localeString . '/glyphs';
if (!CLISetup::writeFile($file, $toFile)) {
$success = false;
}
}
return $success;
}
示例8: generateContent
protected function generateContent()
{
$tabData = array('data' => [], 'name' => Util::ucFirst(Lang::game('enchantments')));
$conditions = [];
if (!User::isInGroup(U_GROUP_EMPLOYEE)) {
$conditions[] = [['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW, '&'], 0];
}
if ($_ = $this->filterObj->getConditions()) {
$conditions[] = $_;
}
$ench = new EnchantmentList($conditions);
$tabData['data'] = array_values($ench->getListviewData());
$this->extendGlobalData($ench->getJSGlobals());
// recreate form selection
$this->filter = array_merge($this->filterObj->getForm('form'), $this->filter);
$this->filter['query'] = isset($_GET['filter']) ? $_GET['filter'] : NULL;
$this->filter['fi'] = $this->filterObj->getForm();
$xCols = $this->filterObj->getForm('extraCols', true);
foreach (Util::$itemFilter as $fiId => $str) {
if (array_column($tabData['data'], $str)) {
$xCols[] = $fiId;
}
}
if (array_column($tabData['data'], 'dmg')) {
$xCols[] = 34;
}
if ($xCols) {
$this->filter['fi']['extraCols'] = "fi_extraCols = " . Util::toJSON(array_values(array_unique($xCols))) . ";";
}
if (!empty($this->filter['fi']['extraCols'])) {
$tabData['extraCols'] = '$fi_getExtraCols(fi_extraCols, 0, 0)';
}
if ($ench->getMatches() > CFG_SQL_LIMIT_DEFAULT) {
$tabData['note'] = sprintf(Util::$tryFilteringString, 'LANG.lvnote_enchantmentsfound', $ench->getMatches(), CFG_SQL_LIMIT_DEFAULT);
$tabData['_truncated'] = 1;
}
if (array_filter(array_column($tabData['data'], 'spells'))) {
$tabData['visibleCols'] = ['trigger'];
}
if (!$ench->hasSetFields(['skillLine'])) {
$tabData['hiddenCols'] = ['skill'];
}
if ($this->filterObj->error) {
$tabData['_errors'] = '$1';
}
$this->lvTabs[] = ['enchantment', $tabData, 'enchantment'];
}
示例9: pets
function pets()
{
$success = true;
$locations = [];
$petList = DB::Aowow()->Select('SELECT cr. id,
cr.name_loc0, cr.name_loc2, cr.name_loc3, cr.name_loc6, cr.name_loc8,
cr.minLevel,
cr.maxLevel,
ft.A,
ft.H,
cr.rank AS classification,
cr.family,
cr.displayId1 AS displayId,
cr.textureString AS skin,
LOWER(SUBSTRING_INDEX(cf.iconString, "\\\\", -1)) AS icon,
cf.petTalentType AS type
FROM ?_creature cr
JOIN ?_factiontemplate ft ON ft.Id = cr.faction
JOIN dbc_creaturefamily cf ON cf.id = cr.family
WHERE cr.typeFlags & 0x1 AND (cr.cuFlags & 0x2) = 0
ORDER BY cr.id ASC');
// check directory-structure
foreach (Util::$localeStrings as $dir) {
if (!CLISetup::writeDir('datasets/' . $dir)) {
$success = false;
}
}
foreach (CLISetup::$localeIds as $lId) {
User::useLocale($lId);
Lang::load(Util::$localeStrings[$lId]);
$petsOut = [];
foreach ($petList as $pet) {
// get locations
// again: caching will save you time and nerves
if (!isset($locations[$pet['id']])) {
$locations[$pet['id']] = DB::Aowow()->SelectCol('SELECT DISTINCT areaId FROM ?_spawns WHERE type = ?d AND typeId = ?d', TYPE_NPC, $pet['id']);
}
$petsOut[$pet['id']] = array('id' => $pet['id'], 'name' => Util::localizedString($pet, 'name'), 'minlevel' => $pet['minLevel'], 'maxlevel' => $pet['maxLevel'], 'location' => $locations[$pet['id']], 'react' => [$pet['A'], $pet['H']], 'classification' => $pet['classification'], 'family' => $pet['family'], 'displayId' => $pet['displayId'], 'skin' => $pet['skin'], 'icon' => $pet['icon'], 'type' => $pet['type']);
}
$toFile = "var g_pets = " . Util::toJSON($petsOut) . ";";
$file = 'datasets/' . User::$localeString . '/pets';
if (!CLISetup::writeFile($file, $toFile)) {
$success = false;
}
}
return $success;
}
示例10: generateContent
protected function generateContent()
{
$this->addJS('?data=zones&locale=' . User::$localeId . '&t=' . $_SESSION['dataKey']);
$conditions = [];
if (!User::isInGroup(U_GROUP_EMPLOYEE)) {
$conditions[] = [['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW, '&'], 0];
}
if ($this->category) {
$conditions[] = ['type', $this->category[0]];
$this->petFamPanel = $this->category[0] == 1;
} else {
$this->petFamPanel = false;
}
if ($_ = $this->filterObj->getConditions()) {
$conditions[] = $_;
}
// beast subtypes are selected via filter
$npcs = new CreatureList($conditions, ['extraOpts' => $this->filterObj->extraOpts]);
// recreate form selection
$this->filter = array_merge($this->filterObj->getForm('form'), $this->filter);
$this->filter['query'] = isset($_GET['filter']) ? $_GET['filter'] : NULL;
$this->filter['fi'] = $this->filterObj->getForm();
$repCols = $this->filterObj->getForm('reputationCols');
$tabData = array('data' => array_values($npcs->getListviewData($repCols ? NPCINFO_REP : 0x0)));
if ($repCols) {
$tabData['extraCols'] = '$fi_getReputationCols(' . Util::toJSON($repCols) . ')';
} else {
if (!empty($this->filter['fi']['extraCols'])) {
$tabData['extraCols'] = '$fi_getExtraCols(fi_extraCols, 0, 0)';
}
}
if ($this->category) {
$tabData['hiddenCols'] = ['type'];
}
// create note if search limit was exceeded
if ($npcs->getMatches() > CFG_SQL_LIMIT_DEFAULT) {
$tabData['note'] = sprintf(Util::$tryFilteringString, 'LANG.lvnote_npcsfound', $npcs->getMatches(), CFG_SQL_LIMIT_DEFAULT);
$tabData['_truncated'] = 1;
}
if ($this->filterObj->error) {
$tabData['_errors'] = 1;
}
$this->lvTabs[] = ['creature', $tabData];
// sort for dropdown-menus
Lang::sort('game', 'fa');
}
示例11: generateContent
protected function generateContent()
{
$conditions = [];
if (!User::isInGroup(U_GROUP_EMPLOYEE)) {
$conditions[] = [['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW, '&'], 0];
}
if (isset($this->category[1])) {
$conditions[] = ['zoneOrSort', $this->category[1]];
} else {
if (isset($this->category[0])) {
$conditions[] = ['zoneOrSort', $this->validCats[$this->category[0]]];
}
}
if ($_ = $this->filterObj->getConditions()) {
$conditions[] = $_;
}
$quests = new QuestList($conditions, ['extraOpts' => $this->filterObj->extraOpts]);
$this->extendGlobalData($quests->getJSGlobals());
// recreate form selection
$this->filter = array_merge($this->filterObj->getForm('form'), $this->filter);
$this->filter['query'] = isset($_GET['filter']) ? $_GET['filter'] : NULL;
$this->filter['fi'] = $this->filterObj->getForm();
$lv = array('file' => 'quest', 'data' => $quests->getListviewData(), 'params' => []);
if ($_ = $this->filterObj->getForm('reputationCols')) {
$lv['params']['extraCols'] = '$fi_getReputationCols(' . Util::toJSON($_) . ')';
} else {
if (!empty($this->filter['fi']['extraCols'])) {
$lv['params']['extraCols'] = '$fi_getExtraCols(fi_extraCols, 0, 0)';
}
}
// create note if search limit was exceeded
if ($quests->getMatches() > CFG_SQL_LIMIT_DEFAULT) {
$lv['params']['note'] = sprintf(Util::$tryFilteringString, 'LANG.lvnote_questsfound', $quests->getMatches(), CFG_SQL_LIMIT_DEFAULT);
$lv['params']['_truncated'] = 1;
} else {
if (isset($this->category[1]) && $this->category[1] > 0) {
$lv['params']['note'] = '$$WH.sprintf(LANG.lvnote_questgivers, ' . $this->category[1] . ', g_zones[' . $this->category[1] . '], ' . $this->category[1] . ')';
}
}
if ($this->filterObj->error) {
$lv['params']['_errors'] = '$1';
}
$this->lvTabs[] = $lv;
}
示例12: gems
function gems()
{
// sketchy, but should work
// Id < 36'000 || ilevel < 70 ? BC : WOTLK
$gems = DB::Aowow()->Select('SELECT i.id AS itemId,
i.name_loc0, i.name_loc2, i.name_loc3, i.name_loc6, i.name_loc8,
IF (i.id < 36000 OR i.itemLevel < 70, 1 , 2) AS expansion,
i.quality,
ic.iconString AS icon,
i.gemEnchantmentId AS enchId,
i.gemColorMask AS colors
FROM ?_items i
JOIN ?_icons ic ON ic.id = -i.displayId
WHERE i.gemEnchantmentId <> 0
ORDER BY i.id DESC');
$success = true;
// check directory-structure
foreach (Util::$localeStrings as $dir) {
if (!CLISetup::writeDir('datasets/' . $dir)) {
$success = false;
}
}
$enchIds = [];
foreach ($gems as $pop) {
$enchIds[] = $pop['enchId'];
}
$enchMisc = [];
$enchJSON = Util::parseItemEnchantment($enchIds, false, $enchMisc);
foreach (CLISetup::$localeIds as $lId) {
set_time_limit(5);
User::useLocale($lId);
Lang::load(Util::$localeStrings[$lId]);
$gemsOut = [];
foreach ($gems as $pop) {
$gemsOut[$pop['itemId']] = array('name' => Util::localizedString($pop, 'name'), 'quality' => $pop['quality'], 'icon' => strToLower($pop['icon']), 'enchantment' => Util::localizedString(@$enchMisc[$pop['enchId']]['text'] ?: [], 'text'), 'jsonequip' => @$enchJSON[$pop['enchId']] ?: [], 'colors' => $pop['colors'], 'expansion' => $pop['expansion']);
}
$toFile = "var g_gems = " . Util::toJSON($gemsOut) . ";";
$file = 'datasets/' . User::$localeString . '/gems';
if (!CLISetup::writeFile($file, $toFile)) {
$success = false;
}
}
return $success;
}
示例13: weightPresets
function weightPresets()
{
// check directory-structure
if (!CLISetup::writeDir('datasets/')) {
return false;
}
$wtPresets = [];
$scales = DB::Aowow()->select('SELECT id, name, icon, class FROM ?_account_weightscales WHERE userId = 0 ORDER BY class, id ASC');
foreach ($scales as $s) {
$weights = DB::Aowow()->selectCol('SELECT field AS ARRAY_KEY, val FROM ?_account_weightscale_data WHERE id = ?d', $s['id']);
if (!$weights) {
CLISetup::log('WeightScale \'' . CLISetup::bold($s['name']) . '\' has no data set. Skipping...', CLISetup::LOG_WARN);
continue;
}
$wtPresets[$s['class']]['pve'][$s['name']] = array_merge(['__icon' => $s['icon']], $weights);
}
$toFile = "var wt_presets = " . Util::toJSON($wtPresets) . ";";
$file = 'datasets/weight-presets';
if (!CLISetup::writeFile($file, $toFile)) {
return false;
}
return true;
}
示例14: Book
<?php
if (!empty($this->pageText)) {
?>
<div class="clear"></div>
<h3><?php
echo Lang::item('content');
?>
</h3>
<div id="book-generic"></div>
<script>//<![CDATA[
new Book({ parent: 'book-generic', pages: <?php
echo Util::toJSON($this->pageText);
?>
})
//]]></script>
<?php
}
示例15: generateTooltip
protected function generateTooltip($asError = false)
{
if ($asError) {
die('$WowheadPower.registerSpell(' . $this->typeId . ', ' . User::$localeId . ', {});');
}
$x = '$WowheadPower.registerSpell(' . $this->typeId . ', ' . User::$localeId . ", {\n";
$pt = [];
if ($n = $this->subject->getField('name', true)) {
$pt[] = "\tname_" . User::$localeString . ": '" . Util::jsEscape($n) . "'";
}
if ($i = $this->subject->getField('iconString')) {
$pt[] = "\ticon: '" . urlencode($i) . "'";
}
if ($tt = $this->subject->renderTooltip()) {
$pt[] = "\ttooltip_" . User::$localeString . ": '" . Util::jsEscape($tt[0]) . "'";
$pt[] = "\tspells_" . User::$localeString . ": " . Util::toJSON($tt[1]);
}
if ($btt = $this->subject->renderBuff()) {
$pt[] = "\tbuff_" . User::$localeString . ": '" . Util::jsEscape($btt[0]) . "'";
$pt[] = "\tbuffspells_" . User::$localeString . ": " . Util::toJSON($btt[1]);
}
$x .= implode(",\n", $pt) . "\n});";
return $x;
}