protected function getPages() { if (!$this->using_pages || $this->count_items <= $this->items_on_page) { return; } // aktualna strona kategorii $page = ClassTools::getValue('page') ? ClassTools::getValue('page') . '/' : ''; echo '<div class="sew-pages clearfix"><ul class="clearfix">'; for ($i = 1; $i <= ceil($this->count_items / $this->items_on_page); $i++) { echo '<li><a href="/' . $this->controller_name . '/' . $page . 'strona/' . $i . '" class="btn btn-' . ($this->current_page == $i ? 'default" disabled="disabled"' : 'default"') . '>' . $i . '</a></li>'; } echo '</ul></div>'; return; }
/** * Returns classpath to parent class. * @return string */ protected function getParentClassName() { $ancestorClassName = ClassTools::classname($this->getChild()->getAncestor()); if ($this->getDatabase()->hasTableByPhpName($ancestorClassName)) { return $this->getNewStubQueryBuilder($this->getDatabase()->getTableByPhpName($ancestorClassName))->getClassname(); } else { // find the inheritance for the parent class foreach ($this->getTable()->getChildrenColumn()->getChildren() as $child) { if ($child->getClassName() == $ancestorClassName) { return $this->getNewStubQueryInheritanceBuilder($child)->getClassname(); } } } }
/** * Validates the current table to make sure that it won't * result in generated code that will not parse. * * This method may emit warnings for code which may cause problems * and will throw exceptions for errors that will definitely cause * problems. */ protected function validateModel() { parent::validateModel(); $table = $this->getTable(); // Check to see if any of the column constants are PHP reserved words. $colConstants = array(); foreach ($table->getColumns() as $col) { $colConstants[] = $this->getColumnName($col); } $reservedConstants = array_map('strtoupper', ClassTools::getPhpReservedWords()); $intersect = array_intersect($reservedConstants, $colConstants); if (!empty($intersect)) { throw new EngineException("One or more of your column names for [" . $table->getName() . "] table conflict with a PHP reserved word (" . implode(", ", $intersect) . ")"); } }
protected static function generateWhereList($controller, $prefix = false) { if (!($session_search = self::getSearchSession($controller))) { return false; } $prefix = $prefix ? $prefix . '.' : ''; $first = true; foreach ($session_search as $key => $val) { $val = ClassTools::pSQL($val); if ($first) { $first = false; $search = "{$prefix}`{$key}` LIKE '%{$val}%'"; } else { $search .= " AND {$prefix}`{$key}` LIKE '%{$val}%'"; } } return $search; }
protected function addClassClose(&$script) { parent::addClassClose($script); $behavior_file_name = 'Base' . $this->getTable()->getPhpName() . 'Behaviors'; $behavior_file_path = ClassTools::getFilePath($this->getStubObjectBuilder()->getPackage() . '.om', $behavior_file_name); $absolute_behavior_file_path = sfConfig::get('sf_root_dir') . '/' . $behavior_file_path; if (file_exists($absolute_behavior_file_path)) { unlink($absolute_behavior_file_path); } $behaviors = $this->getTable()->getAttribute('behaviors'); if ($behaviors) { file_put_contents($absolute_behavior_file_path, sprintf("<?php\nsfPropelBehavior::add('%s', %s);\n", $this->getTable()->getPhpName(), var_export(unserialize($behaviors), true))); $behavior_include_script = <<<EOF if (sfProjectConfiguration::getActive() instanceof sfApplicationConfiguration) { include_once '%s'; } EOF; $script .= sprintf($behavior_include_script, $behavior_file_path); } }
protected function search() { if (!$this->checkSearchDefinition()) { return; } $ClassModel = new ClassModel(); $session_old = false; $session = array(); $class = $this->search_definition['class']; $definition = $class::$definition['fields']; if (isset($_SESSION['search'][$this->search_definition['controller']])) { $session_old = $_SESSION['search'][$this->search_definition['controller']]; } foreach ($_POST as $key => $val) { if ($key == 'form_action_search') { continue; } $value = ClassTools::getValue($key) !== false && ClassTools::getValue($key) != '' ? ClassTools::getValue($key) : false; if ($value === false) { continue; } if (isset($this->search_definition['form'][$key])) { if (isset($definition[$key]) && isset($definition[$key]['validate'])) { foreach ($definition[$key]['validate'] as $validate_method) { $value = $ClassModel->validByMethod($validate_method, $value, $definition[$key]['name'], $key); if ($ClassModel->errors && count($ClassModel->errors) > 0) { $this->alerts['danger search'][] = $ClassModel->errors['0']; $ClassModel->errors = array(); } else { $session[$key] = $value; } } } else { $session[$key] = $value; } } } $_SESSION['search'][$this->search_definition['controller']] = $session; return; }
protected function edit() { // ladowanie klasy $item = new ClassSoldierSchool(ClassTools::getValue('id_school')); // sprawdza czy klasa zostala poprawnie zaladowana if (!$item->load_class) { $this->alerts['danger'] = "Szkoła żołnierza nie istnieje."; return; } $item->name = ClassTools::getValue('form_name'); $item->address = ClassTools::getValue('form_address'); $item->specialization = ClassTools::getValue('form_specialization'); $item->id_academic_degree = ClassTools::getValue('form_academic_degree'); $item->date_start = ClassTools::getValue('form_date_start'); $item->date_end = ClassTools::getValue('form_date_end'); $item->id_soldier = ClassTools::getValue('id_soldier'); $item->id_user = ClassAuth::getCurrentUserId(); // komunikaty bledu if (!$item->update()) { $this->alerts['danger'] = $item->errors; return; } // komunikat $this->alerts['success'] = "Poprawnie zaktualizowano szkolę żołnierza: <b>{$item->name}</b>"; // czyszczeie zmiennych wyswietlania $this->tpl_values = ''; $_POST = array(); return; }
public function getClassFilePath() { return ClassTools::getFilePath('lib.model.om', $this->getClassname()); }
public static function generateRandomPasswordLinkKey() { return ClassTools::generateRandomPasswd(60, array('1', '2', '3')); }
protected function detach() { // ladowanie klasy $item = new ClassSoldier2Mission(ClassTools::getValue('id_soldier2missions')); // sprawdza czy klasa zostala poprawnie zaladowana if (!$item->load_class) { $this->alerts['danger'] = "Misja żołnierza nie istnieje."; return; } $item->id_soldier = ClassTools::getValue('id_soldier'); $item->id_mission = ClassTools::getValue('id_mission'); $item->description_detach = ClassTools::getValue('form_description_detach'); $item->date_mission_detach = ClassTools::getValue('form_date'); $item->id_user = ClassAuth::getCurrentUserId(); // komunikaty bledu if (!$item->detach()) { $this->alerts['danger'] = $item->errors; return; } // komunikat $this->alerts['success'] = "Poprawnie oddelegowano żołnierza z misji."; // czyszczeie zmiennych wyswietlania $this->tpl_values = ''; $_POST = array(); return; }
/** * Lists data model classes and builds an associative array className => classPath * To be used for autoloading * @return array */ protected function getClassMap() { $phpconfClassmap = array(); $generatorConfig = $this->getGeneratorConfig(); foreach ($this->getDataModels() as $dataModel) { foreach ($dataModel->getDatabases() as $database) { $classMap = array(); foreach ($database->getTables() as $table) { if (!$table->isForReferenceOnly()) { // ----------------------------------------------------- // Add TableMap class, // Peer, Object & Query stub classes, // and Peer, Object & Query base classes // ----------------------------------------------------- // (this code is based on PropelOMTask) foreach (array('tablemap', 'peerstub', 'objectstub', 'querystub', 'peer', 'object', 'query') as $target) { $builder = $generatorConfig->getConfiguredBuilder($table, $target); $this->log("Adding class mapping: " . $builder->getClassname() . ' => ' . $builder->getClassFilePath()); $classMap[$builder->getClassname()] = $builder->getClassFilePath(); } // ----------------------------------------------------- // Add children classes for object and query, // as well as base child query, // for single tabel inheritance tables. // ----------------------------------------------------- if ($col = $table->getChildrenColumn()) { if ($col->isEnumeratedClasses()) { foreach ($col->getChildren() as $child) { foreach (array('objectmultiextend', 'queryinheritance', 'queryinheritancestub') as $target) { $builder = $generatorConfig->getConfiguredBuilder($table, $target); $builder->setChild($child); $this->log("Adding class mapping: " . $builder->getClassname() . ' => ' . $builder->getClassFilePath()); $classMap[$builder->getClassname()] = $builder->getClassFilePath(); } } } } // ----------------------------------------------------- // Add base classes for alias tables (undocumented) // ----------------------------------------------------- $baseClass = $table->getBaseClass(); if ($baseClass !== null) { $className = ClassTools::classname($baseClass); if (!isset($classMap[$className])) { $classPath = ClassTools::getFilePath($baseClass); $this->log('Adding class mapping: ' . $className . ' => ' . $classPath); $classMap[$className] = $classPath; } } $basePeer = $table->getBasePeer(); if ($basePeer !== null) { $className = ClassTools::classname($basePeer); if (!isset($classMap[$className])) { $classPath = ClassTools::getFilePath($basePeer); $this->log('Adding class mapping: ' . $className . ' => ' . $classPath); $classMap[$className] = $classPath; } } // ---------------------------------------------- // Add classes for interface // ---------------------------------------------- if ($table->getInterface()) { $builder = $generatorConfig->getConfiguredBuilder($table, 'interface'); $this->log("Adding class mapping: " . $builder->getClassname() . ' => ' . $builder->getClassFilePath()); $classMap[$builder->getClassname()] = $builder->getClassFilePath(); } // ---------------------------------------------- // Add classes from old treeMode implementations // ---------------------------------------------- if ($table->treeMode() == 'MaterializedPath') { foreach (array('nodepeerstub', 'nodestub', 'nodepeer', 'node') as $target) { $builder = $generatorConfig->getConfiguredBuilder($table, $target); $this->log("Adding class mapping: " . $builder->getClassname() . ' => ' . $builder->getClassFilePath()); $classMap[$builder->getClassname()] = $builder->getClassFilePath(); } } if ($table->treeMode() == 'NestedSet') { foreach (array('nestedset', 'nestedsetpeer') as $target) { $builder = $generatorConfig->getConfiguredBuilder($table, $target); $this->log("Adding class mapping: " . $builder->getClassname() . ' => ' . $builder->getClassFilePath()); $classMap[$builder->getClassname()] = $builder->getClassFilePath(); } } } // if (!$table->isReferenceOnly()) } $phpconfClassmap = array_merge($phpconfClassmap, $classMap); } } return $phpconfClassmap; }
public function main() { // check to make sure task received all correct params $this->validate(); $basepath = $this->getOutputDirectory(); // Get new Capsule context $generator = $this->createContext(); $generator->put("basepath", $basepath); // make available to other templates $targetPlatform = $this->getTargetPlatform(); // convenience for embedding in strings below // we need some values that were loaded into the template context $basePrefix = $generator->get('basePrefix'); $project = $generator->get('project'); foreach ($this->getDataModels() as $dataModel) { $this->log("Processing Datamodel : " . $dataModel->getName()); foreach ($dataModel->getDatabases() as $database) { $this->log(" - processing database : " . $database->getName()); $generator->put("platform", $database->getPlatform()); foreach ($database->getTables() as $table) { if (!$table->isForReferenceOnly()) { if ($table->getPackage()) { $package = $table->getPackage(); } else { $package = $this->targetPackage; } $pkbase = "{$package}.om"; $pkpeer = "{$package}"; $pkmap = "{$package}.map"; // make these available $generator->put("package", $package); $generator->put("pkbase", $pkbase); //$generator->put("pkpeer", $pkpeer); -- we're not using this yet $generator->put("pkmap", $pkmap); foreach (array($pkpeer, $pkmap, $pkbase) as $pk) { $path = strtr($pk, '.', '/'); $f = new PhingFile($this->getOutputDirectory(), $path); if (!$f->exists()) { if (!$f->mkdirs()) { throw new Exception("Error creating directories: " . $f->getPath()); } } } // for each package $this->log("\t+ " . $table->getName()); $generator->put("table", $table); // Create the Base Peer class $this->log("\t\t-> " . $basePrefix . $table->getPhpName() . "Peer"); $path = ClassTools::getFilePath($pkbase, $basePrefix . $table->getPhpName() . "Peer"); $generator->parse("om/{$targetPlatform}/Peer.tpl", $path); // Create the Base object class $this->log("\t\t-> " . $basePrefix . $table->getPhpName()); $path = ClassTools::getFilePath($pkbase, $basePrefix . $table->getPhpName()); $generator->parse("om/{$targetPlatform}/Object.tpl", $path); if ($table->isTree()) { // Create the Base NodePeer class $this->log("\t\t-> " . $basePrefix . $table->getPhpName() . "NodePeer"); $path = ClassTools::getFilePath($pkbase, $basePrefix . $table->getPhpName() . "NodePeer"); $generator->parse("om/{$targetPlatform}/NodePeer.tpl", $path); // Create the Base Node class if the table is a tree $this->log("\t\t-> " . $basePrefix . $table->getPhpName() . "Node"); $path = ClassTools::getFilePath($pkbase, $basePrefix . $table->getPhpName() . "Node"); $generator->parse("om/{$targetPlatform}/Node.tpl", $path); } // Create MapBuilder class if this table is not an alias if (!$table->isAlias()) { $this->log("\t\t-> " . $table->getPhpName() . "MapBuilder"); $path = ClassTools::getFilePath($pkmap, $table->getPhpName() . "MapBuilder"); $generator->parse("om/{$targetPlatform}/MapBuilder.tpl", $path); } // if !$table->isAlias() // Create [empty] stub Peer class if it does not already exist $path = ClassTools::getFilePath($package, $table->getPhpName() . "Peer"); $_f = new PhingFile($basepath, $path); if (!$_f->exists()) { $this->log("\t\t-> " . $table->getPhpName() . "Peer"); $generator->parse("om/{$targetPlatform}/ExtensionPeer.tpl", $path); } else { $this->log("\t\t-> (exists) " . $table->getPhpName() . "Peer"); } // Create [empty] stub object class if it does not already exist $path = ClassTools::getFilePath($package, $table->getPhpName()); $_f = new PhingFile($basepath, $path); if (!$_f->exists()) { $this->log("\t\t-> " . $table->getPhpName()); $generator->parse("om/{$targetPlatform}/ExtensionObject.tpl", $path); } else { $this->log("\t\t-> (exists) " . $table->getPhpName()); } if ($table->isTree()) { // Create [empty] stub Node Peer class if it does not already exist $path = ClassTools::getFilePath($package, $table->getPhpName() . "NodePeer"); $_f = new PhingFile($basepath, $path); if (!$_f->exists()) { $this->log("\t\t-> " . $table->getPhpName() . "NodePeer"); $generator->parse("om/{$targetPlatform}/ExtensionNodePeer.tpl", $path); } else { $this->log("\t\t-> (exists) " . $table->getPhpName() . "NodePeer"); } // Create [empty] stub Node class if it does not already exist $path = ClassTools::getFilePath($package, $table->getPhpName() . "Node"); $_f = new PhingFile($basepath, $path); if (!$_f->exists()) { $this->log("\t\t-> " . $table->getPhpName() . "Node"); $generator->parse("om/{$targetPlatform}/ExtensionNode.tpl", $path); } else { $this->log("\t\t-> (exists) " . $table->getPhpName() . "Node"); } } // Create [empty] interface if it does not already exist if ($table->getInterface()) { $path = ClassTools::getFilePath($table->getInterface()); $_f = new PhingFile($basepath, $path); if (!$_f->exists()) { $_dir = new PhingFile(dirname($_f->getAbsolutePath())); $_dir->mkdirs(); $this->log("\t\t-> " . $table->getInterface()); $generator->parse("om/{$targetPlatform}/Interface.tpl", $path); } else { $this->log("\t\t-> (exists) " . $table->getInterface()); } } // If table has enumerated children (uses inheritance) then create the empty child stub classes // if they don't already exist. if ($table->getChildrenColumn()) { $col = $table->getChildrenColumn(); if ($col->isEnumeratedClasses()) { foreach ($col->getChildren() as $child) { $childpkg = $child->getPackage() ? $child->getPackage() : $package; $generator->put("child", $child); $generator->put("package", $childpkg); $path = ClassTools::getFilePath($childpkg, $child->getClassName()); $_f = new PhingFile($basepath, $path); if (!$_f->exists()) { $this->log("\t\t-> " . $child->getClassName()); $generator->parse("om/{$targetPlatform}/MultiExtendObject.tpl", $path); } else { $this->log("\t\t-> (exists) " . $child->getClassName()); } } // foreach } // if col->is enumerated } // if tbl->getChildrenCol } // if !$table->isForReferenceOnly() } // foreach table } // foreach database } // foreach dataModel }
/** * Adds class phpdoc comment and openning of class. * @param string &$script The script will be modified in this method. */ protected function addClassOpen(&$script) { $table = $this->getTable(); $tableName = $table->getName(); $tableDesc = $table->getDescription(); $interface = $this->getInterface(); $script .= "\r\n/**\r\n * Base class that represents a row from the '{$tableName}' table.\r\n *\r\n * {$tableDesc}\r\n *"; if ($this->getBuildProperty('addTimeStamp')) { $now = strftime('%c'); $script .= "\r\n * This class was autogenerated by Propel " . $this->getBuildProperty('version') . " on:\r\n *\r\n * {$now}\r\n *"; } $script .= "\r\n * @package " . $this->getPackage() . "\r\n */\r\nabstract class " . $this->getClassname() . " extends " . ClassTools::classname($this->getBaseClass()) . " "; $interface = ClassTools::getInterface($table); if ($interface) { $script .= " implements " . ClassTools::classname($interface); } $script .= " {\r\n\r\n"; }
protected function addClassClose(&$script) { parent::addClassClose($script); $behaviors = $this->getTable()->getAttribute('behaviors'); if ($behaviors) { $behavior_file_name = 'Base' . $this->getTable()->getPhpName() . 'Behaviors'; $behavior_file_path = ClassTools::getFilePath($this->getStubObjectBuilder()->getPackage() . '.om', $behavior_file_name); $script .= sprintf("\ninclude_once '%s';\n", $behavior_file_path); } }
/** * The main method does the work of the task. */ public function main() { // Check to make sure the input and output files were specified and that the input file exists. if (!$this->xmlConfFile || !$this->xmlConfFile->exists()) { throw new BuildException("No valid xmlConfFile specified.", $this->getLocation()); } if (!$this->outputFile) { throw new BuildException("No outputFile specified.", $this->getLocation()); } if (!$this->outputClassmapFile) { // We'll create a default one for BC $this->outputClassmapFile = 'classmap-' . $this->outputFile; } // Create a PHP array from the XML file $xmlDom = new DOMDocument(); $xmlDom->load($this->xmlConfFile->getAbsolutePath()); $xml = simplexml_load_string($xmlDom->saveXML()); $phpconf = self::simpleXmlToArray($xml); $phpconfClassmap = array(); // $this->log(var_export($phpconf,true)); // Create a map of all PHP classes and their filepaths for this data model $generatorConfig = $this->getGeneratorConfig(); foreach ($this->getDataModels() as $dataModel) { foreach ($dataModel->getDatabases() as $database) { $classMap = array(); // $this->log("Processing class mappings in database: " . $database->getName()); //print the tables foreach ($database->getTables() as $table) { if (!$table->isForReferenceOnly()) { // $this->log("\t+ " . $table->getName()); // Classes that I'm assuming do not need to be mapped (because they will be required by subclasses): // - base peer and object classes // - interfaces // - base node peer and object classes // ----------------------------------------------------------------------------------------- // Add Peer & Object stub classes and MapBuilder classes // ----------------------------------------------------------------------------------------- // (this code is based on PropelOMTask) foreach (array('mapbuilder', 'peerstub', 'objectstub') as $target) { $builder = $generatorConfig->getConfiguredBuilder($table, $target); $this->log("Adding class mapping: " . $builder->getClassname() . ' => ' . $builder->getClassFilePath()); $classMap[$builder->getClassname()] = $builder->getClassFilePath(); } if ($table->getChildrenColumn()) { $col = $table->getChildrenColumn(); if ($col->isEnumeratedClasses()) { foreach ($col->getChildren() as $child) { $builder = $generatorConfig->getConfiguredBuilder($table, 'objectmultiextend'); $builder->setChild($child); $this->log("Adding class mapping: " . $builder->getClassname() . ' => ' . $builder->getClassFilePath()); $classMap[$builder->getClassname()] = $builder->getClassFilePath(); } } } $baseClass = $table->getBaseClass(); if ($baseClass !== null) { $className = ClassTools::classname($baseClass); if (!isset($classMap[$className])) { $classPath = ClassTools::getFilePath($baseClass); $this->log('Adding class mapping: ' . $className . ' => ' . $classPath); $classMap[$className] = $classPath; } } $basePeer = $table->getBasePeer(); if ($basePeer !== null) { $className = ClassTools::classname($basePeer); if (!isset($classMap[$className])) { $classPath = ClassTools::getFilePath($basePeer); $this->log('Adding class mapping: ' . $className . ' => ' . $classPath); $classMap[$className] = $classPath; } } // ----------------------------------------------------------------------------------------- // Create tree Node classes // ----------------------------------------------------------------------------------------- if ('MaterializedPath' == $table->treeMode()) { foreach (array('nodepeerstub', 'nodestub') as $target) { $builder = $generatorConfig->getConfiguredBuilder($table, $target); $this->log("Adding class mapping: " . $builder->getClassname() . ' => ' . $builder->getClassFilePath()); $classMap[$builder->getClassname()] = $builder->getClassFilePath(); } } // if Table->treeMode() == 'MaterializedPath' } // if (!$table->isReferenceOnly()) } $phpconfClassmap['propel']['datasources'][$database->getName()]['classes'] = $classMap; } } // $phpconf['propel']['classes'] = $classMap; $phpconf['propel']['generator_version'] = $this->getGeneratorConfig()->getBuildProperty('version'); // Write resulting PHP data to output file: $outfile = new PhingFile($this->outputDirectory, $this->outputFile); $output = '<' . '?' . "php\n"; $output .= "// This file generated by Propel " . $phpconf['propel']['generator_version'] . " convert-props target" . ($this->getGeneratorConfig()->getBuildProperty('addTimestamp') ? " on " . strftime("%c") : '') . "\n"; $output .= "// from XML runtime conf file " . $this->xmlConfFile->getPath() . "\n"; $output .= "return array_merge_recursive("; $output .= var_export($phpconf, true); $output .= ", include(dirname(__FILE__) . DIRECTORY_SEPARATOR . '" . $this->outputClassmapFile . "'));"; $this->log("Creating PHP runtime conf file: " . $outfile->getPath()); if (!file_put_contents($outfile->getAbsolutePath(), $output)) { throw new BuildException("Error creating output file: " . $outfile->getAbsolutePath(), $this->getLocation()); } $outfile = new PhingFile($this->outputDirectory, $this->outputClassmapFile); $output = '<' . '?' . "php\n"; $output .= "// This file generated by Propel " . $phpconf['propel']['generator_version'] . " convert-props target" . ($this->getGeneratorConfig()->getBuildProperty('addTimestamp') ? " on " . strftime("%c") : '') . "\n"; $output .= "return "; $output .= var_export($phpconfClassmap, true); $output .= ";"; $this->log("Creating PHP classmap runtime file: " . $outfile->getPath()); if (!file_put_contents($outfile->getAbsolutePath(), $output)) { throw new BuildException("Error creating output file: " . $outfile->getAbsolutePath(), $this->getLocation()); } }
/** * Lists data model classes and builds an associative array className => classPath * To be used for autoloading * @return array */ protected function getClassMap() { $phpconfClassmap = array(); $generatorConfig = $this->getGeneratorConfig(); foreach ($this->getDataModels() as $dataModel) { foreach ($dataModel->getDatabases() as $database) { $classMap = array(); foreach ($database->getTables() as $table) { if (!$table->isForReferenceOnly()) { // Classes that I'm assuming do not need to be mapped (because they will be required by subclasses): // - base peer and object classes // - interfaces // - base node peer and object classes // ----------------------------------------------------- // Add Peer & Object stub classes and MapBuilder classes // ----------------------------------------------------- // (this code is based on PropelOMTask) foreach (array('tablemap', 'peerstub', 'objectstub') as $target) { $builder = $generatorConfig->getConfiguredBuilder($table, $target); $this->log("Adding class mapping: " . $builder->getClassname() . ' => ' . $builder->getClassFilePath()); $classMap[$builder->getClassname()] = $builder->getClassFilePath(); } if ($col = $table->getChildrenColumn()) { if ($col->isEnumeratedClasses()) { foreach ($col->getChildren() as $child) { $builder = $generatorConfig->getConfiguredBuilder($table, 'objectmultiextend'); $builder->setChild($child); $this->log("Adding class mapping: " . $builder->getClassname() . ' => ' . $builder->getClassFilePath()); $classMap[$builder->getClassname()] = $builder->getClassFilePath(); } } } $baseClass = $table->getBaseClass(); if ($baseClass !== null) { $className = ClassTools::classname($baseClass); if (!isset($classMap[$className])) { $classPath = ClassTools::getFilePath($baseClass); $this->log('Adding class mapping: ' . $className . ' => ' . $classPath); $classMap[$className] = $classPath; } } $basePeer = $table->getBasePeer(); if ($basePeer !== null) { $className = ClassTools::classname($basePeer); if (!isset($classMap[$className])) { $classPath = ClassTools::getFilePath($basePeer); $this->log('Adding class mapping: ' . $className . ' => ' . $classPath); $classMap[$className] = $classPath; } } // ------------------------ // Create tree Node classes // ------------------------ if ('MaterializedPath' == $table->treeMode()) { foreach (array('nodepeerstub', 'nodestub') as $target) { $builder = $generatorConfig->getConfiguredBuilder($table, $target); $this->log("Adding class mapping: " . $builder->getClassname() . ' => ' . $builder->getClassFilePath()); $classMap[$builder->getClassname()] = $builder->getClassFilePath(); } } } // if (!$table->isReferenceOnly()) } $phpconfClassmap = array_merge($phpconfClassmap, $classMap); } } return $phpconfClassmap; }
protected function edit() { // ladowanie klasy $item = new ClassTrainingCenter(ClassTools::getValue('id_training_centre')); // sprawdza czy klasa zostala poprawnie zaladowana if (!$item->load_class) { $this->alerts['danger'] = "Centrum szkolenia nie istnieje."; return; } $active = ClassTools::getValue('form_active'); $item->name = ClassTools::getValue('form_name'); $item->location = ClassTools::getValue('form_location'); $item->id_user = ClassAuth::getCurrentUserId(); $item->active = $active && $active == '1' ? '1' : '0'; // komunikaty bledu if (!$item->update()) { $this->alerts['danger'] = $item->errors; return; } // komunikat $this->alerts['success'] = "Poprawnie zaktualizowano centrum szkolenia: <b>{$item->name}</b>"; // czyszczeie zmiennych wyswietlania $this->tpl_values = ''; $_POST = array(); return; }
protected function delete() { // ladowanie klasy $item = new ClassSoldierRank(ClassTools::getValue('id_rank')); $item->id_soldier = ClassTools::getValue('id_soldier'); // sprawdza czy klasa zostala poprawnie zaladowana if ($item->load_class) { // usuwanie if ($item->delete()) { // komunikat $this->alerts['success'] = "Poprawnie usunięto stopień wojskowy: <b>{$item->name}</b>."; return; } else { // bledy w przypadku problemow z usunieciem $this->alerts['danger'] = $item->errors; return; } } $this->alerts['danger'] = 'Stopień wojskowy nie istnieje.'; $_POST = array(); return; }
protected function edit() { // ladowanie klasy $item = new ClassMissionType(ClassTools::getValue('id_mission_type')); // sprawdza czy klasa zostala poprawnie zaladowana if (!$item->load_class) { $this->alerts['danger'] = "Rodzaj misji nie istnieje."; return; } $active = ClassTools::getValue('form_active'); $form_parent = ClassTools::getValue('form_parent'); $item->name = ClassTools::getValue('form_name'); $item->id_parent = $form_parent != '' && is_numeric($form_parent) ? $form_parent : NULL; $item->id_user = ClassAuth::getCurrentUserId(); $item->active = $active && $active == '1' ? '1' : '0'; // komunikaty bledu if (!$item->update()) { $this->alerts['danger'] = $item->errors; return; } // komunikat $this->alerts['success'] = "Poprawnie zaktualizowano rodzaj misji: <b>{$item->name}</b>"; // czyszczeie zmiennych wyswietlania $this->tpl_values = ''; $_POST = array(); return; }
/** * Returns the path to the current model's behaviors configuration file. * * @param boolean $absolute * * @return string */ protected function getBehaviorsFilePath($absolute = false) { $base = $absolute ? sfConfig::get('sf_root_dir') . DIRECTORY_SEPARATOR : ''; return $base . ClassTools::getFilePath($this->getTable()->getPackage() . '.om', sprintf('Base%sBehaviors', $this->getTable()->getPhpName())); }
public static function sqlGetCountItems($controller_search = '', array $custom_where = array()) { global $DB; $table_name = (static::$use_prefix ? static::$prefix : '') . static::$definition['table']; $where = ''; if (static::$has_deleted_column) { $where = " WHERE `deleted` = '0'"; } if (static::$is_search && $controller_search != '' && ($where_search = self::generateWhereList($controller_search))) { if ($where == '') { $where = "WHERE "; } else { $where .= " AND "; } $where .= $where_search; } if (count($custom_where) > 0) { if ($where == '') { $where = "WHERE "; } else { $where .= " AND "; } $first = true; foreach ($custom_where as $key => $value) { if ($first) { $first = false; $where .= "`{$key}` = '" . ClassTools::pSQL($value) . "'"; } else { $where .= " AND `{$key}` = '" . ClassTools::pSQL($value) . "'"; } } } $zapytanie = "SELECT COUNT(*) as count_items\n FROM `{$table_name}`\n {$where}\n ;"; $sql = $DB->pdo_fetch($zapytanie, true); if (($sql === false || !is_array($sql)) && (static::$is_search && $controller_search != '' && isset($_SESSION['search'][$controller_search]))) { if (static::$is_search && isset($_SESSION['search'][$controller_search])) { $_SESSION['search'][$controller_search] = array(); } } if (!$sql || !is_array($sql) || count($sql) < 1) { return false; } return $sql['count_items']; }
/** * Adds class phpdoc comment and openning of class. * @param string &$script The script will be modified in this method. */ protected function addClassOpen(&$script) { $table = $this->getTable(); $tableName = $table->getName(); $tableDesc = $table->getDescription(); $interface = $this->getInterface(); $parentClass = $this->getBehaviorContent('parentClass'); $parentClass = null !== $parentClass ? $parentClass : ClassTools::classname($this->getBaseClass()); $script .= "\n/**\n * Base class that represents a row from the '{$tableName}' table.\n *\n * {$tableDesc}\n *"; if ($this->getBuildProperty('addTimeStamp')) { $now = strftime('%c'); $script .= "\n * This class was autogenerated by Propel " . $this->getBuildProperty('version') . " on:\n *\n * {$now}\n *"; } $script .= "\n * @package propel.generator." . $this->getPackage() . "\n */\nabstract class " . $this->getClassname() . " extends " . $parentClass . " "; $interface = ClassTools::getInterface($table); if ($interface) { $script .= " implements " . ClassTools::classname($interface); } if ($this->getTable()->getInterface()) { $this->declareClassFromBuilder($this->getInterfaceBuilder()); } $script .= "\n{\n"; }
/** * Gets the file path to the parent class. * @return string */ protected function getParentClassFilePath() { return ClassTools::getFilePath($this->getParentClasspath()); }
/** * Returns classname of parent class. * @return string */ protected function getParentClassname() { return ClassTools::classname($this->getParentClasspath()); }
/** * Gets the full path to the file for the current class. * @return string */ public function getClassFilePath() { return ClassTools::getFilePath($this->getPackage(), $this->getClassname()); }
protected function addClassClose(&$script) { parent::addClassClose($script); $behaviors = $this->getTable()->getAttribute('behaviors'); if ($behaviors) { $behavior_file_name = 'Base' . $this->getTable()->getPhpName() . 'Behaviors'; $behavior_file_path = ClassTools::getFilePath($this->getStubObjectBuilder()->getPackage() . '.om', $behavior_file_name); $behavior_include_script = <<<EOF if (sfProjectConfiguration::getActive() instanceof sfApplicationConfiguration) { include_once '%s'; } EOF; $script .= sprintf($behavior_include_script, $behavior_file_path); } }
protected function edit() { // ladowanie klasy $item = new ClassMilitaryType(ClassTools::getValue('id_military_type')); // sprawdza czy klasa zostala poprawnie zaladowana if (!$item->load_class) { $this->alerts['danger'] = 'Rodzaj jednoski wojskowej nie istnieje'; return; } $active = ClassTools::getValue('form_active'); $item->name = ClassTools::getValue('form_name'); $item->id_user = ClassAuth::getCurrentUserId(); $item->active = $active && $active == '1' ? '1' : '0'; // komunikaty bledu if (!$item->update()) { $this->alerts['danger'] = $item->errors; return; } // komunikat $this->alerts['success'] = "Poprawnie zaktualizowano rodzaj jednoski wojskowej: <b>" . htmlspecialchars($item->name) . "</b>"; // czyszczeie zmiennych wyswietlania $this->tpl_values = ''; $_POST = array(); return; }
/** * Adds class phpdoc comment and openning of class. * @param string &$script The script will be modified in this method. */ protected function addClassOpen(&$script) { $table = $this->getTable(); $tableName = $table->getName(); $tableDesc = $table->getDescription(); $interface = $this->getInterface(); $script .= " /** * Base class that represents a row from the '$tableName' table. * * $tableDesc *"; if ($this->getBuildProperty('addTimeStamp')) { $now = strftime('%c'); $script .= " * This class was autogenerated by Propel on: * * $now *"; } $script .= " * @package ".$this->getPackage()." */ abstract class ".$this->getClassname()." extends ".ClassTools::classname($this->getBaseClass())." "; $interface = ClassTools::getInterface($table); if ($interface) { $script .= " implements " . ClassTools::classname($interface); } $script .= " { "; }
/** * Returns the name of the current class being built. * @return string */ public function getUnprefixedClassname() { return ClassTools::classname($this->getInterface()); }
protected function edit() { // ladowanie klasy $item = new ClassSoldier(ClassTools::getValue('id_soldier')); // sprawdza czy klasa zostala poprawnie zaladowana if (!$item->load_class) { $this->alerts['danger'] = "Żołnierz nie istnieje."; } $form_height = ClassTools::getValue('form_height'); $form_weight = ClassTools::getValue('form_weight'); $form_shoe_number = ClassTools::getValue('form_shoe_number'); $item->sex = ClassTools::getValue('form_sex'); $item->name = ClassTools::getValue('form_name'); $item->second_name = ClassTools::getValue('form_second_name'); $item->surname = ClassTools::getValue('form_surname'); $item->date_birthday = ClassTools::getValue('form_date_birthday'); $item->place_birthday = ClassTools::getValue('form_place_birthday'); $item->citizenship = ClassTools::getValue('form_citizenship'); $item->nationality = ClassTools::getValue('form_nationality'); $item->pesel = ClassTools::getValue('form_pesel'); $item->identity_document = ClassTools::getValue('form_identity_document'); $item->mail = ClassTools::getValue('form_mail'); $item->phone = ClassTools::getValue('form_phone'); $item->height = $form_height != '' && $form_height != '0' ? $form_height : NULL; $item->weight = $form_weight != '' && $form_weight != '0' ? $form_weight : NULL; $item->shoe_number = $form_shoe_number != '' && $form_shoe_number != '0' ? $form_shoe_number : NULL; $item->blood_group = ClassTools::getValue('form_blood_group'); $item->name_mother = ClassTools::getValue('form_name_mother'); $item->surname_mother = ClassTools::getValue('form_surname_mother'); $item->name_father = ClassTools::getValue('form_name_father'); $item->surname_father = ClassTools::getValue('form_surname_father'); $item->name_partner = ClassTools::getValue('form_name_partner'); $item->surname_partner = ClassTools::getValue('form_surname_partner'); $item->id_education_type = ClassTools::getValue('form_education_type'); $item->wku = ClassTools::getValue('form_wku'); $item->health_category = ClassTools::getValue('form_health_category'); $item->id_military = ClassTools::getValue('form_military'); $item->injuries = ClassTools::getValue('form_injuries'); $item->id_status = ClassTools::getValue('form_status'); $item->id_user = ClassAuth::getCurrentUserId(); // komunikaty bledu if (!$item->update()) { $this->alerts['danger'] = $item->errors; return; } // komunikat $this->alerts['success'] = "Poprawnie zaktualizowano żołnierza: <b>{$item->name} {$item->surname}</b>"; // czyszczeie zmiennych wyswietlania $this->tpl_values = ''; $_POST = array(); return; }