/** * {@inheritdoc} */ public function buildRow(EntityInterface $entity) { /** @var \Drupal\node\NodeInterface $entity */ $mark = array('#theme' => 'mark', '#mark_type' => node_mark($entity->id(), $entity->getChangedTime())); $langcode = $entity->language()->getId(); $uri = $entity->urlInfo(); $options = $uri->getOptions(); $options += $langcode != LanguageInterface::LANGCODE_NOT_SPECIFIED && isset($languages[$langcode]) ? array('language' => $languages[$langcode]) : array(); $uri->setOptions($options); $row['title']['data'] = array('#type' => 'link', '#title' => $entity->label(), '#suffix' => ' ' . drupal_render($mark), '#url' => $uri); $row['type'] = node_get_type_label($entity); $row['author']['data'] = array('#theme' => 'username', '#account' => $entity->getOwner()); $row['status'] = $entity->isPublished() ? $this->t('published') : $this->t('not published'); $row['changed'] = $this->dateFormatter->format($entity->getChangedTime(), 'short'); $language_manager = \Drupal::languageManager(); if ($language_manager->isMultilingual()) { $row['language_name'] = $language_manager->getLanguageName($langcode); } $row['operations']['data'] = $this->buildOperations($entity); return $row + parent::buildRow($entity); }
/** * {@inheritdoc} */ public function buildRow(EntityInterface $entity) { /** @var \Drupal\profile\Entity\ProfileInterface $entity */ $mark = ['#theme' => 'mark', '#mark_type' => node_mark($entity->id(), $entity->getChangedTime())]; $langcode = $entity->language()->id; $uri = $entity->toUrl(); $options = $uri->getOptions(); $options += $langcode != LanguageInterface::LANGCODE_NOT_SPECIFIED && isset($languages[$langcode]) ? ['language' => $languages[$langcode]] : []; $uri->setOptions($options); $row['label']['data'] = ['#type' => 'link', '#title' => $entity->label(), '#suffix' => ' ' . $this->renderer->render($mark)] + $uri->toRenderArray(); $row['type'] = $entity->getType()->id(); $row['owner']['data'] = ['#theme' => 'username', '#account' => $entity->getOwner()]; $row['status'] = $entity->isActive() ? $this->t('active') : $this->t('not active'); $row['changed'] = $this->dateFormatter->format($entity->getChangedTime(), 'short'); $language_manager = \Drupal::languageManager(); if ($language_manager->isMultilingual()) { $row['language_name'] = $language_manager->getLanguageName($langcode); } $route_params = ['user' => $entity->getOwnerId(), 'type' => $entity->bundle(), 'profile' => $entity->id()]; $links['edit'] = ['title' => t('Edit'), 'route_name' => 'entity.profile.edit_form', 'route_parameters' => $route_params]; $links['delete'] = ['title' => t('Delete'), 'route_name' => 'entity.profile.delete_form', 'route_parameters' => $route_params]; $row[] = ['data' => ['#type' => 'operations', '#links' => $links]]; return $row + parent::buildRow($entity); }
/** * Helper function to get the renderable array of the entity's mark. * * @param $entity * The profile entity this field belongs to. * @return array * Renderable array of the entity mark. */ protected function getMark($entity) { return [ '#theme' => 'mark', '#mark_type' => node_mark($entity->id(), $entity->getChangedTime()), ]; }
function alim_comment_view($comment, $node, $links = array(), $visible = TRUE) { static $first_new = TRUE; $output = ''; $comment->new = node_mark($comment->nid, $comment->timestamp); if ($first_new && $comment->new != MARK_READ) { // Assign the anchor only for the first new comment. This avoids duplicate // id attributes on a page. $first_new = FALSE; $output .= "<a id=\"new\"></a>\n"; } $output .= "<a id=\"comment-$comment->cid\"></a>\n"; // Switch to folded/unfolded view of the comment if ($visible) { $comment->comment = check_markup($comment->comment, $comment->format, FALSE); // Comment API hook comment_invoke_comment($comment, 'view'); $output .= theme('comment', $comment, $node, $links); } else { $output .= theme('comment_folded', $comment); } return $output; }
/** * Overrides theme_node_recent_content(). */ function typebased_node_recent_content($variables) { // Make output for "Recent content" block consistent with other blocks $node = $variables['node']; $output = l($node->title, 'node/' . $node->nid); $output .= theme('mark', array('type' => node_mark($node->nid, $node->changed))); return $output; }
function gd_sync_admin_entity_export_select_form ( $form, &$form_state ) { $handlers = module_invoke_all('gd_sync_entities'); $exportHandlers = array(); foreach ( $handlers as $h ) { $exportHandlers[] = $h['export']; } // sort by operation weight usort($exportHandlers,function($a,$b){ if ($a['weight'] == $b['weight']) { return 0; } return ($a['weight'] < $b['weight']) ? -1 : 1; }); $nodes = array(); foreach ( $exportHandlers as $handler ) { $result = $handler['class']::getExportables($form_state['build_info']['args'][0]->nid); $nodes = array_merge($nodes,$result); } // Enable language column if translation module is enabled or if we have any // node with language. $multilanguage = (module_exists('translation') || db_query_range("SELECT 1 FROM {node} WHERE language <> :language", 0, 1, array(':language' => LANGUAGE_NONE))->fetchField()); // Build the sortable table header. $header = array( 'title' => array('data' => t('Title'), 'field' => 'n.title'), 'type' => array('data' => t('Type'), 'field' => 'n.type'), 'author' => t('Author'), 'status' => array('data' => t('Status'), 'field' => 'n.status'), 'changed' => array('data' => t('Updated'), 'field' => 'n.changed', 'sort' => 'desc') ); if ($multilanguage) { $header['language'] = array('data' => t('Language'), 'field' => 'n.language'); } $header['operations'] = array('data' => t('Operations')); // Prepare the list of nodes. $languages = language_list(); $destination = drupal_get_destination(); $options = array(); foreach ($nodes as $node) { $langcode = entity_language('node', $node); $l_options = $langcode != LANGUAGE_NONE && isset($languages[$langcode]) ? array('language' => $languages[$langcode]) : array(); $options[$node->nid] = array( 'title' => array( 'data' => array( '#type' => 'link', '#title' => $node->title, '#href' => 'node/' . $node->nid, '#options' => $l_options, '#suffix' => ' ' . theme('mark', array('type' => node_mark($node->nid, $node->changed))), ), ), 'type' => $node->type, 'author' => theme('username', array('account' => $node)), 'status' => $node->status ? t('published') : t('not published'), 'changed' => format_date($node->changed, 'short'), ); if ($multilanguage) { if ($langcode == LANGUAGE_NONE || isset($languages[$langcode])) { $options[$node->nid]['language'] = $langcode == LANGUAGE_NONE ? t('Language neutral') : t($languages[$langcode]->name); } else { $options[$node->nid]['language'] = t('Undefined language (@langcode)', array('@langcode' => $langcode)); } } // Build a list of all the accessible operations for the current node. $operations = array(); if (node_access('update', $node)) { $operations['edit'] = array( 'title' => t('edit'), 'href' => 'node/' . $node->nid . '/edit', 'query' => $destination, ); } if (node_access('delete', $node)) { $operations['delete'] = array( 'title' => t('delete'), 'href' => 'node/' . $node->nid . '/delete', 'query' => $destination, ); } $options[$node->nid]['operations'] = array(); if (count($operations) > 1) { // Render an unordered list of operations links. $options[$node->nid]['operations'] = array( 'data' => array( '#theme' => 'links__node_operations', '#links' => $operations, '#attributes' => array('class' => array('links', 'inline')), ), ); } elseif (!empty($operations)) { // Render the first and only operation as a link. $link = reset($operations); $options[$node->nid]['operations'] = array( 'data' => array( '#type' => 'link', '#title' => $link['title'], '#href' => $link['href'], '#options' => array('query' => $link['query']), ), ); } } $form['nodes'] = array( '#type' => 'tableselect', '#header' => $header, '#options' => $options, '#empty' => t('No content available.'), ); return $form; }
function md_hosoren_node_recent_content($vars) { // if ($vars['node']->type == 'testimonials') { $node = $vars['node']; $output = '<ul><li><h3 class="node-title">'; $output .= l($node->title, 'node/' . $node->nid); $output .= theme('mark', array('type' => node_mark($node->nid, $node->changed))); $output .= '</h3></li>'; $output .= '</ul>'; return $output; // } }