コード例 #1
0
ファイル: PanelButtonsTest.php プロジェクト: pscheit/psc-cms
 protected function getPanelButtonsLabels($expectedNum)
 {
     $buttons = $this->test->css('div.psc-cms-ui-buttonset', $this->html = $this->panelButtons->html())->count(1)->css('button')->count($expectedNum)->getjQuery();
     $labels = array();
     foreach ($buttons as $button) {
         $button = new jQuery($button);
         $labels[] = $button->text();
     }
     return $labels;
 }
コード例 #2
0
ファイル: JavaScriptBase.php プロジェクト: pscheit/psc-cms
 public function wrapHTML($componentContent)
 {
     $this->html = $wrapper = parent::wrapHTML($componentContent);
     if (($snippet = $this->getJavaScript($wrapper)) instanceof \Psc\JS\Snippet) {
         $snippet = clone $snippet;
         $snippet->setVar(Snippet::VAR_NAME_SELF, \Psc\JS\jQuery::getClassSelector($wrapper));
         $wrapper->getContent()->js = $snippet->html();
     }
     return $wrapper;
 }
コード例 #3
0
ファイル: GridPanelTest.php プロジェクト: pscheit/psc-cms
 public function testRowHTML()
 {
     $this->gridPanel->addRow(array('row1:col1', 'row1:col2', 'row1:col3'));
     $this->gridPanel->addRow(array('row2:col1', 'row2:col2', 'row2:col3'));
     $this->gridPanel->addRow(array('row3:col1', 'row3:col2', 'row3:col3'));
     $trs = $this->test->css('table tr', $this->html = $this->gridPanel->html())->getJQuery();
     foreach ($trs as $row => $tr) {
         if ($row === 0) {
             continue;
         }
         // skip header
         $tr = new jQuery($tr);
         $col = 1;
         foreach ($tr->find('td') as $td) {
             $td = new jQuery($td);
             // everything i right place?
             $this->assertEquals(sprintf('row%d:col%d', $row, $col), $td->text());
             $col++;
         }
         $row++;
     }
 }
コード例 #4
0
 public static function parse(\DOMElement $file)
 {
     $jq = new jQuery($file);
     $file = new static($jq->attr('file_name'));
     $file->setHoster($jq->attr('file_hoster'));
     $file->setStatus($jq->attr('file_status'));
     $file->setPercent((double) $jq->attr('file_percent'));
     $file->setSize($jq->attr('file_size'));
     $file->setLoaded($jq->attr('file_downloaded'));
     return $file;
 }
コード例 #5
0
ファイル: TableScraper.php プロジェクト: pscheit/psc-cms
 /**
  * @return object .rows , .header
  */
 public function scrape()
 {
     extract($this->help());
     $rows = array();
     $header = $this->header;
     foreach ($this->table->find('tr') as $key => $tr) {
         $tr = $jq($tr);
         // filter?
         foreach ($this->rowFilters as $rowFilter) {
             if ($rowFilter($tr, $key, $header !== NULL) === FALSE) {
                 continue 2;
             }
         }
         // scrape the header (wenn er gesetzt ist parsen wir nicht, wenn er leer ist auch nicht)
         if ($header === NULL) {
             $header = array();
             foreach ($tr->find('td,th') as $key => $th) {
                 $value = $thConverter($jq($th), $key);
                 $header[$key] = $value;
             }
         } else {
             // scrape a row
             $row = array();
             foreach ($tr->find('td') as $key => $td) {
                 $value = $tdConverter($jq($td), $key, array_key_exists($key, $header) ? $header[$key] : NULL);
                 // somit geht sogar dass &$key benutzt wird
                 $row[$key] = $value;
             }
             if ($this->useHeader) {
                 $rows[] = array_combine($header, $row);
             } else {
                 $rows[] = $row;
             }
         }
     }
     $table = (object) array('header' => $header, 'rows' => $rows);
     return $table;
 }
コード例 #6
0
 public static function parse(\DOMElement $package)
 {
     $jq = new jQuery($package);
     $package = new static($jq->attr('package_name'));
     $package->setLinksTotal((int) $jq->attr('package_linkstotal'));
     $package->setPercent((double) $jq->attr('package_percent'));
     $package->setSize($jq->attr('package_size'));
     $package->setLoaded($jq->attr('package_loaded'));
     $files = array();
     foreach ($jq->find('file') as $file) {
         $files[] = JDownloaderFile::parse($file);
     }
     $package->setFiles($files);
     return $package;
 }
コード例 #7
0
ファイル: SearchPanel.php プロジェクト: pscheit/psc-cms
 protected function doInit()
 {
     // das zuerst machen, da das html von f::inputSet bei html() schon gemorphed wird
     $widget = $this->getAutoCompleteWidget();
     $widgetSelector = \Psc\JS\jQuery::getClassSelector($widget);
     $content = NULL;
     $content .= f::inputSet(f::input($widget, $this->getHint()))->setStyle('width', '90%')->html();
     // gilt für alle
     // ist auch in ajax.dialog.add.speakers
     $content .= f::hint($this->getExplanation());
     $this->html = f::group($this->getLabel(), $content, f::GROUP_COLLAPSIBLE)->setStyle('width', '80%');
     $this->constructParams['widget'] = new \Psc\JS\Code($widgetSelector);
     $this->constructParams['delay'] = $this->getAutoCompleteDelay();
     $this->constructParams['minLength'] = $this->getAutoCompleteMinLength();
     $this->constructParams['url'] = $this->getAutoCompleteURL();
     $this->constructParams['maxResults'] = $this->getMaxResults();
     if ($this->getAutoCompleteBody() != NULL) {
         $this->constructParams['body'] = $this->getAutoCompleteBody();
     }
     $this->constructParams['eventManager'] = new \Psc\JS\Code('main.getEventManager()');
     $this->autoLoad();
 }
