Create the necessary shims to emulate the ext/calendar package.

@return void
766544
public static function create()
    {
        self::$french_calendar    = new FrenchCalendar();
        self::$gregorian_calendar = new GregorianCalendar();
        self::$jewish_calendar    = new JewishCalendar(array(
            JewishCalendar::EMULATE_BUG_54254 => self::shouldEmulateBug54254(),
        ));
        self::$julian_calendar    = new JulianCalendar();
    }
915187
public function create()
    {
        $params = array(
            'start' => $this->getStart(),
            'hash' => $this->getHash(),
            'parameters' => implode(',', $this->getParameters())
        );
        if (is_int($this->end)) {
            $params['end'] = $this->getEnd();
        }
        $this->fromResponse($this->getUser()->post('preview/create', $params));
    }
811481
public function createStoredFieldsFiles()
    {
        $this->_fdxFile = $this->_directory->createFile($this->_name . '.fdx');
        $this->_fdtFile = $this->_directory->createFile($this->_name . '.fdt');

        $this->_files[] = $this->_name . '.fdx';
        $this->_files[] = $this->_name . '.fdt';
    }
775772
private static function createDependencies()
    {
        if (isset(self::$renderers)) {
            return;
        }

        self::$renderers = array(
            'rect'      => new Renderers\SVGRectRenderer(),
            'line'      => new Renderers\SVGLineRenderer(),
            'ellipse'   => new Renderers\SVGEllipseRenderer(),
            'polygon'   => new Renderers\SVGPolygonRenderer(),
            'image'     => new Renderers\SVGImageRenderer(),
            'text'      => new Renderers\SVGTextRenderer(),
        );

        self::$pathParser       = new Path\SVGPathParser();
        self::$pathApproximator = new Path\SVGPathApproximator();
    }
524315
public function createFixtures()
    {
        /**
         * Bundle fixtures
         */
        if($this->container->getParameter('core.fixtures_bundle')){
            $this->runSqlScript('Country.sql');
            $this->runSqlScript('State.sql');
            //$this->runSqlScript('PostalCode.sql');
            $this->runSqlScript('Translation.sql');

            //get dinamic actor class
            $actorClass = $this->container->get('core_manager')->getActorClass();

            $factory = $this->get('security.encoder_factory');
            $encoder = $factory->getEncoder(new $actorClass());

            //Roles
            $userRole = new Role();
            $userRole->setName('user');
            $userRole->setRole(Role::USER);
            $this->getManager()->persist($userRole);

            $managerRole = new Role();
            $managerRole->setName('manager');
            $managerRole->setRole(Role::MANAGER);
            $this->getManager()->persist($managerRole);

            $companyRole = new Role();
            $companyRole->setName('company');
            $companyRole->setRole(Role::COMPANY);
            $this->getManager()->persist($companyRole);

            $adminRole = new Role();
            $adminRole->setName('admin');
            $adminRole->setRole(Role::ADMIN);
            $this->getManager()->persist($adminRole);

            $superRole = new Role();
            $superRole->setName('root');
            $superRole->setRole(Role::SUPER_ADMIN);
            $this->getManager()->persist($superRole);

            $this->getManager()->flush();

             //User root
            $password = 'root';
            $root = new BaseUser();
            $root->setUsername('root');
            $root->setEmail('root@latinotype.com');
            $root->addRole($superRole);
            $encodePassword = $encoder->encodePassword($password, $root->getSalt());
            $root->setPassword($encodePassword);
            $root->setName('Root');
            $root->setActive(true);
            $this->getManager()->persist($root);
            
            $this->getManager()->flush();
            
            /**
             * Add Parameters
             */
            $this->addParameters();

        }
        
        /**
         * Dev fixtures
         */
        if($this->container->getParameter('core.fixtures_dev')){
            //User admin
            $password = 'admin';
            $admin = new $actorClass();
            $admin->setUsername('admin');
            $admin->setEmail('admin@admin.com');
            $admin->addRole($adminRole);
            $encodePassword = $encoder->encodePassword($password, $admin->getSalt());
            $admin->setPassword($encodePassword);
            $admin->setName('Admin');
            $admin->setLastname('Lastname');
            $admin->setActive(true);
            $this->getManager()->persist($admin);

            $password2 = 'company';
            $company = new $actorClass();
            $company->setUsername('company');
            $company->setEmail('company@latinotype.com');
            $company->addRole($companyRole);
            $encodePassword2 = $encoder->encodePassword($password2, $company->getSalt());
            $company->setPassword($encodePassword2);
            $company->setName('Company');
            $company->setLastname('Lastname');
            $company->setActive(true);
            $this->getManager()->persist($company);

            $password = 'user';
            $user = new $actorClass();
            $user->setUsername('user');
            $user->setEmail('user@user.com');
            $user->addRole($userRole);
            $encodePassword = $encoder->encodePassword($password, $user->getSalt());
            $user->setPassword($encodePassword);
            $user->setName('User');
            $user->setLastname('Lastname');
            $user->setActive(true);
            $this->getManager()->persist($user);

            $password2 = 'user2';
            $user2 = new $actorClass();
            $user2->setUsername('user2');
            $user2->setEmail('user2@user2.com');
            $user2->addRole($userRole);
            $encodePassword2 = $encoder->encodePassword($password2, $user2->getSalt());
            $user2->setPassword($encodePassword2);
            $user2->setName('User2');
            $user2->setLastname('Lastname2');
            $user2->setActive(true);
            $this->getManager()->persist($user2);

            $this->getManager()->flush();
        }
        
    }
