getAttribute() public method

public getAttribute ( $name )
Esempio n. 1
0
 /**
  * Prepare components (set classes to nodes etc.)
  * @param ComponentAbstract $component
  * @param \simple_html_dom_node $node
  */
 protected function beforeHandle(ComponentAbstract $component, \simple_html_dom_node $node)
 {
     $this->attachAngularApp();
     if ($class = $component->getOption('class')) {
         if (is_array($class)) {
             $class = implode(' ', $class);
         } elseif (is_callable($class)) {
             $class = $class();
         }
         if (is_string($class)) {
             $node->setAttribute('class', $class);
         }
     }
     $id = $component->getOption('id');
     if (!$id) {
         $id = $node->getAttribute('id');
     }
     if (!$id) {
         $id = $this->getId($node->getAttribute('data-component'));
     }
     if ($node->getAttribute('data-component') === 'likeGate') {
         $node->setAttribute('ng-init', 'likeGateEnabled = 1');
         $node->setAttribute('ng-show', 'likeGateEnabled');
         $header = $node->find('#likeGate-header', 0);
         $message = $node->find('#likeGate-message', 0);
         if ($header) {
             $header->setAttribute('ng-bind', 'likeGateHeader');
         }
         if ($message) {
             $message->setAttribute('ng-bind', 'likeGateMessage');
         }
         $node->setAttribute('ng-model', 'pageData.' . $id);
     }
 }
Esempio n. 2
0
 /**
  * Manipulate node
  * @param DomNode $node
  * @return mixed
  */
 public function handleNode(DomNode $node)
 {
     if ($this->getOption('editMode')) {
         $data = $this->getValue();
         $id = $node->getAttribute('id');
         if (is_array($data)) {
             $sessionHelper = get_instance()->container->get('core.service.theme.session.helper');
             foreach (array('original', 'cropped') as $type) {
                 if (isset($data[$type])) {
                     //set current images to session
                     if (file_exists($data[$type]['path'])) {
                         $data[$type]['exist'] = true;
                         $sessionHelper->addTemplateImage($id, $data[$type], $type);
                     }
                 }
             }
         }
         if (isset($data['original']['exist'])) {
             $this->setOption('value', $data['original']['url']);
             $node->setAttribute('data-source-url', $data['original']['url']);
             if (isset($data['crop_params']['selection'])) {
                 $node->setAttribute('data-selection', str_replace('"', "'", json_encode($data['crop_params']['selection'])));
             }
             if (isset($data['crop_params']['scales'])) {
                 $node->setAttribute('data-scale', str_replace('"', "'", json_encode($data['crop_params']['scales'])));
             }
         }
     }
     parent::handleNode($node);
 }
Esempio n. 3
0
 /**
  * @param \simple_html_dom_node $node
  * @param string                $class
  */
 protected function addClassToNode($node, $class)
 {
     $node->setAttribute('class', trim(sprintf('%s %s', $node->getAttribute('class'), $class)));
 }