当前位置: 首页>>代码示例>>PHP>>正文


PHP manager::loadModel方法代码示例

本文整理汇总了PHP中manager::loadModel方法的典型用法代码示例。如果您正苦于以下问题:PHP manager::loadModel方法的具体用法?PHP manager::loadModel怎么用?PHP manager::loadModel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在manager的用法示例。


在下文中一共展示了manager::loadModel方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testManyInsDel

 function testManyInsDel()
 {
     $model = manager::loadModel(0);
     //$logoot = new logootEngine($model);
     $logoot = manager::getNewEngine($model);
     $oldContent = "";
     for ($i = 0; $i < 500; $i++) {
         //500 inserts / 499 deletion
         //insert X
         $newContent = "{$i}";
         $listOp1 = $logoot->generate($oldContent, $newContent);
         if ($i == 0) {
             //ins first line
             $this->assertEquals(1, $listOp1->size());
         } else {
             $this->assertEquals(2, $listOp1->size());
         }
         $oldContent = $newContent;
     }
     $modelAssert = $logoot->getModel();
     $this->assertEquals(3, count($modelAssert->getPositionlist()));
 }
开发者ID:hala54,项目名称:DSMW,代码行数:22,代码来源:logootTest.php

示例2: testConcDelOpIntegration

 function testConcDelOpIntegration()
 {
     $oldtext = "";
     $conctext = "line1\nline2\nline3\nline4";
     $model = manager::loadModel(0);
     //$logoot = new logootEngine($model);
     $logoot = manager::getNewEngine($model);
     $listOp = $logoot->generate($oldtext, $conctext);
     //$model has 4 lines created by 4 ins operations
     $tmpMod = $logoot->getModel();
     $this->assertEquals(6, count($tmpMod->getPositionlist()));
     $this->assertEquals(6, count($tmpMod->getLinelist()));
     $oldtext = "line1\nline2\nline3\nline4";
     $actualtext = "line1\nline2\nline4";
     $listOp1 = $logoot->generate($oldtext, $actualtext);
     $tmpMod = $logoot->getModel();
     $this->assertEquals(5, count($tmpMod->getPositionlist()));
     $this->assertEquals(5, count($tmpMod->getLinelist()));
     $logoot->integrate($listOp1);
     $modelAssert = $logoot->getModel();
     $this->assertEquals(5, count($modelAssert->getPositionlist()));
     $this->assertEquals(5, count($modelAssert->getLinelist()));
 }
开发者ID:hala54,项目名称:DSMW,代码行数:23,代码来源:logootTest1.php

示例3: newRev

function newRev($article)
{
    global $wgCanonicalNamespaceNames;
    $indexNS = 0;
    $dbr = wfGetDB(DB_SLAVE);
    $article = str_replace(" ", "_", $article);
    preg_match("/^(.+?)_*:_*(.*)\$/S", $article, $tmp);
    $articleWithoutNS = $tmp[2];
    $NS = $tmp[1];
    if (in_array($NS, $wgCanonicalNamespaceNames)) {
        foreach ($wgCanonicalNamespaceNames as $key => $value) {
            if ($NS == $value) {
                $indexNS = $key;
            }
        }
    }
    $title = Title::newFromText($article);
    if (!$title->exists()) {
        $article = new Article($title);
        $article->doEdit('', '');
    } else {
        $lastRevision = Revision::loadFromTitle($dbr, $title);
        $rev_id = $lastRevision->getPrevious()->getId();
        $revID = $lastRevision->getId();
        $model = manager::loadModel($rev_id);
        $article = new Article($title);
        $article->quickEdit($model->getText(), '');
    }
}
开发者ID:hala54,项目名称:DSMW,代码行数:29,代码来源:IntegrationFunctions.php

示例4: uploadComplete

function uploadComplete($image)
{
    global $wgServerName, $wgScriptPath, $wgServer, $wgVersion;
    $urlServer = 'http://' . $wgServerName . $wgScriptPath;
    //$classe = get_class($image);
    if (compareMWVersion($wgVersion, '1.16.0') == -1) {
        $localfile = $image->mLocalFile;
    } else {
        $localfile = $image->getLocalFile();
    }
    $path = utils::prepareString($localfile->mime, $localfile->size, $wgServer . $localfile->url);
    if (!file_exists($path)) {
        $dbr = wfGetDB(DB_SLAVE);
        $lastRevision = Revision::loadFromTitle($dbr, $localfile->getTitle());
        if ($lastRevision->getPrevious() == null) {
            $rev_id = 0;
        } else {
            $rev_id = $lastRevision->getPrevious()->getId();
        }
        $revID = $lastRevision->getId();
        $model = manager::loadModel($rev_id);
        $patch = new Patch(false, true, null, $urlServer, $rev_id, null, null, null, $localfile->mime, $localfile->size, $localfile->url, null);
        $patch->storePage($localfile->getTitle(), $revID);
        //stores the patch in a wikipage
        manager::storeModel($revID, $sessionId = session_id(), $model, $blobCB = 0);
    }
    return true;
}
开发者ID:hala54,项目名称:DSMW,代码行数:28,代码来源:DSMW.php

