public function getTagListRows($rawTag, $offset, $rows = NUM_ROWS, $filter = null)
 {
     global $wgUser;
     $db = WAPDB::getInstance($this->dbType);
     $orderBy = 'ct_rank';
     $filter = intVal($filter);
     // Don't pass in a filter, will filter below
     $vars['articles'] = $db->getArticlesByTagName($rawTag, 0, self::MAX_NUM_ROWS, WAPArticleTagDB::ARTICLE_UNASSIGNED, '', $orderBy);
     if (!empty($filter)) {
         foreach ($vars['articles'] as $i => $a) {
             // bitwise filter by category
             if (!($a->getCatInfo() & $filter)) {
                 unset($vars['articles'][$i]);
             }
         }
     }
     $vars['u'] = BabelfishUser::newFromUserObject($wgUser, $this->dbType);
     $vars['numrows'] = $rows;
     $vars['tag'] = $rawTag;
     $config = WAPDB::getInstance($this->dbType)->getWAPConfig();
     $linkerClass = $config->getLinkerClassName();
     $vars['linker'] = new $linkerClass($this->dbType);
     $tmpl = new WAPTemplate($this->dbType);
     $html = $tmpl->getHtml('tag_list_pager_rows.tmpl.php', $vars);
     return $html;
 }
Exemplo n.º 2
0
 public function __construct(WAPConfig $config)
 {
     global $wgUser;
     $this->config = $config;
     $this->dbType = $config->getDBType();
     $userClass = $config->getUserClassName();
     $this->cu = $userClass::newFromUserObject($wgUser, $this->dbType);
     $this->wapDB = WAPDB::getInstance($this->dbType);
 }
 public function getTagListRows($rawTag, $offset, $rows = NUM_ROWS, $filter = null)
 {
     $db = WAPDB::getInstance($this->dbType);
     $vars['articles'] = $db->getArticlesByTagName($rawTag, $offset, $rows, WAPArticleTagDB::ARTICLE_UNASSIGNED, $filter);
     $vars['numrows'] = $rows;
     $vars['tag'] = $rawTag;
     $config = WAPDB::getInstance($this->dbType)->getWAPConfig();
     $linkerClass = $config->getLinkerClassName();
     $vars['linker'] = new $linkerClass($this->dbType);
     $tmpl = new WAPTemplate($this->dbType);
     return $tmpl->getHtml('tag_list_pager_rows.tmpl.php', $vars);
 }
Exemplo n.º 4
0
 public function getLanguageTag()
 {
     $languages = WAPDB::getInstance($this->dbType)->getWAPConfig()->getSupportedLanguages();
     $tag = null;
     foreach ($languages as $langTag) {
         if ($this->hasTag($langTag)) {
             $tag = $langTag;
             break;
         }
     }
     if (is_null($tag)) {
         throw new Exception(self::EX_NO_LANG_TAG);
     }
     return $tag;
 }
 protected function completedReport($startDate, $endDate)
 {
     $wapDB = WAPDB::getInstance($this->dbType);
     $langs = $this->wapConfig->getSupportedLanguages();
     $linker = new WAPLinker($this->dbType);
     $defaultUserText = $this->wapConfig->getDefaultUserName();
     foreach ($langs as $lang) {
         $urls = array();
         $articles = $wapDB->getTranslatedArticlesFromDate($lang, $startDate, $endDate);
         foreach ($articles as $a) {
             $userText = $a->getUserText();
             $userText = empty($userText) ? $defaultUserText : $userText;
             $urls[] = $linker->makeWikiHowUrl($a->getPageTitle()) . "\t{$userText}";
         }
         $wapDB->completeTranslatedArticles($articles, $lang);
         if (!empty($urls)) {
             $subject = $this->getSubject("Completed Articles", $lang);
             $body = "The following articles were completed via the translation links tool yesterday.\n\n" . implode("\n", $urls) . "\n\n";
             $emails = $this->wapConfig->getMaintenanceCompletedEmailList();
             mail($emails, $subject, $body);
         }
     }
 }
Exemplo n.º 6
0
 public function __construct($dbType)
 {
     $this->dbType = $dbType;
     $this->config = WAPDB::getInstance($this->dbType)->getWAPConfig();
 }
