Beispiel #1
0
 public function sitemapInfo()
 {
     $config = OW::getConfig();
     if (!(bool) $config->getValue('oaseo', 'sitemap_init')) {
         $this->assign('init', false);
         return;
     }
     if ($this->service->getToProcessPagesCount() > 0) {
         $this->assign('in_process_message', OW::getLanguage()->text('oaseo', 'in_progress_label'));
         $this->assign('url', $this->service->getNextUrlToProcess());
         $this->assign('processed', $this->service->getProcessedPagesCount());
         $this->assign('to_process', $this->service->getToProcessPagesCount());
         return;
     }
     $page = !empty($_GET['page']) && (int) $_GET['page'] > 0 ? (int) $_GET['page'] : 1;
     $numOnPage = 25;
     $first = $numOnPage * ($page - 1);
     $count = $numOnPage;
     $itemsCountArr = array('pages' => $this->service->findAllPagesCount(), 'broken_links' => $this->service->findBrokenPagesCount(), 'images' => $this->service->findItemsCount(OASEO_BOL_Service::ITEM_VAL_IMAGE), 'broken_images' => $this->service->findItemsCount(OASEO_BOL_Service::ITEM_VAL_BROKEN_IMAGE), 'ext_links' => $this->service->findItemsCount(OASEO_BOL_Service::ITEM_VAL_EXT_LINK), 'brok_ext_links' => $this->service->findItemsCount(OASEO_BOL_Service::ITEM_VAL_BROKEN_EXT_LINK));
     $router = OW::getRouter();
     $urlArr = array('pages' => $router->urlFor('OASEO_CTRL_Admin', 'sitemapInfo'), 'broken' => $router->urlFor('OASEO_CTRL_Admin', 'sitemapInfo') . '?list=broken', 'images' => $router->urlFor('OASEO_CTRL_Admin', 'sitemapInfo') . '?list=images', 'broken_images' => $router->urlFor('OASEO_CTRL_Admin', 'sitemapInfo') . '?list=broken_images', 'ext_links' => $router->urlFor('OASEO_CTRL_Admin', 'sitemapInfo') . '?list=ext_links', 'broken_ext_links' => $router->urlFor('OASEO_CTRL_Admin', 'sitemapInfo') . '?list=broken_ext_links');
     $this->assign('urlArray', $urlArr);
     $this->assign('counts', $itemsCountArr);
     $list = empty($_GET['list']) ? 'std' : trim($_GET['list']);
     $finalArray = array();
     switch ($list) {
         case 'broken':
             $items = $this->service->findPages($first, $count, true);
             $itemsCount = $itemsCountArr['broken_links'];
             foreach ($items as $item) {
                 if (!isset($finalArray[$item['burl']])) {
                     $finalArray[$item['burl']] = array();
                 }
                 $finalArray[$item['burl']][] = $item['url'];
             }
             break;
         case 'images':
             $items = $this->service->findItems(OASEO_BOL_Service::ITEM_VAL_IMAGE, $first, $count);
             $itemsCount = $itemsCountArr['images'];
             $list = 'images';
             $finalArray = $this->processPageItems($items);
             break;
         case 'broken_images':
             $items = $this->service->findItems(OASEO_BOL_Service::ITEM_VAL_BROKEN_IMAGE, $first, $count);
             $itemsCount = $itemsCountArr['broken_images'];
             $list = 'broken_images';
             $finalArray = $this->processPageItems($items);
             break;
         case 'ext_links':
             $items = $this->service->findItems(OASEO_BOL_Service::ITEM_VAL_EXT_LINK, $first, $count);
             $itemsCount = $itemsCountArr['ext_links'];
             $list = 'ext_links';
             $finalArray = $this->processPageItems($items);
             break;
         case 'broken_ext_links':
             $items = $this->service->findItems(OASEO_BOL_Service::ITEM_VAL_BROKEN_EXT_LINK, $first, $count);
             $itemsCount = $itemsCountArr['brok_ext_links'];
             $list = 'broken_ext_links';
             $finalArray = $this->processPageItems($items);
             break;
         default:
             $items = $this->service->findPages($first, $count);
             $itemsCount = $itemsCountArr['pages'];
             $list = 'pages';
             foreach ($items as $item) {
                 $metaInfo = json_decode($item['meta'], true);
                 $keywords = empty($metaInfo['keywords']) ? '<span style="color:red;">_NO_KEYWORDS_</span>' : $metaInfo['keywords'];
                 $desc = empty($metaInfo['description']) ? '<span style="color:red;">_NO_DESCRIPTION_</span>' : $metaInfo['description'];
                 $finalArray[] = array('keywords' => $keywords, 'desc' => $desc, 'url' => urldecode($item['url']), 'title' => empty($item['title']) ? '<span style="color:red;">_NO_TITLE_</span>' : $item['title']);
             }
     }
     $this->assign('list', $list);
     $this->assign('items', $finalArray);
     $this->addComponent('paging', new BASE_CMP_Paging($page, ceil($itemsCount / $numOnPage), 5));
 }