Exemple #1
0
 function ligaDesligaTemas($ligar, $desligar, $adicionar = "nao")
 {
     if (strTolower($adicionar) == "sim") {
         $teste = explode(",", $ligar);
         $adicionar = array();
         $verificar = array();
         foreach ($this->layers as $layerE) {
             $verificar[] = $layerE->getmetadata("nomeoriginal");
             $verificar[] = $layerE->name;
         }
         foreach ($teste as $t) {
             if (!in_array($t, $verificar)) {
                 $adicionar[] = $t;
             }
         }
         if (count($adicionar > 0)) {
             $this->adicionaTema(implode(",", $adicionar), $this->locaplic, $random = "sim");
             $this->salva();
             $this->mapa = ms_newMapObj($this->arquivo);
             $c = $this->mapa->numlayers;
             for ($i = 0; $i < $c; ++$i) {
                 $this->layers[] = $this->mapa->getlayer($i);
             }
         }
     }
     if ($desligar == "todos") {
         $desligar = $this->mapa->getalllayernames();
         $desligar = implode(",", $desligar);
     }
     if ($ligar != "") {
         $listal = explode(",", $ligar);
         foreach ($listal as $layer) {
             $ls = array();
             $vermultilayer = new vermultilayer();
             $vermultilayer->verifica($this->arquivo, $layer);
             if ($vermultilayer->resultado == 1) {
                 $ls = $vermultilayer->temas;
             }
             $ls[] = $layer;
             foreach ($ls as $l) {
                 $l = $this->mapa->getlayerbyname($l);
                 if ($l) {
                     $l->set("status", 2);
                 }
             }
         }
     }
     if ($desligar != "") {
         $listad = explode(",", $desligar);
         foreach ($listad as $layer) {
             $ls = array();
             $vermultilayer = new vermultilayer();
             $vermultilayer->verifica($this->arquivo, $layer);
             if ($vermultilayer->resultado == 1) {
                 $ls = $vermultilayer->temas;
             } else {
                 $ls[] = $layer;
             }
             foreach ($ls as $l) {
                 $l = $this->mapa->getlayerbyname($l);
                 if ($l) {
                     $l->set("status", 0);
                 }
             }
         }
     }
     return "ok";
 }
Exemple #2
0
 /**
  * Return the type of the given object
  *
  * @param array request      the $_REQUEST object. Extract the 'on' param to get the object type
  * @param bool upper         if TRUE the return value is in UPPER CASE
  * @return string            a new object of $_REQUEST['on'] type
  * @access public
  */
 public static function getObjectAction(array $request = array(), $upper = false)
 {
     if (!isset($request['act']) || $request['act'] == '') {
         return 'list';
     }
     return strTolower($request['act']);
 }
Exemple #3
0
 /**
  * Return the geo schema name
  */
 public static function getTableSRID($table, $schema = 'public', $geoCol = 'the_geom')
 {
     $table = strTolower($table);
     if (strpos($table, '.') !== false) {
         list($schema, $table) = explode('.', $table);
     }
     $sql = "SELECT srid\r\n                FROM public.geometry_columns\r\n                WHERE f_table_catalog='' AND f_table_schema='{$schema}' AND f_table_name='{$table}' AND f_geometry_column='{$geoCol}'";
     return ezcDbInstance::get()->query($sql)->fetchColumn();
 }
