当前位置: 首页>>代码示例>>PHP>>正文


PHP Element类代码示例

本文整理汇总了PHP中Element的典型用法代码示例。如果您正苦于以下问题:PHP Element类的具体用法?PHP Element怎么用?PHP Element使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Element类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testIdentity

 public function testIdentity()
 {
     $element2 = unserialize(serialize($this->element));
     $this->assertTrue($this->element->equals($element2));
     $element3 = new Element();
     $this->assertTrue($element2->getID() == $element3->getID() - 1);
 }
开发者ID:FTeichmann,项目名称:Erfurt,代码行数:7,代码来源:ElementHelperTest.php

示例2: render

 private function render(\DOMDocument $doc, Element $element, $parent = null)
 {
     if ($element instanceof \tarcisio\svg\SVG) {
         $svgs = $doc->getElementsByTagName('svg');
         $svg = $svgs->item(0);
         $svg->setAttribute('width', $element->width);
         $svg->setAttribute('height', $element->height);
         $svg->setAttribute('viewBox', "0 0 {$element->width} {$element->height}");
         $gs = $doc->getElementsByTagName('g');
         $g = $gs->item(0);
         foreach ($element->getChildren() as $ch) {
             $this->render($doc, $ch, $g);
         }
         return $doc;
     }
     if (!is_null($element->getTitle())) {
         $element->appendChild(new Title('', $element->getTitle()));
     }
     $e = $doc->createElement($element->getElementName());
     $parent->appendChild($e);
     foreach ($element->getAttributes() as $k => $v) {
         if (!is_null($v)) {
             $e->setAttribute($k, $v);
         }
     }
     if (!is_null($element->getValue())) {
         $e->nodeValue = $element->getValue();
     }
     foreach ($element->getChildren() as $ch) {
         $this->render($doc, $ch, $e);
     }
     return $doc;
 }
开发者ID:tarcisio,项目名称:svg,代码行数:33,代码来源:Builder.php

示例3: search

 /**
  * Find list item by search
  * @param \Jazzee\Entity\Element $element
  * @param array $searchTerms
  * @param array $variables
  * @return array
  */
 public function search(Element $element, $searchTerms, $variables = array())
 {
     $queryBuilder = $this->_em->createQueryBuilder();
     $queryBuilder->add('select', 'item')->from('Jazzee\\Entity\\ElementListItem', 'item')->leftJoin('item.variables', 'variable');
     $queryBuilder->where('item.element = :elementId');
     $queryBuilder->setParameter('elementId', $element->getId());
     $expression = $queryBuilder->expr()->orX();
     $expression2 = $queryBuilder->expr()->andX();
     foreach ($searchTerms as $key => $term) {
         $expression2->add($queryBuilder->expr()->like("item.value", ":term{$key}"));
         $queryBuilder->setParameter("term{$key}", '%' . $term . '%');
     }
     $expression->add($expression2);
     $expression2 = $queryBuilder->expr()->andX();
     foreach ($searchTerms as $key => $term) {
         $expression3 = $queryBuilder->expr()->andX();
         foreach ($variables as $key2 => $name) {
             $expression3->add($queryBuilder->expr()->eq("variable.name", ":v{$key2}"));
             $expression3->add($queryBuilder->expr()->like("variable.value", ":term{$key}"));
             $queryBuilder->setParameter('v' . $key2, $name);
         }
         $expression2->add($expression3);
         $queryBuilder->setParameter("term{$key}", '%' . $term . '%');
     }
     $expression->add($expression2);
     $queryBuilder->andWhere($expression);
     return $queryBuilder->getQuery()->getResult();
 }
开发者ID:Jazzee,项目名称:Jazzee,代码行数:35,代码来源:ElementListItemRepository.php