795740
public function buildPropelModels()
    {
        $fs = new Filesystem();

        // cache testing
        if ($fs->exists($this->getPropelModelDir() . 'hash')
            && file_get_contents($this->getPropelCacheDir() . 'hash') === file_get_contents($this->getPropelModelDir() . 'hash')) {
            return;
        }

        $fs->remove($this->getPropelModelDir());

        $this->runCommand(
            new ModelBuildCommand(),
            [
                '--config-dir' => $this->getPropelConfigDir(),
                '--schema-dir' => $this->getPropelSchemaDir(),
            ]
        );

        $fs->copy(
            $this->getPropelCacheDir() . 'hash',
            $this->getPropelModelDir() . 'hash'
        );
    }
1286658
protected function createModel()
    {
        if (! $this->model instanceof \Gems_Model_AppointmentModel) {
            $this->model = $this->loader->getModels()->createAppointmentModel();
            $this->model->applyBrowseSettings();
        }
        $this->model->addColumn(new \Zend_Db_Expr("CONVERT(gap_admission_time, DATE)"), 'date_only');
        $this->model->set('date_only', 'dateFormat',
                \Zend_Date::WEEKDAY . ' ' . \Zend_Date::DAY_SHORT . ' ' .
                \Zend_Date::MONTH_NAME . ' ' . \Zend_Date::YEAR,
                'storageFormat', 'YYYY-MM-DD'
                );
        $this->model->set('gap_admission_time', 'label', $this->_('Time'),
                'dateFormat', 'HH:mm');

        $this->model->set('gr2o_patient_nr', 'label', $this->_('Respondent nr'));

        \Gems_Model_RespondentModel::addNameToModel($this->model, $this->_('Name'));

        // \MUtil_Model::$verbose = true;
        return $this->model;
    }
