Example #1
0
 function getActions($table_name)
 {
     $single = StringFormat::variable($table_name);
     $pks = $this->getPrimaryKeys($table_name);
     if (count($pks) === 1) {
         $pk = $pks[0];
     } else {
         $pk = null;
     }
     $actions = array();
     if (!$pk) {
         return $actions;
     }
     $pk_method = StringFormat::classMethod('get' . StringFormat::titleCase($pk->getName()));
     foreach ($this->standardActions as &$staction) {
         $actions[$staction] = "<?php echo site_url('" . StringFormat::pluralURL($table_name) . '/' . strtolower($staction) . "/' . \$" . $single . '->' . $pk_method . '()) ?>';
     }
     $fkeys_to = $this->getForeignKeysToTable($table_name);
     foreach ($fkeys_to as $k => &$r) {
         $from_table = $r->getTableName();
         $local_columns = $r->getLocalColumns();
         $from_column = array_shift($local_columns);
         if (@$used_to[$from_table]) {
             unset($fkeys_to[$k]);
             continue;
         }
         $used_to[$from_table] = $from_column;
         $actions[ucwords(StringFormat::titleCase(StringFormat::plural($from_table), ' '))] = "<?php echo site_url('" . StringFormat::pluralURL($from_table) . "?{$from_column}=' . \$" . $single . '->' . $pk_method . '()) ?>';
     }
     return $actions;
 }
Example #2
0
 public function testPluralURL()
 {
     $this->assertEquals('my-urls', StringFormat::pluralURL('myURL'));
     $this->assertEquals('my-urls', StringFormat::pluralURL('my--URL'));
     $this->assertEquals('my-urls', StringFormat::pluralURL('my  URL'));
     $this->assertEquals('my-urls', StringFormat::pluralURL('my %^&*  URL'));
     $this->assertEquals('my-urls', StringFormat::pluralURL('my____ URL--'));
     $this->assertEquals('my-urls', StringFormat::pluralURL('my/ \\URL'));
 }
Example #3
0
 /**
  * @param string $table_name
  * @return string
  */
 function getViewDirName($table_name)
 {
     return StringFormat::pluralURL($table_name);
 }