updated core to 7.58 (right after the site was hacked)

This commit is contained in:
2018-04-20 23:48:40 +02:00
parent 18f4aba146
commit 9344a61b61
711 changed files with 99690 additions and 480 deletions

View File

@@ -0,0 +1,12 @@
name = RDF Example
description = Demonstrates an RDF mapping using the RDF mapping API.
package = Example modules
core = 7.x
files[] = rdf_example.test
; Information added by Drupal.org packaging script on 2016-09-18
version = "7.x-1.x-dev"
core = "7.x"
project = "examples"
datestamp = "1474218553"

View File

@@ -0,0 +1,129 @@
<?php
/**
* @file
* Install file for RDF Example module.
*
* To demonstrate hook_rdf_mapping, this module creates it's own node type. For
* more information on creating node types, see Node Example.
*/
/**
* Implements hook_install().
*
* - Create photo, summary fields.
* - Create photo, summary instances.
*
* @see node_type_set_defaults()
* @see field_info_instance()
* @see field_update_instance()
* @see field_create_field()
* @see field_create_instance()
*
* @ingroup rdf_example
*/
function rdf_example_install() {
// Use get_t() to get the name of our localization function for translation
// during install, when t() is not available.
$t = get_t();
// Define the node type.
$rdf_example = array(
'type' => 'recipe',
'name' => $t('Recipe'),
'base' => 'node_content',
'description' => $t('The recipe node is defined to demonstrate RDF mapping.'),
);
// Set additional defaults and save the content type.
$content_type = node_type_set_defaults($rdf_example);
node_type_save($content_type);
// Create all the fields we are adding to our content type.
// http://api.drupal.org/api/function/field_create_field/7
foreach (_rdf_example_installed_fields() as $field) {
field_create_field($field);
}
// Create all the instances for our fields.
// http://api.drupal.org/api/function/field_create_instance/7
foreach (_rdf_example_installed_instances() as $instance) {
$instance['entity_type'] = 'node';
$instance['bundle'] = $rdf_example['type'];
field_create_instance($instance);
}
}
/**
* Return a structured array defining the fields created by this content type.
*
* @ingroup rdf_example
*/
function _rdf_example_installed_fields() {
$t = get_t();
return array(
'recipe_photo' => array(
'field_name' => 'recipe_photo',
'cardinality' => 1,
'type' => 'image',
),
'recipe_summary' => array(
'field_name' => 'recipe_summary',
'cardinality' => 1,
'type' => 'text',
'settings' => array(
'max_length' => 500,
),
),
);
}
/**
* Return a structured array defining the instances for this content type.
*
* @ingroup rdf_example
*/
function _rdf_example_installed_instances() {
$t = get_t();
return array(
'recipe_photo' => array(
'field_name' => 'recipe_photo',
'label' => $t('Photo of the prepared dish'),
),
'recipe_summary' => array(
'field_name' => 'recipe_summary',
'label' => $t('Short summary describing the dish'),
'widget' => array(
'type' => 'text_textarea',
),
),
);
}
/**
* Implements hook_uninstall().
*
* @ingroup rdf_example
*/
function rdf_example_uninstall() {
// Delete recipe content.
$sql = 'SELECT nid FROM {node} n WHERE n.type = :type';
$result = db_query($sql, array(':type' => 'recipe'));
$nids = array();
foreach ($result as $row) {
$nids[] = $row->nid;
}
node_delete_multiple($nids);
// Delete field instances for now.
// Check status of http://drupal.org/node/1015846
$instances = field_info_instances('node', 'recipe');
foreach ($instances as $instance_name => $instance) {
field_delete_instance($instance);
}
// Delete node type.
node_type_delete('recipe');
field_purge_batch(1000);
}

View File

