/**
 * Since Lucene isn't strong at returning an entire resultset, this hook is
 * required by some realms that wish to display facets when either no search has
 * been executed or a search returns empty results.
 *
 * @param $facets
 *   An array containing facet definitions returned by hook_luceneapi_facet()
 *   implementations.
 * @param $realm
 *   A string containing the machine readable realm name the facets are being
 *   rendered in.
 * @param $module
 *   A string containing the search module that is collecting the available
 *   facets.  If Search Lucene Content is collecting facets, then $module will
 *   be "luceneapi_node".
 * @return
 *   An array of facets.
 */
function hook_luceneapi_facet_empty($facets, $realm, $module)
{
    // The following example is a simplified version of code in the
    // luceneapi_node_luceneapi_facet_empty() function.  It allows the "Content
    // type" facet to be displayed in the "block" realm even if no search has been
    // executed.
    // The example is only valid for "node" content in the "block" realm.
    $type = luceneapi_index_type_get($module);
    if ('node' != $type || 'block' != $realm) {
        return;
    }
    // Initializes return array.
    $items = array();
    // Query that gets content types and counts from the database.
    $sql = 'SELECT n.type, COUNT(*) AS num' . ' FROM {node} n' . ' LEFT JOIN {node_type} t ON n.type = t.type' . ' WHERE n.status = 1' . ' GROUP BY n.type' . ' ORDER BY num DESC';
    // Initializes the array containing facet information.  The array mimics how
    // the luceneapi_facet_block_realm_render() function renders facets.
    $items['type'] = array('title' => $facets['type']['title'], 'field' => $facets['type']['field'], 'element' => $facets['type']['element'], 'selected' => array(), 'count' => array(), 'items' => array());
    // Executes query and adds facet items to the $items array.
    if ($result = db_query(db_rewrite_sql($sql))) {
        while ($row = db_fetch_object($result)) {
            $items['type']['items'][$row->type] = array('function' => 'luceneapi_facet_link', 'text' => $row->type, 'path' => sprintf('search/%s/%s:%s', $module, $facets['type']['element'], $row->type), 'options' => array(), 'count' => $row->num);
        }
    }
    return $items;
}
Exemple #2
0
function uiphone_get_menu_icon($path)
{
    // get menu icon for path
    $result = db_query(db_rewrite_sql("SELECT nid FROM {node} WHERE title='%s'"), $path);
    if ($node = db_fetch_object($result)) {
        $node = node_load($node->nid);
        $img = '<img src="' . url($node->field_icon[0]['filepath']) . '" width="32" height="32" alt="' . $node->title . '"/>';
        // $img = l($img, $path, array('html' => TRUE));
        return $img;
    } else {
        return '';
    }
}
/**
 * Helper function to query the values for the module functions.
 */
function covidien_sw_cron_query($i = 0) {
  switch ($i) {
    case 0:
      $qry = db_rewrite_sql("select * from {node} where nid=%d");
      break;
    case 1:
      $qry = "UPDATE content_type_software set field_sw_integrity_check_value='%s' where `vid`='%d' and `nid`='%d'";
      break;
    case 2:
      $qry = 'UPDATE files set filepath="%s",filesize="%s" WHERE fid="%d"';
      break;
    default:
      $qry = '';
  }
  return $qry;
}
Exemple #4
0
/**
 * Find node title matches.
 * 
 * Some code from CCK's nodereference.module
 */
