当前位置: 首页>>代码示例>>PHP>>正文


PHP eZContentObject::exists方法代码示例

本文整理汇总了PHP中eZContentObject::exists方法的典型用法代码示例。如果您正苦于以下问题:PHP eZContentObject::exists方法的具体用法?PHP eZContentObject::exists怎么用?PHP eZContentObject::exists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在eZContentObject的用法示例。


在下文中一共展示了eZContentObject::exists方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: eZSurveyRelatedObject

 function eZSurveyRelatedObject($row = false)
 {
     $row['type'] = 'RelatedObject';
     $this->eZSurveyQuestion($row);
     $surveyID = $this->attribute('survey_id');
     $survey = eZSurvey::fetch($surveyID);
     $contentObjectID = $survey->attribute('contentobject_id');
     $postRelatedObject = 'SelectedNodeIDArray';
     $http = eZHTTPTool::instance();
     if ($http->hasPostVariable($postRelatedObject)) {
         // need to do an extra check if this is the datatype that should receive the information.
         $value = $http->postVariable($postRelatedObject);
     }
     $http = eZHTTPTool::instance();
     $module = $GLOBALS['module'];
     //         $http->removeSessionVariable( 'LastAccessesURI' );
     //         $http->removeSessionVariable( 'RedirectURIAfterPublish' );
     //         $http->removeSessionVariable( 'RedirectIfDiscarded' );
     if ($module->exitStatus() !== eZModule::STATUS_REDIRECT) {
         if ($http->hasSessionVariable('LastAccessesURI_Backup_' . $contentObjectID . '_' . $this->ID) and $http->sessionVariable('LastAccessesURI_Backup_' . $contentObjectID . '_' . $this->ID) !== null) {
             $value = $http->sessionVariable('LastAccessesURI_Backup_' . $contentObjectID . '_' . $this->ID);
             $http->setSessionVariable('LastAccessesURI', $value['content']);
             $http->removeSessionVariable('LastAccessesURI_Backup_' . $contentObjectID . '_' . $this->ID);
             if (is_numeric($this->Num) and $this->Num > 0) {
                 $contentObjectExists = eZContentObject::exists($this->Num);
                 if ($contentObjectExists !== true) {
                     $this->Num = 0;
                     $this->store();
                 }
             }
         }
         if ($http->hasSessionVariable('RedirectURIAfterPublish_Backup_' . $contentObjectID . '_' . $this->ID) and $http->sessionVariable('RedirectURIAfterPublish_Backup_' . $contentObjectID . '_' . $this->ID) !== null) {
             $value = $http->sessionVariable('RedirectURIAfterPublish_Backup_' . $contentObjectID . '_' . $this->ID);
             $http->setSessionVariable('RedirectURIAfterPublish', $value['content']);
             $http->removeSessionVariable('RedirectURIAfterPublish_Backup_' . $contentObjectID . '_' . $this->ID);
         }
         if ($http->hasSessionVariable('RedirectIfDiscarded_Backup_' . $contentObjectID . '_' . $this->ID) and $http->sessionVariable('RedirectIfDiscarded_Backup_' . $contentObjectID . '_' . $this->ID) !== null) {
             $value = $http->sessionVariable('RedirectIfDiscarded_Backup_' . $contentObjectID . '_' . $this->ID);
             $http->setSessionVariable('RedirectIfDiscarded', $value['content']);
             $http->removeSessionVariable('RedirectIfDiscarded_Backup_' . $contentObjectID . '_' . $this->ID);
         }
     }
 }
开发者ID:heliopsis,项目名称:ezsurvey,代码行数:43,代码来源:ezsurveyrelatedobject.php

示例2: processRelationListRow

function processRelationListRow(array $row)
{
    $db = eZDB::instance();
    $document = new DOMDocument("1.0", "utf-8");
    $document->loadXML($row["data_text"]);
    $xpath = new DOMXPath($document);
    $xpathExpression = "//related-objects/relation-list/relation-item";
    $removedRelations = array();
    $relationItems = $xpath->query($xpathExpression);
    /** @var \DOMElement $relationItem */
    foreach ($relationItems as $relationItem) {
        $contentId = $relationItem->getAttribute("contentobject-id");
        if (!eZContentObject::exists($contentId)) {
            $relationItem->parentNode->removeChild($relationItem);
            $removedRelations[] = $contentId;
        }
    }
    if (count($removedRelations) > 0) {
        $db->query("UPDATE ezcontentobject_attribute\n             SET data_text = '" . $db->escapeString($document->saveXML()) . "'\n             WHERE ezcontentobject_attribute.id = " . $row["id"] . " AND\n                   ezcontentobject_attribute.version = " . $row["version"]);
    }
    return $removedRelations;
}
开发者ID:mugoweb,项目名称:ezpublish-legacy,代码行数:22,代码来源:cleanupfieldvaluerelations.php

示例3: array