示例4: write

 /**
  * Write table
  *
  * @return string
  */
 public function write()
 {
     $html = '';
     $rows = $this->element->getRows();
     $rowCount = count($rows);
     if ($rowCount > 0) {
         $html .= '<table>' . PHP_EOL;
         foreach ($rows as $row) {
             // $height = $row->getHeight();
             $rowStyle = $row->getStyle();
             $tblHeader = $rowStyle->getTblHeader();
             $html .= '<tr>' . PHP_EOL;
             foreach ($row->getCells() as $cell) {
                 $cellTag = $tblHeader ? 'th' : 'td';
                 $cellContents = $cell->getElements();
                 $html .= "<{$cellTag}>" . PHP_EOL;
                 if (count($cellContents) > 0) {
                     foreach ($cellContents as $content) {
                         $writer = new Element($this->parentWriter, $content, false);
                         $html .= $writer->write();
                     }
                 } else {
                     $writer = new Element($this->parentWriter, new \PhpOffice\PhpWord\Element\TextBreak(), false);
                     $html .= $writer->write();
                 }
                 $html .= '</td>' . PHP_EOL;
             }
             $html .= '</tr>' . PHP_EOL;
         }
         $html .= '</table>' . PHP_EOL;
     }
     return $html;
 }
开发者ID:kaantunc,项目名称:MYK-BOR,代码行数:38,代码来源:Table.php

示例5: getRoot

 /**
  * Get root element of this component.
  * @return Element
  */
 private function getRoot()
 {
     if ($this->root === NULL) {
         $selector = reset($this->parameters);
         $strategy = key($this->parameters);
         if ($selector instanceof Element) {
             $this->root = $selector;
         } else {
             $this->root = $this->parent->findElement($strategy, $selector);
         }
         $expectedTagName = next($this->parameters);
         $expectedAttributes = next($this->parameters);
         if ($expectedTagName !== FALSE) {
             $actualTagName = $this->root->name();
             if ($actualTagName !== $expectedTagName) {
                 throw new ViewStateException("Root element of '" . get_class($this) . "' is expected to be tag '{$expectedTagName}', but is '{$actualTagName}'.");
             }
         }
         if ($expectedAttributes !== FALSE) {
             foreach ($expectedAttributes as $attributeName => $expectedAttributeValue) {
                 $actualAttributeValue = $this->root->attribute($attributeName);
                 if ($actualAttributeValue !== $expectedAttributeValue) {
                     throw new ViewStateException("Root element's attribute '{$attributeName}' is expected to be '{$expectedAttributeValue}', but is '{$actualAttributeValue}'.");
                 }
             }
         }
     }
     return $this->root;
 }
开发者ID:clevis,项目名称:se34,代码行数:33,代码来源:ElementComponent.php

示例6: add

 /**
  * Inserts a new element into the hash following the specified element.
  *
  * @param null|Element $before The element that precedes the new element. The element is inserted at the beginning
  * when this parameter is NULL.
  * @param string|int $key The new element's key.
  * @param mixed $value The new element's value.
  * @throws \OutOfRangeException Thrown when the key is not a string or integer.
  * @throws \RuntimeException Thrown when the key is not unique.
  */
 public function add($before, $key, $value)
 {
     if (!(is_string($key) || is_int($key))) {
         throw new \OutOfRangeException("{$key} must be a string or an integer");
     }
     if ($this->offsetExists($key)) {
         throw new \RuntimeException("{$key} must be unique");
     }
     $after = null;
     $element = new Element($key, $value);
     $element->setBefore($before);
     if (is_null($before)) {
         // insert at the head
         $after = $this->head;
         $element->setAfter($after);
         $this->head = $element;
     } else {
         // insert between an element and the element that follows it
         $after = $before->getAfter();
         $before->setAfter($element);
         $element->setAfter($after);
     }
     if (is_null($after)) {
         // it was inserted at the tail
         $this->tail = $element;
     } else {
         $after->setBefore($element);
     }
     $this->elements[$key] = $element;
 }
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:40,代码来源:OrderedHash.php

示例7: asHtml

 public function asHtml()
 {
     /*
     	redefine html output for this page
     	special case grabs head and tail lists
     	and constructs entire page with doctype
     */
     // get the head/tail before contents duplicated
     $page_head = $this->_get_head();
     $page_tail = $this->_get_tail();
     $page_ready = $this->_get_ready();
     // construct ready script section
     $ready_script = NULL;
     if ($page_ready) {
         $scripts = implode("\n", $page_ready);
         $ready_script_func = implode("\n", array('$(document).ready(function(){', $scripts, '});'));
         $ready_script = new Element('script', array('type' => 'text/javascript', 'html' => $ready_script_func));
     }
     // create fake body element
     $body = new Element('body');
     $body->contents = $this->contents;
     $body->attributes = $this->attributes;
     // construct page with head and body
     $html = new Element('html', $this->attributes);
     $head = new Element('head');
     $title = new Element('title', array('text' => $this->title));
     $html->Add($head);
     $head->Add($title);
     $head->Add($page_head);
     $html->Add($body);
     $body->Add($page_tail);
     $body->Add($ready_script);
     return '<!DOCTYPE html>' . $html->asHtml() . "\n";
 }
