Beispiel #1
0
 /**
  * Build Recipes
  *
  * @return string
  */
 function show_recipes()
 {
     global $roster, $addon;
     $roster->tpl->assign_vars(array('S_RECIPE_HIDE' => !(bool) $addon['config']['recipe_disp'], 'U_ITEM' => makelink('char-info-recipes&s=item'), 'U_NAME' => makelink('char-info-recipes&s=name'), 'U_DIFFICULTY' => makelink('char-info-recipes&s=difficulty'), 'U_TYPE' => makelink('char-info-recipes&s=type'), 'U_LEVEL' => makelink('char-info-recipes&s=level'), 'U_REAGENTS' => makelink('char-info-recipes&s=reagents')));
     // Get recipe sort mode
     $sort = isset($_GET['s']) ? $_GET['s'] : '';
     $recipes = recipe_get_many($this->data['member_id'], '', $sort);
     $reagents = recipe_get_regents($this->data['member_id']);
     $reagent_arr = array();
     foreach ($reagents as $objects) {
         $skil = $objects->data['reagent_id'];
         $reagent_arr[$skil]['item_color'] = $objects->data['reagent_color'];
         $reagent_arr[$skil]['item_texture'] = $objects->data['reagent_texture'];
         $reagent_arr[$skil]['item_id'] = $objects->data['reagent_id'];
         $reagent_arr[$skil]['item_name'] = $objects->data['reagent_name'];
         $reagent_arr[$skil]['tooltip'] = $objects->data['reagent_tooltip'];
     }
     $recipexx = array();
     //$recipeee = new recipe();
     foreach ($recipes as $idx => $data) {
         if (isset($data['recipe_sub_type']) && !empty($data['recipe_sub_type'])) {
             $skill = $data['skill_name'];
             $type = $data['recipe_type'];
             $subtype = $data['recipe_sub_type'];
             $recipe = $data['recipe_name'];
             $recipeee = new recipe($data);
             $recipexx[$skill][$type][$subtype]["sub"] = true;
             $recipexx[$skill][$type][$subtype][$recipe]['recipe_type'] = $data['recipe_type'];
             $recipexx[$skill][$type][$subtype][$recipe]['difficulty'] = $data['difficulty'];
             $recipexx[$skill][$type][$subtype][$recipe]['item_color'] = $data['item_color'];
             $recipexx[$skill][$type][$subtype][$recipe]['reagents'] = $data['reagents'];
             $recipexx[$skill][$type][$subtype][$recipe]['recipe_texture'] = $data['recipe_texture'];
             $recipexx[$skill][$type][$subtype][$recipe]['level'] = $data['level'];
             $recipexx[$skill][$type][$subtype][$recipe]['item_id'] = $data['item_id'];
             $recipexx[$skill][$type][$subtype][$recipe]['recipe_id'] = $data['recipe_id'];
             $recipexx[$skill][$type][$subtype][$recipe]['icon'] = $roster->config['interface_url'] . 'Interface/Icons/' . $data['recipe_texture'] . '.' . $roster->config['img_suffix'];
             //$data->tpl_get_icon();
             $recipexx[$skill][$type][$subtype][$recipe]['tooltip'] = makeOverlib($data['recipe_tooltip'], '', $data['item_color'], 0, $roster->config['locale']);
             $recipexx[$skill][$type][$subtype][$recipe]['itemlink'] = $recipeee->tpl_get_itemlink();
             $recipexx[$skill][$type][$subtype][$recipe]['quality'] = $recipeee->_setQuality($data['item_color']);
         } else {
             $skill = $data['skill_name'];
             $type = $data['recipe_type'];
             $recipe = $data['recipe_name'];
             $recipeee = new recipe($data);
             $recipexx[$skill][$type][$recipe]['recipe_type'] = $data['recipe_type'];
             $recipexx[$skill][$type][$recipe]['difficulty'] = $data['difficulty'];
             $recipexx[$skill][$type][$recipe]['item_color'] = $data['item_color'];
             $recipexx[$skill][$type][$recipe]['reagents'] = $data['reagents'];
             $recipexx[$skill][$type][$recipe]['recipe_texture'] = $data['recipe_texture'];
             $recipexx[$skill][$type][$recipe]['level'] = $data['level'];
             $recipexx[$skill][$type][$recipe]['item_id'] = $data['item_id'];
             $recipexx[$skill][$type][$recipe]['recipe_id'] = $data['recipe_id'];
             $recipexx[$skill][$type][$recipe]['icon'] = $roster->config['interface_url'] . 'Interface/Icons/' . $data['recipe_texture'] . '.' . $roster->config['img_suffix'];
             //$data->tpl_get_icon();
             $recipexx[$skill][$type][$recipe]['tooltip'] = makeOverlib($data['recipe_tooltip'], '', $data['item_color'], 0, $roster->config['locale']);
             $recipexx[$skill][$type][$recipe]['itemlink'] = $recipeee->tpl_get_itemlink();
             $recipexx[$skill][$type][$recipe]['quality'] = $recipeee->_setQuality($data['item_color']);
         }
     }
     foreach ($recipexx as $skill_name => $header) {
         $roster->tpl->assign_block_vars('recipe', array('ID' => strtolower(str_replace(' ', '', $skill_name)), 'NAME' => $skill_name, 'ICON' => $this->locale['ts_iconArray'][$skill_name], 'TOOLTIP' => makeOverlib($skill_name, '', '', 1, '', ',WRAP'), 'LINK' => makelink('#' . strtolower(str_replace(' ', '', $skill_name)))));
         foreach ($header as $hname => $recipe) {
             $roster->tpl->assign_block_vars('recipe.header', array('NAME' => $hname));
             foreach ($recipe as $name => $data) {
                 if (isset($data['sub'])) {
                     $roster->tpl->assign_block_vars('recipe.header.subheader', array('NAME' => $name));
                     foreach ($data as $s => $dat) {
                         if ($s != 'sub') {
                             $roster->tpl->assign_block_vars('recipe.header.subheader.rows', array('ROW_CLASS' => $roster->switch_row_class(), 'DIFFICULTY' => $dat['difficulty'], 'L_DIFFICULTY' => $roster->locale->act['recipe_' . $dat['difficulty']], 'ITEM_COLOR' => $dat['item_color'], 'NAME' => $s, 'DIFFICULTY_COLOR' => $this->diff($dat['difficulty']), 'TYPE' => $dat['recipe_type'], 'LEVEL' => $dat['level'], 'ICON' => $dat['icon'], 'TOOLTIP' => $dat['tooltip'], 'ITEMLINK' => $dat['itemlink'], 'QUALITY' => $dat['quality']));
                             $reagents = explode('|', $dat['reagents']);
                             if (is_array($reagents)) {
                                 foreach ($reagents as $reagent) {
                                     $dtr = explode(':', $reagent);
                                     if (empty($dtr[0])) {
                                         $roster->tpl->assign_block_vars('recipe.header.subheader.rows.reagents', array('DATA' => $reagent, 'ID' => '000', 'NAME' => 'Missing', 'ITEM_COLOR' => '000000', 'QUALITY' => recipe::getQualityName('ffffff'), 'COUNT' => '0', 'ICON' => 'inv_misc_questionmark', 'TOOLTIP' => makeOverlib('Missing data', '', '', 0, $this->data['clientLocale'], ',RIGHT')));
                                     } else {
                                         $roster->tpl->assign_block_vars('recipe.header.subheader.rows.reagents', array('DATA' => $reagent, 'ID' => $reagent_arr[$dtr[0]]['item_id'], 'NAME' => $reagent_arr[$dtr[0]]['item_name'], 'ITEM_COLOR' => $reagent_arr[$dtr[0]]['item_color'], 'QUALITY' => recipe::getQualityName($reagent_arr[$dtr[0]]['item_color']), 'COUNT' => $dtr[1], 'ICON' => $reagent_arr[$dtr[0]]['item_texture'], 'TOOLTIP' => makeOverlib($reagent_arr[$dtr[0]]['tooltip'], '', '', 0, $this->data['clientLocale'], ',RIGHT')));
                                     }
                                 }
                             }
                         }
                     }
                 } else {
                     $roster->tpl->assign_block_vars('recipe.header.row', array('ROW_CLASS' => $roster->switch_row_class(), 'DIFFICULTY' => $this->diff($data['difficulty']), 'L_DIFFICULTY' => $roster->locale->act['recipe_' . $data['difficulty']], 'ITEM_COLOR' => $data['item_color'], 'NAME' => $name, 'DIFFICULTY_COLOR' => $this->diff($data['difficulty']), 'TYPE' => $data['recipe_type'], 'LEVEL' => $data['level'], 'ICON' => $data['icon'], 'TOOLTIP' => $data['tooltip'], 'ITEMLINK' => $data['itemlink'], 'QUALITY' => $data['quality']));
                     $reagents = explode('|', $data['reagents']);
                     //echo $name.'<br>';
                     if (is_array($reagents)) {
                         //print_r($reagents);
                         //echo '<pre><br>';
                         foreach ($reagents as $reagent) {
                             $dtr = explode(':', $reagent);
                             if (empty($dtr[0])) {
                                 $roster->tpl->assign_block_vars('recipe.header.row.reagents', array('DATA' => $reagent, 'ID' => '000', 'NAME' => 'Missing', 'ITEM_COLOR' => '000000', 'QUALITY' => recipe::getQualityName('ffffff'), 'COUNT' => '0', 'ICON' => 'inv_misc_questionmark', 'TOOLTIP' => makeOverlib('Missing data', '', '', 0, $this->data['clientLocale'], ',RIGHT')));
                             } else {
                                 $roster->tpl->assign_block_vars('recipe.header.row.reagents', array('DATA' => $reagent, 'ID' => $reagent_arr[$dtr[0]]['item_id'], 'NAME' => $reagent_arr[$dtr[0]]['item_name'], 'ITEM_COLOR' => $reagent_arr[$dtr[0]]['item_color'], 'QUALITY' => recipe::getQualityName($reagent_arr[$dtr[0]]['item_color']), 'COUNT' => $dtr[1], 'ICON' => $reagent_arr[$dtr[0]]['item_texture'], 'TOOLTIP' => makeOverlib($reagent_arr[$dtr[0]]['tooltip'], '', '', 0, $this->data['clientLocale'], ',RIGHT')));
                             }
                         }
                     }
                 }
             }
         }
     }
     /*
     if (isset($recipes[0]))
     {
     	$recipe_arr = array();
     	foreach ($recipes as $object)
     	{
     		$skill = $object->data['skill_name'];
     		$recipe = $object->data['recipe_name'];
     		$recipe_arr[$skill][$recipe]['recipe_type'] = $object->data['recipe_type'];
     		$recipe_arr[$skill][$recipe]['difficulty'] = $object->data['difficulty'];
     		$recipe_arr[$skill][$recipe]['item_color'] = $object->data['item_color'];
     		$recipe_arr[$skill][$recipe]['reagents'] = $object->data['reagents'];
     		$recipe_arr[$skill][$recipe]['recipe_texture'] = $object->data['recipe_texture'];
     		$recipe_arr[$skill][$recipe]['level'] = $object->data['level'];
     		$recipe_arr[$skill][$recipe]['item_id'] = $object->data['item_id'];
     		$recipe_arr[$skill][$recipe]['recipe_id'] = $object->data['recipe_id'];
     		$recipe_arr[$skill][$recipe]['icon'] = $object->tpl_get_icon();
     		$recipe_arr[$skill][$recipe]['tooltip'] = $object->tpl_get_tooltip();
     		$recipe_arr[$skill][$recipe]['itemlink'] = $object->tpl_get_itemlink();
     		$recipe_arr[$skill][$recipe]['quality'] = $object->quality;
     	}
     
     //			echo '<pre>';
     //			print_r($recipe_arr);
     
     	foreach ($recipe_arr as $skill_name => $recipe)
     	{
     		$roster->tpl->assign_block_vars('recipe',array(
     			'ID'      => strtolower(str_replace(' ','',$skill_name)),
     			'NAME'    => $skill_name,
     			'ICON'    => $this->locale['ts_iconArray'][$skill_name],
     			'TOOLTIP' => makeOverlib($skill_name,'','',1,'',',WRAP'),
     			'LINK'    => makelink('#' . strtolower(str_replace(' ','',$skill_name))),
     			)
     		);
     		foreach ($recipe as $name => $data)
     		{
     			switch ($data['difficulty'])
     			{
     				case 5 :
     					$difficultycolor = 'red'; //difficult
     					break;
     
     				case 4 :
     					$difficultycolor = 'orange'; //optimal
     					break;
     
     				case 3 :
     					$difficultycolor = 'yellow'; //medium
     					break;
     
     				case 2 :
     					$difficultycolor = 'green'; //easy
     					break;
     
     				case 1 :
     				default :
     					$difficultycolor = 'grey'; //trivial
     					break;
     			}
     
     			$roster->tpl->assign_block_vars('recipe.row',array(
     				'ROW_CLASS'    => $roster->switch_row_class(),
     				'DIFFICULTY'   => $data['difficulty'],
     				'L_DIFFICULTY' => $roster->locale->act['recipe_' . $data['difficulty']],
     				'ITEM_COLOR'   => $data['item_color'],
     				'NAME'         => $name,
     				'DIFFICULTY_COLOR' => $difficultycolor,
     				'TYPE'         => $data['recipe_type'],
     				'LEVEL'        => $data['level'],
     				'ICON'         => $data['icon'],
     				'TOOLTIP'      => $data['tooltip'],
     				'ITEMLINK'     => $data['itemlink'],
     				'QUALITY'      => $data['quality'],
     				)
     			);
     
     			$reagents = explode('|',$data['reagents']);
     
     			//echo $name.'<br>';
     			if ( is_array($reagents) )
     			{
     			//print_r($reagents);
     			//echo '<pre><br>';
     			foreach ($reagents as $reagent)
     			{
     				$dtr = explode(':', $reagent);
     				//print_r($reagent);
     				//echo '<br>';
     				//echo $dtr[0].' -|- '.
     				//print_r($reagent_arr[$dtr[0]]);
     				//echo '<br><hr><br>';
     				if (empty($dtr[0]))
     				{
     					$roster->tpl->assign_block_vars('recipe.row.reagents',array(
     						'DATA' 		 => $reagent,
     						'ID' 		 => '000',
     						'NAME' 		 => 'Missing',
     						'ITEM_COLOR' => '000000',
     						'QUALITY'    => recipe::getQualityName('ffffff'),
     						'COUNT' 	 => '0',
     						'ICON' 		 => 'inv_misc_questionmark',
     						'TOOLTIP' 	 => makeOverlib('Missing data','','',0,$this->data['clientLocale'],',RIGHT'),
     						)
     					);
     				}
     				else
     				{
     					$roster->tpl->assign_block_vars('recipe.row.reagents',array(
     						'DATA' 		 => $reagent,
     						'ID' 		 => $reagent_arr[$dtr[0]]['item_id'],
     						'NAME' 		 => $reagent_arr[$dtr[0]]['item_name'],
     						'ITEM_COLOR' => $reagent_arr[$dtr[0]]['item_color'],
     						'QUALITY'    => recipe::getQualityName($reagent_arr[$dtr[0]]['item_color']),
     						'COUNT' 	 => $dtr[1],
     						'ICON' 		 => $reagent_arr[$dtr[0]]['item_texture'],
     						'TOOLTIP' 	 => makeOverlib($reagent_arr[$dtr[0]]['tooltip'],'','',0,$this->data['clientLocale'],',RIGHT'),
     						)
     					);
     				}
     				}
     			}
     		}
     	}
     }
     */
     //echo '<pre>';print_r($recipexx);echo '</pre>';
     $roster->tpl->set_filenames(array('recipes' => $addon['basename'] . '/recipes.html'));
     return $roster->tpl->fetch('recipes');
 }
