Since: 3.0.0
Author: Henry Ruhs
Exemplo n.º 1
0
 /**
  * render
  *
  * @since 3.0.0
  *
  * @param string $url
  * @param array $optionArray
  *
  * @return string
  */
 public static function render($url = null, $optionArray = [])
 {
     $counter = 0;
     $output = null;
     /* html elements */
     $titleElement = new Html\Element();
     $titleElement->init('h3', ['class' => self::$_configArray['className']['title']]);
     $linkElement = new Html\Element();
     $linkElement->init('a', ['target' => '_blank']);
     $boxElement = new Html\Element();
     $boxElement->init('div', ['class' => self::$_configArray['className']['box']]);
     /* load result */
     $reader = new Reader();
     $result = $reader->loadXML($url)->getObject();
     $result = $result->entry ? $result->entry : $result->channel->item;
     /* process result */
     if ($result) {
         foreach ($result as $value) {
             if ($counter++ < $optionArray['limit']) {
                 $linkElement->attr('href', $value->link->attributes()->href ? $value->link->attributes()->href : $value->link)->text($value->title);
                 /* collect output */
                 $output .= $titleElement->html($linkElement) . $boxElement->text($value->summary ? $value->summary : $value->description);
             }
         }
     } else {
         self::setNotification('error', Language::get('url_incorrect') . Language::get('point'));
     }
     return $output;
 }
Exemplo n.º 2
0
 /**
  * adminPanelNotification
  *
  * @since 3.0.0
  *
  * @return array
  */
 public static function adminPanelNotification()
 {
     /* load result */
     $urlBase = self::$_configArray['url'] . Registry::get('root') . '/' . Registry::get('parameterRoute') . Registry::get('fullRoute');
     $urlXML = $urlBase . '&out=xml';
     $reader = new Reader();
     $result = $reader->loadXML($urlXML)->getObject();
     /* process result */
     foreach ($result as $value) {
         $type = $value->attributes()->type ? (string) $value->attributes()->type : $value->getName();
         if (in_array($type, self::$_configArray['typeArray'])) {
             $message = ['text' => (string) $value->message, 'attr' => ['href' => $urlBase, 'target' => '_blank']];
             self::setNotification($type, $message);
         }
     }
     return self::getNotification();
 }
Exemplo n.º 3
0
 /**
  * adminPanelNotification
  *
  * @since 3.0.0
  *
  * @return array
  */
 public static function adminPanelNotification()
 {
     $output = [];
     $reader = new Reader();
     $aliasFilter = new Filter\Alias();
     $version = $aliasFilter->sanitize(Language::get('version', '_package'));
     /* load result */
     $urlVersion = 'http://service.redaxscript.com/version/' . $version;
     $urlNews = 'http://service.redaxscript.com/news/' . $version;
     $resultVersion = $reader->loadJSON($urlVersion)->getArray();
     $resultNews = $reader->loadJSON($urlNews)->getArray();
     /* merge as needed */
     if (is_array($resultVersion)) {
         $output = array_merge_recursive($output, $resultVersion);
     }
     if (is_array($resultNews)) {
         $output = array_merge_recursive($output, $resultNews);
     }
     return $output;
 }
Exemplo n.º 4
0
 /**
  * adminPanelNotification
  *
  * @since 3.0.0
  *
  * @return array
  */
 public static function adminPanelNotification()
 {
     if (Registry::get('firstParameter') !== 'admin') {
         /* load result */
         $urlBase = self::$_configArray['url'] . Registry::get('root') . '/' . Registry::get('parameterRoute') . Registry::get('fullRoute');
         $urlJSON = $urlBase . '&out=json';
         $reader = new Reader();
         $result = $reader->loadJSON($urlJSON)->getArray();
         /* process result */
         if ($result['messages']) {
             foreach ($result['messages'] as $value) {
                 if (in_array($value['type'], self::$_configArray['typeArray'])) {
                     $message = ['text' => $value['message'], 'attr' => ['href' => $urlBase, 'target' => '_blank']];
                     self::setNotification($value['type'], $message);
                 }
             }
         } else {
             self::setNotification('success', Language::get('documentValidate', '_validator') . Language::get('point'));
         }
         return self::getNotification();
     }
 }
Exemplo n.º 5
0
 /**
  * testConvertToJSON
  *
  * @since 3.0.0
  */
 public function testConvertToXML()
 {
     /* setup */
     $reader = new Reader();
     $reader->loadJSON('tests/provider/reader.json');
     /* actual */
     $actual = $reader->getXML();
     /* compare */
     $this->assertString($actual);
 }