Commit ebddcdaa authored by Ronny López's avatar Ronny López
Browse files

First working copy of the 7.x version.

parent 1dfb1b6f
; $Id$
name = Link
description = Defines simple link field types.
dependencies[] = content
package = CCK
core = 6.x
core = 7.x
files[] = link.module
\ No newline at end of file
......@@ -18,17 +18,58 @@ define('LINK_TARGET_TOP', '_top');
define('LINK_TARGET_USER', 'user');
/**
* Implementation of hook_field_info().
* Implement hook_field_info().
*/
function link_field_info() {
return array(
'link' => array(
'label' => t('Link'),
'description' => t('Store a title, href, and attributes in the database to assemble a link.'),
'settings' => array(
'target' => LINK_TARGET_DEFAULT,
'class' => '',
'rel' => '',
),
'default_widget' => 'text_textfield',
'default_formatter' => 'text_default',
),
);
}
/**
* Implement hook_field_schema().
*/
function link_field_schema($field) {
return array(
'columns' => array(
'url' => array(
'type' => 'varchar',
'length' => 255,
'not null' => FALSE,
'sortable' => TRUE
),
'title' => array(
'type' => 'varchar',
'length' => 255,
'not null' => FALSE,
'sortable' => TRUE
),
'attributes' => array(
'type' => 'text',
'size' => 'medium',
'not null' => FALSE
),
),
);
}
/**
* Implement hook_field_sanitize().
*/
function link_field_sanitize($obj_type, $object, $field, $instance, $langcode, &$items) {
}
/**
* Implementation of hook_field_settings().
*/
......@@ -170,9 +211,9 @@ function theme_link_field_settings($form) {
}
/**
* Implementation of hook_content_is_empty().
* Implement hook_field_is_empty().
*/
function link_content_is_empty($item, $field) {
function link_field_is_empty($item, $field) {
if (empty($item['title']) && empty($item['url'])) {
return TRUE;
}
......@@ -255,7 +296,7 @@ function _link_process(&$item, $delta = 0, $field, $node) {
// if no attributes are set then make sure $item['attributes'] is an empty array - this lets $field['attributes'] override it.
if (empty($item['attributes'])) {
$item['attributes'] = array();
$item['attributes'] = array();
}
// Serialize the attributes array.
......@@ -428,7 +469,7 @@ function link_theme() {
/**
* FAPI theme for an individual text elements.
*/
function theme_link($element) {
function theme_link1($element) {
drupal_add_css(drupal_get_path('module', 'link') .'/link.css');
// Prefix single value link fields with the name of the field.
......@@ -564,6 +605,7 @@ function link_field_formatter_info() {
* Theme function for 'default' text field formatter.
*/
function theme_link_formatter_default($element) {
//drupal_set_message('<pre>'. print_r($element['#item'], TRUE) .'</pre>');
// Display a normal link if both title and URL are available.
if (!empty($element['#item']['display_title']) && !empty($element['#item']['url'])) {
return l($element['#item']['display_title'], $element['#item']['url'], $element['#item']);
......
......@@ -142,40 +142,4 @@ class LinkAttributeCrudTest extends ContentCrudTestCase {
$this->assertLinkOnNode($field['field_name'], l('Test Link', 'http://www.example.com', array('attributes' => array('class' => 'test-class'))));
}
function testLinkWithNoFollowOnField() {
$this->acquireContentTypes(1);
$field_settings = array(
'type' => 'link',
'widget_type' => 'link',
'type_name' => $this->content_types[0]->name,
'attributes' => array(
'class' => '',
'target' => 'default',
'rel' => 'nofollow',
),
);
$field = $this->createField($field_settings, 0);
//$this->pass('<pre>'. print_r($field, TRUE) .'</pre>');
$field_db_info = content_database_info($field);
$this->acquireNodes(2);
$node = node_load($this->nodes[0]->nid);
$node->promote = 1; // We want this to show on front page for the teaser test.
$node->{$field['field_name']}[0] = $this->createLink('http://www.example.com', 'Test Link');
node_save($node);
// Does this display on the node page?
$this->drupalGet('node/'. $this->nodes[0]->nid);
$this->outputScreenContents('Link field with class', 'link_');
$this->assertLinkOnNode($field['field_name'], l('Test Link', 'http://www.example.com', array('attributes' => array('rel' => 'nofollow'))));
// Does this display on the front page?
$this->drupalGet('<front>');
// reset the zebra!
$this->zebra = 0;
$this->assertLinkOnNode($field['field_name'], l('Test Link', 'http://www.example.com', array('attributes' => array('rel' => 'nofollow'))));
}
}
\ No newline at end of file
......@@ -3,7 +3,7 @@
# LANGUAGE translation of Drupal (general)
# Copyright YEAR NAME <EMAIL@ADDRESS>
# Generated from files:
# link.module,v 1.24.4.1 2009/07/04 19:07:42 jcfiala
# link.module,v 1.24.4.5 2009/09/25 02:31:37 herc
# link.info,v 1.2 2008/03/31 06:50:42 quicksketch
# link_views_handler_argument_target.inc,v 1.1.4.2 2009/07/04 19:07:42 jcfiala
# link.views.inc,v 1.1.4.2 2009/07/04 19:07:42 jcfiala
......@@ -13,7 +13,7 @@
msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"POT-Creation-Date: 2009-10-31 21:04+0100\n"
"POT-Creation-Date: 2009-10-08 00:09+0200\n"
"PO-Revision-Date: YYYY-mm-DD HH:MM+ZZZZ\n"
"Last-Translator: NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <EMAIL@ADDRESS>\n"
......@@ -22,171 +22,171 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
#: link.module:21;565 link.info:0
#: link.module:26;591 link.info:0
msgid "Link"
msgstr ""
#: link.module:22
#: link.module:27
msgid "Store a title, href, and attributes in the database to assemble a link."
msgstr ""
#: link.module:39
#: link.module:44
msgid "Optional URL"
msgstr ""
#: link.module:42
#: link.module:47
msgid "If checked, the URL field is optional and submitting a title alone will be acceptable. If the URL is ommitted, the title will be displayed as plain text."
msgstr ""
#: link.module:46
#: link.module:51
msgid "Optional Title"
msgstr ""
#: link.module:47
#: link.module:52
msgid "Required Title"
msgstr ""
#: link.module:48
#: link.module:53
msgid "Static Title: "
msgstr ""
#: link.module:49
#: link.module:54
msgid "No Title"
msgstr ""
#: link.module:54
#: link.module:59
msgid "Link Title"
msgstr ""
#: link.module:57
#: link.module:62
msgid "If the link title is optional or required, a field will be displayed to the end user. If the link title is static, the link will always use the same title. If <a href=\"http://drupal.org/project/token\">token module</a> is installed, the static title value may use any other node field as its value. Static and token-based titles may include most inline XHTML tags such as <em>strong</em>, <em>em</em>, <em>img</em>, <em>span</em>, etc."
msgstr ""
#: link.module:72
#: link.module:77
msgid "Placeholder tokens"
msgstr ""
#: link.module:73
#: link.module:78
msgid "The following placeholder tokens can be used in both paths and titles. When used in a path or title, they will be replaced with the appropriate values."
msgstr ""
#: link.module:81
#: link.module:86
msgid "Allow user-entered tokens"
msgstr ""
#: link.module:83
#: link.module:88
msgid "Checking will allow users to enter tokens in URLs and Titles on the node edit form. This does not affect the field settings on this page."
msgstr ""
#: link.module:92
#: link.module:97
msgid "URL Display Cutoff"
msgstr ""
#: link.module:94
#: link.module:99
msgid "If the user does not include a title for this link, the URL will be used as the title. When should the link title be trimmed and finished with an elipsis (&hellip;)? Leave blank for no limit."
msgstr ""
#: link.module:100
#: link.module:105
msgid "Default (no target attribute)"
msgstr ""
#: link.module:101
#: link.module:106
msgid "Open link in window root"
msgstr ""
#: link.module:102
#: link.module:107
msgid "Open link in new window"
msgstr ""
#: link.module:103
#: link.module:108
msgid "Allow the user to choose"
msgstr ""
#: link.module:110
#: link.module:115
msgid "Link Target"
msgstr ""
#: link.module:116
#: link.module:121
msgid "Rel Attribute"
msgstr ""
#: link.module:117
#: link.module:122
msgid "When output, this link will have this rel attribute. The most common usage is <a href=\"http://en.wikipedia.org/wiki/Nofollow\">rel=&quot;nofollow&quot;</a> which prevents some search engines from spidering entered links."
msgstr ""
#: link.module:125
#: link.module:130
msgid "Additional CSS Class"
msgstr ""
#: link.module:126
#: link.module:131
msgid "When output, this link will have have this class attribute. Multiple classes should be separated by spaces."
msgstr ""
#: link.module:133
#: link.module:138
msgid "A default title must be provided if the title is a static value"
msgstr ""
#: link.module:195
#: link.module:197
msgid "At least one title or URL must be entered."
msgstr ""
#: link.module:269
#: link.module:276
msgid "Not a valid URL."
msgstr ""
#: link.module:273
#: link.module:280
msgid "Titles are required for all links."
msgstr ""
#: link.module:278
#: link.module:285
msgid "You cannot enter a title without a link url."
msgstr ""
#: link.module:469
#: link.module:488
msgid "URL"
msgstr ""
#: link.module:478 views/link_views_handler_argument_target.inc:31
#: link.module:497 views/link_views_handler_argument_target.inc:31
msgid "Title"
msgstr ""
#: link.module:487
#: link.module:513
msgid "Open URL in a New Window"
msgstr ""
#: link.module:501
#: link.module:527
msgid "Title, as link (default)"
msgstr ""
#: link.module:506
#: link.module:532
msgid "URL, as link"
msgstr ""
#: link.module:511
#: link.module:537
msgid "URL, as plain text"
msgstr ""
#: link.module:516
#: link.module:542
msgid "Short, as link with title \"Link\""
msgstr ""
#: link.module:521
#: link.module:547
msgid "Label, as link with label as title"
msgstr ""
#: link.module:526
#: link.module:552
msgid "Separate title and URL"
msgstr ""
#: link.module:594
#: link.module:620
msgid "Link URL"
msgstr ""
#: link.module:595
#: link.module:621
msgid "Link title"
msgstr ""
#: link.module:596
#: link.module:622
msgid "Formatted html link"
msgstr ""
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment