Exemplo n.º 1
0
 /**
  * Class constructor.
  * @param \SimpleXMLElement $xml
  */
 public function __construct(\SimpleXMLElement $xml)
 {
     $this->categories = new Collection();
     $this->requisites = new Collection();
     $this->properties = new Collection();
     $this->characteristics = new Collection();
     $this->images = new Collection();
     $this->taxRate = new Collection();
     $this->id = (string) $xml->Ид;
     $this->name = (string) $xml->Наименование;
     $this->description = (string) $xml->Описание;
     $this->sku = (string) $xml->Артикул;
     $this->barcode = (string) $xml->ШтрихКод;
     if ($xml->Группы) {
         foreach ($xml->Группы->Ид as $categoryId) {
             $this->categories->add((string) $categoryId);
         }
     }
     if ($xml->ЗначенияРеквизитов) {
         foreach ($xml->ЗначенияРеквизитов->ЗначениеРеквизита as $value) {
             $this->requisites->add(new RequisiteValue($value));
         }
     }
     if ($xml->ЗначенияСвойств) {
         foreach ($xml->ЗначенияСвойств->ЗначенияСвойства as $prop) {
             $this->properties->add(new PropertyValue($prop));
         }
     }
     if ($xml->Картинка) {
         $dirName = dirname(Parser::getInstance()->getCurrentFile()->getRealPath());
         foreach ($xml->Картинка as $image) {
             if (file_exists($path = realpath($dirName . DIRECTORY_SEPARATOR . (string) $image))) {
                 $this->images->add($path);
             }
         }
     }
     if ($xml->Изготовитель) {
         $this->manufacturer = new Partner($xml->Изготовитель);
     }
     if ($xml->ХарактеристикиТовара) {
         foreach ($xml->ХарактеристикиТовара->ХарактеристикаТовара as $value) {
             $this->characteristics->add(new ProductCharacteristic($value));
         }
     }
     if ($xml->БазоваяЕдиница) {
         $this->baseUnit = new BaseUnit($xml->БазоваяЕдиница);
     }
     if ($xml->СтавкиНалогов) {
         foreach ($xml->СтавкиНалогов->СтавкаНалога as $value) {
             $this->taxRate->add(new TaxRate($value));
         }
     }
 }
Exemplo n.º 2
0
 public function compile()
 {
     if ($this->values instanceof CompilableInterface) {
         $values = $this->values->compile();
     } else {
         if (0 == count($this->values)) {
             throw new MissingValuesException("You must provide at least one value for the 'IN' expression!");
         }
         $values = implode(",", array_map(function ($element) {
             return "\"{$element}\"";
         }, $this->values));
     }
     return "{$this->field} IN ({$values})";
 }
 public function rewriteSecProfXML()
 {
     if ($this->secprofroot !== null) {
         DH::clearDomNodeChilds($this->secprofroot);
     }
     if ($this->secproftype == 'group') {
         if ($this->secprofroot === null || $this->secprofroot === false) {
             $this->secprofroot = DH::createElement($this->xmlroot, 'profile-setting');
         } else {
             $this->xmlroot->appendChild($this->secprofroot);
         }
         $tmp = $this->secprofroot->ownerDocument->createElement('group');
         $tmp = $this->secprofroot->appendChild($tmp);
         $tmp = $tmp->appendChild($this->secprofroot->ownerDocument->createElement('member'));
         $tmp->appendChild($this->secprofroot->ownerDocument->createTextNode($this->secprofgroup));
     } else {
         if ($this->secproftype == 'profiles') {
             if ($this->secprofroot === null || $this->secprofroot === false) {
                 $this->secprofroot = DH::createElement($this->xmlroot, 'profile-setting');
             } else {
                 $this->xmlroot->appendChild($this->secprofroot);
             }
             $tmp = $this->secprofroot->ownerDocument->createElement('profiles');
             $tmp = $this->secprofroot->appendChild($tmp);
             foreach ($this->secprofprofiles as $index => $value) {
                 $type = $tmp->appendChild($this->secprofroot->ownerDocument->createElement($index));
                 $ntmp = $type->appendChild($this->secprofroot->ownerDocument->createElement('member'));
                 $ntmp->appendChild($this->secprofroot->ownerDocument->createTextNode($value));
             }
         } elseif ($this->secprofroot !== null) {
             DH::removeChild($this->xmlroot, $this->secprofroot);
         }
     }
 }
