Article PHP Class Code Examples

This page contains top rated real world PHP examples of class Article extracted from open source projects. You can rate examples to help us improve the quality of examples

Example #1
Show file File: EditPage.php Project: eFFemeer/seizamcore
0
 /**
  * Get the contents to be preloaded into the box, either set by
  * an earlier setPreloadText() or by loading the given page.
  *
  * @param $preload String: representing the title to preload from.
  * @return String
  */
 protected function getPreloadedText($preload)
 {
     global $wgUser, $wgParser;
     if (!empty($this->mPreloadText)) {
         return $this->mPreloadText;
     } elseif ($preload !== '') {
         $title = Title::newFromText($preload);
         # Check for existence to avoid getting MediaWiki:Noarticletext
         if (isset($title) && $title->exists() && $title->userCanRead()) {
             $article = new Article($title);
             if ($article->isRedirect()) {
                 $title = Title::newFromRedirectRecurse($article->getContent());
                 # Redirects to missing titles are displayed, to hidden pages are followed
                 # Copying observed behaviour from ?action=view
                 if ($title->exists()) {
                     if ($title->userCanRead()) {
                         $article = new Article($title);
                     } else {
                         return "";
                     }
                 }
             }
             $parserOptions = ParserOptions::newFromUser($wgUser);
             return $wgParser->getPreloadText($article->getContent(), $title, $parserOptions);
         }
     }
     return '';
 }
Example #2
Show file File: Title.php Project: rocLv/conference
0
 /**
  * Move page to non-existing title.
  * @param &$nt \type{Title} the new Title
  * @param $reason \type{\string} The reason for the move
  * @param $createRedirect \type{\bool} Whether to create a redirect from the old title to the new title
  *  Ignored if the user doesn't have the suppressredirect right
  */
 private function moveToNewTitle(&$nt, $reason = '', $createRedirect = true)
 {
     global $wgUseSquid, $wgUser, $wgContLang;
     $comment = wfMsgForContent('1movedto2', $this->getPrefixedText(), $nt->getPrefixedText());
     if ($reason) {
         $comment .= wfMsgExt('colon-separator', array('escapenoentities', 'content'));
         $comment .= $reason;
     }
     # Truncate for whole multibyte characters. +5 bytes for ellipsis
     $comment = $wgContLang->truncate($comment, 250);
     $newid = $nt->getArticleID();
     $oldid = $this->getArticleID();
     $latest = $this->getLatestRevId();
     $dbw = wfGetDB(DB_MASTER);
     $now = $dbw->timestamp();
     # Save a null revision in the page's history notifying of the move
     $nullRevision = Revision::newNullRevision($dbw, $oldid, $comment, true);
     if (!is_object($nullRevision)) {
         throw new MWException('No valid null revision produced in ' . __METHOD__);
     }
     $nullRevId = $nullRevision->insertOn($dbw);
     $article = new Article($this);
     wfRunHooks('NewRevisionFromEditComplete', array($article, $nullRevision, $latest, $wgUser));
     # Rename page entry
     $dbw->update('page', array('page_touched' => $now, 'page_namespace' => $nt->getNamespace(), 'page_title' => $nt->getDBkey(), 'page_latest' => $nullRevId), array('page_id' => $oldid), __METHOD__);
     $nt->resetArticleID($oldid);
     if ($createRedirect || !$wgUser->isAllowed('suppressredirect')) {
         # Insert redirect
         $mwRedir = MagicWord::get('redirect');
         $redirectText = $mwRedir->getSynonym(0) . ' [[' . $nt->getPrefixedText() . "]]\n";
         $redirectArticle = new Article($this);
         $newid = $redirectArticle->insertOn($dbw);
         $redirectRevision = new Revision(array('page' => $newid, 'comment' => $comment, 'text' => $redirectText));
         $redirectRevision->insertOn($dbw);
         $redirectArticle->updateRevisionOn($dbw, $redirectRevision, 0);
         wfRunHooks('NewRevisionFromEditComplete', array($redirectArticle, $redirectRevision, false, $wgUser));
         # Record the just-created redirect's linking to the page
         $dbw->insert('pagelinks', array('pl_from' => $newid, 'pl_namespace' => $nt->getNamespace(), 'pl_title' => $nt->getDBkey()), __METHOD__);
         $redirectSuppressed = false;
     } else {
         $this->resetArticleID(0);
         $redirectSuppressed = true;
     }
     # Log the move
     $log = new LogPage('move');
     $log->addEntry('move', $this, $reason, array(1 => $nt->getPrefixedText(), 2 => $redirectSuppressed));
     # Purge caches as per article creation
     Article::onArticleCreate($nt);
     # Purge old title from squid
     # The new title, and links to the new title, are purged in Article::onArticleCreate()
     $this->purgeSquid();
 }
