/** * Overloads the {@link BedrockNode::get()} method to pipe failures through {@link SilverSmithDefaults} * * @param string The path to the setting * @return BedrockNode */ public function get($setting) { $result = parent::get($setting); if (!$result) { return SilverSmithDefaults::get($setting); } return $result; }
/** * Get some lipsum text * * @todo Move this into local storage so it doesn't use HTTP requests * @param integer The length of the lipsum text, in sentences * @param boolean If true, include html links * @return string */ public static function get_lipsum($length = 1, $rich = false) { $tags = $rich ? "link" : ""; $text = @file_get_contents("http://loripsum.net/api/{$length}/short/{$tags}"); if (!$rich) { $text = strip_tags($text); } return $text && !empty($text) ? $text : SilverSmithDefaults::get('DefaultContent'); }
/** * Gets the code that will instantiate this form field in PHP code * * @return string */ public function getInstantiation() { if (!($yml = $this->getConfig()) || !($content = $yml->getInstantiate())) { $content = SilverSmithDefaults::get('InstantiateField'); } $template = new BedrockTemplate(SilverSmithUtil::tabify(rtrim($content))); $template->bind($this); $inst = $template->render(); $up = $this->getUpdate(); if ($up && !empty($up)) { return $this->getVar() . " = " . $inst; } return $inst; }