/**
  * If this is attached to an object with the hierarchy extension, it returns
  * a set of a schema objects attached to any ancestors (which should be
  * present on this object).
  *
  * @return ArrayList
  */
 public function getInheritedSchemas()
 {
     $result = new ArrayList();
     if (!$this->owner->hasExtension('Hierarchy')) {
         return new ArrayList();
     }
     $ids = array();
     $parents = $this->owner->getAncestors();
     foreach ($parents as $parent) {
         $ids[] = $parent->ID;
     }
     if (count($ids)) {
         $filter = sprintf('"MetadataSchema"."ID" = "MetadataSchemaLink"."SchemaID"' . ' AND "MetadataSchemaLink"."ParentClass" = \'%s\'' . ' AND "MetadataSchemaLink"."ParentID" IN (%s)', ClassInfo::baseDataClass($this->owner->class), implode(', ', $ids));
         $result = MetadataSchema::get()->innerJoin('MetadataSchemaLink', $filter);
         if ($result) {
             $result = new ArrayList($result->toArray());
         } else {
             $result = new ArrayList();
         }
     }
     if ($this->owner instanceof SiteTree) {
         // Check SiteConfig too
         $config = SiteConfig::current_site_config();
         if ($config->hasExtension('MetadataExtension')) {
             $schemas = $config->getAttachedSchemas();
             if ($schemas && $schemas->count()) {
                 $result->merge($schemas);
             }
         }
     }
     return $result;
 }
 /**
  * @param ManyManyList $products
  */
 public function updateRelatedProducts(&$products, $limit, $random)
 {
     $curCount = $products->count();
     if ($curCount < $limit) {
         $cfg = Config::inst()->forClass(get_class($this->owner));
         $class = $cfg->get('related_products_class');
         // look up the fields
         $fields = $cfg->get('related_products_fields');
         if (empty($fields)) {
             return;
         }
         if (!is_array($fields)) {
             $fields = array($fields);
         }
         // create a filter from the fields
         $filter = array();
         foreach ($fields as $f) {
             $filter[$f] = $this->owner->getField($f);
         }
         // Convert to an array list so we can add to it
         $products = new ArrayList($products->toArray());
         // Look up products that match the filter
         $generated = DataObject::get($class)->filterAny($filter)->exclude('ID', $this->owner->ID)->sort('RAND()')->limit($limit - $curCount);
         foreach ($generated as $prod) {
             $products->push($prod);
         }
     }
 }
Exemplo n.º 3
0
 /**
  * Sorts the specified list according to the order induced by the specified comparator. All elements in the list
  * must be mutually comparable.
  *
  * @param ArrayList $list
  * @param Comparator $comparator
  * @return ArrayList
  */
 public static function sort(ArrayList &$list, Comparator $comparator)
 {
     $array = $list->toArray();
     usort($array, [$comparator, "compare"]);
     $list->replace($array);
     return $list;
 }
 /**
  * @return ArrayList
  */
 public function Breadcrumbs($unlinked = false)
 {
     $defaultTitle = LeftAndMain::menu_title_for_class('CodeBankIPAgreement');
     $title = _t('CodeBankIPAgreement.MENUTITLE', $defaultTitle);
     $items = new ArrayList(array(new ArrayData(array('Title' => $title, 'Link' => $unlinked ? false : 'admin/codeBank/show/' . $this->currentPageID()))));
     $record = $this->currentPage();
     if ($record && $record->exists()) {
         if ($record->hasExtension('Hierarchy')) {
             $ancestors = $record->getAncestors();
             $ancestors = new ArrayList(array_reverse($ancestors->toArray()));
             $ancestors->push($record);
             foreach ($ancestors as $ancestor) {
                 $items->push(new ArrayData(array('Title' => $ancestor->Title, 'Link' => $unlinked ? false : Controller::join_links($this->Link('show'), $ancestor->ID))));
             }
         } else {
             $items->push(new ArrayData(array('Title' => $record->Title, 'Link' => $unlinked ? false : Controller::join_links($this->Link('show'), $record->ID))));
         }
     }
     return $items;
 }
