コード例 #1
0
 /**
  * Generic method wrapping datatype's fromString() method if implemented
  * Checks if fromString() is implemented in the field's datatype
  * If not, data_text will be used by default
  * @see http://projects.ez.no/sqliimport/forum/issues/two_little_thing
  * @param string $data String representation of data to inject
  * @return void
  */
 public function fromString($data)
 {
     $datatype = $this->attribute->attribute('data_type_string');
     $fromStringImplemented = null;
     // First check if datatype is already known as implementing fromString() or not
     // (Better performance as the check is made through Reflection API)
     if (in_array($datatype, self::$datatypesFromStringImpl)) {
         $fromStringImplemented = true;
     } else {
         if (in_array($datatype, self::$datatypesFromStringNotImpl)) {
             $fromStringImplemented = false;
         } else {
             $reflector = new ReflectionObject($this->attribute->dataType());
             $callerClass = $reflector->getMethod('fromString')->class;
             if ($callerClass == 'eZDataType') {
                 self::$datatypesFromStringNotImpl[] = $datatype;
                 $fromStringImplemented = false;
             } else {
                 self::$datatypesFromStringImpl[] = $datatype;
                 $fromStringImplemented = true;
             }
         }
     }
     // Now insert data through the appropriate way
     if ($fromStringImplemented) {
         $this->attribute->fromString($data);
     } else {
         $this->attribute->setAttribute('data_text', $data);
     }
 }
コード例 #2
0
 /**
  * Initializes the object attribute with some data.
  * @param eZContentObjectAttribute $objectAttribute
  * @param int $currentVersion
  * @param eZContentObjectAttribute $originalContentObjectAttribute
  */
 function initializeObjectAttribute($objectAttribute, $currentVersion, $originalContentObjectAttribute)
 {
     if (NULL === $currentVersion) {
         $data = '';
     } else {
         $data = $originalContentObjectAttribute->attribute("data_text");
     }
     $objectAttribute->setAttribute("data_text", $data);
 }
コード例 #3
0
    /**
     * Store data from string format as created in  {@link eZGmapLocationType::toString()}
     *
     * @param eZContentObjectAttribute $contentObjectAttribute
     * @param string $string
     */
    function fromString( $contentObjectAttribute, $string )
    {
    	$data = $string !== '' && strpos( $string, '|#' ) !== false ? explode( '|#', $string ) : array( 0 );

    	if ( $data[0] != 0 )
    	{
            $location = new eZGmapLocation( array(
                            'contentobject_attribute_id' => $contentObjectAttribute->attribute('id'),
                            'contentobject_version' => $contentObjectAttribute->attribute('version'),
                            'latitude' => $data[1],
                            'longitude' => $data[2],
                            'address' => $data[3]
                         ));
            $contentObjectAttribute->setContent( $location );
    	}
    	$contentObjectAttribute->setAttribute( 'data_int', $data[0] );
    }
コード例 #4
0
 /**
  * Fetches all variables from the object and handles them
  * Data store can be done here
  * @param eZHTTPTool $http
  * @param string $base POST variable name prefix (Always "ContentObjectAttribute")
  * @param eZContentObjectAttribute $contentObjectAttribute
  * @return true if fetching of class attributes are successfull, false if not
  */
 public function fetchObjectAttributeHTTPInput($http, $base, $contentObjectAttribute)
 {
     if ($http->hasPostVariable($base . '_accolorpicker_data_text_' . $contentObjectAttribute->attribute('id'))) {
         $data = $http->postVariable($base . '_accolorpicker_data_text_' . $contentObjectAttribute->attribute('id'));
         $contentObjectAttribute->setAttribute('data_text', $data);
     }
     return true;
 }
コード例 #5
0
 /**
  * Fetches all variables from the object and handles them
  * Data store can be done here
  *
  * @param eZHTTPTool $http
  * @param string $base POST variable name prefix (Always "ContentObjectAttribute")
  * @param eZContentObjectAttribute $contentObjectAttribute
  * @return true if fetching of object attributes is successful, false if not
  */
 public function fetchObjectAttributeHTTPInput($http, $base, $contentObjectAttribute)
 {
     $fieldName = $base . self::COMMENTS_ENABLED_VARIABLE . $contentObjectAttribute->attribute('id');
     $value = $http->hasPostVariable($fieldName) ? 1 : 0;
     $contentObjectAttribute->setAttribute('data_int', $value);
     return true;
 }
