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; } } }
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; }
public function offsetUnset($dao_name) { unset($this->container[\Helper\Text::classNameOnly($dao_name)]); }
/** * 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; }
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'))); }
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; }