Exemplo n.º 5
0
	/**
	 * Displays the items from {@link sourceItems()} using the encapsulation object.
	 * If the field value has been set as an array (e.g. after a failed validation),
	 * it generates the rows from array data instead.
	 * Used in the formfield template to iterate over each row.
	 * 
	 * @return SS_List Collection of {@link TableField_Item}
	 */
	function Items() {
		// holds TableField_Item instances
		$items = new ArrayList();

		$sourceItems = $this->sourceItems();

		// either load all rows from the field value,
		// (e.g. when validation failed), or from sourceItems()
		if($this->value) {
			if(!$sourceItems) $sourceItems = new ArrayList();

			// get an array keyed by rows, rather than values
			$rows = $this->sortData(ArrayLib::invert($this->value));
			// ignore all rows which are already saved
			if(isset($rows['new'])) {
				if($sourceItems instanceof DataList) {
					$sourceItems = new ArrayList($sourceItems->toArray());
				}

				$newRows = $this->sortData($rows['new']);
				// iterate over each value (not each row)
				$i = 0;
				foreach($newRows as $idx => $newRow){
					// set a pseudo-ID
					$newRow['ID'] = "new";

					// unset any extradata
					foreach($newRow as $k => $v){
						if($this->extraData && array_key_exists($k, $this->extraData)){
							unset($newRow[$k]);
						}
					}

					// generate a temporary DataObject container (not saved in the database)
					$sourceClass = $this->sourceClass();
					$sourceItems->add(new $sourceClass($newRow));

					$i++;
				}
			}
		} 

		// generate a new TableField_Item instance from each collected item
		if($sourceItems) foreach($sourceItems as $sourceItem) {
			$items->push($this->generateTableFieldItem($sourceItem));
		}

		// add an empty TableField_Item for a single "add row"
		if($this->showAddRow && $this->Can('add')) {
			$items->push(new TableField_Item(null, $this, null, $this->fieldTypes, true));
		}

		return $items;
	}
 /**
  * CMS-specific functionality: Passes through navigation breadcrumbs
  * to the template, and includes the currently edited record (if any).
  * see {@link LeftAndMain->Breadcrumbs()} for details.
  *
  * @param boolean $unlinked
  * @return ArrayData
  */
 function Breadcrumbs($unlinked = false)
 {
     if (!$this->popupController->hasMethod('Breadcrumbs')) {
         return;
     }
     $items = $this->popupController->Breadcrumbs($unlinked);
     if ($this->record && $this->record->ID) {
         $ancestors = $this->record->getAncestors();
         $ancestors = new ArrayList(array_reverse($ancestors->toArray()));
         $ancestors->push($this->record);
         // Push each ancestor to breadcrumbs
         foreach ($ancestors as $ancestor) {
             $items->push(new ArrayData(array('Title' => $ancestor->Title, 'Link' => $unlinked ? false : $this->popupController->Link() . "?ParentID={$ancestor->ID}")));
         }
     } else {
         $items->push(new ArrayData(array('Title' => sprintf(_t('GridField.NewRecord', 'New %s'), $this->record->singular_name()), 'Link' => false)));
     }
     return $items;
 }
Exemplo n.º 7
0
 /**
  * @return ArrayList
  */
 public function Breadcrumbs($unlinked = false)
 {
     $title = self::menu_title_for_class($this->class);
     $items = new ArrayList(array(new ArrayData(array('Title' => $title, 'Link' => $unlinked ? false : $this->Link()))));
     $record = $this->currentPage();
     if ($record && $record->exists()) {
         if ($record->hasExtension('Hierarchy')) {
             $ancestors = $record->getAncestors();
             $ancestors = new ArrayList(array_reverse($ancestors->toArray()));
             $ancestors->push($record);
             foreach ($ancestors as $ancestor) {
                 $items->push(new ArrayData(array('Title' => $ancestor->Title, 'Link' => $unlinked ? false : Controller::join_links($this->Link('show'), $ancestor->ID))));
             }
         } else {
             $items->push(new ArrayData(array('Title' => $record->Title, 'Link' => $unlinked ? false : Controller::join_links($this->Link('show'), $record->ID))));
         }
     }
     return $items;
 }
