Beispiel #1
0
 public function testHookLoadWithUncachedNode()
 {
     $entry = kentry_load($this->node1);
 }
Beispiel #2
0
function paldo_kentry_synonyms($node, $teaser = TRUE, $type = '')
{
    $synonyms = '';
    $header = $rows = array();
    if ($teaser) {
        $node = kentry_load($node);
        //load synonyms as they're not loaded on non-node pages
    }
    if (isset($node->relations)) {
        $synonyms = "<dd class='synonyms'>";
        if (is_array($node->relations) && count($node->relations)) {
            $header[] = t('Search by');
            foreach ($node->relations as $relid => $rels) {
                $header[$relid] = t(' %lang', array('%lang' => variable_get('ksynset_' . $relid . '_name', '')));
                if (is_array($rels)) {
                    $i = 1;
                    foreach ($rels as $vid => $rel) {
                        $class = $rel['svid'] == $node->vid ? 'manual' : 'robot';
                        $title = $rel['svid'] == $node->vid ? t('Decided by a human') : t('Pending final review');
                        $reltypes[] = $rel['type'];
                        $clean_w = strip_tags($rel['root']);
                        $rs[$rel['type']][$relid][$rel['title']] = l($rel['title'], "search/kclient/{$rel['title']} link:{$rel['type']}|{$node->iso}", array('attributes' => array('class' => $class, 'title' => $title), 'html' => TRUE));
                    }
                }
            }
        }
        $rowtypes = is_array($reltypes) ? array_unique($reltypes) : array();
        //Now restrict to $type
        if ($type) {
            $rowtypes = array_intersect($rowtypes, array($type));
        }
        $coltypes = is_array($node->relations) ? array_keys($node->relations) : array();
        $dbnames = variable_get('kclient_db_names', array());
        foreach ($rowtypes as $rowtype) {
            $rows[$rowtype][1] = $dbnames[$rowtype];
            foreach ($coltypes as $coltype) {
                $rows[$rowtype][$coltype] = is_array($rs[$rowtype][$coltype]) ? join(", ", $rs[$rowtype][$coltype]) : "";
            }
        }
        if (count($rows)) {
            foreach ($coltypes as $a) {
                //Ignore the first header column
                foreach ($rows as $rk => $value) {
                    if ($value[$a]) {
                        $synonyms .= "<div id='{$rk}'><label>{$value['1']}\n                            {$header[$a]}</label> {$value[$a]}</div>";
                    }
                }
            }
            //$synonyms.= theme('table', $header, $rows, array('width'=>'80%'));
        }
        $synonyms .= "</dd>";
    }
    return $synonyms;
}