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


PHP ArrayList::count方法代码示例

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


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

示例1: testThereIsNoPaginatorWhenOnlyOnePage

 function testThereIsNoPaginatorWhenOnlyOnePage()
 {
     // We set the itemsPerPage to an reasonably big number so as to avoid test broke from small changes on the fixture YML file
     $total = $this->list->count();
     $this->gridField->getConfig()->getComponentByType("GridFieldPaginator")->setItemsPerPage($total);
     $fieldHolder = $this->gridField->FieldHolder();
     $content = new CSSContentParser($fieldHolder);
     // Check that there is no paginator render into the footer
     $this->assertEquals(0, count($content->getBySelector('.datagrid-pagination')));
     // Check that there is still 'View 1 - 4 of 4' part on the left of the paginator
     $this->assertEquals(1, count($content->getBySelector('.pagination-records-number')));
 }
开发者ID:nomidi,项目名称:sapphire,代码行数:12,代码来源:GridFieldPaginatorTest.php

示例2: testRelationList

 public function testRelationList()
 {
     $list = new ArrayList();
     $this->loader->transforms['Course.Title'] = array('create' => true, 'link' => true, 'list' => $list);
     $results = $this->loader->load();
     $this->assertEquals(3, $results->CreatedCount(), "3 records created");
     $this->assertEquals(3, $list->count(), "3 relations created");
     //make sure re-run doesn't change relation list
     $results = $this->loader->load();
     $this->assertEquals(3, $results->CreatedCount(), "3 more records created");
     $this->assertEquals(3, $list->count(), "relation list count remains the same");
 }
开发者ID:helpfulrobot,项目名称:burnbright-silverstripe-importexport,代码行数:12,代码来源:BulkLoaderRelationTest.php

示例3: testDeleteActionRemoveRelation

 public function testDeleteActionRemoveRelation()
 {
     $this->logInWithPermission('ADMIN');
     $config = GridFieldConfig::create()->addComponent(new GridFieldDeleteAction(true));
     $gridField = new GridField('testfield', 'testfield', $this->list, $config);
     $form = new Form(new Controller(), 'mockform', new FieldList(array($this->gridField)), new FieldList());
     $stateID = 'testGridStateActionField';
     Session::set($stateID, array('grid' => '', 'actionName' => 'deleterecord', 'args' => array('RecordID' => $this->idFromFixture('GridFieldAction_Delete_Team', 'team1'))));
     $request = new SS_HTTPRequest('POST', 'url', array(), array('action_gridFieldAlterAction?StateID=' . $stateID => true));
     $this->gridField->gridFieldAlterAction(array('StateID' => $stateID), $this->form, $request);
     $this->assertEquals(2, $this->list->count(), 'User should be able to delete records with ADMIN permission.');
 }
开发者ID:ivoba,项目名称:silverstripe-framework,代码行数:12,代码来源:GridFieldDeleteActionTest.php

示例4: testPaginationAvoidsIllegalOffsets

 public function testPaginationAvoidsIllegalOffsets()
 {
     $grid = $this->gridField;
     $total = $this->list->count();
     $perPage = $grid->getConfig()->getComponentByType('GridFieldPaginator')->getItemsPerPage();
     // Get the last page that will contain results
     $lastPage = ceil($total / $perPage);
     // Set the paginator state to point to an 'invalid' page
     $grid->State->GridFieldPaginator->currentPage = $lastPage + 1;
     // Get the paginated list
     $list = $grid->getManipulatedList();
     // Assert that the paginator state has been corrected and the list contains items
     $this->assertEquals(1, $grid->State->GridFieldPaginator->currentPage);
     $this->assertEquals($perPage, $list->count());
 }
开发者ID:aaronleslie,项目名称:aaronunix,代码行数:15,代码来源:GridFieldPaginatorTest.php

示例5: index

 public function index()
 {
     $featured_news = new ArrayList($this->news_repository->getFeaturedNews(true, 3));
     $recent_news = new ArrayList($this->news_repository->getRecentNews());
     $slide_news = new ArrayList($this->news_repository->getSlideNews());
     return $this->renderWith(array('NewsPage', 'Page'), array('FeaturedNews' => $featured_news, 'RecentNews' => $recent_news, 'SlideNews' => $slide_news, 'SlideNewsCount' => $slide_news->count()));
 }
开发者ID:Thingee,项目名称:openstack-org,代码行数:7,代码来源:NewsPage_Controller.php

