Пример #1
0
 public static function test($fpTypeID)
 {
     $ob_mapping = new Mapping();
     $table_name = $ob_mapping->get_mappped_value('map_table_names', 'l_mlp_property');
     $querySelect = "SELECT 1 FROM {$table_name} WHERE listingType = 'rhsProject' AND fpTypeID = {$fpTypeID} AND specialListingID = 3";
     my_print($querySelect);
     $dbhSelect = self::$dbh->prepare($querySelect);
     if (!$dbhSelect) {
         my_print(self::$dbh->errorInfo());
         die;
     }
     $dbhSelect->execute();
     $ar_result = $dbhSelect->fetchAll(PDO::FETCH_ASSOC);
     if (count($ar_result)) {
         return false;
     }
     $queryInsert = "INSERT INTO {$table_name} (listingType, fpTypeID, specialListingID) VALUES ('rhsProject', {$fpTypeID}, 3)";
     $dbhInsert = self::$dbh->prepare($queryInsert);
     if (!$dbhInsert) {
         my_print(self::$dbh->errorInfo());
         die;
     }
     $dbhInsert->execute();
     $last_id = self::$dbh->lastInsertId();
     return $last_id;
 }
 public function setMapping(Mapping $mapping)
 {
     if ($mapping) {
         $this->utilSetFieldFromArray('data_json', 'mapping_id', $mapping->getId());
     } else {
         $this->utilSetFieldFromArray('data_json', 'mapping_id', null);
     }
 }
Пример #3
0
 public static function Initialize()
 {
     $userMapping = new Mapping("User", "T_User");
     $userMapping->AddColumn("UserId", "Id");
     $userMapping->AddColumn("CreationDate", "CreDat");
     $userMapping->AddColumn("IsAdministrator", "IsAdmin");
     self::$Mappings = array("User" => $userMapping);
 }
Пример #4
0
 /**
  * Метод регистрируем маппинг
  */
 protected final function register(Mapping $mapping)
 {
     if (array_key_exists($mapping->getHash(), $this->mappings)) {
         raise_error("Маппинг '{$mapping}' уже заругистрирован");
     } else {
         $this->mappings[$mapping->getHash()] = $mapping;
     }
 }
Пример #5
0
 public static function get_appointment_data($table_name, $appointmentID, $column_name = NULL)
 {
     if (empty($appointmentID)) {
         die("The appointmentID can not be null. \n");
     }
     if (!is_numeric($appointmentID)) {
         die("The appointmentID should be numeric. \n");
     }
     $column_name = $column_name ? $column_name : 'appointmentID';
     // To do - validate the $table_name
     $ob_mapping = new Mapping();
     $data = self::get_data($ob_mapping->get_mappped_value($table_name), $column_name, $appointmentID);
     return $data;
 }
Пример #6
0
 public static function get_data($table_name, $id_field = '', $id_value = '')
 {
     $ob_mapping = new Mapping();
     $table_name = $ob_mapping->get_mappped_value($table_name);
     $query = "SELECT * FROM {$table_name} ";
     if ($id_field != '' && $id_value != '') {
         $query .= "WHERE {$id_field} = {$id_value}";
     }
     $dbh = self::$dbh->prepare($query);
     if (!$dbh) {
         my_print(self::$dbh->errorInfo());
         die;
     }
     $dbh->execute();
     return $dbh->fetchAll(PDO::FETCH_ASSOC);
 }
Пример #7
0
 public function __construct($node, $parent)
 {
     parent::__construct($node, $parent);
     self::$possible_attributes = array_merge(parent::$possible_attributes, self::$possible_attributes);
     self::$required_attributes = array_merge(parent::$required_attributes, self::$required_attributes);
     self::$possible_children = array_merge(parent::$possible_children, self::$possible_children);
     self::$required_children = array_merge(parent::$required_children, self::$required_children);
 }
 /**
  * create type mapping object
  *
  * @param array $indexConfig
  * @return Mapping
  */
 protected function createMapping($indexConfig)
 {
     /*$mapping = $this->createMapping($indexConfig['config']['properties'][$typeName]);*/
     $mapping = Mapping::create($indexConfig['properties']);
     $mappingSpecialFields = array('_uid', '_id', '_source', '_all', '_analyzer', '_boost', '_routing', '_index', '_size', '_timestamp', '_ttl', 'dynamic_templates');
     foreach ($mappingSpecialFields as $specialField) {
         if (isset($indexConfig[$specialField])) {
             $mapping->setParam($specialField, $indexConfig[$specialField]);
         }
     }
     if (isset($indexConfig['_parent'])) {
         $mapping->setParam('_parent', array('type' => $indexConfig['_parent']['type']));
     }
     return $mapping;
 }
