Lussumo's Software Library is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. Lussumo's Software Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Vanilla; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA The latest source code is available at www.lussumo.com Contact Mark O'Sullivan at mark [at] lussumo [dot] com Description: Class that builds and maintains a select list. Applications utilizing this file: Vanilla;
function GetLanguageSelect($FolderName, &$WarningCollector, $SelectedLanguage)
{
    $Select = false;
    $FolderHandle = @opendir($FolderName);
    if (!$FolderHandle) {
        $WarningCollector->Add("We had a problem opening the languages folder");
    } else {
        $Languages = array();
        $Key = 0;
        // Loop through each file
        while (false !== ($Item = readdir($FolderHandle))) {
            $RecordItem = true;
            if ($Item == "." || $Item == ".." || is_dir($FolderName . $Item)) {
                // do nothing
            } else {
                // Retrieve languages names
                $FileParts = explode(".", $Item);
                $Languages[] = $FileParts[0];
                if ($FileParts[0] == $SelectedLanguage) {
                    $Key = count($Languages);
                }
            }
        }
        $Select = new Select();
        $Select->Name = "Language";
        for ($i = 0; $i < count($Languages); $i++) {
            $Select->AddOption($Languages[$i], $Languages[$i]);
        }
        $Select->SelectedIndex = $Key;
    }
    return $Select;
}
Example #2
0
 public function loadRandom()
 {
     $select = new Select(self::$db);
     $select->from(self::$table, "*")->where("`state` =" . self::$db->getSQ(), array(1))->rand()->limit(1);
     $row = self::$db->selectRow($select);
     return $this->init($row);
 }
Example #3
0
 protected static function getAllOnID($table, $id)
 {
     $select = new Select(self::$db);
     $select->from($table, "*")->where("`id` = ?", array($id));
     $data = self::$db->select($select);
     return $data;
 }
 public function getPerfil()
 {
     $element = new Select('perfil');
     $element->setLabel('Perfil');
     $element->setAttributes(array('id' => 'perfil', 'class' => 'form-control'));
     return $element;
 }
Example #5
0
 /**
  * @covers Select::newSelect
  * @uses   Select::__construct
  * @uses   Select::getQuery
  */
 public function testConstructorTableNameSelect()
 {
     $select = new Select('TableName');
     $assertSql = 'SELECT * FROM TableName';
     // Assert
     $this->assertEquals($select->getQuery(), $assertSql);
 }
 public function loadRandom()
 {
     $select = new Select(self::$db);
     $select->from(self::$table, "*")->rand()->limit(1);
     $row = self::$db->selectRow($select);
     return $this->init($row);
 }
Example #7
0
	function doLogin() {
		$this->save("login");
		if (empty($this->messages)) {
			$select = new Select("users");
			$select->add(Exp::eq("username", $this->login["username"]));
			$user = DB::unique($select);
			if (empty($user)) {
				$this->addMsgMessage("error.fieldNotFound", "login.username");
				Msg::save($this->messages);
				Apu::redirect("login");
			}
			if ($user["password"] != $this->login["password"]) {
				$this->addMsgMessage("error.fieldNotFound", "login.password");
				Msg::save($this->messages);
				Apu::redirect("login");
			}	
			$date = new Date();
			Session::save(LOGIN_SCOPE, $user, "user");
			Session::save(LOGIN_SCOPE, $date, "last_access");
			$this->remove();
			Apu::redirect("frame");
		} else {
			Msg::save($this->messages);
			Apu::redirect("login");
		}
	}
Example #8
0
 /**
  * __construct
  *
  * @param string  $caption  caption
  * @param string  $name     name
  * @param integer $size     size
  * @param integer $value    value unix timestamp
  * @param boolean $showtime true to show time, false for date only
  */
 public function __construct($caption, $name, $size = 2, $value = 0, $showtime = true)
 {
     parent::__construct($caption, '');
     $value = (int) $value;
     $value = $value > 0 ? $value : time();
     $datetime = getdate($value);
     $date = new DateSelect('', $name . '[date]', $size, $value);
     $date->setAttribute('id', $name . '-date');
     $this->addElement($date);
     if ($showtime) {
         $timearray = array();
         for ($i = 0; $i < 24; ++$i) {
             for ($j = 0; $j < 60; $j = $j + 10) {
                 $key = $i * 3600 + $j * 60;
                 $timearray[$key] = $j != 0 ? $i . ':' . $j : $i . ':0' . $j;
             }
         }
         ksort($timearray);
         $timeselect = new Select('', $name . '[time]', $datetime['hours'] * 3600 + 600 * ceil($datetime['minutes'] / 10));
         $timeselect->setAttribute('id', $name . '-time');
         $timeselect->addOptionArray($timearray);
         $timeselect->setClass('span2');
         $this->addElement($timeselect);
     } else {
         $this->addElement(new Hidden($name . '[time]', 0));
     }
 }
