/** * */ public function add($entry) { static $entryType = array('article', 'book', 'booklet', 'conference', 'inbook', 'incollection', 'inproceedings', 'manual', 'mastersthesis', 'misc', 'phdthesis', 'proceedings', 'techreport', 'unpublished'); $type = $entry->getType(); $name = $entry->getName(); if (in_array($type, $entryType)) { if ($this->isValidRefnotesName($name)) { if ($name[0] != ':') { $name = $this->namespace . $name; } $this->entry[] = array_merge(array('note-name' => $name), $entry->getData($this->strings)); } } elseif ($type == 'string') { $data = $entry->getData($this->strings); $name = reset(array_keys($data)); if ($this->isValidStringName($name)) { $this->strings->add($name, $data[$name]); } } elseif ($type == 'comment' && strtolower($name) == 'refnotes') { $data = $entry->getData($this->strings); if (isset($data['namespace']) && $this->isValidRefnotesName($data['namespace'])) { $this->namespace = refnotes_namespace::canonizeName($data['namespace']); } } }
/** * */ private function parseStyles($syntax) { $style = array(); preg_match_all('/([-\\w]+)\\s*:\\s*(.+?)\\s*?(:?[\\n;]|$)/', $syntax, $match, PREG_SET_ORDER); foreach ($match as $m) { $style[$m[1]] = $m[2]; } /* Validate direct-to-html styles */ if (array_key_exists('notes-separator', $style)) { if (preg_match('/(?:\\d+\\.?|\\d*\\.\\d+)(?:%|em|px)|none/', $style['notes-separator'], $match) == 1) { $style['notes-separator'] = $match[0]; } else { $style['notes-separator'] = ''; } } /* Ensure that namespaces are in canonic form */ if (array_key_exists('inherit', $style)) { $style['inherit'] = refnotes_namespace::canonizeName($style['inherit']); } return $style; }