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


PHP Asset::getById方法代码示例

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


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

示例1: load

 /**
  * Loads a list of entries for the specicifies parameters, returns an array of Search_Backend_Data
  *
  * @return array
  */
 public function load()
 {
     $entries = array();
     $data = $this->db->fetchAll("SELECT * FROM search_backend_data" . $this->getCondition() . $this->getGroupBy() . $this->getOrder() . $this->getOffsetLimit(), $this->model->getConditionVariables());
     foreach ($data as $entryData) {
         if ($entryData['maintype'] == 'document') {
             $element = Document::getById($entryData['id']);
         } else {
             if ($entryData['maintype'] == 'asset') {
                 $element = Asset::getById($entryData['id']);
             } else {
                 if ($entryData['maintype'] == 'object') {
                     $element = Object_Abstract::getById($entryData['id']);
                 } else {
                     Logger::err("unknown maintype ");
                 }
             }
         }
         if ($element) {
             $entry = new Search_Backend_Data();
             $entry->setId(new Search_Backend_Data_Id($element));
             $entry->setFullPath($entryData['fullpath']);
             $entry->setType($entryData['type']);
             $entry->setSubtype($entryData['subtype']);
             $entry->setUserOwner($entryData['userowner']);
             $entry->setUserModification($entryData['usermodification']);
             $entry->setCreationDate($entryData['creationdate']);
             $entry->setModificationDate($entryData['modificationdate']);
             $entry->setPublished($entryData['published'] === 0 ? false : true);
             $entries[] = $entry;
         }
     }
     $this->model->setEntries($entries);
     return $entries;
 }
开发者ID:ngocanh,项目名称:pimcore,代码行数:40,代码来源:Resource.php

示例2: getIdPathForElement

 /**
  * @static
  * @param  $element
  * @return string
  */
 public static function getIdPathForElement($element)
 {
     $path = "";
     if ($element instanceof Document) {
         $nid = $element->getParentId();
         $ne = Document::getById($nid);
     } else {
         if ($element instanceof Asset) {
             $nid = $element->getParentId();
             $ne = Asset::getById($nid);
         } else {
             if ($element instanceof Object_Abstract) {
                 $nid = $element->getO_parentId();
                 $ne = Object_Abstract::getById($nid);
             }
         }
     }
     if ($ne) {
         $path = self::getIdPathForElement($ne, $path);
     }
     if ($element) {
         $path = $path . "/" . $element->getId();
     }
     return $path;
 }
开发者ID:shanky0110,项目名称:pimcore-custom,代码行数:30,代码来源:Tool.php

示例3: load

 /**
  * Get the assets from database
  *
  * @return array
  */
 public function load()
 {
     $assets = array();
     $assetsData = $this->db->fetchAll("SELECT id,type FROM assets" . $this->getCondition() . $this->getOrder() . $this->getOffsetLimit(), $this->model->getConditionVariables());
     foreach ($assetsData as $assetData) {
         if ($assetData["type"]) {
             $assets[] = Asset::getById($assetData["id"]);
         }
     }
     $this->model->setAssets($assets);
     return $assets;
 }
开发者ID:ngocanh,项目名称:pimcore,代码行数:17,代码来源:Resource.php

示例4: cleanUp

 /**
  * legacy - not required anymore
  *
  *
  * @return void
  */
 protected function cleanUp()
 {
     try {
         $class = Object_Class::getByName("unittest");
         if ($class instanceof Object_Class) {
             $class->delete();
         }
     } catch (Exception $e) {
     }
     try {
         $objectRoot = Object_Abstract::getById(1);
         if ($objectRoot and $objectRoot->hasChilds()) {
             $childs = $objectRoot->getChilds();
             foreach ($childs as $child) {
                 $child->delete();
             }
         }
     } catch (Exception $e) {
     }
     try {
         $assetRoot = Asset::getById(1);
         if ($assetRoot and $assetRoot->hasChilds()) {
             $childs = $assetRoot->getChilds();
             foreach ($childs as $child) {
                 $child->delete();
             }
         }
     } catch (Exception $e) {
     }
     try {
         $documentRoot = Asset::getById(1);
         if ($documentRoot and $documentRoot->hasChilds()) {
             $childs = $documentRoot->getChilds();
             foreach ($childs as $child) {
                 $child->delete();
             }
         }
     } catch (Exception $e) {
     }
     try {
         $userList = new User_List();
         $userList->setCondition("id > 1");
         $users = $userList->load();
         if (is_array($users) and count($users) > 0) {
             foreach ($users as $user) {
                 $user->delete();
             }
         }
     } catch (Exception $e) {
     }
 }