Example #3
Show file File: Nuke_body.php Project: yusufchang/app
0
 /**
  * Does the actual deletion of the pages.
  *
  * @param array $pages The pages to delete
  * @param string $reason
  */
 protected function doDelete(array $pages, $reason)
 {
     $res = array();
     foreach ($pages as $page) {
         $title = Title::newFromURL($page);
         $file = $title->getNamespace() == NS_FILE ? wfLocalFile($title) : false;
         $permission_errors = $title->getUserPermissionsErrors('delete', $this->getUser());
         if (count($permission_errors)) {
             throw new PermissionsError('delete', $permission_errors);
         }
         if ($file) {
             $oldimage = null;
             // Must be passed by reference
             $ok = FileDeleteForm::doDelete($title, $file, $oldimage, $reason, false)->isOK();
         } else {
             $article = new Article($title, 0);
             $ok = $article->doDeleteArticle($reason);
         }
         if ($ok) {
             $res[] = wfMsgExt('nuke-deleted', array('parseinline'), $title->getPrefixedText());
         } else {
             $res[] = wfMsgExt('nuke-not-deleted', array('parseinline'), $title->getPrefixedText());
         }
     }
     $this->getOutput()->addHTML("<ul>\n<li>" . implode("</li>\n<li>", $res) . "</li>\n</ul>\n");
     $this->getOutput()->addWikiMsg('nuke-delete-more');
 }
Example #4
Show file File: DefaultController.php Project: Association-Vie-Etudiante-Descartes/site-aved-prod
0
 public function newarticleAction(Request $request)
 {
     $em = $this->getDoctrine()->getManager();
     $article = new Article();
     $form = $this->createForm(new ArticleType($em), $article);
     if ($request->isMethod('POST')) {
         $form->handleRequest($request);
         $thumbnail = $article->getThumbnail();
         $thumbnailName = md5(uniqid()) . '.' . $thumbnail->guessExtension();
         $thumbnailDir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/thumbnail';
         $thumbnail->move($thumbnailDir, $thumbnailName);
         $article->setThumbnail('uploads/thumbnail/' . $thumbnailName);
         $banner = $article->getBanner();
         $bannerName = md5(uniqid()) . '.' . $banner->guessExtension();
         $bannerDir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/banner';
         $banner->move($bannerDir, $bannerName);
         $article->setBanner('uploads/banner/' . $bannerName);
         $article->setDate(new \DateTime("now"));
         $article->setUser($this->get('security.token_storage')->getToken()->getUser());
         if (!$form->isValid()) {
             return $this->redirectToRoute('aved_new_article');
         }
         $em->persist($article);
         $em->flush();
         return $this->redirectToRoute('aved_new_article');
     }
     return $this->render('AvedBlogBundle:Default:new_article.html.twig', array('form' => $form->createView()));
 }
Example #5
Show file File: ModelDeleteTest.php Project: MrGrigorev/reserva-de-salas
0
 /**
  * testDeleteDependent method
  *
  * @return void
  */
 public function testDeleteDependent()
 {
     $this->loadFixtures('Bidding', 'BiddingMessage', 'Article', 'ArticlesTag', 'Comment', 'User', 'Attachment');
     $Bidding = new Bidding();
     $result = $Bidding->find('all');
     $expected = array(array('Bidding' => array('id' => 1, 'bid' => 'One', 'name' => 'Bid 1'), 'BiddingMessage' => array('bidding' => 'One', 'name' => 'Message 1')), array('Bidding' => array('id' => 2, 'bid' => 'Two', 'name' => 'Bid 2'), 'BiddingMessage' => array('bidding' => 'Two', 'name' => 'Message 2')), array('Bidding' => array('id' => 3, 'bid' => 'Three', 'name' => 'Bid 3'), 'BiddingMessage' => array('bidding' => 'Three', 'name' => 'Message 3')), array('Bidding' => array('id' => 4, 'bid' => 'Five', 'name' => 'Bid 5'), 'BiddingMessage' => array('bidding' => '', 'name' => '')));
     $this->assertEquals($expected, $result);
     $Bidding->delete(4, true);
     $result = $Bidding->find('all');
     $expected = array(array('Bidding' => array('id' => 1, 'bid' => 'One', 'name' => 'Bid 1'), 'BiddingMessage' => array('bidding' => 'One', 'name' => 'Message 1')), array('Bidding' => array('id' => 2, 'bid' => 'Two', 'name' => 'Bid 2'), 'BiddingMessage' => array('bidding' => 'Two', 'name' => 'Message 2')), array('Bidding' => array('id' => 3, 'bid' => 'Three', 'name' => 'Bid 3'), 'BiddingMessage' => array('bidding' => 'Three', 'name' => 'Message 3')));
     $this->assertEquals($expected, $result);
     $Bidding->delete(2, true);
     $result = $Bidding->find('all');
     $expected = array(array('Bidding' => array('id' => 1, 'bid' => 'One', 'name' => 'Bid 1'), 'BiddingMessage' => array('bidding' => 'One', 'name' => 'Message 1')), array('Bidding' => array('id' => 3, 'bid' => 'Three', 'name' => 'Bid 3'), 'BiddingMessage' => array('bidding' => 'Three', 'name' => 'Message 3')));
     $this->assertEquals($expected, $result);
     $result = $Bidding->BiddingMessage->find('all', array('order' => array('BiddingMessage.name' => 'ASC')));
     $expected = array(array('BiddingMessage' => array('bidding' => 'One', 'name' => 'Message 1'), 'Bidding' => array('id' => 1, 'bid' => 'One', 'name' => 'Bid 1')), array('BiddingMessage' => array('bidding' => 'Three', 'name' => 'Message 3'), 'Bidding' => array('id' => 3, 'bid' => 'Three', 'name' => 'Bid 3')), array('BiddingMessage' => array('bidding' => 'Four', 'name' => 'Message 4'), 'Bidding' => array('id' => '', 'bid' => '', 'name' => '')));
     $this->assertEquals($expected, $result);
     $Article = new Article();
     $result = $Article->Comment->find('count', array('conditions' => array('Comment.article_id' => 1)));
     $this->assertEquals(4, $result);
     $result = $Article->delete(1, true);
     $this->assertSame($result, true);
     $result = $Article->Comment->find('count', array('conditions' => array('Comment.article_id' => 1)));
     $this->assertEquals(0, $result);
 }
