source: aowow/faction.php

Last change on this file was 170, checked in by maron, 15 years ago
  • Property svn:executable set to *
File size: 3.7 KB
Line 
1<?php
2
3require_once('includes/allnpcs.php');
4require_once('includes/allitems.php');
5require_once('includes/allquests.php');
6require_once('includes/allcomments.php');
7
8global $npc_cols;
9global $item_cols;
10global $quest_cols;
11
12$smarty->config_load($conf_file,'faction');
13
14// Номер фракции
15$id = $podrazdel;
16
17if(!$faction = load_cache(18, intval($id)))
18{
19 unset($faction);
20
21 // Подключаемся к ДБ:
22 global $DB;
23
24 $row = $DB->selectRow('
25 SELECT factionID, name, description1, description2, team, side
26 FROM ?_factions
27 WHERE factionID=?d
28 LIMIT 1
29 ',
30 $id
31 );
32 if ($row)
33 {
34 $faction=array();
35 // Номер фракции
36 $faction['entry'] = $row['factionID'];
37 // Название фракции
38 $faction['name'] = $row['name'];
39 // Описание фракции, из клиента:
40 $faction['description1'] = $row['description1'];
41 // Описание фракции, c wowwiki.com, находится в таблице factions.sql:
42 $faction['description2'] = $row['description2'];
43 // Команда/Группа фракции
44 if($row['team']!=0)
45 $faction['group'] = $DB->selectCell('SELECT name FROM ?_factions WHERE factionID=?d LIMIT 1', $row['team']);
46 // Альянс(1)/Орда(2)
47 if($row['side']!=0)
48 $faction['side'] = $row['side'];
49
50 // Итемы с requiredreputationfaction
51 $item_rows = $DB->select('
52 SELECT ?#, entry
53 FROM item_template i, ?_icons a
54 WHERE
55 i.RequiredReputationFaction=?d
56 AND a.id=i.displayid
57 ',
58 $item_cols[2],
59 $id
60 );
61 if ($item_rows)
62 {
63 $faction['items'] = array();
64 foreach ($item_rows as $i=>$row)
65 $faction['items'][] = iteminfo2($row, 0);
66 unset ($faction['items']);
67 }
68
69 // Персонажи, состоящие во фракции
70 $creature_rows = $DB->select('
71 SELECT ?#, entry
72 FROM creature_template, ?_factiontemplate
73 WHERE
74 faction_A IN (SELECT factiontemplateID FROM ?_factiontemplate WHERE factionID=?d)
75 AND factiontemplateID=faction_A
76 ',
77 $npc_cols[0],
78 $id
79 );
80 if ($creature_rows)
81 {
82 $faction['creatures'] = array();
83 foreach ($creature_rows as $i=>$row)
84 $faction['creatures'][] = creatureinfo2($row);
85 unset ($creature_rows);
86 }
87
88 // Квесты для этой фракции
89 $quests_rows = $DB->select('
90 SELECT ?#
91 FROM quest_template
92 WHERE
93 RewRepFaction1=?d
94 OR RewRepFaction2=?d
95 OR RewRepFaction3=?d
96 OR RewRepFaction4=?d
97 ',
98 $quest_cols[2],
99 $id, $id, $id, $id
100 );
101 if ($quests_rows)
102 {
103 $faction['quests'] = array();
104 foreach ($quests_rows as $i=>$row)
105 $faction['quests'][] = GetQuestInfo($row, 0xFFFFFF);
106 unset ($quests_rows);
107 }
108
109 // Faction cache
110 save_cache(18, $faction['entry'], $faction);
111 }
112}
113
114$page = array(
115 'Mapper' => false,
116 'Book' => false,
117 'Title' => $faction['name'].' - '.$smarty->get_config_vars('Factions'),
118 'tab' => 0,
119 'type' => 8,
120 'typeid' => $faction['entry'],
121 'path' => '[0, 7, 0]'
122);
123$smarty->assign('page', $page);
124
125// Комментарии
126$smarty->assign('comments', getcomments($page['type'], $page['typeid']));
127
128// Данные о квесте
129$smarty->assign('faction', $faction);
130// Если хоть одна информация о вещи найдена - передаём массив с информацией о вещях шаблонизатору
131if (isset($allitems))
132 $smarty->assign('allitems',$allitems);
133/*
134if (isset($npcs))
135 $smarty->assign('npcs',$npcs);
136if (isset($quests))
137 $smarty->assign('quests',$quests);
138if (isset($items))
139 $smarty->assign('items',$items);
140*/
141// Количество MySQL запросов
142$smarty->assign('mysql', $DB->getStatistics());
143// Загружаем страницу
144$smarty->display('faction.tpl');
145?>
Note: See TracBrowser for help on using the repository browser.