| 8 |
*/ |
*/ |
| 9 |
function last_node_help($section) { |
function last_node_help($section) { |
| 10 |
switch ($section) { |
switch ($section) { |
| 11 |
case 'admin/help#last_node': |
case 'admin/help#last_node': |
| 12 |
$output = t('<p>This module displays the list of inserted lately items (sorted by time) for each node.<BR />Set your own nodes that you want to see at <a href="?q=admin/settings/last_node">settings page</a> and view this page with <a href="?q=last_node/">last_node/</a> address, you can specify a title and image for each item.</p>'); |
$output = t('<p>This module displays the list of inserted lately items (sorted by time) for each node.<br />Set your own nodes that you want to see at <a href="?q=admin/settings/last_node">settings page</a> and view this page with <a href="?q=last_node/">last_node/</a> address, you can specify a title and image for each item.</p>'); |
| 13 |
$output .= t('<p>This module provide:<ul> <li>Block <em>Last 10</em>: Show your last 10 items of all nodes; <li>Block <em>Navigate Last Node</em>: Show Block of all Type node allowed; <li>Block <em>Last 10 - type</em>: any node type can show yours last 10 element at owned block; <li>Menu Items for each node type; <li>API for display in your own page:'); |
$output .= t('<p>This module provide:<ul> <li>Block <em>Last 10</em>: Show your last 10 items of all nodes;</li> <li>Block <em>Navigate Last Node</em>: Show Block of all Type node allowed;</li> <li>Block <em>Last 10 - type</em>: any node type can show yours last 10 element at owned block;</li> <li>Block <em>Sticky Last Node</em>: this block show your ten last nodes with sticky flag enabled;</li> <li>Menu Items for each node type;</li> <li>API for display in your own page:'); |
| 14 |
$output .= t('<ol><li><em>lastnode_display($title,$node_type,$num_item)</em>: if you want show your last items for node specified at own page; <li><em>lastnode_imgdisplay($title,$node_type,$num_item)</em>: show also image for each node.</ol></ul></p>'); |
$output .= t('<ol><li><em>lastnode_display($title,$node_type,$num_item)</em>: if you want show your last items for node specified at own page; <li><em>lastnode_imgdisplay($title,$node_type,$num_item)</em>: show also image for each node.</ol></ul></li></p>'); |
| 15 |
$output .= t('<h3>Example for API usage:</h3><p><ul><li> Enable the page and story module at <a href="?q=admin/modules">administer » modules</a> page. <li>Select <a href="?q=node/add/page">create content » page</a>; <li>For input format, select PHP code; <li>Check frontpage option; <li>Give the page a title. For body, put: <pre><?php print lastnode_display(\'Last 10 Node of Story\',\'story\',10); ?></pre> <li>Save the page.</ul></p>'); |
$output .= t('<h3>Example for API usage:</h3><p><ul><li> Enable the page and story module at <a href="?q=admin/modules">administer » modules</a> page. <li>Select <a href="?q=node/add/page">create content » page</a>; <li>For input format, select PHP code; <li>Check frontpage option; <li>Give the page a title. For body, put: <pre><?php print lastnode_display(\'Last 10 Node of Story\',\'story\',10); ?></pre> <li>Save the page.</ul></p>'); |
| 16 |
$output .= t('<h3>Tips for blocks <em>Last 10 - type</em>:</h3><p>For show these blocks only when the node page it\'s display complete then set the <em>Auto-Hide</em> option in <a href="?q=admin/settings/last_node">settings page</a></p>'); |
$output .= t('<h3>Tips for blocks <em>Last 10 - type</em>:</h3><p>For show these blocks only when the node page it\'s display complete then set the <em>Auto-Hide</em> option in <a href="?q=admin/settings/last_node">settings page</a></p>'); |
| 17 |
return $output; |
return $output; |
| 18 |
break; |
break; |
| 19 |
case 'admin/modules#description': |
case 'admin/modules#description': |
| 20 |
return t('This module displays the list of inserted lately items (sorted by time) for each node and provide blocks and api for a fast access to these informations.'); |
return t('This module displays the list of inserted lately items (sorted by time) for each node and provide blocks and api for a fast access to these informations.'); |
| 21 |
break; |
break; |
| 22 |
} |
} |
| 30 |
if ($op == 'list') { |
if ($op == 'list') { |
| 31 |
$blocks['0']['info'] = t('Last 10 Nodes'); |
$blocks['0']['info'] = t('Last 10 Nodes'); |
| 32 |
$blocks['1']['info'] = t('Navigate Last Node'); |
$blocks['1']['info'] = t('Navigate Last Node'); |
| 33 |
_last_node_blocknode($op,2,&$blocks); |
$blocks['2']['info'] = t('Sticky Last Node'); |
| 34 |
|
_last_node_blocknode($op,2,$blocks); |
| 35 |
return $blocks; |
return $blocks; |
| 36 |
} |
} |
| 37 |
else if ($op == 'view') { |
else if ($op == 'view') { |
| 44 |
$block['subject'] = t('Last Node:'); |
$block['subject'] = t('Last Node:'); |
| 45 |
$block['content'] = _last_node_contents('1'); |
$block['content'] = _last_node_contents('1'); |
| 46 |
break; |
break; |
| 47 |
|
case '2': |
| 48 |
|
$block['subject'] = t('Sticky Last Node:'); |
| 49 |
|
$block['content'] = _last_node_contents('2'); |
| 50 |
|
break; |
| 51 |
default: |
default: |
| 52 |
if (_last_node_blockhide($delta)) { |
if (_last_node_blockhide($delta)) { |
| 53 |
return; |
return; |
| 54 |
} |
} |
| 55 |
$block['subject'] = _last_node_blocknode($op,$delta,&$block); |
$block['subject'] = _last_node_blocknode($op,$delta,$block); |
| 56 |
$block['content'] = _last_node_contents($delta); |
$block['content'] = _last_node_contents($delta); |
| 57 |
break; |
break; |
| 58 |
} |
} |
| 69 |
$node = node_load(arg(1)); |
$node = node_load(arg(1)); |
| 70 |
} |
} |
| 71 |
return $node->type != $type_block ? TRUE : FALSE; |
return $node->type != $type_block ? TRUE : FALSE; |
| 72 |
} |
} |
| 73 |
} |
} |
| 74 |
|
|
| 75 |
function _last_node_blocknode($op,$type_block,&$blocks) { |
function _last_node_blocknode($op,$type_block,&$blocks) { |
| 86 |
if ($op == 'view') { |
if ($op == 'view') { |
| 87 |
if (_last_node_validnode($type_block)) { |
if (_last_node_validnode($type_block)) { |
| 88 |
return variable_get('last_node_labelnode_'. $type_block,t('Last 10 -') .' '. $type_block); |
return variable_get('last_node_labelnode_'. $type_block,t('Last 10 -') .' '. $type_block); |
| 89 |
} |
} |
| 90 |
} |
} |
| 91 |
} |
} |
| 92 |
|
|
| 101 |
$placeholders = implode(',', array_fill(0, count($node), "'%s'")); |
$placeholders = implode(',', array_fill(0, count($node), "'%s'")); |
| 102 |
$result = db_query_range(db_rewrite_sql("SELECT n.nid, n.title FROM {node} n WHERE n.type in ($placeholders) AND n.status = 1 ORDER BY n.created DESC"), $node, 0, 10); |
$result = db_query_range(db_rewrite_sql("SELECT n.nid, n.title FROM {node} n WHERE n.type in ($placeholders) AND n.status = 1 ORDER BY n.created DESC"), $node, 0, 10); |
| 103 |
while ($node = db_fetch_object($result)) { |
while ($node = db_fetch_object($result)) { |
| 104 |
$output .= l($node->title,'node/'. $node->nid) ."<BR>-<BR>"; |
$output .= l($node->title,'node/'. $node->nid) ."<br />-<br />"; |
| 105 |
} |
} |
| 106 |
} |
} |
| 107 |
$output = '<marquee id="last_node-block" direction="up" scrollamount="1" scrolldelay="1" onMouseOver="this.stop()" onMouseOut="this.start()">'. $output .'</marquee>'; |
$output = '<marquee id="last_node-block" direction="up" scrollamount="1" scrolldelay="1" onMouseOver="this.stop()" onMouseOut="this.start()">'. $output .'</marquee>'; |
| 120 |
reset($nodes); |
reset($nodes); |
| 121 |
foreach ($nodes as $key => $value) { |
foreach ($nodes as $key => $value) { |
| 122 |
$title = _last_node_normalize_linkblock($value, $key); |
$title = _last_node_normalize_linkblock($value, $key); |
| 123 |
$output .= html_entity_decode(l($title,'last_node/'. $key, $args)) .'<BR>'; |
$output .= html_entity_decode(l($title,'last_node/'. $key, $args)) .'<br />'; |
| 124 |
} |
} |
| 125 |
} |
} |
| 126 |
drupal_add_css(drupal_get_path("module","last_node") ."/last_node.css"); |
drupal_add_css(drupal_get_path("module","last_node") ."/last_node.css"); |
| 127 |
return $output .'</div></div>'; |
return $output .'</div></div>'; |
| 128 |
} |
} |
| 129 |
|
if ($which_block == '2') { |
| 130 |
|
$node = variable_get('last_node_check',array()); |
| 131 |
|
if (!empty($node)) { |
| 132 |
|
$placeholders = implode(',', array_fill(0, count($node), "'%s'")); |
| 133 |
|
$result = db_query_range(db_rewrite_sql("SELECT n.nid, n.title, n.sticky FROM {node} n WHERE n.type in ($placeholders) AND n.status = 1 AND n.sticky = 1 ORDER BY n.created DESC"), $node, 0, 10); |
| 134 |
|
while ($node = db_fetch_object($result)) { |
| 135 |
|
$output .= l($node->title,'node/'. $node->nid) ."<br />-<br />"; |
| 136 |
|
} |
| 137 |
|
} |
| 138 |
|
$output = '<marquee id="last_node-sticky" direction="up" scrollamount="1" scrolldelay="1" onMouseOver="this.stop()" onMouseOut="this.start()">'. $output .'</marquee>'; |
| 139 |
|
drupal_add_css(drupal_get_path("module","last_node") ."/last_node.css"); |
| 140 |
|
return $output; |
| 141 |
|
} |
| 142 |
if (_last_node_validnode($which_block)) { |
if (_last_node_validnode($which_block)) { |
| 143 |
$result = db_query_range("SELECT n.title, n.nid FROM {node} n WHERE n.status = 1 AND n.type = '%s' ORDER BY n.created DESC", $which_block, 0, 10); |
$result = db_query_range("SELECT n.title, n.nid FROM {node} n WHERE n.status = 1 AND n.type = '%s' ORDER BY n.created DESC", $which_block, 0, 10); |
| 144 |
while ($node = db_fetch_object($result)) { |
while ($node = db_fetch_object($result)) { |
| 150 |
return $output; |
return $output; |
| 151 |
} |
} |
| 152 |
|
|
| 153 |
} |
} |
| 154 |
|
|
| 155 |
//Deprecated |
//Deprecated |
| 156 |
function lastnode_css() { |
function lastnode_css() { |
| 157 |
drupal_add_css(drupal_get_path("module","last_node") ."/last_node.css"); |
drupal_add_css(drupal_get_path("module","last_node") ."/last_node.css"); |
| 158 |
} |
} |
| 159 |
|
|
| 160 |
function lastnode_display($title,$node_type,$numitem = 5) { |
function lastnode_display($title="", $node_type="", $numitem = 5, $alt_text="") { |
| 161 |
$lista = array(); |
$lista = array(); |
| 162 |
|
$args = array(); |
| 163 |
|
|
| 164 |
drupal_add_css(drupal_get_path("module","last_node") ."/last_node.css"); |
drupal_add_css(drupal_get_path("module","last_node") ."/last_node.css"); |
| 165 |
$result = db_query_range("SELECT n.title, n.nid, n.created FROM {node} n WHERE n.status = 1 AND n.type = '%s' ORDER BY n.created DESC", $node_type, 0, $numitem); |
$result = db_query_range("SELECT n.title, n.nid, n.created FROM {node} n WHERE n.status = 1 AND n.type = '%s' ORDER BY n.created DESC", $node_type, 0, $numitem); |
| 168 |
$lista[] = l($node->title ." (". format_date($node->created,'small') .")",'node/'. $node->nid); |
$lista[] = l($node->title ." (". format_date($node->created,'small') .")",'node/'. $node->nid); |
| 169 |
} |
} |
| 170 |
|
|
| 171 |
|
if ($alt_text == '') { |
| 172 |
|
$n = node_get_types(); |
| 173 |
|
$alt_text = $n[$node_type]->description; |
| 174 |
|
} |
| 175 |
|
$args['title'] = $alt_text; |
| 176 |
|
|
| 177 |
$output = theme('item_list',$lista); |
$output = theme('item_list',$lista); |
| 178 |
$output = '<h2 class="page-title"><div class="last_node-linknodetype">'. html_entity_decode(l($title,'last_node/'. $node_type,$args)) .'</div></h2><BR>'. $output; |
$output = '<h2 class="page-title"><div class="last_node-linknodetype">'. html_entity_decode(l($title,'last_node/'. $node_type,$args)) .'</div></h2><br />'. $output; |
| 179 |
|
|
| 180 |
//---Feed RSS |
//---Feed RSS |
| 181 |
$output .= theme('feed_icon',url('last_node/feed/'. $node_type)); |
$output .= theme('feed_icon',url('last_node/feed/'. $node_type)); |
| 182 |
drupal_add_link(array('#rel' => 'alternate', |
drupal_add_link(array('rel' => 'alternate', |
| 183 |
'#type' => 'application/rss+xml', |
'type' => 'application/rss+xml', |
| 184 |
'#title' => t('RSS - blogs'), |
'title' => t('RSS - blogs'), |
| 185 |
'#href' => url("last_node/feed/$node_type"))); |
'href' => url("last_node/feed/$node_type"))); |
| 186 |
|
|
| 187 |
return $output; |
return $output; |
| 188 |
} |
} |
| 189 |
|
|
| 190 |
function lastnode_imgdisplay($title,$node_type,$numitem = 5) { |
function lastnode_imgdisplay($title = "", $node_type = "", $numitem = 5) { |
| 191 |
return lastnode_display(_last_node_normalize_title($title,$node_type),$node_type,$numitem); |
return lastnode_display(_last_node_normalize_title($title,$node_type),$node_type,$numitem); |
| 192 |
} |
} |
| 193 |
|
|
| 194 |
function _last_node_normalize_title($title,$node_type) { |
function _last_node_normalize_title($title,$node_type) { |
| 195 |
$image = variable_get('last_node_imagenode_'. $node_type,''); |
$image = variable_get('last_node_imagenode_'. $node_type,''); |
| 196 |
if ($image) { |
if ($image) { |
| 197 |
$title = " ¤ <img class=\"last_node-imagenode\" src=\"$image\" /> ". $title; |
$title = " ¤ <img class=\"last_node-imagenode\" src=\"$image\" alt=\"$title\" /> ". $title; |
| 198 |
} |
} |
| 199 |
else $title = " ¤ ". $title; |
else $title = " ¤ ". $title; |
| 200 |
return $title; |
return $title; |
| 203 |
function _last_node_normalize_linkblock($title,$node_type) { |
function _last_node_normalize_linkblock($title,$node_type) { |
| 204 |
$image = variable_get('last_node_imagenode_'. $node_type,''); |
$image = variable_get('last_node_imagenode_'. $node_type,''); |
| 205 |
if ($image) { |
if ($image) { |
| 206 |
$title = "<img class=\"last_node-imagelinkblock\" src=\"$image\" /> ". $title; |
$title = "<img class=\"last_node-imagelinkblock\" src=\"$image\" alt=\"$title\" /> ". $title; |
| 207 |
} |
} |
| 208 |
else $title = " ¤ ". $title; |
else $title = " ¤ ". $title; |
| 209 |
return $title; |
return $title; |
| 236 |
$title = variable_get("last_node_labelnode_$value",$value); |
$title = variable_get("last_node_labelnode_$value",$value); |
| 237 |
$items[] = array('path' => "last_node/$value", 'title' => $title, |
$items[] = array('path' => "last_node/$value", 'title' => $title, |
| 238 |
'access' => user_access('access content'), |
'access' => user_access('access content'), |
| 239 |
'type' => MENU_NORMAL_ITEM); |
'type' => MENU_NORMAL_ITEM); |
| 240 |
} |
} |
| 241 |
} |
} |
| 242 |
} |
} |
| 243 |
} |
} |
| 277 |
else drupal_not_found(); |
else drupal_not_found(); |
| 278 |
} |
} |
| 279 |
else { |
else { |
| 280 |
return _last_node_page($type); |
return _last_node_page($type); |
| 281 |
} |
} |
| 282 |
} |
} |
| 283 |
|
|
| 292 |
if (!$type) { |
if (!$type) { |
| 293 |
$node = variable_get('last_node_check', array()); |
$node = variable_get('last_node_check', array()); |
| 294 |
if (!empty($node)) { |
if (!empty($node)) { |
| 295 |
foreach ($node as $key => $value) { |
foreach ($node as $key => $value) { |
| 296 |
if ($value) { |
if ($value) { |
| 297 |
$title = variable_get('last_node_labelnode_'. $value, $value); |
$title = variable_get('last_node_labelnode_'. $value, $value); |
| 298 |
$output .= lastnode_imgdisplay($title, $value); |
$output .= lastnode_imgdisplay($title, $value); |
| 299 |
} |
} |
| 300 |
} |
} |
| 301 |
} |
} |
| 302 |
return $output; |
return $output; |
| 303 |
} |
} |
| 304 |
|
|
| 305 |
drupal_set_title(_last_node_normalize_title(drupal_get_title(), $type)); |
drupal_set_title(_last_node_normalize_title(drupal_get_title(), $type)); |
| 306 |
|
|
| 307 |
$result = pager_query(db_rewrite_sql("SELECT n.nid, n.created FROM {node} n WHERE n.type = '%s' AND n.status = 1 ORDER BY n.created DESC"), variable_get('default_nodes_main', 10), 0, NULL, $type); |
$result = pager_query(db_rewrite_sql("SELECT n.nid, n.created FROM {node} n WHERE n.type = '%s' AND n.status = 1 ORDER BY n.created DESC"), variable_get('default_nodes_main', 10), 0, NULL, $type); |
| 308 |
|
|
| 309 |
while ($node = db_fetch_object($result)) { |
while ($node = db_fetch_object($result)) { |
| 310 |
$output .= node_view(node_load($node), 1); |
$output .= node_view(node_load($node), 1); |
| 311 |
} |
} |
| 324 |
$form["last_node_labelnode_$v"] = array('#type' => 'textfield', |
$form["last_node_labelnode_$v"] = array('#type' => 'textfield', |
| 325 |
'#title' => t('Label for ') . $v, |
'#title' => t('Label for ') . $v, |
| 326 |
'#default_value' => variable_get('last_node_labelnode_'. $v,$v), |
'#default_value' => variable_get('last_node_labelnode_'. $v,$v), |
| 327 |
'#size' => 32,'#maxlength' => 128, |
'#size' => 32,'#maxlength' => 128, |
| 328 |
'#description' => t('It\'s the name for <em>') . $v . t('</em> node type that display in your last_node page')); |
'#description' => t('It\'s the name for <em>') . $v . t('</em> node type that display in your last_node page')); |
| 329 |
|
|
| 330 |
$form["last_node_imagenode_$v"] = array('#type' => 'textfield', |
$form["last_node_imagenode_$v"] = array('#type' => 'textfield', |
| 331 |
'#title' => t('Image for ') . $v .' <em>(Relative path)</em>', |
'#title' => t('Image for ') . $v .' <em>(Relative path)</em>', |
| 333 |
'#size' => 32,'#maxlength' => 128, |
'#size' => 32,'#maxlength' => 128, |
| 334 |
'#description' => t('It\'s the Image associated for <em>') . $v . t('</em> node type that display in your last_node page')); |
'#description' => t('It\'s the Image associated for <em>') . $v . t('</em> node type that display in your last_node page')); |
| 335 |
} |
} |
| 336 |
|
|
| 337 |
$form['last_node_check'] = array('#type' => 'checkboxes', |
$form['last_node_check'] = array('#type' => 'checkboxes', |
| 338 |
'#title' => t('Nodes included when you point at <em>last_node/</em> node and in <em>Last 10</em> block.<BR/>Here active too your block of last 10 nodes for type.'), |
'#title' => t('Nodes included when you point at <em>last_node/</em> node and in <em>Last 10</em> block.<br />Here active too your block of last 10 nodes for type.'), |
| 339 |
'#default_value' => variable_get('last_node_check', array()), |
'#default_value' => variable_get('last_node_check', array()), |
| 340 |
'#options' => $nodes, '#required' => TRUE); |
'#options' => $nodes, '#required' => TRUE); |
| 341 |
|
|
| 342 |
$form['last_node_blockhide'] = array('#type' => 'checkbox', |
$form['last_node_blockhide'] = array('#type' => 'checkbox', |
| 343 |
'#title' => t('<em>Auto-Hide</em> your block Last 10 for type, these will show only for node of same type display'), |
'#title' => t('<em>Auto-Hide</em> your block Last 10 for type, these will show only for node of same type display'), |
| 344 |
'#default_value' => variable_get('last_node_blockhide', FALSE)); |
'#default_value' => variable_get('last_node_blockhide', FALSE)); |
| 345 |
|
|
| 346 |
return system_settings_form($form); |
return system_settings_form($form); |
| 347 |
|
|