private function fillWithDownloadData($releaseContent, $release)
 {
     $fileList = new SimpleListComponent();
     $fileList->setClass("fileList");
     $ddlLinks = new GroupedLinks(new Image("images/icones/ddl.png"));
     $ddlLinks->setClass("ddlLinks");
     $megauploadLinks = new GroupedLinks(new Image("images/icones/megaup.jpg"));
     $megauploadLinks->setClass("megauploadLinks");
     $freeLinks = new GroupedLinks(new Image("images/icones/free.jpg"));
     $freeLinks->setClass("freeLinks");
     $rapidShareLinks = new GroupedLinks(new Image("images/icones/rapidshare.jpg"));
     $rapidShareLinks->setClass("rapidShareLinks");
     $mediaFireLinks = new GroupedLinks(new Image("images/icones/mediafire.jpg", "Mediafire"));
     $mediaFireLinks->setClass("mediaFireLinks");
     $torrentLinks = new GroupedLinks(new Link($release->getTorrentUrl(), new Image("images/icones/torrent.png")));
     $torrentLinks->setClass("torrentLink");
     $fileDescriptors = $release->getFileDescriptors();
     $index = 1;
     foreach ($fileDescriptors as $descriptor) {
         $description = new SimpleTextComponent();
         $path = $descriptor->getFilePath();
         $name = basename($path);
         if (empty($name)) {
             $name = Debug::createWarningTag("aucun fichier renseigné");
         }
         $description->addLine($name);
         $url = "ddl/" . $path;
         $size = "Taille : ";
         try {
             $size .= Format::formatSize(filesize($url));
         } catch (Exception $e) {
             $size .= Debug::createWarningTag("inconnue");
         }
         $size .= " ";
         $description->addComponent($size);
         if ($descriptor->getCRC() !== null) {
             $description->addComponent("CRC : " . $descriptor->getCRC() . " ");
         }
         $id = null;
         if ($release->getProject()->isDoujin()) {
             $pages = "";
             if ($descriptor->getPageNumber() != null) {
                 $n = $descriptor->getPageNumber();
                 $pages = $n . " page" . ($n > 1 ? "s" : null) . " ";
             }
             $description->addComponent($pages);
         } else {
             $array = array();
             if ($descriptor->getVideoCodec() !== null) {
                 $array[] = $descriptor->getVideoCodec()->getName();
                 if ($id == null) {
                     $id = $descriptor->getVideoCodec()->getName();
                 }
             }
             if ($descriptor->getSoundCodec() !== null) {
                 $array[] = $descriptor->getSoundCodec()->getName();
                 if ($id == null) {
                     $id = $descriptor->getSoundCodec()->getName();
                 }
             }
             if ($descriptor->getContainerCodec() !== null) {
                 $array[] = $descriptor->getContainerCodec()->getName();
                 if ($id == null) {
                     $id = $descriptor->getContainerCodec()->getName();
                 }
             }
             $codecs = "";
             if (!empty($array)) {
                 $codecs = "Codecs : " . implode(" ", $array) . " ";
             }
             $description->addComponent($codecs);
         }
         if ($descriptor->getReleaseSource() !== null) {
             $description->addComponent("Source : " . $descriptor->getReleaseSource() . " ");
         }
         if ($descriptor->getID() != null) {
             $id = $descriptor->getID();
         } else {
             if ($id == null) {
                 $id = $index;
             }
         }
         $index++;
         if ($descriptor->getComment() !== null) {
             $description->addLine();
             $comment = new SimpleBlockComponent();
             $comment->setClass("comment");
             $comment->setContent($descriptor->getComment());
             $description->addComponent($comment);
         }
         $description->addLine();
         $description->addLine();
         $fileList->addcomponent($description);
         $linkName = count($fileDescriptors) == 1 ? "Télécharger" : $id;
         $ddlLinks->addLink(new Link($url, $linkName));
         if ($descriptor->getMegauploadUrl() !== null) {
             $megauploadLinks->addLink(new Link($descriptor->getMegauploadUrl(), $linkName));
         }
         if ($descriptor->getFreeUrl() !== null) {
             $freeLinks->addLink(new Link($descriptor->getFreeUrl(), $linkName));
         }
         if ($descriptor->getRapidShareUrl() !== null) {
             $rapidShareLinks->addLink(new Link($descriptor->getRapidShareUrl(), $linkName));
         }
         if ($descriptor->getMediaFireUrl() !== null) {
             $mediaFireLinks->addLink(new Link($descriptor->getMediaFireUrl(), $linkName));
         }
         if ($descriptor->getTorrentUrl() !== null) {
             $torrentLinks->addLink(new Link($descriptor->getTorrentUrl(), $linkName));
         }
     }
     $releaseContent->addComponent(new title("Fichiers"));
     $releaseContent->addComponent($fileList);
     $releaseContent->addComponent(new title("Téléchargements"));
     $list = new SimpleListComponent();
     $list->setClass("linkList");
     $list->addcomponent($ddlLinks);
     if (!$megauploadLinks->isEmpty()) {
         // MU links removed because MU down
         //$list->addComponent($megauploadLinks);
     }
     if (!$freeLinks->isEmpty()) {
         $list->addComponent($freeLinks);
     }
     if (!$rapidShareLinks->isEmpty()) {
         $list->addComponent($rapidShareLinks);
     }
     if (!$mediaFireLinks->isEmpty()) {
         $list->addComponent($mediaFireLinks);
     }
     $list->addComponent($torrentLinks);
     $list->addComponent(new XdccLink());
     $streamingsLinks = new GroupedLinks(new Image("images/icones/streaming.png"));
     $streamingsLinks->setClass("streamingsLinks");
     foreach ($release->getStreamings() as $link) {
         $streamingsLinks->addLink($link);
     }
     if (!$streamingsLinks->isEmpty()) {
         $list->addComponent($streamingsLinks);
     }
     $bonusLinks = new GroupedLinks(new Image("images/icones/bonus.png"));
     $bonusLinks->setClass("bonusLinks");
     foreach ($release->getBonuses() as $link) {
         $bonusLinks->addLink($link);
     }
     if (!$bonusLinks->isEmpty()) {
         $list->addComponent($bonusLinks);
     }
     $releaseContent->addComponent($list);
 }
    public function __construct(News $news)
    {
        $this->setClass("news");
        $title = new Title($news->getTitle(), 2);
        $title->setClass("title");
        $newsUrl = $news->getUrl();
        $this->addComponent(new Link($newsUrl, $title));
        $subtitle = new Title(null, 4);
        $subtitle->setClass("subtitle");
        $time = "Préparée";
        $timestamp = $news->getPublicationTime();
        if ($timestamp !== null) {
            $time = strftime("%d/%m/%Y", $timestamp);
        }
        $subtitle->addComponent($time);
        if (count($news->getAuthors()) > 0) {
            $s = "";
            foreach ($news->getAuthors() as $author) {
                $s .= ", " . $author;
            }
            $subtitle->addComponent(" par " . substr($s, 2));
        }
        $this->addComponent($subtitle);
        $message = new SimpleTextComponent(Format::convertTextToHtml($news->getMessage()));
        $message->setClass("message");
        $message->setContentPinned(true);
        $this->addComponent($message);
        if ($news->isReleasing()) {
            $releases = array();
            foreach ($news->getReleasing() as $release) {
                if ($release instanceof Project) {
                    $pid = $release->getID();
                    if (!array_key_exists($pid, $releases)) {
                        $releases[$pid] = array();
                    } else {
                        // project already listed
                    }
                } else {
                    if ($release instanceof Release) {
                        $pid = $release->getProject()->getID();
                        if (!array_key_exists($pid, $releases)) {
                            $releases[$pid] = array();
                        } else {
                            // array already exists, continue
                        }
                        array_push($releases[$pid], $release->getID());
                    } else {
                        throw new Exception($release . " is not a release nor a project.");
                    }
                }
            }
            $content = '';
            foreach ($releases as $pid => $ids) {
                if (empty($ids)) {
                    $content .= '[release=' . $pid . '|*][/release]';
                } else {
                    $content .= '[release=' . $pid . '|' . implode(",", $ids) . '][/release]';
                }
                $content .= "\n";
            }
            $releasing = new SimpleTextComponent(Format::convertTextToHtml($content));
            $releasing->setLegend('Sorties');
            $releasing->setClass("releases");
            $this->addComponent($releasing);
        }
        $commentId = $news->getCommentID();
        if ($commentId !== null) {
            $commentAccess = new SimpleTextComponent();
            $commentAccess->setClass("comment");
            $commentAccess->addComponent("~ ");
            $commentAccess->addComponent(Link::newWindowLink(new Url("http://commentaires.zerofansub.net/t" . $commentId . ".htm"), "Commentaires"));
            $commentAccess->addComponent(" - ");
            $commentAccess->addComponent(Link::newWindowLink(new Url("http://commentaires.zerofansub.net/posting.php?mode=reply&t=" . $commentId), "Ajouter un commentaire"));
            $commentAccess->addComponent(" ~");
            $this->addComponent($commentAccess);
        }
        $twitterTitle = $news->getTwitterTitle();
        if ($twitterTitle == null) {
            $twitterTitle = "[Zero] " . $news->getTitle();
        }
        $twitterPart = new SimpleTextComponent();
        $twitterPart->setClass("twitter");
        $twitterButton = '<a href="https://twitter.com/share" class="twitter-share-button" data-url="' . $newsUrl->toFullString() . '" data-text="' . $twitterTitle . '" data-via="zero_fansub" data-lang="fr">Tweeter</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>';
        $twitterPart->addComponent($twitterButton);
        $this->addComponent($twitterPart);
        $googlePart = new SimpleTextComponent();
        $googlePart->setClass("google");
        $googleButton = '<div class="g-plusone" data-href="' . $newsUrl->toFullString() . '" data-size="medium"></div>';
        $googlePart->addComponent($googleButton);
        $this->addComponent($googlePart);
        $this->setMetaData('itemscope');
        $this->setMetaData('itemtype', 'http://schema.org/Product');
        $title->setMetaData('itemprop', 'name');
        $message->setMetaData('itemprop', 'description');
        $c = $message->getComponent(0);
        $c = preg_replace('#<img #', '<img itemprop="image"', $c);
        $message->setComponent(0, $c);
        $facebookPart = new SimpleTextComponent();
        $facebookPart->setClass("facebook");
        $facebookButton = '<div class="fb-like" data-href="' . $newsUrl->toFullString() . '" data-send="false" data-layout="button_count" data-width="90" data-show-faces="true"></div>';
        $facebookPart->addComponent($facebookButton);
        $this->addComponent($facebookPart);
    }
 public function addComponent($member)
 {
     if (!$member instanceof TeamMember) {
         throw new Exception('The given element is not a member.');
     }
     $list = new SimpleListComponent();
     $list->setClass("member");
     parent::addComponent($list);
     $image = $member->getImage();
     if ($image->getUrl() != null) {
         $list->addComponent($image);
     }
     $pseudo = $member->getPseudo();
     $list->addComponent("<b>" . $pseudo . "</b>");
     $roles = $member->getRoles();
     $description = "<b>Rôle(s) :</b> ";
     if (!empty($roles)) {
         $isFirst = true;
         foreach ($roles as $role) {
             if ($isFirst) {
                 $description .= ucfirst($role->getName());
                 $isFirst = false;
             } else {
                 $description .= ', ' . $role->getName();
             }
         }
     } else {
         $description .= "Aucun";
     }
     $list->addComponent($description);
     $firstName = $member->getFirstName();
     if ($firstName !== null) {
         $list->addComponent("<b>Prénom :</b> " . $firstName);
     }
     $age = $member->getAge();
     if ($age !== null) {
         if (is_numeric($age)) {
             if ($age > 1000) {
                 $age = time() - $age;
                 $age /= 60 * 60 * 24 * 365.25;
                 $age = floor($age);
             }
             $age = $age . " ans";
         }
         $list->addComponent("<b>Âge :</b> " . $age);
     }
     $location = $member->getLocation();
     if ($location !== null) {
         $list->addComponent("<b>Lieu :</b> " . $location);
     }
     $mail = $member->getMail();
     if ($mail !== null) {
         $wrap = new SimpleTextComponent("<b>Contact :</b> ");
         $wrap->addComponent(new MailLink($mail));
         $list->addComponent($wrap);
     }
     $website = $member->getWebsite();
     if ($website !== null) {
         $wrap = new SimpleTextComponent("<b>Site Web :</b> ");
         $wrap->addComponent($website);
         $list->addComponent($wrap);
     }
 }
 public function __construct(Project $project, $forceDisplay = false)
 {
     $image = new Image('images/series/' . $project->getID() . '.jpg');
     $image->setClass('projectPicture');
     $this->addComponent($image);
     $this->addComponent(new Title("Informations générales", 2));
     if ($project->hasExternalSource()) {
         $subtitle = new Title("Source : ", 4);
         $subtitle->addComponent($project->getExternalSource());
         $this->addComponent($subtitle);
     }
     $array = array(array("Titre Original", $project->getOriginalName()), array("Site officiel", $project->getOfficialWebsite()), array("Année de production", $project->getAiringYear()), array("Studio", $project->getStudio()), array("Auteur", $project->getAuthor()), array("Genre", $project->getGenre()), array("Synopsis", $project->getSynopsis()), array("Coproduction", $project->getCoproduction()), array("Vosta", $project->getVosta()));
     $infos = new SimpleTextComponent();
     $infos->setClass('projectInfos');
     foreach ($array as $data) {
         if ($data[1] !== null) {
             $text = new SimpleTextComponent("<b>" . $data[0] . "</b> ");
             $text->addComponent($data[1]);
             $infos->addLine($text);
         }
     }
     $this->addComponent($infos);
     if ($project->getComment() !== null) {
         $this->addComponent("<p></p>");
         $this->addComponent(new Title("Commentaire", 2));
         $this->addComponent(Format::convertTextToHtml($project->getComment()));
     }
     $this->addComponent("<p></p>");
     $link = Link::newWindowLink("http://zero.xooit.fr/t471-Liens-morts.htm", "Signaler un lien mort");
     $link->setClass('deadLinks');
     $this->addComponent($link);
     $this->addComponent("<p></p>");
     $this->addComponent(new Title($project->isDoujin() ? "Chapitres" : "Épisodes", 2));
     $releases = Release::getAllReleasesForProject($project->getID());
     usort($releases, array('Release', 'idSorter'));
     $list = new SimpleListComponent();
     $list->setClass("releaseList");
     foreach ($releases as $release) {
         $list->addComponent(new ReleaseComponent($release, $forceDisplay));
     }
     $this->addComponent($list);
     $linkedProjects = Project::getProjectsLinkedTo($project);
     if (!empty($linkedProjects)) {
         $this->addComponent("<p></p>");
         $this->addComponent(new Title("Voir aussi", 2));
         $list = new ProjectList();
         foreach ($linkedProjects as $link) {
             $list->addProject($link);
         }
         $list->sortByNames();
         $list = new ProjectListComponent($list);
         $list->useImage(true);
         $this->addComponent($list);
     }
     foreach ($project->getBonuses() as $bonus) {
         $this->addComponent("<p></p>");
         $this->addComponent(new Title("Bonus : " . $bonus->getTitle(), 2));
         $this->addComponent($bonus->getContent());
     }
     $groups = ProjectGroup::getGroupsForProject($project);
     foreach ($groups as $group) {
         foreach ($group->getBonuses() as $bonus) {
             $this->addComponent("<p></p>");
             $this->addComponent(new Title("Bonus : " . $bonus->getTitle(), 2));
             $this->addComponent($bonus->getContent());
         }
     }
     $this->addComponent("<p></p>");
     $url = $project->getDiscussionUrl();
     if ($url == null) {
         $url = new Url("http://zero.xooit.fr/posting.php?mode=reply&t=120");
     }
     $link = Link::newWindowLink($url, new Image("images/interface/avis.png", "Donne ton avis sur le forum !"));
     $link->setClass('discussionLink');
     $this->addComponent($link);
 }