@@ -0,0 +1,86 @@
<?php
/**
* @file
* This is an example outlining how a module can be used to define RDF mappings.
* We define mappings for a node type defined in this module. We also customize
* mappings for a node type that is defined in another module, node_example.
*/
/**
* @defgroup rdf_example Example: RDF
* @ingroup examples
* @{
* Example RDF Mapping.
*/
/**
* Implements hook_rdf_mapping().
*
* This hook should only be used to define the RDF mapping for an entity or
* bundle that has been defined by this module. On installation, this mapping
* will be saved to the database. To alter anything in this mapping after module
* installation (or to alter bundles defined in another module), the RDF CRUD
* functions should be used, as shown below.
*/
function rdf_example_rdf_mapping() {
return array(
array(
'type' => 'node',
'bundle' => 'recipe',
'mapping' => array(
'rdftype' => array('v:Recipe'),
// We don't use the default bundle mapping for title. Instead, we add
// the v:name property. We still want to use dc:title as well, though,
// so we include it in the array.
'title' => array(
'predicates' => array('dc:title', 'v:name'),
),
'recipe_summary' => array(
'predicates' => array('v:summary'),
),
// The photo URI isn't a string but instead points to a resource, so we
// indicate that the attribute type is rel. If type isn't specified, it
// defaults to property, which is used for string values.
'recipe_photo' => array(
'predicates' => array('v:photo'),
'type' => 'rel',
),
),
),
);
}
/**
* Implements hook_rdf_namespaces().
*
* This hook should be used to define any prefixes used by this module that are
* not already defined in core by rdf_rdf_namespaces.
*
* @see hook_rdf_namespaces()
*/
function rdf_example_rdf_namespaces() {
return array(
// Google's namespace for their custom vocabularies.
'v' => 'http://rdf.data-vocabulary.org/#',
);
}
/**
* Implements hook_help().
*/
function rdf_example_help($path, $arg) {
switch ($path) {
case 'examples/rdf_example':
return "<p>" . t(
"The RDF Example module provides RDF mappings for a custom node type and
alters another node type's RDF mapping.
You can check your RDF using a <a href='!parser'>parser</a> by copying
and pasting your HTML source code into the box. For clearest results,
use Turtle as your output format.",
array('!parser' => url('http://www.w3.org/2007/08/pyRdfa/#distill_by_input'))
) . "</p>";
}
}
/**
* @} End of "defgroup rdf_example".
*/

View File

@@ -0,0 +1,55 @@
<?php
/**
* @file
* Tests for rdf.module.
*/
/**
* Test RDFa markup generation.
*
* @ingroup rdf_example
*/
class RdfExampleRdfaMarkupTestCase extends DrupalWebTestCase {
/**
* {@inheritdoc}
*/
public static function getInfo() {
return array(
'name' => 'RDFa markup',
'description' => 'Test RDFa markup generation.',
'group' => 'Examples',
);
}
/**
* {@inheritdoc}
*/
public function setUp() {
parent::setUp('rdf', 'field_test', 'rdf_example');
}
/**
* Test whether RDF mapping is define in markup.
*
* Create a recipe node and test whether the RDF mapping defined for this
* bundle is reflected in the markup.
*/
public function testAttributesInMarkup() {
$node = $this->drupalCreateNode(array('type' => 'recipe'));
$this->drupalGet('node/' . $node->nid);
$iso_date = date('c', $node->changed);
$url = url('node/' . $node->nid);
// The title is mapped to dc:title and v:name and is exposed in a meta tag
// in the header.
$recipe_title = $this->xpath("//span[contains(@property, 'dc:title') and contains(@property, 'v:name') and @content='$node->title']");
$this->assertTrue(!empty($recipe_title), 'Title is exposed with dc:title and v:name in meta element.');
// Test that the type is applied and that the default mapping for date is
// used.
$recipe_meta = $this->xpath("//div[(@about='$url') and (@typeof='v:Recipe')]//span[contains(@property, 'dc:date') and contains(@property, 'dc:created') and @datatype='xsd:dateTime' and @content='$iso_date']");
$this->assertTrue(!empty($recipe_meta), 'RDF type is present on post. Properties dc:date and dc:created are present on post date.');
}
}