function _notifications_node_references($string, $match = 'contains', $types = array(), $limit = 10)
{
    $match_operators = array('contains' => "LIKE '%%%s%%'", 'equals' => "= '%s'", 'starts_with' => "LIKE '%s%%'");
    if ($types) {
        $where[] = 'n.type IN (' . db_placeholders($types, 'char') . ') ';
        $args = $types;
    }
    $where[] = 'n.title ' . (isset($match_operators[$match]) ? $match_operators[$match] : $match_operators['contains']);
    $args[] = $string;
    $sql = db_rewrite_sql('SELECT n.nid, n.title, n.type FROM {node} n WHERE ' . implode(' AND ', $where) . ' ORDER BY n.title, n.type');
    $result = db_query_range($sql, $args, 0, $limit);
    $references = array();
    while ($node = db_fetch_object($result)) {
        $references[$node->nid] = array('title' => $node->title, 'rendered' => check_plain($node->title));
    }
    return $references;
}
// Figure out the filename for the release history we want to serve, and make
// sure that file actually exists in our directory.
$full_path = FILE_ROOT . '/' . $path;
if (!is_file($full_path)) {
    drupal_not_found();
    exit(1);
}
// Find the release this file is associated with. Due to the db_rewrite_sql(),
// this will enforce node access checks for us, so a user without permission
// to view the given file will be denied. Since we're testing if there's a
// node with a file that uses the given path as its filepath, this protects us
// against prying eyes that might try to access "/../../../etc/passwd" or
// something.  Even if they managed to find a file that actually exists that
// way, it's not going to match a valid release node.  So they're going to get
// a 403, not the file they're trying to steal.
$nid = db_result(db_query(db_rewrite_sql("SELECT n.nid FROM {node} n INNER JOIN {project_release_file} prf ON n.nid = prf.nid INNER JOIN {files} f ON prf.fid = f.fid WHERE n.status = 1 AND f.filepath = '%s'"), $path));
if (empty($nid)) {
    drupal_access_denied();
    exit(1);
}
// If we found the release, serve up the file.
$stat = stat($full_path);
$file_size = $stat[7];
$file_mtime = $stat[9];
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $file_mtime) . ' GMT');
header('Content-Type: application/octet-stream');
header('Content-Description: File Transfer');
header('Content-Disposition: attachment; filename="' . basename($path) . '"');
header('Content-Length: ' . $file_size);
Exemple #6
0
function ciclo20v2_taxonomy_term_page($tids, $result)
{
    $str_tids = arg(2);
    $terms = taxonomy_terms_parse_string($str_tids);
    $title_result = db_query(db_rewrite_sql('SELECT t.tid, t.name FROM {term_data} t WHERE t.tid IN (' . db_placeholders($terms['tids']) . ')', 't', 'tid'), $terms['tids']);
    $title_tids = array();
    // we rebuild the $tids-array so it only contains terms the user has access to.
    $names = array();
    while ($term = db_fetch_object($title_result)) {
        $title_tids[] = $term->tid;
        $names[] = $term->name;
    }
    $last_name = array_pop($names);
    if (count($names) == 0) {
        $title = t("Pages containing '@tag'", array('@tag' => $last_name));
    } elseif ($terms['operator'] == "or") {
        $title = t("Pages containing '@tags or @last_tag'", array('@tags' => implode(", ", $names), '@last_tag' => $last_name));
    } else {
        $title = t("Pages containing '@tags and @last_tag'", array('@tags' => implode(", ", $names), '@last_tag' => $last_name));
    }
    drupal_set_title($title);
    drupal_add_css(drupal_get_path('module', 'taxonomy') . '/taxonomy.css');
    $output = '';
    // Only display the description if we have a single term, to avoid clutter and confusion.
    if (count($tids) == 1) {
        $term = taxonomy_get_term($tids[0]);
        $description = $term->description;
        // Check that a description is set.
        if (!empty($description)) {
            $output .= '<div class="taxonomy-term-description">';
            $output .= filter_xss_admin($description);
            $output .= '</div>';
        }
    }
    $output .= commons_connect_taxonomy_render_nodes($result);
    return $output;
}
// $Id: convert_name2uid.php,v 1.1.2.2 2009/09/29 09:40:45 hutch Exp $
/**
 * @file
 * Contributed by RusRabbit, see http://drupal.org/comment/reply/568168
 *
 * Here's the code I used for nodes, teasers and comments conversion. The
 * following example is for nodes; for teasers and comments we have to put
 * correct table name (comments for comments) and columns names
 * respectively (tid, cid instead of nid and teaser, comment instead of
 * body). I put the code into the block on a certain page while site is
 * offline, just for ease of use. The code is written to handle non-latin
 * folder names, too (I had some folders named in Russian).
 */
$sql = "SELECT name, uid FROM {users}";
$result = db_query(db_rewrite_sql($sql));
while ($userinfo = db_fetch_object($result)) {
    $utfname = $userinfo->name;
    $utfname = rawurlencode($utfname);
    $username[$utfname] = $userinfo->uid;
}
$nodez = db_query('SELECT nid, body FROM {node_revisions}');
$i = 0;
while ($mynode = db_fetch_object($nodez)) {
    $editnode = $mynode->comment;
    $currentnid = $mynode->nid;
    $search = '/(imagepicker\\/)([a-z]{1,}\\/)([a-zA-ZÐ-ï°-Ï0-9_.-\\s\\+\\%]{1,})/e';
    $replace = '"$1".$username["$3"]';
    $result = preg_replace($search, $replace, $editnode);
    db_query("UPDATE {node_revisions} SET body = '{$result}' WHERE nid = {$currentnid}");
}
<div class="non_owned_content">
  <h1>Recent Guides By Other Users:</h1>
