public function add(&$object)
 {
     if ($object instanceof Component) {
         $this->addComponent($object);
         return;
     }
     parent::add($object);
 }
 /**
  * Answer tag cloud of related tags
  * 
  * @param Component $mainScreen
  * @return void
  * @access public
  * @since 4/8/08
  */
 public function getRelatedTagsResult(Component $mainScreen)
 {
     ob_start();
     print "<h3 style='margin-top: 0px; margin-bottom: 0px;'>" . _("Related Tags:") . "</h3>";
     $tag = $this->getTag();
     print TagAction::getTagCloudDiv($tag->getRelatedTags(TAG_SORT_FREQ), 'view', 100);
     $mainScreen->add(new Block(ob_get_clean(), STANDARD_BLOCK), "100%", null, LEFT, TOP);
 }
 public function save()
 {
     if (!isset($_SESSION['logged'])) {
         return call('pages', 'home');
     } else {
         $post_data = $_POST;
         Component::add($post_data);
         return call('components', 'index');
     }
 }
Beispiel #4
0
 /**
  * Adds component to given parent component
  *
  * @param Component $parent
  *
  * @return $this
  */
 public function addTo(Component $parent)
 {
     $parent->add($this);
     $this->parent = $parent;
     return $this;
 }
 /**
  * Parses the input data and returns a correct VFREEBUSY object, wrapped in
  * a VCALENDAR.
  *
  * @return Component
  */
 public function getResult()
 {
     $busyTimes = array();
     foreach ($this->objects as $object) {
         foreach ($object->getBaseComponents() as $component) {
             switch ($component->name) {
                 case 'VEVENT':
                     $FBTYPE = 'BUSY';
                     if (isset($component->TRANSP) && strtoupper($component->TRANSP) === 'TRANSPARENT') {
                         break;
                     }
                     if (isset($component->STATUS)) {
                         $status = strtoupper($component->STATUS);
                         if ($status === 'CANCELLED') {
                             break;
                         }
                         if ($status === 'TENTATIVE') {
                             $FBTYPE = 'BUSY-TENTATIVE';
                         }
                     }
                     $times = array();
                     if ($component->RRULE) {
                         $iterator = new RecurrenceIterator($object, (string) $component->uid);
                         if ($this->start) {
                             $iterator->fastForward($this->start);
                         }
                         $maxRecurrences = 200;
                         while ($iterator->valid() && --$maxRecurrences) {
                             $startTime = $iterator->getDTStart();
                             if ($this->end && $startTime > $this->end) {
                                 break;
                             }
                             $times[] = array($iterator->getDTStart(), $iterator->getDTEnd());
                             $iterator->next();
                         }
                     } else {
                         $startTime = $component->DTSTART->getDateTime();
                         if ($this->end && $startTime > $this->end) {
                             break;
                         }
                         $endTime = null;
                         if (isset($component->DTEND)) {
                             $endTime = $component->DTEND->getDateTime();
                         } elseif (isset($component->DURATION)) {
                             $duration = DateTimeParser::parseDuration((string) $component->DURATION);
                             $endTime = clone $startTime;
                             $endTime->add($duration);
                         } elseif ($component->DTSTART->getDateType() === Property\DateTime::DATE) {
                             $endTime = clone $startTime;
                             $endTime->modify('+1 day');
                         } else {
                             // The event had no duration (0 seconds)
                             break;
                         }
                         $times[] = array($startTime, $endTime);
                     }
                     foreach ($times as $time) {
                         if ($this->end && $time[0] > $this->end) {
                             break;
                         }
                         if ($this->start && $time[1] < $this->start) {
                             break;
                         }
                         $busyTimes[] = array($time[0], $time[1], $FBTYPE);
                     }
                     break;
                 case 'VFREEBUSY':
                     foreach ($component->FREEBUSY as $freebusy) {
                         $fbType = isset($freebusy['FBTYPE']) ? strtoupper($freebusy['FBTYPE']) : 'BUSY';
                         // Skipping intervals marked as 'free'
                         if ($fbType === 'FREE') {
                             continue;
                         }
                         $values = explode(',', $freebusy);
                         foreach ($values as $value) {
                             list($startTime, $endTime) = explode('/', $value);
                             $startTime = DateTimeParser::parseDateTime($startTime);
                             if (substr($endTime, 0, 1) === 'P' || substr($endTime, 0, 2) === '-P') {
                                 $duration = DateTimeParser::parseDuration($endTime);
                                 $endTime = clone $startTime;
                                 $endTime->add($duration);
                             } else {
                                 $endTime = DateTimeParser::parseDateTime($endTime);
                             }
                             if ($this->start && $this->start > $endTime) {
                                 continue;
                             }
                             if ($this->end && $this->end < $startTime) {
                                 continue;
                             }
                             $busyTimes[] = array($startTime, $endTime, $fbType);
                         }
                     }
                     break;
             }
         }
     }
     if ($this->baseObject) {
         $calendar = $this->baseObject;
     } else {
         $calendar = new Component('VCALENDAR');
         $calendar->version = '2.0';
         $calendar->prodid = '-//Sabre//Sabre VObject ' . Version::VERSION . '//EN';
         $calendar->calscale = 'GREGORIAN';
     }
     $vfreebusy = new Component('VFREEBUSY');
     $calendar->add($vfreebusy);
     if ($this->start) {
         $dtstart = new Property\DateTime('DTSTART');
         $dtstart->setDateTime($this->start, Property\DateTime::UTC);
         $vfreebusy->add($dtstart);
     }
     if ($this->end) {
         $dtend = new Property\DateTime('DTEND');
         $dtend->setDateTime($this->start, Property\DateTime::UTC);
         $vfreebusy->add($dtend);
     }
     $dtstamp = new Property\DateTime('DTSTAMP');
     $dtstamp->setDateTime(new \DateTime('now'), Property\DateTime::UTC);
     $vfreebusy->add($dtstamp);
     foreach ($busyTimes as $busyTime) {
         $busyTime[0]->setTimeZone(new \DateTimeZone('UTC'));
         $busyTime[1]->setTimeZone(new \DateTimeZone('UTC'));
         $prop = new Property('FREEBUSY', $busyTime[0]->format('Ymd\\THis\\Z') . '/' . $busyTime[1]->format('Ymd\\THis\\Z'));
         $prop['FBTYPE'] = $busyTime[2];
         $vfreebusy->add($prop);
     }
     return $calendar;
 }
