Пример #1
0
    function cast()
    {
        $this->model_name = AkInflector::camelize($this->model_name);
        $this->model_file_path = AkInflector::toModelFilename($this->model_name);
        $this->controller_name = empty($this->controller_name) ? $this->model_name : (AkInflector::camelize($this->controller_name));
        $this->controller_file_path = AkInflector::toControllerFilename($this->controller_name);
        $this->controller_class_name = $this->controller_name.'Controller';
        $this->controller_human_name = AkInflector::humanize($this->controller_name);
        $this->helper_var_name = '$'.AkInflector::underscore($this->controller_name).'_helper';

        $this->singular_name = AkInflector::underscore($this->model_name);
        $this->plural_name = AkInflector::pluralize($this->singular_name);
        $this->singular_controller_name = AkInflector::underscore($this->controller_name);

        $this->files = array(
        'controller.php' => $this->controller_file_path,
        /**
         * @todo Implement generic functional tests
         */
        // 'functional_test.php' => AK_TEST_DIR.DS.'functional'.DS.'test_'.$this->controller_class_name.'.php',
        'helper.php' => AK_HELPERS_DIR.DS.trim($this->helper_var_name,'$').'.php',
        'layout' => AK_VIEWS_DIR.DS.'layouts'.DS.$this->singular_controller_name.'.tpl',
        'view_add' => AK_VIEWS_DIR.DS.$this->singular_controller_name.DS.'add.tpl',
        'view_destroy' => AK_VIEWS_DIR.DS.$this->singular_controller_name.DS.'destroy.tpl',
        'view_edit' => AK_VIEWS_DIR.DS.$this->singular_controller_name.DS.'edit.tpl',
        'view_listing' => AK_VIEWS_DIR.DS.$this->singular_controller_name.DS.'listing.tpl',
        'view_show' => AK_VIEWS_DIR.DS.$this->singular_controller_name.DS.'show.tpl',
        'form' => AK_VIEWS_DIR.DS.$this->singular_controller_name.DS.'_form.tpl',
        );

        $this->user_actions = array();
        foreach ((array)@$this->actions as $action){
            $this->user_actions[$action] = AK_VIEWS_DIR.DS.$this->singular_controller_name.DS.$action.'.tpl';
        }
    }
Пример #2
0
 function menu_for_controllers($menu_options = array())
 {
     $menu_options = empty($menu_options) ? $this->_get_default_full_menu() : $menu_options;
     $menu = '';
     foreach ($menu_options as $controller => $actions) {
         $controller_name = AkInflector::classify($controller);
         $current_controller_name = $this->_controller->getControllerName();
         $current_action_name = $this->_controller->Request->getAction();
         $controller_class_name = $controller_name . 'Controller';
         $controller_human_name = AkInflector::humanize($controller);
         $controller_file_name = AkInflector::toControllerFilename($controller);
         if (file_exists($controller_file_name)) {
             include_once $controller_file_name;
             if (class_exists($controller_class_name)) {
                 $menu_header = TagHelper::content_tag('h2', TagHelper::content_tag('a', $controller_human_name, array('href' => $this->_controller->urlFor(array('controller' => $controller)))), array('class' => $current_controller_name == $controller_name ? 'current' : ''));
                 $submenu = '';
                 foreach ((array) $actions as $action) {
                     if ($action[0] == '_') {
                         continue;
                     }
                     $submenu .= TagHelper::content_tag('li', TagHelper::content_tag('a', AkInflector::humanize($action), array('href' => $this->_controller->urlFor(array('controller' => $controller, 'action' => $action)))), array('class' => $current_controller_name == $controller_name && $current_action_name == $action ? 'current' : ''));
                 }
                 $menu .= !empty($submenu) ? TagHelper::content_tag('ul', TagHelper::content_tag('li', $menu_header . TagHelper::content_tag('ul', $submenu))) : '';
             }
         }
     }
     return TagHelper::content_tag('div', $menu, array('id' => 'menu'));
 }
