protected function getOldFileList($dir) { $list = array(); $faq = new PMF_Faq(); $faq->getAllRecords(); $records = $faq->faqRecords; reset($records); while (list(, $record) = each($records)) { $recordDir = "{$dir}/{$record['id']}"; if (file_exists($recordDir) && is_dir($recordDir)) { $list[$record['id']]['files'] = array(); foreach (new DirectoryIterator($recordDir) as $entry) { if (!$entry->isDot() && $entry->isFile()) { $list[$record['id']]['files'][] = "{$recordDir}/{$entry->getFilename()}"; } } $list[$record['id']]['lang'] = $record['lang']; } } return $list; }
} // FIXME: Count "comments"/"entries" for each category also within a search context. Now the count is broken. // FIXME: we are not considering 'faqdata.links_state' for filtering the faqs. if (!is_null($searchterm)) { $numCommentsByCat = array(); foreach ($relationMatrix as $relation) { if (!isset($numCommentsByCat[$relation->category_id])) { $numCommentsByCat[$relation->category_id] = 0; } if (isset($numCommentsByFaq[$relation->record_id])) { $numCommentsByCat[$relation->category_id] += $numCommentsByFaq[$relation->record_id]; } } } if ($action == 'view' && is_null($searchterm)) { $faq->getAllRecords($orderby, null, $sortby); $laction = 'view'; $internalSearch = ''; foreach ($faq->faqRecords as $record) { if (!isset($numActiveByCat[$record['category_id']])) { $numActiveByCat[$record['category_id']] = 0; } $numActiveByCat[$record['category_id']] += $record['active'] == 'yes' ? 1 : 0; } } elseif ($action == "view" && !is_null($searchterm)) { $fdTable = SQLPREFIX . 'faqdata'; $fcrTable = SQLPREFIX . 'faqcategoryrelations'; $search = PMF_Search_Factory::create($Language, array('database' => PMF_Db::getType())); $search->setDatabaseHandle($db)->setTable($fdTable)->setResultColumns(array($fdTable . '.id AS id', $fdTable . '.lang AS lang', $fdTable . '.solution_id AS solution_id', $fcrTable . '.category_id AS category_id', $fdTable . '.sticky AS sticky', $fdTable . '.active AS active', $fdTable . '.thema AS thema', $fdTable . '.content AS content', $fdTable . '.datum AS date'))->setJoinedTable($fcrTable)->setJoinedColumns(array($fdTable . '.id = ' . $fcrTable . '.record_id', $fdTable . '.lang = ' . $fcrTable . '.record_lang')); if (is_numeric($searchterm)) { $search->setMatchingColumns(array($fdTable . '.solution_id'));
break; case "translist": require_once 'trans.list.php'; break; case "transadd": require_once 'trans.add.php'; break; default: print "Error"; break; } } else { // start page with some informations about the FAQ printf('<h2>%s</h2>', $PMF_LANG['ad_pmf_info']); $PMF_TABLE_INFO = $db->getTableStatus(); $faq->getAllRecords(FAQ_SORTING_TYPE_CATID_FAQID, array('fd.active' => 'no')); ?> <dl class="table-display"> <dt><strong>→ <a href="?action=viewsessions"><?php print $PMF_LANG["ad_start_visits"]; ?> </a></strong></dt> <dd><?php print $PMF_TABLE_INFO[SQLPREFIX . "faqsessions"]; ?> </dd> <dt><strong>→ <a href="?action=view"><?php print $PMF_LANG["ad_start_articles"]; ?> </a></strong></dt> <dd><?php
require_once PMF_ROOT_DIR . '/lang/language_' . LANGCODE . '.php'; } //Load plurals support for selected language $plr = new PMF_Language_Plurals(LANGCODE); // // Initalizing static string wrapper // PMF_String::init(LANGCODE); $oLnk = new PMF_Linkverifier($faqConfig); $faq = new PMF_Faq($faqConfig); $totStart = microtime(true); // Read the data directly from the faqdata table (all faq records in all languages) $start = microtime(true); $output .= $isRequestedByWebLocalhost ? '' : "\n"; $output .= 'Extracting faq records...'; $faq->getAllRecords(); $_records = $faq->faqRecords; $tot = count($_records); $end = microtime(true); $output .= ' #' . $tot . ', done in ' . round($end - $start, 4) . ' sec.' . ($isRequestedByWebLocalhost ? '' : "\n"); $output .= $isRequestedByWebLocalhost ? '' : "\n"; if ($isRequestedByWebLocalhost) { echo '<pre>'; } $output = $output . "\n"; echo $output; $i = 0; foreach ($_records as $_r) { $i++; $output = ''; $output .= sprintf('%0' . strlen((string) $tot) . 'd', $i) . '/' . $tot . '. Checking ' . $_r['solution_id'] . ' (' . PMF_Utils::makeShorterText(strip_tags($_r['title']), 8) . '):';
?> <form id="recordSelection" name="recordSelection" method="post" accept-charset="utf-8"> <?php $numCommentsByFaq = $comment->getNumberOfComments(); $numRecordsByCat = $category->getNumberOfRecordsOfCategory(); $matrix = $category->getCategoryRecordsMatrix(); foreach ($matrix as $catkey => $value) { $numCommentsByCat[$catkey] = 0; foreach ($value as $faqkey => $value) { if (isset($numCommentsByFaq[$faqkey])) { $numCommentsByCat[$catkey] += $numCommentsByFaq[$faqkey]; } } } if (is_null($searchTerm)) { $faq->getAllRecords($orderBy, null, $sortBy); foreach ($faq->faqRecords as $record) { if (!isset($numActiveByCat[$record['category_id']])) { $numActiveByCat[$record['category_id']] = 0; } $numActiveByCat[$record['category_id']] += $record['active'] == 'yes' ? 1 : 0; } } else { $fdTable = PMF_Db::getTablePrefix() . 'faqdata'; $fcrTable = PMF_Db::getTablePrefix() . 'faqcategoryrelations'; $search = PMF_Search_Factory::create($faqConfig, array('database' => PMF_Db::getType())); $search->setTable($fdTable)->setResultColumns(array($fdTable . '.id AS id', $fdTable . '.lang AS lang', $fdTable . '.solution_id AS solution_id', $fcrTable . '.category_id AS category_id', $fdTable . '.sticky AS sticky', $fdTable . '.active AS active', $fdTable . '.thema AS thema', $fdTable . '.content AS content', $fdTable . '.datum AS date'))->setJoinedTable($fcrTable)->setJoinedColumns(array($fdTable . '.id = ' . $fcrTable . '.record_id', $fdTable . '.lang = ' . $fcrTable . '.record_lang')); if (is_numeric($searchTerm)) { $search->setMatchingColumns(array($fdTable . '.solution_id')); } else { $search->setMatchingColumns(array($fdTable . '.thema', $fdTable . '.content', $fdTable . '.keywords'));