示例5: run

 function run()
 {
     global $wgServerName, $wgScriptPath, $wgServer, $wgScriptExtension;
     $urlServer = 'http://' . $wgServerName;
     wfProfileIn('DSMWUpdateJob::run()');
     $revids = array();
     $revids1 = array();
     $page_ids = array();
     //Getting all the revision ids of pages having been logootized
     $db = wfGetDB(DB_SLAVE);
     $model_table = $db->tableName('model');
     $sql = "SELECT `rev_id` FROM {$model_table}";
     $res = $db->query($sql);
     while ($row = $db->fetchObject($res)) {
         $revids[] = $row->rev_id;
     }
     $db->freeResult($res);
     //if (count($revids)==0) $revids=array();
     //Getting all the revision ids without the pages in the DSMW namespaces and
     //Administration_pull_site_addition and Administration_pull_site_addition pages
     $rev_table = $db->tableName('revision');
     $page_table = $db->tableName('page');
     $sql = "SELECT {$rev_table}.`rev_id` FROM {$rev_table}, {$page_table} WHERE\n     `rev_page`=`page_id` and `page_namespace`!= 110 and `page_namespace`!= 200\n        and `page_namespace`!= 210 and `page_namespace`!= 220 \nand `page_title`!= \"Administration_pull_site_addition\"\nand `page_title` != \"Administration_push_site_addition\"";
     $res1 = $db->query($sql);
     while ($row = $db->fetchObject($res1)) {
         $revids1[] = $row->rev_id;
     }
     $db->freeResult($res1);
     //if (count($revids1)==0) $revids1=array();
     //Array_diff returns an array containing all the entries from $revids1 that are
     //not present in $revids.
     $diff = array_diff($revids1, $revids);
     //get page ids of these revisions (each id must be unique in the array)
     foreach ($diff as $id) {
         $page_id = $db->selectField('revision', 'rev_page', array('rev_id' => $id));
         $page_ids[] = $page_id;
     }
     $page_ids = array_unique($page_ids);
     sort($page_ids);
     //Now we can logootize:
     if (count($page_ids) != 0) {
         foreach ($page_ids as $pageid) {
             $title = Title::newFromID($pageid);
             $ns = $title->getNamespace();
             $lastRev = Revision::loadFromPageId($db, $pageid);
             $pageText = $lastRev->getText();
             //load an empty model
             $model = manager::loadModel(0);
             $logoot = manager::getNewEngine($model, DSMWSiteId::getInstance()->getSiteId());
             // new logootEngine($model);
             $listOp = $logoot->generate("", $pageText);
             $modelAfterIntegrate = $logoot->getModel();
             $tmp = serialize($listOp);
             $patchid = sha1($tmp);
             if ($ns == NS_FILE || $ns == NS_IMAGE || $ns == NS_MEDIA) {
                 $apiUrl = $wgServer . $wgScriptPath . "/api" . $wgScriptExtension;
                 $onPage = str_replace(array(' '), array('%20'), $lastRev->getTitle()->getText());
                 $download = $apiUrl . "?action=query&titles=File:" . $onPage . "&prop=imageinfo&format=php&iiprop=mime|url|size";
                 $resp = Http::get($download);
                 $resp = unserialize($resp);
                 $a = $resp['query']['pages'];
                 $a = current($a);
                 $a = $a['imageinfo'];
                 $a = current($a);
                 $mime = $a['mime'];
                 $size = $a['size'];
                 $url = $a['url'];
                 $patch = new Patch(false, true, null, $urlServer . $wgScriptPath, 0, null, null, null, $mime, $size, $url, null);
                 $patch->storePage('File:' . $lastRev->getTitle()->getText(), $lastRev->getId());
             } else {
                 $patch = new Patch(false, false, $listOp, $urlServer, 0);
                 $patch->storePage($lastRev->getTitle()->getText(), $lastRev->getId());
             }
             manager::storeModel($lastRev->getId(), $sessionId = session_id(), $modelAfterIntegrate, $blobCB = 0);
         }
     }
     wfProfileOut('DSMWUpdateJob::run()');
     return true;
 }
开发者ID:hala54,项目名称:DSMW,代码行数:79,代码来源:DSMWUpdateJob.php

示例6: test5

 function test5()
 {
     $model = manager::loadModel(0);
     $logoot = manager::getNewEngine($model, 3);
     $logoot->compute("Space-filling_curve.xml");
     $doc = simplexml_load_file("Space-filling_curve.xml");
     $ota = explode("\n", $doc->current_page);
     $nta = explode("\n", $logoot->getModel()->getText());
     $counter = 0;
     if (count($ota) == 1 && $ota[0] == "") {
         unset($ota[0]);
     }
     $diffs = new Diff1($ota, $nta);
     $ok = true;
     foreach ($diffs->edits as $operation) {
         switch ($operation->type) {
             case "add":
                 $adds = $operation->closing;
                 ksort($adds, SORT_NUMERIC);
                 foreach ($adds as $lineNb => $linetxt) {
                     echo "Add {$lineNb} : '{$linetxt}'\n";
                 }
                 $ok = false;
                 break;
             case "delete":
                 foreach ($operation->orig as $lineNb => $linetxt) {
                     echo "Del {$lineNb} : '{$linetxt}'\n";
                 }
                 $ok = false;
                 break;
             case "change":
                 foreach ($operation->orig as $lineNb => $linetxt) {
                     echo "Change/Del {$lineNb} : '{$linetxt}'\n";
                 }
                 $adds1 = $operation->closing;
                 ksort($adds1, SORT_NUMERIC);
                 foreach ($adds1 as $lineNb => $linetxt) {
                     echo "Change/Add {$lineNb} : '{$linetxt}'\n";
                 }
                 $ok = false;
                 break;
             case "copy":
                 break;
             default:
         }
     }
     $this->assertTrue($ok);
 }
开发者ID:hala54,项目名称:DSMW,代码行数:48,代码来源:logootTest2.php


注:本文中的manager::loadModel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。