Ejemplo n.º 1
0
 public function testGetReadOnly()
 {
     $map = new TMap(null, true);
     self::assertEquals(true, $map->getReadOnly(), 'List is not read-only');
     $map = new TList(null, false);
     self::assertEquals(false, $map->getReadOnly(), 'List is read-only');
 }
Ejemplo n.º 2
0
 /**
  * Removes an item at the specified position.
  * @param integer the index of the item to be removed.
  * @return mixed the removed item.
  */
 public function removeAt($index)
 {
     $step = parent::removeAt($index);
     $this->_wizard->getMultiView()->getViews()->remove($step);
     $this->_wizard->removedWizardStep($step);
     return $step;
 }
Ejemplo n.º 3
0
 /**
  * Inserts an item at the specified position.
  * This overrides the parent implementation by performing additional type checking
  * for each newly added item.
  * @param integer the specified position.
  * @param mixed new item
  * @throws TInvalidDataTypeException if the item to be inserted is not a dependency instance
  */
 public function insertAt($index, $item)
 {
     if ($item instanceof ICacheDependency) {
         parent::insertAt($index, $item);
     } else {
         throw new TInvalidDataTypeException('cachedependencylist_cachedependency_required');
     }
 }
 /**
  * Inserts an item at the specified position.
  * This overrides the parent implementation by performing additional
  * operations for each newly added TAuthorizationRule object.
  * @param integer the specified position.
  * @param mixed new item
  * @throws TInvalidDataTypeException if the item to be inserted is not a TAuthorizationRule object.
  */
 public function insertAt($index, $item)
 {
     if ($item instanceof TAuthorizationRule) {
         parent::insertAt($index, $item);
     } else {
         throw new TInvalidDataTypeException('authorizationrulecollection_authorizationrule_required');
     }
 }
Ejemplo n.º 5
0
 /**
  * @param integer|string index of the cookie in the collection or the cookie's name
  * @return THttpCookie the cookie found
  */
 public function itemAt($index)
 {
     if (is_integer($index)) {
         return parent::itemAt($index);
     } else {
         return $this->findCookieByName($index);
     }
 }
Ejemplo n.º 6
0
 /**
  * Inserts an item at the specified position.
  * This overrides the parent implementation by inserting only {@link THotSpot}.
  * @param integer the speicified position.
  * @param mixed new item
  * @throws TInvalidDataTypeException if the item to be inserted is not a THotSpot.
  */
 public function insertAt($index, $item)
 {
     if ($item instanceof THotSpot) {
         parent::insertAt($index, $item);
     } else {
         throw new TInvalidDataTypeException('hotspotcollection_hotspot_required');
     }
 }
Ejemplo n.º 7
0
 /**
  * Inserts an item at the specified position.
  * This overrides the parent implementation by inserting only TControl descendants.
  * @param integer the speicified position.
  * @param mixed new item
  * @throws TInvalidDataTypeException if the item to be inserted is not a TControl descendant.
  */
 public function insertAt($index, $item)
 {
     if ($item instanceof TControl) {
         parent::insertAt($index, $item);
     } else {
         throw new TInvalidDataTypeException('datalistitemcollection_datalistitem_required');
     }
 }
Ejemplo n.º 8
0
 /**
  * Inserts an item at the specified position.
  * This overrides the parent implementation by performing type
  * check on the item being added.
  * @param integer the speicified position.
  * @param mixed new item
  * @throws TInvalidDataTypeException if the item to be inserted is not a {@link TMetaTag}
  */
 public function insertAt($index, $item)
 {
     if ($item instanceof TMetaTag) {
         parent::insertAt($index, $item);
     } else {
         throw new TInvalidDataTypeException('metatagcollection_metatag_invalid');
     }
 }
Ejemplo n.º 9
0
 /**
  * Removes an item at the specified position.
  * This overrides the parent implementation by performing additional
  * cleanup work when removing a TXmlElement object.
  * @param integer the index of the item to be removed.
  * @return mixed the removed item.
  */
 public function removeAt($index)
 {
     $item = parent::removeAt($index);
     if ($item instanceof TXmlElement) {
         $item->setParent(null);
     }
     return $item;
 }
Ejemplo n.º 10
0
 /**
  * Inserts an item at the specified position.
  * This overrides the parent implementation by inserting only objects that are descendant of {@link TControl}.
  * @param integer the speicified position.
  * @param TControl new item
  * @throws TInvalidDataTypeException if the item to be inserted is not a control.
  */
 public function insertAt($index, $item)
 {
     if ($item instanceof \Prado\Web\UI\TControl) {
         parent::insertAt($index, $item);
     } else {
         throw new TInvalidDataTypeException('repeateritemcollection_item_invalid');
     }
 }
Ejemplo n.º 11
0
 /**
  * Inserts an item at the specified position.
  * This overrides the parent implementation by inserting only TDataGridColumn.
  * @param integer the speicified position.
  * @param mixed new item
  * @throws TInvalidDataTypeException if the item to be inserted is not a TDataGridColumn.
  */
 public function insertAt($index, $item)
 {
     if ($item instanceof TDataGridColumn) {
         $item->setOwner($this->_o);
         parent::insertAt($index, $item);
     } else {
         throw new TInvalidDataTypeException('datagridcolumncollection_datagridcolumn_required');
     }
 }
