Esempio n. 1
0
 /**
  * Inline Plugin Main Function
  */
 function inline()
 {
     static $tagging = FALSE;
     if (func_num_args() == 0) {
         return 'tag(): no argument(s). ';
     }
     global $vars, $defaultpage;
     $page = isset($vars['page']) ? $vars['page'] : $defaultpage;
     $args = func_get_args();
     array_pop($args);
     // drop {}
     $tags = $args;
     $tags = sonots::trim_array($tags, true, true);
     $pkwk_tag = new PluginSonotsTag();
     if ($tagging) {
         // 2nd call
         $pkwk_tag->add_tags($page, $tags);
     } elseif (isset($vars['preview']) || isset($vars['realview']) || sonots::is_page_newer($page, PluginSonotsTag::get_tags_filename($page))) {
         $pkwk_tag->save_tags($page, $tags);
         $tagging = TRUE;
     }
     return $this->display_tagging($tags);
 }
Esempio n. 2
0
 /**
  * True Constructor
  *
  * @access private
  * @param string $page
  * @param boolean $usecache
  */
 function init($page, $usecache)
 {
     if (!$usecache) {
         $this->construct_toc($page);
         return;
     }
     // use cache
     $cachefile = $this->syntax['cachefile']($page);
     // check whether renewing is required or not
     // renew cache if one of including pages are newer than cache
     $renew = false;
     if (sonots::is_page_newer($page, $cachefile, true)) {
         $renew = true;
     } else {
         // check all including pages too
         // including pages are obtained from cache
         $toc = unserialize(file_get_contents($cachefile));
         $pages = array_keys($toc->includes);
         for ($i = 1; $i < count($pages); ++$i) {
             // first is the current page, already done
             if (sonots::is_page_newer($pages[$i], $cachefile)) {
                 $renew = true;
                 break;
             }
         }
     }
     if ($renew) {
         // recreate and write
         $this->construct_toc($page);
         $contents = serialize($this);
         file_put_contents($cachefile, $contents);
     } else {
         // read from cache
         // cache is already read
         PluginSonotsToc::shallow_copy($toc, $this);
         $this->usecache = $usecache;
     }
 }