Joostina CMS / CMF v2.* API
  • Docs
  • Package
  • Class
  • Tree
  • Todo
Overview

Packages

  • Components
    • Acls
      • Models
        • Admin
        • Site
    • BlogCategory
      • Models
        • Admin
        • Site
    • Blogs
      • Controllers
        • Admin
        • Site
      • Helpers
      • Models
        • Admin
        • Site
    • Coder
      • Controllers
        • Admin
      • Models
        • Admin
    • Comments
      • Controllers
        • Admin
        • Site
      • Helpers
      • Models
        • Admin
        • Site
    • CommentsCounter
      • Models
        • Admin
        • Site
    • Mainpage
      • Controllers
        • Site
    • News
      • Controllers
        • Admin
        • Site
      • Helpers
      • Models
        • Admin
        • Site
    • Pages
      • Controllers
        • Admin
        • Site
      • Models
        • Site
    • Search
      • Controllers
        • Site
    • Site
      • Controllers
        • Admin
        • Site
    • Sitemap
      • Controllers
        • Admin
        • Site
      • Models
        • Admin
        • Site
    • Test
      • Controllers
        • Site
    • Torrents
      • Controllers
        • Site
    • Users
      • Controllers
        • Admin
        • Site
      • Models
        • Admin
        • Site
  • Compression
  • Core
    • Libraries
      • Arhive
      • Array
      • Attached
      • Autoadmin
      • Autoloader
      • Benchmark
      • Breadcrumbs
      • Cache
      • Config
      • Cookie
      • Csrf
      • Database
        • Drivers
          • Interfaces
      • Datetime
      • Debug
      • Editor
      • Events
      • File
      • Filter
      • Flashmessage
      • Folder
      • Hit
      • Html
      • Image
      • Inflector
      • Inputfilter
      • Libraries
      • Mail
      • Module
      • Nestedset
      • Pager
      • Pages
      • Params
      • Randomizer
      • Request
      • RobotLoader
      • Route
      • Security
      • Session
      • Static
      • String
      • Text
      • Trash
      • Validate
  • Email
  • Extra
    • Libraries
      • Basket
  • Joostina
    • Controller
    • Core
    • Document
  • JSMin
  • Libraries
    • Extra
      • Basket
        • Models
          • Site
  • None
  • Plugins
    • Autoadmin
    • Editor
    • Sitemap
  • SimpleMail
  • Vendors
    • Libraries
      • Email

