Ejemplo n.º 1
0
 public function fromArray(array $values)
 {
     foreach ($values as $attribute => $value) {
         if (property_exists($this, $attribute)) {
             $attribute = \Helper\Text::sanitizeAttributeName($attribute);
             $this->{$attribute} = $value;
         } else {
             $this->foreignAttributes[$attribute] = $value;
         }
     }
 }
Ejemplo n.º 2
0
 public function getColLabels(array $only_these_cols = array())
 {
     if (!empty($only_these_cols)) {
         $cols = array();
         foreach ($only_these_cols as $col) {
             if (!key_exists($col, $this->labels)) {
                 $this->labels[$col] = \Helper\Text::generateLabel($col);
             }
             $cols[$col] = $this->labels[$col];
         }
         return $cols;
     }
     return $this->labels;
 }
Ejemplo n.º 3
0
 public function offsetUnset($dao_name)
 {
     unset($this->container[\Helper\Text::classNameOnly($dao_name)]);
 }
Ejemplo n.º 4
0
 /**
  * Returns the original columns of table based on class attributes
  * @return array Columns for SELECT
  */
 private function getOriginalColumns()
 {
     $className = \Helper\Text::classNameOnly(get_called_class());
     $class = 'Model\\' . $className;
     $reflection = new \ReflectionClass($class);
     $properties = $reflection->getProperties(\ReflectionProperty::IS_PUBLIC);
     $cols = array();
     foreach ($properties as $property) {
         if ($property->getDeclaringClass()->getName() == $class) {
             $cols[] = $property->getName();
         }
     }
     return $cols;
 }
Ejemplo n.º 5
0
 public function testInList()
 {
     $h = new Text($this->container);
     $this->assertEquals('?', $h->in('a', array('b' => 'c')));
     $this->assertEquals('c', $h->in('b', array('b' => 'c')));
 }
Ejemplo n.º 6
0
 private function getSearchingArea($keys, $values, $options)
 {
     $search = $this->app['request']->get($options['paramName'], array('value' => '', 'field' => ''));
     $btID = isset($options['buttonId']) ? $options['buttonId'] : 'ssk_search_input';
     $selID = isset($options['selectId']) ? $options['selectId'] : 'ssk_search_select';
     $placeholder = isset($options['placeholder']) ? $options['placeholder'] : 'Input search string';
     $default = isset($options['defaultText']) ? $options['defaultText'] : '-- Choose --';
     $text = isset($options['buttonText']) ? $options['buttonText'] : 'Search';
     $container = isset($options['container']) ? $options['container'] : 'ssk_search_container';
     $error = isset($options['error']) ? $options['error'] : 'Must choose field!';
     $html = '<div id="' . $container . '">' . "\n";
     $html .= '<select id="' . $selID . '" name="' . $options['paramName'] . '[field]">' . "\n";
     $html .= '    <option value="">' . $default . '</option>' . "\n";
     foreach ($keys as $idx => $val) {
         $html .= '    <option value="' . $val . '"' . ($search['field'] == $val ? ' selected' : '') . '>' . \Helper\Text::generateLabel($values[$idx]) . '</option>' . "\n";
     }
     $html .= '</select>' . "\n";
     $html .= '<input type="search" name="' . $options['paramName'] . '[value]" value="' . $search['value'] . '" placeholder="' . $placeholder . '" />' . "\n";
     $html .= '<button id="' . $btID . '">' . $text . '</button>' . "\n";
     $html .= '<script>' . "\n";
     $html .= '    var button = document.getElementById("' . $btID . '");' . "\n";
     $html .= '    button.addEventListener("click", sskCallSearch, false);' . "\n";
     $html .= '    function sskCallSearch(evt) {' . "\n";
     $html .= '        evt.preventDefault();' . "\n";
     $html .= '        var form = document.getElementById("ssk_table_modifier_form");' . "\n";
     $html .= '        var selectSearch = document.getElementById("' . $selID . '");' . "\n";
     $html .= '        var searchField = selectSearch.options[selectSearch.selectedIndex].value;' . "\n";
     $html .= '        if (searchField != "")' . "\n";
     $html .= '            form.submit();' . "\n";
     $html .= '        else' . "\n";
     $html .= '            alert("' . $error . '");' . "\n";
     $html .= '    }' . "\n";
     $html .= '</script>' . "\n";
     $html .= '</div>' . "\n";
     return $html;
 }