Пример #9
0
 /**
  * Creates a mapping from given type.
  *
  * @param string $type The type
  *
  * @return Mapping
  */
 public function of($type)
 {
     $isArray = '[]' === substr($type, -2);
     if ($isArray) {
         $type = substr($type, 0, -2);
     }
     if (array_key_exists($type, $this->mappings)) {
         $mapping = clone $this->mappings[$type];
     } else {
         $refl = new \ReflectionClass($type);
         $mapping = new Mapping(new Emitter(), $this->extensions);
         foreach ($refl->getProperties() as $prop) {
             if ($child = $this->mappingFromProp($prop)) {
                 $mapping->addChild($prop->getName(), $child);
             }
         }
         $mapping->transformTo($type);
         $this->mappings[$type] = clone $mapping;
     }
     if ($isArray) {
         $mapping = $mapping->multiple();
     }
     return $mapping;
 }
Пример #10
0
 public static function createCustomerXml($customer)
 {
     $docXml = self::createResponseXml();
     $request = $docXml->createElement("request");
     $customerElem = $docXml->createElement("Client_Web");
     $customerElem->setAttribute('Code_Site_Web', GlobalConfig::getWebSiteCode());
     $customerElem->setAttribute('Login', $customer['id_customer']);
     $customerElem->setAttribute('Civilite', Mapping::psCivility2OsiCivility($customer['id_gender']));
     $customerElem->setAttribute('Nom', $customer['customerLastname']);
     $customerElem->setAttribute('Prenom', $customer['customerFirstname']);
     $customerElem->setAttribute('Societe', $customer['company']);
     $customerElem->setAttribute('Adresse_1', $customer['address1']);
     $customerElem->setAttribute('Adresse_2', $customer['address2']);
     $customerElem->setAttribute('Code_Postal', $customer['postcode']);
     $customerElem->setAttribute('Ville', $customer['city']);
     $customerElem->setAttribute('Code_Pays', $customer['iso_code']);
     $phone = $customer["phone"] != "" ? $customer["phone"] : $customer["phone_mobile"];
     $customerElem->setAttribute('Telephone', $phone);
     $customerElem->setAttribute('Email', $customer['email']);
     $request->appendChild($customerElem);
     $docXml->appendChild($request);
     return $docXml->saveXML();
 }
Пример #11
0
/**
 * Check if a domain has a mapping available
 *
 * @param stdClass|null $site Site object if already found, null otherwise
 * @param string $domain Domain we're looking for
 * @return stdClass|null Site object if already found, null otherwise
 */
