$output"); } function theme_ejournal_list_this_issue(&$journal, $iid, $print=FALSE) { global $ejrn_viewed_issue; $order = variable_get('ejournal_issue_order', 'DESC'); $issue = ejournal_issue_get($iid); //ejrn_viewed_issue is a special variable used in themes to display identification of the //current (displayed) issue, it may be shown in the header of the whole site $ejrn_viewed_issue = $issue; $output = theme('ejournal_journal_reference', $journal); $result = _ejournal_issue_get_articles($journal, $iid); if($print && $iid) { // we will print contents of the whole issue (should we allow it?) print ""; print drupal_get_html_head(); print ""; foreach($result as $article) { print node_view(node_load(array('nid' => $article->nid))); print "\n

"; } print "\n"; return; } foreach($result as $article) { if($article->name != $old_section) { $output .= theme('ejournal_section', $article->name); $old_section = $article->name; } $output .= "
". _ejournal_article_get_author_names($journal, $article->nid)."
"; $output .= theme('ejournal_article_reference', &$article) . "
"; } drupal_set_title(t('%title %issue', array('%title' => $journal->title, '%issue' => ejournal_issue_reference($issue, $journal)))); print theme('ejournal_page', "
$output
", $journal); } function theme_ejournal_journal_reference(&$journal) { $output .= '
' . l($journal->title, "ejournal/$journal->jid") . "
\n"; if ($journal->description) { $output .= "

$journal->description

\n"; } $output .= "
\n"; return $output; } function theme_ejournal_volume_reference($issue, $jid = FALSE) { $out = $jid ? l(ejournal_volume_reference($issue), "ejournal/$jid/v".urlencode($issue->volume)) : ejournal_volume_reference($issue); return "
" . $out . "
\n"; } /** * theme_ejournal_issue_reference: A themeable layout that formats a single issue of a journal. * * @param $issue * An edition object. * * @return * An HTML-formatted display showing the reference name of the issue */ function theme_ejournal_issue_reference(&$issue, $full=TRUE) { //esta es la que está usando!! $output = "
"; if($full) { $output .= l((ejournal_issue_reference($issue)), "ejournal/$issue->jid/$issue->iid"); } else { //escribe un item del archivo $output .= $issue->number ? l(t('No. ') . $issue->number, "ejournal/$issue->jid/$issue->iid") : l( $issue->custom_identification , "ejournal/$issue->jid/$issue->iid"); // $output .= "
[ " . format_date($issue->date_published, 'custom', 'd. m. Y') . " ]"; } $output .= "
\n"; return $output; } function theme_ejournal_article_reference(&$article) { return l($article->title, "node/$article->nid", array('class' => 'article')); } function theme_ejournal_section($section) { return "
$section
\n"; } function theme_ejournal_archive(&$journal, $issues = NULL) { if(!$issues) { // if no issues, we will display whole archive $issues = _ejournal_journal_get_issues($journal); $full_archive = 1; } $output = "
\n"; $output .= "
"; while($issue = db_fetch_object($issues)) { if($issue->volume != $old_volume) { $output .= "
"; $output .= $full_archive ? theme('ejournal_volume_reference', $issue, $journal->jid) : theme('ejournal_volume_reference', $issue); $old_volume = $issue->volume; } $output .= theme('ejournal_issue_reference', $issue, FALSE); if(!$full_archive) { $articles = _ejournal_issue_get_articles($journal, $issue->iid); foreach($articles as $article) { $output .= l($article->title, "node/$article->nid") . "
"; } } } $output .= "
"; if($full_archive) { $output .= "

" . t('Display articles in section') . "