Пример #3
0
 function cast()
 {
     $this->model_name = AkInflector::camelize($this->model_name);
     $this->model_file_path = AkInflector::toModelFilename($this->model_name);
     if (empty($this->actions) && !empty($this->controller_name) && strstr($this->controller_name, ',')) {
         $this->controller_name = '';
     }
     $this->controller_name = empty($this->controller_name) ? AkInflector::pluralize($this->model_name) : AkInflector::camelize($this->controller_name);
     $this->controller_file_path = AkInflector::toControllerFilename($this->controller_name);
     $this->controller_class_name = str_replace(array('/', '::'), '_', $this->controller_name . 'Controller');
     $this->controller_name = AkInflector::demodulize($this->controller_name);
     $this->controller_human_name = AkInflector::humanize($this->controller_name);
     $this->helper_name = (AkInflector::is_plural($this->controller_name) ? AkInflector::singularize($this->controller_name) : $this->controller_name) . 'Helper';
     $this->helper_var_name = '$' . AkInflector::underscore($this->helper_name);
     $this->singular_name = AkInflector::underscore($this->model_name);
     $this->plural_name = AkInflector::pluralize($this->singular_name);
     $this->singular_controller_name = AkInflector::underscore($this->controller_name);
     $this->module_preffix = AkInflector::underscore(substr($this->controller_class_name, 0, strrpos($this->controller_class_name, '_')));
     $this->module_preffix = empty($this->module_preffix) ? '' : DS . $this->module_preffix;
     $this->files = array('controller.php' => $this->controller_file_path, 'helper.php' => AK_HELPERS_DIR . $this->module_preffix . DS . trim($this->helper_var_name, '$') . '.php', 'layout' => AK_VIEWS_DIR . DS . 'layouts' . DS . $this->singular_controller_name . '.tpl', 'view_add' => AK_VIEWS_DIR . $this->module_preffix . DS . $this->singular_controller_name . DS . 'add.tpl', 'view_destroy' => AK_VIEWS_DIR . $this->module_preffix . DS . $this->singular_controller_name . DS . 'destroy.tpl', 'view_edit' => AK_VIEWS_DIR . $this->module_preffix . DS . $this->singular_controller_name . DS . 'edit.tpl', 'view_listing' => AK_VIEWS_DIR . $this->module_preffix . DS . $this->singular_controller_name . DS . 'listing.tpl', 'view_show' => AK_VIEWS_DIR . $this->module_preffix . DS . $this->singular_controller_name . DS . 'show.tpl', 'form' => AK_VIEWS_DIR . $this->module_preffix . DS . $this->singular_controller_name . DS . '_form.tpl');
     $this->user_actions = array();
     foreach ((array) @$this->actions as $action) {
         $this->user_actions[$action] = AK_VIEWS_DIR . $this->module_preffix . DS . $this->singular_controller_name . DS . $action . '.tpl';
     }
 }
Пример #4
0
 /**
  * Displays a tring representation of the model for debugging.
  */
 public function toString($print = false)
 {
     $result = '';
     if (!AK_CLI || AK_ENVIRONMENT == 'testing' && !AK_CLI) {
         $result = "<h2>Details for " . AkInflector::humanize(AkInflector::underscore($this->_Model->getModelName())) . " with " . $this->_Model->getPrimaryKey() . " " . $this->_Model->getId() . "</h2>\n<dl>\n";
         foreach ($this->_Model->getColumnNames() as $column => $caption) {
             $result .= "<dt>{$caption}</dt>\n<dd>" . $this->_Model->getAttribute($column) . "</dd>\n";
         }
         $result .= "</dl>\n<hr />";
         if ($print) {
             echo $result;
         }
     } elseif (AK_DEV_MODE) {
         $result = "\n" . str_replace("\n", " ", var_export($this->_Model->getAttributes(), true));
         $result .= "\n";
         echo $result;
         return '';
     } elseif (AK_CLI) {
         $result = "\n-------\n Details for " . AkInflector::humanize(AkInflector::underscore($this->_Model->getModelName())) . " with " . $this->_Model->getPrimaryKey() . " " . $this->_Model->getId() . " ==\n\n/==\n";
         foreach ($this->_Model->getColumnNames() as $column => $caption) {
             $result .= "\t * {$caption}: " . $this->_Model->getAttribute($column) . "\n";
         }
         $result .= "\n\n-------\n";
         if ($print) {
             echo $result;
         }
     }
     return $result;
 }
