/**
  * Returns the attributes for the content object version \a $version and content object \a $contentObjectID.
  *
  * @param int $version
  * @param bool $asObject
  * @return eZContentClassAttribute[]|array|null
  */
 function fetchClassAttributes( $version = 0, $asObject = true )
 {
     return eZContentClassAttribute::fetchListByClassID( $this->attribute( 'contentclass_id' ), $version, $asObject );
 }
function storeRSSImport( $rssImport, $http, $publish = false )
{
    $rssImport->setAttribute( 'name', $http->postVariable( 'name' ) );
    $rssImport->setAttribute( 'url', $http->postVariable( 'url' ) );
    if ( $http->hasPostVariable( 'active' ) )
        $rssImport->setAttribute( 'active', 1 );
    else
        $rssImport->setAttribute( 'active', 0 );

    if ( $http->hasPostVariable( 'Class_ID' ) )
    {
        $rssImport->setAttribute( 'class_id', $http->postVariable( 'Class_ID' ) );
    }

    $importDescription = $rssImport->importDescription();
    $classAttributeList = eZContentClassAttribute::fetchListByClassID( $rssImport->attribute( 'class_id' ) );

    $importDescription['class_attributes'] = array();
    foreach( $classAttributeList as $classAttribute )
    {
        $postVariableName = 'Class_Attribute_' . $classAttribute->attribute( 'id' );
        if ( $http->hasPostVariable( $postVariableName ) )
        {
            $importDescription['class_attributes'][(string)$classAttribute->attribute( 'id' )] = $http->postVariable( $postVariableName );
        }
    }

    $importDescription['object_attributes'] = array();
    foreach( $rssImport->objectAttributeList() as $key => $attributeName )
    {
        $postVariableName = 'Object_Attribute_' . $key;
        if ( $http->hasPostVariable( $postVariableName ) )
        {
            $importDescription['object_attributes'][$key] = $http->postVariable( $postVariableName );
        }
    }

    $rssImport->setImportDescription( $importDescription );

    if ( $publish )
    {
        $db = eZDB::instance();
        $db->begin();
        $rssImport->setAttribute( 'status', eZRSSImport::STATUS_VALID );
        $rssImport->store();
        // remove draft
        $rssImport->setAttribute( 'status', eZRSSImport::STATUS_DRAFT );
        $rssImport->remove();
        $db->commit();
    }
    else
    {
        $rssImport->store();
    }
}
 function attribute($attr)
 {
     switch ($attr) {
         case 'contentclass_list':
             return eZContentClass::fetchList(eZContentClass::VERSION_STATUS_DEFINED, true);
             break;
         case 'contentclassattribute_list':
             //                $postvarname = 'WorkflowEvent' . '_event_ezwaituntildate_' .'class_' . $workflowEvent->attribute( 'id' ); and $http->hasPostVariable( $postvarname )
             if (isset($GLOBALS['eZWaitUntilDateSelectedClass'])) {
                 $classID = $GLOBALS['eZWaitUntilDateSelectedClass'];
             } else {
                 // if nothing was preselected, we will use the first one:
                 // POSSIBLE ENHANCEMENT: in the common case, the contentclass_list fetch will be called twice
                 $classList = eZWaitUntilDateType::attribute('contentclass_list');
                 if (isset($classList[0])) {
                     $classID = $classList[0]->attribute('id');
                 } else {
                     $classID = false;
                 }
             }
             if ($classID) {
                 return eZContentClassAttribute::fetchListByClassID($classID);
             }
             return array();
             break;
         case 'has_class_attributes':
             // for the backward compatibility:
             return 1;
             break;
         default:
             return eZWorkflowEventType::attribute($attr);
     }
 }
 function attributeDecoder($event, $attribute)
 {
     switch ($attribute) {
         case 'target_nodes':
             if ($event->attribute('data_text1') == '') {
                 return array();
             }
             return explode(',', $event->attribute('data_text1'));
         case 'contentclassattribute_list':
             $id = $event->attribute('id');
             if (isset($GLOBALS['multiPublishTypeSelectedClass']) && isset($GLOBALS['multiPublishTypeSelectedClass'][$id])) {
                 $classID = $GLOBALS['multiPublishTypeSelectedClass'][$id];
             } else {
                 // if nothing was preselected, we will use the first one:
                 // @todo in the common case, the contentclass_list fetch will be called twice
                 $classList = $this->attribute('contentclass_list');
                 if (isset($classList[0])) {
                     $classID = $classList[0]->attribute('id');
                 } else {
                     $classID = false;
                 }
             }
             if ($classID) {
                 $attrlist = eZContentClassAttribute::fetchListByClassID($classID);
                 foreach ($attrlist as $key => $attr) {
                     if ($attr->attribute('data_type_string') != 'ezboolean') {
                         unset($attrlist[$key]);
                     }
                 }
                 return $attrlist;
             }
             return array();
         case 'contentclass':
             $id = $event->attribute('id');
             if (isset($GLOBALS['multiPublishTypeSelectedClass']) && isset($GLOBALS['multiPublishTypeSelectedClass'][$id])) {
                 return $GLOBALS['multiPublishTypeSelectedClass'][$id];
             }
             return '';
     }
     return null;
 }
