Handle icon image which is PNG formatted
@param IconImage $entry
@param string $data
422171
private function parsePng(IconImage $entry, $data)
    {
        //a png icon contains a complete png image at the file offset
        $png = substr($data, $entry->fileOffset, $entry->sizeInBytes);
        $entry->setPngFile($png);
    }
577837
public function setImageData($image_data)
    {

        if (!is_null($image_data) && (!preg_match("/^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/", $image_data))) {
            throw new \InvalidArgumentException("invalid value for $image_data when calling ConditionalFormattingIcon., must conform to the pattern /^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/.");
        }

        $this->container['image_data'] = $image_data;

        return $this;
    }
13131
protected function dataToGlyphSet($data)
    {
        $glyphs = array();
        foreach ($data->icons as $iconProperties) {
            $glyphs[] = $iconProperties->properties->name;
        }
        return $glyphs;
    }
1360309
protected function handleImageManipulation(ImageInterface $image, array $data): ImageInterface
    {
        $width = $height = $data['dimension'];

        return $image->thumbnail(new Box($width, $height), $data['mode'], $data['filter']);
    }
1182074
protected function cleanup($dataType, $data)
    {
        // Delete Translations, if present
        if (is_crud_translatable($data)) {
            $data->deleteAttributeTranslations($data->getTranslatableAttributes());
        }

        // Delete Images
        $this->deleteCrudImages($data, $dataType->deleteRows->where('type', 'image'));

        // Delete Files
        foreach ($dataType->deleteRows->where('type', 'file') as $row) {
            $files = json_decode($data->{$row->field});
            if ($files) {
                foreach ($files as $file) {
                    $this->deleteFileIfExists($file->download_link);
                }
            }
        }
    }
65923
public function deserialize($data, Entry $entry, array $options = [])
    {
        $this->sipe('title', 'setTitle', $data, $entry);
        $this->sipe('status', 'setStatus', $data, $entry);

        if (isset($data['user']['id'])) {
            $user = $this->userRepo->findOneBy(['uuid' => $data['user']['id']]);

            if (!empty($user)) {
                $entry->setUser($user);
            }
        }
        /* TODO: checks rights */
        $this->deserializeCategories($entry, $data['categories']);
        $this->deserializeKeywords($entry, $data['keywords']);

        if (isset($data['clacoForm']['id'])) {
            $clacoForm = $this->clacoFormRepo->findOneBy(['uuid' => $data['clacoForm']['id']]);

            if (!empty($clacoForm)) {
                $entry->setClacoForm($clacoForm);

                // Initializes status
                if (empty($entry->getStatus())) {
                    $status = $clacoForm->isModerated() ? Entry::PENDING : Entry::PUBLISHED;
                    $entry->setStatus($status);
                }

                // Sets values for fields
                $fields = $this->fieldRepo->findBy(['clacoForm' => $clacoForm]);

                foreach ($fields as $field) {
                    $uuid = $field->getUuid();

                    if (isset($data['values'][$uuid])) {
                        $fieldValue = $this->fieldValueRepo->findOneBy(['entry' => $entry, 'field' => $field]);

                        if (empty($fieldValue)) {
                            $fieldValue = new FieldValue();
                            $fieldValue->setEntry($entry);
                            $fieldValue->setField($field);

                            $fielFacetValue = new FieldFacetValue();
                            $fielFacetValue->setUser($entry->getUser());
                            $fielFacetValue->setFieldFacet($field->getFieldFacet());
                            $fielFacetValue->setValue($data['values'][$uuid]);
                            $fieldValue->setFieldFacetValue($fielFacetValue);

                            $this->om->persist($fielFacetValue);
                        } else {
                            $fieldValue->setValue($data['values'][$uuid]);
                        }
                        $this->om->persist($fieldValue);

                        $fieldsCategories = $this->fieldChoiceCategoryRepo->findBy(['field' => $field]);

                        foreach ($fieldsCategories as $fieldCategory) {
                            switch ($field->getType()) {
                                case FieldFacet::NUMBER_TYPE:
                                    $isCategoryValue = floatval($data['values'][$uuid]) === floatval($fieldCategory->getValue());
                                    break;
                                default:
                                    $isCategoryValue = $data['values'][$uuid] === $fieldCategory->getValue();
                            }
                            if ($isCategoryValue) {
                                $entry->addCategory($fieldCategory->getCategory());
                            }
                        }
                    }
                }
            }
        }
        $currentDate = new \DateTime();

        if (empty($entry->getCreationDate())) {
            $entry->setCreationDate($currentDate);
            $this->clacoFormManager->notifyCategoriesManagers($entry, [], $entry->getCategories());
        } else {
            $entry->setEditionDate($currentDate);
            $this->clacoFormManager->notifyCategoriesManagers($entry, $entry->getCategories(), $entry->getCategories());
        }

        return $entry;
    }