コード例 #6
0
 /**
  * Unserailize contentobject attribute
  *
  * @param eZPackage $package
  * @param eZContentObjectAttribute $objectAttribute
  * @param DOMElement $attributeNode
  */
 function unserializeContentObjectAttribute($package, $objectAttribute, $attributeNode)
 {
     $rootNode = $attributeNode->childNodes->item(0);
     $xmlString = $rootNode ? $rootNode->ownerDocument->saveXML($rootNode) : '';
     $objectAttribute->setAttribute('data_text', $xmlString);
 }
コード例 #7
0
ファイル: ngoibtype.php プロジェクト: netgen/ngoib
 /**
  * Imports the data to the attribute
  *
  * @param eZContentObjectAttribute $contentObjectAttribute
  * @param string $string
  *
  * @return string
  */
 function fromString($contentObjectAttribute, $string)
 {
     $contentObjectAttribute->setAttribute(self::OIB_FIELD, trim($string));
 }
コード例 #8
0
 /**
  * @param eZContentObjectAttribute $contentObjectAttribute
  * @param string $string
  */
 function fromString( $contentObjectAttribute, $string )
 {
     $contentObjectAttribute->setAttribute( 'data_text', $string );
 }
コード例 #9
0
 /**
  * Extracts values from the attribute parameters and sets it in the class attribute.
  *
  * @param eZContentObjectAttribute $classAttribute
  * @param DOMElement $attributeNode
  * @param DOMElement $attributeParametersNode
  */
 public function unserializeContentClassAttribute($classAttribute, $attributeNode, $attributeParametersNode)
 {
     $content = array();
     $delimiter = $attributeParametersNode->getElementsByTagName('delimiter')->item(0)->nodeValue;
     $multiselect = $attributeParametersNode->getElementsByTagName('multiselect')->item(0)->textContent;
     $query = $attributeParametersNode->getElementsByTagName('query')->item(0)->nodeValue;
     $content['delimiter'] = $delimiter !== false ? $delimiter : '';
     $content['is_multiselect'] = $multiselect !== false ? intval($multiselect) : 0;
     $content['query'] = $query !== false ? $query : '';
     $content['options'] = array();
     $optionsNode = $attributeParametersNode->getElementsByTagName('options')->item(0);
     if ($optionsNode instanceof DOMElement && $optionsNode->hasChildNodes()) {
         $children = $optionsNode->childNodes;
         foreach ($children as $key => $child) {
             if ($child instanceof DOMElement) {
                 $content['options'][] = array('id' => $child->getAttribute('id'), 'name' => $child->getAttribute('name'), 'identifier' => $child->getAttribute('identifier'), 'priority' => $child->getAttribute('priority'));
             }
         }
     }
     unset($optionsNode);
     $xmlString = $this->classContentToXml($content);
     $classAttribute->setAttribute(self::CLASS_STORAGE_XML, $xmlString);
 }
コード例 #10
0
 /**
  * This function is called when a new version is created or an object is copied
  * @param eZContentObjectAttribute $objectAttribute
  * @param integer $currentVersion
  * @param eZContentObjectAttribute $originalContentObjectAttribute
  */
 function initializeObjectAttribute($objectAttribute, $currentVersion, $originalContentObjectAttribute)
 {
     if ($objectAttribute->attribute('contentobject_id') != $originalContentObjectAttribute->attribute('contentobject_id')) {
     }
     // this is a copy of an original object
     // we should remove datas from data_text
     $objectAttribute->setAttribute('data_text', '');
 }
コード例 #11
0
 /**
  * Set parameters from post data
  *
  * @param eZHTTPTool $http
  * @param string $base
  * @param eZContentObjectAttribute $contentObjectAttribute
  */
 function fetchObjectAttributeHTTPInput($http, $base, $contentObjectAttribute)
 {
     $data = $_REQUEST[$base . '_' . $contentObjectAttribute->attribute('id') . '_related_nodes'];
     $contentObjectAttribute->setAttribute('data_text', serialize($data));
     return true;
 }