/**
  *
  */
 private function initializePatterns()
 {
     if (refnotes_configuration::getSetting('replace-footnotes')) {
         $entry = '(?:\\(\\(|\\[\\()';
         $exit = '(?:\\)\\)|\\)\\])';
         $id = '@@FNT\\d+|#\\d+';
     } else {
         $entry = '\\[\\(';
         $exit = '\\)\\]';
         $id = '#\\d+';
     }
     $strictName = refnotes_note::getNamePattern('strict');
     $extendedName = refnotes_note::getNamePattern('extended');
     $namespace = refnotes_namespace::getNamePattern('optional');
     $text = '.*?';
     $strictName = '(?:' . $id . '|' . $strictName . ')';
     $fullName = '\\s*(?:' . $namespace . $strictName . '|:' . $namespace . $extendedName . ')\\s*';
     $lookaheadExit = '(?=' . $exit . ')';
     $nameEntry = $fullName . $lookaheadExit;
     $extendedName = '(?:' . $id . '|' . $extendedName . ')';
     $optionalFullName = $namespace . $extendedName . '?';
     $structuredEntry = '\\s*' . $optionalFullName . '\\s*>>' . $text . $lookaheadExit;
     $define = '\\s*' . $optionalFullName . '\\s*>\\s*';
     $optionalDefine = '(?:' . $define . ')?';
     $lookaheadExit = '(?=' . $text . $exit . ')';
     $defineEntry = $optionalDefine . $lookaheadExit;
     $this->entryPattern = $entry . '(?:' . $nameEntry . '|' . $structuredEntry . '|' . $defineEntry . ')';
     $this->exitPattern = $exit;
     $this->handlePattern = '/' . $entry . '\\s*(' . $optionalFullName . ')\\s*(?:>>(.*))?(.*)/s';
 }
Example #2
0
 /**
  * Constructor
  */
 public function __construct($name, $data)
 {
     list($namespace, $name) = refnotes_namespace::parseName($name);
     if (preg_match('/(?:@@FNT|#)(\\d+)/', $name, $match) == 1) {
         $name = intval($match[1]);
     }
     parent::__construct(array('ns' => $namespace, 'name' => $name));
     if ($data != '') {
         $this->parseStructuredData($data);
     }
 }
Example #3
0
 /**
  *
  */
 public static function getNamePattern($type)
 {
     if ($type == 'full-extended' || $type == 'extended') {
         $result = $type == 'full-extended' ? refnotes_namespace::getNamePattern('optional') : '';
         $result .= '[[:alpha:]][\\w.&\\(\\)\\[\\]{}+-]*';
     } else {
         $result = '[[:alpha:]]\\w*';
     }
     return $result;
 }
Example #4
0
 /**
  *
  */
 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']);
         }
     }
 }
Example #5
0
 /**
  *
  */
 public function initializePageNote($data)
 {
     if (isset($data['note-name'])) {
         if (preg_match('/^' . refnotes_note::getNamePattern('full-extended') . '$/', $data['note-name']) == 1) {
             $this->nameParts = refnotes_namespace::parseName($data['note-name']);
         }
         unset($data['note-name']);
     }
     $this->data = $data;
 }
Example #6
0
 /**
  *
  */
 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;
 }
Example #7
0
 /**
  *
  */
 public function add($namespace, $data)
 {
     $style = new refnotes_namespace_style_info($namespace, $data);
     $parent = $style->getInheritedNamespace();
     if ($parent == '' && $namespace->getScopesCount() == 1) {
         /* Default inheritance for the first scope */
         $parent = refnotes_namespace::getParentName($namespace->getName());
     }
     $index = $namespace->getStyleIndex($this->page->findParentNamespace($parent));
     $this->index[$index][] = $style;
 }
Example #8
0
 /**
  *
  */
 protected function createNamespace($name)
 {
     if ($name != ':') {
         $parentName = refnotes_namespace::getParentName($name);
         $parent = $this->getNamespace($parentName);
         $this->namespace[$name] = new refnotes_namespace($name, $parent);
     } else {
         $this->namespace[$name] = new refnotes_namespace($name);
     }
     if (array_key_exists($name, $this->presetStyle)) {
         $this->namespace[$name]->setStyle($this->presetStyle[$name]);
     }
     return $this->namespace[$name];
 }