Ejemplo n.º 1
0
 private function content_ajax_page_fc($fcid)
 {
     $fcitem = \Drupal\field_collection\Entity\FieldCollectionItem::load($fcid);
     $target = WG::entity_get_field_value($fcitem, 'field_target');
     preg_match('%^([^:]+)://([0-9]+)$%', $target, $m);
     $itemtype = $m[1];
     $id = $m[2];
     switch ($itemtype) {
         case 'public318':
             $identifier = $id;
             $text = WG::entity_get_field_formatted_text($fcitem, 'field_annotation');
             $stylename = 'large';
             $icon_uri = _expo_public318_get_icon_uri($identifier);
             $icontag = WG::render_styled_image($icon_uri, $stylename);
             $output = '<div class="sticky-fc-public318">' . '<div class="collicon">' . _expo_coll_url($identifier, $icontag) . '</div>' . '<div class="colltext">' . $text . '</div>' . '</div>';
             break;
         case 'storynode':
             $nid = $id;
             $story = node_load($nid);
             $v = entity_view($story, 'ajaxpage');
             $output = render($v);
             break;
         default:
             $tag = "<div class=\"sticky\" id=\"sticky_{$pos}\">" . $itemtype . $pos . "</div>";
     }
     $build = ['#markup' => $output];
     return $build;
 }
Ejemplo n.º 2
0
 private function _collitem_element_make(&$el, $i, $identifier, $fcid, $annotation = '', $stylename = 'expothumb')
 {
     $icon_info = _expo_public318_get_content_by_id($identifier, 'icon_info');
     $icon_uri = _expo_public318_get_icon_by_id($identifier, $icon_info);
     $icontag = WG::render_styled_image($icon_uri, $stylename);
     $el['icon'] = ['#markup' => '<div class="collitem-icon">' . $icontag . '</div>', '#weight' => -10];
     $el['annotationwrapper'] = ['#prefix' => '<div class="annotationwrapper">', '#suffix' => '</div>'];
     $el['annotationwrapper']['annotation'] = array('#type' => 'textarea', '#title' => t('我的註記'), '#attributes' => ['class' => ['theannotation']]);
     $el['target'] = ['#type' => 'hidden', '#value' => 'public318://' . $identifier, '#attributes' => ['class' => ['thetarget']]];
     $el['actions'] = ['#type' => 'container', '#prefix' => '<span class="collitem-edit-actions">', '#suffix' => '</span>', '#weight' => 50];
     $el['actions']['remove'] = array('#markup' => '<a href="#" class="collitem-remove btn btn-default" data-index="' . $i . '">移除</i></a>');
 }