/** * @param \Exception|\Throwable $e * * @return string */ protected static function renderForWeb($e) { $uri = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : 'n/a'; $errorString = '<div style="font-family: courier; font-size: 14px">'; $message = get_class($e) . ' - ' . $e->getMessage(); $errorString .= '<h1>' . APPLICATION . ' Exception</h1><div style="background: #dadada; padding: 5px"><font style="12"><b>' . $message . '</b></font></div><br/>'; $errorString .= 'in ' . $e->getFile() . ' (' . $e->getLine() . ')'; $errorString .= '<br/><br/>'; $errorString .= '<b>Url:</b> ' . Html::escape($uri); $errorString .= '<br/><br/>'; $errorString .= '<b>Trace:</b>'; $errorString .= '<br/>'; $errorString .= '<pre>' . $e->getTraceAsString() . '</pre>'; $errorString .= '</div>'; $version = new Version(); if ($version->hasData()) { $errorString .= '<hr>'; $errorString .= 'DeployInfo (Revision: ' . $version->getRevision() . ', Path: ' . $version->getPath() . ', Date: ' . $version->getDate() . ')'; } $errorString = '<pre>' . $errorString . '</pre>'; if ($e instanceof AbstractErrorRendererException) { $errorString .= '<br/><hr/><br/>' . (string) $e->getExtra(); } return $errorString; }
/** * @param \Spryker\Zed\Gui\Communication\Table\TableConfiguration $config * * @return array */ protected function prepareData(TableConfiguration $config) { $keys = $this->storageClient->getAllKeys(); sort($keys); $result = []; foreach ($keys as $i => $key) { $keys[$i] = str_replace('kv:', '', $key); } $values = $this->storageClient->getMulti($keys); $fixedValues = []; foreach ($values as $i => $value) { $i = str_replace('kv:', '', $i); $fixedValues[$i] = $value; } $values = $fixedValues; foreach ($values as $key => $value) { $url = Url::generate('/storage/maintenance/key', ['key' => $key]); $result[] = ['key' => '<a href="' . $url . '">' . Html::escape($key) . '</a>', 'value' => substr($value, 0, 200)]; } $this->setTotal(count($result)); return $result; }
/** * @dataProvider dataProvider * * @param string $string * @param string $expected * * @return void */ public function testEscape($string, $expected) { $this->assertSame($expected, Html::escape($string)); }
/** * @param string|\Spryker\Shared\Url\Url $url * @param string $title * @param array $defaultOptions * @param array $customOptions * * @return string */ protected function generateButton($url, $title, array $defaultOptions, array $customOptions = []) { $buttonOptions = $this->generateButtonOptions($defaultOptions, $customOptions); $class = $this->getButtonClass($defaultOptions, $customOptions); $parameters = $this->getButtonParameters($buttonOptions); if (is_string($url)) { $url = Html::escape($url); } else { $url = $url->buildEscaped(); } $html = '<a href="' . $url . '" class="btn btn-xs btn-outline ' . $class . '"' . $parameters . '>'; if (array_key_exists(self::BUTTON_ICON, $buttonOptions) === true && $buttonOptions[self::BUTTON_ICON] !== null) { $html .= '<i class="fa ' . $buttonOptions[self::BUTTON_ICON] . '"></i> '; } $html .= $title; $html .= '</a>'; return $html; }
/** * @param array $item * * @return string */ protected function formatCustomer(array $item) { $customer = $item[SpySalesOrderTableMap::COL_FIRST_NAME] . ' ' . $item[SpySalesOrderTableMap::COL_LAST_NAME]; $customer = Html::escape($customer); if ($item[SpySalesOrderTableMap::COL_FK_CUSTOMER]) { $url = Url::generate('/customer/view', ['id-customer' => $item[SpySalesOrderTableMap::COL_FK_CUSTOMER]]); $customer = '<a href="' . $url . '">' . $customer . '</a>'; } return $customer; }
/** * @param \Orm\Zed\Sales\Persistence\SpySalesOrderItem[] $orderItems * @param int $idProcess * @param int $idState * * @return string */ protected function formatElement($orderItems, $idProcess, $idState) { $grid = ['day' => 0, 'week' => 0, 'other' => 0]; foreach ($orderItems as $orderItem) { $created = $orderItem->getLastStateChange(); $lastDay = new \DateTime('-1 day'); if ($created > $lastDay) { ++$grid['day']; continue; } $lastDay = new \DateTime('-7 day'); if ($created > $lastDay) { ++$grid['week']; continue; } ++$grid['other']; } foreach ($grid as $key => $value) { if (!$value) { $grid[$key] = $value; continue; } $url = sprintf('/sales?id-order-item-process=%s&id-order-item-state=%s&filter=%s', $idProcess, $idState, $key); $grid[$key] = '<a href="' . Html::escape($url) . '">' . $value . '</a>'; } return implode(' | ', $grid); }
/** * @return string */ public function buildEscaped() { return Html::escape($this->build()); }