Example #9
0
 public function testCompileWithNumericValue()
 {
     $field = new Select("test", "Test", array("test", "blue"), array("useNumericValue" => true));
     $expected = "<label for=\"test\">Test</label><select name=\"test\" ><option value=\"0\" selected=\"selected\">test</option><option value=\"1\">blue</option></select>";
     $value = $field->compile(0);
     $this->assertEquals($expected, $value);
 }
Example #10
0
 public static function getImgOnID($id)
 {
     $select = new Select(self::$db);
     $select->from(self::$table, "*")->where("`product_id` = " . self::$db->getSQ(), array($id));
     $data = self::$db->select($select);
     $images = ObjectDB::buildMultiple(__CLASS__, $data);
     return $images;
 }
Example #11
0
 /** @test */
 public function it_renders_with_options_the_full_html()
 {
     $field = new Select('test', 'Test', ['values' => ['miro' => 'test']]);
     $field->render();
     $options = $field->options();
     $this->assertCount(1, $options);
     $this->assertInstanceOf(Option::class, $options[0]);
 }
Example #12
0
 /**
  * @param Select $select
  * @return array
  */
 public function getElementsCount(Select $select)
 {
     $select->setLimit(null);
     $select->setOffset(null);
     $select->setColumns(array('COUNT(*)'));
     $db = new DbGateway();
     return $db->execute($select, \PDO::FETCH_COLUMN);
 }
Example #13
0
 protected function __listTables($cache = TRUE)
 {
     if ($cache && sizeof($this->tables)) {
         return $this->tables;
     }
     $select = new Select('information_schema.TABLES');
     $select->where(array(array('field' => 'TABLE_SCHEMA', 'value' => $this->params['name'])));
     return $this->tables = $select->execute('\\apf\\db\\mysql5\\Table', $smart = FALSE);
 }
Example #14
0
 public static function getStudentsOnGroupID($group_id)
 {
     $select = new Select(self::$db);
     $select->from(self::$table, "*")->where("`group_id` = ?", array($group_id));
     $data = self::$db->select($select);
     $students = ObjectDB::buildMultiple(__CLASS__, $data);
     //foreach ($groups as $g) $g->postHandling();
     return $students;
 }
Example #15
0
 /**
  * render
  *
  * @return string
  */
 public function render()
 {
     $editor_handler = \XoopsEditorHandler::getInstance();
     $editor_handler->allowed_editors = $this->allowed_editors;
     $option_select = new Select("", $this->name, $this->value);
     $onchangeCode = '"if(this.options[this.selectedIndex].value.length > 0 ){window.document.forms.' . $this->form->getName() . '.submit();}"';
     $option_select->set('onchange', $onchangeCode);
     $option_select->addOptionArray($editor_handler->getList($this->nohtml));
     $this->addElement($option_select);
     return parent::render();
 }
Example #16
0
 public static function getItemsOnView($view)
 {
     $select = new Select(self::$db);
     $select->from(self::$table, "*")->where("`view_id` = ?", array($view));
     $data = self::$db->select($select);
     $items = ObjectDB::buildMultiple(__CLASS__, $data);
     foreach ($items as $item) {
         $item->postHandling();
     }
     return $items;
 }
Example #17
0
 public static function getGroupsOnTeacherID($id)
 {
     $select = new Select(self::$db);
     $select->from(self::$table, "*")->where("`teacher_id` = ?", array($id));
     $data = self::$db->select($select);
     $groups = ObjectDB::buildMultiple(__CLASS__, $data);
     foreach ($groups as $g) {
         $g->postHandling();
     }
     return $groups;
 }
Example #18
0
 public static function getItems()
 {
     $select = new Select(self::$db);
     $select->from(self::$table, array("s.*", "p.img"), "s")->join("INNER", "product", "p", "s.product_id = p.id");
     $data = self::$db->select($select);
     $slider = ObjectDB::buildMultiple(__CLASS__, $data);
     foreach ($slider as $slide) {
         $slide->postHandling();
     }
     return $slider;
 }
Example #19
0
 public function clearSelect()
 {
     $this->last_select_user_id = $this->select_user_id;
     $select = new Select();
     $select->day = $this->room->day;
     $select->state = $this->state;
     $select->selected_mate_id = $this->select_user_id;
     $select->save();
     $this->select_user_id = null;
     $this->save();
 }