Пример #5
0
 public function typeCondition($table_alias = null)
 {
     $inheritance_column = $this->_ActiveRecord->getInheritanceColumn();
     $type_condition = array();
     $table_name = $this->_ActiveRecord->getTableName();
     $available_types = array_merge(array($this->_ActiveRecord->getModelName()), $this->getSubclasses());
     foreach ($available_types as $subclass) {
         $type_condition[] = ' ' . ($table_alias != null ? $table_alias : $table_name) . '.' . $inheritance_column . ' = \'' . AkInflector::humanize(AkInflector::underscore($subclass)) . '\' ';
     }
     return empty($type_condition) ? '' : '(' . join('OR', $type_condition) . ') ';
 }
Пример #6
0
 function sortable_link($column, $url_options = array(), $link_options = array())
 {
     $default_url_options = array('sort' => $column, 'direction' => empty($this->_controller->params['sort']) ? 'desc' : ($this->_controller->params['sort'] == $column ? empty($this->_controller->params['direction']) ? 'desc' : ($this->_controller->params['direction'] == 'desc' ? 'asc' : 'desc') : 'desc'));
     $page_var_on_url = empty($url_options['page_var_on_url']) ? 'page' : $url_options['page_var_on_url'];
     unset($url_options['page_var_on_url']);
     $url_options = array_merge($default_url_options, $url_options);
     $link_options['href'] = html_entity_decode($this->_controller->url_helper->modify_current_url($url_options, array($page_var_on_url)));
     if (empty($link_options['title'])) {
         $link_options['title'] = $this->_controller->t("Sort by {$column} ({$url_options['direction']})");
     }
     return TagHelper::content_tag('a', $this->_controller->t(AkInflector::humanize($column)), $link_options);
 }