Exemplo n.º 4
0
 /**
  * @param string $line
  */
 public function addLine($line)
 {
     if (!$this->acceptsLines()) {
         throw new \LogicException('You cannot add lines to a block which cannot accept them');
     }
     $this->strings->add($line);
 }
 public function rewriteAddressGroupStoreXML()
 {
     DH::clearDomNodeChilds($this->addrgroot);
     foreach ($this->addrg as $s) {
         $this->addrgroot->appendChild($s->xmlroot);
     }
 }
Exemplo n.º 6
0
 /**
  *
  */
 public function printMenu()
 {
     $result = [];
     $complete = true;
     $entries = $this->entries;
     foreach ($entries as $entry) {
         $active = $entry == current($this->entries);
         if ($active) {
             $complete = false;
         }
         $key = 'menuitem_' . $entry;
         $label = $this->translations->translate($key);
         $result[] = ['label' => $label, 'complete' => $complete, 'active' => $active];
     }
     $this->slim->render('/_menu.php', ['entries' => $result]);
 }
Exemplo n.º 7
0
 /**
  * @param \Error|\Exception|string[]|string $throwableOrMessage
  */
 public function __construct($throwableOrMessage)
 {
     if ($throwableOrMessage instanceof \Error || $throwableOrMessage instanceof \Exception) {
         $prev = $throwableOrMessage->getPrevious();
         $this->class = get_class($throwableOrMessage);
         $this->message = $throwableOrMessage->getMessage();
         $this->prev = $prev === null ? null : new ThrowableProxy($prev);
     } else {
         if (is_array($throwableOrMessage)) {
             $this->class = $throwableOrMessage[0];
             $this->message = $throwableOrMessage[1];
             $this->prev = null;
         } else {
             $this->class = 'Exception';
             $this->message = $throwableOrMessage;
             $this->prev = null;
         }
     }
 }
Exemplo n.º 8
0
 /**
  * @param string $local
  * @param string $remote
  * @return bool
  */
 function removeProxyId($local, $remote)
 {
     foreach ($this->proxys as $index => &$proxy) {
         if ($proxy['local'] == $local && $proxy['remote'] == $remote) {
             unset($this->proxys[$index]);
             $this->proxyIdRoot->removeChild($proxy['xmlroot']);
             return true;
         }
     }
     return false;
 }
Exemplo n.º 9
0
 /**
  * To remove a property from the instance.
  *
  * Data management : In PHP7, \Closure::bind(), \Closure::bindTo() and \Closure::call()
  * can not change the scope about non real closure (all closures obtained by \ReflectionMethod::getClosure()) to avoid
  * error due to compilation pass with self::
  *
  * Thise change does not impact rebinding of $this, but the scope stay unchanged, and private or protected attributes
  * or method are not available in this closure (the scope differ).
  *
  * So we use magic call to restore this behavior during a calling
  *
  * @param string $name
  *
  * @throws \ErrorException of the property is not accessible
  */
 public function __unset(string $name)
 {
     if (!$this->callerStatedClassesStack->isEmpty() && property_exists($this, $name)) {
         unset($this->{$name});
         return;
     }
     if ($this->isPublicProperty($name)) {
         unset($this->{$name});
         return;
     }
     throw new \ErrorException('Error: Cannot access private property ' . get_class($this) . '::' . $name);
 }
Exemplo n.º 10
0
 /**
  * Rewrite XML for this object, useful after a batch editing to save computing time.
  * You should not need to call it by yourself in normal situations
  *
  */
 public function rewriteXML()
 {
     DH::clearDomNodeChilds($this->xmlroot);
     foreach ($this->rules as $rule) {
         $this->xmlroot->appendChild($rule->xmlroot);
     }
     if ($this->isPreOrPost) {
         DH::clearDomNodeChilds($this->postRulesRoot);
         foreach ($this->postRules as $rule) {
             $this->postRulesRoot->appendChild($rule->xmlroot);
         }
     }
 }
Exemplo n.º 11
0
 /**
  * Render the content of the tag.
  *
  * @throws CoreException
  * @return string
  */
 protected function renderContent()
 {
     if (is_string($this->content) || $this->content instanceof SafeHtmlWrapper || $this->content instanceof SafeHtmlProducerInterface) {
         return Html::escape($this->content);
     } elseif ($this->content instanceof RenderableInterface) {
         return Html::escape($this->content->render());
     } elseif (is_array($this->content) || $this->content instanceof ArrayableInterface) {
         return ArrayList::of($this->content)->map(function ($child) {
             if (is_string($child) || $child instanceof SafeHtmlWrapper || $child instanceof SafeHtmlProducerInterface) {
                 return Html::escape($child);
             } elseif ($child instanceof RenderableInterface) {
                 return Html::escape($child->render());
             }
             throw new NodeChildRenderingException($child);
         })->join();
     }
     throw new NodeRenderingException($this->content);
 }