Example #6
Show file File: BehaviorCollectionTest.php Project: magooemp/eramba
0
 /**
  * undocumented function
  *
  * @return void
  */
 public function testBindModelCallsInBehaviors()
 {
     // hasMany
     $Article = new Article();
     $Article->unbindModel(array('hasMany' => array('Comment')));
     $result = $Article->find('first');
     $this->assertFalse(array_key_exists('Comment', $result));
     $Article->Behaviors->attach('Test4');
     $result = $Article->find('first');
     $this->assertTrue(array_key_exists('Comment', $result));
     // belongsTo
     $Article->unbindModel(array('belongsTo' => array('User')));
     $result = $Article->find('first');
     $this->assertFalse(array_key_exists('User', $result));
     $Article->Behaviors->attach('Test5');
     $result = $Article->find('first');
     $this->assertTrue(array_key_exists('User', $result));
     // hasAndBelongsToMany
     $Article->unbindModel(array('hasAndBelongsToMany' => array('Tag')));
     $result = $Article->find('first');
     $this->assertFalse(array_key_exists('Tag', $result));
     $Article->Behaviors->attach('Test6');
     $result = $Article->find('first');
     $this->assertTrue(array_key_exists('Comment', $result));
     // hasOne
     $Comment = new Comment();
     $Comment->unbindModel(array('hasOne' => array('Attachment')));
     $result = $Comment->find('first');
     $this->assertFalse(array_key_exists('Attachment', $result));
     $Comment->Behaviors->attach('Test7');
     $result = $Comment->find('first');
     $this->assertTrue(array_key_exists('Attachment', $result));
 }
Example #7
Show file File: deleteBatch.php Project: eFFemeer/seizamcore
0
 public function execute()
 {
     global $wgUser;
     # Change to current working directory
     $oldCwd = getcwd();
     chdir($oldCwd);
     # Options processing
     $user = $this->getOption('u', 'Delete page script');
     $reason = $this->getOption('r', '');
     $interval = $this->getOption('i', 0);
     if ($this->hasArg()) {
         $file = fopen($this->getArg(), 'r');
     } else {
         $file = $this->getStdin();
     }
     # Setup
     if (!$file) {
         $this->error("Unable to read file, exiting", true);
     }
     $wgUser = User::newFromName($user);
     $dbw = wfGetDB(DB_MASTER);
     # Handle each entry
     for ($linenum = 1; !feof($file); $linenum++) {
         $line = trim(fgets($file));
         if ($line == '') {
             continue;
         }
         $page = Title::newFromText($line);
         if (is_null($page)) {
             $this->output("Invalid title '{$line}' on line {$linenum}\n");
             continue;
         }
         if (!$page->exists()) {
             $this->output("Skipping nonexistent page '{$line}'\n");
             continue;
         }
         $this->output($page->getPrefixedText());
         $dbw->begin();
         if ($page->getNamespace() == NS_FILE) {
             $art = new ImagePage($page);
             $img = wfFindFile($art->mTitle);
             if (!$img || !$img->isLocal() || !$img->delete($reason)) {
                 $this->output(" FAILED to delete image file... ");
             }
         } else {
             $art = new Article($page);
         }
         $success = $art->doDeleteArticle($reason);
         $dbw->commit();
         if ($success) {
             $this->output(" Deleted!\n");
         } else {
             $this->output(" FAILED to delete article\n");
         }
         if ($interval) {
             sleep($interval);
         }
         wfWaitForSlaves();
     }
 }