开发者ID:ngocanh,项目名称:pimcore,代码行数:57,代码来源:AllTests.php

示例5: getById

 /**
  * Get the data for the object from database for the given id
  * @param integer $id
  * @return void
  */
 public function getById($id)
 {
     $data = $this->db->fetchRow("SELECT * FROM notes WHERE id = ?", $id);
     if (!$data["id"]) {
         throw new Exception("Note item with id " . $id . " not found");
     }
     $this->assignVariablesToModel($data);
     // get key-value data
     $keyValues = $this->db->fetchAll("SELECT * FROM notes_data WHERE id = ?", $id);
     $preparedData = array();
     foreach ($keyValues as $keyValue) {
         $data = $keyValue["data"];
         $type = $keyValue["type"];
         $name = $keyValue["name"];
         if ($type == "document") {
             if ($data) {
                 $data = Document::getById($data);
             }
         } else {
             if ($type == "asset") {
                 if ($data) {
                     $data = Asset::getById($data);
                 }
             } else {
                 if ($type == "object") {
                     if ($data) {
                         $data = Object_Abstract::getById($data);
                     }
                 } else {
                     if ($type == "date") {
                         if ($data > 0) {
                             $data = new Zend_Date($data);
                         }
                     } else {
                         if ($type == "bool") {
                             $data = (bool) $data;
                         }
                     }
                 }
             }
         }
         $preparedData[$name] = array("data" => $data, "type" => $type);
     }
     $this->model->setData($preparedData);
 }
开发者ID:shanky0110,项目名称:pimcore-custom,代码行数:50,代码来源:Resource.php

示例6: setTargetId

 /**
  * @param int $targetId
  */
 public function setTargetId($targetId)
 {
     $this->targetId = $targetId;
     try {
         if ($this->type == "object") {
             $this->target = Object_Abstract::getById($targetId);
         } else {
             if ($this->type == "asset") {
                 $this->target = Asset::getById($targetId);
             } else {
                 if ($this->type == "document") {
                     $this->target = Document::getById($targetId);
                 } else {
                     Logger::log(get_class($this) . ": could not set resource - unknown type[" . $this->type . "]");
                 }
             }
         }
     } catch (Exception $e) {
         Logger::log(get_class($this) . ": Error setting resource");
     }
 }
开发者ID:ascertain,项目名称:NGshop,代码行数:24,代码来源:RatingsComments.php

示例7: commentsAction

 public function commentsAction()
 {
     if ($this->_getParam('xaction') == "destroy") {
         $id = $this->_getParam("comments");
         $id = str_replace('"', '', $id);
         RatingsComments_Plugin::deleteComment($id);
         $results["success"] = true;
         $results["comments"] = "";
     } else {
         $id = $this->_getParam("objectid");
         $type = $this->_getParam("type");
         if ($type == "object") {
             $target = Object_Abstract::getById($id);
         } else {
             if ($type == "page" || $type == "snippet") {
                 $target = Document::getById($id);
             } else {
                 //try asset
                 $target = Asset::getById($id);
             }
         }
         $comments = RatingsComments_Plugin::getComments($target);
         $results = array();
         if (is_array($comments)) {
             foreach ($comments as $comment) {
                 $shorttext = $comment->getComment();
                 if (strlen($shorttext) > 50) {
                     $shorttext = substr($shorttext, 0, 50) . "...";
                 }
                 $results["comments"][] = array("c_id" => $comment->getId(), "c_shorttext" => $shorttext, "c_text" => $comment->getComment(), "c_rating" => $comment->getRating(), "c_user" => $comment->getName(), "c_created" => $comment->getDate());
             }
         }
         if (!isset($results["comments"])) {
             $results["comments"] = "";
         }
     }
     echo Zend_Json::encode($results);
     $this->removeViewRenderer();
 }
开发者ID:ascertain,项目名称:NGshop,代码行数:39,代码来源:AdminController.php