Exemplo n.º 12
0
 /**
  * Finalize the block; mark it closed for modification
  *
  * @param int          $lineNumber
  * @param InlineParser $inlineParser
  * @param ReferenceMap $refMap
  */
 public function finalize($lineNumber, CommonMark_InlineParser $inlineParser, CommonMark_Reference_ReferenceMap $refMap)
 {
     if (!$this->open) {
         return;
     }
     $this->open = false;
     if ($lineNumber > $this->startLine) {
         $this->endLine = $lineNumber - 1;
     } else {
         $this->endLine = $lineNumber;
     }
     switch ($this->getType()) {
         case self::TYPE_PARAGRAPH:
             $this->stringContent = preg_replace('/^  */m', '', implode("\n", $this->strings->toArray()));
             // Try parsing the beginning as link reference definitions:
             while ($this->stringContent[0] === '[' && ($pos = $inlineParser->parseReference($this->stringContent, $refMap))) {
                 $this->stringContent = substr($this->stringContent, $pos);
                 if ($this->isStringContentBlank()) {
                     //RegexHelper::getInstance()->isBlank($this->stringContent)) {
                     $this->type = self::TYPE_REFERENCE_DEF;
                     break;
                 }
             }
             break;
         case self::TYPE_ATX_HEADER:
         case self::TYPE_SETEXT_HEADER:
         case self::TYPE_HTML_BLOCK:
             $this->stringContent = implode("\n", $this->strings->toArray());
             break;
         case self::TYPE_INDENTED_CODE:
             $reversed = array_reverse($this->strings->toArray(), true);
             foreach ($reversed as $index => $line) {
                 if ($line == '' || $line === "\n" || preg_match('/^(\\n *)$/', $line)) {
                     unset($reversed[$index]);
                 } else {
                     break;
                 }
             }
             $fixed = array_reverse($reversed);
             $tmp = implode("\n", $fixed);
             if (substr($tmp, -1) !== "\n") {
                 $tmp .= "\n";
             }
             $this->stringContent = $tmp;
             break;
         case self::TYPE_FENCED_CODE:
             // first line becomes info string
             $this->setExtra('info', CommonMark_Util_RegexHelper::unescape(trim($this->strings->first())));
             if ($this->strings->count() == 1) {
                 $this->stringContent = '';
             } else {
                 $this->stringContent = implode("\n", $this->strings->slice(1)) . "\n";
             }
             break;
         case self::TYPE_LIST:
             $this->setExtra('tight', true);
             // tight by default
             $numItems = $this->children->count();
             $i = 0;
             while ($i < $numItems) {
                 /** @var BlockElement $item */
                 $item = $this->children->get($i);
                 // check for non-final list item ending with blank line:
                 $lastItem = $i == $numItems - 1;
                 if ($item->endsWithBlankLine() && !$lastItem) {
                     $this->setExtra('tight', false);
                     break;
                 }
                 // Recurse into children of list item, to see if there are
                 // spaces between any of them:
                 $numSubItems = $item->getChildren()->count();
                 $j = 0;
                 while ($j < $numSubItems) {
                     $subItem = $item->getChildren()->get($j);
                     $lastSubItem = $j == $numSubItems - 1;
                     if ($subItem->endsWithBlankLine() && !($lastItem && $lastSubItem)) {
                         $this->setExtra('tight', false);
                         break;
                     }
                     $j++;
                 }
                 $i++;
             }
             break;
         default:
             break;
     }
 }
Exemplo n.º 13
0
 /**
  * @since 1.17
  * @param string|string[]|MessageSpecifier $key Message key, or array of
  * message keys to try and use the first non-empty message for, or a
  * MessageSpecifier to copy from.
  * @param array $params Message parameters.
  * @param Language $language [optional] Language to use (defaults to current user language).
  * @throws InvalidArgumentException
  */
 public function __construct($key, $params = [], Language $language = null)
 {
     if ($key instanceof MessageSpecifier) {
         if ($params) {
             throw new InvalidArgumentException('$params must be empty if $key is a MessageSpecifier');
         }
         $params = $key->getParams();
         $key = $key->getKey();
     }
     if (!is_string($key) && !is_array($key)) {
         throw new InvalidArgumentException('$key must be a string or an array');
     }
     $this->keysToTry = (array) $key;
     if (empty($this->keysToTry)) {
         throw new InvalidArgumentException('$key must not be an empty list');
     }
     $this->key = reset($this->keysToTry);
     $this->parameters = array_values($params);
     // User language is only resolved in getLanguage(). This helps preserve the
     // semantic intent of "user language" across serialize() and unserialize().
     $this->language = $language ?: false;
 }
