Permalink
Browse files

reverted back to r173

git-svn-id: https://gii-template-collection.googlecode.com/svn/trunk/gtc@182 fa601203-8fba-3265-82bf-2153ca8df311
  • Loading branch information...
1 parent a26ba15 commit ba60f5f54472e9aadc428a63c8f5766422eeffdc schmunk@usrbin.de committed Aug 30, 2011
Showing with 1,733 additions and 441 deletions.
  1. +169 −0 class/ClassCode.php
  2. +7 −0 class/ClassGenerator.php
  3. +32 −0 class/templates/copyrighted/copyright.php
  4. +13 −0 class/templates/copyrighted/php5class.php
  5. +13 −0 class/templates/default/php5class.php
  6. +41 −0 class/views/__class.php
  7. +6 −0 class/views/__comment.php
  8. +23 −0 class/views/__infos.php
  9. +33 −0 class/views/__methods.php
  10. +1 −0 class/views/__properties.php
  11. +18 −0 class/views/form.php
  12. +27 −0 class/views/index.php
  13. +64 −0 class/widgets/XMarkDownReferenceLink.php
  14. +110 −0 command/CommandCode.php
  15. +21 −0 command/CommandGenerator.php
  16. +23 −0 command/templates/copyrighted/command.php
  17. +26 −0 command/templates/copyrighted/copyright.php
  18. +23 −0 command/templates/default/command.php
  19. +28 −0 command/views/__class.php
  20. +13 −0 command/views/__comment.php
  21. +3 −0 command/views/__infos.php
  22. +20 −0 command/views/index.php
  23. +64 −0 command/widgets/XMarkDownReferenceLink.php
  24. +66 −0 components/GController.php
  25. +1 −1 controller/templates/copyrighted/controller.php
  26. +0 −183 fullCrud/CodeProvider.php
  27. +165 −10 fullCrud/FullCrudCode.php
  28. +7 −9 fullCrud/FullCrudGenerator.php
  29. +53 −0 fullCrud/providers/FullCrudFieldProvider.php
  30. +0 −19 fullCrud/providers/datefield.php
  31. +11 −15 fullCrud/templates/default/_form.php
  32. +44 −0 fullCrud/templates/default/_miniform.php
  33. +1 −1 fullCrud/templates/default/_search.php
  34. +41 −6 fullCrud/templates/default/admin.php
  35. +27 −0 fullCrud/templates/default/auth/auth_filter_default.php
  36. +23 −0 fullCrud/templates/default/auth/auth_filter_strict.php
  37. +4 −0 fullCrud/templates/default/auth/auth_none.php
  38. +27 −0 fullCrud/templates/default/auth/auth_yum.php
  39. +19 −47 fullCrud/templates/default/controller.php
  40. +6 −0 fullCrud/templates/default/success.php
  41. +24 −17 fullCrud/templates/default/view.php
  42. +79 −52 fullCrud/views/crud.php
  43. +13 −10 fullCrud/views/index.php
  44. +7 −5 fullCrud/views/info.php
  45. +37 −0 model/templates/copyrighted/copyright.php
  46. +114 −0 model/templates/copyrighted/model.php
  47. +86 −32 portlet/PortletCode.php
  48. +26 −0 portlet/templates/copyrighted/copyright.php
  49. +10 −0 portlet/templates/copyrighted/portlet.php
  50. +2 −1 portlet/templates/default/portlet.php
  51. +28 −0 portlet/views/__class.php
  52. +13 −0 portlet/views/__comment.php
  53. +3 −0 portlet/views/__infos.php
  54. +18 −33 portlet/views/index.php