//
// ## END COPYRIGHT, LICENSE AND WARRANTY NOTICE ##
//
$http = eZHTTPTool::instance();
$basket = eZBasket::currentBasket();
$module = $Params['Module'];
$quantity = (int) $module->NamedParameters["Quantity"];
if (!is_numeric($quantity) or $quantity <= 0) {
    $quantity = 1;
}
// Verify the ObjectID input
if (!is_numeric($ObjectID)) {
    return $module->handleError(eZError::KERNEL_NOT_AVAILABLE, 'kernel');
}
// Check if the object exists on disc
if (!eZContentObject::exists($ObjectID)) {
    return $module->handleError(eZError::KERNEL_NOT_AVAILABLE, 'kernel');
}
// Check if the user can read the object
$object = eZContentObject::fetch($ObjectID);
if (!$object->canRead()) {
    return $Module->handleError(eZError::KERNEL_ACCESS_DENIED, 'kernel', array('AccessList' => $object->accessList('read')));
}
// Check if the object has a price datatype, if not it cannot be used in the basket
$error = $basket->canAddProduct($object);
if ($error !== eZError::SHOP_OK) {
    return $Module->handleError($error, 'shop');
}
$OptionList = $http->sessionVariable("AddToBasket_OptionList_" . $ObjectID);
$operationResult = eZOperationHandler::execute('shop', 'addtobasket', array('basket_id' => $basket->attribute('id'), 'object_id' => $ObjectID, 'quantity' => $quantity, 'option_list' => $OptionList));
switch ($operationResult['status']) {
开发者ID:runelangseid,项目名称:ezpublish,代码行数:31,代码来源:add.php

示例4: publishHandlerLink

 /**
  * publishHandlerLink (Publish handler, pass 2 after schema validation)
  * Publish handler for link element, converts href to [object|node|link]_id.
  *
  * @param DOMElement $element
  * @param array $param parameters for xml element
  * @return null|array changes structure if it contains 'result' key
  */
 function publishHandlerLink($element, &$params)
 {
     $ret = null;
     $href = $element->getAttribute('href');
     if ($href) {
         $objectID = false;
         if (strpos($href, 'ezobject') === 0 && preg_match("@^ezobject://([0-9]+)/?(#.+)?@i", $href, $matches)) {
             $objectID = $matches[1];
             if (isset($matches[2])) {
                 $anchorName = substr($matches[2], 1);
             }
             $element->setAttribute('object_id', $objectID);
             if (!eZContentObject::exists($objectID)) {
                 $this->Messages[] = ezpI18n::tr('design/standard/ezoe/handler', 'Object %1 does not exist.', false, array($objectID));
             }
         } elseif (strpos($href, 'eznode') === 0 && preg_match("@^eznode://([^#]+)(#.+)?@i", $href, $matches)) {
             $nodePath = trim($matches[1], '/');
             if (isset($matches[2])) {
                 $anchorName = substr($matches[2], 1);
             }
             if (is_numeric($nodePath)) {
                 $nodeID = $nodePath;
                 $node = eZContentObjectTreeNode::fetch($nodeID);
                 if (!$node instanceof eZContentObjectTreeNode) {
                     $this->Messages[] = ezpI18n::tr('design/standard/ezoe/handler', 'Node %1 does not exist.', false, array($nodeID));
                 }
             } else {
                 $node = eZContentObjectTreeNode::fetchByURLPath($nodePath);
                 if (!$node instanceof eZContentObjectTreeNode) {
                     $this->Messages[] = ezpI18n::tr('design/standard/ezoe/handler', 'Node &apos;%1&apos; does not exist.', false, array($nodePath));
                 } else {
                     $nodeID = $node->attribute('node_id');
                 }
                 $element->setAttribute('show_path', 'true');
             }
             if (isset($nodeID) && $nodeID) {
                 $element->setAttribute('node_id', $nodeID);
             }
             if (isset($node) && $node instanceof eZContentObjectTreeNode) {
                 $objectID = $node->attribute('contentobject_id');
             }
         } elseif (strpos($href, '#') === 0) {
             $anchorName = substr($href, 1);
         } else {
             $temp = explode('#', $href);
             $url = $temp[0];
             if (isset($temp[1])) {
                 $anchorName = $temp[1];
             }
             if ($url) {
                 // Protection from XSS attack
                 if (preg_match("/^(java|vb)script:.*/i", $url)) {
                     $this->isInputValid = false;
                     $this->Messages[] = "Using scripts in links is not allowed, '{$url}' has been removed";
                     $element->removeAttribute('href');
                     return $ret;
                 }
                 // Check mail address validity following RFC 5322 and RFC 5321
                 if (preg_match("/^mailto:([^.][a-z0-9!#\$%&'*+-\\/=?`{|}~^]+@([a-z0-9.-]+))/i", $url, $mailAddr)) {
                     if (!eZMail::validate($mailAddr[1])) {
                         $this->isInputValid = false;
                         if ($this->errorLevel >= 0) {
                             $this->Messages[] = ezpI18n::tr('kernel/classes/datatypes/ezxmltext', "Invalid e-mail address: '%1'", false, array($mailAddr[1]));
                         }
                         $element->removeAttribute('href');
                         return $ret;
                     }
                 }
                 // Store urlID instead of href
                 $url = str_replace(array('&amp;', '%28', '%29'), array('&', '(', ')'), $url);
                 $urlID = eZURL::registerURL($url);
                 if ($urlID) {
                     if (!in_array($urlID, $this->urlIDArray)) {
                         $this->urlIDArray[] = $urlID;
                     }
                     $element->setAttribute('url_id', $urlID);
                 }
             }
         }
         if ($objectID && !in_array($objectID, $this->linkedObjectIDArray)) {
             $this->linkedObjectIDArray[] = $objectID;
         }
         if (isset($anchorName) && $anchorName) {
             $element->setAttribute('anchor_name', $anchorName);
         }
     }
     return $ret;
 }
开发者ID:legende91,项目名称:ez,代码行数:96,代码来源:ezoeinputparser.php

示例5: addContentObjectRelation

    /**
     * Adds a link to the given content object id.
     *
     * Transaction unsafe. If you call several transaction unsafe methods you must enclose
     * the calls within a db transaction; thus within db->begin and db->commit.
     *
     * @param int $toObjectID
     * @param int|bool $fromObjectVersion
     * @param int $attributeID
     * @param int $relationType
     * @return bool|void
     */
    function addContentObjectRelation( $toObjectID,
                                       $fromObjectVersion = false,
                                       $attributeID = 0,
                                       $relationType = eZContentObject::RELATION_COMMON )
    {
        if ( $attributeID !== 0 )
        {
            $relationType = eZContentObject::RELATION_ATTRIBUTE;
        }

        $relationType =(int) $relationType;
        if ( ( $relationType & eZContentObject::RELATION_ATTRIBUTE ) != 0 &&
             $relationType != eZContentObject::RELATION_ATTRIBUTE )
        {
            eZDebug::writeWarning( "Object relation type conflict", __METHOD__ );
        }

        $db = eZDB::instance();

        if ( !$fromObjectVersion )
            $fromObjectVersion = $this->CurrentVersion;

        $fromObjectID = $this->ID;

        if ( !is_numeric( $toObjectID ) )
        {
            eZDebug::writeError( "Related object ID (toObjectID): '$toObjectID', is not a numeric value.",
                                 "eZContentObject::addContentObjectRelation" );
            return false;
        }

        if ( !eZContentObject::exists( $toObjectID ) )
        {
            eZDebug::writeError( "Related object ID (toObjectID): '$toObjectID', does not refer to any existing object.",
                                 "eZContentObject::addContentObjectRelation" );
            return false;
        }

        $fromObjectID =(int) $fromObjectID;
        $attributeID =(int) $attributeID;
        $fromObjectVersion =(int) $fromObjectVersion;
        $relationBaseType = ( $relationType & eZContentObject::RELATION_ATTRIBUTE ) ?
                                eZContentObject::RELATION_ATTRIBUTE :
                                eZContentObject::RELATION_COMMON | eZContentObject::RELATION_EMBED | eZContentObject::RELATION_LINK;
        $relationTypeMatch = $db->bitAnd( 'relation_type', $relationBaseType );
        $query = "SELECT count(*) AS count
                  FROM   ezcontentobject_link
                  WHERE  from_contentobject_id=$fromObjectID AND
                         from_contentobject_version=$fromObjectVersion AND
                         to_contentobject_id=$toObjectID AND
                         $relationTypeMatch != 0 AND
                         contentclassattribute_id=$attributeID";
        $count = $db->arrayQuery( $query );
        // if current relation does not exist
        if ( !isset( $count[0]['count'] ) ||  $count[0]['count'] == '0'  )
        {
            $db->begin();
            $db->query( "INSERT INTO ezcontentobject_link ( from_contentobject_id, from_contentobject_version, to_contentobject_id, contentclassattribute_id, relation_type )
                         VALUES ( $fromObjectID, $fromObjectVersion, $toObjectID, $attributeID, $relationType )" );
            $db->commit();
        }
        elseif ( isset( $count[0]['count'] ) &&
                 $count[0]['count'] != '0' &&
                 $attributeID == 0 &&
                 (eZContentObject::RELATION_ATTRIBUTE & $relationType) == 0 )
        {
            $db->begin();
            $newRelationType = $db->bitOr( 'relation_type', $relationType );
            $db->query( "UPDATE ezcontentobject_link
                         SET    relation_type = $newRelationType
                         WHERE  from_contentobject_id=$fromObjectID AND
                                from_contentobject_version=$fromObjectVersion AND
                                to_contentobject_id=$toObjectID AND
                                contentclassattribute_id=$attributeID" );
            $db->commit();
        }
    }
开发者ID:ezsystemstraining,项目名称:ez54training,代码行数:89,代码来源:ezcontentobject.php

示例6: contentObjectVersion

 function contentObjectVersion()
 {
     $retVal = false;
     if (eZContentObject::exists($this->attribute('contentobject_id'))) {
         $retVal = eZContentObjectVersion::fetchVersion($this->attribute('contentobject_version'), $this->attribute('contentobject_id'));
     }
     return $retVal;
 }
开发者ID:EVE-Corp-Center,项目名称:ECC-Website,代码行数:8,代码来源:eznewsletter.php


注:本文中的eZContentObject::exists方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。