Example #8
Show file File: ScribeProducer.php Project: Tjorriemorrie/app
0
 /**
  * articleUndelete -- hook
  *
  * @static
  * @access public
  *
  * @param Title $oTitle,
  *
  * @author Piotr Molski (MoLi)
  * @return true
  */
 public static function articleUndelete(&$oTitle, $is_new = false)
 {
     global $wgCityId;
     wfProfileIn(__METHOD__);
     if ($oTitle instanceof Title) {
         $pageId = 0;
         $oArticle = new Article($oTitle, 0);
         if (is_object($oArticle)) {
             $pageId = $oArticle->getID();
         }
         if (empty($pageId) || $pageId < 0) {
             $pageId = $oTitle->getArticleID(Title::GAID_FOR_UPDATE);
         }
         $revId = $oTitle->getLatestRevID(Title::GAID_FOR_UPDATE);
         if ($revId > 0 && $pageId > 0) {
             $oScribeProducer = new ScribeProducer('undelete', $pageId, $revId);
             if (is_object($oScribeProducer)) {
                 $oScribeProducer->send_log();
             }
         } else {
             $title = $oTitle->getText();
             Wikia::log(__METHOD__, "error", "Cannot send log via scribe ({$wgCityId}): invalid revision or page Id: {$title}, page Id: {$pageId}, rev Id: {$revId}");
         }
     } else {
         $isTitle = is_object($oTitle);
         Wikia::log(__METHOD__, "error", "Cannot send log via scribe ({$wgCityId}): invalid title: {$isTitle}");
     }
     wfProfileOut(__METHOD__);
     return true;
 }
Example #9
Show file File: IsAllowedTest.php Project: gbelmm/ACL
0
 public function testIsAllowed()
 {
     $article1 = new Article();
     $this->em->persist($article1);
     $article2 = new Article();
     $this->em->persist($article2);
     $user = new User();
     $this->em->persist($user);
     $this->em->flush();
     $this->acl->grant($user, new ArticleEditorRole($user, $article2));
     $this->assertFalse($this->acl->isAllowed($user, Actions::VIEW, $article1));
     $this->assertFalse($this->acl->isAllowed($user, Actions::EDIT, $article1));
     $this->assertTrue($this->acl->isAllowed($user, Actions::VIEW, $article2));
     $this->assertTrue($this->acl->isAllowed($user, Actions::EDIT, $article2));
 }
Example #10
Show file File: Issue131Test.php Project: esserj/DoctrineExtensions
0
 public function testSlugGeneration()
 {
     $test = new Article();
     $test->setTitle('');
     $this->em->persist($test);
     $this->em->flush();
     $this->assertNull($test->getSlug());
     $test2 = new Article();
     $test2->setTitle('');
     $this->em->persist($test2);
     $this->em->flush();
     $this->assertNull($test2->getSlug());
 }
Example #11
Show file File: Issue114Test.php Project: raphydev/onep
0
 public function testIssue114()
 {
     $repo = $this->em->getRepository(self::TRANSLATION);
     //Categories
     $category1 = new Category();
     $category1->setTitle('en category1');
     $category2 = new Category();
     $category2->setTitle('en category2');
     $this->em->persist($category1);
     $this->em->persist($category2);
     $this->em->flush();
     //Articles
     $article1 = new Article();
     $article1->setTitle('en article1');
     $article1->setCategory($category1);
     $article2 = new Article();
     $article2->setTitle('en article2');
     $article2->setCategory($category1);
     $article3 = new Article();
     $article3->setTitle('en article3');
     $article3->setCategory($category1);
     $this->em->persist($article1);
     $this->em->persist($article2);
     $this->em->persist($article3);
     $this->em->flush();
     $this->translatableListener->setTranslatableLocale('es');
     // Setting es_ES title.
     $article1->setTitle('es article1');
     $article2->setTitle('es article2');
     $article3->setTitle('es article3');
     $this->em->persist($article1);
     $this->em->persist($article2);
     $this->em->persist($article3);
     $this->em->flush();
     // Updating articles' category
     $article1->setCategory($category2);
     $article2->setCategory($category2);
     $article3->setCategory($category2);
     $this->em->persist($article1);
     $this->em->persist($article2);
     $this->em->persist($article3);
     $this->em->flush();
     // Removing $category1
     $this->em->remove($category1);
     $this->em->flush();
     $trans = $repo->findTranslations($article2);
     $this->assertEquals(1, count($trans));
     $trans = $repo->findTranslations($article3);
     $this->assertEquals(1, count($trans));
     $trans = $repo->findTranslations($article1);
     $this->assertEquals(1, count($trans));
 }
