/** * Constructor. * * Load form data (if applicable) * * @param sfTestFunctionalBase $browser A browser * @param lime_test $tester A tester object */ public function __construct(sfTestFunctionalBase $browser, $tester) { parent::__construct($browser, $tester); if (file_exists(sfConfig::get('sf_test_dir') . '/data/forms.yml')) { $this->setFormData(sfYaml::load(sfConfig::get('sf_test_dir') . '/data/forms.yml')); } }
/** * Get the package configuration * * @param string $yaml Pathname of the YAML configuration file * @return array */ function configure($yaml) { $cfg = \sfYaml::load($yaml); $name = $cfg['name']; $options = $cfg['options']; if (!isset($options['filelistgenerator'])) { $cfg['options']['filelistgenerator'] = 'file'; } if (!isset($options['baseinstalldir'])) { $cfg['options']['baseinstalldir'] = '/'; } if (!isset($options['packagedirectory'])) { $cfg['options']['packagedirectory'] = __DIR__; } // ignored files $ignore = array('package.php', 'package.xml', 'package.xml.orig', 'package.yml', 'config.w32', "{$name}.dsp", "{$name}-*.tgz"); if (isset($options['ignore'])) { $ignore = array_merge($ignore, $options['ignore']); } $cfg['options']['ignore'] = glob_values($ignore); // directory roles $dir_roles = array('examples' => 'data', 'manual' => 'doc', 'tests' => 'test'); if (isset($options['dir_roles'])) { $dir_roles = array_merge($dir_roles, $options['dir_roles']); } $cfg['options']['dir_roles'] = $dir_roles; // role exceptions $exceptions = array('CREDITS' => 'doc', 'EXPERIMENTAL' => 'doc', 'LICENSE' => 'doc', 'README' => 'doc'); if (isset($options['exceptions'])) { $exceptions = array_merge($exceptions, $options['exceptions']); } $cfg['options']['exceptions'] = glob_keys($exceptions); return $cfg; }
private function _init() { $pluginsPath = sfConfig::get('sf_plugins_dir'); $directoryIterator = new DirectoryIterator($pluginsPath); foreach ($directoryIterator as $fileInfo) { if ($fileInfo->isDir()) { $pluginName = $fileInfo->getFilename(); $configuraitonPath = $pluginsPath . '/' . $pluginName . '/config/action_extensions.yml'; if (is_file($configuraitonPath)) { $configuraiton = sfYaml::load($configuraitonPath); if (!is_array($configuraiton)) { continue; } foreach ($configuraiton as $module => $extentionsForActions) { if (!isset($this->preExecuteMethodStack[$module])) { $this->preExecuteMethodStack[$module] = array(); } if (!isset($this->postExecuteMethodStack[$module])) { $this->postExecuteMethodStack[$module] = array(); } foreach ($extentionsForActions as $action => $extentions) { if (!isset($this->preExecuteMethodStack[$module][$action])) { $this->preExecuteMethodStack[$module][$action] = array(); } if (!isset($this->postExecuteMethodStack[$module][$action])) { $this->postExecuteMethodStack[$module][$action] = array(); } $this->preExecuteMethodStack[$module][$action] = array_merge($this->preExecuteMethodStack[$module][$action], $extentions['pre']); $this->postExecuteMethodStack[$module][$action] = array_merge($this->postExecuteMethodStack[$module][$action], $extentions['post']); } } } } } }
public function executeImportSentences(dmWebRequest $request) { $catalogue = $this->getObjectOrForward404($request); $form = new DmCatalogueImportForm(); sfContext::getInstance()->getConfiguration()->loadHelpers(array('Url')); if ($request->isMethod('post') && $form->bindAndValid($request)) { $file = $form->getValue('file'); $override = $form->getValue('override'); $dataFile = $file->getTempName(); $table = dmDb::table('DmTransUnit'); $existQuery = $table->createQuery('t')->select('t.id, t.source, t.target, t.created_at, t.updated_at')->where('t.dm_catalogue_id = ? AND t.source = ?'); $catalogueId = $catalogue->get('id'); $nbAdded = 0; $nbUpdated = 0; try { if (!is_array($data = sfYaml::load(file_get_contents($dataFile)))) { $this->getUser()->logError($this->getI18n()->__('Could not load file: %file%', array('%file%' => $file->getOriginalName()))); return $this->renderPartial('dmInterface/flash'); } } catch (Exception $e) { $this->getUser()->logError($this->getI18n()->__('Unable to parse file: %file%', array('%file%' => $file->getOriginalName()))); return $this->renderPartial('dmInterface/flash'); } $addedTranslations = new Doctrine_Collection($table); $line = 0; foreach ($data as $source => $target) { ++$line; if (!is_string($source) || !is_string($target)) { $this->getUser()->logError($this->getI18n()->__('Error line %line%: %file%', array('%line%' => $line, '%file%' => $file->getOriginalName()))); return $this->renderPartial('dmInterface/flash'); } else { $existing = $existQuery->fetchOneArray(array($catalogueId, $source)); if (!empty($existing) && $existing['source'] === $source) { if ($existing['target'] !== $target) { if ($override || $existing['created_at'] === $existing['updated_at']) { $table->createQuery()->update('DmTransUnit')->set('target', '?', array($target))->where('id = ?', $existing['id'])->execute(); ++$nbUpdated; } } } elseif (empty($existing)) { $addedTranslations->add(dmDb::create('DmTransUnit', array('dm_catalogue_id' => $catalogue->get('id'), 'source' => $source, 'target' => $target))); ++$nbAdded; } } } $addedTranslations->save(); if ($nbAdded) { $this->getUser()->logInfo($this->getI18n()->__('%catalogue%: added %count% translation(s)', array('%catalogue%' => $catalogue->get('name'), '%count%' => $nbAdded))); } if ($nbUpdated) { $this->getUser()->logInfo($this->getI18n()->__('%catalogue%: updated %count% translation(s)', array('%catalogue%' => $catalogue->get('name'), '%count%' => $nbUpdated))); } if (!$nbAdded && !$nbUpdated) { $this->getUser()->logInfo($this->getI18n()->__('%catalogue%: nothing to add and update', array('%catalogue%' => $catalogue->get('name')))); } return $this->renderText(url_for1($this->getRouteArrayForAction('index'))); } $action = url_for1($this->getRouteArrayForAction('importSentences', $catalogue)); return $this->renderText($form->render('.dm_form.list.little action="' . $action . '"')); }
protected function execute($arguments = array(), $options = array()) { $file = sfConfig::get('sf_apps_dir') . '/' . $options['app'] . '/config/app.yml'; $config = file_exists($file) ? sfYaml::load($file) : array(); $config = $this->switchConfig($config, strtolower($options['option']), strtolower($options['status'])); file_put_contents($file, sfYaml::dump($config, 4)); }
/** * @covers OperationalCountryDao::getLocationsMappedToOperationalCountry */ public function testGetLocationsMappedToOperationalCountry_Successful() { $sampleData = sfYaml::load($this->fixture); $sampleData = $sampleData['Location']; $result = $this->dao->getLocationsMappedToOperationalCountry('LK'); $this->assertTrue($result instanceof Doctrine_Collection); $this->assertEquals(2, $result->count()); $sampleDataIndices = array(0, 1); foreach ($result as $i => $location) { $index = $sampleDataIndices[$i]; $this->assertTrue($location instanceof Location); $this->assertEquals($sampleData[$index]['id'], $location->getId()); $this->assertEquals($sampleData[$index]['name'], $location->getName()); } $result = $this->dao->getLocationsMappedToOperationalCountry('US'); $this->assertTrue($result instanceof Doctrine_Collection); $this->assertEquals(1, $result->count()); $sampleDataIndices = array(2); foreach ($result as $i => $location) { $index = $sampleDataIndices[$i]; $this->assertTrue($location instanceof Location); $this->assertEquals($sampleData[$index]['id'], $location->getId()); $this->assertEquals($sampleData[$index]['name'], $location->getName()); } }
protected function _init_() { $data = sfYaml::load(sfConfig::get('sf_lib_dir') . '/task/RandomData.yml'); $this->series = SeriesTable::getChoicesForSelect(); $this->letters = $data['letters']; $this->tags = $data['tags']; $this->items = $data['short_texts']; $this->terms = $data['long_texts']; $this->companies = $data['company_names']; $this->names = $data['names']; $this->lastnames = $data['lastnames']; $this->taxes = array(); foreach ($q = Doctrine_Query::create()->from('Tax t')->execute() as $tax) { $this->taxes[] = $tax->getId(); } $customers = array('name' => array(), 'email' => array(), 'id' => array(), 'company' => array()); for ($i = 0; $i < mt_rand(20, 100); $i++) { $customers['id'][] = str_pad(mt_rand(11111, 99999) . mt_rand(11111, 99999), 10, '0', STR_PAD_LEFT) . $this->letters[array_rand($this->letters)]; $name = $this->names[array_rand($this->names)] . " " . $this->lastnames[array_rand($this->lastnames)]; $customers['name'][] = $name; $customers['email'][] = str_replace(' ', '_', strtolower($name)) . '@example.com'; $customers['company'][] = $this->companies[array_rand($this->companies)]; } $this->customers = $customers; }
/** * a function that allows link_to between apps * @param $app string the app we want to go to * @param $route string the route in the app. Must be valid * @param $args array the arguments required by the route. Optional * @author Cf. http://ivanramirez.fr/2011/08/09/faire-un-lien-dune-application-a-une-autre/ * */ function cross_app_link_to($app, $route, $args = null) { /* get the host to build the absolute paths needed because this menu lets switch between sf apps */ $host = sfContext::getInstance()->getRequest()->getHost(); /* get the current environment. Needed to switch between the apps preserving the environment */ $env = sfConfig::get('sf_environment'); /* get the routing file */ $appRoutingFile = sfConfig::get('sf_root_dir') . DIRECTORY_SEPARATOR . 'apps' . DIRECTORY_SEPARATOR . $app . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'routing.yml'; /* get the route in the routing file */ /* first, substract the @ from the route name */ $route = substr($route, 1, strlen($route)); if (file_exists($appRoutingFile)) { $yml = sfYaml::load($appRoutingFile); $routeUrl = $yml[$route]['url']; if ($args) { foreach ($args as $k => $v) { $routeUrl = str_replace(':' . $k, $v, $routeUrl); } } if (strrpos($routeUrl, '*') == strlen($routeUrl) - 1) { $routeUrl = substr($routeUrl, 0, strlen($routeUrl) - 2); } } if ($env == 'dev') { $path = '//' . $host . '/' . $app . '_dev.php' . $routeUrl; } else { $path = '//' . $host . $routeUrl; } return $path; }
protected function setUp() { $this->leaveRequestDao = new LeaveRequestDao(); $fixtureFile = sfConfig::get('sf_plugins_dir') . '/orangehrmCoreLeavePlugin/test/fixtures/LeaveRequestDao.yml'; TestDataService::populate($fixtureFile); $this->fixture = sfYaml::load($fixtureFile); }
public function executeRun(sfWebRequest $request) { // Cargo definicion $def = sfYaml::load($request->getParameter('definicion')); // Extraigo nombre del patron y parametros $patternClassName = key($def) . 'Pattern'; $params = $def[key($def)]['Params']; // Instancio el patron $ptn = new $patternClassName(); // Seteo parametros de entrada foreach ($params as $key => $value) { $ptn->setParameter($key, $value); } // Logica particular del patron antes de visualizar interfaz $ptn->execute(); if ($ptn->hasTemplate()) { // Con interfaz. Paso parametros a la interfaz $this->include = $ptn->getTemplate(); $this->patternName = $ptn->getName(); // Tomo los datos del patron que van a la interfaz foreach ($ptn->getTplParameters() as $name => $value) { $this->{$name} = $value; } } // Seteo instancia del patron en la sesion del usuario // para leerlo cuando vuelva de la interfaz del patron // y/o finalize. $this->getUser()->setFlash('patron_class_test', $ptn); // Si el patron no tiene interfaz, finalizo redireccionando al index. if (!$ptn->hasTemplate()) { $this->redirect('psdfTestPattern/index'); } }
public function generateMenu() { $menu = new ioMenu(); if ($this->getCurrentApp() == Menu::FRONTEND_APP) { $routings = sfYaml::load(sfConfig::get('sf_apps_dir') . '/' . Menu::FRONTEND_APP . '/config/routing.yml'); } else { $routings = sfYaml::load(sfConfig::get('sf_apps_dir') . '/' . Menu::BACKEND_APP . '/config/routing.yml'); } foreach ($this->getItems() as $item) { foreach ($routings as $key => $routing) { if ("@" . $key == $item->routing) { if (!empty($item->section)) { //Set class "active" if the item is a link to the current page if ($menu->getChild($item->section, false) == null) { $menu->addChild($item->section, $item->section_routing)->setLinkOptions(array('class' => 'link')); } $menu->getChild($item->section)->addChild($item->text, $item->routing)->setLinkOptions(array('class' => 'link large')); } else { //Set class "active" if the item is a link to the current page $menu->addChild($item->text, $item->routing)->setLinkOptions(array('class' => 'link')); } } } } return $menu; }
public function executeRender() { $this->user = $this->getUser(); $this->menu = array(); $this->menu = sfYaml::load(sfConfig::get('sf_app_config_dir') . '/' . sfConfig::get('app_menu_file')); foreach ($this->menu as $navItemsLabel => $navItems) { echo "{$navItemsLabel}:<br />"; foreach ($navItems as $navItemLabel => $navItem) { if (!is_array($navItem)) { echo "+{$navItemLabel}: {$navItem}<br />"; } else { echo "+{$navItemLabel}:<br />"; foreach ($navItem as $childItemsLabel => $childItems) { echo "++{$childItemsLabel}:<br />"; foreach ($childItems as $childItemLabel => $childItem) { if (!is_array($childItem)) { echo "+++{$childItemLabel}: {$childItem}<br />"; } else { echo "+++{$childItemLabel}: <br />"; foreach ($childItem as $babyItemsLabel => $babyItems) { echo "++++{$babyItemsLabel}: {$babyItems}<br />"; } } } } } } } }
public function executeTableManager() { $class = $this->getRequestParameter('class'); $generator_configuration = array( 'model_class' => $class, 'theme' => 'sfControlPanel', 'moduleName' => $class.'ControlPanel', 'list' => array( 'title' => $class.' list', ), 'edit' => array( 'title' => 'edit '.$class, ), ); if(file_exists(SF_ROOT_DIR.'/config/sfControlPanel_generator.yml')) { $custom_configuration = sfYaml::load(SF_ROOT_DIR.'/config/sfControlPanel_generator.yml'); if(isset($custom_configuration[$class])) { $generator_configuration = sfToolkit::arrayDeepMerge($generator_configuration, $custom_configuration[$class]); } } $generatorManager = new sfGeneratorManager(); $generatorManager->initialize(); $data = $generatorManager->generate('sfControlPanelGenerator', $generator_configuration); $this->redirect('auto'.$class.'ControlPanel/list'); }
private function _init() { $pluginsPath = sfConfig::get('sf_plugins_dir'); $directoryIterator = new DirectoryIterator($pluginsPath); foreach ($directoryIterator as $fileInfo) { if ($fileInfo->isDir()) { $pluginName = $fileInfo->getFilename(); $configuraitonPath = $pluginsPath . '/' . $pluginName . '/config/ui_extensions.yml'; if (is_file($configuraitonPath)) { $configuraiton = sfYaml::load($configuraitonPath); if (!is_array($configuraiton)) { continue; } foreach ($configuraiton as $module => $uiExtentionsForActions) { if (!isset($this->uiSubComponents[$module])) { $this->uiSubComponents[$module] = array(); } foreach ($uiExtentionsForActions as $action => $extensions) { if (!isset($this->uiSubComponents[$module][$action])) { $this->uiSubComponents[$module][$action] = array(); } foreach ($extensions as $location => $subComponents) { if (isset($this->uiSubComponents[$module][$action][$location])) { $this->uiSubComponents[$module][$action][$location] = array_merge($this->uiSubComponents[$module][$action][$location], $subComponents); } else { $this->uiSubComponents[$module][$action][$location] = $subComponents; } } } } } } } }
/** * Adds a new yaml file to the dataset. * @param string $yamlFile */ public function addYamlFile($yamlFile) { $data = sfYaml::load($yamlFile); foreach ($data as $tableName => $rows) { if (!is_array($rows)) { continue; } if (!array_key_exists($tableName, $this->tables)) { $columns = count($rows) ? array_keys(current($rows)) : array(); $tableMetaData = new PHPUnit_Extensions_Database_DataSet_DefaultTableMetaData($tableName, $columns); $this->tables[$tableName] = new PHPUnit_Extensions_Database_DataSet_DefaultTable($tableMetaData); } foreach ($rows as $row) { $this->tables[$tableName]->addRow($row); } } }
public function __construct() { $this->ArchivoLogTraspasos = $_SERVER['DOCUMENT_ROOT'] . $_SESSION['appPath'] . "/docs/docs{$_SESSION['emp']}/interfaces/contaplus/logtraspasos.yml"; if (file_exists($this->ArchivoLogTraspasos)) { $this->Traspasos = sfYaml::load($this->ArchivoLogTraspasos); } }
protected function setUp() { TestDataService::truncateSpecificTables(array('Employee', 'Leave', 'LeaveRequest', 'LeaveType', 'EmployeeLeaveEntitlement', 'LeavePeriod')); // Save leave type $leaveTypeData = sfYaml::load(sfConfig::get('sf_plugins_dir') . '/orangehrmCoreLeavePlugin/test/fixtures/leaveType.yml'); $leaveTypeDao = new LeaveTypeDao(); $leaveType = new LeaveType(); $leaveType->setLeaveTypeName($leaveTypeData['leaveType']['LT_001']['name']); // $leaveType->setLeaveRules($leaveTypeData['leaveType']['LT_001']['rule']); $leaveTypeDao->saveLeaveType($leaveType); $this->leaveType = $leaveType; $this->leaveTypeId = $leaveType->getLeaveTypeId(); // Save leave Period $leavePeriodData = sfYaml::load(sfConfig::get('sf_plugins_dir') . '/orangehrmCoreLeavePlugin/test/fixtures/leavePeriod.yml'); $leavePeriodService = new LeavePeriodService(); $leavePeriodService->setLeavePeriodDao(new LeavePeriodDao()); $leavePeriod = new LeavePeriod(); $leavePeriod->setStartDate($leavePeriodData['leavePeriod']['1']['startDate']); $leavePeriod->setEndDate($leavePeriodData['leavePeriod']['1']['endDate']); $leavePeriodService->saveLeavePeriod($leavePeriod); $this->leavePeriod = $leavePeriod; $this->leavePeriodId = $leavePeriod->getLeavePeriodId(); // Save Employee $employeeservice = new EmployeeService(); $this->employee = new Employee(); $employeeservice->saveEmployee($this->employee); $this->empNumber = $this->employee->getEmpNumber(); // save leave quota $this->leaveEntitlement = sfYaml::load(sfConfig::get('sf_plugins_dir') . '/orangehrmCoreLeavePlugin/test/fixtures/leaveEntitlement.yml'); $this->leaveEntitlementDao = new LeaveEntitlementDao(); }
/** * Create an instance of pmJSCookMenu from a yaml file. * * @param string $yaml_file The yaml file path * @return pmJSCookMenu */ public static function createFromYaml($yaml_file) { $yaml = sfYaml::load($yaml_file); $yaml = array_pop($yaml); $root = new pmJSCookMenu(); $root_attrs = array("credentials", "description", "icon", "orientation", "target", "theme", "title", "url"); foreach ($root_attrs as $attr) { if (isset($yaml[$attr])) { $method = "set" . ucfirst($attr); call_user_func(array($root, $method), $yaml[$attr]); unset($yaml[$attr]); } } if (isset($yaml["root"]) && $yaml["root"] == true) { $root->setRoot(); unset($yaml["root"]); } $separator_count = 0; foreach ($yaml as $name => $arr_menu) { if ($name == "separator") { $item = new pmJSCookMenuSeparator(); $root->addChild("{$name}{$separator_count}", $item); $separator_count++; } else { $item = self::createMenu($arr_menu); $root->addChild($name, $item); } } return $root; }
public function configure() { $yamlConf = sfYaml::load(sfConfig::get('sf_apps_dir') . '/backend/config/app.yml'); $this->setWidget('fichier_source', new sfWidgetFormInputFileEditable(array('file_src' => $yamlConf['all']['document_upload_dir'] . $this->getObject()->getFichierSource(), 'with_delete' => false, 'edit_mode' => false))); $this->validatorSchema['fichier_source'] = new sfValidatorFile(array('required' => false, 'path' => $yamlConf['all']['document_upload_dir'])); $this->validatorSchema['date_document'] = new sfValidatorDate(array('required' => false, 'date_format' => '~(?P<day>\\d{2})/(?P<month>\\d{2})/(?P<year>\\d{2})~')); }
private function _init() { $pluginsPath = sfConfig::get('sf_plugins_dir'); $directoryIterator = new DirectoryIterator($pluginsPath); foreach ($directoryIterator as $fileInfo) { if ($fileInfo->isDir()) { $pluginName = $fileInfo->getFilename(); $configuraitonPath = $pluginsPath . '/' . $pluginName . '/config/external_configurations.yml'; if (is_file($configuraitonPath)) { $configuraiton = sfYaml::load($configuraitonPath); if (!is_array($configuraiton)) { continue; } foreach ($configuraiton as $component => $configuraitonForComponent) { if (!isset($this->externalConfigurations[$component])) { $this->externalConfigurations[$component] = array(); } foreach ($configuraitonForComponent as $property => $value) { if (!isset($this->externalConfigurations[$component][$property])) { $this->externalConfigurations[$component][$property] = array(); } if (is_array($value)) { foreach ($value as $k => $v) { $this->externalConfigurations[$component][$property]["{$pluginName}_{$k}"] = $v; } } else { $this->externalConfigurations[$component][$property][] = $value; } } } } } } }
public function execute($request) { $head = sfYaml::load(sfConfig::get('sf_app_dir') . '/lib/list/seller_list.yml'); $sellerlist_headers = array($head['listSeller']['header1'], $head['listSeller']['header2'], $head['listSeller']['header3'], $head['listSeller']['header4']); $columns = 'id,name,address,tp_hp'; $recordsLimit = 5; //have to take from lists if (!$request->hasParameter('pageNo')) { $pageNo = 1; } else { $pageNo = $request->getParameter('pageNo', 1); } $pager = new SimplePager('Seller', $recordsLimit); $pager->setPage($pageNo); $pager->setNumResults($this->getSellerService()->countSellers()); $pager->init(); $offset = $pager->getOffset(); $offset = empty($offset) ? 0 : $offset; $paramHolder = new sfParameterHolder(); $paramHolder->set('columns', $columns); $paramHolder->set('offset', $offset); $paramHolder->set('limit', $recordsLimit); $sellerlist_data = $this->getSellerService()->getSellers($paramHolder); $listContainer = new ListContainer(); $listContainer->setListName('SellerList'); $listContainer->setListHeaders($sellerlist_headers); $listContainer->setListContent($sellerlist_data); $listContainer->setRowLink("seller/showSeller?id="); $listContainer->setPager($pager); $this->listcontainer = $listContainer; }
/** * @see sfTask */ protected function execute($arguments = array(), $options = array()) { $r = new ReflectionClass($arguments['model']); if (!$r->isSubclassOf('Doctrine_Record')) { throw new sfCommandException(sprintf('"%s" is not a Doctrine class.', $arguments['model'])); } // create a route $model = $arguments['model']; $module = $arguments['module']; $app = $arguments['application']; $routing = sfConfig::get('sf_app_config_dir') . '/routing.yml'; $content = file_get_contents($routing); $routesArray = sfYaml::load($content); if (!isset($routesArray[$name])) { $databaseManager = new sfDatabaseManager($this->configuration); $primaryKey = Doctrine_Core::getTable($model)->getIdentifier(); $content = sprintf(<<<EOF %s: class: sfObjectRouteCollection options: model: %s actions: [ create, delete, list, show, update ] module: %s column: %s default_params: sf_format: json EOF , $module, $model, $module, $primaryKey) . $content; $this->logSection('file+', $routing); file_put_contents($routing, $content); } return $this->generate($app, $module, $model); }
public function testFeature($name) { $features = sfYaml::load(sfConfig::get('sf_test_dir') . '/data/features/' . $name . '_features.yml'); include_once sfConfig::get('sf_test_dir') . '/data/features/steps/' . $name . '_steps.php'; include_once sfConfig::get('sf_test_dir') . '/data/features/steps/steps.php'; foreach ($features as $name => $feature) { $this->info($name); foreach ((array) $this['Given'] as $statement) { $matches = array(); foreach ($this->givens as $given => $function) { if (preg_match_all($statement, $given, $matches)) { $function($this, $mathces); } } } foreach ((array) $this['When'] as $statement) { $matches = array(); foreach ($this->whens as $when => $function) { if (preg_match_all($statement, $when, $matches)) { $function($this, $mathces); } } } foreach ((array) $this['Then'] as $statement) { $matches = array(); foreach ($this->thens as $then => $function) { if (preg_match_all($statement, $then, $matches)) { $function($this, $mathces); } } } } }
/** * UI.Layout creates a 'page-layout' that has auto-sizing 'center pane' * surrounded by up to four collapsible and resizable 'border panes' * (north, south, east & west). It can also create multiple headers & * footers inside each pane. * @param string $layoutName The layout name * @param string $selector jQuery Selector * @param array() $configurations Array. See the options and events in * http://layout.jquery-dev.net/documentation.html#Options */ function ui_layout_configure_to($layoutName, $selector, $configurations = array()) { $configurations = get_default_widget_configuration('app_ys_jquery_ui_layout_defaults', $configurations); if (isset($configurations['yml'])) { $ymlItems = sfYaml::load($configurations['yml']); $ymlIndex = isset($configurations['ymlKey']) ? $configurations['ymlKey'] : 'layout'; $ymlConfigurations = isset($ymlItems[$ymlIndex]) ? $ymlItems[$ymlIndex] : array(); $configurations = array_merge($ymlConfigurations, $configurations); unset($configurations['yml'], $configurations['ymlKey']); } $support = core_init_javasacript_tag(); $support .= 'var ' . $layoutName . ';'; $pattern = ui_layout_pattern($configurations); $utilityMethods = ''; if (!is_array($configurations) || !sizeof($configurations) > 0) { $configurations = array('applyDefaultStyles' => true); } else { if (!isset($configurations['name'])) { $configurations['name'] = $layoutName; } $utilityMethods = ui_layout_utility_methods_pattern($layoutName, $configurations); } if (isset($configurations['cache']) && $configurations['cache'] === true) { echo add_jquery_support('window', 'unload', like_function("layoutState.save('{$layoutName}')")); $pattern = "\$.extend( {$pattern} , layoutState.load('{$layoutName}'))"; } $jsVar = like_function($layoutName . ' = ' . jquery_support($selector, 'layout', $pattern, true, $utilityMethods)); $support .= jquery_support($selector, 'ready', $jsVar); echo $support .= core_end_javasacript_tag(); }
/** * Execute /../stock/listItem * * @param type $request */ public function execute($request) { $head = sfYaml::load(sfConfig::get('sf_app_dir') . '/lib/list/item_list.yml'); $itemlist_headers = array($head['listItem']['header1'], $head['listItem']['header2'], $head['listItem']['header3'], $head['listItem']['header6']); $columns = 'id,name,sales_unit_price,stock_available'; $recordsLimit = 5; //have to take from lists if (!$request->hasParameter('pageNo')) { $pageNo = 1; } else { $pageNo = $request->getParameter('pageNo', 1); } $pager = new SimplePager('Item', $recordsLimit); $pager->setPage($pageNo); $pager->setNumResults($this->getItemService()->countItems()); $pager->init(); $offset = $pager->getOffset(); $offset = empty($offset) ? 0 : $offset; $paramHolder = new sfParameterHolder(); $paramHolder->set('columns', $columns); $paramHolder->set('offset', $offset); $paramHolder->set('limit', $recordsLimit); $itemlist_data = $this->getItemService()->getItems($paramHolder); $listContainer = new ListContainer(); $listContainer->setListName('ItemList'); $listContainer->setListHeaders($itemlist_headers); $listContainer->setListContent($itemlist_data); $listContainer->setRowLink("stock/showItem?id="); $listContainer->setPager($pager); $this->listcontainer = $listContainer; }
/** * Removes some default routes from the routing.yml file * * This removes the following routes: * * homepage (only if module=default) * * default * * default_index */ protected function removeRoutes() { $this->logSection('sympal', sprintf('...removing default routes for app "%s"', sfConfig::get('sf_app')), null, 'COMMENT'); $path = sfConfig::get('sf_app_dir') . '/config/routing.yml'; // don't do anything if the routing.yml file has been removed if (file_exists($path)) { $routes = sfYaml::load($path); $changed = false; if (isset($routes['homepage'])) { // don't remove the homepage route if it appears to be used if ($routes['homepage']['param']['module'] == 'default') { $this->logSection('sympal', 'Removing "homepage" route.'); $this->logSection('sympal', ' Unless you choose to override it in the application\'s app.yml,'); $this->logSection('sympal', ' the "homepage" route is specified inside sympal, and renders an'); $this->logSection('sympal', ' sfSympalContent object whose slug is slug is "home"'); unset($routes['homepage']); $changed = true; } } if (isset($routes['default'])) { $this->logSection('sympal', 'Removing route "default"'); unset($routes['default']); $changed = true; } if (isset($routes['default_index'])) { $this->logSection('sympal', 'Removing route "default_index"'); unset($routes['default_index']); $changed = true; } if ($changed) { $this->logSection('sympal', 'Writing modified routing file to ' . $path); file_put_contents($path, sfYaml::dump($routes)); } } }
public function setDpendencies($package, $dir) { $file = $dir . 'dependencies.yml'; if (!is_file($file)) { $package->setPhpDep('5.2.3'); $package->setPearinstallerDep('1.4.0'); return $package; } $list = sfYaml::load($file); foreach ($list as $type => $v) { if (empty($v)) { continue; } if ('php' === $type) { $v = array_merge(array('min' => false, 'max' => false, 'exclude' => false), $v); $package->setPhpDep($v['min'], $v['max'], $v['exclude']); } if ('pearinstaller' === $type) { $v = array_merge(array('min' => false, 'max' => false, 'recommended' => false, 'exclude' => false), $v); $package->setPearinstallerDep($v['min'], $v['max'], $v['recommended'], $v['exclude']); } elseif ('package' === $type || 'extension' === $type) { foreach ($v as $name => $dep) { $dep = array_merge(array('min' => false, 'max' => false, 'recommended' => false, 'exclude' => false, 'conflicts' => false, 'channel' => false), $dep); if ('extension' === $type) { $package->addExtensionDep('required', $name, $dep['min'], $dep['max'], $dep['recommended'], $dep['exclude']); } elseif ($dep['conflicts']) { $package->addConflictingPackageDepWithChannel($name, $dep['channel'], false, $dep['min'], $dep['max'], $dep['exclude']); } else { $package->addPackageDepWithChannel('required', $name, $dep['channel'], $dep['min'], $dep['max'], $dep['recommended'], $dep['exclude']); } } } } return $package; }
/** * Establece la conexion a la base de datos. * Abre el fichero de configuracion '$fileConfig', o en su defecto config/config.yml * y lee el nodo $conection donde se definen los parametros de conexion. * * En entorno de poducción los parámetros de conexión se fuerzan a: * * host = localhost * user = $conection * password= $conection * dataBase= $conection * * Si la conexion es exitosa, getDblink() devolvera valor y si no getError() nos indica * el error producido. * * @param mixed $conection Nombre de la conexion * @param string $fileConfig Nombre del fichero de configuracion */ public function __construct($conection, $fileConfig = '') { if (is_array($conection)) { $this->dbEngine = $conection['dbEngine']; $this->host = $conection['host']; $this->user = $conection['user']; $this->password = $conection['password']; $this->dataBase = $conection['database']; $this->conecta(); } else { if ($fileConfig == '') { $fileConfig = $_SERVER['DOCUMENT_ROOT'] . $_SESSION['appPath'] . "/" . $this->file; } if (file_exists($fileConfig)) { $yaml = sfYaml::load($fileConfig); $params = $yaml['config']['conections'][$conection]; $this->dbEngine = $params['dbEngine']; $this->host = $params['host']; /**if ($_SESSION['EntornoDesarrollo']) { $this->user = $conection; $this->password = $conection; $this->dataBase = $conection; } else {*/ $this->user = $params['user']; $this->password = $params['password']; $this->dataBase = $params['database']; //} $this->conecta(); } else { $this->error[] = "EntityManager []: ERROR AL LEER EL ARCHIVO DE CONFIGURACION. " . $fileConfig . " NO EXISTE\n"; } } }
/** * @see sfTask */ protected function execute($arguments = array(), $options = array()) { // update databases.yml if (!is_null($options['app'])) { $file = sfConfig::get('sf_apps_dir') . '/' . $options['app'] . '/config/databases.yml'; } else { $file = sfConfig::get('sf_config_dir') . '/databases.yml'; } $config = file_exists($file) ? sfYaml::load($file) : array(); $config[$options['env']][$options['name']] = array('class' => $options['class'], 'param' => array_merge(isset($config[$options['env']][$options['name']]['param']) ? $config[$options['env']][$options['name']]['param'] : array(), array('dsn' => $arguments['dsn'], 'username' => $arguments['username'], 'password' => $arguments['password']))); file_put_contents($file, sfYaml::dump($config, 4)); // update propel.ini if (is_null($options['app']) && false !== strpos($options['class'], 'Propel') && 'all' == $options['env']) { $propelini = sfConfig::get('sf_config_dir') . '/propel.ini'; if (file_exists($propelini)) { $content = file_get_contents($propelini); if (preg_match('/^(.+?):/', $arguments['dsn'], $match)) { $content = preg_replace('/^propel\\.database(\\s*)=(\\s*)(.+?)$/m', 'propel.database$1=${2}' . $match[1], $content); $content = preg_replace('/^propel\\.database.driver(\\s*)=(\\s*)(.+?)$/m', 'propel.database.driver$1=${2}' . $match[1], $content); $content = preg_replace('/^propel\\.database\\.createUrl(\\s*)=(\\s*)(.+?)$/m', 'propel.database.createUrl$1=${2}' . $arguments['dsn'], $content); $content = preg_replace('/^propel\\.database\\.url(\\s*)=(\\s*)(.+?)$/m', 'propel.database.url$1=${2}' . $arguments['dsn'], $content); $content = preg_replace('/^propel\\.database\\.user(\\s*)=(\\s*)(.+?)$/m', 'propel.database.user$1=${2}' . $arguments['username'], $content); $content = preg_replace('/^propel\\.database\\.password(\\s*)=(\\s*)(.+?)$/m', 'propel.database.password$1=${2}' . $arguments['password'], $content); file_put_contents($propelini, $content); } } } }
/** * Load translation data * * @param string|array $data Filename and full path to the translation source * @param string $locale Locale/Language to add data for, identical with locale identifier, * see Zend_Locale for more information * @param array $option OPTIONAL Options to use */ protected function _loadTranslationData($data, $locale, array $options = array()) { $options = array_merge($this->_options, $options); if ($options['clear'] || !isset($this->_translate[$locale])) { $this->_translate[$locale] = array(); } if (is_array($data)) { return array($locale => $data); } $this->_filename = $data; if (!is_readable($this->_filename)) { require_once 'Zend/Translate/Exception.php'; throw new Zend_Translate_Exception('Error opening translation file \'' . $this->_filename . '\'.'); } $content = sfYaml::load(file_get_contents($this->_filename)); if ($locale != 'auto' && $content && !array_key_exists($locale, $content)) { require_once 'Zend/Translate/Exception.php'; throw new Zend_Translate_Exception(sprintf('Locale "%s" not found in file %s', $locale, $this->_filename)); } // Rails YML files supported arbitrarily nested keys, Zend_Translate doesn't - so we flatten them. // See http://stackoverflow.com/questions/7011451/transaprently-flatten-an-array/7011675 $flattened = array(); if ($content && $content[$locale]) { $iterator = new Translate_Adapter_RailsYaml_Iterator(new RecursiveArrayIterator($content[$locale])); foreach ($iterator as $k => $v) { $flattened[implode($options['keyDelimiter'], $iterator->getKeyStack())] = $v; } } return array($locale => $flattened); }