public function addLink($userId, $href, $title, $description, $thumbnailUrl, $text = null, $addToFeed = true) { if (!$this->isActive()) { return null; } OW::getCacheManager()->clean(array(LinkDao::CACHE_TAG_LINK_COUNT)); $service = LinkService::getInstance(); $url = mb_ereg_match('^http(s)?:\\/\\/', $href) ? $href : 'http://' . $href; $link = new Link(); $eventParams = array('action' => LinkService::PRIVACY_ACTION_VIEW_LINKS, 'ownerId' => OW::getUser()->getId()); $privacy = OW::getEventManager()->getInstance()->call('plugin.privacy.get_privacy', $eventParams); if (!empty($privacy)) { $link->setPrivacy($privacy); } $link->setUserId($userId); $link->setTimestamp(time()); $link->setUrl($url); $link->setDescription(strip_tags($description)); $title = empty($title) ? $text : $title; $link->setTitle(strip_tags($title)); $service->save($link); if ($addToFeed) { $content = array("format" => null, "vars" => array("status" => $text)); if (!empty($thumbnailUrl)) { $content["format"] = "image_content"; $content["vars"]["image"] = $thumbnailUrl; $content["vars"]["thumbnail"] = $thumbnailUrl; } //Newsfeed $event = new OW_Event('feed.action', array('pluginKey' => 'links', 'entityType' => 'link', 'entityId' => $link->getId(), 'userId' => $link->getUserId()), array("content" => $content)); OW::getEventManager()->trigger($event); } return $link->id; }
public function __construct() { parent::__construct(null, new Image("images/icones/xdcc.png")); $url = new Url('index.php'); $url->setQueryVar("page", "xdcc"); parent::setUrl($url); $this->setClass("xdccLink"); }
public function __construct($projectId, $releaseList, $content = null) { if (!is_array($releaseList)) { $releaseList = array($releaseList); } parent::setUrl(new Url()); $this->setProjectId($projectId); $this->setReleaseList($releaseList); if ($content === null) { $release = Release::getRelease($projectId, $releaseList[0]); $content = $release->getCompleteName() . (count($releaseList) > 1 ? "+" : ""); } $this->setContent($content); }
function processNew() { $peer_class = getDefaultConnectionPeer(); foreach (array('url', 'tags') as $var) { if (!$_POST[$var] || !is_string($_POST[$var])) { return false; } } $url = $_POST['url']; $tags = explode(', ', $_POST['tags']); $link = new Link(); $link->setUrl($url); foreach ($tags as $tag) { $link->addTag($tag); } $peer_class->insert($link); return true; }
public function __construct(Release $release, $forceDisplay = false) { $this->addComponent(new Anchor($release->getID())); $link = new Link(null, $release->getCompleteName()); $title = new Title($link); $title->setClass("title"); $this->addComponent($title); if ($release->isReleased() || $forceDisplay) { $this->setClass("released"); $link->setUrl(new Url()); $link->setOnClick("show('" . $release->getID() . "');return(false)"); $releaseContent = new SimpleBlockComponent(); $releaseContent->setID($release->getID()); $releaseContent->setClass("content"); $this->addComponent($releaseContent); $previewImage = null; if ($release->getPreviewUrl() !== null) { try { $pUrl = $release->getPreviewUrl()->toString(); $previewImage = new AutoFloatImage($pUrl); $previewImage->setClass("previewImage"); $description = getimagesize($pUrl); $width = $description[0]; if ($width < 150) { $previewImage->makeRightFloating(); } } catch (ErrorException $ex) { $previewImage = Debug::createWarningTag("Preview introuvable"); } } $releaseContent->addComponent($previewImage); $localizedName = new SimpleBlockComponent(); $localizedName->setClass("localizedName"); if ($release->getLocalizedTitle() !== null) { $localizedName->addComponent(new Title("Nom de l'épisode FR")); $localizedName->addComponent($release->getLocalizedTitle()); } $releaseContent->addComponent($localizedName); $originalName = new SimpleBlockComponent(); $originalName->setClass("originalName"); if ($release->getOriginalTitle() !== null) { $originalName->addComponent(new Title("Nom original")); $originalName->addComponent($release->getOriginalTitle()); } $releaseContent->addComponent($originalName); $synopsis = new SimpleBlockComponent(); $synopsis->setClass("synopsis"); if ($release->getSynopsis() !== null) { $synopsis->addComponent(new Title("Synopsis")); $synopsis->addComponent(Format::convertTextToHtml($release->getSynopsis())); } $releaseContent->addComponent($synopsis); $comment = new SimpleBlockComponent(); $comment->setClass("comment"); if ($release->getComment() !== null) { $comment->addComponent($release->getComment()); } $releaseContent->addComponent($comment); $staff = new SimpleBlockComponent(); $staff->setClass("staff"); $members = $release->getStaffMembers(); if (!empty($members)) { $staff->addComponent(new Title("Staff")); $strings = array(); foreach ($members as $member) { $string = $member->getPseudo(); $roles = $release->getAssignmentFor($member->getID())->getRoles(); if (!empty($roles)) { $strings2 = array(); foreach ($roles as $role) { $strings2[] = $role->getName(); } $string .= " : " . Format::arrayToString($strings2); } $strings[] = $string; } $staff->addComponent(format::arrayToString($strings, " | ")); } $releaseContent->addComponent($staff); if ($release->isLicensed()) { $this->fillWithLicenseData($releaseContent, $release); } else { $this->fillWithDownloadData($releaseContent, $release); } $releaseContent->addComponent(new Pin()); $url = new Url(); $vars = $url->getQueryVars(); if (!isset($vars['show']) || !(strcmp($vars['show'], "*") == 0 || preg_match("#(,|^)" . preg_quote($release->getID()) . "(,|\$)#", $vars['show']) > 0)) { $releaseContent->addComponent("<script type='text/javascript'>show('" . $release->getID() . "');</script>"); } } else { $this->setClass("notReleased"); $link->setUrl(new Url()); $link->addComponent(" - Non disponible"); } }
$db = new ConexionBd(); $db->execute($insert); header("Location: index.php"); } else { echo "Error al crear el enlace"; } } } //Guardar link despues de editar if (strtolower($_POST['accion']) == 'doedit') { $id_link = filter_var($_POST['id_link'], FILTER_SANITIZE_URL); $enlace = filter_var($_POST['enlace'], FILTER_SANITIZE_URL); $descripcion = filter_var($_POST['descripcion'], FILTER_SANITIZE_STRING); $link = new Link($_GET['id_link']); $link->setDescription($descripcion); $link->setUrl($enlace); $link->dbsave(); header("Location: index.php"); } } else { if (isset($_GET['id_link']) && !empty($_GET['id_link']) && isset($_GET['accion'])) { $link = new Link($_GET['id_link']); if ($_GET['accion'] == 'edit') { ?> <form action="#" method="post"> <input type="hidden" name="id_link" value="<?php echo $_GET['id_link']; ?> " /> <p> <label for="codigo">Código</label>
echo "\n----\n"; // Add some links $lnk1 = new Link(); $lnk1->setUrl('http://www.google.com'); $lnk1->addTag('google'); $lnk1->addTag('com'); $lnk2 = new Link(); $lnk2->setUrl('http://www.mongodb.org'); $lnk2->addTag('mongodb'); $lnk2->addTag('org'); $lnk3 = new Link(); $lnk3->setUrl('http://www.ibuildings.com'); $lnk3->addTag('ibuildings'); $lnk3->addTag('com'); $lnk4 = new Link(); $lnk4->setUrl('http://techportal.ibuildings.com/'); $lnk4->addTag('techportal'); $lnk4->addTag('ibuildings'); $lnk4->addTag('com'); $linkPeer->insert($lnk1); $linkPeer->insert($lnk2); $linkPeer->insert($lnk3); $linkPeer->insert($lnk4); // Print the entire database echo "> new entire database :\n"; foreach ($linkPeer->fetchAll() as $link) { echo "{$link}\n"; } echo "\n----\n"; // Print the techportal link echo "> retrieve the techportal link:\n";
<?php $page = PageContent::getInstance(); $page->setClass("havert"); $page->addComponent(new Title("Avertissement", 1)); $page->addComponent(new Image("images/news/avert.jpg")); $page->addComponent(new Title("Vous êtes sur le point d'entrer en mode Hentaï", 2)); $page->addComponent(new SimpleParagraphComponent("Comme son nom l'indique, vous vous apprêtez à regarder plein de machins dégoûtants interdits aux enfants. Mais bon, si vous êtes majeur, vacciné et consentant, on vous y autorise.")); $okLink = new Link(); $okLink->setContent("Montrer les machins dégoutants"); $url = $okLink->getUrl(); $url->removeQueryVar(DISPLAY_H_AVERT); $url->setQueryVar(MODE_H, true); $page->addComponent($okLink); $cancelLink = new Link(Url::indexUrl(), "Garder mon écran propre"); if (isset($_SERVER["HTTP_REFERER"])) { // TODO if the referer is a page needing the H mode, do not use it $cancelLink->setUrl(new Url($_SERVER["HTTP_REFERER"])); } $page->addComponent($cancelLink);