Example #12
Show file File: SpecialBlockip.php Project: rocLv/conference
0
 /**
  * Block a list of selected users
  * @param array $users
  * @param string $reason
  * @param string $tag replaces user pages
  * @param string $talkTag replaces user talk pages
  * @returns array, list of html-safe usernames
  */
 public static function doMassUserBlock($users, $reason = '', $tag = '', $talkTag = '')
 {
     global $wgUser;
     $counter = $blockSize = 0;
     $safeUsers = array();
     $log = new LogPage('block');
     foreach ($users as $name) {
         # Enforce limits
         $counter++;
         $blockSize++;
         # Lets not go *too* fast
         if ($blockSize >= 20) {
             $blockSize = 0;
             wfWaitForSlaves(5);
         }
         $u = User::newFromName($name, false);
         // If user doesn't exist, it ought to be an IP then
         if (is_null($u) || !$u->getId() && !IP::isIPAddress($u->getName())) {
             continue;
         }
         $userTitle = $u->getUserPage();
         $userTalkTitle = $u->getTalkPage();
         $userpage = new Article($userTitle);
         $usertalk = new Article($userTalkTitle);
         $safeUsers[] = '[[' . $userTitle->getPrefixedText() . '|' . $userTitle->getText() . ']]';
         $expirestr = $u->getId() ? 'indefinite' : '1 week';
         $expiry = Block::parseExpiryInput($expirestr);
         $anonOnly = IP::isIPAddress($u->getName()) ? 1 : 0;
         // Create the block
         $block = new Block($u->getName(), $u->getId(), $wgUser->getId(), $reason, wfTimestampNow(), 0, $expiry, $anonOnly, 1, 1, 0, 0);
         $oldblock = Block::newFromDB($u->getName(), $u->getId());
         if (!$oldblock) {
             $block->insert();
             # Prepare log parameters
             $logParams = array();
             $logParams[] = $expirestr;
             if ($anonOnly) {
                 $logParams[] = 'anononly';
             }
             $logParams[] = 'nocreate';
             # Add log entry
             $log->addEntry('block', $userTitle, $reason, $logParams);
         }
         # Tag userpage! (check length to avoid mistakes)
         if (strlen($tag) > 2) {
             $userpage->doEdit($tag, $reason, EDIT_MINOR);
         }
         if (strlen($talkTag) > 2) {
             $usertalk->doEdit($talkTag, $reason, EDIT_MINOR);
         }
     }
     return $safeUsers;
 }
Example #13
Show file File: Issue827Test.php Project: saberyounis/Sonata-Project
0
 /**
  * @test
  * @group issue827
  */
 public function handlePersistedSlugsForForeignKeyUniqueBased()
 {
     // Creating categories
     $testCat1 = new Category();
     $testCat1->setTitle('Category1');
     $this->em->persist($testCat1);
     $testCat11 = new Category();
     $testCat11->setTitle('Category1');
     $this->em->persist($testCat11);
     $testCat2 = new Category();
     $testCat2->setTitle('Category2');
     $this->em->persist($testCat2);
     // Creating articles
     $test = new Article();
     $test->setTitle('Unique to category 1');
     $test->setCategory($testCat1);
     $this->em->persist($test);
     $test2 = new Article();
     $test2->setTitle('Unique to category 2');
     $test2->setCategory($testCat2);
     $this->em->persist($test2);
     $test3 = new Article();
     $test3->setTitle('Unique to category 1');
     $test3->setCategory($testCat1);
     $this->em->persist($test3);
     $this->em->flush();
     $this->assertEquals('category1', $testCat1->getSlug());
     $this->assertEquals('category1-1', $testCat11->getSlug());
     $this->assertEquals('category2', $testCat2->getSlug());
     $this->assertEquals('unique-to-category-1', $test->getSlug());
     $this->assertEquals('unique-to-category-2', $test2->getSlug());
     $this->assertEquals('unique-to-category-1-1', $test3->getSlug());
 }