示例8: maintenanceCleanUp

 /**
  *
  */
 public function maintenanceCleanUp()
 {
     $conf["document"] = Pimcore_Config::getSystemConfig()->documents->versions;
     $conf["asset"] = Pimcore_Config::getSystemConfig()->assets->versions;
     $conf["object"] = Pimcore_Config::getSystemConfig()->objects->versions;
     $elementTypes = array();
     foreach ($conf as $elementType => $tConf) {
         if (intval($tConf->days) > 0) {
             $versioningType = "days";
             $value = intval($tConf->days);
         } else {
             $versioningType = "steps";
             $value = intval($tConf->steps);
         }
         if ($versioningType) {
             $elementTypes[] = array("elementType" => $elementType, $versioningType => $value);
         }
     }
     $versions = $this->getResource()->maintenanceGetOutdatedVersions($elementTypes);
     if (is_array($versions)) {
         foreach ($versions as $index => $id) {
             $version = Version::getById($id);
             if ($version->getCtype() == "document") {
                 $element = Document::getById($version->getCid());
             } else {
                 if ($version->getCtype() == "asset") {
                     $element = Asset::getById($version->getCid());
                 } else {
                     if ($version->getCtype() == "object") {
                         $element = Object_Abstract::getById($version->getCid());
                     }
                 }
             }
             if ($element instanceof Element_Interface) {
                 if ($element->getModificationDate() > $version->getDate()) {
                     // delete version if it is outdated
                     $version->delete();
                 }
             } else {
                 // delete version if the correspondening element doesn't exist anymore
                 $version->delete();
             }
             // call the garbage collector every 100 iterations, to avoid a out-of-memory
             if ($index % 100 == 0) {
                 Pimcore::collectGarbage();
             }
         }
     }
 }
开发者ID:shanky0110,项目名称:pimcore-custom,代码行数:52,代码来源:Version.php

