Esempio n. 1
0
/**
 * Converts a class name to table name (MyTable -> my_table)
 *
 * @param string $classname The class name to convert
 * @return string Table name
 */
function classToTable($classname)
{
    $tbl = '';
    // Remove namespace from class name
    $classname = classUnqualified($classname);
    foreach (str_split($classname) as $char) {
        if ($char == mb_strtoupper($char, 'UTF-8')) {
            $tbl .= '_';
        }
        $tbl .= $char;
    }
    return strtolower(substr($tbl, 1));
}
Esempio n. 2
0
 public static function encode($object)
 {
     $xml = '';
     if (is_object($object)) {
         $node_name = classUnqualified(get_class($object));
         if ($node_name === 'stdClass') {
             $node_name = 'object';
         }
         $xml .= '<' . $node_name . '>';
         $xml .= self::traverse($object);
         $xml .= '</' . $node_name . '>' . PHP_EOL;
     } else {
         if (is_array($object)) {
             $xml .= self::traverse($object);
         } else {
             $node_name = gettype($object);
             $xml .= '<' . $node_name . '>' . self::encodeValue($object) . '</' . $node_name . '>' . PHP_EOL;
         }
     }
     return $xml;
 }
Esempio n. 3
0
 protected function preRender($form_name)
 {
     $template_name = strtolower(classUnqualified(get_class($this)));
     $template = new FileTemplate(__DIR__ . '/templates/' . $template_name);
     $template->set('form_name', $form_name);
     $template->set('name', $this->name);
     $template->set('flat_name', $this->getFlatName());
     $template->set('label', $this->label);
     $template->set('default_value', $this->default_value);
     $template->set('attributes', $this->getAttributesHtml());
     $template->set('value_attribute', $this->getValueAttr());
     $template->set('errors_html', $this->getErrorsHtml());
     return $template;
 }