Example #20
0
 public function testOffset()
 {
     $offset = 123;
     $table = $this->getMockBuilder(\Sharkodlak\FluentDb\Table::class)->disableOriginalConstructor()->getMock();
     $factory = $this->getMockBuilder(\Sharkodlak\FluentDb\Factory\Factory::class)->getMock();
     $queryBuilder = $this->getMockBuilder(\Sharkodlak\FluentDb\Query\Builder::class)->setConstructorArgs(['SELECT', 'FROM'])->setMethods(['offset'])->getMock();
     $queryBuilder->expects($this->once())->method('offset')->with($this->equalTo($offset));
     $factory->expects($this->once())->method('getQueryBuilder')->will($this->returnValue($queryBuilder));
     $table->expects($this->once())->method('getFactory')->will($this->returnValue($factory));
     $query = new Select($table);
     $this->assertInstanceOf(Select::class, $query->offset($offset));
 }
Example #21
0
 private function createSelect($name, $options)
 {
     $select = new Select();
     $select->setLanguage($this->language);
     $select->push('name', $this->getName() . '[' . $name . ']');
     if ($this->value && $this->value[$name]) {
         $select->setValue($this->value[$name]);
     }
     $this->proxyPush($select);
     $this->buildOptions($select, $options);
     return $select;
 }
Example #22
0
 public static function getIdonNumder($number)
 {
     $select = new Select(self::$db);
     $select->from(self::$table, array("id"))->where("`number` = ?", array($number));
     $id = self::$db->selectCell($select);
     if (!$id) {
         $select = new Select(self::$db);
         $select->from(self::$table, array("id"))->where("`parent_number` = ?", array($number));
         $id = self::$db->selectCell($select);
     }
     return $id;
 }
 public function testSelectComWheresComOrEAnd()
 {
     $select = new Select();
     $where = new Where();
     $where->set('id', '=', 1);
     $where->set('last_name', '=', 1, 'or');
     $where->set('name', '=', 'Erik', 'or');
     $select->table = 'pages';
     $select->where($where);
     $sql = $select->sql();
     $this->assertEquals('SELECT * FROM pages WHERE `id`=:id and `last_name`=:last_name or `name`=:name;', $sql);
 }
Example #24
0
 function __construct($parent, $id, $args = array())
 {
     $this->special_args('label-class', $args);
     $this->label_class = trim('checkbox ' . $this->label_class);
     $this->has_multiple_values = true;
     parent::__construct($parent, $id, $args);
 }
Example #25
0
 /**
  * @param $property
  * @return bool|string
  */
 public function __get($property)
 {
     if ($property == 'inline') {
         return $this->inline;
     }
     return parent::__get($property);
 }
Example #26
0
	function doIndex() {
		$this->fetch("list");
		$select = new Select("lookups");
		if (!empty($this->list["sort"]["key"])) {
			$select->addOrder($this->list["sort"]["key"], $this->list["sort"]["order"]);
			$this->serverDatas["sort"] = $this->list["sort"];
		}
		if (!empty($this->list["filter"])) {
			$filter = $this->list["filter"];
			$select->expressions = array();
			$select->add(Exp::like("type", $filter["type"], Exp::MATCH_BOTH));
			$select->add(Exp::like("code", $filter["code"], Exp::MATCH_BOTH));
		}
		$this->list["list"] = DB::query($select);
		Apu::dispatch("/todo/faces/lookup/lookup_list.php");
	}
 /**
  * @return array
  */
 public function getValueOptions()
 {
     if (empty($this->valueOptions)) {
         $this->valueOptions = $this->defaultValueOptions;
     }
     return parent::getValueOptions();
 }
Example #28
0
 public function formatFormOutput($key, &$attributes, \GO\Customfields\Model\AbstractCustomFieldsRecord $model)
 {
     if (!\GO\Customfields\Model\AbstractCustomFieldsRecord::$formatForExport) {
         return parent::formatFormOutput($key, $attributes, $model);
     } else {
         return $this->getName($attributes[$key]);
     }
 }
Example #29
0
 /**
  * Constructor
  *
  * @param string  $caption caption
  * @param string  $name    name
  * @param mixed   $value   Pre-selected value (or array of them).
  * @param integer $size    Number of rows. "1" makes a drop-down-list
  */
 public function __construct($caption, $name, $value = null, $size = 1)
 {
     parent::__construct($caption, $name, $value, $size, false);
     $this->addOption(XOOPS_MATCH_START, \XoopsLocale::STARTS_WITH);
     $this->addOption(XOOPS_MATCH_END, \XoopsLocale::ENDS_WITH);
     $this->addOption(XOOPS_MATCH_EQUAL, \XoopsLocale::MATCHES);
     $this->addOption(XOOPS_MATCH_CONTAIN, \XoopsLocale::CONTAINS);
 }
Example #30
0
 /**
  * Constructor
  *
  * @param string $name
  * @param string $selectedValue 
  * @param Option $optionsTags 
  * @param string or array $options 
  * @author Justin Palmer
  */
 function __construct($name, array $array, $selectedValue = null, $options = null)
 {
     $options = $this->preparePrompt($options);
     foreach ($array as $option) {
         $this->display .= $option;
     }
     parent::__construct($name, $selectedValue, null, $options);
 }