class csl_date in Bibliography Module 7
Same name and namespace in other branches
- 6.2 modules/CiteProc/CSL.inc \csl_date
- 7.2 modules/CiteProc/CSL.inc \csl_date
Hierarchy
- class \csl_collection
- class \csl_element
- class \csl_rendering_element
- class \csl_format
- class \csl_date
- class \csl_format
- class \csl_rendering_element
- class \csl_element
Expanded class hierarchy of csl_date
File
- modules/
CiteProc/ CSL.inc, line 1170 - CiteProc-PHP.
View source
class csl_date extends csl_format {
/**
*
*/
public function init($dom_node, $citeproc) {
$locale_elements = array();
if ($form = $this->form) {
$local_date = $this->citeproc
->get_locale('date_options', $form);
$dom_elem = dom_import_simplexml($local_date[0]);
if ($dom_elem) {
foreach ($dom_elem->childNodes as $node) {
if ($node->nodeType == 1) {
$locale_elements[] = csl_factory::create($node, $citeproc);
}
}
}
foreach ($dom_node->childNodes as $node) {
if ($node->nodeType == 1) {
$element = csl_factory::create($node, $citeproc);
foreach ($locale_elements as $key => $locale_element) {
if ($locale_element->name == $element->name) {
$locale_elements[$key]->attributes = array_merge($locale_element->attributes, $element->attributes);
$locale_elements[$key]->format = $element->format;
break;
}
else {
$locale_elements[] = $element;
}
}
}
}
if ($date_parts = $this->{'date-parts'}) {
$parts = explode('-', $date_parts);
foreach ($locale_elements as $key => $element) {
if (array_search($element->name, $parts) === FALSE) {
unset($locale_elements[$key]);
}
}
if (count($locale_elements) != count($parts)) {
foreach ($parts as $part) {
$element = new csl_date_part();
$element->name = $part;
$locale_elements[] = $element;
}
}
// Now re-order the elements.
foreach ($parts as $part) {
foreach ($locale_elements as $key => $element) {
if ($element->name == $part) {
$this->elements[] = $element;
unset($locale_elements[$key]);
}
}
}
}
else {
$this->elements = $locale_elements;
}
}
else {
parent::init($dom_node, $citeproc);
}
}
/**
*
*/
public function render($data, $mode = NULL) {
$date_parts = array();
$text = '';
if (($var = $this->variable) && isset($data->{$var})) {
if (is_array($data->{$var})) {
$date = $data->{$var};
}
else {
$date = array(
$data->{$var},
);
}
foreach ($this->elements as $element) {
$date_parts[] = $element
->render($date, $mode);
}
$text = implode($this->delimiter, $date_parts);
}
// @code
// else {
// $text = $this->citeproc->get_locale('term', 'no date');
// }
// @endcode
return $this
->format($text);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
csl_collection:: |
protected | property | ||
csl_collection:: |
public | function | ||
csl_date:: |
public | function |
Overrides csl_element:: |
|
csl_date:: |
public | function |
Overrides csl_rendering_element:: |
|
csl_element:: |
protected | property | ||
csl_element:: |
protected | property | ||
csl_element:: |
public | function | ||
csl_element:: |
public | function | ||
csl_element:: |
public | function | ||
csl_element:: |
public | function | ||
csl_element:: |
public | function | ||
csl_element:: |
public | function | ||
csl_element:: |
public | function | ||
csl_element:: |
public | function | ||
csl_format:: |
protected | property | 1 | |
csl_format:: |
protected | property | ||
csl_format:: |
public | function |
Overrides csl_collection:: |
1 |
csl_format:: |
public | function | 5 | |
csl_format:: |
public | function |
Overrides csl_element:: |
2 |