private function savePosts() { $counter = 0; foreach ($this->dbhWp->query('SELECT p.* FROM wp_posts p WHERE p.post_type = \'post\' ORDER BY p.post_date', PDO::FETCH_ASSOC) as $post) { echo $counter++ . PHP_EOL; $node = new stdClass(); $node->type = 'blog'; $node->uid = 3; // hosszu.kalman $node->created = strtotime($post['post_date']); $node->status = $post['post_status'] == 'publish'; $node->title = $post['post_title']; $node->body = $post['post_content']; $node->format = 4; // New importer input filter $node->comment = 2; $this->addGeSHiFilter($node); $node->teaser = node_teaser($node->body, 4); $this->addTerms($node, $post['ID']); $this->addMetaKeywords($node, $post['ID']); node_save($node); $this->dbhImport->query('INSERT INTO posts VALUES (' . $post['ID'] . ', ' . $node->nid . ')'); $redirect = array('source' => $post['post_name'], 'redirect' => 'node/' . $node->nid); $this->saveRedirect($redirect); if ($post['pinged']) { $redirect = array('source' => $post['pinged'], 'redirect' => 'node/' . $node->nid); $this->saveRedirect($redirect); } } }
/** * Campsite teaser modifier plugin * * Type: modifier * Name: teaser * Purpose: build an teaser our of input * * @param string * $p_input the string or object * @param string * $p_format the date format wanted * * @return * string the formatted date * null in case a non-valid format was passed */ function smarty_modifier_teaser($p_input, $p_length = null) { if (empty($length)) { $length = is_null(SystemPref::Get('teaser_length')) ? 100 : SystemPref::Get('teaser_length'); } $pattern = '/<!-- *break *-->/i'; if (is_object($p_input) && method_exists($p_input, '__toString')) { $input = $p_input->__toString(); } else { $input = (string) $p_input; } $output = node_teaser($input, null, $length); return $output; }
?> <?php if (preg_match('/.*<img .*/', $content)) { ?> <?php print node_teaser($content, NULL, 240); ?> <?php } else { ?> <img src="<?php print base_path() . path_to_theme(); ?> /images/dummy-100x100.png" /> <?php print node_teaser($node->content['body']['#value'], NULL, 240); ?> <?php } } else { ?> <?php print $content; } ?> </div> <div class="clear-block"><?php print $admin_links; ?> </div>
<ul> <li class="entry clearfix"> <div class="entry_summary clearfix"> <div class="float-left"> <h2><?php print $node->title; ?> </h2> <div class="source_and_date"><?php print $source_link; ?> | <?php print $time_ago; ?> </div><!--/source and date--></div><!--/float left--> </div><!--/entry summary--> <p><?php print node_teaser(strip_tags($node->body, '<a><b>')); ?> </p> </li><!--/entry--> </ul> </div> </div>
// Parse arguments $team_id = isset($argv[1]) ? $argv[1] : null; $team_type_tid = isset($argv[2]) ? $argv[2] : null; $input_format = isset($argv[3]) ? $argv[3] : null; $count = 0; // Get teams from BOINC db_set_active('boinc'); $boincteam = db_fetch_object(db_query('SELECT * FROM team WHERE id=%d', array($team_id))); $boincteam_members = db_query('SELECT id FROM user WHERE teamid=%d', array($team_id)); $boincteam_admin = (int) db_result(db_query('SELECT userid FROM team_admin WHERE teamid=%d', array($team_id))); db_set_active('default'); $team_exists = db_query('SELECT team_id FROM {boincteam} WHERE team_id = %d', $boincteam->id); // FIXME: $team_exists==FALSE should be handled as an error and return an error code! if ($team_exists != FALSE && db_fetch_object($team_exists) == FALSE) { $boincteam->description = _boincimport_text_sanitize($boincteam->description); $teaser = node_teaser($boincteam->description); // Construct the team as an organic group node $node = array('type' => 'team', 'title' => $boincteam->name, 'body' => $boincteam->description, 'teaser' => $teaser, 'uid' => boincuser_lookup_uid($boincteam->userid), 'path' => null, 'status' => 1, 'promote' => 0, 'created' => $boincteam->create_time, 'comment' => 0, 'moderate' => 0, 'sticky' => 0, 'format' => $input_format); // Use pathauto function, if available, to clean up the path if (module_exists('pathauto')) { module_load_include('inc', 'pathauto', 'pathauto'); $node['path'] = pathauto_cleanstring($boincteam->name); } else { echo 'Pathauto module is required!'; exit; } $node = (object) $node; // node_save requires an object form $node->taxonomy[] = taxonomy_get_term($team_type_tid); // Save the team node node_save($node);
<?php } ?> <div class="content"> <?php print $content; ?> </div> <?php if (!$page) { ?> <?php $full_node = node_load($node->nid); if ($full_node) { $body = str_replace('<!--break-->', "", $full_node->body); $teaser_more = node_teaser($body, NULL, 1900); if (strlen(strip_tags($teaser_more)) > strlen(strip_tags($content))) { $class_extra = strlen($teaser_more) == strlen($body) ? " complete" : ""; print '<div class="content-more' . $class_extra . '" style="display:none;">' . $teaser_more . '</div>'; } } ?> <div class="submitted-by">submitted by <strong><?php print $name; ?> </strong> <?php if ($submitted) { ?> on <strong><?php print $submitted; ?>
function budgets_supplier_view($node, $teaser = FALSE, $page = FALSE) { global $user; if (!isset($node->nid)) { $node = node_load(array('nid' => $node->id)); } if ($node->sticky) { $node->sticky = 0; } guifi_log(GUIFILOG_TRACE, 'function budgets_supplier_view(teaser)', $teaser); node_prepare($node, $teaser); if ($teaser) { $body = node_teaser($node->body, TRUE, $node->rated == true ? 600 : 300); $body = strip_tags($body, '<br> '); if ($node->rated) { if (!empty($node->logo)) { $img = '<img class="supplier-logo" src="/' . $node->logo . '" width="150">'; } if (!empty($node->web_url)) { $img = '<a href="' . $node->web_url . '">' . $img . '</a>'; } $body = "<div class=\"supplier-rated\">" . $img . $body . "</div>"; } $node->content['body']['#value'] = $body; } if ($node->rated) { $node->content['body']['#value'] = '<p class="rating" >' . $node->official_rating . '</p>' . $node->content['body']['#value']; } $node->content['header'] = array('#value' => theme_budgets_supplier_header($node, $teaser), '#weight' => -10); if ($page) { drupal_set_breadcrumb(guifi_zone_ariadna($node->zone_id, 'node/%d/view/suppliers')); $body = $node->content['body']['#value']; if (!empty($node->logo)) { $img = '<img class="supplier-logo" src="/' . $node->logo . '" width="200">'; } if (!empty($node->web_url)) { $img = '<a href="' . $node->web_url . '">' . $img . '</a>'; } // Quotes //to-do // Accounting guifi_log(GUIFILOG_TRACE, 'function budgets_supplier_view(accounting)', $node->accounting_urls); if (count($node->accounting_urls) > 1 and !empty($node->accounting_urls[0]['url'])) { // There are accounting urls $rows = array(); foreach ($node->accounting_urls as $value) { guifi_log(GUIFILOG_TRACE, 'function budgets_supplier_view(value)', $value); if (!empty($value['url'])) { $rows[] = array(array('data' => $value['node_id']), array('data' => '<a href="' . $value['url'] . '">' . $value['url'] . '</a>'), array('data' => $value['comment'])); } } $headers = array(array('data' => t('Node')), array('data' => t('Url')), array('data' => t('Comment'))); $body .= '<br><hr><h2>' . t('Accounting') . '</h2>' . theme('table', $headers, $rows); } $node->content['body']['#value'] = $img . ' ' . $body; } $node->content['footer'] = array('#value' => theme_budgets_supplier_footer($node, $teaser), '#weight' => 10); return $node; // format antic $node = node_prepare($node, $teaser); $output = ''; $qquotes = pager_query(sprintf('SELECT id ' . 'FROM {supplier_quote} ' . 'WHERE supplier_id = %d ' . 'ORDER BY title, partno, id', $node->nid), variable_get('default_nodes_main', 10)); $output .= '<h3>' . t('Contact information:') . '<h3 />' . t('Phone') . ':' . $node->phone . t(' Email: ') . $user->uid ? l($node->notification) : l('login to view email contact', 'user/login'); if (!$teaser) { $output .= '<br<br><hr><h2>' . t('Quotes') . '</h2>'; while ($quote = db_fetch_object($qquotes)) { $output .= node_view(node_load(array('nid' => $quote->id)), TRUE, FALSE); } empty($quote) ? $output .= t('No quotes available') : NULL; $node->content['quotes'] = array('#value' => $output . theme('pager', NULL, variable_get('default_nodes_main', 10)), '#weight' => 1); } return $node; }
<h1><?php print l($node->title, $orig_url, array('attributes' => array('target' => '_blank'))); ?> </h1> <div class="source_and_time"><?php print $source_link; ?> | <?php print $time_ago; ?> </div><!--/source and date--> <div id="node-content"><?php print node_teaser(strip_tags($node->content['body']['#value'], '<a><b>')); ?> </div> <?php if (arg(0) == 'node' && is_numeric(arg(1))) { ?> <div id="visible-comments"> <h2>Comments:</h2> <?php print comment_render($node); ?> </div> <?php print comment_form_box(array('nid' => $node->nid), t('Post new comment')); ?>
/** * Prepare an individual item for viewing in a browser. * * @param $field * The field the action is being performed on. * @param $item * An array, keyed by column, of the data stored for this item in this field. * @param $formatter * The name of the formatter being used to display the field. * @param $node * The node object, for context. Will be NULL in some cases. * Warning : when displaying field retrieved by Views, $node will not * be a "full-fledged" node object, but an object containg the data returned * by the Views query (at least nid, vid, changed) * @return * An HTML string containing the formatted item. * * In a multiple-value field scenario, this function will be called once per * value currently stored in the field. This function is also used as the handler * for viewing a field in a views.module tabular listing. * * It is important that this function at the minimum perform security * transformations such as running check_plain() or check_markup(). */ function hook_field_formatter($field, $item, $formatter, $node) { if (!isset($item['value'])) { return ''; } if ($field['text_processing']) { $text = check_markup($item['value'], $item['format'], is_null($node) || isset($node->in_preview)); } else { $text = check_plain($item['value']); } switch ($formatter) { case 'plain': return strip_tags($text); case 'trimmed': return node_teaser($text, $field['text_processing'] ? $item['format'] : NULL); default: return $text; } }