Пример #1
0
        $id = intval($_GET['id']);
        $getPermalinkSql = 'SELECT ' . '* ' . 'FROM ' . DOWNLOADS_META_TABLE . ' ' . 'WHERE ' . '(id = :id) AND (draft = :draft)';
        $getPermalinkSql = $app->setDelimitedIdentifier($getPermalinkSql);
        $stmt = $app->db->prepare($getPermalinkSql);
        $stmt->execute(array(':id' => $id, ':draft' => 0));
        $itemArray = $stmt->fetch();
        if ($itemArray == true) {
            $item = $stmt->fetch();
            $item['title_date'] = date($config['title_date_format'], strtotime($item['file_date']));
            $item = $app->setEntryItems($itemArray);
            $permalinkTemplateFile = $pathToIndex . LM_Downloads::THEME_PATH . 'parmalink.html';
            $contentsView = new Loggix_View($permalinkTemplateFile);
            $contentsVars = array('session_state' => $sessionState, 'module' => $module, 'item' => $item, 'lang' => $lang);
            $contentsView->assign($contentsVars);
            $permalinkTitle = $app->setTitle(array('Downloads', $item['file_title']));
            $item = array('title' => $permalinkTitle, 'contents' => $app->plugin->applyFilters('permalink-view', $contentsView->render()), 'pager' => '', 'result' => '');
        } else {
            $e = new Loggix_Exception();
            $item = $e->getFileNotFoundMessage();
        }
        // (3) Index View (Show Recent Entries)
    } else {
        $getLatestItemsSql = 'SELECT ' . '* ' . 'FROM ' . DOWNLOADS_META_TABLE . ' AS d ' . 'WHERE ' . "d.draft = '0' " . 'ORDER BY ' . 'd.file_date DESC ' . 'LIMIT ' . $config['page_max'];
        $countTotalItemsSql = 'SELECT ' . 'COUNT(d.id) ' . 'FROM ' . DOWNLOADS_META_TABLE . ' AS d ' . 'WHERE ' . "d.draft = '0'";
        $totalItemsCount = $app->getTotalItemsCount($countTotalItemsSql);
        $item = array('title' => $app->setTitle('Downloads'), 'contents' => $app->getArchives($getLatestItemsSql), 'pager' => $app->getPager($totalItemsCount, $pageNumberToShow = '1', $date = '', $expand = '0'), 'result' => '');
    }
} catch (Loggix_Exception $e) {
    $item = $e->getArticleNotFoundMessage();
}
$app->display($item, $sessionState);
Пример #2
0
 /**
  * Get and Display Expander Content
  * 
  * Supported extensions are:
  * .inc.php | .php | .inc | .html | .txt | 
  * .text, .markdown, .md, .mdown, .mkd, .mkdn (Markdown format)
  *
  * @return string $contents
  */
 public function getContent()
 {
     global $pathToIndex, $config, $lang, $item, $module;
     $this->getModuleLanguage();
     $contents = '';
     // Load data file by ID
     // foo.inc.php | foo.php | foo.inc | foo.html | foo.txt |
     // foo.text, foo.markdown, foo.md, foo.mdown, foo.mkd, foo.mkdn, |
     try {
         $id = isset($_GET['id']) ? str_replace(DIRECTORY_SEPARATOR, '', htmlspecialchars(basename($_GET['id']))) : 'default';
         $contentType = array('inc.php' => self::EXPANDER_DATA_DIR . $id . '.inc.php', 'php' => self::EXPANDER_DATA_DIR . $id . '.php', 'inc' => self::EXPANDER_DATA_DIR . $id . '.inc', 'html' => self::EXPANDER_DATA_DIR . $id . '.html', 'txt' => self::EXPANDER_DATA_DIR . $id . '.txt', 'text' => self::EXPANDER_DATA_DIR . $id . '.text', 'markdown' => self::EXPANDER_DATA_DIR . $id . '.markdown', 'md' => self::EXPANDER_DATA_DIR . $id . '.md', 'mdown' => self::EXPANDER_DATA_DIR . $id . '.mdown', 'mkd' => self::EXPANDER_DATA_DIR . $id . '.mkd', 'mkdn' => self::EXPANDER_DATA_DIR . $id . '.mkdn');
         $aView = new Loggix_View();
         $aView->assign('config', $config);
         $aView->assign('lang', $lang);
         $aView->assign('module', $module);
         if (file_exists($contentType['inc.php'])) {
             $contents = $aView->render($contentType['inc.php']);
         } else {
             if (file_exists($contentType['php'])) {
                 $contents = $aView->render($contentType['php']);
             } else {
                 if (file_exists($contentType['inc'])) {
                     $contents = $aView->render($contentType['inc']);
                 } else {
                     if (file_exists($contentType['html'])) {
                         $contents = $aView->render($contentType['html']);
                     } else {
                         if (file_exists($contentType['txt'])) {
                             $contents = "<pre>\n" . $aView->render($contentType['txt']) . "</pre>\n";
                         } else {
                             if (file_exists($contentType['text'])) {
                                 $contents = $aView->render($contentType['text']);
                             } else {
                                 if (file_exists($contentType['markdown'])) {
                                     $contents = $aView->render($contentType['markdown']);
                                 } else {
                                     if (file_exists($contentType['md'])) {
                                         $contents = $aView->render($contentType['md']);
                                     } else {
                                         if (file_exists($contentType['mdown'])) {
                                             $contents = $aView->render($contentType['mdown']);
                                         } else {
                                             if (file_exists($contentType['mkd'])) {
                                                 $contents = $aView->render($contentType['mkd']);
                                             } else {
                                                 if (file_exists($contentType['mkdn'])) {
                                                     $contents = $aView->render($contentType['mkdn']);
                                                 } else {
                                                     $e = new Loggix_Exception();
                                                     $item = $e->getFileNotFoundMessage();
                                                     $contents = $item['contents'];
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     } catch (Loggix_Exception $e) {
         $item = $e->getFileNotFoundMessage();
         $contents = $item['contents'];
     }
     return $this->plugin->applyFilters('ex-content', $contents);
 }