Пример #7
0
 function _setupCloner()
 {
     $this->clone_setup_done = true;
     $this->class_to_clone = AkInflector::underscore($this->class_to_clone);
     $this->class_name = AkInflector::underscore($this->class_name);
     $this->clone_replacements = array(AkInflector::camelize($this->class_to_clone) . 'Controller' => AkInflector::camelize($this->class_name) . 'Controller', AkInflector::humanize(AkInflector::pluralize($this->class_to_clone)) => AkInflector::humanize(AkInflector::pluralize($this->class_name)), AkInflector::titleize(AkInflector::pluralize($this->class_to_clone)) => AkInflector::titleize(AkInflector::pluralize($this->class_name)), AkInflector::humanize($this->class_to_clone) => AkInflector::humanize($this->class_name), AkInflector::titleize($this->class_to_clone) => AkInflector::titleize($this->class_name), AkInflector::camelize(AkInflector::pluralize($this->class_to_clone)) => AkInflector::camelize(AkInflector::pluralize($this->class_name)), AkInflector::pluralize($this->class_to_clone) => AkInflector::pluralize($this->class_name), AkInflector::camelize($this->class_to_clone) => AkInflector::camelize($this->class_name), $this->class_to_clone => $this->class_name);
     //AK_VIEWS_DIR.DS.AkInflector::underscore($this->class_name).DS.$action.'.tpl'
     $this->files_to_clone = array(AkInflector::toModelFilename($this->class_to_clone) => AkInflector::toModelFilename($this->class_name), AK_TEST_DIR . DS . 'unit' . DS . 'test_' . $this->class_to_clone . '.php' => AK_TEST_DIR . DS . 'unit' . DS . 'test_' . $this->class_name . '.php', AK_TEST_DIR . DS . 'fixtures' . DS . AkInflector::tableize($this->class_to_clone) . '.yml' => AK_TEST_DIR . DS . 'fixtures' . DS . AkInflector::tableize($this->class_name) . '.yml', AkInflector::toControllerFilename($this->class_to_clone) => AkInflector::toControllerFilename($this->class_name), AK_TEST_DIR . DS . 'functional' . DS . 'test_' . AkInflector::camelize($this->class_to_clone . '_controller') . '.php' => AK_TEST_DIR . DS . 'functional' . DS . 'test_' . AkInflector::camelize($this->class_name . '_controller') . '.php', AK_HELPERS_DIR . DS . AkInflector::underscore("{$this->class_to_clone}_helper") . '.php' => AK_HELPERS_DIR . DS . AkInflector::underscore("{$this->class_name}_helper") . '.php');
     foreach ($this->_getControllerViews() as $view_file) {
         $this->files_to_clone[AK_VIEWS_DIR . DS . $this->class_to_clone . DS . $view_file . '.tpl'] = AK_VIEWS_DIR . DS . $this->class_name . DS . $view_file . '.tpl';
     }
     $this->files_to_clone[AK_VIEWS_DIR . DS . 'layouts' . DS . $this->class_to_clone . '.tpl'] = AK_VIEWS_DIR . DS . 'layouts' . DS . $this->class_name . '.tpl';
     foreach (Ak::dir(AK_APP_DIR . DS . 'locales' . DS . $this->class_to_clone, array('dirs' => false)) as $locale_file) {
         $this->files_to_clone[AK_APP_DIR . DS . 'locales' . DS . $this->class_to_clone . DS . $locale_file] = AK_APP_DIR . DS . 'locales' . DS . $this->class_name . DS . $locale_file;
     }
 }
Пример #8
0
 /**
  * Returns a menu for all or several actions in all or several controllers.
  *
  * Let +menu_options+ defaults and this will generate a menu with all actions in all controllers.
  * Set +menu_options+ to an array with keys as controller name and values as actions names.
  *
  * <?php echo $menu_helper->menu_for_controllers(array('advertiser' => array('buy', 'partial_in_template'))); ?>
  * will generate something like :
  * <div id="menu">
  *  <ul>
  *   <li>
  *    <h2><a href="/advertiser">Advertiser</a></h2>
  *    <ul>
  *     <li><a href="/advertiser/buy">Buy</a></li>
  *     <li><a href="/advertiser/partial_in_template">Partial in template</a></li>
  *    </ul>
  *   </li>
  *  </ul>
  * </div>
  *
  * +div_menu_id+: the id of the main div (default is "menu")
  * +current_class+: the class name of the current controller or the current action (default is "current")
  * +title_tag+: the tag that will contain the controller name link (default is "h2"). If it's empty, it won't be present
  */
 public function menu_for_controllers($menu_options = array(), $div_menu_id = 'menu', $current_class = 'current', $title_tag = 'h2')
 {
     $menu_options = empty($menu_options) ? $this->_get_default_full_menu() : $menu_options;
     $menu = '';
     foreach ($menu_options as $controller => $actions) {
         $controller_name = AkInflector::classify($controller);
         $current_controller_name = $this->_controller->getControllerName();
         $current_action_name = $this->_controller->Request->getAction();
         $controller_class_name = $controller_name . 'Controller';
         $controller_human_name = AkInflector::humanize($controller);
         $controller_file_name = AkInflector::toControllerFilename($controller);
         if (file_exists($controller_file_name)) {
             include_once $controller_file_name;
             if (class_exists($controller_class_name)) {
                 $class = $current_controller_name == $controller_name ? array('class' => $current_class) : array();
                 $href = array('href' => $this->_controller->urlFor(array('controller' => $controller)));
                 if (empty($title_tag)) {
                     $_title_tag = 'a';
                     $content = $controller_human_name;
                     $options = array_merge($class, $href);
                 } else {
                     $content = AkTagHelper::content_tag('a', $controller_human_name, $href);
                     $options = $class;
                     $_title_tag = $title_tag;
                 }
                 $menu_header = AkTagHelper::content_tag($_title_tag, $content, $options);
                 $submenu = '';
                 foreach ((array) $actions as $action) {
                     if ($action[0] == '_') {
                         continue;
                     }
                     $submenu .= AkTagHelper::content_tag('li', AkTagHelper::content_tag('a', AkInflector::humanize($action), array('href' => $this->_controller->urlFor(array('controller' => $controller, 'action' => $action)))), $current_controller_name == $controller_name && $current_action_name == $action ? array('class' => $current_class) : array());
                 }
                 $menu .= !empty($submenu) ? AkTagHelper::content_tag('ul', AkTagHelper::content_tag('li', $menu_header . AkTagHelper::content_tag('ul', $submenu))) : '';
             }
         }
     }
     return AkTagHelper::content_tag('div', $menu, array('id' => $div_menu_id));
 }
