'; foreach ($content as $type) { $output .= '
' . t('You have not created any content types yet. Go to the content type creation page to add a new content type.', array('@create-content' => url('admin/structure/types/add'))) . '
'; } return $output; } /** * Generates a node preview. * * @param \Drupal\Core\Entity\EntityInterface $node * The node to preview. * * @return * An HTML-formatted string of a node preview. * * @see node_form_build_preview() */ function node_preview(NodeInterface $node, array &$form_state) { if ($node->access('create') || $node->access('update')) { $node->changed = REQUEST_TIME; // Display a preview of the node. if (!form_get_errors($form_state)) { $node->in_preview = TRUE; $node_preview = array( '#theme' => 'node_preview', '#node' => $node, ); $output = drupal_render($node_preview); unset($node->in_preview); } return $output; } } /** * Returns HTML for a node preview for display during node creation and editing. * * @param $variables * An associative array containing: * - node: The node entity which is being previewed. * * @see NodeFormController::preview() * @see node_preview() * * @ingroup themeable */ function theme_node_preview($variables) { $node = $variables['node']; $output = ''; $elements = node_view($node, 'teaser'); $elements['#attached']['library'][] = array('node', 'drupal.node.preview'); $trimmed = drupal_render($elements); $elements = node_view($node, 'full'); $full = drupal_render($elements); // Do we need to preview trimmed version of post as well as full version? if ($trimmed != $full) { drupal_set_message(t('The trimmed version of your post shows what your post looks like when promoted to the main page or when exported for syndication. You can insert the delimiter "<!--break-->" (without the quotes) to fine-tune where your post gets split.')); $output .= '' . filter_xss($revision->log) . '
' : ''), 'class' => array('revision-current')); $row[] = array('data' => drupal_placeholder(t('current revision')), 'class' => array('revision-current')); } else { $username = array( '#theme' => 'username', '#account' => user_load($revision->uid), ); $row[] = t('!date by !username', array('!date' => l(format_date($revision->revision_timestamp, 'short'), "node/" . $node->id() . "/revisions/" . $revision->vid . "/view"), '!username' => drupal_render($username))) . (($revision->log != '') ? '' . filter_xss($revision->log) . '
' : ''); if ($revert_permission) { $links['revert'] = array( 'title' => t('Revert'), 'href' => "node/" . $node->id() . "/revisions/" . $revision->vid . "/revert", ); } if ($delete_permission) { $links['delete'] = array( 'title' => t('Delete'), 'href' => "node/" . $node->id() . "/revisions/" . $revision->vid . "/delete", ); } $row[] = array( 'data' => array( '#type' => 'operations', '#links' => $links, ), ); } $rows[] = $row; } $build['node_revisions_table'] = array( '#theme' => 'table', '#rows' => $rows, '#header' => $header, '#attached' => array ( 'css' => array(drupal_get_path('module', 'node') . '/css/node.admin.css'), ), ); return $build; }