<?php 
    $output = '';
    $uid = arg(1);
    $nlimit = 6;
    $result = db_query_range(db_rewrite_sql("SELECT n.created, n.title, n.nid, n.changed FROM {node} n WHERE n.uid != %d AND n.type = 'panels_sub_guide' ORDER BY n.changed DESC"), $uid, 0, $nlimit);
    $output .= '<div class="item-list"><ul>' . "\n";
    $output .= node_title_list($result);
    $output .= '</ul></div>';
    print $output;
    ?>
</div>

<div class="db_list_content">
   <h1>My Database Lists:</h1>
 <?php 
    $output = '';
    $uid = arg(1);
    $nlimit = 6;
    $result = db_query_range(db_rewrite_sql("SELECT n.created, n.title, n.nid, n.changed FROM {node} n WHERE n.uid = %d AND n.type = 'database_list' ORDER BY n.changed DESC"), $uid, 0, $nlimit);
    $output .= '<div class="item-list"><ul>' . "\n";
    $output .= node_title_list($result);
    $output .= '</ul></div>';
    print $output;
    ?>
</div>

<?php 
}
  *
  * When fetching output from the $row, this construct should be used:
  * $data = $row->{$field->field_alias}
  *
  * The above will guarantee that you'll always get the correct data,
  * regardless of any changes in the aliasing that might happen if
  * the view is modified.
  */
?>
<?php
 global $theme_path;
  global $base_url; 


		 	$qry = "SELECT count(*) FROM {comments} where nid=$output";
	$num = db_result(db_query(db_rewrite_sql($qry)));



?>


