Example #1
0
 /**
  * @param $category
  * @param $action
  * @param $label
  * @param $day
  * @param $month
  * @param $year
  * @return Event
  */
 public static function getByDate($category, $action, $label, $day, $month, $year)
 {
     $event = new self();
     try {
         $event->getDao()->getByDate($category, $action, $label, $day, $month, $year);
     } catch (\Exception $e) {
         $event->setTimestamp(mktime(1, 0, 0, $month, $day, $year));
         $event->setCategory($category);
         $event->setAction($action);
         $event->setLabel($label);
     }
     return $event;
 }
 /**
  * Read from a file
  *
  * @deprecated  Use img.io.MetaDataReader instead
  * @param   io.File file
  * @param   var default default void what should be returned in case no data is found
  * @return  img.util.IptcData
  * @throws  lang.FormatException in case malformed meta data is encountered
  * @throws  lang.ElementNotFoundException in case no meta data is available
  * @throws  img.ImagingException in case reading meta data fails
  */
 public static function fromFile(File $file)
 {
     if (FALSE === getimagesize($file->getURI(), $info)) {
         $e = new ImagingException('Cannot read image information from ' . $file->getURI());
         xp::gc(__FILE__);
         throw $e;
     }
     if (!isset($info['APP13'])) {
         if (func_num_args() > 1) {
             return func_get_arg(1);
         }
         throw new ElementNotFoundException('Cannot get IPTC information from ' . $file->getURI() . ' (no APP13 marker)');
     }
     if (!($iptc = iptcparse($info['APP13']))) {
         throw new FormatException('Cannot parse IPTC information from ' . $file->getURI());
     }
     // Parse creation date
     if (3 == sscanf(@$iptc['2#055'][0], '%4d%2d%d', $year, $month, $day)) {
         $created = Date::create($year, $month, $day, 0, 0, 0);
     } else {
         $created = NULL;
     }
     with($i = new self());
     $i->setTitle(@$iptc['2#005'][0]);
     $i->setUrgency(@$iptc['2#010'][0]);
     $i->setCategory(@$iptc['2#015'][0]);
     $i->setSupplementalCategories(@$iptc['2#020']);
     $i->setKeywords(@$iptc['2#025']);
     $i->setSpecialInstructions(@$iptc['2#040'][0]);
     $i->setDateCreated($created);
     $i->setAuthor(@$iptc['2#080'][0]);
     $i->setAuthorPosition(@$iptc['2#085'][0]);
     $i->setCity(@$iptc['2#090'][0]);
     $i->setState(@$iptc['2#095'][0]);
     $i->setCountry(@$iptc['2#101'][0]);
     $i->setOriginalTransmissionReference(@$iptc['2#103'][0]);
     $i->setHeadline(@$iptc['2#105'][0]);
     $i->setCredit(@$iptc['2#110'][0]);
     $i->setSource(@$iptc['2#115'][0]);
     $i->setCopyrightNotice(@$iptc['2#116'][0]);
     $i->setCaption(@$iptc['2#120'][0]);
     $i->setWriter(@$iptc['2#122'][0]);
     return $i;
 }
 /**
  * {@inheritdoc}
  */
 public static function fromArray(array $values)
 {
     $message = new self();
     $values = array_merge(['item_id' => null, 'item_type' => null, 'category' => null, 'drop_freq' => null, 'drop_trainer_level' => null, 'pokeball' => null, 'potion' => null, 'revive' => null, 'battle' => null, 'food' => null, 'inventory_upgrade' => null, 'xp_boost' => null, 'incense' => null, 'egg_incubator' => null, 'fort_modifier' => null], $values);
     $message->setItemId($values['item_id']);
     $message->setItemType($values['item_type']);
     $message->setCategory($values['category']);
     $message->setDropFreq($values['drop_freq']);
     $message->setDropTrainerLevel($values['drop_trainer_level']);
     $message->setPokeball($values['pokeball']);
     $message->setPotion($values['potion']);
     $message->setRevive($values['revive']);
     $message->setBattle($values['battle']);
     $message->setFood($values['food']);
     $message->setInventoryUpgrade($values['inventory_upgrade']);
     $message->setXpBoost($values['xp_boost']);
     $message->setIncense($values['incense']);
     $message->setEggIncubator($values['egg_incubator']);
     $message->setFortModifier($values['fort_modifier']);
     return $message;
 }