Example #14
Show file File: Title.php Project: amjadtbssm/website
0
 /**
  * Move page to non-existing title.
  * @param &$nt \type{Title} the new Title
  * @param $reason \type{\string} The reason for the move
  * @param $createRedirect \type{\bool} Whether to create a redirect from the old title to the new title
  *  Ignored if the user doesn't have the suppressredirect right
  */
 private function moveToNewTitle(&$nt, $reason = '', $createRedirect = true)
 {
     global $wgUseSquid, $wgUser;
     $fname = 'MovePageForm::moveToNewTitle';
     $comment = wfMsgForContent('1movedto2', $this->getPrefixedText(), $nt->getPrefixedText());
     if ($reason) {
         $comment .= wfMsgExt('colon-separator', array('escapenoentities', 'content'));
         $comment .= $reason;
     }
     $newid = $nt->getArticleID();
     $oldid = $this->getArticleID();
     $latest = $this->getLatestRevId();
     $dbw = wfGetDB(DB_MASTER);
     $now = $dbw->timestamp();
     # Save a null revision in the page's history notifying of the move
     $nullRevision = Revision::newNullRevision($dbw, $oldid, $comment, true);
     $nullRevId = $nullRevision->insertOn($dbw);
     $article = new Article($this);
     wfRunHooks('NewRevisionFromEditComplete', array($article, $nullRevision, $latest, $wgUser));
     # Rename page entry
     $dbw->update('page', array('page_touched' => $now, 'page_namespace' => $nt->getNamespace(), 'page_title' => $nt->getDBkey(), 'page_latest' => $nullRevId), array('page_id' => $oldid), $fname);
     $nt->resetArticleID($oldid);
     if ($createRedirect || !$wgUser->isAllowed('suppressredirect')) {
         # Insert redirect
         $mwRedir = MagicWord::get('redirect');
         $redirectText = $mwRedir->getSynonym(0) . ' [[' . $nt->getPrefixedText() . "]]\n";
         $redirectArticle = new Article($this);
         $newid = $redirectArticle->insertOn($dbw);
         $redirectRevision = new Revision(array('page' => $newid, 'comment' => $comment, 'text' => $redirectText));
         $redirectRevision->insertOn($dbw);
         $redirectArticle->updateRevisionOn($dbw, $redirectRevision, 0);
         wfRunHooks('NewRevisionFromEditComplete', array($redirectArticle, $redirectRevision, false, $wgUser));
         # Record the just-created redirect's linking to the page
         $dbw->insert('pagelinks', array('pl_from' => $newid, 'pl_namespace' => $nt->getNamespace(), 'pl_title' => $nt->getDBkey()), $fname);
         $redirectSuppressed = false;
     } else {
         $this->resetArticleID(0);
         $redirectSuppressed = true;
     }
     # Move an image if this is a file
     if ($this->getNamespace() == NS_FILE) {
         $file = wfLocalFile($this);
         if ($file->exists()) {
             $status = $file->move($nt);
             if (!$status->isOk()) {
                 $dbw->rollback();
                 return $status->getErrorsArray();
             }
         }
     }
     # Log the move
     $log = new LogPage('move');
     $log->addEntry('move', $this, $reason, array(1 => $nt->getPrefixedText(), 2 => $redirectSuppressed));
     # Purge caches as per article creation
     Article::onArticleCreate($nt);
     # Purge old title from squid
     # The new title, and links to the new title, are purged in Article::onArticleCreate()
     $this->purgeSquid();
 }
Example #15
Show file File: RelativeSlugHandlerTest.php Project: esserj/DoctrineExtensions
0
 private function populate()
 {
     $sport = new Article();
     $sport->setTitle('Sport');
     $sport->setCode('test');
     $this->em->persist($sport);
     $cars = new Article();
     $cars->setTitle('Cars');
     $cars->setCode('code');
     $this->em->persist($cars);
     $thomas = new ArticleRelativeSlug();
     $thomas->setTitle('Thomas');
     $thomas->setArticle($sport);
     $this->em->persist($thomas);
     $jen = new ArticleRelativeSlug();
     $jen->setTitle('Jen');
     $jen->setArticle($sport);
     $this->em->persist($jen);
     $john = new ArticleRelativeSlug();
     $john->setTitle('John');
     $john->setArticle($cars);
     $this->em->persist($john);
     $single = new ArticleRelativeSlug();
     $single->setTitle('Single');
     $this->em->persist($single);
     $this->em->flush();
 }
Example #16
Show file File: ClassScopeTest.php Project: gbelmm/ACL
0
 /**
  * Check after a new resource has been created (role was added before)
  */
 public function testNewResource()
 {
     $article1 = new Article();
     $this->em->persist($article1);
     $user = new User();
     $this->em->persist($user);
     $this->em->flush();
     $this->acl->grant($user, new AllArticlesEditorRole($user));
     // Add a new resource after the role was given
     $article2 = new Article();
     $this->em->persist($article2);
     $this->em->flush();
     // Test on the resource class
     $classResource = new ClassResource('Tests\\MyCLabs\\ACL\\Integration\\Model\\Article');
     $this->assertTrue($this->acl->isAllowed($user, Actions::VIEW, $classResource));
     $this->assertTrue($this->acl->isAllowed($user, Actions::EDIT, $classResource));
     $this->assertFalse($this->acl->isAllowed($user, Actions::DELETE, $classResource));
     // Test on entities
     $this->assertTrue($this->acl->isAllowed($user, Actions::VIEW, $article1));
     $this->assertTrue($this->acl->isAllowed($user, Actions::EDIT, $article1));
     $this->assertFalse($this->acl->isAllowed($user, Actions::DELETE, $article1));
     $this->assertTrue($this->acl->isAllowed($user, Actions::VIEW, $article2));
     $this->assertTrue($this->acl->isAllowed($user, Actions::EDIT, $article2));
     $this->assertFalse($this->acl->isAllowed($user, Actions::DELETE, $article2));
 }