示例6: downloads

 /**
  * This may need to be optimised. We'll just have to see how it performs.
  *
  * @param SS_HTTPRequest $req
  * @return array
  */
 public function downloads(SS_HTTPRequest $req)
 {
     $downloads = new ArrayList();
     $member = Member::currentUser();
     if (!$member || !$member->exists()) {
         $this->httpError(401);
     }
     // create a dropdown for sorting
     $sortOptions = Config::inst()->get('DownloadableAccountPageController', 'sort_options');
     if ($sortOptions) {
         $sort = $req->requestVar('sort');
         if (empty($sort)) {
             reset($sortOptions);
             $sort = key($sortOptions);
         }
         $sortControl = new DropdownField('download-sort', 'Sort By:', $sortOptions, $sort);
     } else {
         $sort = 'PurchaseDate';
         $sortControl = '';
     }
     // create a list of downloads
     $orders = $member->getPastOrders();
     if (!empty($orders)) {
         foreach ($orders as $order) {
             if ($order->DownloadsAvailable()) {
                 $downloads->merge($order->getDownloads());
             }
         }
     }
     Requirements::javascript(SHOP_DOWNLOADABLE_FOLDER . '/javascript/AccountPage_downloads.js');
     return array('Title' => 'Digital Purchases', 'Content' => '', 'SortControl' => $sortControl, 'HasDownloads' => $downloads->count() > 0, 'Downloads' => $downloads->sort($sort));
 }
开发者ID:helpfulrobot,项目名称:markguinn-silverstripe-shop-downloadable,代码行数:38,代码来源:DownloadableAccountPageController.php

示例7: testCount

 public function testCount()
 {
     $list = new ArrayList();
     $this->assertEquals(0, $list->count());
     $list = new ArrayList(array(1, 2, 3));
     $this->assertEquals(3, $list->count());
 }
开发者ID:maent45,项目名称:redefine_renos,代码行数:7,代码来源:ArrayListTest.php

示例8: testRetainAll

 public function testRetainAll()
 {
     // Remove the following lines when you implement this test.
     $this->assertTrue($this->object->retainAll($list = $this->object->subList(2, 8)));
     $this->assertTrue($this->object->count() == 6);
     $this->assertTrue($this->object->get(0) == 2);
     $list = $this->object->subList(2, 4);
     $list->add(5468);
     $this->assertFalse($this->object->retainAll($list));
 }
开发者ID:robo47,项目名称:BlazeFramework,代码行数:10,代码来源:ArrayListTest.php

示例9: FindChildrenOfType

 function FindChildrenOfType($objectType, $all = false, $limit = null)
 {
     $result = new ArrayList();
     $children = $all ? $this->owner->AllChildren() : $this->owner->Children();
     foreach ($children as $child) {
         if (!is_null($limit) && $result->count() >= $limit) {
             break;
         }
         if ($child->ClassName == $objectType) {
             $result->add($child);
         }
         if ($child->hasMethod('FindChildrenOfType')) {
             $result->merge($child->FindChildrenOfType($objectType, $all, is_null($limit) ? null : $limit - $result->count()));
         }
     }
     return $result;
 }
开发者ID:helpfulrobot,项目名称:gdmedia-silverstripe-gdm-extensions,代码行数:17,代码来源:SSGuru_PageUtilities.php

示例10: getRecentPosts

 /**
  * Get the latest posts
  *
  * @param int $limit Number of posts to return
  * @param int $forumID - Forum ID to limit it to
  * @param int $threadID - Thread ID to limit it to
  * @param int $lastVisit Optional: Unix timestamp of the last visit (GMT)
  * @param int $lastPostID Optional: ID of the last read post
  */
 function getRecentPosts($limit = 50, $forumID = null, $threadID = null, $lastVisit = null, $lastPostID = null)
 {
     $filter = array();
     if ($lastVisit) {
         $lastVisit = @date('Y-m-d H:i:s', $lastVisit);
     }
     $lastPostID = (int) $lastPostID;
     // last post viewed
     if ($lastPostID > 0) {
         $filter[] = "\"Post\".\"ID\" > '" . Convert::raw2sql($lastPostID) . "'";
     }
     // last time visited
     if ($lastVisit) {
         $filter[] = "\"Post\".\"Created\" > '" . Convert::raw2sql($lastVisit) . "'";
     }
     // limit to a forum
     if ($forumID) {
         $filter[] = "\"Post\".\"ForumID\" = '" . Convert::raw2sql($forumID) . "'";
     }
     // limit to a thread
     if ($threadID) {
         $filter[] = "\"Post\".\"ThreadID\" = '" . Convert::raw2sql($threadID) . "'";
     }
     // limit to just this forum install
     $filter[] = "\"ForumPage\".\"ParentID\"='{$this->ID}'";
     $posts = Post::get()->leftJoin('ForumThread', '"Post"."ThreadID" = "ForumThread"."ID"')->leftJoin(ForumHolder::baseForumTable(), '"ForumPage"."ID" = "Post"."ForumID"', 'ForumPage')->limit($limit)->sort('"Post"."ID"', 'DESC')->where($filter);
     $recentPosts = new ArrayList();
     foreach ($posts as $post) {
         $recentPosts->push($post);
     }
     if ($recentPosts->count() > 0) {
         return $recentPosts;
     }
     return null;
 }