Exemplo n.º 8
0
 public function testToArray()
 {
     // Remove the following lines when you implement this test.
     $this->assertTrue(\is_array($this->object->toArray()));
 }
 public function testVFI()
 {
     // Given a simple definition, spec should be properly fleshed out
     $spec = VirtualFieldIndex::get_vfi_spec('Product');
     $this->assertEquals('simple', $spec['Price2']['Type']);
     $this->assertEquals('all', $spec['Price2']['DependsOn']);
     $this->assertEquals('sellingPrice', $spec['Price2']['Source']);
     // Given a simple array definition, spec should be properly fleshed out
     $spec = VirtualFieldIndex::get_vfi_spec('Product');
     $this->assertEquals('list', $spec['Category']['Type']);
     $this->assertEquals('all', $spec['Category']['DependsOn']);
     $this->assertEquals('Parent', $spec['Category']['Source'][0]);
     // build the vfi just in case
     VirtualFieldIndex::build('Product');
     $p = $this->objFromFixture('Product', 'p4');
     $cats = new ArrayList(array($this->objFromFixture('ProductCategory', 'c1'), $this->objFromFixture('ProductCategory', 'c2'), $this->objFromFixture('ProductCategory', 'c3')));
     // vfi fields should be present and correct
     $this->assertTrue($p->hasField('VFI_Price'), 'Price index exists');
     $this->assertEquals(5, $p->VFI_Price, 'Price is correct');
     $this->assertTrue($p->hasField('VFI_Category'), 'Category index exists');
     $this->assertEquals('>ProductCategory|' . implode('|', $cats->column('ID')) . '|', $p->VFI_Category, 'Category index is correct');
     // vfi accessors work
     $this->assertEquals(5, $p->getVFI('Price'), 'Simple getter works');
     $this->assertEquals($cats->toArray(), $p->getVFI('Category'), 'List getter works');
     $this->assertNull($p->getVFI('NonExistentField'), 'Non existent field should return null');
 }
Exemplo n.º 10
0
 public function testSort()
 {
     $list = new ArrayList(array(array('Name' => 'Steve'), (object) array('Name' => 'Bob'), array('Name' => 'John')));
     $list->sort('Name');
     $this->assertEquals($list->toArray(), array((object) array('Name' => 'Bob'), array('Name' => 'John'), array('Name' => 'Steve')));
     $list->sort('Name', 'DESC');
     $this->assertEquals($list->toArray(), array(array('Name' => 'Steve'), array('Name' => 'John'), (object) array('Name' => 'Bob')));
 }
Exemplo n.º 11
0
 /**
  * Return the subsites that the current user can access by given permission.
  * Sites will only be included if they have a Title.
  *
  * @param $permCode array|string Either a single permission code or an array of permission codes.
  * @param $includeMainSite If true, the main site will be included if appropriate.
  * @param $mainSiteTitle The label to give to the main site
  * @param $member
  * @return DataList of {@link Subsite} instances
  */
 public static function accessible_sites($permCode, $includeMainSite = true, $mainSiteTitle = "Main site", $member = null)
 {
     // Rationalise member arguments
     if (!$member) {
         $member = Member::currentUser();
     }
     if (!$member) {
         return new ArrayList();
     }
     if (!is_object($member)) {
         $member = DataObject::get_by_id('Member', $member);
     }
     // Rationalise permCode argument
     if (is_array($permCode)) {
         $SQL_codes = "'" . implode("', '", Convert::raw2sql($permCode)) . "'";
     } else {
         $SQL_codes = "'" . Convert::raw2sql($permCode) . "'";
     }
     // Cache handling
     $cacheKey = $SQL_codes . '-' . $member->ID . '-' . $includeMainSite . '-' . $mainSiteTitle;
     if (isset(self::$_cache_accessible_sites[$cacheKey])) {
         return self::$_cache_accessible_sites[$cacheKey];
     }
     $subsites = DataList::create('Subsite')->where("\"Subsite\".\"Title\" != ''")->leftJoin('Group_Subsites', "\"Group_Subsites\".\"SubsiteID\" = \"Subsite\".\"ID\"")->innerJoin('Group', "\"Group\".\"ID\" = \"Group_Subsites\".\"GroupID\" OR \"Group\".\"AccessAllSubsites\" = 1")->innerJoin('Group_Members', "\"Group_Members\".\"GroupID\"=\"Group\".\"ID\" AND \"Group_Members\".\"MemberID\" = {$member->ID}")->innerJoin('Permission', "\"Group\".\"ID\"=\"Permission\".\"GroupID\" AND \"Permission\".\"Code\" IN ({$SQL_codes}, 'CMS_ACCESS_LeftAndMain', 'ADMIN')");
     if (!$subsites) {
         $subsites = new ArrayList();
     }
     $rolesSubsites = DataList::create('Subsite')->where("\"Subsite\".\"Title\" != ''")->leftJoin('Group_Subsites', "\"Group_Subsites\".\"SubsiteID\" = \"Subsite\".\"ID\"")->innerJoin('Group', "\"Group\".\"ID\" = \"Group_Subsites\".\"GroupID\" OR \"Group\".\"AccessAllSubsites\" = 1")->innerJoin('Group_Members', "\"Group_Members\".\"GroupID\"=\"Group\".\"ID\" AND \"Group_Members\".\"MemberID\" = {$member->ID}")->innerJoin('Group_Roles', "\"Group_Roles\".\"GroupID\"=\"Group\".\"ID\"")->innerJoin('PermissionRole', "\"Group_Roles\".\"PermissionRoleID\"=\"PermissionRole\".\"ID\"")->innerJoin('PermissionRoleCode', "\"PermissionRole\".\"ID\"=\"PermissionRoleCode\".\"RoleID\" AND \"PermissionRoleCode\".\"Code\" IN ({$SQL_codes}, 'CMS_ACCESS_LeftAndMain', 'ADMIN')");
     if (!$subsites && $rolesSubsites) {
         return $rolesSubsites;
     }
     $subsites = new ArrayList($subsites->toArray());
     if ($rolesSubsites) {
         foreach ($rolesSubsites as $subsite) {
             if (!$subsites->find('ID', $subsite->ID)) {
                 $subsites->push($subsite);
             }
         }
     }
     if ($includeMainSite) {
         if (!is_array($permCode)) {
             $permCode = array($permCode);
         }
         if (self::hasMainSitePermission($member, $permCode)) {
             $subsites = $subsites->toArray();
             $mainSite = new Subsite();
             $mainSite->Title = $mainSiteTitle;
             array_unshift($subsites, $mainSite);
             $subsites = ArrayList::create($subsites);
         }
     }
     self::$_cache_accessible_sites[$cacheKey] = $subsites;
     return $subsites;
 }
 /**
  * Evaluate yepnope conditions and build Javascript to be output in template
  *
  * @return void
  */
 public function evalYepnope($customScriptID)
 {
     $str = "";
     $tests = $this->yepnopeTests->toArray();
     if (empty($tests)) {
         return;
     }
     if ($yepnope = $this->get_yepnope()) {
         Requirements::javascript($yepnope);
     }
     if ($timeout = $this->get_timeout()) {
         $str .= "yepnope.errorTimeout = " . $timeout . ";\n";
     }
     $data = $this->convertToObject($tests);
     $str .= 'yepnope(' . $data . ');';
     Requirements::customScript($str, $customScriptID);
 }