Example #17
Show file File: fservices.php Project: lxthien/batdongsan
0
 function detail($title_none = NULL)
 {
     $title_none = $this->uri->segment(3);
     $arrTitle = explode('.', $title_none);
     if ($arrTitle[1] == '' || $arrTitle[1] != 'html') {
         redirect('');
     }
     $title_none = $arrTitle[0];
     $news = new Article();
     $news->where('title_none', $title_none);
     $news->get();
     //print_r($this->db->last_query());exit();
     if (!$news->exists()) {
         show_404();
     }
     $dis['news'] = $news;
     //related news
     $related_news = new Article();
     $related_news->where('recycle', 0);
     $related_news->where('newscatalogue_id', $news->newscatalogue_id);
     $related_news->where("id !=", $news->id);
     $related_news->order_by('created', 'DESC');
     $related_news->get_paged(0, 10, TRUE);
     $dis['related_news'] = $related_news;
     $category = new Newscatalogue($news->newscatalogue_id);
     $dis['category'] = $category;
     $this->page_title = $news->{'title_vietnamese'};
     $this->page_description = $news->short_vietnamese;
     $this->page_keyword = $news->tag;
     $dis['base_url'] = base_url();
     $dis['link'] = base_url() . $_SERVER['REQUEST_URI'];
     $dis['view'] = 'front/services/news_de';
     $this->viewfront($dis);
 }
Example #18
Show file File: fnewsother.php Project: lxthien/batdongsan
0
 function detail($url)
 {
     $urlcat = $this->uri->segment(1);
     $category = new Newscatalogue();
     $category->where(array('recycle' => 0, 'name_none' => $urlcat))->get();
     if (!$category->exists()) {
         show_404();
     }
     $dis['category'] = $category;
     $url = geturlfromuri($this->uri->segment(2));
     $news = new Article();
     $news->where(array('title_none' => $url, 'recycle' => 0));
     $news->get();
     if (!$news->exists()) {
         show_404();
     }
     $dis['news'] = $news;
     $this->page_title = $news->title_vietnamese;
     $this->page_description = $news->short_vietnamese;
     $this->page_keyword = $news->tag;
     //related news
     $related_news = new Article();
     $related_news->where('recycle', 0);
     $related_news->where('newscatalogue_id', $news->newscatalogue_id);
     $related_news->where("id !=", $news->id);
     $related_news->order_by('created', 'DESC');
     $related_news->get_paged(0, 10, TRUE);
     $dis['related_news'] = $related_news;
     $dis['base_url'] = base_url();
     $dis['view'] = 'front/newsother/news_de';
     $this->viewfront($dis);
 }
Example #19
Show file File: faboutus.php Project: lxthien/batdongsan
0
 function detail($title_none = NULL)
 {
     $title_none = $this->uri->segment(3);
     $arrTitle = explode('.', $title_none);
     if ($arrTitle[1] == '' || $arrTitle[1] != 'html') {
         redirect('');
     }
     $title_none = $arrTitle[0];
     $news = new Article();
     $news->where('title_none', $title_none);
     $news->get();
     if (!$news->exists()) {
         show_404();
     }
     $dis['news'] = $news;
     //related news
     $related_news = new Article();
     $related_news->where('recycle', 0);
     $related_news->where('newscatalogue_id', $news->newscatalogue_id);
     $related_news->where("id !=", $news->id);
     $related_news->order_by('created', 'DESC');
     $related_news->get_paged(0, 10, TRUE);
     $dis['related_news'] = $related_news;
     $this->page_title = $news->{'title_vietnamese'};
     $this->page_description = $news->short_vietnamese;
     $this->page_keyword = $news->tag;
     $dis['base_url'] = base_url();
     $dis['link'] = base_url() . $_SERVER['REQUEST_URI'];
     $dis['view'] = 'front/aboutus/aboutus-de';
     $this->viewfront($dis);
 }
Example #20
Show file File: MY_Controller.php Project: lxthien/batdongsan
0
 function resetNewsViewMost()
 {
     try {
         $dateNow = new DateTime(date('Y-m-d'));
         $dateStart = new DateTime(getconfigkey('date_start_reset_news'));
         $interval = $dateNow->diff($dateStart);
         if ($interval->days % 7 == 0) {
             $cauhinh = new Cauhinh();
             $cauhinh->where('fieldname', 'date_reset_news')->get();
             if (getconfigkey('date_reset_news') == 0) {
                 $news = new Article();
                 $news->where('recycle', 0);
                 $news->where_in('newscatalogue_id', array(71, 73, 72, 74, 75, 77, 80, 81, 82, 78, 79));
                 $news->get_iterated();
                 foreach ($news as $row) {
                     $o = new Article($row->id);
                     $o->view_count = 0;
                     $o->save();
                     $o->clear();
                 }
                 $cauhinh->value = 1;
                 $cauhinh->save();
             }
         } else {
             if (getconfigkey('date_reset_news') != 0) {
                 $cauhinh = new Cauhinh();
                 $cauhinh->where('fieldname', 'date_reset_news')->get();
                 $cauhinh->value = 0;
                 $cauhinh->save();
             }
         }
     } catch (Exception $e) {
         echo 'Caught exception: ', $e->getMessage(), "\n";
     }
 }