Beispiel #2
0
 function search($search, $limit = 10, $page = 0)
 {
     global $roster;
     $first = $page * $limit;
     $sql = "SELECT `players`.`name`, `players`.`member_id`, `players`.`server`, `players`.`region`, `recipes`.*" . " FROM `" . $roster->db->table('recipes') . "` AS recipes,`" . $roster->db->table('players') . "` AS players" . " WHERE `recipes`.`member_id` = `players`.`member_id`" . " AND (`recipes`.`recipe_name` LIKE '%{$search}%' OR `recipes`.`recipe_tooltip` LIKE '%{$search}%')" . ($this->minlvl != '' ? " AND `recipes`.`level` >= '{$this->minlvl}'" : '') . ($this->maxlvl != '' ? " AND `recipes`.`level` <= '{$this->maxlvl}'" : '') . $this->quality_sql . " ORDER BY `recipes`.`recipe_name` ASC, `recipes`.`recipe_type` ASC" . ($limit > 0 ? " LIMIT {$first}," . $limit : '') . ';';
     //calculating the search time
     $this->start_search = format_microtime();
     $result = $roster->db->query($sql);
     $this->stop_search = format_microtime();
     $this->time_search = $this->stop_search - $this->start_search;
     $nrows = $roster->db->num_rows($result);
     $x = $limit > $nrows ? $nrows : ($limit > 0 ? $limit : $nrows);
     if ($nrows > 0 && $limit > 0) {
         while ($x > 0) {
             $row = $roster->db->fetch($result);
             $icon = new recipe($row);
             $item['html'] = '<td class="SearchRowCell">' . $icon->out(true) . '</td>' . '<td class="SearchRowCell">' . $icon->data['level'] . '</td>' . '<td class="SearchRowCell"><span style="color:#' . $icon->data['item_color'] . '">[' . $icon->data['recipe_name'] . ']</span></td>' . '<td class="SearchRowCell">' . $icon->data['skill_name'] . '<br />' . $icon->data['recipe_type'] . '</td>' . '<td class="SearchRowCell">' . str_replace('<br>', '<br />', $icon->data['reagents']) . '</td>' . '<td class="SearchRowCellRight"><a href="' . makelink('char-info-recipes&amp;a=c:' . $row['member_id'] . '#' . strtolower(str_replace(' ', '', $icon->data['skill_name']))) . '"><strong>' . $row['name'] . '</strong></a></td>';
             $this->add_result($item);
             unset($item);
             $x--;
         }
     } else {
         $this->result_count = $nrows;
     }
     $roster->db->free_result($result);
 }