add('name', PLUGIN_ENTRYSPLIT_NAME); $propbag->add('description', PLUGIN_ENTRYSPLIT_BLAHBLAH); $propbag->add('stackable', false); $propbag->add('author', 'Garvin Hicking, Tadashi Jokagi, Thomas Werner'); $propbag->add('version', '1.5.6'); $propbag->add('requirements', array( 'serendipity' => '0.8', 'smarty' => '2.6.7', 'php' => '4.1.0' )); $propbag->add('event_hooks', array('entry_display' => true)); $propbag->add('scrambles_true_content', true); $propbag->add('groups', array('BACKEND_EDITOR')); $propbag->add('configuration', array('split_char', 'split_length', 'showbody')); } function introspect_config_item($name, &$propbag) { switch($name) { case 'split_char': $propbag->add('type', 'string'); $propbag->add('name', PLUGIN_ENTRYSPLIT_CHAR); $propbag->add('description', PLUGIN_ENTRYSPLIT_CHAR_DESC); $propbag->add('default', ''); break; case 'split_length': $propbag->add('type', 'string'); $propbag->add('name', PLUGIN_ENTRYSPLIT_LENGTH); $propbag->add('description', PLUGIN_ENTRYSPLIT_LENGTH_DESC); $propbag->add('default', '20000'); break; case 'showbody': $propbag->add('type', 'boolean'); $propbag->add('name', PLUGIN_ENTRYSPLIT_SHOWBODY); $propbag->add('description', ''); $propbag->add('default', true); break; default: return false; } return true; } function generate_content(&$title) { $title = $this->title; } function event_hook($event, &$bag, &$eventData, $addData = null) { $hooks = &$bag->get('event_hooks'); if (isset($hooks[$event])) { switch($event) { case 'entry_display': $evtCount = count($eventData); for ($entryIdx = 0; $entryIdx < $evtCount; ++$entryIdx) { $this->toc_count = 0; $current_page = $this->get_userselected_page(); if (!isset($eventData[$entryIdx])) continue; // Check whether the cache plugin is used. If so, we need to append our karma-voting output // to the cached version, since that one is used instead of the 'extended' key later on. $text = &$this->getFieldReference('extended', $eventData[$entryIdx]); $body_text = &$this->getFieldReference('body', $eventData[$entryIdx]); if(!$addData['extended']) { // The entry url needs to be specified more precisely if the system isn't currently // displaying the current entry. $url = $this->get_entrysplit_url($eventData[$entryIdx]['id'], $eventData[$entryIdx]['title']); } else { // Otherwise the current user-specified URL already contains entry id and title. $url = $this->get_entrysplit_url(); } $split_char = $this->get_config('split_char'); if (strpos($text, $split_char) === false) { $split_char = ''; $text = wordwrap($text, $this->get_config('split_length'), ''); } $parts = explode($split_char, $text); $parts_count = count($parts); // Create table of contents if a quick search for a [TOCx]-tag is successful if ((strpos($text, '[TOC') !== false) || (strpos($body_text, '[TOC') !== false)) { // Create table of contents $this->toc_count = 0; for ($this->header_order = 3; $this->header_order <= 6; ++$this->header_order) { $this->toc = ''; for ($this->split_index = 0; $this->split_index < $parts_count; ++$this->split_index) { $this->add_to_toc($parts[$this->split_index]); } $this->toc .= ''; for ($i = 0; $i < $parts_count; ++$i) { $parts[$i] = str_replace('[TOC'.$this->header_order.']', $this->toc, $parts[$i]); $body_text = str_replace('[TOC'.$this->header_order.']', $this->toc, $body_text); } } } if (!$addData['extended']) { continue; } if ($current_page != 'all') { $text = $parts[$current_page - 1]; } $parts_count++; if ($parts_count <= 2) { return true; } if ($current_page > 1 && !serendipity_db_bool($this->get_config('showbody'))) { $eventData[$entryIdx]['body'] = ''; $eventData[$entryIdx]['properties']['ep_cache_body'] = ''; } $pagination = '