Inheritance: extends Component
Exemplo n.º 1
0
 function testTags()
 {
     $string = "<b>a</b><em>b</em>c<img />";
     $this->assertEqual(FilterComponent::tags($string), 'abc');
     $this->assertEqual(FilterComponent::tags($string, array('b')), '<b>a</b>bc');
     $this->assertEqual(FilterComponent::tags($string, array('b', 'em', 'img')), '<b>a</b><em>b</em>c<img />');
     $this->assertEqual(FilterComponent::tags($string, array('b'), true), 'a<em>b</em>c<img />');
     $this->assertEqual(FilterComponent::tags($string, array('img'), true), '<b>a</b><em>b</em>c');
     $this->assertEqual(FilterComponent::tags($string, array('b', 'img'), true), 'a<em>b</em>c');
 }
 function testUrl()
 {
     $url = "http://url.com";
     $this->assertTrue(ValidatorComponent::url($url));
     $url = "http:/url.com";
     $this->assertFalse(ValidatorComponent::url($url));
     $url = "http://u rl.com";
     $this->assertFalse(ValidatorComponent::url($url));
     $url = FilterComponent::url($url);
     $this->assertTrue(ValidatorComponent::url($url));
 }
Exemplo n.º 3
0
 public function buildDashboard()
 {
     $this->setDashboardTitle("Stock Dashboard");
     $kpi = new KPIGroupComponent('kpi');
     $kpi->setDimensions(12, 2);
     $kpi->setCaption('Units stock by Category');
     $Units = $this->get_units(true);
     foreach ($Units as $key => $value) {
         $kpi->addKPI($value['id'], array('caption' => $value['CategoryName'], 'value' => $value['Quantity'] / 10, 'numberSuffix' => ' units', 'numberHumanize' => true));
     }
     $this->addComponent($kpi);
     $kpi1 = new KPIGroupComponent('kpi1');
     $kpi1->setDimensions(12, 2);
     // $kpi1->setCaption('Units stock by Category');
     $Units = $this->get_units(false);
     foreach ($Units as $key => $value) {
         $kpi1->addKPI($value['id'], array('caption' => $value['CategoryName'], 'value' => $value['Quantity'], 'numberSuffix' => ' units', 'numberHumanize' => true));
     }
     $this->addComponent($kpi1);
     $table = new TableComponent('table');
     $table->setCaption("List of Item in Stock");
     $table->setDimensions(6, 4);
     $stock = $this->get_stock();
     $table->addColumn('id', 'Product Id');
     $table->addColumn('name', 'Product Name');
     $table->addColumn('category', 'Category');
     $table->addColumn('price', 'Price');
     $table->addColumn('stock', 'Stock');
     $table->addMultipleRows($this->PolulateData($stock));
     $this->addComponent($table);
     $c12 = new FilterComponent('filter');
     $c12->setDimensions(6, 6);
     $c12->setCaption('Filter items in stock');
     $category = $this->get_category();
     $c12->addSelectFilter('category', 'Select Category', array_merge(['no selection'], ArrayUtils::pluck($category, 'CategoryName')));
     $c12->addTextFilter('contains', 'Product Name Contains');
     $c12->addNumericRangeFilter('stock', 'Units In Stock', array(0, 100));
     $this->addComponent($c12);
     $c12->onApplyClick(array($table), 'handleApply', $this);
 }
Exemplo n.º 4
0
Arquivo: Search.php Projeto: arhe/pwak
 /**
  * Appelé entre autres par Mapper::_getSQLRequest() pour construire un objet
  * Filter si le paramètre $attributeFilters est un tableau
  *
  * @access public
  * @param  array $array le tableau filtre
  * @return object FilterComponent
  */
 public static function buildFilterFromArray($array = array(), $filter = false, $cls = '')
 {
     $metafilter = new FilterComponent();
     $metafilter->operator = FilterComponent::OPERATOR_AND;
     if ($filter instanceof FilterComponent) {
         if (empty($array)) {
             return $filter;
         }
         $metafilter->setItem($filter);
     }
     foreach ($array as $filterName => $filterValue) {
         if (false !== strpos($filterName, '.')) {
             $operator = is_array($filterValue) ? 'In' : 'Equals';
             $component = SearchTools::newFilterComponent($filterName, $filterName, $operator, $filterValue, 1, $cls);
             $metafilter->setItem($component);
         } else {
             $operator = is_array($filterValue) ? FilterRule::OPERATOR_IN : FilterRule::OPERATOR_EQUALS;
             $rule = new FilterRule($filterName, $operator, $filterValue);
             $metafilter->setItem($rule);
         }
     }
     return $metafilter;
 }
Exemplo n.º 5
0
 /**
  * Try to retrieve a filtered backlink from the session.
  *
  * @param array $url proper route array
  * @return array
  */
 public function getBacklink($url)
 {
     App::uses('FilterComponent', 'Filter.Controller/Component');
     return FilterComponent::getBacklink($url);
 }
Exemplo n.º 6
0
 private function process($data)
 {
     $data = FilterComponent::sanitize($data);
     $data = $this->smartDates($data);
     return $data;
 }