示例#1
0
 public function afterIteration(array $list)
 {
     $list = parent::afterIteration($list);
     $makeLinks = $this->getProperty('makeLinks', false);
     if ($makeLinks) {
         $this->modx->getParser();
     }
     if ($summary = $this->getProperty('summary')) {
         $properties = $this->getProperties();
     }
     switch ($this->getProperty('image_url_schema')) {
         case 'base':
             $images_base_url = $this->getSourcePath();
             break;
         case 'full':
             $images_base_url = $this->modx->getOption('site_url');
             $images_base_url .= preg_replace("/^\\/*/", "", $this->getSourcePath());
             break;
         default:
             $images_base_url = '';
     }
     foreach ($list as &$l) {
         // Картинка
         #  = '';
         if (empty($l['image']) and !empty($l['tvs']['image']['value'])) {
             $l['image'] = $images_base_url . $l['tvs']['image']['value'];
         } else {
             # $l['imageDefault'] = $images_base_url . 'public/images/No-Photo.jpg';
             $l['imageDefault'] = $images_base_url . 'images/No-Photo.jpg';
         }
         // Ссылки
         if ($makeLinks) {
             if ($l['class_key'] == "modWebLink") {
                 $l['link'] = $this->makeUrl($l['content']);
             } else {
                 $l['link'] = $l['uri'];
             }
         }
         // Режем текст
         if ($summary) {
             $l['summary'] = '';
             $trunc = new truncate_modSiteWebResourcesGetdataProcessor($this->modx, array_merge($properties, array('resource' => $l)));
             if ($response = $trunc->run() and !$response->isError()) {
                 $l['summary'] = $response->getResponse();
             }
         }
     }
     return $list;
 }
示例#2
0
 public function afterIteration(array $list)
 {
     $list = parent::afterIteration($list);
     $makeLinks = $this->getProperty('makeLinks', false);
     if ($makeLinks) {
         $this->modx->getParser();
     }
     if ($summary = $this->getProperty('summary')) {
         $properties = $this->getProperties();
     }
     $images_base_url = $this->getImageBaseUrl();
     foreach ($list as &$l) {
         // Картинка
         if (empty($l['image']) and !empty($l['tvs']['image']['value'])) {
             $l['image'] = $images_base_url . $l['tvs']['image']['value'];
         } else {
             $l['imageDefault'] = $images_base_url . 'products/No-Photo.jpg';
         }
         // Ссылки
         if ($makeLinks) {
             if ($l['class_key'] == "modWebLink") {
                 $l['link'] = $this->makeUrl($l['content']);
             } else {
                 $l['link'] = $l['uri'];
             }
         }
         // Режем текст
         if ($summary) {
             $l['summary'] = '';
             $trunc = new truncate_modSiteWebResourcesGetdataProcessor($this->modx, array_merge($properties, array('resource' => $l)));
             if ($response = $trunc->run() and !$response->isError()) {
                 $l['summary'] = $response->getResponse();
             }
         }
     }
     return $list;
 }