function parseSkins() { $skinPaths = glob(dirname($this->_file()) . '/skins/*', GLOB_ONLYDIR); lava::currentPlugin($this->_this()); //make sure theme files can access the plugin easily foreach ($skinPaths as $skinPath) { $includePath = $skinPath . '/skin.php'; if (file_exists($includePath)) { $dir = str_replace('\\', '/', $skinPath); $dir = explode('/', $dir); $dir = end($dir); $this->currentSkinSlug = $dir; $skinName = $dir; $skinAuthor = "Undefined"; if ($this->_request("admin")) { //only parse file headers on admin requests $skinHeader = file_get_contents($includePath); if (strpos(substr($skinHeader, 0, 20), '/*') === false) { //the substr prevents the search incorrectly matching the string in code (like on this line) by only searching the top of the file (where the header should be) //File has no header so leave defaults } else { $skinHeader = explode('/*', $skinHeader); $skinHeader = $skinHeader[1]; $skinHeader = explode('*/', $skinHeader); $skinHeader = $skinHeader[0]; $skinHeader = explode("\n", $skinHeader); foreach ($skinHeader as $head) { $head = trim($head); if (!empty($head)) { $head = explode(":", $head); if (count($head == 2)) { $property = strtoupper($head[0]); $value = trim($head[1]); switch ($property) { case 'NAME': case 'TITLE': $skinName = $value; break; case 'AUTHOR': $skinAuthor = $value; break; } } } } } } $this->registerSkin()->setName($skinName)->setAuthor($skinAuthor); include_once $includePath; } } }
static function currentPlugin($thePlugin = null) { if (!is_null($thePlugin)) { self::$currentPlugin = $thePlugin; } return self::$currentPlugin; }
<?php /* Title: Default with options Author: Daniel Chatfield */ $thePlugin = lava::currentPlugin(); $skinUrl = $thePlugin->_skins()->getSkin(__FILE__)->skinUrl(); $thePlugin->_skins()->getSkin(__FILE__)->addSkinSetting("logo")->setName(__("Logo", $thePlugin->_slug()))->setType("image")->setDefault($skinUrl . 'static/images/logo.png')->addTag("is-premium")->addSkinSetting("enable_message")->setName(__("Display a message", $thePlugin->_slug()))->setHelp(__("Set a message to appear above the form. Any urls and email addresses will be converted into links.", $thePlugin->_slug()))->setType("checkbox")->setDefault("off")->settingToggle("message")->addTag("is-premium")->addSkinSetting("message")->setType("textarea")->addTag("no-margin")->addTag("align-center")->addTag("is-premium")->addPresetSkinSetting("custom_css")->addTag("is-premium");