Ejemplo n.º 12
0
 /**
  * @return TList list of all child elements that have the specified tag-name
  */
 public function getElementsByTagName($tagName)
 {
     $list = new TList();
     if ($this->_elements) {
         foreach ($this->_elements as $element) {
             if ($element->_tagName === $tagName) {
                 $list->add($element);
             }
         }
     }
     return $list;
 }
Ejemplo n.º 13
0
 /**
  * Returns a list of registered validators.
  * If validation group is specified, only the validators in that group will be returned.
  * @param string validation group
  * @return TList registered validators in the requested group. If the group is null, all validators will be returned.
  */
 public function getValidators($validationGroup = null)
 {
     if (!$this->_validators) {
         $this->_validators = new TList();
     }
     if (empty($validationGroup) === true) {
         return $this->_validators;
     } else {
         $list = new TList();
         foreach ($this->_validators as $validator) {
             if ($validator->getValidationGroup() === $validationGroup) {
                 $list->add($validator);
             }
         }
         return $list;
     }
 }
Ejemplo n.º 14
0
 /**
  * Validates if the parameter is a valid data source.
  * If it is a string or an array, it will be converted as a TList object.
  * @param Traversable|array|string data source to be validated
  * @return Traversable the data that is traversable
  * @throws TInvalidDataTypeException if the data is neither null nor Traversable
  */
 protected function validateDataSource($value)
 {
     if (is_string($value)) {
         $list = new TList();
         foreach (TPropertyValue::ensureArray($value) as $key => $value) {
             if (is_array($value)) {
                 $list->add($value);
             } else {
                 $list->add(array($value, is_string($key) ? $key : $value));
             }
         }
         return $list;
     } else {
         if (is_array($value)) {
             return new TMap($value);
         } else {
             if ($value instanceof TDbDataReader) {
                 // read array from TDbDataReader since it's forward-only stream and can only be traversed once
                 return $value->readAll();
             } else {
                 if ($value instanceof \Traversable || $value === null) {
                     return $value;
                 } else {
                     throw new TInvalidDataTypeException('databoundcontrol_datasource_invalid', get_class($this));
                 }
             }
         }
     }
 }
Ejemplo n.º 15
0
 /**
  * Overrides the parent implementation by invoking {@link TControl::clearNamingContainer}
  */
 public function clear()
 {
     parent::clear();
     if ($this->_o instanceof INamingContainer) {
         $this->_o->clearNamingContainer();
     }
 }
Ejemplo n.º 16
0
 public function testOffsetUnset()
 {
     $list = new TList(array(1, 2, 3));
     $list->offsetUnset(1);
     self::assertEquals(array(1, 3), $list->toArray());
 }
Ejemplo n.º 17
0
 /**
  * Performs databinding to populate datagrid items from data source.
  * This method is invoked by {@link dataBind()}.
  * You may override this function to provide your own way of data population.
  * @param Traversable the bound data
  */
 protected function performDataBinding($data)
 {
     $this->reset();
     $keys = $this->getDataKeys();
     $keys->clear();
     $keyField = $this->getDataKeyField();
     // get all columns
     if ($this->getAutoGenerateColumns()) {
         $columns = new TList($this->getColumns());
         $autoColumns = $this->createAutoColumns($data);
         $columns->mergeWith($autoColumns);
     } else {
         $columns = $this->getColumns();
     }
     $this->_allColumns = $columns;
     $items = $this->getItems();
     $index = 0;
     $allowPaging = $this->getAllowPaging() && $data instanceof TPagedDataSource;
     $dsIndex = $allowPaging ? $data->getFirstIndexInPage() : 0;
     $this->setViewState('DataSourceIndex', $dsIndex, 0);
     if ($columns->getCount()) {
         foreach ($columns as $column) {
             $column->initialize();
         }
         $selectedIndex = $this->getSelectedItemIndex();
         $editIndex = $this->getEditItemIndex();
         foreach ($data as $key => $row) {
             if ($keyField !== '') {
                 $keys->add($this->getDataFieldValue($row, $keyField));
             } else {
                 $keys->add($key);
             }
             if ($index === 0) {
                 if ($allowPaging) {
                     $this->_topPager = $this->createPager();
                 }
                 $this->_header = $this->createItemInternal(-1, -1, TListItemType::Header, true, null, $columns);
             }
             if ($index === $editIndex) {
                 $itemType = TListItemType::EditItem;
             } else {
                 if ($index === $selectedIndex) {
                     $itemType = TListItemType::SelectedItem;
                 } else {
                     if ($index % 2) {
                         $itemType = TListItemType::AlternatingItem;
                     } else {
                         $itemType = TListItemType::Item;
                     }
                 }
             }
             $items->add($this->createItemInternal($index, $dsIndex, $itemType, true, $row, $columns));
             $index++;
             $dsIndex++;
         }
         if ($index > 0) {
             $this->_footer = $this->createItemInternal(-1, -1, TListItemType::Footer, true, null, $columns);
             if ($allowPaging) {
                 $this->_bottomPager = $this->createPager();
             }
         }
     }
     $this->setViewState('ItemCount', $index, 0);
     if (!$dsIndex && $this->_emptyTemplate !== null) {
         $this->_useEmptyTemplate = true;
         $this->_emptyTemplate->instantiateIn($this);
         $this->dataBindChildren();
     }
 }
Ejemplo n.º 18
0
 /**
  * This initializes the list and the name of the method to be called
  *	@param string the name of the function call
  */
 public function __construct($method)
 {
     $this->_method = $method;
     parent::__construct();
 }