开发者ID:helpfulrobot,项目名称:silverstripe-forum,代码行数:44,代码来源:ForumHolder.php

示例11: DataList

 function DataList()
 {
     $list = new ArrayList();
     if (!$this->value) {
         return $list;
     }
     $val = $this->value;
     $cols = array_keys($this->columns);
     $subcols = array_keys($this->subColumns);
     $i = 0;
     foreach ($val as $data) {
         $i++;
         $arr = $data;
         if (is_object($arr)) {
             $arr = get_object_vars($arr);
         }
         $rows = new ArrayList();
         $subcolumnsToAdd = array();
         $subcolumnsHaveValues = false;
         foreach ($arr as $k => $v) {
             if (in_array($k, $subcols)) {
                 if ($v) {
                     $subcolumnsHaveValues = true;
                 }
                 $subcolumnsToAdd[] = array('Name' => $k, 'Label' => $this->subColumns[$k][self::KEY_HEADER], 'Value' => $v);
             }
             // Ignore unknown columns
             if (!in_array($k, $cols)) {
                 continue;
             }
             $rows->push(new ArrayData(array('Name' => $k, 'Value' => $v)));
         }
         $list->push(new ArrayData(array('ID' => $i, 'Rows' => $rows)));
         foreach ($subcolumnsToAdd as $subcolumnToAdd) {
             $list->push(new ArrayData(array('ID' => $i, 'SubColumn' => 1, 'SubcolumnsHaveValues' => $v, 'ColSpan' => $rows->count(), 'Rows' => new ArrayData($subcolumnToAdd))));
         }
     }
     return $list;
 }
开发者ID:helpfulrobot,项目名称:lekoala-silverstripe-form-extras,代码行数:39,代码来源:TableField.php

示例12: init

 /**
  * init runs on start of a new Order (@see onAfterWrite)
  * it adds all the modifiers to the orders and the starting OrderStep
  *
  * @param Boolean $recalculate
  * @return DataObject (Order)
  **/
 public function init($recalculate = false)
 {
     if ($this->IsSubmitted()) {
         user_error("Can not init an order that has been submitted", E_USER_NOTICE);
     } else {
         //to do: check if shop is open....
         if ($this->StatusID || $recalculate) {
             if (!$this->StatusID) {
                 $createdOrderStatus = OrderStep::get()->First();
                 if (!$createdOrderStatus) {
                     user_error("No ordersteps have been created", E_USER_WARNING);
                 }
                 $this->StatusID = $createdOrderStatus->ID;
             }
             $createdModifiersClassNames = array();
             $modifiersAsArrayList = new ArrayList();
             $modifiers = $this->modifiersFromDatabase($includingRemoved = true);
             if ($modifiers->count()) {
                 foreach ($modifiers as $modifier) {
                     $modifiersAsArrayList->push($modifier);
                 }
             }
             if ($modifiersAsArrayList->count()) {
                 foreach ($modifiersAsArrayList as $modifier) {
                     $createdModifiersClassNames[$modifier->ID] = $modifier->ClassName;
                 }
             } else {
             }
             $modifiersToAdd = EcommerceConfig::get("Order", "modifiers");
             if (is_array($modifiersToAdd) && count($modifiersToAdd) > 0) {
                 foreach ($modifiersToAdd as $numericKey => $className) {
                     if (!in_array($className, $createdModifiersClassNames)) {
                         if (class_exists($className)) {
                             $modifier = new $className();
                             //only add the ones that should be added automatically
                             if (!$modifier->DoNotAddAutomatically()) {
                                 if (is_a($modifier, "OrderModifier")) {
                                     $modifier->OrderID = $this->ID;
                                     $modifier->Sort = $numericKey;
                                     //init method includes a WRITE
                                     $modifier->init();
                                     //IMPORTANT - add as has_many relationship  (Attributes can be a modifier OR an OrderItem)
                                     $this->Attributes()->add($modifier);
                                     $modifiersAsArrayList->push($modifier);
                                 }
                             }
                         } else {
                             user_error("reference to a non-existing class: " . $className . " in modifiers", E_USER_NOTICE);
                         }
                     }
                 }
             }
             $this->extend('onInit', $this);
             //careful - this will call "onAfterWrite" again
             $this->write();
         }
     }
     return $this;
 }
