Exemplo n.º 1
0
 public function editAction()
 {
     if ($this->_hasParam('id')) {
         $constId = $this->_getParam('id');
         if ($this->_request->isPost()) {
             $val = $this->_request->getPost('value');
             $this->siteDbAdapter->update('const', array('c_value' => trim($val)), $this->siteDbAdapter->quoteInto('c_id = ?', $constId));
             $this->_redirect('/constants/list/');
         }
         if ($this->existConstants[$constId]['c_name'] == 'un404page' || $this->existConstants[$constId]['c_name'] == 'loginPage') {
             $pages = new Pages($this->getSiteId());
             $pagesList = $pages->getPagesList();
             $this->tplVars['consts']['val']['pages'] = $pagesList;
         }
         $this->tplVars['consts']['val']['value'] = $this->existConstants[$constId]['c_value'];
         $this->tplVars['consts']['val']['name'] = $this->existConstants[$constId]['c_name'];
         array_push($this->tplVars['header']['actions']['names'], array('name' => 'edit', 'menu_name' => 'Edit Constant'));
         array_push($this->viewIncludes, 'constants/editConstant.tpl');
     }
 }
Exemplo n.º 2
0
 public function sitemapAction()
 {
     $pages = new Pages($this->getSiteId());
     $data = array();
     if ($this->_request->getPost('generate')) {
         $data['action'] = 'generate';
         $pagesList = $pages->getPagesList();
         $hostname = $this->getNCSiteHostname();
         $sitemap = '<?xml version="1.0" encoding="UTF-8"?>' . "\n" . '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . "\n";
         foreach ($pagesList as $page) {
             $pg_options = unserialize($page['pg_options']);
             if ($page['pg_hidden'] == '0' && !isset($pg_options['noIndex'])) {
                 $sitemap .= '<url><loc>http://' . $hostname . '' . $page['pg_address'] . '</loc></url>' . "\n";
             }
         }
         $sitemap .= '</urlset>';
         if (file_exists($pages->getSitePath() . 'sitemap.xml')) {
             copy($pages->getSitePath() . 'sitemap.xml', $pages->getSitePath() . 'tmp/sitemap_' . date('Y-m-d_H-i-s') . '.xml');
         }
         if (file_put_contents($pages->getSitePath() . 'sitemap.xml', $sitemap)) {
             $data['result'] = true;
             $data['sitemap_link'] = 'http://' . $hostname . '/sitemap.xml';
         } else {
             $data['result'] = false;
         }
     }
     // function uploading a new sitemap file to the root of the site
     if ($this->_request->getPost('max_file_size') && count($_FILES)) {
         $data['action'] = 'uploadfile';
         $allowed_to_upload = false;
         $hostname = $this->getNCSiteHostname();
         $uploadfile = $pages->getSitePath() . basename($_FILES['uploadfile']['name']);
         if (file_exists($pages->getSitePath() . 'sitemap.xml')) {
             if (copy($pages->getSitePath() . 'sitemap.xml', $pages->getSitePath() . 'tmp/sitemap_' . date('Y-m-d_H-i-s') . '.xml')) {
                 $allowed_to_upload = true;
             } else {
                 $data['result'] = false;
                 $data['message'] = 'Cannot copy the old sitemap file';
             }
             if (!unlink($uploadfile)) {
                 $data['result'] = false;
                 $data['message'] = 'Cannot remove the old sitemap file';
             }
         } else {
             $allowed_to_upload = true;
         }
         // if($_FILES['uploadfile']['size'] > $this->_request->getPost('max_file_size')){
         //     $allowed_to_upload = false;
         //     $data['message'] = 'Maximum file size to upload is '.sprintf("%u", filesize($uploadfile));
         // }
         if ($allowed_to_upload) {
             if (move_uploaded_file($_FILES['uploadfile']['tmp_name'], $uploadfile)) {
                 $data['result'] = true;
                 $data['message'] = 'Your request was completed successfully!';
                 $data['sitemap_link'] = 'http://' . $hostname . '/sitemap.xml';
             } else {
                 $data['result'] = false;
                 $data['message'] = 'Cannot copy the new sitemap file';
             }
         } else {
             $data['result'] = false;
             $data['message'] = 'Something has happened, the new sitemap file was not allowed to upload...';
         }
     }
     $this->tplVars['data'] = $data;
     array_push($this->viewIncludes, 'content/sitemap.tpl');
 }
Exemplo n.º 3
0
 public function getPages($smarty = FALSE, $siteId)
 {
     $pages = new Pages($siteId);
     $prods = $pages->getPagesList(NULL, array('pg_lang', 'pg_address'));
     if ($smarty) {
         $tcats['values'] = array();
         $tcats['names'] = array();
         $tsize = sizeof($prods);
         for ($i = 0; $i < $tsize; $i++) {
             array_push($tcats['values'], $prods[$i]['pg_address']);
             array_push($tcats['names'], $prods[$i]['pg_address']);
         }
         $prods = $tcats;
     }
     return $prods;
 }