Exemplo n.º 13
0
 /**
  * @return FieldList
  */
 public function getCMSFields()
 {
     $fields = new FieldList(new TextField('EmailSubject', _t('UserDefinedForm.EMAILSUBJECT', 'Email subject')), new LiteralField('EmailFromContent', '<p>' . _t('UserDefinedForm.EmailFromContent', "The from address allows you to set who the email comes from. On most servers this " . "will need to be set to an email address on the same domain name as your site. " . "For example on yoursite.com the from address may need to be something@yoursite.com. " . "You can however, set any email address you wish as the reply to address.") . "</p>"), new TextField('EmailFrom', _t('UserDefinedForm.FROMADDRESS', 'Send email from')), new TextField('EmailReplyTo', _t('UserDefinedForm.REPLYADDRESS', 'Email for reply to')), new TextField('EmailAddress', _t('UserDefinedForm.SENDEMAILTO', 'Send email to')), new CheckboxField('HideFormData', _t('UserDefinedForm.HIDEFORMDATA', 'Hide form data from email?')), new CheckboxField('SendPlain', _t('UserDefinedForm.SENDPLAIN', 'Send email as plain text? (HTML will be stripped)')), new TextareaField('EmailBody', _t('UserDefinedForm.EMAILBODY', 'Body')));
     $formID = $this->FormID != 0 ? $this->FormID : Session::get('CMSMain.currentPage');
     $dropdowns = array();
     // if they have email fields then we could send from it
     $validEmailFields = EditableEmailField::get()->filter('ParentID', (int) $formID);
     // for the subject, only one-line entry boxes make sense
     $validSubjectFields = EditableTextField::get()->filter('ParentID', (int) $formID)->filterByCallback(function ($item, $list) {
         return (int) $item->getSetting('Rows') === 1;
     });
     // predefined choices are also candidates
     $multiOptionFields = EditableMultipleOptionField::get()->filter('ParentID', (int) $formID);
     $fields->insertAfter($dropdowns[] = new DropdownField('SendEmailFromFieldID', _t('UserDefinedForm.ORSELECTAFIELDTOUSEASFROM', '.. or select a field to use as reply to address'), $validEmailFields->map('ID', 'Title')), 'EmailReplyTo');
     $validEmailFields = new ArrayList($validEmailFields->toArray());
     $validEmailFields->merge($multiOptionFields);
     $validSubjectFields->merge($multiOptionFields);
     $fields->insertAfter($dropdowns[] = new DropdownField('SendEmailToFieldID', _t('UserDefinedForm.ORSELECTAFIELDTOUSEASTO', '.. or select a field to use as the to address'), $validEmailFields->map('ID', 'Title')), 'EmailAddress');
     $fields->insertAfter($dropdowns[] = new DropdownField('SendEmailSubjectFieldID', _t('UserDefinedForm.SELECTAFIELDTOSETSUBJECT', '.. or select a field to use as the subject'), $validSubjectFields->map('ID', 'Title')), 'EmailSubject');
     foreach ($dropdowns as $dropdown) {
         $dropdown->setHasEmptyDefault(true);
         $dropdown->setEmptyString(" ");
     }
     $this->extend('updateCMSFields', $fields);
     return $fields;
 }
