Example #1
0
 public function getPaginationLinks($pageNumber, $num, $totalCount, $topBottom)
 {
     $mainTag = new Div();
     $catalogLink = new CatalogLink();
     $dots = false;
     $topBottomStyle = $topBottom == 'bottom' ? 'link_next_prev_bottom' : '';
     if ($totalCount != 0) {
         $amountPages = ceil($totalCount / $num);
         if ($pageNumber > 0 && $pageNumber <= $amountPages) {
             $mainTag->addStyleClasses(["pagination_bar", "right_top_bar", $topBottomStyle]);
             $brokerTag = new Div();
             $mainTag->addChild($brokerTag);
             $tagCenterContainer = new Span();
             if ($pageNumber != 1) {
                 $tagPrevious = new A();
                 $tagPrevious->addStyleClasses(["f-16", "text_non_select", "link_style", "link_next_prev", "input_hover", "prev_link"]);
                 $tagPrevious->addAttribute("href", URLBuilder::getCatalogLinkPrev($pageNumber, $num));
                 $text = new Div();
                 $text->addStyleClass("text");
                 $text->addChild("назад");
                 $arrow = new Div();
                 $arrow->addStyleClass("arrow");
                 $tagCenterContainer->addChild($tagPrevious->addChildList([$arrow, $text]));
             }
             $brokerTag->addChild($tagCenterContainer);
             $tagCenterContainer->addStyleClasses(["numeric_links", "f-15"]);
             for ($currentRenderPage = 1; $currentRenderPage <= $amountPages; $currentRenderPage++) {
                 if ($currentRenderPage < 2 || $currentRenderPage > $pageNumber - $this->linksGroupCount && $currentRenderPage < $pageNumber + $this->linksGroupCount || $currentRenderPage > $amountPages - 1) {
                     $dots = false;
                     if ($currentRenderPage != $pageNumber) {
                         $tagCenterContainer->addChild($catalogLink->getLink($currentRenderPage, $num));
                     } else {
                         $emptyLinkView = $catalogLink->getEmptyLink($pageNumber);
                         $emptyLinkView->addStyleClass("f-16");
                         $tagCenterContainer->addChild($emptyLinkView);
                     }
                 } else {
                     if (!$dots) {
                         $dots = true;
                         $tagCenterContainer->addChild($catalogLink->get3dots());
                     }
                 }
             }
             if ($pageNumber != $amountPages) {
                 $tagNext = new A();
                 $tagNext->addStyleClasses(["f-16", "text_non_select", "link_style", "input_hover", "link_next_prev", "next_link"]);
                 $tagNext->addAttribute("href", URLBuilder::getCatalogLinkNext($pageNumber, $num));
                 $text = new Div();
                 $text->addStyleClass("text");
                 $text->addChild("вперед");
                 $arrow = new Div();
                 $arrow->addStyleClass("arrow");
                 $tagCenterContainer->addChild($tagNext->addChildList([$text, $arrow]));
             }
         }
     }
     return $mainTag;
 }
function twitterBadge($userEmail, $userPassword, $count = 4)
{
    $json = new Services_JSON();
    // Create the twitter Cacher object to pull feed
    // Password is needed in case feed is protected
    // HTTP Basic Auth hasn't been deprecated...yet...so...lazy wins for now
    $tc = new TwitterCacher($userEmail, $userPassword);
    $tc->setUserAgent("Mozilla/5.0 (compatible; TwitterCacher/1.0; +http://www.kolich.com)");
    //echo '<!-- ' . $tc->getUserTimeline(4) . ' -->';
    //Create a timeline object of the feed (pull from live if old)
    $timeline = $json->decode($tc->getUserTimeline($count));
    if (!$timeline) {
        return '<p>Error locating tweets.</p>';
    }
    // Create unorderer list of tweets (see gagawa module)
    $ul = new Ol();
    foreach ($timeline as $tweet) {
        $text = $tweet->text;
        //Format date as 5 min ago, 2 hours ago, etc.
        $date = distance_of_time_in_words(strtotime($tweet->created_at)) . ' ago';
        // Tweet source, i.e. twhril, tweetie, tweetdeck, etc.
        // $source = $tweet->source;
        // Generate direct link to tweet
        $tweetid = $tweet->id;
        $screenname = $tweet->user->screen_name;
        $tweetlink = 'http://twitter.com/' . $screenname . '/status/' . $tweetid;
        // Turn links into links
        $text = eregi_replace('(((f|ht){1}tp://)[-a-zA-Z0-9@:%_\\+.~#?&//=]+)', '<a href="\\1" target="_blank">\\1</a>', $text);
        // Turn twitter @username into links to the users Twitter page
        $text = preg_replace('/(^|\\s)@(\\w+)/', '\\1<a href="http://www.twitter.com/\\2">@\\2</a>', $text);
        // Turn #hashtags into searches
        $text = preg_replace('/(^|\\s)#(\\w+)/', '\\1<a href="http://search.twitter.com/search?q=%23\\2">#\\2</a>', $text);
        // Personal Formatting, see Gagawa for documentaiton.
        // <li>Tweet Text <span>(<a href="linktotweet">some time ago</a>)<span></li>
        $li = new Li();
        $ul->appendChild($li);
        $li->appendChild(new Text($text . ' ('));
        $span = new Span();
        $link = new A();
        $link->setHref($tweetlink);
        $link->appendChild(new Text($date));
        $span->appendChild($link);
        $li->appendChild($span);
        $li->appendChild(new Text(')'));
    }
    //end foreach( $timeline as $tweet )
    // Returns the stack of li's enclosed by ul
    return $ul->write();
}
 public function testRenderWithSingleContainerUnordered()
 {
     $list = ListElement::createUnordered()->addItem(ListItem::create()->appendText(Paragraph::create()->appendText('Item 1')))->addItem(ListItem::create()->appendText(Div::create()->appendText('Item 2')))->addItem(ListItem::create()->appendText(Span::create()->appendText('Item 3')));
     $expected = '<ul>' . '<li><p>Item 1</p></li>' . '<li><div>Item 2</div></li>' . '<li><span>Item 3</span></li>' . '</ul>';
     $rendered = $list->render();
     $this->assertEquals($expected, $rendered);
 }