Exemple #4
0
function enchants()
{
    // from g_item_slots: 13:"One-Hand", 26:"Ranged", 17:"Two-Hand",
    $slotPointer = [13, 17, 26, 26, 13, 17, 17, 13, 17, null, 17, null, null, 13, null, 13, null, null, null, null, 17];
    $castItems = [];
    $successs = true;
    $enchantSpells = new SpellList([['effect1Id', 53], ['name_loc0', 'QA%', '!'], CFG_SQL_LIMIT_NONE]);
    // enchantItemPermanent && !qualityAssurance
    // check directory-structure
    foreach (Util::$localeStrings as $dir) {
        if (!CLISetup::writeDir('datasets/' . $dir)) {
            $success = false;
        }
    }
    $enchIds = [];
    foreach ($enchantSpells->iterate() as $__) {
        $enchIds[] = $enchantSpells->getField('effect1MiscValue');
    }
    $enchMisc = [];
    $enchJSON = Util::parseItemEnchantment($enchIds, false, $enchMisc);
    foreach (CLISetup::$localeIds as $lId) {
        set_time_limit(120);
        User::useLocale($lId);
        Lang::load(Util::$localeStrings[$lId]);
        $enchantsOut = [];
        foreach ($enchantSpells->iterate() as $__) {
            // slots have to be recalculated
            $slot = 0;
            if ($enchantSpells->getField('equippedItemClass') == 4) {
                if ($invType = $enchantSpells->getField('equippedItemInventoryTypeMask')) {
                    $slot = $invType >> 1;
                } else {
                    /* if (equippedItemSubClassMask == 64) */
                    // shields have it their own way <_<
                    $slot = 1 << 14 - 1;
                }
            } else {
                if ($enchantSpells->getField('equippedItemClass') == 2) {
                    foreach ($slotPointer as $i => $sp) {
                        if (!$sp) {
                            continue;
                        }
                        if (1 << $i & $enchantSpells->getField('equippedItemSubClassMask')) {
                            if ($sp == 13) {
                                // also mainHand & offHand *siiigh*
                                $slot |= 1 << 21 - 1 | 1 << 22 - 1;
                            }
                            $slot |= 1 << $sp - 1;
                        }
                    }
                }
            }
            $eId = $enchantSpells->getField('effect1MiscValue');
            // defaults
            $ench = array('name' => [], 'quality' => -1, 'icon' => strToLower($enchantSpells->getField('iconString')), 'source' => [], 'skill' => -1, 'slots' => [], 'enchantment' => Util::localizedString($enchMisc[$eId]['text'], 'text'), 'jsonequip' => @$enchJSON[$eId] ?: [], 'temp' => 0, 'classes' => 0);
            if (isset($enchMisc[$eId]['reqskill'])) {
                $ench['jsonequip']['reqskill'] = $enchMisc[$eId]['reqskill'];
            }
            if (isset($enchMisc[$eId]['reqskillrank'])) {
                $ench['jsonequip']['reqskill'] = $enchMisc[$eId]['reqskillrank'];
            }
            if (isset($enchMisc[$eId]['requiredLevel'])) {
                $ench['jsonequip']['requiredLevel'] = $enchMisc[$eId]['requiredLevel'];
            }
            // check if the spell has an entry in skill_line_ability -> Source:Profession
            if ($skills = $enchantSpells->getField('skillLines')) {
                $ench['name'][] = $enchantSpells->getField('name', true);
                $ench['source'][] = $enchantSpells->id;
                $ench['skill'] = $skills[0];
                $ench['slots'][] = $slot;
            }
            // check if this spell can be cast via item -> Source:Item
            if (!isset($castItems[$enchantSpells->id])) {
                $castItems[$enchantSpells->id] = new ItemList([['spellId1', $enchantSpells->id], ['name_loc0', 'Scroll of Enchant%', '!']]);
            }
            // do not reuse enchantment scrolls
            $cI =& $castItems[$enchantSpells->id];
            // this construct is a bit .. unwieldy
            foreach ($cI->iterate() as $__) {
                $ench['name'][] = $cI->getField('name', true);
                $ench['source'][] = -$cI->id;
                $ench['icon'] = strTolower($cI->getField('iconString'));
                $ench['slots'][] = $slot;
                if ($cI->getField('quality') > $ench['quality']) {
                    $ench['quality'] = $cI->getField('quality');
                }
                if ($cI->getField('requiredClass') > 0) {
                    $ench['classes'] = $cI->getField('requiredClass');
                    $ench['jsonequip']['classes'] = $cI->getField('requiredClass');
                }
                if (!isset($ench['jsonequip']['reqlevel'])) {
                    if ($cI->getField('requiredLevel') > 0) {
                        $ench['jsonequip']['reqlevel'] = $cI->getField('requiredLevel');
                    }
                }
            }
            // enchant spell not in use
            if (empty($ench['source'])) {
                continue;
            }
            // everything gathered
            if (isset($enchantsOut[$eId])) {
                foreach ($enchantsOut[$eId] as $k => $v) {
                    if (is_array($v)) {
                        while ($pop = array_pop($ench[$k])) {
                            $enchantsOut[$eId][$k][] = $pop;
                        }
                    } else {
                        if ($k == 'quality') {
                            if ($enchantsOut[$eId]['source'][0] > 0 && $ench['source'][0] < 0) {
                                $enchantsOut[$eId][$k] = -1;
                            } else {
                                if ($enchantsOut[$eId]['source'][0] < 0 && $ench['source'][0] > 0) {
                                    $enchantsOut[$eId][$k] = -1;
                                } else {
                                    $enchantsOut[$eId][$k] = $ench[$k];
                                }
                            }
                        } else {
                            if ($enchantsOut[$eId][$k] <= 0) {
                                $enchantsOut[$eId][$k] = $ench[$k];
                            }
                        }
                    }
                }
            } else {
                // nothing yet, create new
                $enchantsOut[$eId] = $ench;
            }
        }
        // walk over each entry and strip single-item arrays
        foreach ($enchantsOut as &$ench) {
            foreach ($ench as $k => $v) {
                if (is_array($v) && count($v) == 1 && $k != 'jsonequip') {
                    $ench[$k] = $v[0];
                }
            }
        }
        $toFile = "var g_enchants = " . Util::toJSON($enchantsOut) . ";";
        $file = 'datasets/' . User::$localeString . '/enchants';
        if (!CLISetup::writeFile($file, $toFile)) {
            $success = false;
        }
    }
    return $successs;
}
Exemple #5
0
 /**
  * Return the table definition DDL
  *
  * @param string         table or schema.table
  * @return array
  * @access public
  */
 public function getTableDescDDL($table)
 {
     $table = strTolower($table);
     // TODO: if table has no schema part, should we then read the search_path?
     if (strpos($table, '.') === false) {
         // Search for temporary first!
         $schema = 'public';
     } else {
         list($schema, $table) = explode('.', $table);
     }
     $sql = "SELECT " . "  column_name, column_default, is_nullable, data_type, character_maximum_length, " . "  numeric_precision, numeric_scale, datetime_precision " . "FROM " . "  information_schema.columns " . "WHERE " . "  table_schema='{$schema}' AND " . "  table_name='{$table}' " . "ORDER BY " . "  ordinal_position";
     // echo $sql;
     return $sql;
 }