Example #4
0
 /**
  * @param ShopEntity $shop
  * @return Shop
  */
 public static function createFromShopEntity(ShopEntity $shop)
 {
     $struct = new self();
     $struct->setId($shop->getId());
     $struct->setParentId($shop->getMain() ? $shop->getMain()->getId() : $shop->getId());
     $struct->setIsDefault($shop->getDefault());
     $struct->setName($shop->getName());
     $struct->setHost($shop->getHost());
     $struct->setPath($shop->getBasePath());
     $struct->setUrl($shop->getBaseUrl());
     $struct->setSecure($shop->getSecure());
     $struct->setSecureHost($shop->getSecureHost());
     $struct->setSecurePath($shop->getSecureBasePath());
     if ($shop->getCategory()) {
         $struct->setCategory(Category::createFromCategoryEntity($shop->getCategory()));
     }
     if ($shop->getFallback()) {
         $struct->setFallbackId($shop->getFallback()->getId());
     }
     return $struct;
 }
 public static function syncEwattch($_ip)
 {
     $request_http = new com_http($_ip . '/log.json?mode=10');
     $result = json_decode($request_http->exec(1, 1), true);
     foreach ($result['resource']['electricity'] as $resource) {
         $eqLogic = self::byLogicalId('electricity_' . $resource['name'], 'ewattch');
         if (!is_object($eqLogic)) {
             $eqLogic = new self();
             $eqLogic->setName('electricity_' . $resource['name']);
             $eqLogic->setEqType_name('ewattch');
             $eqLogic->setIsVisible(1);
             $eqLogic->setIsEnable(1);
             $eqLogic->setLogicalId('electricity_' . $resource['name']);
             $eqLogic->setConfiguration('ip', $_ip);
             $eqLogic->setCategory('energy', 1);
             $eqLogic->save();
         }
         $index = $eqLogic->getCmd(null, 'index');
         if (!is_object($index)) {
             $index = new ewattchCmd();
             $index->setLogicalId('index');
             $index->setIsVisible(1);
             $index->setName(__('Index', __FILE__));
         }
         $index->setUnite('wh');
         $index->setType('info');
         $index->setSubType('numeric');
         $index->setEventOnly(1);
         $index->setEqLogic_id($eqLogic->getId());
         $index->save();
         $cost = $eqLogic->getCmd(null, 'cost');
         if (!is_object($cost)) {
             $cost = new ewattchCmd();
             $cost->setLogicalId('cost');
             $cost->setIsVisible(1);
             $cost->setName(__('Coût', __FILE__));
         }
         $cost->setUnite('€');
         $cost->setType('info');
         $cost->setSubType('numeric');
         $cost->setEventOnly(1);
         $cost->setEqLogic_id($eqLogic->getId());
         $cost->save();
     }
     foreach ($result['resource']['water'] as $resource) {
         $eqLogic = self::byLogicalId('water_' . $resource['name'], 'ewattch');
         if (!is_object($eqLogic)) {
             $eqLogic = new self();
             $eqLogic->setName('water_' . $resource['name']);
             $eqLogic->setEqType_name('ewattch');
             $eqLogic->setIsVisible(1);
             $eqLogic->setIsEnable(1);
             $eqLogic->setLogicalId('water_' . $resource['name']);
             $eqLogic->setConfiguration('ip', $_ip);
             $eqLogic->setCategory('energy', 1);
             $eqLogic->save();
         }
         $index = $eqLogic->getCmd(null, 'index');
         if (!is_object($index)) {
             $index = new ewattchCmd();
             $index->setLogicalId('index');
             $index->setIsVisible(1);
             $index->setName(__('Index', __FILE__));
         }
         $index->setUnite('L');
         $index->setType('info');
         $index->setSubType('numeric');
         $index->setEventOnly(1);
         $index->setEqLogic_id($eqLogic->getId());
         $index->save();
         $cost = $eqLogic->getCmd(null, 'cost');
         if (!is_object($cost)) {
             $cost = new ewattchCmd();
             $cost->setLogicalId('cost');
             $cost->setIsVisible(1);
             $cost->setName(__('Coût', __FILE__));
         }
         $cost->setUnite('€');
         $cost->setType('info');
         $cost->setSubType('numeric');
         $cost->setEventOnly(1);
         $cost->setEqLogic_id($eqLogic->getId());
         $cost->save();
     }
     foreach ($result['resource']['heating'] as $resource) {
         $eqLogic = self::byLogicalId('heating_' . $resource['name'], 'ewattch');
         if (!is_object($eqLogic)) {
             $eqLogic = new self();
             $eqLogic->setName('heating_' . $resource['name']);
             $eqLogic->setEqType_name('ewattch');
             $eqLogic->setIsVisible(1);
             $eqLogic->setIsEnable(1);
             $eqLogic->setLogicalId('heating_' . $resource['name']);
             $eqLogic->setConfiguration('ip', $_ip);
             $eqLogic->setCategory('heating', 1);
             $eqLogic->save();
         }
         $index = $eqLogic->getCmd(null, 'index');
         if (!is_object($index)) {
             $index = new ewattchCmd();
             $index->setLogicalId('index');
             $index->setIsVisible(1);
             $index->setName(__('Index', __FILE__));
         }
         $index->setUnite('wh');
         $index->setType('info');
         $index->setSubType('numeric');
         $index->setEventOnly(1);
         $index->setEqLogic_id($eqLogic->getId());
         $index->save();
     }
     foreach ($result['resource']['environment'] as $resource) {
         $eqLogic = self::byLogicalId('environment_' . $resource['name'], 'ewattch');
         if (!is_object($eqLogic)) {
             $eqLogic = new self();
             $eqLogic->setName('environment_' . $resource['name']);
             $eqLogic->setEqType_name('ewattch');
             $eqLogic->setIsVisible(1);
             $eqLogic->setIsEnable(1);
             $eqLogic->setLogicalId('environment_' . $resource['name']);
             $eqLogic->setConfiguration('ip', $_ip);
             $eqLogic->save();
         }
         $value = $eqLogic->getCmd(null, 'value');
         if (!is_object($value)) {
             $value = new ewattchCmd();
             $value->setLogicalId('value');
             $value->setIsVisible(1);
             $value->setName(__('Valeur', __FILE__));
         }
         $value->setUnite($resource['units']);
         $value->setType('info');
         $value->setSubType('numeric');
         $value->setEventOnly(1);
         $value->setEqLogic_id($eqLogic->getId());
         $value->save();
     }
 }