316115
public function onLabelCallback(array $row, $label, DataContainer $dc, $attributes)
    {
        /** @var Image $imageAdapter */
        $imageAdapter = $this->framework->getAdapter(Image::class);

        // Align the icon with the text
        if (false !== \stripos($attributes, 'style="')) {
            $attributes = \str_replace('style="', 'style="vertical-align:text-top;', $attributes);
        } else {
            $attributes .= \trim($attributes.' style="vertical-align:text-top;"');
        }

        return $imageAdapter->getHtml('iconPLAIN.svg', '', $attributes).' '.$label;
    }
144241
protected function validateClassEntry($entry)
    {
        if (!is_string($entry) && !is_object($entry)) {
            $type = gettype($entry);
            $message = sprintf('Argument "entry" in "%s" must be a string or an object; "%s" was given.', __METHOD__, $type);
            throw new Exception\InvalidArgumentException($message);
        }

        if (is_string($entry) && !class_exists($entry)) {
            throw new Exception\ClassNotFoundException($entry);
        }
    }
34479
protected function render_image_icon(image_icon $icon) {
        $system = \core\output\icon_system::instance(\core\output\icon_system::STANDARD);
        return $system->render_pix_icon($this, $icon);
    }
494244
public function addRaw($data)
	{
		$this->validateData($data);

		$data['location'] = trim($data['location'], '/');

		$this->entries[] = $this->replaceAttributes($data);
	}
485416
public function onPostImageDataLoad(&$data, array $keys)
    {
        foreach ($keys as $key) {
            if (isset($data[$key])) {
                $data[$key] = wei()->cdn->convertToRealUrl($data[$key]);
            }
        }
    }
944012
public function setIcon($icon)
    {
        switch ($icon) {
            case 'info':
            case 'error':
            case 'warning':
                $this->icon = $icon;
                break;
            default:
                if (file_exists($icon) && is_file($icon)) {
                    $this->icon = $icon;
                } else {
                    if (isset($this->log)) {
                        $this->log(
                            sprintf(
                                "%s is not a file. Using default icon instead.",
                                $icon
                            ),
                            Project::MSG_WARN
                        );
                    }
                }
        }
    }
432163
public function search($entry)
    {
        $data = TrimContentTransformer::trim($this->fileReader->read());

        if (in_array($entry, $data)) {
            return true;
        }

        foreach ($data as $item) {
            if (0 === strpos($entry, $item)) {
                return true;
            }
        }

        return false;
    }
147551
private function parseTrueColorImageData(IconImage $entry, $data)
    {
        $length = $entry->bmpHeaderWidth * $entry->bmpHeaderHeight * ($entry->bitCount / 8);
        $bmpData = substr($data, $entry->fileOffset + $entry->bmpHeaderSize, $length);
        $entry->setBitmapData($bmpData);
    }
1353562
def parse_resource_entry(self, rva):
        """"""

        try:
            data = self.get_data( rva, Structure(self.__IMAGE_RESOURCE_DIRECTORY_ENTRY_format__).sizeof() )
        except PEFormatError, excp:
            # A warning will be added by the caller if this method returns None
            return None

        resource = self.__unpack_data__(
            self.__IMAGE_RESOURCE_DIRECTORY_ENTRY_format__, data,
            file_offset = self.get_offset_from_rva(rva) )
        
        if resource is None:
            return None
        
        #resource.NameIsString = (resource.Name & 0x80000000L) >> 31
        resource.NameOffset = resource.Name & 0x7FFFFFFFL
        
        resource.__pad = resource.Name & 0xFFFF0000L
        resource.Id = resource.Name & 0x0000FFFFL
        
        resource.DataIsDirectory = (resource.OffsetToData & 0x80000000L) >> 31
        resource.OffsetToDirectory = resource.OffsetToData & 0x7FFFFFFFL
        
        return resource
901574
def parse_resource_data_entry(self, rva):
        """"""

        try:
            # If the RVA is invalid all would blow up. Some EXEs seem to be
            # specially nasty and have an invalid RVA.
            data = self.get_data(rva, Structure(self.__IMAGE_RESOURCE_DATA_ENTRY_format__).sizeof() )
        except PEFormatError as excp:
            self.__warnings.append(
                'Error parsing a resource directory data entry, '
                'the RVA is invalid: 0x%x' % ( rva ) )
            return None

        data_entry = self.__unpack_data__(
            self.__IMAGE_RESOURCE_DATA_ENTRY_format__, data,
            file_offset = self.get_offset_from_rva(rva) )

        return data_entry
1323664
protected function handleIcon(Infoset $info) {
		if (empty($this->errors)) {
			$info->setIcon('ok');
			return;
		}
		
		if ($this->hasError) {
			$info->setIcon('alert');
			return;
		}
		
		$info->setIcon('warning');
	}