コード例 #1
0
ファイル: LinkTest.php プロジェクト: fruition-sciences/phpfw
 /**
  * @covers Link::__toString
  */
 public function test__toString()
 {
     $title = "fruition sciences";
     $link = $this->link->setTitle($title);
     $actual = $link->__toString();
     $excepted = '<a href="">fruition sciences</a>';
     $this->assertEquals($excepted, $actual);
 }
コード例 #2
0
ファイル: links_bridge.php プロジェクト: vazahat/dudex
 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;
 }
コード例 #3
0
 /**
  * Construct a new dropdown option.
  *
  * @param String $label the text of this dropdown
  * @param String $value the value of this form element
  * @param Link $readonlyLink (optional) a link to render instead of the
  *        label, in readonly mode.
  */
 public function __construct($label, $value, $readonlyLink = null)
 {
     parent::__construct("option");
     $this->set("value", $value);
     $this->setBody($label);
     if ($readonlyLink) {
         $readonlyLink->setTitle($label);
         $this->readonlyLink = $readonlyLink;
     }
 }
コード例 #4
0
ファイル: TableCSS3.php プロジェクト: fruition-sciences/phpfw
 private function showRecordsPerPage()
 {
     $numbers = array(Config::getInstance()->getInt("tablePaging/rowsPerPage", 10), 50, 100, 200);
     if ($this->getPaging()->getTotalRows() < $numbers[0]) {
         return;
     }
     $body = "Show:";
     foreach ($numbers as $number) {
         if ($number == $this->getPaging()->getRecordsPerPage()) {
             $recordsNumber = new HTMLElement("span");
             $recordsNumber->setBody($number);
         } else {
             $recordsNumber = new Link(Href::current());
             $recordsNumber->setParam(PagingInfoPrefs::getPageNumberParamName($this->getName()), floor($this->getPaging()->getFirstRecord() / $number));
             $recordsNumber->setTitle($number)->setParam(PagingInfoPrefs::getRecordsPerPageParamName($this->getName()), $number);
         }
         $body .= $recordsNumber;
         if ($this->getPaging()->getTotalRows() < $number) {
             break;
         }
     }
     $recordsPerPageSpan = new HTMLElement("span");
     $recordsPerPageSpan->set("class", "recordsPerPage");
     $recordsPerPageSpan->setBody($body);
     echo $recordsPerPageSpan;
 }
コード例 #5
0
ファイル: Table.php プロジェクト: fruition-sciences/phpfw
 /**
  * Write the links to the various pages, including the 'prev' and 'next'
  * links.
  */
 protected function writePageLinks()
 {
     $linksCount = Config::getInstance()->getInt("tablePaging/maxLinksCount", 10);
     $pageNumParamName = PagingInfoPrefs::getPageNumberParamName($this->getName());
     $recordsPerPageParamName = PagingInfoPrefs::getRecordsPerPageParamName($this->getName());
     $pageLink = new Link(Href::current());
     $pageLink->set("class", "pageNumber");
     $arrowLink = new Link(Href::current());
     $arrowLink->set("class", "arrows");
     $totalPages = $this->pagingInfo->getTotalPages();
     $lastLinkablePage = min($totalPages, $this->pagingInfo->getPageNumber() + $linksCount);
     $lastLinkIsShown = $lastLinkablePage == $totalPages;
     $i = max($this->pagingInfo->getPageNumber() - $linksCount, 0);
     $firstLinkIsShown = $i == 0;
     if (!$firstLinkIsShown) {
         echo $arrowLink->setTitle("First")->setParam($pageNumParamName, 0);
         echo "&nbsp;|&nbsp;";
     }
     if ($this->pagingInfo->getPageNumber() > 0) {
         echo $arrowLink->setTitle("Previous")->setParam($pageNumParamName, $this->pagingInfo->getPageNumber() - 1);
         echo " ";
     }
     if (!$firstLinkIsShown) {
         echo "...&nbsp;";
     }
     // If there's only one page available, don't write anything
     if ($i == $lastLinkablePage - 1) {
         echo "&nbsp;";
         return;
     }
     while ($i < $lastLinkablePage) {
         if ($i == $this->pagingInfo->getPageNumber()) {
             // Write current page number (not a link)
             $currentPageSpan = new HTMLElement("span");
             $currentPageSpan->set("class", "currentPage");
             $currentPageSpan->setBody($i + 1);
             echo $currentPageSpan;
         } else {
             // Write a link to this page
             $pageLink->setParam($pageNumParamName, $i);
             $pageLink->setTitle($i + 1);
             echo $pageLink;
         }
         echo "&nbsp;";
         $i++;
     }
     if (!$lastLinkIsShown) {
         echo "...";
     }
     //echo ($this->pagingInfo->getFirstRecord()+1) . " - " . ($this->pagingInfo->getFirstRecord() + $this->rowCount) . " of " . $this->pagingInfo->getTotalRows();
     if (!$this->pagingInfo->isLastPage()) {
         echo " ";
         echo $arrowLink->setTitle("Next")->setParam($pageNumParamName, $this->pagingInfo->getPageNumber() + 1);
     }
     if (!$lastLinkIsShown) {
         echo "&nbsp;|&nbsp;";
         echo $arrowLink->setTitle("Last")->setParam($pageNumParamName, $totalPages - 1);
     }
 }