1124648
public function actionCreate()
    {
        
        $extensionsToCreate = explode(',', $this->options['extension']);
        $extensionsToCreate = array_unique($extensionsToCreate);
        
        foreach ($extensionsToCreate as $etc){
        	$this->options['extension'] = $etc;
        	$this->options['input'] = dirname(__FILE__) . '/../../' . $etc . '/' . self::DEF_INPUT_DIR;
        	$this->options['output'] = dirname(__FILE__) . '/../../' . $etc . '/' . self::DEF_OUTPUT_DIR;
        	
        	$this->outVerbose("Creating language '" . $this->options['language'] . "' for extension '" . $this->options['extension'] . "' ...");
        	 
        	// We first create the directory where locale files will go.
        	$dir = $this->buildLanguagePath($this->options['extension'], $this->options['language']);
        	$dirExists = false;
        	
        	if (file_exists($dir) && is_dir($dir) && $this->options['force'] == true) {
        		$dirExists = true;
        		$this->outVerbose("Language '" . $this->options['language'] . "' exists for extension '" . $this->options['extension'] . "'. Creation will be forced.");
        		 
        		// Clean it up.
        		foreach (scandir($dir) as $d) {
        			if ($d !== '.' && $d !== '..' && $d !== '.svn') {
        				if (!tao_helpers_File::remove($dir . '/' . $d, true)) {
        					$this->err("Unable to clean up 'language' directory '" . $dir . "'.", true);
        				}
        			}
        		}
        	} else if (file_exists($dir) && is_dir($dir) && $this->options['force'] == false) {
        		$this->err("The 'language' " . $this->options['language'] . " already exists in the file system. Use the 'force' parameter to overwrite it.", true);
        	}
        	
        	// If we are still here... it means that we have to create the language directory.
        	if (!$dirExists && !@mkdir($dir)) {
        		$this->err("Unable to create 'language' directory '" . $this->options['language'] . "'.", true);
        	} else {
        		if ($this->options['build'] == true) {
        			$sortingMethod = tao_helpers_translation_TranslationFile::SORT_ASC_I;
        			$this->outVerbose("Building language '" . $this->options['language'] . "' for extension '" . $this->options['extension'] . "' ...");
        			// Let's populate the language with raw PO files containing sources but no targets.
        			// Source code extraction.
        			$fileExtensions = array('php', 'tpl', 'js', 'ejs');
        			$filePaths = array();
        			foreach (self::$WHITE_LIST as $subFolder) {
        			    $filePaths[] = $this->options['input'] . DIRECTORY_SEPARATOR. $subFolder;
        			}
        			 
        			$sourceExtractor = new tao_helpers_translation_SourceCodeExtractor($filePaths, $fileExtensions);
        			$sourceExtractor->extract();
        	
        			$translationFile = new tao_helpers_translation_POFile();
        			$translationFile->setSourceLanguage(tao_helpers_translation_Utils::getDefaultLanguage());
        			$translationFile->setTargetLanguage($this->options['language']);
        			$translationFile->addTranslationUnits($sourceExtractor->getTranslationUnits());
        			
        			$file = MenuService::getStructuresFilePath($this->options['extension']);
        			if (!is_null($file)) {
            			$structureExtractor = new tao_helpers_translation_StructureExtractor(array($file));
            			$structureExtractor->extract();
            			$translationFile->addTranslationUnits($structureExtractor->getTranslationUnits());
        			}

        			$sortedTus = $translationFile->sortBySource($sortingMethod);
        	
        			$sortedTranslationFile = new tao_helpers_translation_POFile();
        			$sortedTranslationFile->setSourceLanguage(tao_helpers_translation_Utils::getDefaultLanguage());
        			$sortedTranslationFile->setTargetLanguage($this->options['language']);
        			$sortedTranslationFile->addTranslationUnits($sortedTus);
        			$this->preparePOFile($sortedTranslationFile, true);

        			$poPath = $dir . '/' . self::DEF_PO_FILENAME;
        			$writer = new tao_helpers_translation_POFileWriter($poPath,
        					$sortedTranslationFile);
        			$writer->write();
        			$this->outVerbose("PO Translation file '" . basename($poPath) . "' in '" . $this->options['language'] . "' created for extension '" . $this->options['extension'] ."'.");
        			$writer->write();

					// Writing JS files
					$jsPath = $dir . '/' . self::DEF_JS_FILENAME;
        			$writer = new tao_helpers_translation_JSFileWriter(
						 $jsPath, $sortedTranslationFile
					);
        			$writer->write(false);
					$this->outVerbose("JavaScript Translation file '" . basename($jsPath) . "' in '" . $this->options['language'] . "' created for extension '" . $this->options['extension'] ."'.");
					$writer->write();

        			// Now that PO files & JS files are created, we can create the translation models
        			// if we find RDF models to load for this extension.
        			$translatableProperties = array(OntologyRdfs::RDFS_LABEL, OntologyRdfs::RDFS_COMMENT);
        	
        			foreach ($this->getOntologyFiles() as $f){
       					common_Logger::d('reading rdf '.$f);
						$translationFile = $this->extractPoFileFromRDF($f, $translatableProperties);

						$writer = new tao_helpers_translation_POFileWriter($dir . '/' . $this->getOntologyPOFileName($f), $translationFile);
       					$writer->write();

       					$this->outVerbose("PO Translation file '" .  $this->getOntologyPOFileName($f) . "' in '" . $this->options['language'] . "' created for extension '" . $this->options['extension'] . "'.");
        			}
        	
        			$this->outVerbose("Language '" . $this->options['language'] . "' created for extension '" . $this->options['extension'] . "'.");
        		} else {
        			// Only build virgin files.
        			// (Like a virgin... woot !)
        			$translationFile = new tao_helpers_translation_POFile();
        			$translationFile->setSourceLanguage(tao_helpers_translation_Utils::getDefaultLanguage());
        			$translationFile->setTargetLanguage($this->options['language']);
        			$this->preparePOFile($translationFile, true);

        			foreach ($this->getOntologyFiles() as $f){
                            common_Logger::d('reading rdf '.$f);
                            $translationFile = new tao_helpers_translation_POFile();
        					$translationFile->setSourceLanguage(tao_helpers_translation_Utils::getDefaultLanguage());
        					$translationFile->setTargetLanguage($this->options['language']);
        					$translationFile->setExtensionId($this->options['extension']);

						$writer = new tao_helpers_translation_POFileWriter($dir . '/' . $this->getOntologyPOFileName($f), $translationFile);
                        $writer->write();
        			}
        	
        			$this->outVerbose("Language '" . $this->options['language'] . "' created for extension '" . $this->options['extension'] . "'.");
        		}
        	
        		// Create the language manifest in RDF.
        		if ($this->options['extension'] == 'tao'){
        			$langDescription = tao_helpers_translation_RDFUtils::createLanguageDescription($this->options['language'],
        					$this->options['languageLabel']);
        			$langDescription->save($dir . '/' . self::DEF_LANG_FILENAME);
        		}
        	}	
        }
        
    }