Classes

  • actionsAdminCoder
  • actionsAjaxAdminCoder
  1: <?php defined('_JOOS_CORE') or exit();
  2: 
  3: /**
  4:  * Компонент управляемой генерации расширений системы
  5:  * Аякс - контроллер панели управления
  6:  *
  7:  * @version    1.0
  8:  * @package    Components\Coder
  9:  * @subpackage Controllers\Admin
 10:  * @author     Joostina Team <info@joostina.ru>
 11:  * @copyright  (C) 2007-2012 Joostina Team
 12:  * @license    MIT License http://www.opensource.org/licenses/mit-license.php
 13:  * Информация об авторах и лицензиях стороннего кода в составе Joostina CMS: docs/copyrights
 14:  *
 15:  * */
 16: class actionsAjaxAdminCoder extends joosAdminControllerAjax
 17: {
 18:     private static $implode_model = true;
 19: 
 20:     public static function index()
 21:     {
 22:         $tables = joosRequest::array_param('codertable',array(),$_POST);
 23: 
 24:         $ret = array(
 25:             'site'=>array(),
 26:             'admin'=>array()
 27:         );
 28: 
 29:         foreach ($tables as $table) {
 30: 
 31:             $model_code = modelAdminCoder::get_model($table, self::$implode_model);
 32:             $ret['site'][] = $model_code['site'];
 33:             $ret['admin'][] = $model_code['admin'];
 34: 
 35:         }
 36: 
 37:         $body_site = self::$implode_model ? implode('', $ret['site']) : implode("\n\n\n", $ret);
 38:         $body_admin = self::$implode_model ? implode('', $ret['admin']) : implode("\n\n\n", $ret);
 39: 
 40:         $tables_count = count( $tables );
 41: 
 42:         return array(
 43:             'success'=>true,
 44:             'message'=> $tables_count ? sprintf('Код для %s %s готов', $tables_count, joosText::declension($tables_count, array('модели','моделей','моделей') )  ) : 'Модели не выбраны' ,
 45:             'body_site'=>'<pre>' . $body_site . '</pre>',
 46:             'body_admin'=>'<pre>' . $body_admin . '</pre>'
 47:         );
 48:     }
 49: 
 50:     public static function table_select()
 51:     {
 52:         $table = joosRequest::post('table');
 53: 
 54:         $types = modelAdminCoder_Faker::$data_types;
 55:         $type_names = array();
 56: 
 57:         array_walk($types, function( $v, $k ) use ( &$type_names ) {
 58:             $type_names[$k] = $v['name'];
 59:         });
 60: 
 61:         $table_fields = joosDatabase::instance()->get_utils()->get_table_fields($table);
 62: 
 63:         ob_start();
 64:         ?>
 65:             <table class="table table-striped">
 66:                 <thead>
 67:                     <tr>
 68:                         <th>#</th>
 69:                         <th>Поле</th>
 70:                         <th>Тип</th>
 71:                         <th>Чем заполнить</th>
 72:                     </tr>
 73:                 </thead>
 74: 
 75:                 <tbody>
 76:                     <?php $i = 1; foreach ($table_fields as $key => $value) :?>
 77:                         <?php
 78: 
 79:                         $type = preg_replace('#[^A-Z]#i', '', $value);
 80:                         $type = str_replace('unsigned', '', $type);
 81:                         $active_option = null;
 82: 
 83:                         array_walk($types, function($v, $k) use ($type, &$active_option) {
 84:                             $active_option = (in_array($type, $v['types']) && $active_option === null) ? $k : $active_option;
 85:                         });
 86: 
 87:                         $faker_selector = joosHTML::dropdown('type', $type_names, $active_option);
 88:                         ?>
 89:                     <tr>
 90:                         <td><?php echo $i;?></td>
 91:                         <td><?php echo $key ?></td>
 92:                         <td><?php echo $type ?></td>
 93:                         <td><?php echo $faker_selector ?></td>
 94:                     </tr>
 95: 
 96:                     <?php ++$i; endforeach;?>
 97:                 </tbody>
 98:             </table>
 99:         <?php
100: 
101:         $return = ob_get_contents();
102:         ob_get_clean();
103: 
104:         return $return;
105:     }
106: 
107:     public static function codegenerator()
108:     {
109:         $template_vars_default = array(
110:             'component_title' => '',
111:             'component_name' => '',
112:             'component_description' => '',
113:             'component_author' => 'Joostina Team',
114:             'component_authoremail' => 'info@joostina.ru',
115:             'component_copyright'=>'(C) 2007-2012 Joostina Team'
116:         );
117: 
118:         $template_vars = array();
119:         foreach ($template_vars_default as $var => $default_value) {
120:             $value = joosRequest::post($var, false);
121:             $template_vars[':'.$var] = $value ? $value : $default_value;
122:         }
123: 
124:         $template_vars[':component_name_camelcase'] =  joosInflector::camelize($template_vars[':component_name']);
125: 
126:         $template_path_root = JPATH_BASE . DS . 'app' . DS . 'components' . DS . 'coder' . DS . 'templates' . DS . 'component'.DS;
127: 
128:         $template_files = array(
129:             'controller.component_name',
130:             'controller.component_name.ajax',
131:             'controller.admin.component_name',
132:             'controller.admin.component_name.ajax'
133:         );
134: 
135:         $return = array();
136:         foreach ($template_files as $template_file) {
137:             $template_body = joosFile::get_content( $template_path_root . $template_file);
138: 
139:             $file_body = strtr($template_body,$template_vars);
140:             $file_name = str_replace('component_name', $template_vars[':component_name'] ,$template_file);
141: 
142:             $return[$template_file] = sprintf('%s.php<br /><textarea class="span10" rows="10">%s</textarea>',$file_name,$file_body);
143: 
144:         }
145: 
146:         return array('success'=>true, 'body' => implode("\n", $return) );
147:     }
148: 
149: }
150: 
Joostina CMS / CMF v2.* API API documentation generated by ApiGen 2.6.1 – Template adapted by @olvlv and Joostina Team