/**
  * Get all pages/subpages from wordpress db
  * 
  * @return void
  */
 public function getPages()
 {
     $query = "SELECT * FROM `" . $this->_tableSuffix . "posts` \n\t\t\t\t  WHERE `post_type` LIKE 'page' AND post_status LIKE 'publish'";
     $result = $this->db->fetchAll($query);
     $isOddEven = preg_match('#odd|even#i', Rajax_Application::$request->options);
     if (count($result) != 0) {
         if (preg_match('#xml|json#', Rajax_Application::$request->output)) {
             if (!$this->output($result)) {
                 $this->_showCustomError($this->_noSite);
             }
             return;
         }
         //////////////////////// WP Event - Get : Subpages //////////////////////////////////////
         if ($this->options['_type'] == 'wp' && $this->options['get'] == 'subpages') {
             $query = "SELECT * FROM `" . $this->_tableSuffix . "posts` \n\t\t\t\t\t\t  WHERE `post_type` LIKE 'page' AND post_status LIKE 'publish' AND post_parent =0";
             $result = $this->db->fetchAll($query);
             $subPagesSubList = array();
             $html = new Rajax_HTML('');
             foreach ($result as $page) {
                 $page['slug'] = isset($page['slug']) ? $page['slug'] : 'page/' . $page['post_title'];
                 if (!preg_match('#^_[\\w]+#i', $page['post_title'])) {
                     print '<li>';
                     $page = $this->_checkForNavLink($page);
                     $html->getTemplate($this->options['file'], $page);
                     $this->_getSubPagesRecursive($page);
                     print '</li>';
                 }
             }
             return;
         }
         ////////////////////////////////////////////////////////////////////////////////////////
         if (Rajax_Application::$request->output == 'html' && $isOddEven) {
             if (!$this->output($result)) {
                 $this->_showCustomError($this->_noSite);
             }
             return;
         }
         foreach ($result as $post) {
             if (!$this->output($post)) {
                 $this->_showCustomError($this->_noSite);
                 return;
             }
         }
     } else {
         print Rajax_Application::error404();
     }
 }
 /**
  * Output the gathered data from db
  * given format outputs = xml,json,html
  * 
  * $secureOutput = array('username','registereddate')
  * With secure output you control which column is able to output within this request
  * 
  * @param array/object $resultList
  * @param string $format
  * @param array $secureOutput
  * @return html/xml/json
  */
 public function output($resultList, $secureOutput = array())
 {
     if (!$resultList || empty(Rajax_Application::$request->options) && Rajax_Application::$request->output == 'html') {
         return false;
     }
     if (!is_array($resultList) && !is_object($resultList)) {
         throw new Exception('Output expects an object/array as resultList');
     }
     //$resultList = $this->_secureTheOutput($resultList,$secureOutput);
     if ($this->_isSingleRow($resultList)) {
         $data = $resultList;
         unset($resultList);
         $resultList[0] = $data;
     }
     $resultList = $this->_convertUTF8($resultList);
     switch (strtolower(Rajax_Application::$request->output)) {
         case 'json':
             if (!Rajax_Application::$fallback) {
                 header('Content-type: application/json');
             }
             print new Rajax_JSON($resultList);
             break;
         case 'xml':
             if (!Rajax_Application::$fallback) {
                 header('Content-type: text/xml');
             }
             $xml = new Rajax_XML($resultList);
             print $xml->getXML();
             break;
         case 'html':
             if (!Rajax_Application::$fallback) {
                 header('Content-type: text/html');
             }
             $html = new Rajax_HTML($resultList);
             if ($this->options['_type'] == 'template' && isset($this->options['file'])) {
                 if (is_array($resultList) && !empty($resultList)) {
                     foreach ($resultList as $result) {
                         $html->getTemplate($this->options['file'], $result);
                     }
                 }
             } else {
                 if ($this->options['_type'] == 'template' && isset($this->options['odd']) && isset($this->options['even'])) {
                     $count = 1;
                     if (is_array($resultList) && !empty($resultList)) {
                         foreach ($resultList as $result) {
                             if ($count == 1) {
                                 $html->getTemplate($this->options['odd'], $result);
                                 $count = 2;
                             } else {
                                 $html->getTemplate($this->options['even'], $result);
                                 $count = 1;
                             }
                         }
                     }
                 } else {
                     print $html->getHTML();
                 }
             }
             break;
     }
     return true;
 }