465804
protected function generate()
    {
        if ($this->subperiodsProcessed) {
            return;
        }

        parent::generate();
        $date = $this->date;

        if ($date->toString('N') > 1) {
            $date = $date->subDay($date->toString('N') - 1);
        }

        $startWeek = $date;

        $currentDay = clone $startWeek;
        while ($currentDay->compareWeek($startWeek) == 0) {
            $this->addSubperiod(new Day($currentDay));
            $currentDay = $currentDay->addDay(1);
        }
    }
838730
public function prepare_package() {
        $entries = $this->exportdata['entries'];
        $aliases = array();
        $categories = array();
        if (is_array($this->exportdata['aliases'])) {
            foreach ($this->exportdata['aliases'] as $alias) {
                if (!array_key_exists($alias->entryid, $aliases)) {
                    $aliases[$alias->entryid] = array();
                }
                $aliases[$alias->entryid][] = $alias->alias;
            }
        }
        if (is_array($this->exportdata['categoryentries'])) {
            foreach ($this->exportdata['categoryentries'] as $cat) {
                if (!array_key_exists($cat->entryid, $categories)) {
                    $categories[$cat->entryid] = array();
                }
                $categories[$cat->entryid][] = $cat->name;
            }
        }
        if ($this->get('exporter')->get('formatclass') == PORTFOLIO_FORMAT_SPREADSHEET) {
            $csv = glossary_generate_export_csv($entries, $aliases, $categories);
            $this->exporter->write_new_file($csv, clean_filename($this->cm->name) . '.csv', false);
            return;
        } else if ($this->get('exporter')->get('formatclass') == PORTFOLIO_FORMAT_LEAP2A) {
            $ids = array(); // keep track of these to make into a selection later
            global $USER, $DB;
            $writer = $this->get('exporter')->get('format')->leap2a_writer($USER);
            $format = $this->exporter->get('format');
            $filename = $this->get('exporter')->get('format')->manifest_name();
            foreach ($entries as $e) {
                $content = glossary_entry_portfolio_caller::entry_content(
                    $this->course,
                    $this->cm,
                    $this->glossary,
                    $e,
                    (array_key_exists($e->id, $aliases) ? $aliases[$e->id] : array()),
                    $format
                );
                $entry = new portfolio_format_leap2a_entry('glossaryentry' . $e->id, $e->concept, 'entry', $content);
                $entry->author    = $DB->get_record('user', array('id' => $e->userid), 'id,firstname,lastname,email');
                $entry->published = $e->timecreated;
                $entry->updated   = $e->timemodified;
                if (!empty($this->keyedfiles[$e->id])) {
                    $writer->link_files($entry, $this->keyedfiles[$e->id], 'glossaryentry' . $e->id . 'file');
                    foreach ($this->keyedfiles[$e->id] as $file) {
                        $this->exporter->copy_existing_file($file);
                    }
                }
                if (!empty($categories[$e->id])) {
                    foreach ($categories[$e->id] as $cat) {
                        // this essentially treats them as plain tags
                        // leap has the idea of category schemes
                        // but I think this is overkill here
                        $entry->add_category($cat);
                    }
                }
                $writer->add_entry($entry);
                $ids[] = $entry->id;
            }
            $selection = new portfolio_format_leap2a_entry('wholeglossary' . $this->glossary->id, get_string('modulename', 'glossary'), 'selection');
            $writer->add_entry($selection);
            $writer->make_selection($selection, $ids, 'Grouping');
            $content = $writer->to_xml();
        }
        $this->exporter->write_new_file($content, $filename, true);
    }