Example #4
0
 private function createRightEarBar()
 {
     $svg = new Svg();
     $earRect = new Polygon();
     $earTriangl = new Polygon();
     $svg->addChild($earRect);
     $svg->addChild($earTriangl);
     $mainSpan = new Span();
     $mainSpan->addChild($svg);
     $mainSpan->addStyleClass("right_ear");
     $earTriangl->addAttribute("points", "0,0   0,10  10,10");
     $earTriangl->addAttribute("style", "stroke:#ade681; fill:#ade681; stroke-width: 1;");
     $earRect->addAttribute("points", "0,10   10,10  10,40 0,40");
     $earRect->addAttribute("style", "stroke:#88cc55; fill:#88cc55; stroke-width: 1;");
     return $mainSpan;
 }
Example #5
0
 public static function createNote($text, $link)
 {
     $note = new A();
     $note->addStyleClass("note");
     $textWrapper01 = new Div();
     $textWrapper = new Span();
     $textWrapper->addChild($text);
     $textWrapper01->addChild($textWrapper);
     $note->addChild($textWrapper01);
     if (strlen($link) > 0) {
         $note->addAttribute("href", $link);
         $note->addStyleClasses(["hover_text_underline"]);
     } else {
         $note->addStyleClasses(["cursor_default"]);
     }
     return $note;
 }
Example #6
0
 /**
  * @param RenderAPI  $renderApi
  * @param Unit       $unit
  * @param ModuleInfo $moduleInfo
  */
 public function renderContent($renderApi, $unit, $moduleInfo)
 {
     $formSend = false;
     $this->http = new \Request();
     $form = new \Form();
     $honeyPotComponent = new \HoneyPotComponent();
     $this->formSubmit = new \FormSubmit();
     $postRequest = $this->formSubmit->getPostValues();
     $elementProperties = $form->getElementProperties();
     $elementProperties->setId("form" . str_replace("-", "", $unit->getId()));
     $elementProperties->addAttribute('action', $_SERVER['REQUEST_URI'] . '#' . $unit->getId());
     $elementProperties->addAttribute('method', 'post');
     $elementProperties->addAttribute('enctype', 'multipart/form-data');
     $form->add($honeyPotComponent->getHoneyPot());
     $form->add($honeyPotComponent->getFormUnitIdentifier($unit->getId()));
     if ($this->formSubmit->isValid($renderApi, $unit) && count($postRequest) > 0 && $honeyPotComponent->isValidHoneyPot($postRequest) && $this->hasValidFormData($renderApi, $unit)) {
         $this->formSubmit->setFieldLabelsToFormValueSet($renderApi);
         try {
             $this->sentEmail($renderApi, $unit, $postRequest);
             $formSend = true;
         } catch (\Exception $e) {
             $errorText = new \Span();
             $errorText->setContent("Unable to send email:<br />" . $e->getMessage());
             $errorContainer = new \Container();
             $errorContainer->add($errorText);
             $errorContainer->getElementProperties()->addClass('vf__main_error');
             $form->add($errorContainer);
         }
     }
     if ($formSend) {
         $confirmationText = new \Span();
         $confirmationText->setContent(preg_replace('/\\n/', '<br>', $renderApi->getFormValue($unit, 'confirmationText')));
         $confirmationContainer = new \Container();
         $confirmationContainer->add($confirmationText);
         $confirmationContainer->getElementProperties()->addClass('confirmationText');
         $form->add($confirmationContainer);
         echo $form->renderElement();
     } else {
         echo $form->renderElementProgressive($renderApi, $unit);
     }
 }
