I never really had the time to continue this project from 2008: http://cakephp.dereuromark.de/
so I guess this would be the change to make it open source and let someone who is interested in it work on it. the idea was to use actual cakephp code to display examples and live cakephp modules (plugins, components, helpers, libs, ...) and how they work. for your conventions request above I propose a plugin with a conventions controller doing exactly that: I created the files: http://cakephp.dereuromark.de/sandbox/conventions //TODO => simple form + conventions results ... more to come? PS: after upgrading to 1.3.3 the rest of the site is quite messed up and probably not very useful anymore anyway :) write me an email if you want to contribute (functionality, sandbox features, other layout, ...). cheers mark On 23 Jul., 01:55, LunarDraco <[email protected]> wrote: > Not sure the rules on pasting code here but my weekend is starting for > me and wanted to post what I had. A few function are incomplete but I > think its a good start. > Try something like > cake inflect core events_contacts > Watch the detail about the warnings and suggestions. > enjoy! > > file vendors/shells/inflect.php > > <?php > App::import('Core',array('Folder')); > class InflectShell extends Shell > { > var $tasks = array(); > var $uses = array(); > > function startup() { > $this->hr('='); > $this->out('Cake Inflect shows the various Inflections used > for the > given input.'); > $this->hr(); > if(empty($this->args[0])){ > $this->help(); > exit(); > } > } > //TODO add named parameters for controller:Cakes table:cakes > model:Cake action:getCake > //to see how things should be mapped when not following the > standards. > > function help() { > $this->hr('+'); > $this->out('CakePHP Inflect:'); > $this->hr(); > $this->out('The Inflect console script shows all the various > inflections given an input based'); > $this->out('on the defined cake standards. The input can be in > various formats: singular, plural,'); > $this->out('lower_underscored, CamelCase functionCase etc.'); > $this->hr(); > $this->out("Usage: cake inflect [InputType] word > [TypesForCustom]"); > $this->hr(); > $this->out('Show a summary of all possible inflections for > the given > word as InputType.'); > $this->out("InputType when not given defaults to 'core'"); > $this->out('InputType can be one of:'); > $this->out(' all - includes core, component, behavior, > helper'); > $this->out(' core - (default) includes table, model, > controller, > action'); > $this->out(' custom - allows list of inputs after word like > model > controller'); > $this->out(' table'); > $this->out(' model'); > $this->out(' controller'); > $this->out(' action'); > $this->out(' component'); > $this->out(' behavior'); > $this->out(' helper'); > $this->out(' cakeclass'); > $this->out('word - the word to analyze try people, person, > ContactsEvents, EventsContacts, etc.'); > $this->hr(); > $this->out('ex: cake inflect core people'); > $this->hr(); > } > > function main() > { > $this->core(); > } > > function all(){ > $this->core(); > $this->behavior(); > $this->component(); > $this->helper(); > $this->cakeclass(); > } > > function core(){ > $this->table(); > $this->model(); > $this->controller(); > $this->action(); > } > > function custom(){ > if(!empty($this->args[1])){ > $argcount = count($this->args)-1; > for($i = 1; $i <= $argcount; $i++) > { > $function = $this->args[$i]; > $this->$function(); > } > } else { > $this->core(); > } > } > > function table($input = null) > { > if(empty($input)){ > $input = $this->args[0]; > } > $this->hr('='); > $this->out('=== '.$input.' as a Table'); > $this->hr('='); > $singular = Inflector::singularize($input); > $plural = Inflector::pluralize($input); > if($singular == $input){ > $this->out($input.' is Singular note table name is > pluralized.'); > $this->hr(); > } > $tablename = Inflector::tableize(Inflector::camelize($input)); > $this->out('Table Name: '.$tablename); > $this->out('FK Pattern: > '.Inflector::singularize($tablename).'_id'); > $this->hr(); > $this->out('Model Class Name: > '.Inflector::classify($singular)); > $this->out('Controller Class Name: > '.Inflector::camelize($plural).'Controller'); > $words = > explode('_',Inflector::tableize(Inflector::camelize($input))); > $pluralCount = 0; > $tables = array(); > foreach($words as $table){ > > if(empty($tables[$pluralCount])){ > $tables[$pluralCount] = $table; > } else { > $tables[$pluralCount] = > $tables[$pluralCount].'_'.$table; > } > //TODO Add code to convert form of each word to and > from single and > plural for Condition of FreindsPeople > if(Inflector::pluralize($table)==$table){ > $pluralCount += 1; > } > } > if($pluralCount>1){ > //TODO check for alphebetical order of table names. > sort($tables); > $jointable = ''; > foreach($tables as $joinname){ > if(empty($jointable)){ > $jointable = $joinname; > }else{ > $jointable = $jointable.'_'.$joinname; > } > } > $this->hr(); > if($jointable !== $tablename){ > $this->out('WARNING! '.$tablename.' appears > to be a mapping > table.'); > $this->out('But the supporting tables are not > alphabetical.'); > $this->out('Suggested format: '.$jointable.' > for join or mapping > of tables:'); > }else{ > $this->out($tablename.' appears to be a > mapping or join table for > tables:'); > } > // the sort leaves empty elements in the array. > foreach($tables as $tablename){ > if(strlen(trim($tablename))){ > $this->out(" ".trim($tablename)); > //Is this useful or redundant? > //$this->table(trim($tablename)); > } > } > } > $this->hr(); > $this->out("\n"); > } > > function model() > { > $input = $this->args[0]; > $this->hr('='); > $this->out('=== '.$input.' as a Model'); > $this->hr('='); > $singular = Inflector::singularize($input); > $plural = Inflector::pluralize($input); > if($plural == $input){ > $this->out($input.' is Plural note model is > singular.'); > $this->hr(); > } > $path = Inflector::underscore($singular); > $this->out('Model Class Name: '. > Inflector::classify($singular)); > $this->out('Model Path: '. > $this->params['working'].DS.'models'.DS); > > $this->out('Model File: '.$path.'.php'); > $this->hr(); > $this->out('Table: '. > Inflector::tableize(Inflector::camelize($input))); > $this->out('Controller Class Name: > '.Inflector::camelize($plural).'Controller'); > $this->hr(); > $this->out("\n"); > } > > function controller() > { > $input = $this->args[0]; > $this->hr('='); > $this->out('=== '.$input.' as a Controller'); > $this->hr('='); > $singular = Inflector::singularize($input); > $plural = Inflector::pluralize($input); > if($singular == $input){ > $this->out($input.' is singular note Controller is > plural.'); > $this->hr(); > } > $path = Inflector::underscore($plural); > $this->out('Controller Class Name: > '.Inflector::camelize($plural).'Controller'); > $this->out('Controller Path: ' > .$this->params['working'].DS.'controllers'.DS); > > $this->out('Controller File: '.$path.'.php'); > $this->hr(); > $this->out('Model Class Name: '. > Inflector::classify($singular)); > $this->out('Table: '. > Inflector::tableize(Inflector::camelize($input))); > $this->out('View File Path: > '.$this->params['working'].DS.'views'.DS.$path.DS); > > $this->hr(); > $this->out("\n"); > } > > function action() > { > $input = $this->args[0]; > $this->hr('='); > $this->out($input.' as a Controller Action for mock > CakesController'); > $this->hr('='); > $variable = Inflector::variable($input); > if($variable !== $input){ > $this->out($input.' is not the correct format for a > Controller > function note function name below.'); > $this->hr(); > } > $this->out('Controller function: '.$variable.'()'); > $this->out('View File Path: > '.$this->params['working'].DS.'views'.DS.'cakes'.DS.Inflector::underscore($variable > ).'.ctp'); > > $this->hr(); > $this->out("\n"); > } > > function component() > { > $input = $this->args[0]; > $this->hr('='); > $this->out($input.' as a Component'); > $this->hr(); > $this->out("\n"); > } > > function behavior() > { > $input = $this->args[0]; > $this->hr('='); > $this->out($input.' as a Behavior'); > $this->hr(); > $this->out("\n"); > } > > function helper() > { > $input = $this->args[0]; > $this->hr('='); > $this->out($input.' as a Helper'); > $this->hr(); > $this->out("\n"); > } > > function cakeclass() > { > $input = $this->args[0]; > $this->hr('='); > $this->out('=== '.$input.' as a class'); > $this->hr('='); > $this->out('Controller'); > $this->out('Component'); > $this->out('Model'); > $this->out('Behavior'); > $this->out('View'); > $this->out('Helper'); > > $this->hr(); > $this->out("\n"); > } > > function hr($char = '-',$newline = false) { > if ($newline) { > $this->out("\n"); > } > $strline = str_repeat ( $char,74 ); > $this->out($strline); > if ($newline) { > $this->out("\n"); > } > }} > > ?> Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
