function testUnderScores()
 {
     $this->assertEqual(lmb_under_scores('FooBar'), 'foo_bar');
     $this->assertEqual(lmb_under_scores('Foo168Bar'), 'foo168_bar');
     $this->assertEqual(lmb_under_scores('FooBarZoo'), 'foo_bar_zoo');
     $this->assertEqual(lmb_under_scores('_FooBarZoo'), '_foo_bar_zoo');
     $this->assertEqual(lmb_under_scores('_FooBarZoo_'), '_foo_bar_zoo_');
 }
 function create()
 {
     $vars = array('model_name' => $this->_model_name, 'model_url' => lmb_under_scores($this->_model_name), 'columns' => $this->_table->getColumns());
     $content = $this->_createContentFromTemplate('front_for_model/controller.phtml', $vars);
     $this->_project->addController($this->getControllerFileName(), $content);
     $content = $this->_createContentFromTemplate('front_for_model/display.phtml', $vars, false);
     $this->_project->addTemplate($this->_getResultTemplatePath('display.phtml'), $content);
     $content = $this->_createContentFromTemplate('front_for_model/item.phtml', $vars, false);
     $this->_project->addTemplate($this->_getResultTemplatePath('item.phtml'), $content);
 }
 function create()
 {
     $columns = $this->_table->getColumns();
     $columns_for_display = $this->_getColumnsForDisplay();
     $form_constructor = new lmbFormConstructorHelper($columns);
     $vars = array('model_name' => $this->_model_name, 'model_url' => lmb_under_scores($this->_model_name), 'columns' => $columns_for_display, 'column_names' => array_diff($form_constructor->getColumnsNames(), $this->_meta_fields), 'form_fields' => $form_constructor->createFormFields($columns), 'fields_for_display' => $this->_getFieldsForDisplay($columns_for_display), 'apply_publish_templates' => $this->_apply_publish_templates);
     $content = $this->_createContentFromTemplate('admin_templates/display.phtml', $vars, false);
     $this->_project->addTemplate($this->_getResultTemplatePath('display.phtml'), $content);
     $content = $this->_createContentFromTemplate('admin_templates/form_fields.phtml', $vars, false);
     $this->_project->addTemplate($this->_getResultTemplatePath('include/form_fields.phtml'), $content);
     $content = $this->_createContentFromTemplate('admin_templates/create.phtml', $vars, false);
     $this->_project->addTemplate($this->_getResultTemplatePath('create.phtml'), $content);
     $content = $this->_createContentFromTemplate('admin_templates/edit.phtml', $vars, false);
     $this->_project->addTemplate($this->_getResultTemplatePath('edit.phtml'), $content);
     $content = $this->_createContentFromTemplate('admin_templates/delete.phtml', $vars, false);
     $this->_project->addTemplate($this->_getResultTemplatePath('delete.phtml'), $content);
 }
示例#4
0
function lmb_humanize($str)
{
    return str_replace('_', ' ', lmb_under_scores($str));
}
示例#5
0
 /**
  *  Maps "addTo" to property, e.g. "addToPropertyName" => "property_name"
  *  @param string
  *  @return string
  */
 function mapAddToProperty($method)
 {
     if (substr($method, 0, 5) == 'addTo') {
         return lmb_under_scores(substr($method, 5));
     }
 }
示例#6
0
 protected function _guessName()
 {
     if ($pos = strpos(get_class($this), 'Controller')) {
         return lmb_under_scores(substr(get_class($this), 0, $pos));
     }
 }
示例#7
0
 protected function _mapSetToProperty($method)
 {
     if (0 === strpos($method, 'set')) {
         return lmb_under_scores(substr($method, 3));
     }
 }
示例#8
0
 function forwardToSelf($action)
 {
     return $this->forward(str_ireplace('_controller', '', lmb_under_scores(get_class($this))), $action);
 }
 public function create()
 {
     $vars = array('model_url' => lmb_under_scores($this->_model_name));
     $this->_createRootElementIfNotExists();
     parent::create($vars);
 }
 function testUnderScoresWithNumbers()
 {
     $this->assertEqual(lmb_under_scores('Foo_0'), 'foo_0');
     $this->assertEqual(lmb_under_scores('Foo_1Bar'), 'foo_1_bar');
 }
示例#11
0
 protected function _guessDbTableName()
 {
     return str_replace('_db_table', '', lmb_under_scores(get_class($this)));
 }
 protected function _getResultTemplatePath($name)
 {
     return 'admin_' . lmb_under_scores($this->_model_name) . '/' . $name;
 }