\n"; $form = array(); $form['tid'] = array( '#type' => 'select', '#title' => t('Section'), '#default_value' => NULL, '#options' => ejournal_sections_get($journal->jid, NULL) ); $form['jid'] = array('#type' => 'hidden', '#value' => $journal->jid); $form['op'] = array('#type' => 'submit', '#value' => t('Submit')); $form['#action'] = url("ejournal/$journal->jid/term"); $output .= drupal_get_form('section_archive', $form); $output .= "
"; } $output .= "
"; drupal_set_title(t('%journal archive', array('%journal' => $journal->title))); print theme('ejournal_page', $output); } function theme_ejournal_about ($journal) { if(!$journal->about_page) { theme('ejournal_archive', $journal); } $path = drupal_get_normal_path($journal->about_page); $status = MENU_NOT_FOUND; if ($path) { menu_set_active_item($path); $status = menu_execute_active_handler(); } exit; } /** * This is only adopted taxonomy_term_page function * It would be better to call this function, however I need to construct * different url(s) - not "taxonomy/term/1" but "ejournal/{jid}/term/1" * If you can live without that, override theme_ejournal_taxonomy_term_page * from some custom layout **/ function theme_ejournal_taxonomy_term_page($journal, $str_tids = '', $depth = 0, $op = 'page') { if (preg_match('/^([0-9]+[+ ])+[0-9]+$/', $str_tids)) { $operator = 'or'; // The '+' character in a query string may be parsed as ' '. $tids = preg_split('/[+ ]/', $str_tids); } else if (preg_match('/^([0-9]+,)*[0-9]+$/', $str_tids)) { $operator = 'and'; $tids = explode(',', $str_tids); } else { drupal_not_found(); } // Needed for '+' to show up in RSS discovery URLs $rss_tids = urlencode($str_tids); if ($tids) { // Build title: $result = db_query('SELECT name FROM {term_data} WHERE tid IN (%s)', implode(',', $tids)); $names = array(); while ($term = db_fetch_object($result)) { $names[] = $term->name; } if ($names) { drupal_set_title($title = implode(', ', $names)); switch ($op) { case 'page': // Build breadcrumb based on first hierarchy of first term: $current->tid = $tids[0]; $breadcrumbs = array(array('path' => $_GET['q'])); while ($parents = taxonomy_get_parents($current->tid)) { $current = array_shift($parents); $breadcrumbs[] = array('path' => 'ejournal/'.$journal->jid.'/term/'. $current->tid, 'title' => $current->name); } $breadcrumbs = array_reverse($breadcrumbs); menu_set_location($breadcrumbs); drupal_add_link(array('rel' => 'alternate', 'type' => 'application/rss+xml', 'title' => 'RSS - '. $title, 'href' => url('ejournal/'.$journal->jid.'term/'. $rss_tids .'/'. $depth .'/feed'))); // str_replace is added for the sake of ejournal module $output = str_replace('taxonomy/term', "ejournal/$journal->jid/term", taxonomy_render_nodes(taxonomy_select_nodes($tids, $operator, $depth, TRUE))); $output .= theme('xml_icon', url("ejournal/$journal->jid/term/$rss_tids/$depth/feed")); print theme('ejournal_page', $output); break; case 'feed': $term = taxonomy_get_term($tids[0]); $channel['link'] = url('ejournal/'.$journal->jid.'/term/'. $str_tids .'/'. $depth, NULL, NULL, TRUE); $channel['title'] = variable_get('site_name', 'drupal') .' - '. $title; $channel['description'] = $term->description; $result = taxonomy_select_nodes($tids, $operator, $depth, FALSE); node_feed($result, $channel); break; default: drupal_not_found(); } } else { drupal_not_found(); } } } function theme_ejournal_article_citation($journal, $issue, &$node) { $array = array( '{%journal}' => $journal->title, '{%issn}' => $journal->issn, '{%publisher}' => $journal->publisher_name, '{%publisher_url}' => $journal->publisher_url, '{%publisher_email}' => $journal->publisher_email, '{%year}' => $issue->year, '{%volume}' => $issue->volume, '{%number}' => $issue->number, '{%custom_id}' => $issue->custom_identification, '{%issue_date}' => format_date($issue->date_published, 'custom', 'd. m. Y'), '{%nid}' => $node->nid, '{%title}' => $node->title, '{%article_created}' => format_date($node->created, 'custom', 'd. m. Y'), '{%article_changed}' => format_date($node->changed, 'custom', 'd. m. Y'), '{%url}' => l(url('node/'.$node->nid, NULL, NULL, TRUE), 'node/'.$node->nid), '{%now}' => format_date(time(), 'custom', 'd. m. Y'), '{%section}' => _ejournal_article_get_section_name($journal, $node->nid), '{%authors}' => _ejournal_article_get_author_names($journal, $node->nid) ); /* foreach(array_keys($array) as $key) { print "'$key ' . t('') . \"\\n\" ." . "\n"; }; */ return '
' . str_replace(array_keys($array), array_values($array), $journal->citation_template) . "
\n"; } function theme_ejournal_list_vocabulary($journal, $vid, $char=NULL) { if(!is_numeric($vid)) { return; } /* $list = db_query("SELECT LEFT(name, 1) AS x FROM {term_data} WHERE vid='%d' GROUP BY x", $vid); while($char = db_fetch_object($list)) { $chars[] = l($char->x, "ejournal/$journal->jid/list/$vid/" . urlencode($char->x)); } $output = implode(' ', $chars); */ //select term together with synonyms (if any) - group by name and show duplicates in "num" $sql = "(SELECT tid, name, COUNT(name) AS num FROM {term_data} WHERE vid=$vid GROUP BY name) UNION ALL (SELECT ts.tid, ts.name, 0 AS num FROM {term_synonym} ts INNER JOIN {term_data} td ON ts.tid=td.tid WHERE td.vid=$vid GROUP BY ts.name) ORDER BY name"; //$sql = "SELECT name, tid FROM {term_data} WHERE vid='".db_escape_string($vid)."' ORDER BY name"; $sql_count = "SELECT count(name) FROM {term_data} WHERE vid='".db_escape_string($vid)."'"; $result = pager_query($sql, 50, 0, $sql_count); if($journal->author_vid == "$vid") { $type = 'author'; $url_type = urlencode("edit[type]")."=$type"; } $output .= theme('pager', NULL, 50, 0); $output .= "
\n"; while ($term = db_fetch_object($result)) { if($term->num) { if($term->num > 1) { // two terms with identical name $output .= l("$term->name *", "ejournal/$journal->jid/term/$term->tid", NULL, urlencode("edit[type]")."=$type&".urlencode("edit[multiple]")."=1") . "
\n"; } else { $output .= l($term->name, "ejournal/$journal->jid/term/$term->tid", NULL, $url_type) . "
\n"; } } else { $output .= $term->name . '  ' . l(t('see this'), "ejournal/$journal->jid/term/$term->tid", NULL, $url_type) . "
\n"; } $i++; if($i == 25) { $output .="
"; } } $output .= "
\n"; $output .= theme('pager', NULL, 50, 0); drupal_set_title(t('Browse journal %name', array('%name' => $journal->title))); print theme('ejournal_page', $output); } function theme_ejournal_list_vocabularies($journal) { $vocs = taxonomy_get_vocabularies(); foreach(split(',', ($journal->vid)) as $vid) { if($vocs[$vid]) { $output .= "