Exemplo n.º 14
0
	/**
	 * $list->exclude(array('Name'=>array('bob','phil'), 'Age'=>array(10, 16), 'HasBananas'=>true));
	 */
	public function testMultipleExcludeThreeArguments() {
		$list = new ArrayList(array(
			0 => array('Name' => 'bob', 'Age' => 10, 'HasBananas'=>false),
			1 => array('Name' => 'phil','Age' => 11, 'HasBananas'=>true),
			2 => array('Name' => 'bob', 'Age' => 12, 'HasBananas'=>true),
			3 => array('Name' => 'phil','Age' => 12, 'HasBananas'=>true),
			4 => array('Name' => 'bob', 'Age' => 14, 'HasBananas'=>false),
			4 => array('Name' => 'ann', 'Age' => 14, 'HasBananas'=>true),
			5 => array('Name' => 'phil','Age' => 14, 'HasBananas'=>false),
			6 => array('Name' => 'bob', 'Age' => 16, 'HasBananas'=>false),
			7 => array('Name' => 'phil','Age' => 16, 'HasBananas'=>true),
			8 => array('Name' => 'clair','Age' => 16, 'HasBananas'=>true)
		));

		$list->exclude(array('Name'=>array('bob','phil'),'Age'=>array(10, 16),'HasBananas'=>true));
		$expected = array(
			0 => array('Name' => 'bob', 'Age' => 10, 'HasBananas'=>false),
			1 => array('Name' => 'phil','Age' => 11, 'HasBananas'=>true),
			2 => array('Name' => 'bob', 'Age' => 12, 'HasBananas'=>true),
			3 => array('Name' => 'phil','Age' => 12, 'HasBananas'=>true),
			4 => array('Name' => 'bob', 'Age' => 14, 'HasBananas'=>false),
			4 => array('Name' => 'ann', 'Age' => 14, 'HasBananas'=>true),
			5 => array('Name' => 'phil','Age' => 14, 'HasBananas'=>false),
			6 => array('Name' => 'bob', 'Age' => 16, 'HasBananas'=>false),
			8 => array('Name' => 'clair','Age' => 16, 'HasBananas'=>true)
		);
		$this->assertEquals($expected, $list->toArray());
	}