开发者ID:TouchtechLtd,项目名称:silverstripe-ecommerce,代码行数:66,代码来源:Order.php

示例13: getViewableChildren

 /**
  * All viewable product groups of this group.
  *
  * @param int $numberOfProductGroups Number of product groups to display
  * 
  * @return PaginatedList
  * 
  * @author Sebastian Diel <sdiel@pixeltricks.de>, Ramon Kupper <rkupper@pixeltricks.de>
  * @since 04.01.2014
  */
 public function getViewableChildren($numberOfProductGroups = false)
 {
     if ($this->viewableChildren === null) {
         $viewableChildren = new ArrayList();
         foreach ($this->Children() as $child) {
             if ($child->hasProductsOrChildren()) {
                 $viewableChildren->push($child);
             }
         }
         if ($viewableChildren->count() > 0) {
             if ($numberOfProductGroups == false) {
                 if ($this->productGroupsPerPage) {
                     $pageLength = $this->productGroupsPerPage;
                 } else {
                     $pageLength = SilvercartConfig::ProductGroupsPerPage();
                 }
             } else {
                 $pageLength = $numberOfProductGroups;
             }
             $pageStart = $this->getSqlOffsetForProductGroups($numberOfProductGroups);
             $viewableChildrenPage = new PaginatedList($viewableChildren, $this->getRequest());
             $viewableChildrenPage->setPaginationGetVar('groupStart');
             $viewableChildrenPage->setPageStart($pageStart);
             $viewableChildrenPage->setPageLength($pageLength);
             $this->viewableChildren = $viewableChildrenPage;
         } else {
             return false;
         }
     }
     return $this->viewableChildren;
 }
开发者ID:silvercart,项目名称:silvercart,代码行数:41,代码来源:SilvercartProductGroupPage.php

示例14: testExcludeWithTwoArrays

	/**
	 * $list->exclude(array('Name'=>'bob, 'Age'=>21)); // exclude all Bob that has Age 21
	 */
	public function testExcludeWithTwoArrays() {
		$list = new ArrayList(array(
			0=>array('Name' => 'Bob' , 'Age' => 21),
			1=>array('Name' => 'Bob' , 'Age' => 32),
			2=>array('Name' => 'John', 'Age' => 21)
		));
		
		$list->exclude(array('Name' => 'Bob', 'Age' => 21));
		
		$expected = array(
			1=>array('Name' => 'Bob', 'Age' => 32),
			2=>array('Name' => 'John', 'Age' => 21)
		);
		
		$this->assertEquals(2, $list->count());
		$this->assertEquals($expected, $list->toArray(), 'List should only contain John and Bob');
	}
开发者ID:redema,项目名称:sapphire,代码行数:20,代码来源:ArrayListTest.php

示例15: catch

} catch (Exception $e) {
    echo get_class($e), ': ', $e->getMessage(), "\n\n";
}
try {
    echo "Removing using unset\n";
    unset($list[1]);
} catch (Exception $e) {
    echo get_class($e), ': ', $e->getMessage(), "\n\n";
}
// IList::indexOf()
echo "indexOf Jack:\n";
Debug::dump($list->indexOf($jack));
echo "indexOf Mary:\n";
Debug::dump($list->indexOf($mary));
// IList::count
echo "Count: ", $list->count(), "\n";
echo "Count: ", count($list), "\n";
// IList::getIterator
echo "Get Interator:\n";
foreach ($list as $key => $person) {
    echo $key, ' => ', $person->sayHi();
}
// IList::clear
echo "Clearing\n";
$list->clear();
foreach ($list as $person) {
    $person->sayHi();
}
// ArrayList::__construct()
$arr = array('a' => $jack, 'b' => $mary, 'c' => $foo);
try {
开发者ID:vrana,项目名称:nette,代码行数:31,代码来源:test.ArrayList.php


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