コード例 #8
0
 public function getFormular()
 {
     $pane = new SplitPane(70);
     $pane->setLeftContent($container = Form::group('Navigation', NULL));
     $container->getContent()->div->setStyle('min-height', '600px');
     $container->addClass('\\Psc\\navigation');
     $pane->setRightContent($this->getFormDocumentation());
     $panelButtons = new PanelButtons(array('save', 'reload'), $this->getTranslationContainer());
     $form = new \Psc\CMS\Form(NULL, '/entities/navigation-node/' . $this->context, 'post');
     $form->setHTTPHeader('X-Psc-Cms-Request-Method', 'PUT');
     $form->setContent('buttons', $panelButtons)->setContent('pane', $pane);
     $main = $form->html();
     $main->addClass('\\Psc\\navigation-container');
     $main->addClass('\\Psc\\serializable');
     $snippet = JooseSnippet::create('Psc.UI.Navigation', array('widget' => JooseSnippet::expr(\Psc\JS\jQuery::getClassSelector($main)), 'flat' => $this->getFlat(), 'uiController' => JooseSnippet::expr('main.getUIController()'), 'languages' => (array) $this->container->getLanguages()));
     $main->templateAppend($snippet->html());
     return $main;
 }
コード例 #9
0
 /**
  *
  * Reihenfolge der Optionen ist wichtig
  */
 public function formSelect($html, $label, $name, $selectedValue = NULL, $options = NULL)
 {
     $select = $this->css($sel = sprintf('select[name="%s"]', $name), $html)->count(1, 'Count-Selector: ' . $sel)->hasAttribute('name', $name)->getJQuery();
     // options parsen
     $actualSelected = NULL;
     $actualOptions = array();
     foreach ($select->find('option') as $option) {
         $option = new jQuery($option);
         if ($option->attr('selected') != NULL) {
             $this->testCase->assertEmpty($actualSelected, 'Attribut "selected" ist mehrmals in <select> angegeben!');
             $actualSelected = $option->attr('value');
             // kann auch leer sein
         }
         // @TODO reread: name hier "überschreiben" okay? wiesn das in html?
         $actualOptions[$option->attr('value')] = $option->text();
     }
     if (func_num_args() >= 5) {
         $this->testCase->assertEquals($options, $actualOptions, 'Optionen stimmen nicht. (Reihenfolge relevant)');
     }
     if (func_num_args() >= 4) {
         $this->testCase->assertEquals($selectedValue, $actualSelected, 'Selected value stimmt nicht');
     }
     // label muss die id vom input haben
     if ($label != NULL) {
         $this->formLabelFor($html, $label, $select->attr('id'));
     }
 }
コード例 #10
0
ファイル: Tag.php プロジェクト: pscheit/psc-cms
 public function html()
 {
     /* js chains */
     if ($this->getOption('closeTag', TRUE) == TRUE) {
         foreach ($this->jsChain as $code) {
             jQuery::chain($this, $code);
         }
         $this->jsChain = array();
     }
     $tagIndent = (int) $this->getOption('tag.indent', 0);
     $indent = max((int) $this->getOption('indent', 0), (int) $this->getOption('content.indent', 0));
     if ($this->tag == 'textarea' || $this->tag == 'pre') {
         $indent = $tagIndent = 0;
     }
     $html = '<' . HTML::esc($this->tag) . $this->htmlAttributes();
     if ($this->getOption('selfClosing', FALSE)) {
         /* self closing element ohne inhalt */
         $html .= ' />' . ($this->getOption('br.selfClosing', FALSE) ? "\n" : NULL);
     } elseif ($this->getOption('onlyOpen', FALSE)) {
         /* nur open-tag schließen, kein content, kein schließendes tag */
         $html .= '>' . ($this->getOption('br.onlyOpen', FALSE) ? "\n" : NULL);
     } else {
         /* open-tag schließen, content, schließendes tag */
         $html .= '>' . ($this->getOption('br.openTag', FALSE) ? "\n" : NULL) . ($this->getOption('br.beforeContent', FALSE) ? "\n" : NULL) . ($indent > 0 ? S::indent($this->htmlContent(), $indent) : $this->htmlContent()) . ($this->getOption('br.afterContent', FALSE) ? "\n" : NULL);
         if ($this->getOption('closeTag', TRUE)) {
             $html .= '</' . HTML::esc($this->tag) . '>' . ($this->getOption('br.closeTag', FALSE) ? "\n" : NULL);
         }
     }
     if ($tagIndent > 0) {
         $html = S::indent($html, $tagIndent, "\n");
     } else {
         $html;
     }
     if (isset($this->template)) {
         $contentsArray = array_merge($this->convertContent(), $this->convertTemplateContent());
         $contentsArray['self'] = $html;
         $html = str_replace(array_map(create_function('$a', 'return "%".$a."%"; '), array_keys($contentsArray)), array_values($contentsArray), $this->template);
     }
     return $html;
 }
コード例 #11
0
ファイル: JooseBase.php プロジェクト: pscheit/psc-cms
 public function getJooseSelector(\Psc\HTML\Tag $tag = NULL)
 {
     return new \Psc\JS\Code(\Psc\JS\jQuery::getClassSelector($tag ?: $this->html));
 }