Exemplo n.º 15
0
 public function testSortSimpleDESCOrder()
 {
     $list = new ArrayList(array(array('Name' => 'Steve'), (object) array('Name' => 'Bob'), array('Name' => 'John')));
     // Sort two arguments
     $list1 = $list->sort('Name', 'DESC');
     $this->assertEquals($list1->toArray(), array(array('Name' => 'Steve'), array('Name' => 'John'), (object) array('Name' => 'Bob')));
     // Sort single string
     $list2 = $list->sort('Name desc');
     $this->assertEquals($list2->toArray(), array(array('Name' => 'Steve'), array('Name' => 'John'), (object) array('Name' => 'Bob')));
     // Sort quoted string
     $list3 = $list->sort('"Name" DESCENDING');
     $this->assertEquals($list3->toArray(), array(array('Name' => 'Steve'), array('Name' => 'John'), (object) array('Name' => 'Bob')));
     // Sort array specifier
     $list4 = $list->sort(array('Name' => 'descending'));
     $this->assertEquals($list4->toArray(), array(array('Name' => 'Steve'), array('Name' => 'John'), (object) array('Name' => 'Bob')));
     // Check original list isn't altered
     $this->assertEquals($list->toArray(), array(array('Name' => 'Steve'), (object) array('Name' => 'Bob'), array('Name' => 'John')));
 }
 function handleAction($request)
 {
     // This method can't be called without ajax.
     if (!$request->isAjax()) {
         $this->parentController->redirectBack();
         return;
     }
     // Protect against CSRF on destructive action
     if (!SecurityToken::inst()->checkRequest($request)) {
         return $this->httpError(400);
     }
     $actions = $this->batchActions();
     $actionClass = $actions[$request->param('BatchAction')]['class'];
     $actionHandler = new $actionClass();
     // Sanitise ID list and query the database for apges
     $ids = preg_split('/ *, */', trim($request->requestVar('csvIDs')));
     foreach ($ids as $k => $v) {
         if (!is_numeric($v)) {
             unset($ids[$k]);
         }
     }
     if ($ids) {
         if (class_exists('Translatable') && Object::has_extension('SiteTree', 'Translatable')) {
             Translatable::disable_locale_filter();
         }
         $pages = DataObject::get($this->recordClass, sprintf('"%s"."ID" IN (%s)', ClassInfo::baseDataClass($this->recordClass), implode(", ", $ids)));
         if (class_exists('Translatable') && Object::has_extension('SiteTree', 'Translatable')) {
             Translatable::enable_locale_filter();
         }
         if (Object::has_extension($this->recordClass, 'Versioned')) {
             // If we didn't query all the pages, then find the rest on the live site
             if (!$pages || $pages->Count() < sizeof($ids)) {
                 foreach ($ids as $id) {
                     $idsFromLive[$id] = true;
                 }
                 if ($pages) {
                     foreach ($pages as $page) {
                         unset($idsFromLive[$page->ID]);
                     }
                 }
                 $idsFromLive = array_keys($idsFromLive);
                 $sql = sprintf('"%s"."ID" IN (%s)', $this->recordClass, implode(", ", $idsFromLive));
                 $livePages = Versioned::get_by_stage($this->recordClass, 'Live', $sql);
                 if ($pages) {
                     // Can't merge into a DataList, need to condense into an actual list first
                     // (which will retrieve all records as objects, so its an expensive operation)
                     $pages = new ArrayList($pages->toArray());
                     $pages->merge($livePages);
                 } else {
                     $pages = $livePages;
                 }
             }
         }
     } else {
         $pages = new ArrayList();
     }
     return $actionHandler->run($pages);
 }
 private function dirFileInfo($dir, $type)
 {
     if (!is_dir($dir)) {
         return false;
     }
     $dirhandle = opendir($dir);
     $arrayFileName = array();
     while (($file = readdir($dirhandle)) !== false) {
         if ($file != "." && $file != "..") {
             $typelen = 0 - strlen($type);
             if (substr($file, $typelen) == $type) {
                 $file_only_name = substr($file, 0, strlen($file) + $typelen);
                 $file_name_arr = explode("_", $file_only_name);
                 $file_only_name = $file_name_arr[0];
                 $fileIdx = $file_name_arr[1];
                 if ($fileIdx) {
                     $arrayFileName[$file_only_name][$fileIdx] = array('filename' => $file, 'filedate' => to_date($file_only_name));
                 } else {
                     $arrayFileName[$file_only_name][] = array('filename' => $file, 'filedate' => to_date($file_only_name));
                 }
             }
         }
     }
     //通过ArrayList类对数组排序
     foreach ($arrayFileName as $k => $group) {
         $arr = new ArrayList($group);
         $arr->ksort();
         $arrayFileName[$k] = $arr->toArray();
     }
     return $arrayFileName;
 }
 /**
  * Returns the elements for the static slider view.
  * 
  * @return ArrayList
  *
  * @author Sascha Koehler <*****@*****.**>, Sebastian Diel <*****@*****.**>
  * @since 21.02.2013
  */
 public function Elements()
 {
     if (is_null($this->elements)) {
         switch ($this->useSelectionMethod) {
             case 'products':
                 $this->elements = $this->getElementsByProducts();
                 break;
             case 'productGroup':
             default:
                 $this->elements = $this->getElementsByProductGroup();
                 break;
         }
         $this->elements = new ArrayList($this->elements->toArray());
         foreach ($this->elements as $element) {
             $element->addCartFormIdentifier = $this->ID . '_' . $element->ID;
         }
     }
     return $this->elements;
 }