示例9: foreach

 foreach ($s as $el) {
     if ($el->src) {
         if (preg_match("/asset:([0-9]+)/i", $el->src, $match)) {
             if ($asset = Asset::getById($match[1])) {
                 $el->pimcore_id = $asset->getId();
                 $el->pimcore_type = "asset";
                 $el->src = $asset->getFullPath();
             } else {
                 $el->outertext = "";
             }
         }
     }
     if ($el->href) {
         if (preg_match_all("/(asset|document):([0-9]+)/i", $el->href, $match)) {
             if ($match[1][0] == "asset") {
                 if ($asset = Asset::getById($match[2][0])) {
                     $el->pimcore_id = $asset->getId();
                     $el->pimcore_type = "asset";
                     $el->href = $asset->getFullPath();
                 } else {
                     $el->outertext = $el->innertext;
                 }
             } else {
                 if ($match[1][0] == "document") {
                     if ($doc = Document::getById($match[2][0])) {
                         $el->pimcore_id = $doc->getId();
                         $el->pimcore_type = "document";
                         $el->href = $doc->getFullPath();
                     } else {
                         $el->outertext = $el->innertext;
                     }
开发者ID:SeerUK,项目名称:pimcore-manual-updater,代码行数:31,代码来源:postupdate.php

示例10: getForWebserviceExport

 /**
  * Returns the current tag's data for web service export
  *
  * @abstract
  * @return array
  */
 public function getForWebserviceExport()
 {
     $el = parent::getForWebserviceExport();
     if ($this->data["internal"]) {
         if (intval($this->data["internalId"]) > 0) {
             if ($this->data["internalType"] == "document") {
                 $referencedDocument = Document::getById($this->data["internalId"]);
                 if (!$referencedDocument instanceof Document) {
                     //detected broken link
                     $document = Document::getById($this->getDocumentId());
                     Element_Service::scheduleForSanityCheck($document);
                 }
             } else {
                 if ($this->data["internalType"] == "asset") {
                     $referencedAsset = Asset::getById($this->data["internalId"]);
                     if (!$referencedAsset instanceof Asset) {
                         //detected broken link
                         $document = Document::getById($this->getDocumentId());
                         Element_Service::scheduleForSanityCheck($document);
                     }
                 }
             }
         }
     }
     $el->data = $this->data;
     return $el;
 }
开发者ID:ngocanh,项目名称:pimcore,代码行数:33,代码来源:Link.php

示例11: testPermissionChanges

 /**
  * change general user permissions
  * @depends testModifyUserToAdmin
  * @var User $user
  */
 public function testPermissionChanges()
 {
     $userGroup = User::getByName("unitTestUserGroup");
     $username = $userGroup->getUsername();
     $userGroup->setAdmin(false);
     $userGroup->save();
     unset($userGroup);
     $userGroup = User::getByName($username);
     //test if admin is allowed all
     $permissionList = new User_Permission_Definition_List();
     $permissionList->load();
     $permissions = $permissionList->getDefinitions();
     $setPermissions = array();
     //gradually set all system permissions
     foreach ($permissions as $permission) {
         $userGroup->setPermission($permission->getKey());
         $setPermissions[] = $permission->getKey();
         $userGroup->save();
         unset($userGroup);
         $userGroup = User::getByName($username);
         foreach ($setPermissions as $p) {
             $this->assertTrue($userGroup->isAllowed($p));
         }
     }
     //remove system permissions
     $userGroup->setAllAclToFalse();
     foreach ($setPermissions as $p) {
         $this->assertFalse($userGroup->isAllowed($p));
     }
     //cannot list documents, assts, objects because no permissions by now
     $documentRoot = Document::getById(1);
     $documentRoot->getPermissionsForUser($userGroup);
     $this->assertFalse($documentRoot->isAllowed("list"));
     $objectRoot = Object_Abstract::getById(1);
     $objectRoot->getPermissionsForUser($userGroup);
     $this->assertFalse($objectRoot->isAllowed("list"));
     $assetRoot = Asset::getById(1);
     $assetRoot->getPermissionsForUser($userGroup);
     $this->assertFalse($assetRoot->isAllowed("list"));
     $objectFolder = new Object_Folder();
     $objectFolder->setParentId(1);
     $objectFolder->setUserOwner(1);
     $objectFolder->setUserModification(1);
     $objectFolder->setCreationDate(time());
     $objectFolder->setKey(uniqid() . rand(10, 99));
     $objectFolder->save();
     $documentFolder = Document_Folder::create(1, array("userOwner" => 1, "key" => uniqid() . rand(10, 99)));
     $assetFolder = Asset_Folder::create(1, array("filename" => uniqid() . "_data", "type" => "folder", "userOwner" => 1));
     $user = User::getByName("unitTestUser");
     $user->setAdmin(false);
     $user->save();
     $userGroup->setPermission("objects");
     $userGroup->setPermission("documents");
     $userGroup->setPermission("assets");
     $userGroup->save();
     //test permissions with user group and user
     $this->permissionTest($objectRoot, $objectFolder, $userGroup, $user, $user, "object");
     $this->permissionTest($assetRoot, $assetFolder, $userGroup, $user, $user, "asset");
     $this->permissionTest($documentRoot, $documentFolder, $userGroup, $user, $user, "document");
     //test permissions when there is no user group permissions
     $user = User::create(array("parentId" => 0, "username" => "unitTestUser2", "password" => md5("unitTestUser2"), "hasCredentials" => true, "active" => true));
     unset($user);
     $user = User::getByName("unitTestUser2");
     $user->setPermission("objects");
     $user->setPermission("documents");
     $user->setPermission("assets");
     $user->save();
     $this->assertTrue($user instanceof User and $user->getUsername() == "unitTestUser2");
     $this->permissionTest($objectRoot, $objectFolder, null, $user, $user, "object");
     $this->permissionTest($assetRoot, $assetFolder, null, $user, $user, "asset");
     $this->permissionTest($documentRoot, $documentFolder, null, $user, $user, "document");
     //test permissions when there is only user group permissions
     $user = User::create(array("parentId" => $userGroup->getId(), "username" => "unitTestUser3", "password" => md5("unitTestUser3"), "hasCredentials" => true, "active" => true));
     unset($user);
     $user = User::getByName("unitTestUser3");
     $this->assertTrue($user instanceof User and $user->getUsername() == "unitTestUser3");
     $this->permissionTest($objectRoot, $objectFolder, $userGroup, null, $user, "object");
     $this->permissionTest($assetRoot, $assetFolder, $userGroup, null, $user, "asset");
     $this->permissionTest($documentRoot, $documentFolder, $userGroup, null, $user, "document");
 }
开发者ID:ngocanh,项目名称:pimcore,代码行数:85,代码来源:UserTest.php

示例12: getFromWebserviceImport

 /**
  * Receives a Webservice_Data_Document_Element from webservice import and fill the current tag's data
  *
  * @abstract
  * @param  Webservice_Data_Document_Element $data
  * @return void
  */
 public function getFromWebserviceImport($wsElement)
 {
     $data = $wsElement->value;
     if ($data->id !== null) {
         $this->type = $data->type;
         $this->subtype = $data->subtype;
         $this->id = $data->id;
         if (is_numeric($this->id)) {
             if ($this->type == "asset") {
                 $this->element = Asset::getById($this->id);
                 if (!$this->element instanceof Asset) {
                     throw new Exception("cannot get values from web service import - referenced asset with id [ " . $this->id . " ] is unknown");
                 }
             } else {
                 if ($this->type == "document") {
                     $this->element = Document::getById($this->id);
                     if (!$this->element instanceof Document) {
                         throw new Exception("cannot get values from web service import - referenced document with id [ " . $this->id . " ] is unknown");
                     }
                 } else {
                     if ($this->type == "object") {
                         $this->element = Object_Abstract::getById($this->id);
                         if (!$this->element instanceof Object_Abstract) {
                             throw new Exception("cannot get values from web service import - referenced object with id [ " . $this->id . " ] is unknown");
                         }
                     } else {
                         throw new Exception("cannot get values from web service import - type is not valid");
                     }
                 }
             }
         } else {
             throw new Exception("cannot get values from web service import - id is not valid");
         }
     }
 }
开发者ID:nblackman,项目名称:pimcore,代码行数:42,代码来源:Href.php

示例13: getElementById

 /**
  * @static
  * @param  string $type
  * @param  int $id
  * @return Element_Interface
  */
 public static function getElementById($type, $id)
 {
     $element = null;
     if ($type == "asset") {
         $element = Asset::getById($id);
     } else {
         if ($type == "object") {
             $element = Object_Abstract::getById($id);
         } else {
             if ($type == "document") {
                 $element = Document::getById($id);
             }
         }
     }
     return $element;
 }
开发者ID:ngocanh,项目名称:pimcore,代码行数:22,代码来源:Service.php

示例14: updateAsset

 /**
  * @param Webservice_Data_Asset $wsDocument
  * @return bool
  */
 protected function updateAsset($wsDocument)
 {
     $asset = Asset::getById($wsDocument->id);
     $this->setModificationParams($asset, false);
     if ($asset instanceof Asset and $asset->getType() == strtolower($wsDocument->type)) {
         $wsDocument->reverseMap($asset);
         $asset->save();
         return true;
     } else {
         if ($asset instanceof Asset) {
             throw new Exception("Type mismatch for given asset with ID [" . $wsDocument->id . "] and existing asset with id [" . $asset->getId() . "]");
         } else {
             throw new Exception("Asset with given ID (" . $wsDocument->id . ") does not exist.");
         }
     }
 }
开发者ID:shanky0110,项目名称:pimcore-custom,代码行数:20,代码来源:Service.php

示例15: readGoogleResponse

 public function readGoogleResponse($googleResponse)
 {
     $this->setRaw($googleResponse);
     $this->setTotal(intval($googleResponse["searchInformation"]["totalResults"]));
     $items = array();
     if (array_key_exists("items", $googleResponse) && is_array($googleResponse["items"])) {
         foreach ($googleResponse["items"] as $item) {
             // check for relation to document or asset
             // first check for an image
             if (array_key_exists("pagemap", $item) && is_array($item["pagemap"])) {
                 if (array_key_exists("cse_image", $item["pagemap"]) && is_array($item["pagemap"]["cse_image"])) {
                     if ($item["pagemap"]["cse_image"][0]) {
                         // try to get the asset id
                         if (preg_match("/thumb_([0-9]+)__/", $item["pagemap"]["cse_image"][0]["src"], $matches)) {
                             $test = $matches;
                             if ($matches[1]) {
                                 if ($image = Asset::getById($matches[1])) {
                                     if ($image instanceof Asset_Image) {
                                         $item["image"] = $image;
                                     }
                                 }
                             }
                         }
                         if (!array_key_exists("image", $item)) {
                             $item["image"] = $item["pagemap"]["cse_image"][0]["src"];
                         }
                     }
                 }
             }
             // now a document
             $urlParts = parse_url($item["link"]);
             if ($document = Document::getByPath($urlParts["path"])) {
                 $item["document"] = $document;
             }
             $items[] = new Pimcore_Google_Cse_Item($item);
         }
     }
     $this->setResults($items);
 }
开发者ID:shanky0110,项目名称:pimcore-custom,代码行数:39,代码来源:Cse.php


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