Пример #9
0
 function humanize($text)
 {
     return AkInflector::humanize($text);
 }
Пример #10
0
echo "Admin_" . AkInflector::camelize($controller_name) . "Controller";
?>
 extends AdminController
{

    var $controller_information = '<?php 
echo AkInflector::titleize($singular_name);
?>
 management area.';
    
<?php 
echo "    var \$models = '{$CamelCaseSingular}';\n";
echo "    var \$admin_menu_options = array('" . AkInflector::titleize($controller_name) . "'=>array('id'=>'" . AkInflector::underscore($controller_name) . "','url'=>array('controller'=>'" . AkInflector::underscore($controller_name) . "','action'=>'listing')));\n";
echo "    var \$controller_menu_options = array(";
foreach (array('listing', 'add') as $k) {
    echo "'" . AkInflector::humanize($k) . "'=> array('id'=>'{$k}','url'=>array('controller'=>'" . AkInflector::underscore($controller_name) . "','action'=>'{$k}')),";
}
echo ");\n\n";
?>
   
    function index()
    {
        $this->redirectToAction('listing');
    }

<?php 
foreach ((array) @$actions as $action) {
    ?>
    function <?php 
    echo $action;
    ?>
Пример #11
0
 /**
  * Returns a string with a div containing all the error messages for the object located as an instance variable by the name
  * of <tt>object_name</tt>. This div can be tailored by the following options:
  *
  * * <tt>header_tag</tt> - Used for the header of the error div (default: h2)
  * * <tt>id</tt> - The id of the error div (default: errorExplanation)
  * * <tt>class</tt> - The class of the error div (default: errorExplanation)
  *
  * NOTE: This is a pre-packaged presentation of the errors with embedded strings and a certain HTML structure. If what
  * you need is significantly different from the default presentation, it makes plenty of sense to access the $object->getErrors()
  * instance yourself and set it up. View the source of this method to see how easy it is.
  */
 public function error_messages_for($object_name, $options = array())
 {
     $object = $this->_controller->{$object_name};
     if ($object->hasErrors()) {
         $error_list = '<ul>';
         foreach ($object->getFullErrorMessages() as $field => $errors) {
             foreach ($errors as $error) {
                 $error_list .= AkTagHelper::content_tag('li', $error);
             }
         }
         $error_list .= '</ul>';
         return AkTagHelper::content_tag('div', AkTagHelper::content_tag(!empty($options['header_tag']) ? $options['header_tag'] : 'h2', $this->t('%number_of_errors %errors prohibited this %object_name from being saved', array('%number_of_errors' => $object->countErrors(), '%errors' => $this->t(AkInflector::conditionalPlural($object->countErrors(), 'error')), '%object_name' => $this->t(AkInflector::humanize($object->getModelName()))))) . AkTagHelper::content_tag('p', $this->t('There were problems with the following fields:')) . $error_list, array('id' => !empty($options['id']) ? $options['id'] : 'errorExplanation', 'class' => !empty($options['class']) ? $options['class'] : 'errorExplanation'));
     }
 }
Пример #12
0
 public function getAttributeCaption($attribute)
 {
     return $this->t(AkInflector::humanize($attribute));
 }
Пример #13
0
 /**
  * Creates a label field
  *
  * ==== Options  
  * * Creates standard HTML attributes for the tag.
  *
  * ==== Examples
  *   label_tag 'name'
  *   # => <label for="name">Name</label>
  *
  *   label_tag 'name', 'Your name'
  *   # => <label for="name">Your Name</label>
  *
  *   label_tag 'name', nil, :class => 'small_label'
  *   # => <label for="name" class="small_label">Name</label>
  */
 static function label_tag($name, $text = null, $options = array())
 {
     return AkTagHelper::content_tag('label', empty($text) ? AkInflector::humanize($name) : $text, array_merge($options, array('for' => self::sanitize_to_id($name))));
 }
Пример #14
0
            if($this-><?php 
echo $CamelCaseSingular;
?>
 =& $this-><?php 
echo $CamelCaseSingular;
?>
->find($this->params['id'])){
                if($this->Request->isPost()){
                    $this-><?php 
echo $CamelCaseSingular;
?>
->destroy();
                    $this->flash_options = array('seconds_to_close' => 10);
                    $this->flash['notice'] = $this->t('<?php 
echo AkInflector::humanize($singular_name);
?>
 was successfully deleted.');
                    $this->redirectToAction('listing');
                }
            }else {
                $this->flash['error'] = $this->t('<?php 
echo AkInflector::humanize($singular_name);
?>
 not found.');
                $this->redirectToAction('listing');
            }
        }
    }
}

?>
Пример #15
0
 /**
  * Returns all the full error messages in an array.
  */
 function getFullErrorMessages()
 {
     $full_messages = array();
     foreach ($this->_errors as $attribute => $errors) {
         $full_messages[$attribute] = array();
         foreach ($errors as $error) {
             $full_messages[$attribute][] = $this->t(AkInflector::humanize($attribute)) . ' ' . $error;
         }
     }
     return $full_messages;
 }
Пример #16
0
 function Test_of_humanize()
 {
     foreach ($this->UnderscoreToHuman as $underscore => $human) {
         $this->assertEqual($human, AkInflector::humanize($underscore));
     }
 }
Пример #17
0
 function _getLogFormatedAsString($type, $error_number, $error_message, $filename, $line_number, $serialized = false)
 {
     $message = Ak::getTimestamp() . "\t[{$error_number}]\t{$error_message}";
     $params = array_merge($this->_log_params, $this->extended_details ? array('file' => $filename, 'line_number' => $line_number, 'remote_address' => $_SERVER['REMOTE_ADDR'], 'browser' => $_SERVER['HTTP_USER_AGENT']) : array());
     if ($serialized) {
         $message .= count($params) ? "\t" . serialize($params) : '';
     } else {
         $details = '';
         foreach ($params as $k => $v) {
             $details .= "\n\t\t- " . AkInflector::humanize($k) . ": {$v}";
         }
         $message .= empty($details) ? "\n" : "\n\t" . 'PARAMS{' . $details . "\t\n}\n";
     }
     return $message;
 }
Пример #18
0
 /**
  * Returns a label tag tailored for labelling an input field for a specified attribute (identified by +method+) on an object
  * assigned to the template (identified by +object+). The text of label will default to the attribute name unless you specify
  * it explicitly. Additional options on the label tag can be passed as an array with +options+. These options will be tagged
  * onto the HTML as an HTML element attribute as in the example shown, except for the <tt>value</tt> option, which is designed to
  * target labels for radio_button tags (where the value is used in the ID of the input tag).
  *
  * ==== Examples
  *   label('post', 'title')
  *   # => <label for="post_title">Title</label>
  *
  *   label('post', 'title', 'A short title')
  *   # => <label for="post_title">A short title</label>
  *
  *   label('post', 'title', 'A short title', :class => 'title_label')
  *   # => <label for="post_title" class="title_label">A short title</label>
  *
  *   label('post', 'privacy', 'Public Post', :value => 'public')
  *   # => <label for="post_privacy_public">Public Post</label>
  */
 function label($method, $text = null, $options = array())
 {
     return $this->_field($this->object_name, $method, array_merge($options, array('text' => empty($text) ? $this->t(AkInflector::humanize($method)) : $text)), 'label');
 }
Пример #19
0
 public function humanize()
 {
     return AkInflector::humanize($this->value);
 }
Пример #20
0
 function demodulize($module_name)
 {
     $module_name = preg_replace('/^.*::/','',$module_name);
     return AkInflector::humanize(AkInflector::underscore($module_name));
 }
Пример #21
0
 /**
  * Returns all the full error messages in an array.
  */
 public function getFullErrorMessages()
 {
     $full_messages = array();
     foreach ($this->_errors as $attribute => $errors) {
         $full_messages[$attribute] = array();
         $attribute_name = AkInflector::humanize(isset($this->_Model->internationalize) && $this->_Model->internationalize ? $this->_Model->delocalizeAttribute($attribute) : $attribute);
         foreach ($errors as $error) {
             $full_messages[$attribute][] = $this->_Model->t('%attribute_name %error', array('%attribute_name' => $attribute_name, '%error' => $error));
         }
     }
     return $full_messages;
 }
Пример #22
0
 /**
  * Returns all the full error messages in an array.
  */
 function fullMessages()
 {
     $full_messages = array();
     foreach ($this->errors as $attribute->{$errors}) {
         $full_messages[$attribute] = array();
         foreach ($errors as $error) {
             $full_messages[] = AkInflector::humanize($attribute) . ' ' . $error;
         }
     }
     return $full_messages;
 }
Пример #23
0
 /**
  * @return PHPUnit_Framework_TestSuite
  */
 function createSuiteForDirectory($path)
 {
     $suite = $this->createTestSuite(AkInflector::humanize($path));
     $files = new RecursiveDirectoryIterator($path);
     foreach ($files as $file) {
         $this->addFile($suite, $file);
     }
     return $suite;
 }
Пример #24
0
 /**
  * Returns a label with proper for attribute
  * @param array $options 
  * @return string tag
  */
 public function to_label_field_tag($options = array())
 {
     $label = $options['label'] === true ? AkInflector::humanize($this->_column_name) : $options['label'];
     $required = !empty($options['required']) && $options['required'] == true ? TagHelper::content_tag('span', '*', array('class' => 'required')) : '';
     return TagHelper::content_tag('label', $required . $label, array('for' => $this->tag_id()));
 }
Пример #25
0
 /**
  * Returns $class_name in underscored form, with "_id" tacked on at the end.
  * This is for use in dealing with the database.
  *
  * @param string $class_name
  * @return string
  */
 static function foreignKey($class_name, $separate_class_name_and_id_with_underscore = true)
 {
     return AkInflector::underscore(AkInflector::humanize(AkInflector::underscore($class_name))) . ($separate_class_name_and_id_with_underscore ? "_id" : "id");
 }
Пример #26
0
 /**
  * Returns a label with proper for attribute
  * @param array $options 
  * @return string tag
  */
 public function to_label_field_tag($options = array())
 {
     $label = isset($options['label']) && is_string($options['label']) ? $options['label'] : AkInflector::humanize($this->_column_name);
     $required = !empty($options['required']) && $options['required'] == true ? TagHelper::content_tag('span', '*', array('class' => 'required')) : '';
     $question_mark = empty($options['help_box']) ? '' : TagHelper::content_tag('a', '[?]', array('href' => '#', 'title' => 'Need more help about this field?', 'class' => 'question_mark'));
     return TagHelper::content_tag('label', $required . $label . $question_mark, array('for' => $this->tag_id()));
 }