Exemplo n.º 14
0
 /**
  *  Populate object with information about the table it represents 
  *
  *  Call {@link 
  *  http://pear.php.net/manual/en/package.database.db.db-common.tableinfo.php
  *  DB_common::tableInfo()} to get a description of the table and
  *  store it in {@link $content_columns}.  Add a more human
  *  friendly name to the element for each column.
  *  @uses $db
  *  @uses $content_columns
  *  @uses Inflector::humanize()
  *  @see __set()
  *  @param string $table_name  Name of table to get information about
  */
 function set_content_columns($table_name)
 {
     if (!is_null($this->table_prefix)) {
         $table_name = $this->table_prefix . $table_name;
     }
     if (isset(self::$table_info[$table_name])) {
         $this->content_columns = self::$table_info[$table_name];
     } else {
         self::$db->loadModule('Reverse', null, true);
         $this->content_columns = self::$db->reverse->tableInfo($table_name);
         if ($this->is_error($this->content_columns)) {
             $this->raise($this->content_columns->getMessage());
         }
         if (is_array($this->content_columns)) {
             $i = 0;
             foreach ($this->content_columns as $column) {
                 $this->content_columns[$i++]['human_name'] = Inflector::humanize($column['name']);
             }
             self::$table_info[$table_name] = $this->content_columns;
         }
     }
 }
Exemplo n.º 15
0
 /**
  * Поиск региона
  * @param string $query
  * @param RegionSearchCriteria|string[] $criteria
  * @param string[] $additionalFields
  * @return Mappers\Region[]|array
  */
 public function search($query, $criteria = array(), array $additionalFields = array())
 {
     return $this->getInternalList('region/search', 'Region', array_merge($criteria instanceof RegionSearchCriteria ? $criteria->toArray() : $criteria, array('q' => $query, 'fields' => self::getArray($additionalFields))));
 }
Exemplo n.º 16
0
 /**
  * @since 1.17
  *
  * @param string|string[]|MessageSpecifier $key Message key, or array of
  * message keys to try and use the first non-empty message for, or a
  * MessageSpecifier to copy from.
  * @param array $params Message parameters.
  * @param Language $language Optional language of the message, defaults to $wgLang.
  *
  * @throws InvalidArgumentException
  */
 public function __construct($key, $params = array(), Language $language = null)
 {
     global $wgLang;
     if ($key instanceof MessageSpecifier) {
         if ($params) {
             throw new InvalidArgumentException('$params must be empty if $key is a MessageSpecifier');
         }
         $params = $key->getParams();
         $key = $key->getKey();
     }
     if (!is_string($key) && !is_array($key)) {
         throw new InvalidArgumentException('$key must be a string or an array');
     }
     $this->keysToTry = (array) $key;
     if (empty($this->keysToTry)) {
         throw new InvalidArgumentException('$key must not be an empty list');
     }
     $this->key = reset($this->keysToTry);
     $this->parameters = array_values($params);
     $this->language = $language ?: $wgLang;
 }
 /**
  * @return array
  */
 private function getOptions()
 {
     $options = ["headers" => $this->getHeaders(), "query" => $this->queryParams->toArray()];
     return $this->setBody($options);
 }
Exemplo n.º 18
0
 /**
  * @param string $query
  * @param BranchSearchCriteria|string[] $criteria
  * @param int $page
  * @param int $pageSize
  * @param string[] $additionalFields
  * @link http://api.2gis.ru/doc/2.0/catalog/branch/search
  * @return mappers\Branch[]|array()
  */
 public function branchSearch($query, $criteria, $page = null, $pageSize = null, array $additionalFields = array())
 {
     return $this->getInternalList('catalog/branch/search', 'Branch', array_merge($criteria instanceof BranchSearchCriteria ? $criteria->toArray() : $criteria, array('q' => $query, 'page' => $page, 'page_size' => $pageSize, 'fields' => self::getArray($additionalFields))));
 }
Exemplo n.º 19
0
 /**
  * Set header
  *
  * @param   string $name header name
  * @param   string|string[]|peer.http.Header|peer.http.Authorization $header header value
  */
 public function setHeader($name, $header)
 {
     if ($header instanceof Header) {
         $this->headers[$header->name()] = [$header->value()];
     } else {
         if ($header instanceof Authorization) {
             // BC
             $header->sign($this);
         } else {
             if ($header instanceof \peer\Header) {
                 // BC
                 $this->headers[$header->getName()] = [$header->getValueRepresentation()];
             } else {
                 $this->headers[$name] = (array) $header;
             }
         }
     }
 }