/** * A widget containing a menu * @param string $id The HTML #id of the element * @param string $class The HTML .class of element * @param string[][] $links The links in the menu * @param string $selected The title of the selected item in the menu * @param HtmlAttributes $args Allows custom html tag arguments to be specified (not recommended) **/ public function __construct($id, $class, $links, $selected = null, $args = null) { HtmlAttributes::Assure($args); $args->Add('id', $id); $args->Add('class', $class); $url = $title = null; $items = array(); foreach ($links as $link) { if (_array::IsLongerThan($link, 1)) { $url = $link[0]; $title = $link[1]; } else { $url = $title = $link; } $linkargs = null; $forcehttps = false; if (_string::StartsWith($title, '_')) { $title = _string::RemovePrefix($title, '_'); $forcehttps = true; } if ($selected != null && $selected == $title) { $linkargs = array('selected' => true); } $items[] = new RTK_Link($url, $title, $forcehttps, $linkargs); } parent::__construct($items, $args); }
public static function Insert($message, $recipe, $id = EMPTYSTRING) { $result = false; if (Site::HasHttps() && Login::IsLoggedIn()) { if (Value::SetAndNotEmpty($message) && Value::SetAndNotNull($recipe)) { $path = 'R=' . $recipe; if ($id != EMPTYSTRING) { if ($stmt = Database::GetLink()->prepare('SELECT `comment_path` FROM `Comment` WHERE `comment_path` LIKE ?;')) { $stmt->bindParam(1, $path, PDO::PARAM_STR, 255); $stmt->execute(); $stmt->bindColumn(1, $result); $stmt->fetch(); $stmt->closeCursor(); if ($result != null && _string::StartsWith($result, $path)) { $path = $result . '>' . $id; } else { $path = null; } } } if ($path != null) { $userid = Login::GetId(); $timestamp = time(); if ($stmt = Database::GetLink()->prepare('INSERT INTO `Comment` (`user_id`, `comment_path`, `comment_contents`, `sent_at`) VALUES (?, ?, ?, ?);')) { $stmt->bindParam(1, $userid, PDO::PARAM_INT); $stmt->bindParam(2, $path, PDO::PARAM_STR, 255); $stmt->bindParam(3, $message, PDO::PARAM_STR, 255); $stmt->bindParam(4, $timestamp, PDO::PARAM_INT); $stmt->execute(); $stmt->closeCursor(); } } } } return $result; }