<?php // print $output; ?>
<span id="total_comments" style=" margin-bottom: 5px; float:left;">
<span id="bracket" style="color: rgb(204, 204, 204);">{ </span>
<span style=" font-size:16px;font-weight: bold">
<?php 
print $num ;
?>
</span>
Comments  
/**
 * Construct a tree structure for an specific vocabulary. This' the gateway for the treeview
 * @return json with the tree structure 
 */
function neologism_gateway_get_classes_tree_old()
{
    $voc['id'] = $_POST['voc_id'];
    $voc['title'] = $_POST['voc_title'];
    $node = $_POST['node'];
    $nodes = array();
    if ($node == 'super') {
        $classes = db_query(db_rewrite_sql('select * from {evoc_rdf_classes} where superclasses = "0"'));
        while ($class = db_fetch_object($classes)) {
            $qname = $class->prefix . ':' . $class->id;
            $children = neologism_gateway_get_class_children($qname, $voc['title']);
            if ($class->prefix == $voc['title'] || _neologism_gateway_in_nodes($voc['title'], $children)) {
                $qtip = '<b>' . $class->label . '</b><br/>' . $class->comment;
                $leaf = count($children) == 0;
                $nodes[] = array('text' => $qname, 'id' => $qname, 'leaf' => $leaf, 'iconCls' => $class->prefix == $voc['title'] ? 'class-samevoc' : 'class-diffvoc', 'cls' => $class->prefix == $voc['title'] ? 'currentvoc' : '', 'children' => $children, 'qtip' => $qtip);
            }
        }
    }
    drupal_json($nodes);
}
/**
 * Helper function to query the values for the module functions.
 */
function firmware_integrity_query($i = 0) {
  $qry = db_rewrite_sql("select file_integrity_check_value from {firmware} where id=%d");
  return $qry;
}
Exemple #12
0
 public function loadRecentNodes($limit = 10, $element = 0)
 {
     $assoc = $this->associatesWith();
     $nodes = array();
     $sql = "SELECT";
     $sql .= " n.nid,";
     $sql .= " IF(n.changed < c.last_comment_timestamp,";
     if ($assoc) {
         $sql .= " IF(IFNULL(a.last_association_timestamp, 0) > c.last_comment_timestamp, a.last_association_timestamp, c.last_comment_timestamp),";
         $sql .= " IF(IFNULL(a.last_association_timestamp, 0) > n.changed, a.last_association_timestamp, n.changed)) AS t ";
     } else {
         $sql .= " n.changed, c.last_comment_timestamp) AS t ";
     }
     $sql .= "FROM {node} n JOIN {node_comment_statistics} c ON n.nid = c.nid ";
     if ($assoc) {
         $sql .= " LEFT OUTER JOIN {association_statistics} a ON n.nid = a.nid ";
     }
     $sql .= "WHERE type = '%s' AND status = 1 ";
     $sql .= "ORDER BY";
     $sql .= " t DESC";
     $sql = db_rewrite_sql($sql);
     $result = pager_query($sql, $limit, $element, NULL, $this->name);
     while ($row = db_fetch_array($result)) {
         $nodes[] = node_load($row['nid']);
     }
     return array($nodes, theme('pager', NULL, $limit, $element));
 }
function rdf_sioc_xml_story_render($xml, $nid, $title, $type, $created, $changed, $last_updated, $uid, $body)
{
    $node_url = url($nid, array('absolute' => true));
    $xml .= "<sioc:Post rdf:about=\"{$node_url}\">\n";
    $xml .= "  <dc:title>{$title}</dc:title>\n";
    $xml .= "  <sioc:content>\n ";
    $xml .= "    <![CDATA[{$body}]]>\n";
    $xml .= "  </sioc:content>\n";
    $xml .= "  <dc:created>" . date(DATE_ISO8601, $created) . "</dc:created>\n";
    $xml .= "  <dc:modified>" . date(DATE_ISO8601, $changed) . "</dc:modified>\n";
    $xml .= "  <sioc:link rdf:resource=\"{$node_url}\" rdfs:label=\"{$title}\" />\n";
    $xml .= "  <sioc:has_creator rdf:nodeID=\"{$uid}\"/>\n";
    /*Add taxonomy terms as SIOC topics*/
    $query = db_query('SELECT tn.tid AS tid, td.name AS name FROM {term_node} tn, {term_data} td WHERE td.tid = tn.tid AND tn.nid = %d', $nid);
    while ($term = db_fetch_object($query)) {
        $taxonomy_terms = "  <sioc:topic rdfs:label=\"{$term->name}\" rdf:resource=\"" . url("taxonomy/term/{$term->tid}", array('absolute' => TRUE)) . "\" />\n";
    }
    $xml .= $taxonomy_terms;
    /*Add comments as SIOC replies*/
    $query_count = 'SELECT COUNT(*) FROM {comments} WHERE nid = %d AND status = %d';
    $query = 'SELECT c.cid as cid, c.pid, c.nid, c.subject, c.comment, c.format, c.timestamp, c.name, c.mail, c.homepage, u.uid, u.name AS registered_name, u.signature, u.picture, u.data, c.thread, c.status FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.nid = %d and c.status = %d ORDER BY SUBSTRING(c.thread, 1, (LENGTH(c.thread) - 1))';
    $query_args = array($nid, COMMENT_PUBLISHED);
    $query = db_rewrite_sql($query, 'c', 'cid');
    $comment_children = 0;
    $num_rows = FALSE;
    $comments = '';
    $result = db_query($query, $query_args);
    while ($comment = db_fetch_object($result)) {
        $comment = drupal_unpack($comment);
        //    var_dump($comment);module_invoke_all('exit');return;
        //    $comment->depth = count(explode('.', $comment->thread)) - 1;
        //    if ($comment->depth > $comment_children) {
        //      $comment_children++;
        //      $comments .= "  <sioc:has_reply>\n";
        //    }
        //    else {
        //      while ($comment->depth < $comment_children) {
        //        $comment_children--;
        //        $comments .= "  </sioc:has_reply>\n";
        //      }
        //    }
        //    $comments .="     <sioc:Post rdf:about=\"$node_url#comment-$comment->cid\">\n";
        //    while ($comment_children-- > 0) {
        //      $num_rows = TRUE;
        //      $comments .="       <sioc:content><![CDATA[$comment->comment]]></sioc:content>\n";
        //      $comments .="     </sioc:Post>\n";
        //      $comments .= "  </sioc:has_reply>\n";
        //    }
        //  }
        $comments .= "  <sioc:has_reply>\n";
        $comments .= "    <sioc:Post rdf:about=\"{$node_url}#comment-{$comment->cid}\">\n";
        if ($comment->subject) {
            $comments .= "      <dc:title>{$comment->subject}</dc:title>\n";
        }
        if ($comment->timestamp) {
            $comments .= "      <dc:created>" . date(DATE_ISO8601, $comment->timestamp) . "</dc:created>\n";
        }
        if ($comment->uid) {
            $comments .= "    <sioc:has_creator>\n";
            $comments .= "      <sioc:User>\n";
            $comments .= "        <sioc:name>{$comment->registered_name}</sioc:name>\n";
            $comments .= "        <sioc:email rdf:resource=\"mailto:{$comment->mail}\"/>\n";
            $comments .= "         <sioc:link rdf:resource=\"" . url('user/' . $comment->uid, array('absolute' => true)) . "\" rdfs:label=\"{$comment->registered_name}\"/>\n";
            $comments .= "      </sioc:User>\n";
            $comments .= "    </sioc:has_creator>\n";
        }
        $comments .= "      <sioc:content><![CDATA[{$comment->comment}]]></sioc:content>\n";
        $comments .= "    </sioc:Post>\n";
        $comments .= "  </sioc:has_reply>\n";
    }
    $xml .= $comments;
    $xml .= "</sioc:Post>\n";
    return $xml;
}
/**
 * This function search for the children of a node on the tree. As the rearch at this scope is global
 * we need to search in all the sistem including evoc_rdf_classes table.
 * @param object $node
 * @return array of children belonging to $node 
 */
function evocwidget_dynamic_gateway_get_children($node)
{
    $children = db_query(db_rewrite_sql("select n.title, n.nid from content_field_superclass2 as c inner join node as n on c.nid = n.nid \r\n    where c.field_superclass2_evoc_term = '%s'"), $node);
    // get children from vocabularies on Drupal content
    $arr_children = array();
    while ($child = db_fetch_object($children)) {
        $classes = db_query(db_rewrite_sql("select e.prefix, e.superclass from {evoc_rdf_classes} as e where e.id = '%s'"), $child->title);
        // may there is more than one class with the same title but belong to a different vocabulary
        while ($class = db_fetch_object($classes)) {
            $class->prefix = trim($class->prefix);
            $class->superclass = trim($class->superclass);
            // check if the current $class is well selected, because might be a class with same title/id and different vocabulary/prefix
            // otherwise we need to join more tables to make the correct query.
            // this fix when there is two class with same name but different prefix, eg: eg:Agent and foaf:Agent
            if ($class->superclass == $node) {
                $arr = array('prefix' => $class->prefix, 'id' => $child->title);
                if (!in_array($arr, $arr_children)) {
                    $arr_children[] = $arr;
                }
            }
        }
    }
    // get child from evoc classes
    $children = db_query(db_rewrite_sql("select e.prefix, e.id from {evoc_rdf_classes} as e where e.superclass = '%s'"), $node);
    while ($child = db_fetch_object($children)) {
        $child->prefix = trim($child->prefix);
        $child->id = trim($child->id);
        // may there is more than one class with the same title but belong to a different vocabulary
        $arr = array('prefix' => $child->prefix, 'id' => $child->id);
        if (!in_array($arr, $arr_children)) {
            $arr_children[] = $arr;
        }
    }
    return $arr_children;
}
Exemple #15
0
/**
 * Renders comment(s) without forms.
 *
 * @param $node
 *   The node which comment(s) needs rendering.
 * @param $cid
 *   Optional, if given, only one comment is rendered.
 *
 * @see comment_render.
 */
function comment_display_comment_render_without_form($node, $cid = 0)
{
    global $user;
    $output = '';
    if (user_access('access comments')) {
        // Pre-process variables.
        $nid = $node->nid;
        if (empty($nid)) {
            $nid = 0;
        }
        $mode = _comment_get_display_setting('mode', $node);
        $order = _comment_get_display_setting('sort', $node);
        $comments_per_page = _comment_get_display_setting('comments_per_page', $node);
        if ($cid && is_numeric($cid)) {
            // Single comment view.
            $query = 'SELECT c.cid, c.pid, c.nid, c.subject, c.comment, c.format, c.timestamp, c.name, c.mail, c.homepage, u.uid, u.name AS registered_name, u.signature, u.picture, u.data, c.status FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.cid = %d';
            $query_args = array($cid);
            if (!user_access('administer comments')) {
                $query .= ' AND c.status = %d';
                $query_args[] = COMMENT_PUBLISHED;
            }
            $query = db_rewrite_sql($query, 'c', 'cid');
            $result = db_query($query, $query_args);
            if ($comment = db_fetch_object($result)) {
                $comment->name = $comment->uid ? $comment->registered_name : $comment->name;
                $links = module_invoke_all('link', 'comment', $comment, 1);
                drupal_alter('link', $links, $node);
                $output .= theme('comment_view', $comment, $node, $links);
            }
        } else {
            // Multiple comment view
            $query_count = 'SELECT COUNT(*) FROM {comments} c WHERE c.nid = %d';
            $query = 'SELECT c.cid as cid, c.pid, c.nid, c.subject, c.comment, c.format, c.timestamp, c.name, c.mail, c.homepage, u.uid, u.name AS registered_name, u.signature, u.picture, u.data, c.thread, c.status FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.nid = %d';
            $query_args = array($nid);
            if (!user_access('administer comments')) {
                $query .= ' AND c.status = %d';
                $query_count .= ' AND c.status = %d';
                $query_args[] = COMMENT_PUBLISHED;
            }
            if ($order == COMMENT_ORDER_NEWEST_FIRST) {
                if ($mode == COMMENT_MODE_FLAT_COLLAPSED || $mode == COMMENT_MODE_FLAT_EXPANDED) {
                    $query .= ' ORDER BY c.cid DESC';
                } else {
                    $query .= ' ORDER BY c.thread DESC';
                }
            } else {
                if ($order == COMMENT_ORDER_OLDEST_FIRST) {
                    if ($mode == COMMENT_MODE_FLAT_COLLAPSED || $mode == COMMENT_MODE_FLAT_EXPANDED) {
                        $query .= ' ORDER BY c.cid';
                    } else {
                        // See comment above. Analysis reveals that this doesn't cost too
                        // much. It scales much much better than having the whole comment
                        // structure.
                        $query .= ' ORDER BY SUBSTRING(c.thread, 1, (LENGTH(c.thread) - 1))';
                    }
                }
            }
            $query = db_rewrite_sql($query, 'c', 'cid');
            $query_count = db_rewrite_sql($query_count, 'c', 'cid');
            // Start a form, for use with comment control.
            $result = pager_query($query, $comments_per_page, 0, $query_count, $query_args);
            $divs = 0;
            $num_rows = FALSE;
            $comments = '';
            drupal_add_css(drupal_get_path('module', 'comment') . '/comment.css');
            while ($comment = db_fetch_object($result)) {
                $comment = drupal_unpack($comment);
                $comment->name = $comment->uid ? $comment->registered_name : $comment->name;
                $comment->depth = count(explode('.', $comment->thread)) - 1;
                if ($mode == COMMENT_MODE_THREADED_COLLAPSED || $mode == COMMENT_MODE_THREADED_EXPANDED) {
                    if ($comment->depth > $divs) {
                        $divs++;
                        $comments .= '<div class="indented">';
                    } else {
                        while ($comment->depth < $divs) {
                            $divs--;
                            $comments .= '</div>';
                        }
                    }
                }
                if ($mode == COMMENT_MODE_FLAT_COLLAPSED) {
                    $comments .= theme('comment_flat_collapsed', $comment, $node);
                } else {
                    if ($mode == COMMENT_MODE_FLAT_EXPANDED) {
                        $comments .= theme('comment_flat_expanded', $comment, $node);
                    } else {
                        if ($mode == COMMENT_MODE_THREADED_COLLAPSED) {
                            $comments .= theme('comment_thread_collapsed', $comment, $node);
                        } else {
                            if ($mode == COMMENT_MODE_THREADED_EXPANDED) {
                                $comments .= theme('comment_thread_expanded', $comment, $node);
                            }
                        }
                    }
                }
                $num_rows = TRUE;
            }
            while ($divs-- > 0) {
                $comments .= '</div>';
            }
            $output .= $comments;
            $output .= theme('pager', NULL, $comments_per_page, 0);
        }
        $output = theme('comment_wrapper', $output, $node);
    }
    return $output;
}
Exemple #16
0
<?php 
}
?>
</div>