".l($vocs[$vid]->name, "ejournal/$journal->jid/list/$vid")."

"; $output .= '

' . $vocs[$vid]->description . "

\n"; unset($vocs[$vid]); } } foreach(array('author_vid', 'other_vid') as $name) { foreach(split(',', $journal->$name) as $vid) { if($vocs[$vid]) { $output .= "

".l($vocs[$vid]->name, "ejournal/$journal->jid/list/$vid")."

"; $output .= '

' . $vocs[$vid]->description . "

\n"; unset($vocs[$vid]); } } } drupal_set_title(t('Browse journal %name', array('%name' => $journal->title))); print theme('ejournal_page', $output); } function theme_ejournal_show_author($journal, $tid) { if($authors = ejournal_authors_find_by_tid($journal, $tid)) { // find the authors mapped in ejournal_authors (uid <-> tid) } else if($authors = ejournal_authors_find_by_name($journal, $tid)) { // try to find author from profile_values be value (name) of its term // but we are unable to distinguish their tids and map them to uids $name = db_result(db_query("SELECT name FROM {term_data} WHERE tid='%d'", $tid)); $result = db_query("SELECT tid FROM {term_data} WHERE name='%s'", $name); while($tid = db_fetch_object($result)) { $tids[] = $tid->tid; } } else { // last resort, send to taxonomy function to find all nodes with tid print theme('ejournal_taxonomy_term_page', $journal, $tid); return; } $names = array(); while ($author = db_fetch_object($authors)) { $names[] = $author->name; if ($account = user_load(array('uid' => $author->uid, 'status' => 1))) { $fields = array(); if(function_exists('profile_load_profile')) { if ($data = module_invoke('profile', 'user', 'view', '', $account)) { foreach ($data as $category => $content) { $fields[$category] .= $content; } } } $output .= theme('user_profile', $account, $fields); } if($author->tid) { $tids[] = $author->tid; } } $output .= "
\n"; $ejrn_find = array(); foreach($tids as $tid) { $nodes = taxonomy_select_nodes(array($tid), NULL, 0, TRUE); while($node = db_fetch_object($nodes)) { $articles[$node->nid] = l($node->title, "node/$node->nid") ."
\n" ; $ejrn_find[] = $node->nid; } } $issues = db_query("SELECT ei.*, ea.nid FROM {ejournal_issues} ei INNER JOIN {ejournal_articles} ea ON ei.iid=ea.iid WHERE ea.nid IN ('".implode("','", $ejrn_find)."') ORDER BY ei.date_published DESC"); $output .= "
"; while($issue = db_fetch_object($issues)) { if($old != $issue->iid) { $output .= theme('ejournal_issue_reference', $issue); $old = $issue->iid; } $output .= $articles[$issue->nid]; } $output .= "
"; $output .= theme('pager', NULL, variable_get('default_nodes_main', 10), 0, array('edit[type]' => 'author')); drupal_set_title(t('Articles by %authors', array('%authors' => implode(', ', $names)))); print theme('ejournal_page', $output); }