View
@@ -0,0 +1,169 @@
+<?php
+class ClassCode extends CCodeModel
+{
+ public $className;
+ public $baseClass='CComponent';
+ public $scriptPath='application.components';
+ public $isAbstract=false;
+ public $interfaceName;
+ public $comment;
+ public $md_comment; // comment after mardown parse
+
+ public $propertyName;
+ public $commentProperty;
+ public $propertyGetter;
+ public $propertySetter;
+ public $propertyScope;
+ public $subject2;
+
+ public $codeBody;
+ public $magicMethods;
+
+ public function rules()
+ {
+ return array_merge(parent::rules(), array(
+ array('className, scriptPath', 'required'),
+ array('className', 'match', 'pattern'=>'/^\w+$/'),
+ array('baseClass', 'match', 'pattern'=>'/^\w+$/', 'message'=>'{attribute} should only contain word characters.'),
+ array('baseClass', 'sticky'),
+ array('scriptPath', 'validateScriptPath'),
+ array('scriptPath', 'sticky'),
+ array('isAbstract', 'boolean'),
+ array('isAbstract', 'boolean'),
+ array('comment,interfaceName,magicMethods,codeBody', 'safe'),
+ ));
+ }
+
+ public function attributeLabels()
+ {
+ return array_merge(parent::attributeLabels(), array(
+ 'className'=>'Class',
+ 'baseClass'=>'extends',
+ 'interfaceName'=>'implements',
+ 'comment'=>'class-level DocBlock for your component',
+ 'scriptPath'=>'Script Path',
+ 'isAbstract'=>'The class is abstract.',
+ 'codeBody'=>'Your codelines after the magic methods',
+ ));
+ }
+
+ public function validateScriptPath($attribute,$params)
+ {
+ if($this->hasErrors('scriptPath'))
+ return;
+ if(Yii::getPathOfAlias($this->scriptPath)===false)
+ $this->addError('scriptPath','Script Path must be a valid path alias.');
+ }
+
+ public function prepare()
+ {
+ $path=Yii::getPathOfAlias($this->scriptPath).'/' . ucfirst($this->className) . '.php';
+ $code=$this->render($this->templatepath.'/php5class.php');
+ $this->files[]=new CCodeFile($path, $code);
+ }
+
+ public function getPhpInfo()
+ {
+ ob_start();
+ phpinfo();
+ $info = ob_get_contents();
+ ob_end_clean();
+ return preg_replace('%^.*<body>(.*)</body>.*$%ms', '$1', $info);
+ }
+
+ public function renderSelection($field,$style,$data,$htmlOptions=array()) {
+ if(strcasecmp($style, "selectbox") == 0)
+ echo CHtml::ActiveDropDownList(
+ $this,
+ $field,
+ $data,
+ $this);
+ else if(strcasecmp($style, "listbox") == 0)
+ echo CHtml::ActiveListBox(
+ $this,
+ $field,
+ $data,
+ $htmlOptions);
+ else if(strcasecmp($style, "checkbox") == 0)
+ echo CHtml::ActiveCheckBoxList(
+ $this,
+ $field,
+ $data,
+ $htmlOptions);
+ }
+
+ /**
+ * Prepares comment before performing validation.
+ */
+ protected function beforeValidate()
+ {
+ $parser= new CMarkdownParser;
+ $this->md_comment = $parser->transform($this->comment);
+ return true;
+ }
+
+ /**
+ * Logs a message.
+ *
+ * @param string $message Message to be logged
+ * @param string $level Level of the message (e.g. 'trace', 'warning',
+ * 'error', 'info', see CLogger constants definitions)
+ */
+ protected static function log($message, $level='error')
+ {
+ Yii::log($message, $level, __CLASS__);
+ }
+
+ /**
+ * Dumps a variable or the object itself in terms of a string.
+ *
+ * @param mixed variable to be dumped
+ */
+ protected static function dump($var='dump-the-object',$highlight=true)
+ {
+ if ($var === 'dump-the-object') {
+ return CVarDumper::dumpAsString($this,$depth=15,$highlight);
+ } else {
+ return CVarDumper::dumpAsString($var,$depth=15,$highlight);
+ }
+ }
+
+ public function startComment()
+ {
+ return "/**\n";
+ }
+
+ public function endComment()
+ {
+ return " */\n";
+ }
+
+ public function renderComment()
+ {
+ if (!$this->comment) return '';
+ $result = $this->startComment();
+ $result .= $this->renderCommentPart($this->md_comment);
+ return $result . $this->endComment();
+ }
+
+ public function renderCommentPart($comment = false)
+ {
+ if ($comment===false)
+ $comment = $this->md_comment;
+ $lines = explode("\n", $comment);
+ $part = '';
+ foreach($lines as $line){
+ $part .= $this->renderCommentLine($line);
+ }
+ return $part;
+ }
+
+ public function renderCommentLine($line = '', $newLine = true)
+ {
+ if (!$line) return '';
+ return ($newLine) ? " * " . $line . "\n"
+ : " * " . $line;
+ }
+
+}
+?>
View
@@ -0,0 +1,7 @@
+<?php
+Yii::setPathOfAlias('ClassGenerator',dirname(__FILE__));
+class ClassGenerator extends CCodeGenerator
+{
+ public $codeModel='ext.gtc.class.ClassCode';
+}
+?>
@@ -0,0 +1,32 @@
+<?php
+function param($name)
+{
+ return Yii::app()->params[$name];
+}
+echo '<?php'."\n";
+?>
+/**
+ * <?php echo $this->className; ?> class file.
+ *
+<?php
+$author_email = (param('author-email'))
+ ? ' <'.param('author-email').">\n"
+ : "\n";;
+if (param('author')) echo ' * @author '.param('author').$author_email;
+if (param('link')) echo ' * @link '.param('link')."\n";
+if (param('copyright')) echo ' * @copyright Copyright &copy; '.param('copyright')."\n";
+if (param('license')) echo ' * @license '.param('license')."\n";
+?>
+ */
+
+/**
+<?php echo $this->renderCommentPart(); ?>
+ *
+<?php
+if (param('author')) echo ' * @author '.param('author').$author_email;
+if (param('version'))echo ' * @version '.param('version')."\n";
+if (param('package')) echo ' * @package '.param('package')."\n";
+if (param('since')) echo ' * @since '.param('since')."\n";
+?>
+ */
+
@@ -0,0 +1,13 @@
+<?php
+include(dirname(__FILE__).'/copyright.php');
+?>
+class <?php echo ucfirst($this->className); ?> extends <?php echo $this->baseClass."\n"; ?>
+{
+ function __construct() {
+ // parent::__construct();
+ }
+
+ function __destruct() {
+ //your code here...
+ }
+}
@@ -0,0 +1,13 @@
+<?php echo "<?php\n"; ?>
+<?php echo $this->renderComment(); ?>
+class <?php echo ucfirst($this->className); ?> extends <?php echo $this->baseClass."\n"; ?>
+{
+ function __construct() {
+ // parent::__construct();
+ }
+
+ function __destruct() {
+ //your code here...
+ }
+
+}
View
@@ -0,0 +1,41 @@
+<div class ="row">
+<?php echo $form->labelEx($model, 'className'); ?>
+ <?php echo $form->textField($model, 'className', array('size' => 65));?>
+ <div class="tooltip">
+ The class name must only contain word characters.
+ </div>
+ <?php echo $form->error($model, 'className');?>
+</div>
+
+<div class="row sticky">
+<?php echo $form->labelEx($model, 'baseClass');?>
+<?php echo $form->textField($model, 'baseClass', array('size' => 65));?>
+<div class="tooltip">
+This is the class that the new class will extend from.
+Please make sure the class exists and can be autoloaded.
+</div>
+<?php echo $form->error($model, 'baseClass');?>
+</div>
+<div class="row">
+ <?php echo $form->labelEx($model, 'interfaceName');?>
+ <?php echo $form->textField($model, 'interfaceName', array('size' => 65));?>
+ <?php echo $form->error($model, 'interfaceName');?>
+<div class="tooltip">
+Name of a object interface
+</div>
+</div>
+<div class="row">
+ <?php echo $form->checkBox($model, 'isAbstract', array('style' => 'margin-right:10px;float:left;'));?>
+ <?php echo $form->labelEx($model, 'isAbstract');?>
+</div>
+
+<div class="row sticky">
+<?php echo $form->labelEx($model, 'scriptPath');?>
+<?php echo $form->textField($model, 'scriptPath', array('size' => 65));?>
+<div class="tooltip">
+This refers to the directory that the new view script file should be generated under.
+It should be specified in the form of a path alias, for example, <code>application.web</code>,
+<code>mymodule.views</code>.
+</div>
+<?php echo $form->error($model, 'scriptPath');?>
+</div>
@@ -0,0 +1,6 @@
+<div class="row">
+<?php echo $form->labelEx($model,'comment'); ?>
+<?php echo $form->textArea($model,'comment',array('rows'=>10, 'cols'=>75)); ?>
+<?php $this->widget('ClassGenerator.widgets.XMarkDownReferenceLink', array()); ?>
+<?php echo $form->error($model,'comment'); ?>
+</div>
View
@@ -0,0 +1,23 @@
+<div style="border:1px solid #CCCCFF;padding:5px;font-size:80%;margin-bottom:12px;">
+The root class of the Yii framework is CComponent.
+<br />CComponent implements the protocol of defining, using properties and events.
+<br /><br />Please use the other generators for Yii-components in the generators menu!
+<br />The class generator have no specific code templates.
+<br />
+</div>
+<div style="border:1px solid #CCCCFF;padding:5px;font-size:80%;margin-bottom:12px;">
+Web resources for this generator:
+<ul style="margin-top:8px">
+<li><a href="http://www.yiiframework.com/doc/api/" target="_blank">Yii Class Reference</a></li>
+<li><a href="http://www.yiiframework.com/doc/guide/basics.namespace" target="_blank">Yii Path Alias and Namespace</a></li>
+<li><a href="http://yiiframework.ru/doc/guide/en/index" target="_blank">The Definitive Guide to Yii</a></li>
+<?php if (strtolower(Yii::app()->language)=='de'): ?>
+<li><a href="http://de2.php.net/manual/de/language.oop5.php" target="_blank">Klassen und Objekte</a></li>
+<?php else: ?>
+<li><a href="http://de2.php.net/manual/en/language.oop5.php" target="_blank">Classes and Objects</a></li>
+<?php endif; ?>
+</ul>
+</div>
+<div style="height:190px;overflow:scroll;border:1px solid #CCCCFF;padding:5px;font-size:80%;margin-bottom:12px;">
+<?php echo $model->getPhpInfo(); ?>
+</div>
View
@@ -0,0 +1,33 @@
+<fieldset>
+<legend>magic methods:</legend>
+<div style="height:80px;width:99%;overflow:scroll;font-size:85%;">
+<?php $model->renderSelection('magicMethods','checkbox',
+ array(
+ '__construct'=>CHtml::link('__construct',
+ 'http://de2.php.net/manual/en/language.oop5.decon.php#language.oop5.decon.constructor'),
+ '__destruct'=>CHtml::link('__destruct',
+ 'http://de2.php.net/manual/en/language.oop5.decon.php#language.oop5.decon.destructor'),
+ '__call'=>CHtml::link('__call','#'),
+ '__callStatic'=>CHtml::link('__callStatic','#'),
+ '__get'=>CHtml::link('__get','#'),
+ '__set'=>CHtml::link('__set','#'),
+ '__isset'=>CHtml::link('__isset','#'),
+ '__unset'=>CHtml::link('__unset','#'),
+ '__sleep'=>CHtml::link('__sleep','#'),
+ '__wakeup'=>CHtml::link('__wakeup','#'),
+ '__toString'=>CHtml::link('__toString','#'),
+ '__invoke'=>CHtml::link('__invoke','#'),
+ '__set_state'=>CHtml::link('__set_state','#'),
+ '__clone'=>CHtml::link('__clone','#'),
+ ),
+ array('style'=>'margin-right:10px;float:left;')
+ );
+?>
+</div>
+</fieldset>
+<fieldset>
+ <div class="row">
+ <?php echo $form->labelEx($model,'codeBody'); ?>
+ <?php echo $form->textArea($model,'codeBody',array('rows'=>15, 'cols'=>70)); ?>
+ </div>
+</fieldset>
@@ -0,0 +1 @@
+
View
@@ -0,0 +1,18 @@
+ <div class="row">
+ <?php echo $form->labelEx($model,'status'); ?>
+ <?php echo $form->dropDownList($model,'status',Lookup::items('PostStatus')); ?>
+ <?php echo $form->error($model,'status'); ?>
+ </div>
+
+At model:
+
+public function getGenderOptions(){
+ return array('M' => 'Male', 'F' => 'Female');
+}
+At view:
+
+<?php echo CHtml::dropDownList('listname', $select,
+ $model->genderOptions,
+ array('empty' => '(Select a gender'));
+
+
Oops, something went wrong.

0 comments on commit ba60f5f

Please sign in to comment.