<div id="profile_blog">
    <!-- START - LATEST 10 BLOG ENTRIES -->
    <div class="profilefeeds">
    <?php 
$nlimit = 10;
?>
    <?php 
$userid = $profile->uid;
?>
    <?php 
$result1 = pager_query(db_rewrite_sql("SELECT n.nid, n.created FROM {node} n WHERE n.type = 'blog' AND n.status = 1 AND n.uid = {$userid} ORDER BY n.created DESC"), variable_get('default_nodes_main', $nlimit));
?>
    <?php 
while ($node = db_fetch_object($result1)) {
    $output2 .= node_view(node_load(array('nid' => $node->nid)), 1);
}
?>
    
    <?php 
if ($output2) {
    ?>
    <?php 
    print $output2;
    ?>
    <?php 
} else {
/**
 * Helper function to query the values for the module functions.
 */
function conf_association_query($i = 0) {
  $qry = db_rewrite_sql("SELECT node.nid FROM {content_type_device_type_config} AS cdtc JOIN {content_field_device_config_hw_list} AS cfdchwl ON cdtc.vid=cfdchwl.vid JOIN {content_type_device_config_hardware} AS ctdch ON cfdchwl.field_device_config_hw_list_nid=ctdch.nid JOIN {node} AS node ON node.vid=cdtc.vid JOIN content_field_expiration_datetime ON cdtc.vid=content_field_expiration_datetime.vid AND content_field_expiration_datetime.field_expiration_datetime_value IS NULL WHERE ctdch.field_device_config_hardware_nid='%d'");
  return $qry;
}
function _neologism_get_range_terms($prefix, $id)
{
    $array_ranges = array();
    $result = db_query(db_rewrite_sql("select rdf_range from {evoc_rdf_propertiesranges} where prefix = '%s' and reference = '%s'"), $prefix, $id);
    while ($obj = db_fetch_object($result)) {
        $array_ranges[] = $obj->rdf_range;
    }
    return $array_ranges;
}
<?php

// $Id$
/* @file
 * get most recent three tools
 */
$list_no = 3;
$query = "SELECT DISTINCT n.nid, n.created\n  FROM {node} n\n  WHERE n.type = 'tool' AND n.status = 1\n  ORDER BY n.created DESC\n  LIMIT {$list_no}";
$sql = db_rewrite_sql($query);
$result = db_query($sql);
$items = array();
while ($item = db_fetch_object($result)) {
    $node = node_load($item->nid);
    // $term_names = array();
    // # gather, into $term_names, all the terms because of which this node was selected:
    // foreach (taxonomy_node_get_terms($item->nid) as $term) {
    //    if (in_array($term->tid, $taxo_id_arr))
    //        $term_names[] = $term->name;
    // }
    // $items[]= l($item->title, "node/$item->nid") .
    //   '<br />' .
    //   'Created ' . format_date($item->created, 'custom', 'Y-m-d') . '.';
    $title = drupal_substr(strip_tags(check_plain($node->title)), 0, 22);
    $link = "/node/" . $node->nid;
    $clink = "/comment/reply/" . $node->nid . "#comment-form";
    $description = trim(strip_tags(check_plain($node->body)));
    if (strpos($description, '<') !== FALSE || strpos($description, '&lt;') !== FALSE || drupal_strlen($description) == 0) {
        $description = "More";
    }
    $description = drupal_substr($description, 0, 65) . " ... ";
    $image = "";
Exemple #20
0
  function printdata($node1){	
	
	$qry = "SELECT count(*) FROM {comments} where pid=$node1";
	$num = db_result(db_query(db_rewrite_sql($qry)));
	//print $node1.'--'.$num.'--';
	
	
	$result = db_query("SELECT * FROM {comments} where pid=%d",$node1);
	while($row = db_fetch_array($result)){
		$node=$row['cid']; $nodepid=$row['pid'];
		
		
		 $result = db_query("SELECT * FROM {comments} where pid=%d",$node1);
	while($row = db_fetch_array($result)){
		$node22=$row['cid']; $nodepid=$row['pid'];
		 $viewName = 'user_scholar_comments';
		//print $node22.'**--';
		$qry = "SELECT count(*) FROM {comments} where pid=$node22";
	$num = db_result(db_query(db_rewrite_sql($qry)));
//print '-------------------------------------------------**'.$num.'--------------->>';

		
		
		 print views_embed_view($viewName , $display_id = 'default',$node22);
		  
		  
		$subitem11 = db_query("SELECT * FROM {comments} where pid=%d",$node22);
		while($row = db_fetch_array($subitem11)){
		
		 $node1122=$row['cid'];
		 
		 print views_embed_view($viewName , $display_id = 'default', $node1122);
		  if($node1122!=" "){
			printdata($node1122);
		}
		  
		  
		  }
		  }
		//  print "-----------".$nodepid."-----------";
		$subitem = db_query("SELECT * FROM {comments} where pid=%d",$node);
		while($row = db_fetch_array($subitem)){
		
		 $node11=$row['cid']; //printdata($node11);
	//print $node11."ooooooooooooooooo";
		}
		if($node11!=" "){
		//	printdata_cmt($node);
		}
		
	}
 }
function _scratchy_forum_topic_navigation($node)
{
    return;
    $output = '';
    // get previous and next topic
    $sql = "SELECT n.nid, n.title, n.sticky, l.comment_count, l.last_comment_timestamp FROM {node} n INNER JOIN {node_comment_statistics} l ON n.nid = l.nid INNER JOIN {term_node} r ON n.nid = r.nid AND r.tid = %d WHERE n.status = 1 AND n.type = 'forum' ORDER BY n.sticky DESC, " . _forum_get_topic_order_sql(variable_get('forum_order', 1));
    $result = db_query(db_rewrite_sql($sql), $node->tid);
    $stop = 0;
    while ($topic = db_fetch_object($result)) {
        if ($stop == 1) {
            $next = new stdClass();
            $next->nid = $topic->nid;
            $next->title = $topic->title;
            break;
        }
        if ($topic->nid == $node->nid) {
            $stop = 1;
        } else {
            $prev = new stdClass();
            $prev->nid = $topic->nid;
            $prev->title = $topic->title;
        }
    }
    if ($prev || $next) {
        $output .= '<div class="forum-topic-navigation clear-block">';
        if ($prev) {
            $output .= l(t('‹ ') . $prev->title, 'node/' . $prev->nid, array('class' => 'topic-previous', 'title' => t('Go to previous forum topic')));
        }
        if ($prev && $next) {
            // Word break (a is an inline element)
            $output .= ' ';
        }
        if (!empty($next)) {
            $output .= l($next->title . t(' ›'), 'node/' . $next->nid, array('class' => 'topic-next', 'title' => t('Go to next forum topic')));
        }
        $output .= '</div>';
    }
    return $output;
}
Exemple #22
0
/**
 * Enables Domain Access modules to fire cron hooks across all
 * active domains.
 *
 * Each module implementing this hook will have the function run
 * once per active domain record.  The global $_domain variable
 * will be set to the current $domain passed as an argument.
 *
 * This function is especially useful if you need to run node queries
 * that obey node access rules.
 *
 * Note that Domain Prefix and Domain Conf are activated by this hook.
 * That means each domain will have its tables and variables loaded before
 * your function fires.
 *
 * @param $domain
 *  The information for the current domain record, taken from {domain}.
 *
 * @ingroup domain_hooks
 */
function hook_domaincron($domain)
{
    // Run a node query.
    $result = db_query_range(db_rewrite_sql("SELECT n.nid FROM {node} n ORDER BY n.changed"), 0, 1);
    $node = db_fetch_object($result);
    // Set a variable for each domain containing the last node updated.
    variable_set('domain_' . $domain['domain_id'] . '_lastnode', $node->nid);
}
Exemple #23
0
/**
 * Override of comment_get_recent.
 * 
 * Find a number of recent comments. This is done in two steps.
 *   1. Find the n (specified by $number) nodes that have the most recent
 *      comments.  This is done by querying node_comment_statistics which has
 *      an index on last_comment_timestamp, and is thus a fast query.
 *   2. Loading the information from the comments table based on the nids found
 *      in step 1.
 *
 * @param $number
 *   (optional) The maximum number of comments to find.
 * @return
 *   An array of comment objects each containing a nid,
 *   subject, cid, and timestamp, or an empty array if there are no recent
 *   comments visible to the current user.
 * 
 * @todo Should this be a preprocess function?
 */
function phptemplate_comment_get_recent($number = 10)
{
    // Select the $number nodes (visible to the current user) with the most
    // recent comments. This is efficient due to the index on
    // last_comment_timestamp.
    $result = db_query_range(db_rewrite_sql("SELECT nc.nid FROM {node_comment_statistics} nc WHERE nc.comment_count > 0 ORDER BY nc.last_comment_timestamp DESC", 'nc'), 0, $number);
    $nids = array();
    while ($row = db_fetch_object($result)) {
        $nids[] = $row->nid;
    }
    $comments = array();
    if (!empty($nids)) {
        // From among the comments on the nodes selected in the first query,
        // find the $number most recent comments.
        $result = db_query_range('SELECT c.nid, c.uid, c.subject, c.comment, c.cid, c.timestamp FROM {comments} c INNER JOIN {node} n ON n.nid = c.nid WHERE c.nid IN (' . implode(',', $nids) . ') AND n.status = 1 AND c.status = %d ORDER BY c.cid DESC', COMMENT_PUBLISHED, 0, $number);
        while ($comment = db_fetch_object($result)) {
            $comments[] = $comment;
        }
    }
    return $comments;
}