function wrapTweets($timeline)
{
    if (!$timeline) {
        return '<p>Unable to connect to twitter.</p>';
    }
    // Create unorderer list of tweets (see gagawa module)
    $ul = new Ol();
    foreach ($timeline as $tweet) {
        $text = $tweet->text;
        //Format date as 5 min ago, 2 hours ago, etc.
        $date = distance_of_time_in_words(strtotime($tweet->created_at)) . ' ago';
        // Tweet source, i.e. twhril, tweetie, tweetdeck, etc.
        // $source = $tweet->source;
        // Generate direct link to tweet
        $tweetid = $tweet->id;
        $screenname = $tweet->user->screen_name;
        $tweetlink = 'http://twitter.com/' . $screenname . '/status/' . $tweetid;
        // Turn links into links
        $text = eregi_replace('(((f|ht){1}tp://)[-a-zA-Z0-9@:%_\\+.~#?&//=]+)', '<a href="\\1" target="_blank">\\1</a>', $text);
        // Turn twitter @username into links to the users Twitter page
        $text = preg_replace('/(^|\\s)@(\\w+)/', '\\1<a href="http://www.twitter.com/\\2" target="_blank">@\\2</a>', $text);
        // Turn #hashtags into searches
        $text = preg_replace('/(^|\\s)#(\\w+)/', '\\1<a href="http://search.twitter.com/search?q=%23\\2" target="_blank">#\\2</a>', $text);
        // Personal Formatting, see Gagawa for documentaiton.
        // <li>Tweet Text <span>(<a href="linktotweet">some time ago</a>)<span></li>
        $li = new Li();
        $ul->appendChild($li);
        $span = new Span();
        $link = new A();
        $link->setHref($tweetlink);
        $link->appendChild(new Text($date));
        $span->appendChild($link);
        //$li->appendChild($span);
        $li->appendChild(new Text($text));
    }
    //end foreach( $timeline as $tweet )
    // Returns the stack of li's enclosed by ul
    return $ul->write();
}
$a = new A("Link", "http://www.google.com", array("style" => "color:blue"));
echo $a;
$h1 = new H("1", "This is a h1");
$h2 = new H("2", "This is a h2");
echo $h1 . $h2;
$hr = new HR();
$h1->setContents("This is the new contents");
echo $hr . $h1 . $h2;
$p = new P();
$br = new BR();
$p->setContents("This is some {$br} contents");
echo $p;
$comment = new Comment("This is commented out");
echo $comment;
$img = new Img("https://i.ytimg.com/vi/KY4IzMcjX3Y/maxresdefault.jpg", "This is a dog", array("width" => "100", "height" => "100"));
echo $img;
$table = new Table();
$table->columns(array("col1", "col2", "col3"));
$table->addRow(array("data col1", "data col2", "data col3"));
echo $table;
$list = new BootstrapList();
$list->addLi("item 1")->addLi("item 2");
echo $list;
$div = new Div();
$div->setContents($p . $img);
echo $div;
$span = new Span();
$span->setContents("This is a span");
$div->setContents($span->setContents("This is some new content"));
echo $div;
Example #9
0
 /**
  * Set the time span from an array.
  *
  * Set the time span from an array. Any value can be a float (but it
  * has no sense in seconds), for example array(23.5, 20, 0) is
  * interpreted as 23 hours, .5*60 + 20 = 50 minutes and 0 seconds.
  *
  * @param array $time
  *        	Items are counted from right to left. First
  *        	item is for seconds, second for minutes, third
  *        	for hours and fourth for days. If there are
  *        	less items than 4, zero (0) is assumed for the
  *        	absent values.
  *        	
  * @return bool True on success.
  *        
  * @access public
  */
 function setFromArray($time)
 {
     if (!is_array($time)) {
         return false;
     }
     $tmp1 = new Span();
     if (!$tmp1->setFromSeconds(@array_pop($time))) {
         return false;
     }
     $tmp2 = new Span();
     if (!$tmp2->setFromMinutes(@array_pop($time))) {
         return false;
     }
     $tmp1->add($tmp2);
     if (!$tmp2->setFromHours(@array_pop($time))) {
         return false;
     }
     $tmp1->add($tmp2);
     if (!$tmp2->setFromDays(@array_pop($time))) {
         return false;
     }
     $tmp1->add($tmp2);
     return $this->copy($tmp1);
 }
 function showMobile()
 {
     $dvSc = new Div();
     $dvSc->setWidth("100%");
     $title = new Title("Shortcuts", 0, "10em");
     $spc = new Line();
     $dvSc->add(new Spacer(20));
     $dvSc->add($title);
     $dvSc->add($spc);
     foreach ($this->SHORTCUTS_DB->ROWS as $shortcutRow) {
         $this->SHORTCUTS_URL_COMMAND = "/?switchShortcut=";
         $this->SHORTCUTS_TOOLTIP = "<table width='120' cellspacing=0 cellpadding=0>";
         $this->prepareShortcutSwitchLink($shortcutRow->getNamedAttribute("id"));
         if ($this->SHORTCUTS_URL_COMMAND != "/?switchShortcut=") {
             // aktiver Link mit konfigurierten Items
             $this->SHORTCUTS_URL_COMMAND = str_replace("_", "", $this->SHORTCUTS_URL_COMMAND);
             $this->SHORTCUTS_TOOLTIP .= "</table> ";
             //$txtShortcut = new Text($shortcutRow->getNamedAttribute("name"), 3, true);
             //$txtShortcut->setTooltip($this->SHORTCUTS_TOOLTIP);
             $spn = new Span($shortcutRow->getNamedAttribute("name"), $shortcutRow->getNamedAttribute("name"));
             $spn->setFontsize("12em");
             $spn->add(new Text($this->SHORTCUTS_TOOLTIP, null, false, false, false, false));
             $dvSc->add($spn);
             $dvSc->add(new Text("<a href='" . $this->SHORTCUTS_URL_COMMAND . "'>" . "<center><div align='center' style='display:table-cell; padding:2px 25px; width:100%;vertical-align:middle;background-color:green'>" . "<font size='12em' color='#deffde'><b>aktivieren</b></font>" . "</div></center>" . "</a>", 2, false, false, false, false));
             $dvSc->add($spc);
         } else {
             // inaktiv (Keine konfigurierten Items)
             $txt = new Text($shortcutRow->getNamedAttribute("name"), 3, false);
             $txt->setTooltip("Noch keine Konfiguration hinterlegt");
             $dvSc->add($txt);
             $dvSc->add($spc);
         }
     }
     $dvSc->show();
 }
        <title></title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link rel="stylesheet" type="text/css" href="Sourcerer-1.2.css" />
        <script src="jquery-1.7.1.min.js" type="text/javascript"></script>
        <script src="Sourcerer-1.2.js" type="text/javascript"></script>
        <script type="text/javascript">
            $(document).ready(function(){
 
                $('.mycode').sourcerer('html');
 
            });    
        </script>
    </head>
    <body>
        <pre class="mycode">
            <?php 