开发者ID:stgnet,项目名称:pui,代码行数:34,代码来源:page.php

示例8: addElement

 /**
  * Add an element to the tray
  *
  * @param Element $formElement Element to add
  * @param boolean $required    true = entry required
  *
  * @return void
  */
 public function addElement(Element $formElement, $required = false)
 {
     $this->elements[] = $formElement;
     if ($required) {
         $formElement->setRequired();
     }
 }
开发者ID:ming-hai,项目名称:XoopsCore,代码行数:15,代码来源:ElementTray.php

示例9: formTest

 public static function formTest()
 {
     $form = new Element('form');
     $form->addElement(new Text(array('label' => 'Nome Completo: ', 'name' => 'nome', 'size' => '40', 'maxlength' => '80')));
     $form->addElement(new Text(array('label' => 'E-mail: ', 'name' => 'E-mail', 'size' => '30', 'maxlength' => '40')));
     $form->addElement(new Button(array('value' => 'Enviar', 'id' => 'cadastra')));
     $form->mount();
 }
开发者ID:pelif,项目名称:curso-design-pattern,代码行数:8,代码来源:Form.php

示例10: addElement

 /**
  * Add an element
  * @param \Foundation\Form\Element
  */
 public function addElement(Element $element)
 {
     if (array_key_exists($element->getName(), $this->form->getElements())) {
         $message = 'An element with the name ' . $element->getName() . ' already exists in this form';
         throw new \Foundation\Exception($message);
     }
     $this->elements[$element->getName()] = $element;
 }
开发者ID:jazzee,项目名称:foundation,代码行数:12,代码来源:Field.php

示例11: show

 public function show($template)
 {
     require 'views/header.php';
     $chapters = $this->getAllChaptersHTML();
     $slides = new Element("slides", null, $chapters);
     echo $slides->toHTML();
     require 'views/footer.php';
 }
开发者ID:shaungeorge,项目名称:facebook_analyser,代码行数:8,代码来源:SetupDialog.php

示例12: _script

 private function _script($src)
 {
     $js = new Element('script');
     $js->attr('type', 'text/javascript');
     $js->attr('src', $src);
     $js->add('');
     $this->_js = $js;
     return $this;
 }
开发者ID:4app,项目名称:zuniphp,代码行数:9,代码来源:Javascript.php

示例13: s_element_replace

function s_element_replace(array $matches)
{
    if (isset($matches[1])) {
        $dD = new DataStore();
        $o_Element = new Element($dD->get_element_data($matches[1]));
        $o_Element->_set_full_element($dD->o_get_full_element($matches[1]));
        return $o_Element->render();
    }
}
开发者ID:Divian,项目名称:flot,代码行数:9,代码来源:items.php

示例14: updateElement

 /**
  * Updates an element in cache
  * @param Element $element The element to update
  */
 public static function updateElement($element)
 {
     $elementClass = $element->getElementClass();
     $elementId = $element->id;
     // Updates element attributes if already cached
     if (self::isCachedElement($elementClass, $elementId)) {
         self::$cachedElementArray[$elementClass][$elementId] = $element;
     }
 }
开发者ID:jonathan-vallet,项目名称:craftanat,代码行数:13,代码来源:CacheFactory.class.php

示例15: decodeOrRead

 /**
  * Determines if the Element should `read` or `decode` the value.
  *
  * @param  Element  $element    The Element object
  * @param  mixed    $value      The value to put in the Object
  * @param  boolean  $decode     True to `decode`, false to `read`
  * 
  * @return Element  An Element object representing the value
  */
 public function decodeOrRead($element, $value, $decode)
 {
     if ($decode) {
         $element->decode($value);
     } else {
         $element->read($value);
     }
     return $element;
 }
开发者ID:dsmithhayes,项目名称:bencode,代码行数:18,代码来源:FactoryBuild.php


注:本文中的Element类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。