public function preview($data) { if ($url = $data->{$this->value}) { $a = html::em('a', array('href' => $url), html::plain($url)); return html::em('value', array('html' => true), html::cdata($a)); } }
public function getHTML($data) { if (empty($data[$this->value])) { return null; } $output = "<table>"; $output .= "<tr class='header'>"; $output .= "<th class='check'> </th>"; $output .= "<th class='name'>" . t('Название') . "</th>"; $output .= "<th class='qty'>" . t('Количество') . "</th>"; $output .= "<th class='price'>" . t('Цена') . "</th>"; $output .= "<th class='sum'>" . t('Сумма') . "</th>"; $output .= "</tr>"; $total = 0; foreach ($data[$this->value] as $row) { $output .= "<tr class='product'>"; $output .= "<td class='check'>" . html::em('input', array('type' => 'checkbox', 'name' => $this->value . '_checked[]', 'value' => $row['id'])) . "</td>"; $output .= "<td class='name'>" . html::plain($row['name']) . "</td>"; $output .= "<td class='qty'>" . html::em('input', array('type' => 'text', 'name' => "{$this->value}[{$row['id']}][qty]", 'value' => $row['qty'])) . "</td>"; $output .= "<td class='price'>" . number_format($row['price'], 2) . "</td>"; $output .= "<td class='sum'>" . number_format($row['sum'], 2) . "</td>"; $output .= "</tr>"; $total += $row['sum']; } $output .= "<tr class='total'>"; $output .= "<td> </td>"; $output .= "<td class='total'><strong>" . t('Итого') . ":</td>"; $output .= "<td class='qty'> </td>"; $output .= "<td class='price'> </td>"; $output .= "<td class='sum'>" . number_format($total, 2) . "</td>"; $output .= "</tr>"; $output .= "</table>"; return $output; }
public static function attrs(array $attrs) { $result = ''; foreach ($attrs as $k => $v) { if ('#' == substr($k, 0, 1)) { continue; } if ('class' == $k) { if (!is_array($v)) { $v = preg_split('/\\s+/', $v, -1, PREG_SPLIT_NO_EMPTY); } $v = join(' ', array_unique($v)); } if (null === $v or '' === $v or is_array($v)) { continue; } if (!empty($v)) { if (true === $v) { $v = 'yes'; } else { $v = html::plain($v, false); } $result .= ' ' . self::attrname($k) . '=\'' . $v . '\''; } elseif ($k == 'value') { $result .= " value=''"; } } return $result; }
private function getProductLink(array $item) { $ctx = Context::last(); if (empty($item['id'])) { return htmlspecialchars($item['name']); } if (0 === strpos($ctx->query(), 'admin/')) { $url = '?q=admin/edit/' . $item['id'] . '&destination=admin'; } else { $url = '?q=nodeapi.rpc&action=locate&node=' . $item['id']; } return html::link($url, html::plain($item['name'])); }
/** * Добавляет информацию о разделах в предварительный просмотр. * @mcms_message ru.molinos.cms.hook.preview.xml */ public static function on_preview_tags(Node $node) { if (!$node->checkPermission(ACL::UPDATE)) { return; } if ($data = $node->getDB()->getResultsKV("id", "name", "SELECT `id`, `name` FROM `node` WHERE `deleted` = 0 AND `class` = 'tag' AND `id` IN (SELECT `tid` FROM `node__rel` WHERE `nid` = ?)", array($node->id))) { $result = array(); foreach ($data as $k => $v) { $result[] = html::em('a', array('href' => "admin/node/{$k}?destination=CURRENT"), html::plain($v)); } $result = html::em('value', html::cdata(implode(', ', $result))); return html::em('field', array('html' => true, 'title' => t('Находится в разделах'), 'editurl' => "admin/structure/taxonomy/setup?node={$node->id}&destination=" . urlencode(MCMS_REQUEST_URI)), $result); } }
private static function reindexNode(Node $node) { return; $html = ''; $schema = Schema::load($node->getDB(), $node->class); foreach ($schema['fields'] as $k => $v) { if (isset($node->{$k})) { $html .= '<strong>' . html::plain($v['label']) . '</strong>'; $html .= '<div class=\'data\'>' . $node->{$k} . '</div>'; } } $lang = empty($node->lang) ? 'en' : $node->lang; $html = "HTTP/1.0 200 OK\n" . "Content-Type: text/html; charset=utf-8\n" . "Content-Language: {$lang}\n\n" . "<html><head><title>{$node->name}</title></head>" . "<body><h1>{$node->name}</h1>{$html}</body></html>"; try { $node->getDB()->exec('DELETE FROM `node__searchindex` WHERE `nid` = :nid', array(':nid' => $node->id)); $node->getDB()->exec('INSERT INTO `node__searchindex` (`nid`, `url`, `html`) ' . 'VALUES (:nid, :url, :html)', array(':nid' => $node->id, ':url' => self::getNodeUrl($node), ':html' => $html)); } catch (TableNotFoundException $e) { } }
/** * Формирует таблицу для предварительного просмотра. */ public function getPreviewXML(Context $ctx) { $xml = parent::getPreviewXML($ctx); if (is_array($this->orderdetails)) { $params = array(); $names = $this->getDB()->getResultsKV("id", "name", "SELECT `id`, `name` FROM `node` WHERE `id` " . sql::in(array_keys($this->orderdetails), $params), $params); $table = ''; foreach ($this->orderdetails as $k => $v) { $name = isset($names[$k]) ? $names[$k] : '???'; $row = html::em('td', html::em('a', array('href' => "admin/node/{$k}?destination=CURRENT"), html::plain($name))); $row .= html::em('td', html::cdata('× ' . $v)); $table .= html::em('tr', $row); } if ($value = html::wrap('table', $table, array('class' => 'classic'))) { $xml .= html::em('field', array('title' => t('Содержимое заказа')), html::em('value', array('html' => true), html::cdata($value))); } } return $xml; }
public static function send($from, $to, $subject, $body, array $attachments = null, array $headers = null) { if (empty($to)) { Logger::trace("mail not sent: no recipients: {$subject}"); return; } $config = Context::last()->config; if (empty($from)) { if (!($from = $config->get('modules/mail/from'))) { $from = "Molinos.CMS <no-reply@" . MCMS_HOST_NAME . ">"; } } if (strstr($body, '<html>') === false) { $body = '<html><head><title>' . html::plain($subject) . '</title></head><body>' . $body . '</body></html>'; } if (!is_array($to)) { $to = preg_split('/, */', $to, -1, PREG_SPLIT_NO_EMPTY); } Logger::log(sprintf('to=%s, subject=%s', join(',', $to), $subject), 'mail'); $mail = new htmlMimeMail(); if ('smtp' == ($transport = ($server = $config->get('modules/mail/server')) ? 'smtp' : 'mail')) { $mail->setSMTPParams($server); } $mail->setFrom($from); $mail->setSubject($subject); $mail->setHtml(self::fixhtml($body)); $mail->setTextCharset('UTF-8'); $mail->setTextEncoding('base64'); $mail->setHTMLCharset('UTF-8'); $mail->setHTMLEncoding('UTF-8'); $mail->setHeadCharset('UTF-8'); foreach ((array) $attachments as $file) { $mail->addAttachment($file['data'], $file['name'], $file['type']); } foreach ((array) $headers as $k => $v) { if (!empty($v)) { $mail->setHeader($k, $v); } } return $mail->send($to, $transport); }
private static function getNodeBody(Node $node) { $body = '<dl>'; $schema = $node->getSchema(); foreach ($schema as $k => $v) { if (isset($node->{$k})) { if ($v instanceof PasswordControl) { $value = null; } elseif ($v instanceof EmailControl) { $value = html::em('a', array('href' => 'mailto:' . $node->{$k}), $node->{$k}); } elseif (!is_object($node->{$k})) { $value = $node->{$k}; } if (null !== $value) { $body .= '<dt>' . html::plain($v->label) . ':</dt>'; $body .= '<dd>' . $value . '</dd>'; } } } $body .= '</dl>'; $body .= '<p>' . html::link('admin/node/' . $node->id . '?destination=admin', t('Открыть в админке')) . '</p>'; return $body; }
public function preview($value) { if ($value = $value->{$this->value}) { if (is_object($value)) { $link = html::em('a', array('href' => 'admin/node/' . $value->id), html::plain($value->name)); return html::wrap('value', html::cdata($link), array('html' => true)); } } }
public function preview($value) { $file = $value->{$this->value}; if (!$file instanceof FileNode) { return; } if (0 === strpos($file->filetype, 'image/')) { $path = Context::last()->config->getPath('modules/files/storage'); if (isset($file->versions['thumbnail'])) { $attrs = array('width' => $file->versions['thumbnail']['width'], 'height' => $file->versions['thumbnail']['height'], 'src' => os::webpath($path, $file->versions['thumbnail']['filename'])); } else { $attrs = array('width' => $file->width, 'height' => $file->height, 'src' => os::webpath($path, $file->filepath)); } $attrs['alt'] = $file->filename; $img = html::em('img', $attrs); $html = html::em('a', array('href' => 'admin/node/' . $file->id . '?destination=' . urlencode(MCMS_REQUEST_URI)), $img); } else { $html = html::em('a', array('href' => "admin/node/{$file->id}?destination=CURRENT"), html::plain($file->filename)); // $html = $this->getEmbedCode($file); } if ($value->checkPermission(ACL::UPDATE)) { $html .= t('<p><a href="@url">Открепить файл</a></p>', array('@url' => "files/unlink.rpc?node={$value->id}&file={$file->id}&field={$this->value}&destination=" . urlencode(MCMS_REQUEST_URI))); } return html::em('value', array('html' => true), html::cdata($html)); }
public function preview($data) { $nodes = Node::find($filter = array('class' => $this->dictionary, 'deleted' => 0, $this->parents ? 'tagged' : 'tags' => $data->id)); $items = array(); foreach ($nodes as $node) { $items[$node->id] = $node->getName(); } asort($items); $result = array(); foreach ($items as $k => $v) { $result[] = html::em('a', array('href' => 'admin/node/' . $k), html::plain($v)); } $result = empty($result) ? null : implode(', ', $result) . '.'; if (empty($result)) { $result = t('нет'); } return html::em('value', array('html' => true), html::cdata($result)); }
/** * Возвращает информацию для предварительного просмотра. */ public function preview($node) { if ($user = $node->{$this->value}) { if (!is_object($user)) { $user = Node::load($user); } $html = html::em('a', array('href' => 'admin/node/' . $user->id), html::cdata($user->getName())); } elseif ($name = $node->{$this->value . ':name'}) { $html = html::plain($name); } else { $html = t('Авторство не установлено.'); } return html::wrap('value', html::cdata($html)); }
/** * Возвращает имя связанного объекта для предварительного просмотра. */ public function preview($value) { if (is_object($value = $value->{$this->value})) { $html = html::em('a', array('href' => 'admin/node/' . $value->id . '?destination=CURRENT'), html::plain($value->getName())); return html::em('value', array('html' => true), html::cdata($html)); } }
protected function getData() { if ('404' == $this->preset) { $data = array(); $limit = $this->ctx->get('limit', 10); $offset = $limit * $this->ctx->get('page') - $limit; foreach ($this->ctx->db->getResults("SELECT * FROM `node__fallback` ORDER BY `old` LIMIT {$offset}, {$limit}") as $row) { $row['_links'] = array('edit' => array('href' => '?q=admin/content/edit/404' . '&subid=' . urlencode($row['old']) . '&destination=CURRENT', 'title' => 'Изменить', 'icon' => 'edit'), 'delete' => array('href' => '?q=admin.rpc&action=404&mode=delete' . '&src=' . urlencode($row['old']) . '&destination=CURRENT', 'title' => 'Удалить', 'icon' => 'delete')); if (!empty($row['new'])) { $row['new'] = html::em('a', array('href' => '?q=' . urlencode($row['new'])), html::plain($row['new'])); } if (!empty($row['ref'])) { $url = new url($row['ref']); if (0 === strpos($name = $url->host, 'www.')) { $name = substr($name, 4); } $row['ref'] = html::link($row['ref'], $name); } $data[] = $row; } return $data; } $result = ''; $filter = $this->getNodeFilter(); if (null !== $this->limit) { $filter['#limit'] = $this->limit; $filter['#offset'] = ($this->page - 1) * $this->limit; } $result = Node::findXML($filter); return html::em('data', $result); }