Пример #1
0
 private function destroy_views($plugin, $name)
 {
     $plugin_app_path = $this->get_plugin_app_path($plugin);
     $name_tableized = MvcInflector::tableize($name);
     $public_directory = $plugin_app_path . 'views/' . $name_tableized;
     $admin_directory = $plugin_app_path . 'views/admin/' . $name_tableized;
     $directory = new MvcDirectory();
     $directory->delete($public_directory);
     $directory->delete($admin_directory);
 }
Пример #2
0
 public function write($content, $path = null, $options = array())
 {
     $defaults = array('create_nonexistent_parent_directories' => true);
     $options = array_merge($defaults, $options);
     if (!$path) {
         $path = $this->path;
     }
     if (!$path) {
         return false;
     }
     if ($options['create_nonexistent_parent_directories']) {
         $directory = new MvcDirectory();
         $directories = explode('/', dirname($path));
         for ($i = 1; $i <= count($directories); $i++) {
             $directory_path = implode('/', array_slice($directories, 0, $i));
             if (!$directory->exists($directory_path)) {
                 $directory->create($directory_path);
             }
         }
     }
     $handle = fopen($path, 'w');
     fwrite($handle, $content);
     fclose($handle);
 }
Пример #3
0
 private function generate_views($plugin, $name)
 {
     $plugin_app_path = $this->get_plugin_app_path($plugin);
     $name_tableized = MvcInflector::tableize($name);
     $name_titleized = MvcInflector::titleize($name);
     $name_titleized_pluralized = MvcInflector::pluralize($name_titleized);
     $name_underscored = MvcInflector::underscore($name);
     $directory = new MvcDirectory();
     $public_directory = $plugin_app_path . 'views/' . $name_tableized . '/';
     $directory->create($public_directory);
     $admin_directory = $plugin_app_path . 'views/admin/' . $name_tableized . '/';
     $directory->create($admin_directory);
     $vars = array('name_tableized' => $name_tableized, 'name_titleized' => $name_titleized, 'name_titleized_pluralized' => $name_titleized_pluralized, 'name_underscored' => $name_underscored);
     $this->templater->create('views/_item', $public_directory . '_item.php', $vars);
     $this->templater->create('views/index', $public_directory . 'index.php', $vars);
     $this->templater->create('views/show', $public_directory . 'show.php', $vars);
     $this->templater->create('views/admin/add', $admin_directory . '/add.php', $vars);
     $this->templater->create('views/admin/edit', $admin_directory . '/edit.php', $vars);
 }