Beispiel #6
0
 /**
  * Add the site content gui components
  * 
  * @param Component $mainScreen
  * @return void
  * @access public
  */
 public function addSiteContent(Component $mainScreen)
 {
     $harmoni = Harmoni::instance();
     if ($this->isAuthorizedToExecute()) {
         // :: Site ::
         $rootSiteComponent = SiteDispatcher::getCurrentRootNode();
         $this->siteGuiComponent = $rootSiteComponent->acceptVisitor($this->getSiteVisitor());
         $mainScreen->add($this->siteGuiComponent);
     } else {
         // Replace the title
         $outputHandler = $harmoni->getOutputHandler();
         $title = "\n\t\t<title>" . _("Unauthorized") . "</title>";
         $outputHandler->setHead(preg_replace("/<title>[^<]*<\\/title>/", $title, $outputHandler->getHead()));
         $mainScreen->add(new Block($this->getUnauthorizedMessage(), ALERT_BLOCK), "100%", null, CENTER, TOP);
     }
 }
Beispiel #7
0
 function testAnotherSerializeOrderProp()
 {
     $prop4s = array('1', '2', '3', '4', '5', '6', '7', '8', '9', '10');
     $comp = new Component('VCARD');
     $comp->__set('SOMEPROP', 'FOO');
     $comp->__set('ANOTHERPROP', 'FOO');
     $comp->__set('THIRDPROP', 'FOO');
     foreach ($prop4s as $prop4) {
         $comp->add('PROP4', 'FOO ' . $prop4);
     }
     $comp->__set('PROPNUMBERFIVE', 'FOO');
     $comp->__set('PROPNUMBERSIX', 'FOO');
     $comp->__set('PROPNUMBERSEVEN', 'FOO');
     $comp->__set('PROPNUMBEREIGHT', 'FOO');
     $comp->__set('PROPNUMBERNINE', 'FOO');
     $comp->__set('PROPNUMBERTEN', 'FOO');
     $comp->__set('VERSION', '2.0');
     $comp->__set('UID', 'FOO');
     $str = $comp->serialize();
     $this->assertEquals("BEGIN:VCARD\r\nVERSION:2.0\r\nSOMEPROP:FOO\r\nANOTHERPROP:FOO\r\nTHIRDPROP:FOO\r\nPROP4:FOO 1\r\nPROP4:FOO 2\r\nPROP4:FOO 3\r\nPROP4:FOO 4\r\nPROP4:FOO 5\r\nPROP4:FOO 6\r\nPROP4:FOO 7\r\nPROP4:FOO 8\r\nPROP4:FOO 9\r\nPROP4:FOO 10\r\nPROPNUMBERFIVE:FOO\r\nPROPNUMBERSIX:FOO\r\nPROPNUMBERSEVEN:FOO\r\nPROPNUMBEREIGHT:FOO\r\nPROPNUMBERNINE:FOO\r\nPROPNUMBERTEN:FOO\r\nUID:FOO\r\nEND:VCARD\r\n", $str);
 }
Beispiel #8
0
 /**
  * Add the footer controls to the main screen gui component
  * 
  * @param object Component $mainScreen
  * @return void
  * @access public
  * @since 4/7/08
  */
 public function addFooterControls(Component $mainScreen)
 {
     // :: Footer ::
     $harmoni = Harmoni::instance();
     $rootSiteComponent = SiteDispatcher::getCurrentRootNode();
     $footer = $mainScreen->add(new Container(new XLayout(), BLANK, 1), $rootSiteComponent->getWidth(), null, CENTER, BOTTOM);
     ob_start();
     print "<div class='seguefooter_left'>";
     // Home
     print "<a href='" . $harmoni->request->quickURL('portal', 'list') . "' title='" . _("List of Segue sites") . "'>";
     print _("home") . "</a> | ";
     // Help LInk
     print Help::link();
     // Site Map
     $siteMapUrl = $harmoni->request->quickURL("view", "map", array('node' => SiteDispatcher::getCurrentNodeId()));
     print " | <a target='_blank' href='" . $siteMapUrl . "'";
     print ' onclick="';
     print "var url = '" . $siteMapUrl . "'; ";
     print "window.open(url, 'site_map', 'width=500,height=600,resizable=yes,scrollbars=yes'); ";
     print "return false;";
     print '"';
     print ">" . _("map") . "</a>";
     // Tracking
     $trackingUrl = $harmoni->request->quickURL("participation", "actions", array('node' => SiteDispatcher::getCurrentNodeId()));
     print " | <a target='_blank' href='" . $trackingUrl . "'";
     print ' onclick="';
     print "var url = '" . $trackingUrl . "'; ";
     print "window.open(url, 'site_map', 'width=500,height=600,resizable=yes,scrollbars=yes'); ";
     print "return false;";
     print '"';
     print ">" . _("track") . "</a>";
     print "</div>";
     $footer->add(new UnstyledBlock(ob_get_clean()), "50%", null, LEFT, BOTTOM);
     $footer->add(new UnstyledBlock(displayAction::getVersionText()), "50%", null, RIGHT, BOTTOM);
 }