/** * show the data in an input element for editing * * @return string */ protected function getWriteDisplay() { $selectedOptionNames = explode(', ', $this->value); $output = Html::startTag('div', ['class' => $this->class]); $connectedClassName = $this->fieldinfo->getConnectedClass(); /** @var BaseConnectionObject $connObj */ $connObj = new $connectedClassName(); $class = $connObj->getOtherClass($this->fieldinfo->getClass()); $obj = Factory::createObject($class); $connectedFieldName = $this->fieldinfo->getFieldsOfConnectedClass(); $table = DB::table($obj->getTable()); $result = Finder::create($class)->find([$table->getColumn($connectedFieldName), $table->getColumn('LK')]); foreach ($result as $row) { $params = []; $params['value'] = $row['LK']; $params['type'] = 'checkbox'; $params['class'] = 'checkbox'; $params['name'] = $this->name . '[]'; if (in_array($row[$connectedFieldName], $selectedOptionNames)) { $params['checked'] = 'checked'; } $output .= Html::startTag('p') . Html::singleTag('input', $params) . " " . $row[$connectedFieldName] . Html::endTag('p'); } $output .= Html::endTag('div'); return $output; }
/** * set data */ public function setData() { $obj = Factory::createObject('News'); $table = DB::table($obj->getTable()); $limit = new base_database_Limit(10); $order = DB::order($table->getColumn('firstEditTime')); $finder = Finder::create('news')->setOrder($order)->setlimit($limit); $this->data = $finder->find(); }
/** * {@inheritdoc} */ public function all() : MapInterface { $files = Finder::create()->in($this->path); $map = new Map('string', FileInterface::class); foreach ($files as $file) { $map = $map->put($file->getRelativePathname(), $this->get($file->getRelativePathname())); } return $map; }
public function mapFieldValue($value) { $obj = Factory::createObject('vendor'); $table = DB::table($obj->getTable()); $where = DB::where($table->getColumn('name'), DB::term($value)); $finder = Finder::create('vendor')->setWhere($where); $result = $finder->find(array($table->getColumn('LK'))); if (count($result) > 1) { throw new base_exception_Mapper(TMS('medexchange.exception.mapper.vendorDuplicatedEntry')); } $lkArray = $result[0]; return $lkArray['LK']; }
/** * load the right object by its name * * @param $name * @return mixed|null * @throws base_database_Exception */ public static function getGroupLKByName($name) { $table = DB::table('gruppe'); $column = $table->getColumn('name'); $where = DB::where($column, DB::term($name)); $finder = Finder::create('group')->setWhere($where); $results = $finder->find(array($table->getColumn('LK'))); if (empty($results)) { return null; } $result = $results[0]; return $result['LK']; }
/** * {@inheritDoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $this->file_system = new Filesystem(); $source_dir = __DIR__ . '/../Resources/public/'; if (!file_exists($source_dir)) { throw new \Exception(sprintf("`%s` is not exists!", $source_dir)); } $root_dir = dirname($this->getContainer()->getParameter('kernel.root_dir')); $source_dir = realpath($source_dir); $target_dir = $root_dir . '/web' . $this->getContainer()->getParameter('sf.web_assets_dir'); $this->ensureDirectoryExists($target_dir . '/js'); $this->ensureDirectoryExists($target_dir . '/css'); $this->ensureDirectoryExists($target_dir . '/img'); $this->ensureDirectoryExists($target_dir . '/fonts'); $this->linkDir($source_dir . '/bootstrap-colorpicker/img', $target_dir . '/img'); $this->linkDir($source_dir . '/bootstrap/fonts', $target_dir . '/fonts'); $this->linkDir($source_dir . '/font-awesome4/fonts', $target_dir . '/fonts'); $this->linkDir($source_dir . '/jstree/themes/default/images', $target_dir . '/css'); $this->symlink($source_dir . '/jcrop/css/Jcrop.gif', $target_dir . '/css/Jcrop.gif'); /** * copy from Symfony\Bundle\FrameworkBundle\Command\AssetsInstallCommand */ if (!function_exists('symlink') && !$input->getOption('nosymlink')) { throw new \InvalidArgumentException('The symlink() function is not available on your system. You need to install the assets without the --symlink option.'); } $filesystem = $this->getContainer()->get('filesystem'); // Create the bundles directory otherwise symlink will fail. $bundlesDir = $target_dir . '/bundles/'; $filesystem->mkdir($bundlesDir, 0777); $output->writeln(sprintf('Installing assets as <comment>%s</comment>', !$input->getOption('nosymlink') ? 'symlinks' : 'hard copies')); foreach ($this->getContainer()->get('kernel')->getBundles() as $bundle) { if (is_dir($originDir = $bundle->getPath() . '/Resources/public')) { $targetDir = $bundlesDir . preg_replace('/bundle$/', '', strtolower($bundle->getName())); $output->writeln(sprintf('Installing assets for <comment>%s</comment> into <comment>%s</comment>', $bundle->getNamespace(), $targetDir)); $filesystem->remove($targetDir); if (!$input->getOption('nosymlink')) { if (!$input->getOption('norelative')) { $relativeOriginDir = $filesystem->makePathRelative($originDir, realpath($bundlesDir)); } else { $relativeOriginDir = $originDir; } $filesystem->symlink($relativeOriginDir, $targetDir); } else { $filesystem->mkdir($targetDir, 0777); // We use a custom iterator to ignore VCS files $filesystem->mirror($originDir, $targetDir, Finder::create()->ignoreDotFiles(false)->in($originDir)); } } } return 0; }
public function loadEntriesForCategory($catLK) { $navEntry = Factory::createObject('NavigationEntry'); $table = DB::table($navEntry->getTable()); $where = DB::where($table->getColumn('category'), DB::intTerm($catLK)); $entries = Finder::create('navigationEntry')->setWhere($where)->find(); $relevantEntries = []; foreach ($entries as $entry) { if ($this->_isEntitledForEntry($entry)) { $relevantEntries[] = $entry; } } return $relevantEntries; }
public function toExternal($value) { if (empty($value)) { return $value; } $className = $this->fi->getConnectedClass(); $obj = Factory::createObject($className); $table = DB::table($obj->getTable()); $where = DB::where($table->getColumn('LK'), DB::intTerm($value)); $displayField = $this->fi->getFieldsOfConnectedClass(); $result = Finder::create($className)->setWhere($where)->find(array($table->getColumn($displayField))); if (empty($result)) { return null; } return $result[0][$displayField]; }
/** * converts a given value to the specified structure * * @param $value * @return mixed * @throws base_database_Exception * @throws base_exception_Mapper */ public function mapFieldValue($value) { $obj = Factory::createObject('TSMCollocgroup'); $table = DB::table($obj->getTable()); $where = DB::where($table->getColumn('name'), DB::term($value)); $where->addAnd($table->getColumn('FK_tsmserver'), DB::term(TSMServerManager::get()->getActualTsmServerLK())); $finder = Finder::create('TSMCollocgroup')->setWhere($where); $result = $finder->find(array($table->getColumn('LK'))); if (count($result) > 1) { throw new base_exception_Mapper(TMS('tsmviewer.exception.mapper.collocgroupDuplicatedEntry')); } $lkArray = current($result); return $lkArray['LK']; }
protected function getWriteDisplay() { $fi = $this->fieldinfo; $class = $fi->getConnectedClass(); $connectedField = $fi->getFieldsOfConnectedClass(); $objs = Finder::create($class)->find(); $output = Html::startTag('select', array('class' => $this->class, 'name' => $this->name)); foreach ($objs as $obj) { $params = []; $actualFieldValue = $obj[$connectedField]; if ($this->value == $actualFieldValue) { $params['selected'] = 'selected'; } $params['value'] = $obj->getLogicalKey(); $output .= Html::startTag('option', $params) . $actualFieldValue . Html::endTag('option'); } $output .= Html::endTag('select'); return $output; }
protected function getData() { $requestHelper = $this->controller->getRequestHelper(); $pzn = $requestHelper->getParam('pzn'); $obj = Factory::createObject('medicament'); $table = DB::table($obj->getTable()); $where = DB::where($table->getColumn('pzn'), DB::term($pzn)); $finder = Finder::create('medicament')->setWhere($where); $result = $finder->find(); if (empty($result)) { return array(); } /** @var BaseObject $obj */ $obj = $result[0]; foreach ($obj->getAllFields() as $fi) { if ($fi->getDisplayClass() == 'system') { continue; } $values[$fi->getFieldName()] = $obj->getField($fi->getFieldName()); } return $values; }
/** * execute the actual ajax request */ protected function executeRequest() { $requestHelper = $this->controller->getRequestHelper(); $class = $requestHelper->getParam('class'); $object = Factory::createObject($class); /** @var BaseObject[] $result */ $result = Finder::create($class)->find(); $urlColumns = $requestHelper->getParam('cols'); if (!is_null($urlColumns)) { if ($urlColumns == 'all') { $fi = new Fieldinfo($class); $columnNames = $fi->getAllFieldNames(); } else { $columnNames = explode(',', $urlColumns); } } else { $columnNames = $object->getStdSearchColumns(); } $response = new stdClass(); $i = 0; foreach ($result as $obj) { $values = []; $values['LK'] = (int) $obj['LK']; foreach ($columnNames as $colName) { $values[$colName] = $obj->getField($colName); } $response->BaseObjectReader[] = $values; $i++; } $jsonObject = json_encode($response); echo $jsonObject; exit(); }
/** * login of an user with the given userid and password * * @param string $userid * @param string $password * * @return int * @throws base_database_Exception */ public static function login($userid, $password) { $table = DB::table(Factory::createObject('user')->getTable()); $where = DB::where($table->getColumn('userid'), DB::stringTerm($userid)); $res = Finder::create('user')->setWhere($where)->find(); if (empty($res)) { return self::LOGIN_FAILURE; } $user = current($res); if ($user['disabled'] == self::USER_DISABLED) { return self::LOGIN_USER_DISABLED; } if ($user['password'] != md5($password)) { return self::_updateLoginTries($table, $user); } try { $time = new base_date_model_DateTime(); $updateData = array( 'ip' => DB::stringTerm($_SERVER['REMOTE_ADDR']), 'sessionid' => DB::stringTerm(session_id()), 'lastLogin' => DB::stringTerm($time->toDB()), 'loginTries' => DB::intTerm(0), ); self::_updateUserLoginData($table, $where, $updateData); } catch (Exception $e) { return self::LOGIN_FAILURE; } $user['ip'] = $_SERVER['REMOTE_ADDR']; $user['sessionid'] = session_id(); $user['lastLogin'] = $time; $user['loginTries'] = 0; $_SESSION['user'] = $user; return self::LOGIN_SUCCESS; }
/** * @param $where * @return int */ private function getExistingObjects($where) { $table = DB::table($this->obj->getTable()); $colPK = $table->getColumn('PK'); $finder = Finder::create(get_class($this->obj)); $result = $finder->setWhere($where)->find(array($colPK)); if (empty($result)) { return null; } return $result[0]['PK']; }
/** * {@inheritDoc} */ protected function execute(InputInterface $input, OutputInterface $output) { if (!function_exists('symlink') && !$input->getOption('nosymlink')) { throw new \InvalidArgumentException('The symlink() function is not available on your system. You need to install the assets without the --symlink option.'); } $this->file_system = new Filesystem(); $assets_root_dir = $this->getContainer()->getParameter('sf.web_root_dir') . $this->getContainer()->getParameter('sf.web_assets_dir'); $this->ensureDirectoryExists($assets_root_dir); $assets_root_dir = realpath($assets_root_dir); $filesystem = $this->getContainer()->get('filesystem'); $bundlesDir = $assets_root_dir . '/bundles/'; $this->ensureDirectoryExists($bundlesDir); $output->writeln(sprintf('Installing assets as <comment>%s</comment>', !$input->getOption('nosymlink') ? 'symlinks' : 'hard copies')); foreach ($this->getContainer()->get('kernel')->getBundles() as $bundle) { if (is_dir($originDir = $bundle->getPath() . '/Resources/public')) { $targetDir = $bundlesDir . preg_replace('/bundle$/', '', strtolower($bundle->getName())); $output->writeln(sprintf('Installing assets for <comment>%s</comment> into <comment>%s</comment>', $bundle->getNamespace(), $targetDir)); $filesystem->remove($targetDir); if (!$input->getOption('nosymlink')) { if (!$input->getOption('norelative')) { $relativeOriginDir = $filesystem->makePathRelative($originDir, realpath($bundlesDir)); } else { $relativeOriginDir = $originDir; } $filesystem->symlink($relativeOriginDir, $targetDir); } else { $filesystem->mkdir($targetDir, 0777); // We use a custom iterator to ignore VCS files $filesystem->mirror($originDir, $targetDir, Finder::create()->ignoreDotFiles(false)->in($originDir)); } } } /** * @var $factory \Symforce\CoreBundle\Assets\SymforceAssetsCompiler */ $compiler = $this->getContainer()->get('sf.compiler.assets'); $output->writeln(sprintf('Installing assets from <comment>%s</comment>', $compiler->getTagName())); $twig_parser = $this->getContainer()->get('templating.name_parser'); $twig_locator = $this->getContainer()->get('templating.locator'); $assets_target_dirs = $this->getContainer()->getParameter('sf.web_assets_target_dirs'); /** * @var $assets_resource \Symforce\CoreBundle\Assets\SymforceAssetsResource */ foreach ($compiler->getResources() as $service_id => $assets_resource) { if (!in_array($assets_resource->getTarget(), $assets_target_dirs)) { throw new \Exception(sprintf("service(%s) with tags(name=%s, target=%s) target must be one of(%s)", $service_id, $compiler->getTagName(), $assets_resource->getTarget(), join(',', $assets_target_dirs))); } $path = $assets_resource->getPath(); try { $_path = $twig_locator->locate($twig_parser->parse($path)); } catch (\InvalidArgumentException $e) { throw new \Exception(sprintf("service(%s) with tags(name=%s, path=%s): %s", $service_id, $compiler->getTagName(), $path, $e->getMessage())); } $_target_dir = $assets_root_dir . '/' . $assets_resource->getTarget(); $this->ensureDirectoryExists($_target_dir); $output->writeln(sprintf('Installing assets for <comment>%s</comment> into <comment>%s/%s</comment>', $path, $this->getContainer()->getParameter('sf.web_assets_dir'), $assets_resource->getTarget())); if (is_dir($_path)) { $this->linkDir($_path, $_target_dir, $assets_resource->getExtension()); } else { $this->symlink($_path, $_target_dir . '/' . basename($_path)); } } return 0; }
$od = new OutputDevice(); base_ui_Site::displayHead($od); base_ui_Site::displayTop($od); base_ui_Site::displayNavigation($od); base_ui_Site::startMainContent($od); $od->addContent(Html::startTag('h3')); $od->addContent('Import der TSMServer Klassen'); $od->addContent(Html::endTag('h3')); $importer = new base_importer_csv_BaseObject('tsmserver', ROOT . "/modules/tsmviewer/init/tsmserver_data.csv"); $importer->import(); $result = Finder::create('TSMServer')->find(); $od->addContent(Html::startTag('ul')); foreach ($result as $obj) { TSMServerManager::get()->setActualTsmServerLK((int) $obj['LK']); $od->addContent(Html::startTag('li', array('class' => 'serverList'))); $od->addContent("Import der Daten zu TSM Server '{$obj['name']}'"); $od->addContent(Html::startTag('ul')); $importer = new tsmviewer_importer_csv_TSMObject('tsmdomain', ROOT . "/modules/tsmviewer/init/tsmdomain_{$obj['LK']}_data.csv", ',', false); $ret = $importer->import(); if ($ret == tsmviewer_importer_csv_TSMObject::SUCCESS) { $od->addContent(Html::startTag('li')); $od->addContent("Die Domains wurden erfolgreich importiert");
/** * Get all of the directories within a given directory. * * @param string $directory * @return array */ public static function directories($directory) { $directories = array(); foreach (Finder::create()->in($directory)->directories()->depth(0) as $dir) { $directories[] = $dir->getPathname(); } return $directories; }
base_ui_Site::displayNavigation($od); base_ui_Site::startMainContent($od); $od->addContent(Html::startTag('h3')); $od->addContent('Artikelangebote'); $od->addContent(Html::endTag('h3')); if (!User::isLoggedIn()) { $od->addContent('Sie sind nicht eingeloggt'); } else { /** @var MedOffer $obj */ $obj = Factory::createObject('medOffer'); $table = DB::table($obj->getTable()); $where = DB::where($table->getColumn('offerAmount'), DB::intTerm(0), base_database_Where::GREATER); /** @var BaseObject[] $objs */ $objs = Finder::create('medOffer')->setWhere($where)->find(); if (empty($objs)) { $od->addContent('Keine Datensätze gefunden'); } else { $table = new base_html_model_Table(); $table->setCssClass('offerTable'); $headRow = new base_html_model_table_Row(); $headRow->setRowType(base_html_model_table_Row::ROWTAG_HEAD); /** @var Fieldinfo[] $fis */ $fis = []; foreach ($obj->getFieldsForOfferPage() as $field) { $fi = $obj->getFieldinfo($field); $cell = new base_html_model_table_Cell(); $cell->setCssId($fi->getFieldName()); $cell->setContent($fi->getFieldLabel());
base_ui_Site::displayTop($od); base_ui_Site::displayNavigation($od); base_ui_Site::startMainContent($od); print $od->toString(); $od->flush(); $od->addContent(Html::startTag('h3')); $od->addContent('Summary'); $od->addContent(Html::endTag('h3')); $table = DB::table(Factory::createObject('TSMSummary')->getTable()); $dateTime = new base_date_model_DateTime(new DateTime('2015-01-01 00:00:00')); $where = DB::where($table->getColumn('startTime'), DB::term($dateTime->toDB()), base_database_Where::GREATER); $order = DB::order($table->getColumn('startTime')); $finder = Finder::create('TSMSummary')->setWhere($where)->setOrder($order); $objs = $finder->find(); $times = []; $nodeNames = []; $sortedObjects = []; foreach ($objs as $obj) { /** @var base_date_model_DateTime $startTime */ $startTime = $obj['startTime']; $nodeName = $obj['nodeName']; if (strpos($nodeName, 'FULLVM')) { $nodeName = $obj['subEntity'] . ' (FULLVM)'; } if (!in_array($nodeName, $nodeNames)) { $nodeNames[] = $nodeName;
public function countData() { return Finder::create($this->class)->count(); }