Exemplo n.º 7
0
 public function addUser(&$url, $powerUser = false)
 {
     if (0 !== stripos($url, 'http://www.wikihow.com/')) {
         throw new Exception('User urls should start with http://www.wikihow.com/');
     }
     $uname = WAPUtil::getUserNameFromUserUrl($url);
     $success = false;
     $u = User::newFromName($uname);
     if ($u) {
         $uid = $u->getId();
         if (!empty($uid)) {
             $groupName = $this->getWAPConfig()->getWikiHowGroupName();
             $u->addGroup($groupName);
             if ($powerUser) {
                 $powerUserGroup = WAPDB::getInstance($this->dbType)->getWAPConfig()->getWikiHowPowerUserGroupName();
                 $u->addGroup($powerUserGroup);
             }
             $success = true;
         }
     }
     return $success;
 }
 public function getLanguageTag()
 {
     $languages = WAPDB::getInstance($this->dbType)->getWAPConfig()->getSupportedLanguages();
     return $languages[0];
 }
Exemplo n.º 9
0
 function hasPermissions($action = array(''))
 {
     $hasPermissions = false;
     $adminGroup = WAPDB::getInstance($this->dbType)->getWAPConfig()->getWikiHowAdminGroupName();
     $userGroup = WAPDB::getInstance($this->dbType)->getWAPConfig()->getWikiHowGroupName();
     if ($this->inGroup($userGroup)) {
         switch ($action[0]) {
             case 'tag':
                 if ($this->hasTag(WAPTagDB::sanitizeRawTag($action[1]))) {
                     $hasPermissions = true;
                 }
                 break;
             case 'user':
                 if ($action[1] == $this->getId()) {
                     $hasPermissions = true;
                 }
                 break;
             case 'reserve_article':
             case 'complete_article':
             case 'article_details':
             case 'release_article':
             case 'assigned_list_more_rows':
             case 'tag_list_more_rows':
                 $hasPermissions = true;
         }
     }
     if ($this->isPowerUser()) {
         switch ($action[0]) {
             case 'rpt_assigned_articles':
             case 'rpt_completed_articles':
                 $hasPermissions = true;
         }
     }
     if ($this->inGroup($adminGroup)) {
         // Admins can only access the system from dev or a wikiknowhow.com domain
         // for perf reasons
         $hasPermissions = stripos(@$_SERVER['HOSTNAME'], 'wikidiy.com') !== false || stripos(@$_SERVER['HOSTNAME'], 'spare1.wikihow.com') !== false;
         $hasPermissions = true;
     }
     return $hasPermissions;
 }
Exemplo n.º 10
0
 public function tagArticles($tagName)
 {
     global $IP;
     $dbr = self::getDBR();
     $articles = WAPDB::getInstance($this->dbType)->getArticlesByTagName($tagName, 0, self::MAX_RPT_SIZE, WAPArticleTagDB::ARTICLE_ALL, '');
     $data = "";
     if (!empty($articles)) {
         $aids = array();
         foreach ($articles as $article) {
             $aids[] = $article->getArticleId();
         }
         $aids = "(" . implode(",", $aids) . ")";
         require_once "{$IP}/extensions/wikihow/DatabaseHelper.class.php";
         $articleTable = $this->config->getArticleTableName();
         $rows = DatabaseHelper::batchSelect($articleTable, array('*'), array("ct_page_id IN {$aids}"), __METHOD__, array(), DatabaseHelper::DEFAULT_BATCH_SIZE, $dbr);
         $data = WAPUtil::generateTSVOutput($rows);
     }
     $rpt = self::getReportArray($data);
     return $rpt;
 }
Exemplo n.º 11
0
<?php

/*
*  This script imports urls into the babelfish system given a filename on the commandline
*/
require_once 'commandLine.inc';
$wapDB = WAPDB::getInstance(WAPDB::DB_BABELFISH);
$file = $argv[0];
$simulate = false;
$wapDB->importArticles($file, $simulate);
Exemplo n.º 12
0
 public function getViewableTags(WAPUser &$user)
 {
     if ($user->inGroup(WAPDB::getInstance($this->dbType)->getWAPConfig()->getWikiHowAdminGroupName())) {
         return $this->getTags();
     } else {
         $tags = array();
         foreach ($this->getTags() as $aTag) {
             foreach ($user->getTags() as $uTag) {
                 if ($aTag['raw_tag'] == $uTag['raw_tag']) {
                     $tags[] = $aTag;
                 }
             }
         }
         return $tags;
     }
 }
Exemplo n.º 13
0
 protected function handleUnassignedIdRemoval(&$idsToRemove, $lang, $subject)
 {
     $wapDB = WAPDB::getInstance($this->dbType);
     // Delete the unassigned ids from Concierge for each lang
     if (!empty($idsToRemove)) {
         echo "{$subject} - {$lang} for removal - " . implode(",", $idsToRemove) . "\n";
         // Delete articles that haven't been assigned/completed
         $wapDB->removeArticles($idsToRemove, $lang);
     }
 }