function check_domain_mapping($site, $domain)
{
    // Have we already matched? (Allows other plugins to match first)
    if (!empty($site)) {
        return $site;
    }
    global $wpdb;
    // Grab both WWW and no-WWW
    if (strpos($domain, 'www.') === 0) {
        $www = $domain;
        $nowww = substr($domain, 4);
    } else {
        $nowww = $domain;
        $www = 'www.' . $domain;
    }
    $mapping = Mapping::get_by_domain(array($www, $nowww));
    if (empty($mapping) || is_wp_error($mapping)) {
        return $site;
    }
    // Ignore non-active domains
    if (!$mapping->is_active()) {
        return $site;
    }
    // Fetch the actual data for the site
    $mapped_site = $mapping->get_site();
    if (empty($mapped_site)) {
        return $site;
    }
    // Note: This is only for backwards compatibility with WPMU Domain Mapping,
    // do not rely on this constant in new code.
    defined('DOMAIN_MAPPING') or define('DOMAIN_MAPPING', 1);
    return $mapped_site;
}
    if (count($parts) !== 3) {
        continue;
    }
    list($s, $p, $o) = $parts;
    $key = $s . '#' . $o;
    if (array_key_exists($key, $wikidataValues)) {
        $wikidataValues[$key] .= "\t" . $p;
    } else {
        $wikidataValues[$key] = $p;
    }
}
fclose($input);
echo "\nLoad Freebase and compute\n";
$count = 0;
$input = fopen($argv[2], 'r');
$mapping = new Mapping(new DummyCVTProvider(), new DummyReviewedFacts(), $argv[3]);
$isoDateParser = new ValueParsers\IsoTimestampParser(new ValueParsers\CalendarModelParser(new ValueParsers\ParserOptions()), new ValueParsers\ParserOptions());
while ($line = fgets($input)) {
    $count++;
    if ($count % 1000000 === 0) {
        echo '.';
    }
    list($s, $p, $o) = explode("\t", trim($line, " .\t\n\r\v"), 3);
    $s = substr($s, 28, -1);
    if (!$mapping->isFreebaseMapped($s)) {
        continue;
    }
    $s = $mapping->mapMid($s);
    $p = substr($p, 24, -1);
    //Format object
    if ($o[0] === '"') {
    public function countUsedFacts()
    {
        $count = 0;
        foreach ($this->reviewedFacts as $used) {
            if ($used) {
                $count++;
            }
        }
        return $count;
    }
}
$outputdirectory = $argv[4];
$input = fopen($argv[1], 'r');
$cvtStorage = new CvtStorage();
$reviewedFactsStorage = new ReviewedFactsStorage();
$mapping = new Mapping($cvtStorage, $reviewedFactsStorage, $argv[3]);
print_r($mapping->getStatistics());
//Extract CVTss
if (file_exists($outputdirectory . '/cvt-triples.tsv')) {
    echo "\nLoading CVTs\n";
    $cvtStorage->loadfromFile($outputdirectory . '/cvt-triples.tsv');
} else {
    //Find CVT nodes
    $cvtMids = array();
    if (file_exists($outputdirectory . '/freebase-cvt-ids.csv')) {
        $cvtIdsFile = fopen($outputdirectory . '/freebase-cvt-ids.csv', 'r');
        while ($line = fgets($cvtIdsFile)) {
            $cvtMids[trim($line)] = true;
        }
        fclose($cvtIdsFile);
    } else {
Пример #14
0
 /**
  * create object from  array
  * @see parent::fromArray
  * @param array $array
  */
 public function fromArray($array)
 {
     if (!empty($array['number'])) {
         $this->_ensureNumber()->fromArray($array['number']);
         unset($array['number']);
     }
     if (!empty($array['map_data'])) {
         $this->setMapData(Mapping::create($array['map_data']));
         unset($array['map_data']);
     }
     parent::fromArray($array);
 }
Пример #15
0
 /**
  * factory to build mapping object by params array
  * @param array $params array of key=>value properties
  * @return Mapping
  */
 public static function create($params = array())
 {
     if (isset($params['type'])) {
         $className = "Didww\\API2\\Mapping\\" . $params['type'];
         $mapping = new $className();
         unset($params['type']);
     } else {
         $mapping = new Mapping();
     }
     $mapping->fromArray($params);
     return $mapping;
 }
Пример #16
0
// Begin script
debug_message('Script begin.');
/**
 *	Save the Agent information
 */
$ra = @$_SERVER['REMOTE_ADDR'];
$hua = @$_SERVER['HTTP_USER_AGENT'];
$ob_log->write("Remote IP: {$ra}");
$ob_log->write("Remote User Agents: {$hua}");
/***

Availble variables
	$ob_property
	$ob_appointment 
*/
$ob_map = new Mapping();
// Get all appointments whose status is complete
// To do - This should go in the Appointment class
$results = $ob_appointment::get_complted_appointments();
$count = count($results);
$ob_log->write("Total {$count} completed appointment found.");
// Go through each result
foreach ($results as $key => $result) {
    $ap_details = array();
    $ai_details = array();
    $aw_details = array();
    $ak_details = array();
    $ab_details = array();
    $at_details = array();
    $al_details = array();
    // Get the appointment details
Пример #17
0
 public static function save_attributes($property_id, $attributes)
 {
     $map = new Mapping();
     foreach ($attributes as $key => $value) {
         $attr_type = self::get_attribute_type($key);
         if ($attr_type == 'select') {
             $map_value = $map->get_app_field_value($value);
             $attr_options = self::get_attribute_options($key);
             if ($key == 21) {
                 if ($map_value > 3) {
                     $map_value = '4+';
                 }
             }
             if ($key == 15 && $value == 'All Type') {
                 $map_value = 'No preference';
             }
             if ($key == 124 && $value > 0) {
                 $map_value = 'Yes';
             } elseif ($key == 124 && ($value = 0)) {
                 $map_value = 'No';
             }
             $attr_option_id = isset($attr_options[$map_value]) ? $attr_options[$map_value] : 0;
             $attr_option_value = $map_value;
         } elseif ($attr_type == 'multiselect') {
             $map_value = explode(',', $map->get_app_field_value($value));
             $attr_options = self::get_attribute_options($key);
             $options = $details = array();
             $i = 0;
             foreach ($attr_options as $id => $option) {
                 if (trim($map_value[$i]) == 'Y') {
                     $options[$id] = $option;
                     $details[$id] = $id;
                 }
                 $i++;
             }
             $attr_option_id = join($options, '#|#');
             $attr_option_value = join($details, '#|#');
         } else {
             $attr_option_id = 0;
             $attr_option_value = $map->get_app_field_value($value);
         }
         $ar_proprerty_attribute_values = array('propertyID' => $property_id, 'attributeID' => $key, 'attrOptionID' => $attr_option_id);
         $attrValueID = self::save_data('rp_property_attribute_values', $ar_proprerty_attribute_values);
         $ar_proprerty_attribute_values_l1 = array('attrValueID' => $attrValueID, 'languageID' => 1, 'attrDetValue' => $attr_option_value);
         $attrValueID = self::save_data('rp_property_attribute_value_details', $ar_proprerty_attribute_values_l1);
         $ar_proprerty_attribute_values_l2 = array('attrValueID' => $attrValueID, 'languageID' => 2, 'attrDetValue' => $attr_option_value);
         $attrValueID = self::save_data('rp_property_attribute_value_details', $ar_proprerty_attribute_values_l2);
     }
 }
Пример #18
0
 /**
  * Маппинг групп кешей к сущностям базы - таблицам и представлениям
  * 
  * @param str $postType - тип поста
  * @return MappingClient
  */
 public static final function CACHE_DBENTITYS()
 {
     return Mapping::inst(MapSrcCacheGroups::inst(array(), __FUNCTION__), MapSrcDbEntitys::inst(array(), __FUNCTION__), 'Группы кеширования к Таблицам и представлениям');
 }
 private function buildInquireMapping($xml)
 {
     $inquireMapping = new InquireMapping();
     $inquireMapping->setRequestId((string) $xml->RequestId);
     $mappings = new Mappings();
     $mappingArray = array();
     foreach ($xml->Mappings->Mapping as $mapping) {
         $tmpMapping = new Mapping();
         $tmpMapping->setMappingId((string) $mapping->MappingId);
         $tmpMapping->setSubscriberId((string) $mapping->SubscriberId);
         $tmpMapping->setAccountUsage((string) $mapping->AccountUsage);
         $tmpMapping->setDefaultIndicator((string) $mapping->DefaultIndicator);
         $tmpMapping->setAlias((string) $mapping->Alias);
         $tmpMapping->setICA((string) $mapping->ICA);
         $tmpMapping->setAccountNumber((string) $mapping->AccountNumber);
         $tmpCardholderFullName = new CardholderFullName();
         $cardholderFullName = $mapping->CardholderFullName;
         $tmpCardholderFullName->setCardholderFirstName((string) $cardholderFullName->CardholderFirstName);
         $tmpCardholderFullName->setCardholderMiddleName((string) $cardholderFullName->CardholderMiddleName);
         $tmpCardholderFullName->setCardholderLastName((string) $cardholderFullName->CardholderLastName);
         $tmpAddress = new Address();
         $address = $mapping->Address;
         $tmpAddress->setLine1((string) $address->line1);
         $tmpAddress->setLine2((string) $address->line2);
         $tmpAddress->setCity((string) $address->City);
         $tmpAddress->setCountrySubdivision((string) $address->CountrySubdivision);
         $tmpAddress->setPostalCode((string) $address->PostalCode);
         $tmpAddress->setCountry((string) $address->Country);
         $tmpReceivingEligibility = new ReceivingEligibility();
         $receivingEligibility = $mapping->ReceivingEligibility;
         $tmpReceivingEligibility->setEligible((string) $receivingEligibility->Eligible);
         $tmpCurrency = new Currency();
         $currency = $receivingEligibility->Currency;
         $tmpCurrency->setAlphaCurrencyCode((string) $currency->AlphaCurrencyCode);
         $tmpCurrency->setNumericCurrencyCode((string) $currency->NumericCurrencyCode);
         $tmpCountry = new Country();
         $country = $receivingEligibility->Country;
         $tmpCountry->setAlphaCountryCode((string) $country->AlphaCountryCode);
         $tmpCountry->setAlphaCountryCode((string) $country->NumericCountryCode);
         $tmpBrand = new Brand();
         $brand = $receivingEligibility->Brand;
         $tmpBrand->setAcceptanceBrandCode((string) $brand->AcceptanceBrandCode);
         $tmpBrand->setProductBrandCode((string) $brand->ProductBrandCode);
         $tmpMapping->setExpiryDate((string) $mapping->ExpiryDate);
         $tmpReceivingEligibility->setCurrency($tmpCurrency);
         $tmpReceivingEligibility->setCountry($tmpCountry);
         $tmpReceivingEligibility->setBrand($tmpBrand);
         $tmpMapping->setCardholderFullName($tmpCardholderFullName);
         $tmpMapping->setAddress($tmpAddress);
         $tmpMapping->setReceivingEligibility($tmpReceivingEligibility);
         array_push($mappingArray, $tmpMapping);
     }
     $mappings->setMapping($mappingArray);
     $inquireMapping->setMappings($mappings);
     return $inquireMapping;
 }
Пример #20
0
 /**
  * @param $string
  * @return string
  */
 public function valueMapping($string)
 {
     $matches = [];
     if (preg_match('/@([a-zA-Z\\d_\\-]+).@([a-zA-Z\\d_\\-]+)/', $string, $matches)) {
         $table = '';
         $column = '';
         if ($matches[1] == 'this') {
             $table = $this->classMapping['Table']->name;
             $column = $this->propertiesMapping[$matches[2]];
         } else {
             $nameSpace = $this->reflectionClass->getNamespaceName();
             $mapping = Mapping::getReader($nameSpace . '\\' . ucfirst($matches[1]));
             $table = $mapping->getClassMapping('Table')->name;
             $properties = $mapping->getPropertiesMapping();
             $column = $properties[$matches[2]];
         }
         return '`' . $table . '`' . '.' . '`' . $column . '`';
     } else {
         return $string;
     }
 }
Пример #21
0
 function offsetUnset($offset)
 {
     parent::offsetUnset($this->parseOffset($offset));
 }
Пример #22
0
 public static function update_data($table, $data, $key_field)
 {
     $ar_columns = array();
     $str_columns = array();
     // Todo : use a validation class to get validation massages
     if (!is_string($table)) {
         die("\$table should be a string \n");
     }
     if (!is_array($data)) {
         die("\$data should be an array \n");
     }
     if (!is_string($key_field)) {
         die("\$key_field should be an array \n");
     }
     if (isset($data[$key_field])) {
         $key_value = $data[$key_field];
         unset($data[$key_field]);
     } else {
         echo "The key field <em>{$key_field}</em> is not in the data.";
         die;
     }
     foreach ($data as $col_name => $col_value) {
         $ar_columns[] = "{$col_name} = '{$col_value}'";
     }
     $str_columns = join($ar_columns);
     $ob_mapping = new Mapping();
     $table_name = $ob_mapping->get_mappped_value('map_table_names', $table);
     $query = "UPDATE {$table_name} SET {$str_columns} WHERE {$key_field} = '{$key_value}'";
     $dbh = self::$dbh->prepare($query);
     //my_print($query);
     if (!$dbh) {
         my_print(self::$dbh->errorInfo());
         die;
     }
     $dbh->execute();
     $last_id = self::$dbh->lastInsertId();
     return $last_id;
 }
        }
    }
    fclose($input);
    echo "\nSaving Wikidata labels languages\n";
    $file = fopen($argv[4] . '/wikidata-labels-languages.tsv', 'w');
    foreach ($wikidataLabels as $qid => $languages) {
        fwrite($file, $qid . "\t" . implode(' ', $languages) . "\n");
    }
    fclose($file);
}
$input = fopen($argv[2], 'r');
$output = fopen($argv[4] . '/freebase-new-labels.tsv', 'w');
$LANGUAGE_CODE_CONVERSION = ['iw' => 'he', 'pt-pt' => 'pt', 'fil' => 'tl', 'es-419' => 'es', 'en-us' => 'en'];
//Count types
$count = 0;
$mapping = new Mapping(new DummyCVTProvider(), new DummyReviewedFacts(), $argv[3]);
echo "\nCreating missing labels list\n";
while ($line = fgets($input)) {
    list($mid, $labelSer) = explode("\t", trim($line));
    $parts = explode('@', $labelSer);
    if (count($parts) === 2) {
        list($label, $language) = $parts;
    } else {
        $label = $parts[0];
        for ($i = 1; $i < count($parts) - 1; $i++) {
            $label .= '@' . $parts[$i];
        }
        $language = $parts[$i];
    }
    $language = strtolower($language);
    if (array_key_exists($language, $LANGUAGE_CODE_CONVERSION)) {
Пример #24
0
 public function fromServiceData($properties)
 {
     $properties = (array) $properties;
     if ($this->_order) {
         $this->_order->setCountryIso($properties['country_iso']);
         $this->_order->setCityPrefix($properties['city_prefix']);
         $this->_order->setAutorenewEnable($properties['autorenew_enable']);
         $mappingVars = explode(":", $properties['did_mapping_format']);
         if (count($mappingVars) == 3) {
             $mapping = Mapping::create(array("map_type" => $mappingVars[0], "map_proto" => $mappingVars[1], "map_detail" => $mappingVars[2]));
             $this->_order->setMapData($mapping);
         }
     }
     unset($properties['city_prefix'], $properties['country_iso'], $properties['autorenew_enable']);
     $assignType = $this->getAssignType();
     $this->setAssignType(\Didww\API2\Object::ASSIGN_IGNORE);
     $this->fromArray($properties);
     $this->setAssignType($assignType);
 }
Пример #25
0
 /**
  * Маппинг фолдингов к сущностям БД
  * 
  * @param str $postType - тип поста
  * @return MappingClient
  */
 public static final function FOLDINGS2DB()
 {
     return Mapping::inst(MapSrcAllFoldings::inst(__FUNCTION__), MapSrcDbEntitys::inst(__FUNCTION__), 'Маппинг фолдингов к сущностям БД');
 }
Пример #26
0
 /**
  * Add properties to load.
  *
  * @param string[] $properties
  *
  * @return $this
  */
 public function addProperties($properties)
 {
     $this->mapping->addProperties($properties);
     return $this;
 }
Пример #27
0
 public function fromServiceData($properties)
 {
     $properties = (array) $properties;
     if ($this->_order) {
         $this->_order->setCountryIso($properties['country_iso']);
         $this->_order->setCityPrefix($properties['city_prefix']);
         $this->_order->setAutorenewEnable($properties['autorenew_enable']);
         // only URI supporting
         if (preg_match("/^URI:(\\w+)\\/(\\S+)\$/", $properties['did_mapping_format'], $matches)) {
             if (count($matches) == 3) {
                 $mapping = Mapping::create(array("map_type" => 'URI', "map_proto" => $matches[1], "map_detail" => $matches[2]));
                 $this->_order->setMapData($mapping);
             }
         }
     }
     unset($properties['city_prefix'], $properties['country_iso'], $properties['autorenew_enable']);
     $assignType = $this->getAssignType();
     $this->setAssignType(\Didww\API2\Object::ASSIGN_IGNORE);
     $this->fromArray($properties);
     $this->setAssignType($assignType);
 }
Пример #28
0
 /**
  * Puts a mapping on index
  *
  * @param array|object $mapping
  * @param array $config
  * @throws Exception
  * @return array
  */
 public function map($mapping, array $config = array())
 {
     if (is_array($mapping)) {
         $mapping = new Mapping($mapping);
     }
     $mapping->config($config);
     try {
         $type = $mapping->config('type');
     } catch (\Exception $e) {
     }
     // No type is cool
     if (isset($type) && !$this->passesTypeConstraint($type)) {
         throw new Exception("Cant create mapping due to type constraint mismatch");
     }
     return $this->request('_mapping', 'PUT', $mapping->export(), true);
 }
Пример #29
0
 public static function save_attributes($property_id, $attributes)
 {
     $map = new Mapping();
     foreach ($attributes as $key => $value) {
         $attr_type = self::get_attribute_type($key);
         if ($attr_type == 'select') {
             $map_value = $map->get_app_field_value($value);
             $attr_options = self::get_attribute_options($key);
             if ($key == 21) {
                 $map_value = 1;
             }
             if ($key == 15 && $value == 'All Type') {
                 $map_value = 'No preference';
             }
             if ($key == 124 && $value > 0) {
                 $map_value = 'Yes';
             } elseif ($key == 124 && ($value = 0)) {
                 $map_value = 'No';
             }
             $attr_option_id = isset($attr_options[$map_value]) ? $attr_options[$map_value] : 0;
             $attr_option_value = $map_value;
             //my_print('arrt_id: '.$key);
             //my_print('value: '.$value);
             //my_print('Map value: '.$map_value);
             //my_print($attr_options);
         } else {
             $attr_option_id = 0;
             $attr_option_value = $map->get_app_field_value($value);
         }
         //my_print($key . '::' .  $attr_option_id . '::' . $attr_option_value . '::' .  $attr_type);
         $ar_proprerty_attribute_values = array('propertyID' => $property_id, 'attributeID' => $key, 'attrOptionID' => $attr_option_id);
         $attrValueID = self::save_data('rp_property_attribute_values', $ar_proprerty_attribute_values);
         $ar_proprerty_attribute_values_l1 = array('attrValueID' => $attrValueID, 'languageID' => 1, 'attrDetValue' => $attr_option_value);
         $attrValueID = self::save_data('rp_property_attribute_value_details', $ar_proprerty_attribute_values_l1);
         $ar_proprerty_attribute_values_l2 = array('attrValueID' => $attrValueID, 'languageID' => 2, 'attrDetValue' => $attr_option_value);
         $attrValueID = self::save_data('rp_property_attribute_value_details', $ar_proprerty_attribute_values_l2);
     }
 }
Пример #30
0
                            break;
                        case MappingDetail::$MAPPING_AMOUNT:
                            // We may have Credit / Debit Column, so at one time there is one column have value one doesn't
                            if (trim($data[$map->getCsvColumnNumber()])) {
                                $activity->setAmount(trim($data[$map->getCsvColumnNumber()]));
                            }
                            break;
                        case MappingDetail::$MAPPING_NAME:
                            $activity->setName($data[$map->getCsvColumnNumber()]);
                            break;
                    }
                }
            }
            fclose($handle);
        }
        $transaction->commit();
        $smarty->assign('message', "Imported CSV successfully");
    }
    $smarty->assign('left_menu', true);
    $smarty->assign('mappingTypes', Mapping::getOptions(array('USER_ID' => $user->getId())) + Mapping::getOptions());
    $smarty->display('process.tpl');
} catch (AccessDeniedException $e) {
    header('HTTP/1.1 401 Access Denied');
    echo "AccessDeniedException: " . $e->getMessage();
} catch (Exception $e) {
    if ($transaction && !$transaction->isComplete()) {
        $transaction->rollback();
    }
    header('HTTP/1.1 500 Internal Server Error');
    echo "Exception: " . $e->getMessage();
}