本文整理汇总了PHP中Pimcore\Model\Element\Service::getCustomViewById方法的典型用法代码示例。如果您正苦于以下问题:PHP Service::getCustomViewById方法的具体用法?PHP Service::getCustomViewById怎么用?PHP Service::getCustomViewById使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pimcore\Model\Element\Service
的用法示例。
在下文中一共展示了Service::getCustomViewById方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: treeGetChildsByIdAction
public function treeGetChildsByIdAction()
{
$document = Document::getById($this->getParam("node"));
$documents = [];
$cv = false;
if ($document->hasChilds()) {
$limit = intval($this->getParam("limit"));
if (!$this->getParam("limit")) {
$limit = 100000000;
}
$offset = intval($this->getParam("start"));
if ($this->getParam("view")) {
$cv = \Pimcore\Model\Element\Service::getCustomViewById($this->getParam("view"));
}
$list = new Document\Listing();
if ($this->getUser()->isAdmin()) {
$list->setCondition("parentId = ? ", $document->getId());
} else {
$userIds = $this->getUser()->getRoles();
$userIds[] = $this->getUser()->getId();
$list->setCondition("parentId = ? and\n (\n (select list from users_workspaces_document where userId in (" . implode(',', $userIds) . ") and LOCATE(CONCAT(path,`key`),cpath)=1 ORDER BY LENGTH(cpath) DESC LIMIT 1)=1\n or\n (select list from users_workspaces_document where userId in (" . implode(',', $userIds) . ") and LOCATE(cpath,CONCAT(path,`key`))=1 ORDER BY LENGTH(cpath) DESC LIMIT 1)=1\n )", $document->getId());
}
$list->setOrderKey(["index", "id"]);
$list->setOrder(["asc", "asc"]);
$list->setLimit($limit);
$list->setOffset($offset);
\Pimcore\Model\Element\Service::addTreeFilterJoins($cv, $list);
$childsList = $list->load();
foreach ($childsList as $childDocument) {
// only display document if listing is allowed for the current user
if ($childDocument->isAllowed("list")) {
$documents[] = $this->getTreeNodeConfig($childDocument);
}
}
}
if ($this->getParam("limit")) {
$this->_helper->json(["offset" => $offset, "limit" => $limit, "total" => $document->getChildAmount($this->getUser()), "nodes" => $documents]);
} else {
$this->_helper->json($documents);
}
$this->_helper->json(false);
}
示例2: treeGetChildsByIdAction
public function treeGetChildsByIdAction()
{
$object = Object\AbstractObject::getById($this->getParam("node"));
$objectTypes = null;
$objects = [];
$cv = false;
$offset = 0;
$total = 0;
if ($object instanceof Object\Concrete) {
$class = $object->getClass();
if ($class->getShowVariants()) {
$objectTypes = [Object\AbstractObject::OBJECT_TYPE_FOLDER, Object\AbstractObject::OBJECT_TYPE_OBJECT, Object\AbstractObject::OBJECT_TYPE_VARIANT];
}
}
if (!$objectTypes) {
$objectTypes = [Object\AbstractObject::OBJECT_TYPE_OBJECT, Object\AbstractObject::OBJECT_TYPE_FOLDER];
}
if ($object->hasChilds($objectTypes)) {
$limit = intval($this->getParam("limit"));
if (!$this->getParam("limit")) {
$limit = 100000000;
}
$offset = intval($this->getParam("start"));
$childsList = new Object\Listing();
$condition = "objects.o_parentId = '" . $object->getId() . "'";
// custom views start
if ($this->getParam("view")) {
$cv = \Pimcore\Model\Element\Service::getCustomViewById($this->getParam("view"));
if ($cv["classes"]) {
$cvConditions = [];
$cvClasses = explode(",", $cv["classes"]);
foreach ($cvClasses as $cvClass) {
$cvConditions[] = "objects.o_classId = '" . $cvClass . "'";
}
$cvConditions[] = "objects.o_type = 'folder'";
if (count($cvConditions) > 0) {
$condition .= " AND (" . implode(" OR ", $cvConditions) . ")";
}
}
}
// custom views end
if (!$this->getUser()->isAdmin()) {
$userIds = $this->getUser()->getRoles();
$userIds[] = $this->getUser()->getId();
$condition .= " AND (\n (select list from users_workspaces_object where userId in (" . implode(',', $userIds) . ") and LOCATE(CONCAT(o_path,o_key),cpath)=1 ORDER BY LENGTH(cpath) DESC LIMIT 1)=1\n OR\n (select list from users_workspaces_object where userId in (" . implode(',', $userIds) . ") and LOCATE(cpath,CONCAT(o_path,o_key))=1 ORDER BY LENGTH(cpath) DESC LIMIT 1)=1\n )";
}
$childsList->setCondition($condition);
$childsList->setLimit($limit);
$childsList->setOffset($offset);
$childsList->setOrderKey("FIELD(objects.o_type, 'folder') DESC, objects.o_key ASC", false);
$childsList->setObjectTypes($objectTypes);
Element\Service::addTreeFilterJoins($cv, $childsList);
$childs = $childsList->load();
foreach ($childs as $child) {
$tmpObject = $this->getTreeNodeConfig($child);
if ($child->isAllowed("list")) {
$objects[] = $tmpObject;
}
}
//pagination for custom view
$total = $cv ? $childsList->count() : $object->getChildAmount([Object\AbstractObject::OBJECT_TYPE_OBJECT, Object\AbstractObject::OBJECT_TYPE_FOLDER, Object\AbstractObject::OBJECT_TYPE_VARIANT], $this->getUser());
}
//Hook for modifying return value - e.g. for changing permissions based on object data
//data need to wrapped into a container in order to pass parameter to event listeners by reference so that they can change the values
$returnValueContainer = new Model\Tool\Admin\EventDataContainer($objects);
\Pimcore::getEventManager()->trigger("admin.object.treeGetChildsById.preSendData", $this, ["returnValueContainer" => $returnValueContainer]);
if ($this->getParam("limit")) {
$this->_helper->json(["offset" => $offset, "limit" => $limit, "total" => $total, "nodes" => $returnValueContainer->getData(), "fromPaging" => intval($this->getParam("fromPaging"))]);
} else {
$this->_helper->json($returnValueContainer->getData());
}
}
示例3: treeGetChildsByIdAction
public function treeGetChildsByIdAction()
{
$assets = [];
$cv = false;
$asset = Asset::getById($this->getParam("node"));
if ($asset->hasChilds()) {
$limit = intval($this->getParam("limit"));
if (!$this->getParam("limit")) {
$limit = 100000000;
}
$offset = intval($this->getParam("start"));
if ($this->getParam("view")) {
$cv = \Pimcore\Model\Element\Service::getCustomViewById($this->getParam("view"));
}
// get assets
$childsList = new Asset\Listing();
if ($this->getUser()->isAdmin()) {
$childsList->setCondition("parentId = ? ", $asset->getId());
} else {
$userIds = $this->getUser()->getRoles();
$userIds[] = $this->getUser()->getId();
$childsList->setCondition("parentId = ? and\n (\n (select list from users_workspaces_asset where userId in (" . implode(',', $userIds) . ") and LOCATE(CONCAT(path,filename),cpath)=1 ORDER BY LENGTH(cpath) DESC LIMIT 1)=1\n or\n (select list from users_workspaces_asset where userId in (" . implode(',', $userIds) . ") and LOCATE(cpath,CONCAT(path,filename))=1 ORDER BY LENGTH(cpath) DESC LIMIT 1)=1\n )", $asset->getId());
}
$childsList->setLimit($limit);
$childsList->setOffset($offset);
$childsList->setOrderKey("FIELD(assets.type, 'folder') DESC, assets.filename ASC", false);
\Pimcore\Model\Element\Service::addTreeFilterJoins($cv, $childsList);
$childs = $childsList->load();
foreach ($childs as $childAsset) {
if ($childAsset->isAllowed("list")) {
$assets[] = $this->getTreeNodeConfig($childAsset);
}
}
}
if ($this->getParam("limit")) {
$this->_helper->json(["offset" => $offset, "limit" => $limit, "total" => $asset->getChildAmount($this->getUser()), "nodes" => $assets]);
} else {
$this->_helper->json($assets);
}
$this->_helper->json(false);
}