Example #6
0
 /**
  * @param ConfigurationEntryDefinition $def
  *
  * @return ConfigurationEntry
  */
 public static function createFromDefinition(ConfigurationEntryDefinition $def)
 {
     $me = new self($def->getName());
     $me->setReadableName($def->getReadableName());
     $me->setValue($def->getValue());
     $me->setServerHandlerConfig($def->getServerHandlerConfig());
     $me->setClientHandlerConfig($def->getClientHandlerConfig());
     $me->setExposed($def->isExposed());
     $me->setCategory($def->getCategory());
     return $me;
 }
 /**
  * @param \SimpleXMLElement $product
  * @return ErpProductEntity
  */
 public static function createFromCatalogXmlResponse(\SimpleXMLElement $product)
 {
     $self = new self();
     $sku = isset($product->attributes()->ItemNo) ? (string) $product->attributes()->ItemNo : null;
     if (!$sku) {
         throw new \InvalidArgumentException('Invalid product downloaded from catalog');
     }
     $self->setSku($sku);
     $self->setTitle((string) $product->Description);
     $self->setLastUpdated(new \DateTime((string) $product->attributes()->LastUpdated));
     $self->setDescription((string) $product->Description);
     foreach ($product->SupplementalData as $data) {
         foreach ($data->attributes() as $k => $v) {
             switch ((string) $v) {
                 case 'webcategory':
                     $self->setCategory((string) $data);
                     break;
             }
         }
     }
     $self->setPrice((string) $product->Pricing->UnitPrice);
     $self->setQty((int) (string) $product->Availability->QtyAvailable);
     return $self;
 }
 /**
  * {@inheritdoc}
  */
 public static function fromArray(array $values)
 {
     $message = new self();
     $values = array_merge(['sku' => null, 'category' => null, 'sort_order' => null, 'item_ids' => [], 'counts' => []], $values);
     $message->setSku($values['sku']);
     $message->setCategory($values['category']);
     $message->setSortOrder($values['sort_order']);
     foreach ($values['item_ids'] as $item) {
         $message->addItemIds($item);
     }
     foreach ($values['counts'] as $item) {
         $message->addCounts($item);
     }
     return $message;
 }