Exemple #5
0
 private function createContentObject($classIdentifier, $parentNodeId, $fillMode)
 {
     $contentClass = eZContentClass::fetchByIdentifier($classIdentifier);
     if (!$contentClass) {
         throw new Exception("This content class does not exist: [" . $classIdentifier . "]");
     }
     if (!eepValidate::validateContentNodeId($parentNodeId)) {
         throw new Exception("This is not an node id: [" . $parentNodeId . "]");
     }
     // todo, in addition to "random" mode, datamap content should be
     // pullable from a suitable xml file; might also provide a way to dump
     // the framework for a content class "as xml"
     if ("random" == $fillMode) {
         $classId = eZContentClass::classIDByIdentifier($classIdentifier);
         $attributeList = eZContentClassAttribute::fetchListByClassID($classId);
         $words = explode(" ", self::fake_text);
         $dataSet = array();
         foreach ($attributeList as $attr) {
             switch ($attr->DataTypeString) {
                 default:
                 case "ezmedia":
                     echo "NOT YET SUPPORTED: [" . $attr->DataTypeString . "]\n";
                     $dataSet[$attr->Identifier] = "123";
                     break;
                 case "ezkeyword":
                     $randomKeys = array_flip(array_rand($words, 2));
                     $randomWords = array_intersect_key($words, $randomKeys);
                     $dataSet[$attr->Identifier] = implode(",", $randomWords);
                     break;
                 case "ezstring":
                     $randomKeys = array_flip(array_rand($words, 5));
                     $randomWords = array_intersect_key($words, $randomKeys);
                     $dataSet[$attr->Identifier] = implode(" ", $randomWords);
                     break;
                 case "eztext":
                     $randomKeys = array_flip(array_rand($words, 100));
                     $randomWords = array_intersect_key($words, $randomKeys);
                     $dataSet[$attr->Identifier] = implode(" ", $randomWords);
                     break;
                 case "ezdatetime":
                     $dataSet[$attr->Identifier] = time();
                     break;
                 case "ezxmltext":
                     $text = "";
                     for ($paraCount = 0; $paraCount < 5; $paraCount += 1) {
                         $randomKeys = array_flip(array_rand($words, 60));
                         $randomWords = array_intersect_key($words, $randomKeys);
                         $text .= "<p>" . implode(" ", $randomWords) . "</p>";
                     }
                     $parser = new eZOEInputParser();
                     $document = $parser->process($text);
                     $dataSet[$attr->Identifier] = eZXMLTextType::domString($document);
                     break;
             }
         }
         $createResults = $this->create($parentNodeId, $classIdentifier, $dataSet);
         //echo "\nobject creation results\n";
         //var_dump( $createResults );
     } else {
         throw new Exception("Only 'random' is currently supported.");
     }
 }
Exemple #6
0
 static function listAttributes($classIdentifier)
 {
     $contentClass = eZContentClass::fetchByIdentifier($classIdentifier);
     if (!$contentClass) {
         throw new Exception("This content class does not exist: [" . $classIdentifier . "]");
     }
     $classId = eZContentClass::classIDByIdentifier($classIdentifier);
     $attributeList = eZContentClassAttribute::fetchListByClassID($classId);
     $results = array();
     $results[] = array("Identifier", "Lang", "Id", "Type", "Srch", "Reqd", "Info", "Pos", "Name");
     foreach ($attributeList as $attribute) {
         $snl = unserialize($attribute->SerializedNameList);
         $results[] = array($attribute->Identifier, $snl["always-available"], $attribute->ID, $attribute->DataTypeString, $attribute->IsSearchable, $attribute->IsRequired, $attribute->IsInformationCollector, $attribute->Position, $snl[$snl["always-available"]]);
     }
     eep::printTable($results, "list attributes of class: " . $classIdentifier);
 }
Exemple #7
0
 private function searchForNodes($parentNodeId, $classIdentifier, $searchString)
 {
     $contentClass = eZContentClass::fetchByIdentifier($classIdentifier);
     if (!$contentClass) {
         throw new Exception("This content class does not exist: [" . $classIdentifier . "]");
     }
     if (!eepValidate::validateContentNodeId($parentNodeId)) {
         throw new Exception("This is not a node id: [" . $parentNodeId . "]");
     }
     $classId = eZContentClass::classIDByIdentifier($classIdentifier);
     $attributeList = eZContentClassAttribute::fetchListByClassID($classId);
     $limit = 100;
     if (isset($additional["limit"])) {
         $limit = $additional["limit"];
     }
     $offset = 0;
     if (isset($additional["offset"])) {
         $offset = $additional["offset"];
     }
     $params["ClassFilterType"] = "include";
     $params["ClassFilterArray"] = array($classIdentifier);
     $params["MainNodeOnly"] = true;
     $params["IgnoreVisibility"] = true;
     $params['Limitation'] = array();
     $params['Offset'] = $offset;
     $params['Limit'] = $limit;
     $searchStringIsNumeric = is_numeric($searchString);
     $numericTypes = array("ezinteger", "ezfloat", "ezdatetime", "ezboolean");
     $params["AttributeFilter"] = array("or");
     foreach ($attributeList as $attribute) {
         $qualifiedAttributeName = $classIdentifier . "/" . $attribute->Identifier;
         // eg folder/name
         // if the string is not numeric and the attribute is numeric, don't
         // search on it -- this is still rough functionality
         if (in_array($attribute->DataTypeString, $numericTypes) && !$searchStringIsNumeric) {
             continue;
         }
         // search on everything else -- maybe a bad idea which generates too
         // many hits ...
         $params["AttributeFilter"][] = array($qualifiedAttributeName, "like", "*" . $searchString . "*");
     }
     $matches = eZContentObjectTreeNode::subTreeByNodeID($params, $parentNodeId);
     $title = "Search on all attributes in '" . $classIdentifier . "' for '" . $searchString . "' from parent " . $parentNodeId;
     eep::displayNodeList($matches, $title);
 }