public function seopanelTreeAction() { $document = Document::getById($this->_getParam("node")); $documents = array(); if ($document->hasChilds()) { $list = new Document_List(); $list->setCondition("parentId = ?", $document->getId()); $list->setOrderKey("index"); $list->setOrder("asc"); $childsList = $list->load(); foreach ($childsList as $childDocument) { // only display document if listing is allowed for the current user if ($childDocument->isAllowed("list")) { $list = new Document_List(); $list->setCondition("path LIKE ? and type = ?", array($childDocument->getFullPath() . "/%", "page")); if ($childDocument instanceof Document_Page || $list->getTotalCount() > 0) { $nodeConfig = $this->getTreeNodeConfig($childDocument); if (method_exists($childDocument, "getTitle") && method_exists($childDocument, "getDescription")) { $nodeConfig["title"] = $childDocument->getTitle(); $nodeConfig["description"] = $childDocument->getDescription(); $nodeConfig["title_length"] = strlen($childDocument->getTitle()); $nodeConfig["description_length"] = strlen($childDocument->getDescription()); // anaylze content $nodeConfig["links"] = 0; $nodeConfig["externallinks"] = 0; $nodeConfig["h1"] = 0; $nodeConfig["h1_text"] = ""; $nodeConfig["hx"] = 0; $nodeConfig["imgwithalt"] = 0; $nodeConfig["imgwithoutalt"] = 0; try { // cannot use the rendering service from Document_Service::render() because of singleton's ... // $content = Document_Service::render($childDocument, array("pimcore_admin" => true, "pimcore_preview" => true), true); $request = $this->getRequest(); $contentUrl = $request->getScheme() . "://" . $request->getHttpHost() . $childDocument->getFullPath(); $content = Pimcore_Tool::getHttpData($contentUrl, array("pimcore_preview" => true, "pimcore_admin" => true, "_dc" => time())); if ($content) { $html = str_get_html($content); if ($html) { $nodeConfig["links"] = count($html->find("a")); $nodeConfig["externallinks"] = count($html->find("a[href^=http]")); $nodeConfig["h1"] = count($html->find("h1")); $h1 = $html->find("h1", 0); if ($h1) { $nodeConfig["h1_text"] = strip_tags($h1->innertext); } $nodeConfig["hx"] = count($html->find("h2,h2,h4,h5")); $images = $html->find("img"); if ($images) { foreach ($images as $image) { $alt = $image->alt; if (empty($alt)) { $nodeConfig["imgwithoutalt"]++; } else { $nodeConfig["imgwithalt"]++; } } } } } } catch (Exception $e) { Logger::debug($e); } if (strlen($childDocument->getTitle()) > 80 || strlen($childDocument->getTitle()) < 5 || strlen($childDocument->getDescription()) > 180 || strlen($childDocument->getDescription()) < 20 || $nodeConfig["h1"] != 1 || $nodeConfig["hx"] < 1) { $nodeConfig["cls"] = "pimcore_document_seo_warning"; } } $documents[] = $nodeConfig; } } } } $this->_helper->json($documents); }
public function deleteInfoAction() { $hasDependency = false; try { $document = Document::getById($this->_getParam("id")); $hasDependency = $document->getDependencies()->isRequired(); } catch (Exception $e) { Logger::err("failed to access document with id: " . $this->_getParam("id")); } $deleteJobs = array(); // check for childs if ($document instanceof Document) { $deleteJobs[] = array(array("url" => "/admin/recyclebin/add", "params" => array("type" => "document", "id" => $document->getId()))); $hasChilds = $document->hasChilds(); if (!$hasDependency) { $hasDependency = $hasChilds; } $childs = 0; if ($hasChilds) { // get amount of childs $list = new Document_List(); $list->setCondition("path LIKE '" . $document->getFullPath() . "/%'"); $childs = $list->getTotalCount(); if ($childs > 0) { $deleteObjectsPerRequest = 5; for ($i = 0; $i < ceil($childs / $deleteObjectsPerRequest); $i++) { $deleteJobs[] = array(array("url" => "/admin/document/delete", "params" => array("step" => $i, "amount" => $deleteObjectsPerRequest, "type" => "childs", "id" => $document->getId()))); } } } // the object itself is the last one $deleteJobs[] = array(array("url" => "/admin/document/delete", "params" => array("id" => $document->getId()))); } $this->_helper->json(array("hasDependencies" => $hasDependency, "childs" => $childs, "deletejobs" => $deleteJobs)); }