/** * 获取APP与客户端的对应信息 * @param Array $data */ public function app_client($data = array()) { $app_id = isset($data['app_id']) ? intval($data['app_id']) : intval($this->input['appId']); $client_id = isset($data['client_id']) ? intval($data['client_id']) : intval($this->input['clientId']); if ($app_id <= 0 || $client_id <= 0) { $this->errorOutput(PARAM_WRONG); } $ret = $this->api->detail('app_info', array('id' => $app_id, 'del' => 0)); if (!$ret) { $this->errorOutput(NO_APPID); } $where = array('app_id' => $app_id, 'client_id' => $client_id, 'flag' => 1); $info = $this->api->detail('client_relation', $where); if (!$info) { $this->errorOutput(PARAM_WRONG); } $clientInfo = $this->api->detail('app_client', array('id' => $client_id)); if (!$clientInfo) { $this->errorOutput(PARAM_WRONG); } $info['app_name'] = $ret['name']; $info['mark'] = $clientInfo['mark']; $info['user_id'] = $ret['user_id']; if ($data) { return $info; } if ($info['version_name']) { $info['version_name'] = getVersionName($info['version_name']); } $this->addItem($info); $this->output(); }
header('Content-Type: text/html; charset=utf-8'); ini_set('display_errors', 1); error_reporting(E_ALL); require_once '../includes/simple_html_dom.php'; require_once "../includes/session.php"; require_once "../includes/functions.php"; require_once "../includes/connect.php"; /* php grabber for BibleGateway */ $book_id = $_GET['book']; $chapter = $_GET['chapter']; $verse = $_GET['verse']; $version_id = $_GET['version_id']; $lookup = $_GET['lookup']; $book = getBookName($book_id); $versionName = getVersionName($version_id); $url = getUrl($book, $chapter, $verse, $versionName); if ($lookup == 0) { $verse_text = ""; showTextArea($verse_text, $url); } else { $verse_text = getBGVerseText($book, $chapter, $verse, $url); if ($verse_text != "") { showTextArea($verse_text, $url); } else { echo "<div class='error'>There seems to have been a problem. getVerse line 27.</div>"; } } function showTextArea($verse_text, $url) { echo "<textarea id='verseText' rows='10' cols='50'>" . $verse_text . "</textarea>";
/** * 检查更新 */ public function checkUpdate() { $app_id = intval($this->input['appId']); $client_id = intval($this->input['clientId']); if ($app_id <= 0 || $client_id <= 0) { $this->errorOutput(PARAM_WRONG); } //先检测APP是否存在 $app_info = $this->api->detail('app_info', array('id' => $app_id, 'del' => 0)); if (!$app_info) { $this->errorOutput(NO_APPID); } $client_info = $this->api->detail('app_client', array('id' => $client_id)); if (!$client_info) { $this->errorOutput(PARAM_WRONG); } $result = $this->api->check($app_id, $client_id); if ($result) { $result['mark'] = $client_info['mark']; if ($result['version_name']) { $result['version_name'] = getVersionName($result['version_name']); } $this->addItem($result); } $this->output(); }
/** * 获取APP与客户端的对应信息 * @param $data:array 如果data存在是内部调用,否则外部调用 * appId:应用id * clientId:客户端id * @return array */ public function app_client($data = array()) { $app_id = isset($data['app_id']) ? intval($data['app_id']) : intval($this->input['appId']); $client_id = isset($data['client_id']) ? intval($data['client_id']) : intval($this->input['clientId']); if ($app_id <= 0) { $this->errorOutput(NO_APP_ID); } if ($client_id <= 0) { $this->errorOutput(NO_CLIENT_TYPE); } //获取应用信息 $ret = $this->api->detail('app_info', array('id' => $app_id, 'del' => 0)); if (!$ret) { $this->errorOutput(APP_NOT_EXISTS); } $where = array('app_id' => $app_id, 'client_id' => $client_id, 'flag' => 1); //获取版本信息 $info = $this->api->detail('client_relation', $where); if (!$info) { $this->errorOutput(NO_VERSION_INFO); } //获取客户端信息 $clientInfo = $this->api->detail('app_client', array('id' => $client_id)); if (!$clientInfo) { $this->errorOutput(CLIENT_INFO_NOT_EXISTS); } $info['app_name'] = $ret['name']; $info['user_id'] = $ret['user_id']; $info['mark'] = $clientInfo['mark']; //如果是内部调用就返回 if ($data) { return $info; } //如果是外部调用从这边输出 if ($info['version_name']) { $info['version_name'] = getVersionName($info['version_name']); } $this->addItem($info); $this->output(); }
/** * Branch a TOC. Take existing TOC, create new TOC. * * @param $manual PonyDocsManual The manual to create a TOC for. * @param $sourceVersion PonyDocsVersion The source version TOC to copy. * @param $targetVersion PonyDocsVersion The target version for the new TOC. * @returns boolean */ static function branchTOC($product, $manual, $sourceVersion, $targetVersion) { global $wgTitle; // Perform old TOC operation $title = self::TOCExists($product, $manual, $sourceVersion); if ($title == false) { throw new Exception("TOC does not exist for " . $manual->getShortName() . " with version " . $sourceVersion->getVersionName()); } $title = Title::newFromText($title); $wgTitle = $title; $article = new Article($title); if (!$article->exists()) { throw new Exception("TOC does not exist for " . $manual->getShortName() . " with version " . $sourceVersion > getVersionName()); } // Let's grab the content and also do an update $oldContent = $content = $article->getContent(); // Remove old Version from old TOC (if exists) preg_match_all("/\\[\\[Category:V:" . $product->getShortName() . ':' . $targetVersion->getVersionName() . "\\]\\]/", $content, $matches); foreach ($matches[0] as $match) { $oldContent = str_replace($match, "", $oldContent); } $article->doEdit($oldContent, "Removed version " . $product->getShortName() . ':' . $targetVersion->getVersionName(), EDIT_UPDATE); // Now do the TOC for the new version if (self::TOCExists($product, $manual, $targetVersion)) { throw new Exception("TOC Already exists for " . $manual->getShortName() . " with version: " . $targetVersion->getVersionName()); } $title = PONYDOCS_DOCUMENTATION_NAMESPACE_NAME . ':' . $product->getShortName() . ':' . $manual->getShortName() . 'TOC' . $targetVersion->getVersionName(); $newTitle = Title::newFromText($title); $wgTitle = $newTitle; $newArticle = new Article($newTitle); if ($newArticle->exists()) { throw new Exception("TOC Already exists."); } // Remove old versions from and add new version to new TOC preg_match_all("/\\[\\[Category:V:[^\\]]*\\]\\]/", $content, $matches); // identify the last of the old tags $lastTag = $matches[0][count($matches[0]) - 1]; // make the new tag $newVersionTag = "[[Category:V:" . $product->getShortName() . ':' . $targetVersion->getVersionName() . "]]"; foreach ($matches[0] as $match) { // delete tags that aren't the last tag if ($match != $lastTag) { $content = str_replace($match, "", $content); // replace the last tag with the new tag } else { $content = str_replace($match, $newVersionTag, $content); } } $newArticle->doEdit($content, "Branched TOC For Version: " . $product->getShortName() . ':' . $sourceVersion->getVersionName() . " from Version: " . $product->getShortName() . ':' . $sourceVersion->getVersionName(), EDIT_NEW); return $title; }