Example #21
Show file File: RevokedRoleTest.php Project: gbelmm/ACL
0
 public function testRoleRevoked()
 {
     $article1 = new Article();
     $this->em->persist($article1);
     $article2 = new Article();
     $this->em->persist($article2);
     $user = new User();
     $this->em->persist($user);
     $this->em->flush();
     // Before: no access
     $this->assertFalse($this->acl->isAllowed($user, Actions::VIEW, $article1));
     $this->assertFalse($this->acl->isAllowed($user, Actions::EDIT, $article1));
     $this->assertFalse($this->acl->isAllowed($user, Actions::VIEW, $article2));
     $this->assertFalse($this->acl->isAllowed($user, Actions::EDIT, $article2));
     // Role granted: access
     $role = new ArticleEditorRole($user, $article2);
     $this->acl->grant($user, $role);
     $this->assertFalse($this->acl->isAllowed($user, Actions::VIEW, $article1));
     $this->assertFalse($this->acl->isAllowed($user, Actions::EDIT, $article1));
     $this->assertTrue($this->acl->isAllowed($user, Actions::VIEW, $article2));
     $this->assertTrue($this->acl->isAllowed($user, Actions::EDIT, $article2));
     // Role revoked: no access
     $this->acl->revoke($user, $role);
     $this->assertFalse($this->acl->isAllowed($user, Actions::VIEW, $article1));
     $this->assertFalse($this->acl->isAllowed($user, Actions::EDIT, $article1));
     $this->assertFalse($this->acl->isAllowed($user, Actions::VIEW, $article2));
     $this->assertFalse($this->acl->isAllowed($user, Actions::EDIT, $article2));
 }
Example #22
Show file File: DateConverter.php Project: cllu/MediaWiki-Calendar
0
 function convert($newFormat, $pageName, $calName, $redirect, $go)
 {
     $search = "{$pageName}/{$calName}";
     $pages = PrefixSearch::titleSearch($search, 1000000);
     //search upto 1,000,000 events (no performace issue)
     $count = $erroredCount = 0;
     foreach ($pages as $page) {
         $retval = false;
         $newPage = $this->convertToNewPage($page, $newFormat);
         $article = new Article(Title::newFromText($page));
         if ($newPage != '') {
             $fromTitle = Title::newFromText($page);
             $toTitle = Title::newFromText($newPage);
             $articleNew = new Article(Title::newFromText($newPage));
             if (!$article->isRedirect() && !$articleNew->exists()) {
                 if ($go) {
                     $retval = $fromTitle->moveTo($toTitle, true, 'CalendarConversion', $redirect);
                 } else {
                     if ($count < 10) {
                         $testRun .= '&nbsp;&nbsp;' . $page . '  &rarr;&rarr;  ' . $newPage . '<br>';
                     }
                 }
             }
         }
     }
     unset($pages);
     if ($go) {
         $ret = "Conversion completed.";
     } else {
         $ret = "<b>Test Results, add '<i>go</i>' to the <i>dateConverter</i> tag to convert:</b><br>{$testRun}";
     }
     return $ret;
 }
Example #23
Show file File: SMW_QP_RSSlink.php Project: Tjorriemorrie/app
0
 /**
  * Constructor for a single item in the feed. Requires the URI of the item.
  */
 public function __construct(Title $t, $c, $d)
 {
     $this->title = $t;
     $this->uri = $t->getFullURL();
     $this->label = $t->getText();
     $article = null;
     if (count($c) == 0) {
         $article = new Article($t);
         $this->creator = array();
         $this->creator[] = $article->getUserText();
     } else {
         $this->creator = $c;
     }
     $this->date = array();
     if (count($d) == 0) {
         if (is_null($article)) {
             $article = new Article($t);
         }
         $this->date[] = date("c", strtotime($article->getTimestamp()));
     } else {
         foreach ($d as $date) {
             $this->date[] = $date;
         }
     }
     // get content
     if ($t->getNamespace() == NS_MAIN) {
         $this->articlename = ':' . $t->getDBkey();
     } else {
         $this->articlename = $t->getPrefixedDBKey();
     }
 }
Example #24
Show file File: ArticlesController.php Project: Ouajjani/Laravel101
0
 public function store(Requests\ArticleRequest $request)
 {
     // Validation:
     $article = new Article($request->all());
     Auth::user()->articles()->save($article);
     return redirect('articles');
 }
Frequently Used Methods