/** * @param bool $asKey * @return string */ public function getType($asKey = false) { if ($asKey) { return $this->type; } return $this->types->getType($this->type); }
public static function fromString(string $type, Types $types) : TypeInterface { $type = new Str($type); if (!$type->match(self::PATTERN)) { throw new InvalidArgumentException(); } return new self($types->build((string) $type->getMatches(self::PATTERN)->get('inner'))); }
/** * {@inheritdoc} */ public static function fromConfig(MapInterface $config, Types $types) : TypeInterface { if ((string) $config->keyType() !== 'scalar' || (string) $config->valueType() !== 'variable') { throw new InvalidArgumentException(); } $type = new self(); $type->innerKey = $config->get('inner'); $type->inner = $types->build($config->get('inner'), $config->remove('inner')); return $type; }
/** * Сохраняет скриншоты и связи между играми и жанрами после сохранения * игры */ public function afterSave() { //если запись уже существует, то перед обновлением удаляем все связанные данные if (!$this->isNewRecord) { $this->dbConnection->createCommand('DELETE FROM ygs_games_types WHERE gt_game_id=' . $this->g_id)->execute(); //скриншоты удаляем только если updateScreenshots == true if ($this->updateScreenshots) { $this->dbConnection->createCommand('DELETE FROM ygs_screenshots WHERE s_game_id=' . $this->g_id)->execute(); } } //сохраняем жанры foreach ($this->g_types as $type) { if (($t = Types::model()->findByPk($type)) !== null) { $this->dbConnection->createCommand('INSERT INTO ygs_games_types (gt_game_id, gt_type_id) VALUES (' . $this->g_id . ',' . $type . ')')->execute(); } } //сохраняем скриншоты if ($this->updateScreenshots) { $command = $this->dbConnection->createCommand('INSERT INTO ygs_screenshots (s_game_id, s_image, s_thumbnail) VALUES (:s_game_id, :s_image, :s_thumbnail)'); foreach ($this->g_screenshots as $screenshot) { $command->bindParam(':s_game_id', $this->g_id, PDO::PARAM_INT); $command->bindParam(':s_image', $screenshot->IMAGE, PDO::PARAM_STR); $command->bindParam(':s_thumbnail', $screenshot->THUMBNAIL, PDO::PARAM_STR); $command->execute(); } } }
/** * Show the form for creating a new resource. * * @return Response */ public function create() { $input = Input::all(); $products = Products::filter($input, 25); $types = Types::dropdownList(); return View::make('sales.create', compact('products', 'types', 'input')); }
public function provideItemsOfVariousTypes() { $data = []; foreach (Types::getAll() as $type => $item) { $data[$type] = [$item, $type]; } return $data; }
/** * @param string $tab * @return string */ public function dump($tab = "") { if ($this->cast == Types::OBJECT) { $cast = $this->instance_of; } else { $cast = Types::getTypeCode($this->cast); } return $cast . ' ' . ($this->is_ref ? '&' : '') . '$' . $this->name . ($this->is_optional ? ' = ' . var_export($this->value, true) : ''); }
public function setValue($value) { if ($this instanceof EntityConstant && !is_scalar($value)) { throw new \LogicException("Only scalar value allowed in constant"); } $this->type = Types::detectType($value); $this->value = $value; return $this; }
/** * @covers Phossa\Db\Types::guessType() */ public function testGuessType() { // null $this->assertEquals(Types::PARAM_NULL, Types::guessType(null)); // int $this->assertEquals(Types::PARAM_INT, Types::guessType(12)); // bool $this->assertEquals(Types::PARAM_BOOL, Types::guessType(false)); // string $this->assertEquals(Types::PARAM_STR, Types::guessType('test')); }
public function testTypes() { $types = new Types(); $types->sequence = 123; $types->clientForename = "Lucius Junius"; $types->clientSurname = "Brutus"; $types->clientMobile = "01234567890"; $types->clientEmail = "*****@*****.**"; $types->supplierForename = "Leslie"; $types->supplierSurname = "Lamport"; $types->supplierMobile = "01987654321"; $types->supplierEmail = "*****@*****.**"; $msg = $types->serialize(); $this->assertSame("dee674a1bcac455b7cd1801f4008c65d0a37b2ea", sha1($msg)); $typesRcvd = new Types($msg); $typesRcvd->unserialize(); $msg = $typesRcvd->serialize(); $this->assertSame("dee674a1bcac455b7cd1801f4008c65d0a37b2ea", sha1($msg)); $this->assertEquals($types, $typesRcvd); }
public function __construct($objectName, IAdaptingType $typedObject) { $this->m_objectName = $objectName; $this->m_typedObject = $typedObject; try { $this->m_mappedType = Types::getServerTypeForClientClass($objectName); } catch (Exception $ex) { } if ($this->m_mappedType != null) { $serverType = $this->m_mappedType->getName(); } else { $serverType = "Unknown"; } if (LOGGING) { Log::log(LoggingConstants::SERIALIZATION, "class: {$objectName}, server type: {$serverType}"); } }
/** * Метод предназначен для преобразования значения в поле g_rate * таблицы ygs_games в массив соответствующих жанров * @return array массив с жанрами */ public function _decodeTypes($value) { if (count($this->_allTypes) == 0) { //получаем список жанров $this->_allTypes = Types::model()->findAll(); } $types = array(); //перебираем все жанры и проверяем указаны ли они в поле жанра игры //для этого используется логическая операция "И" foreach ($this->_allTypes as $type) { if ((int) $value & (int) $type->t_id) { $types[] = $type; } } //возвращаем массив с жанрами return $types; }
/** * Show the form for creating a new resource. * * @return Response */ public function create() { $suppliers = Suppliers::dropdownList(); $types = Types::dropdownList(); return View::make('stocks.create', compact('suppliers', 'types')); }
private function getClientClass($className) { return Types::getClientClassForServerType($className); }
$type->setName(0); $type->setVarName(0); $type->insertType(); echo $type->getId(); break; case 'deleteType': $type = new Types(); if (!$type->verifyAreJobs(intval($_POST['id']))) { $type->setId(intval($_POST['id'])); $type->deleteType(); echo 1; } echo 0; break; case 'saveType': $type = new Types(); $type->setVarName($_POST['var_name']); $type->setName($_POST['name']); $type->setId(intval($_POST['id'])); $type->updateType(); break; } exit; } $template = 'types.tpl'; $js[] = 'types'; $type = new Types(); $type->getAllTypes(); $types = $type->getTypesArray(); $smarty->assign('types', $types); $smarty->assign('current_category', 'types');
public function __construct() { parent::__construct("job status type"); $this->map = array(self::SUCCESS => "success", self::RUNNING => "running", self::FAILED => "failed"); }
/** * Returns array of all column types available. * * @return string[] * */ public function getColumns() { $types_num = array('INTEGER', 'BIGINT', '-', 'DECIMAL', 'DOUBLE', '-', 'BOOLEAN', 'SERIAL', 'UUID'); $types_date = array('DATE', 'DATETIME', 'TIMESTAMP', 'TIME'); $types_string = array('VARCHAR', 'TEXT', '-', 'VARBINARY', 'BLOB', '-', 'ENUM'); if (PMA_MYSQL_INT_VERSION >= 70132) { $types_string[] = '-'; $types_string[] = 'IPV6'; } $ret = parent::getColumns(); // numeric $ret[_pgettext('numeric types', 'Numeric')] = $types_num; // Date/Time $ret[_pgettext('date and time types', 'Date and time')] = $types_date; // Text $ret[_pgettext('string types', 'String')] = $types_string; return $ret; }
public static function getHitPoints($kind) { return self::$properties[Types::getKindAsString($kind)]['hp']; }
/** * Возвращает жанр по его id, если он не найден - 404-ую ошибку * id может быть указан в первом параметре или в массиве $_GET * * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer the primary key value. Defaults to null, meaning using the 'id' GET variable */ public function loadTypes($id = null) { if ($this->_model === null) { if ($id !== null || isset($_GET['id'])) { $this->_model = Types::model()->findbyPk($id !== null ? $id : $_GET['id']); } if ($this->_model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } } return $this->_model; }
public function run() { $types = Types::model()->findAll(); $this->render('typesMenu', array('types' => $types)); }
public function __construct() { parent::__construct("decision scope"); $this->map = array(self::ITEM => "local", self::PACKAGE => "package", self::REPO => "global"); }
public function __construct() { parent::__construct("upload status type"); $this->map = array(self::OPEN => "open", self::IN_PROGRESS => "in progress", self::CLOSED => "closed", self::REJECTED => "rejected"); }
/** * 格式化从Data class获得的配置信息 * * @param array $options * @return array */ protected function normalizeOptions(array $options) { $options = array_merge(array('service' => null, 'collection' => null, 'attributes' => array(), 'readonly' => false, 'strict' => false), $options); $primary_key = array(); foreach ($options['attributes'] as $key => $attribute) { $attribute = Types::normalizeAttribute($attribute); if ($attribute['strict'] === null) { $attribute['strict'] = $options['strict']; } if ($attribute['primary_key'] && !$attribute['deprecated']) { $primary_key[] = $key; } $options['attributes'][$key] = $attribute; } if (!$primary_key) { throw new \RuntimeException('Mapper: undefined primary key'); } $options['primary_key'] = $primary_key; return $options; }
public static function dropdownList() { return array('' => 'Select Type') + Types::orderBy('name', 'asc')->get()->lists('name', 'id'); }
/** * Show the form for editing the specified resource. * * @param int $id * @return Response */ public function edit($id) { if (!$id) { return Redirect::route('products.index')->with('error', 'Please Provide product id'); } $product = Products::find($id); if (empty($product)) { return Redirect::route('products.index')->with('error', 'Product not found'); } $types = Types::dropdownList(); $units = Units::dropdownList(); return View::make('products.edit', compact('product', 'types', 'units')); }
public function init() { $this->plugin_name = __('Bs', 'bs'); //Custom data definitions //uses Types singleton, q.v. //custom post types - the only one so far is "Best Sellers", //but you may not need that particular one Types::instance()->register_post_types(); //use if you have the need for custom taxonomies Types::instance()->register_taxonomies(); //disable emojis // remove_action( 'wp_head', 'print_emoji_detection_script', 7 ); // remove_action( 'admin_print_scripts', 'print_emoji_detection_script' ); // remove_action( 'wp_print_styles', 'print_emoji_styles' ); // remove_action( 'admin_print_styles', 'print_emoji_styles' ); // remove_filter( 'the_content_feed', 'wp_staticize_emoji' ); // remove_filter( 'comment_text_rss', 'wp_staticize_emoji' ); // remove_filter( 'wp_mail', 'wp_staticize_emoji_for_email' ); // add_filter( 'tiny_mce_plugins', 'disable_emojis_tinymce' ); }
/** * Returns array of all column types available. * * VARCHAR, TINYINT, TEXT and DATE are listed first, based on * estimated popularity. * * @return string[] * */ public function getColumns() { $ret = parent::getColumns(); // numeric $ret[_pgettext('numeric types', 'Numeric')] = array('TINYINT', 'SMALLINT', 'MEDIUMINT', 'INT', 'BIGINT', '-', 'DECIMAL', 'FLOAT', 'DOUBLE', 'REAL', '-', 'BIT', 'BOOLEAN', 'SERIAL'); // Date/Time $ret[_pgettext('date and time types', 'Date and time')] = array('DATE', 'DATETIME', 'TIMESTAMP', 'TIME', 'YEAR'); // Text $ret[_pgettext('string types', 'String')] = array('CHAR', 'VARCHAR', '-', 'TINYTEXT', 'TEXT', 'MEDIUMTEXT', 'LONGTEXT', '-', 'BINARY', 'VARBINARY', '-', 'TINYBLOB', 'MEDIUMBLOB', 'BLOB', 'LONGBLOB', '-', 'ENUM', 'SET'); $ret[_pgettext('spatial types', 'Spatial')] = array('GEOMETRY', 'POINT', 'LINESTRING', 'POLYGON', 'MULTIPOINT', 'MULTILINESTRING', 'MULTIPOLYGON', 'GEOMETRYCOLLECTION'); $ret['JSON'] = array('JSON'); return $ret; }
public function deletetypesAction($id) { $id = $this->filter->sanitize($id, array("int")); $Types = Types::findFirst('id="' . $id . '"'); if (!$Types) { $this->flash->error("没找到对应下级类型"); return $this->forward("producttypes/index"); } if (!$Types->delete()) { foreach ($Types->getMessages() as $message) { $this->flash->error((string) $message); } return $this->forward("producttypes/search"); } else { /* $this->flash->success("该下级类型已删除"); */ $this->response->redirect("producttypes/search"); } }
/** * 格式化属性值 * 可以通过重载此方法实现自定义格式化逻辑 * * @param string $key 属性名 * @param mixed $value 属性值 * @param array $attribute 属性定义信息 * @return mixed 格式化过后的值 */ protected function normalize($key, $value, array $attribute) { return Types::factory($attribute['type'])->normalize($value, $attribute); }
/** * Show the form for editing the specified resource. * * @param int $id * @return Response */ public function edit($id) { $distribution = Distributions::find($id); $input = Input::all(); $products = Products::filter($input, 25); $types = Types::dropdownList(); $outlets = SalesOutlets::dropdownList(); return View::make('distributions.edit', compact('products', 'types', 'input', 'outlets')); }