yellow = $yellow; $this->yellow->system->setDefault("metaDefaultImage", "icon"); } // Handle update public function onUpdate($action) { if ($action=="update") { //TODO: remove later, converts old settings $path = $this->yellow->system->get("coreContentDir"); foreach ($this->yellow->toolbox->getDirectoryEntriesRecursive($path, "/^.*\.md$/", true, false) as $entry) { $fileData = $fileDataNew = $this->yellow->toolbox->readFile($entry); $fileDataNew = preg_replace("/SocialtagsImage:/i", "Image:", $fileDataNew); $fileDataNew = preg_replace("/SocialtagsImageAlt:/i", "ImageAlt:", $fileDataNew); if ($fileData!=$fileDataNew) { $modified = $this->yellow->toolbox->getFileModified($entry); if (!$this->yellow->toolbox->deleteFile($entry) || !$this->yellow->toolbox->createFile($entry, $fileDataNew) || !$this->yellow->toolbox->modifyFile($entry, $modified)) { $this->yellow->log("error", "Can't write file '$entry'!"); } } } } } // Handle page extra data public function onParsePageExtra($page, $name) { $output = null; if ($name=="header" && !$page->isError()) { list($imageUrl, $imageAlt) = $this->getImageInformation($page); $locale = $this->yellow->text->getText("languageLocale", $page->get("language")); $output .= "getUrl().$this->yellow->toolbox->getLocationArgs())."\" />\n"; $output .= "\n"; $output .= "\n"; $output .= "getHtml("title")."\" />\n"; $output .= "getHtml("sitename")."\" />\n"; $output .= "getHtml("description")."\" />\n"; $output .= "\n"; $output .= "\n"; } return $output; } // Handle page output data public function onParsePageOutput($page, $text) { $output = null; if ($text && preg_match("/^(.*)(.*)$/s", $text, $matches)) { $output = $matches[1]."".$matches[3]; } return $output; } // Return image information for page public function getImageInformation($page) { if ($page->isExisting("image")) { $name = $page->get("image"); $alt = $page->isExisting("imageAlt") ? $page->get("imageAlt") : $page->get("title"); } elseif (preg_match("/\[image(\s.*?)\]/", $page->getContent(true), $matches)) { list($name, $alt) = $this->yellow->toolbox->getTextArgs(trim($matches[1])); if (empty($alt)) $alt = $page->get("title"); } else { $name = $this->yellow->system->get("metaDefaultImage"); $alt = $page->isExisting("imageAlt") ? $page->get("imageAlt") : $page->get("title"); } if (!preg_match("/^\w+:/", $name)) { $location = $name!="icon" ? $this->yellow->system->get("coreImageLocation").$name : $this->yellow->system->get("coreResourceLocation").$page->get("theme")."-icon.png"; $url = $this->yellow->lookup->normaliseUrl( $this->yellow->system->get("coreServerScheme"), $this->yellow->system->get("coreServerAddress"), $this->yellow->system->get("coreServerBase"), $location); } else { $url = $this->yellow->lookup->normaliseUrl("", "", "", $name); } return array($url, $alt); } }