$root = new Div();
$root->setInnerHtml('The Root Div');
$root->addNode(new Div());
$root->addNode(new Div());
$span1 = new Span();
$br1 = new Br();
$span1->addNode(new Div());
$span1->addNode(new Br());
$root->addNode($span1);
$root->display();
?>
        </pre>
    </body>
</html>
Example #12
0
 private function getCatalogItemsTitle()
 {
     $headContainer = new Div();
     $head = new Div();
     $head->addStyleClasses(["slogan_container_horizontal", "z-10"]);
     $leftEar = new Div();
     $leftEar->addStyleClass("slogan_left_ear");
     $rightEar = new Div();
     $rightEar->addStyleClass("slogan_right_ear");
     $sloganContainer = new Div();
     $slogan = new Div();
     $slogan->addStyleClass("slogan catalog_slogan");
     $slogan->addChild("Наша спецодежда позаботится о Вас.");
     $sloganContainer->addChildren($slogan);
     $head->addChildren($leftEar, $sloganContainer, $rightEar, $rightEar);
     $head2 = new Div();
     $head2->addStyleClasses(["slogan_container_horizontal", "z-9"]);
     $catalogLinkContainer = new A();
     $catalogLinkContainer->addAttribute("href", Labels::$TOP_NAVIGATION_LINKS[catalog]);
     $catalogLinkContainer->addStyleClass("main_page_catalog_link_container");
     $catalogLink = new Span();
     $catalogLink->addChild("Каталог");
     $catalogLink->addStyleClasses(["main_page_catalog_link button input_hover", "f-25"]);
     $catalogLinkContainer->addChildren($catalogLink);
     /*$rightEarForLink = new Div();
       $rightEarForLink->addStyleClasses(["slogan_right_ear", "background_dark"]);*/
     $head2->addChildren($catalogLinkContainer);
     $headContainer->addChildren($head, $head2);
     $slogan = new Div();
     $slogan->addStyleClass('catalog_slogan');
     $headContainer->addStyleClass("main_page_slogan_container");
     return $slogan->addChild($headContainer);
 }