236641
protected function createModel()
    {
        if ($this->model instanceof \Gems_Model_AppointmentModel) {
            $model = $this->model;
        } else {
            $model = $this->loader->getModels()->createAppointmentModel();
            $model->applyBrowseSettings();
        }

        $model->addColumn(new \Zend_Db_Expr("CONVERT(gap_admission_time, DATE)"), 'date_only');
        $model->set('date_only', 'formatFunction', array($this, 'formatDate'));
                // 'dateFormat', \Zend_Date::DAY_SHORT . ' ' . \Zend_Date::MONTH_NAME . ' ' . \Zend_Date::YEAR);
        $model->set('gap_admission_time', 'label', $this->_('Time'),
                'formatFunction', array($this, 'formatTime'));
                // 'dateFormat', 'HH:mm ' . \Zend_Date::WEEKDAY);

        $this->_dateStorageFormat = $model->get('gap_admission_time', 'storageFormat');
        // $this->_timeImg           = \MUtil_Html::create('img', array('src' => 'stopwatch.png', 'alt' => ''));

        $model->set('gr2o_patient_nr', 'label', $this->_('Respondent nr'));

        if ($this->respondent instanceof \Gems_Tracker_Respondent) {
            $model->addFilter(array(
                'gap_id_user' => $this->respondent->getId(),
                'gap_id_organization' => $this->respondent->getOrganizationId(),
                ));
        }

        return $model;
    }
340215
protected function createStages()
    {
        // Get stages
        $availableStages = $this->connections->getAvailableStages();
        $originalStage = $this->connections->getCurrentConnectionKey()->stage;
        if (empty($availableStages)) {
            $availableStages = [null];
        }

        // Create folders
        $mapping = $this->config->get('remote.directories');
        foreach ($availableStages as $stage) {
            $this->connections->setStage($stage);
            $this->createFolder($mapping['releases']);
            $this->createFolder($mapping['current']);
            $this->createFolder($mapping['shared']);
        }

        if ($originalStage) {
            $this->connections->setStage($originalStage);
        }
    }
1315521
protected function createTrueSubset()
    {
        $this->parent->data[$this->emptySubset] = array();
        $this->data = & $this->parent->data[$this->emptySubset];
        $this->emptySubset = null;
    }
264718
protected function configure(): void
    {

        $this->register('makeType');
        $this->register('makeValue');
        $this->register('makeArgument');
        $this->register('makeStrong');
        $this->register('makeExceptionHeader');
        $this->register('makeExceptionBody');
        $this->register('makeExceptionTrace');
        $this->register('makeEmpty');
    }
1193901
protected function makeYamlCopy()
    {
        if ($this->yamlCopyRequired) {
            file_put_contents(
                $this->yamlDocsFile,
                (new YamlDumper(2))->dump(json_decode(file_get_contents($this->docsFile), true), 20)
            );
        }
    }
1104693
protected function createCompositeWidgets()
    {
        $this->ignore_errors_checkbox = new SwatCheckbox(
            $this->id . '_ignore_checkbox'
        );

        $ignore_field = new SwatFormField($this->id . '_ignore_field');
        $ignore_field->title = Swat::_('Ignore XHTML validation errors');
        $ignore_field->add($this->ignore_errors_checkbox);

        $this->addCompositeWidget($ignore_field, 'ignore_field');
    }
1282108
public function build()
    {
        foreach ($this->modules->enabled() as $module) {
            $name = studly_case($module->getName());
            $class = 'Modules\\'.$name.'\\MenuExtenders\\SidebarExtender';

            if (class_exists($class)) {
                $extender = $this->container->make($class);

                $this->menu->add(
                    $extender->extendWith($this->menu)
                );
            }
        }
    }