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
 /**
  * Constructor.
  * @param TList the data to be iterated through
  * @param integer start index
  * @param integer number of items to be iterated through
  */
 public function __construct(TList $list, $startIndex, $count)
 {
     $this->_list = $list;
     $this->_index = 0;
     $this->_startIndex = $startIndex;
     if ($startIndex + $count > $list->getCount()) {
         $this->_count = $list->getCount() - $startIndex;
     } else {
         $this->_count = $count;
     }
 }
Ejemplo n.º 3
0
 public function addList()
 {
     try {
         $db = new DB();
         $list = new TList($_POST["name"], $_POST["description"], $_GET["board"]);
         $sql = "INSERT INTO list(name,description,board_id) VALUES (:name,:description,:board_id)";
         $q = $db->getConnection()->prepare($sql);
         $q->execute(array(':name' => $list->getName(), ':description' => $list->getDescription(), ':board_id' => $list->getBoardId()));
     } catch (PDOException $e) {
         echo $e->getMessage();
     }
 }
Ejemplo n.º 4
0
 /**
  * Inserts an item into the collection.
  * @param integer the location where the item will be inserted.
  * The current item at the place and the following ones will be moved backward.
  * @param TListItem the item to be inserted.
  * @throws TInvalidDataTypeException if the item being inserted is neither a string nor TListItem
  */
 public function insertAt($index, $item)
 {
     if (is_string($item)) {
         $item = $this->createNewListItem($item);
     }
     if (!$item instanceof TListItem) {
         throw new TInvalidDataTypeException('listitemcollection_item_invalid', get_class($this));
     }
     parent::insertAt($index, $item);
 }
Ejemplo n.º 5
0
 /**
  * Constructor.
  * Initializes the list with an array or an iterable object.
  * @param array|Iterator the intial data. Default is null, meaning no initial data.
  * @param boolean whether the list is read-only
  * @param numeric the default priority of items without specified priorities.
  * @param integer the precision of the numeric priorities
  * @throws TInvalidDataTypeException If data is not null and is neither an array nor an iterator.
  */
 public function __construct($data = null, $readOnly = false, $defaultPriority = 10, $precision = 8)
 {
     parent::__construct();
     if ($data !== null) {
         $this->copyFrom($data);
     }
     $this->setReadOnly($readOnly);
     $this->setPrecision($precision);
     $this->setDefaultPriority($defaultPriority);
 }
Ejemplo n.º 6
0
 /**
  * Returns the item at the specified offset.
  * This method is exactly the same as {@link offsetGet}.
  * @param integer the index of the item
  * @return mixed the item at the index
  * @throws TInvalidDataValueException if the index is out of the range
  */
 public function itemAt($index)
 {
     if ($this->_customPaging) {
         return parent::itemAt($index);
     } else {
         return parent::itemAt($this->_pageSize * $this->_currentPageIndex + $index);
     }
 }
Ejemplo n.º 7
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.º 8
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.º 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
 /**
  * @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.º 11
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();
 }
Ejemplo n.º 12
0
     if ($tabela == 'imoveis') {
         $criteria->addFilter('codigoImovel', '=', $codigo);
     }
     if ($tabela == 'produtos') {
         $criteria->addFilter('codigoProduto', '=', $codigo);
     }
     if ($tabela == 'galeria') {
         $criteria->addFilter('codigoGaleria', '=', $codigo);
     }
     $galeria = new TRepository();
     $galeria->addEntity('galeriaimagens');
     $galeria->deleteFisico($criteria);
 }
 $object = new $tabelaClass();
 $object->delete($codigo);
 $listagem = new TList();
 if ($tabela == 'paginas') {
     $listagem->setTituloPagina('Páginas');
     $listagem->addColumn('titulo');
     $listagem->addColumn('descricao');
     $listagem->addColumn('ativo');
     $listagem->addEntity($tabela);
 } else {
     if ($tabela == 'banners') {
         $listagem->setTituloPagina(ucfirst($tabela));
         $listagem->addColumn('titulo');
         $listagem->addColumn('descricao');
         $listagem->addColumn('imagem');
         $listagem->addColumn('ativo');
         $listagem->addEntity($tabela);
     } else {
 /**
  * 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.º 14
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.º 15
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 TControl) {
         parent::insertAt($index, $item);
     } else {
         throw new TInvalidDataTypeException('repeateritemcollection_item_invalid');
     }
 }
Ejemplo n.º 16
0
 public function copyTo(TList $array)
 {
     $array->copyFrom($this);
 }
Ejemplo n.º 17
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.º 18
0
        if ($controlador->usuario->store()) {
            $_SESSION['usuario']->senha = $senhaNova;
            echo 'Senha alterada com sucesso!';
        }
    } else {
        echo 'Senha antiga inválida!';
    }
}
//Apaga item
if ($request == 'apagar') {
    $tabela = $_POST['tabela'];
    $tabelaClass = 'tb' . ucfirst($tabela);
    $codigo = $_POST['codigo'];
    $object = new $tabelaClass();
    $object->delete($codigo);
    $listagem = new TList();
    if ($tabela == 'paginas') {
        $listagem->setTituloPagina('Páginas');
        $listagem->addColumn('titulo');
        $listagem->addColumn('descricao');
        $listagem->addColumn('ativo');
        $listagem->addEntity($tabela);
    } else {
        if ($tabela == 'banners') {
            $listagem->setTituloPagina(ucfirst($tabela));
            $listagem->addColumn('titulo');
            $listagem->addColumn('descricao');
            $listagem->addColumn('imagem');
            $listagem->addColumn('ativo');
            $listagem->addEntity($tabela);
        } else {
Ejemplo n.º 19
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.º 20
0
 public function testOffsetUnset()
 {
     $list = new TList(array(1, 2, 3));
     $list->offsetUnset(1);
     self::assertEquals(array(1, 3), $list->toArray());
 }
Ejemplo n.º 21
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.
  * @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 Traversable || $value === null) {
                 return $value;
             } else {
                 throw new TInvalidDataTypeException('databoundcontrol_datasource_invalid', get_class($this));
             }
         }
     }
 }
Ejemplo n.º 22
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 CMultiStateButtonState}
  */
 public function insertAt($index, $item)
 {
     if ($item instanceof CContextMenuItem) {
         parent::insertAt($index, $item);
     } else {
         throw new TInvalidDataTypeException('Invalid context menu item');
     }
 }
Ejemplo n.º 23
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');
     }
 }
Ejemplo n.º 24
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.º 25
0
 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.º 26
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');
     }
 }