/** get action menu */ public function getItemInfo($params) { if ($params['item'] instanceof ItemDao) { $jobs = $this->Remoteprocessing_Job->getRelatedJob($params['item']); $items = array(); foreach ($jobs as $job) { $items = array_merge($items, $job->getItems()); } Zend_Loader::loadClass('UtilityComponent', BASE_PATH . '/core/controllers/components'); $component = new UtilityComponent(); $html = "<div class='sideElement'>\n <h1>" . $this->t('Related Items') . '</h1> <ul>'; $itemIds = array(); $i = 0; $nameArrayCurrent = explode('.', $params['item']->getName()); foreach ($items as $item) { $nameArrayItem = explode('.', $item->getName()); // remove doublons if (in_array($item->getKey(), $itemIds)) { continue; } $itemIds[] = $item->getKey(); // policy check if (!$this->Item->policyCheck($item, $this->userSession->Dao)) { continue; } // don't show current item if ($params['item']->getKey() == $item->getKey()) { continue; } // don't show related results if ($nameArrayCurrent[0] == $nameArrayItem[0] && end($nameArrayItem) == end($nameArrayCurrent)) { continue; } $html .= '<li>'; $html .= "<a element='" . htmlspecialchars($item->getKey(), ENT_QUOTES, 'UTF-8') . "' href='" . Zend_Registry::get('webroot') . '/item/' . htmlspecialchars($item->getKey(), ENT_QUOTES, 'UTF-8') . "'>" . $component->slicename(htmlspecialchars($item->getName(), ENT_QUOTES, 'UTF-8'), 25) . '</a>'; $html .= '</li>'; if ($i > 7) { $html .= '<li>...</li>'; break; } ++$i; } if ($i == 0) { return ''; } $html .= '</ul>'; $html .= '</div>'; $html .= "<div class='sideElementLast'>\n <h1>" . $this->t('Related Jobs') . '</h1> <ul>'; $i = 0; foreach ($jobs as $job) { $name = $job->getName(); if (empty($name)) { $name = $job->getCreationDate(); } $html .= '<li>'; $html .= "<a element='" . htmlspecialchars($job->getKey(), ENT_QUOTES, 'UTF-8') . "' href='" . Zend_Registry::get('webroot') . '/remoteprocessing/job/view/?jobId=' . htmlspecialchars($job->getKey(), ENT_QUOTES, 'UTF-8') . "'>" . htmlspecialchars($name, ENT_QUOTES, 'UTF-8') . '</a>'; $html .= '</li>'; if ($i > 3) { $html .= '<li>...</li>'; break; } ++$i; } $html .= '</ul>'; $html .= '</div>'; return $html; } return ''; }