Пример #1
0
 function runCommand($command)
 {
     $commands = $this->getOptionsFromCommand($command);
     $generator_name = AkInflector::underscore(isset($commands['generator']) ? $commands['generator'] : array_shift($commands));
     $available_generators = $this->_getAvailableGenerators();
     $generator_file_name = array_shift(array_keys($available_generators, $generator_name));
     if (empty($generator_file_name)) {
         echo "\n   " . Ak::t("You must supply a valid generator as the first command.\n\n   Available generator are:");
         echo "\n\n   " . join("\n   ", $available_generators) . "\n\n";
         defined('AK_CONSOLE_MODE') && AK_CONSOLE_MODE ? null : exit;
         return;
     }
     if (include_once $generator_file_name) {
         $generator_class_name = AkInflector::camelize($generator_name . '_generator');
         $generator = new $generator_class_name();
         $generator->_generator_base_path = dirname($generator_file_name);
         if (count(array_diff($commands, array('help', '-help', 'usage', '-usage', 'h', '-h', 'USAGE', '-USAGE'))) != count($commands) || count($commands) == 0) {
             if (empty($generator->command_values) && empty($commands)) {
                 // generator without commands
             } else {
                 $generator->banner();
                 return;
             }
         }
         $generator->type = $generator_name;
         $generator->_identifyUnnamedCommands($commands);
         $generator->_assignVars($commands);
         $generator->cast();
         $generator->_generate();
     } else {
         echo "\n" . Ak::t('Could not find %generator_name generator', array('%generator_name' => $generator_name)) . "\n";
     }
 }
Пример #2
0
    function generate()
    {
        $this->_preloadPaths();

        $this->class_name = AkInflector::camelize($this->class_name);

        $files = array(
        'mailer'=>AkInflector::toModelFilename($this->class_name),
        'unit_test'=>AK_TEST_DIR.DS.'unit'.DS.'app'.DS.'models'.DS.$this->underscored_class_name.'.php'
        );

        foreach ($files as $template=>$file_path){
            $this->save($file_path, $this->render($template));
        }

        $mailer_views_folder = AK_VIEWS_DIR.DS.AkInflector::underscore($this->class_name);
        @Ak::make_dir($mailer_views_folder);

        foreach ($this->actions as $action){
            $this->assignVarToTemplate('action', $action);
            $path = $mailer_views_folder.DS.$action.'.tpl';
            $this->assignVarToTemplate('path', $path);
            $this->save($path, $this->render('view'));
        }
    }
Пример #3
0
 function addHelper($helper_name, $helper_path = null)
 {
     require_once AK_LIB_DIR . DS . 'AkActionView' . DS . 'AkHelperLoader.php';
     $helper_name = AkInflector::camelize($helper_name);
     $helper_path = empty($helper_path) ? $this->getPath() . DS . 'lib' . DS . AkInflector::underscore($helper_name) . '.php' : $helper_path;
     AkHelperLoader::addPluginHelper($helper_name, array('path' => $helper_path));
 }
Пример #4
0
    function installAndIncludeModels($models = array())
    {
        $args = func_get_args();
        $models = !empty($args) ? (is_array($args[0]) ? $args[0] : (count($args) > 1 ? $args : Ak::toArray($args[0]))) : array();

        $default_options = array('instantiate' => true);
        $options = is_array($models[count($models)-1]) ? array_pop($models) : array();
        $options = array_merge($default_options, $options);

        foreach ($models as $model){
            require_once(AK_APP_DIR.DS.'installers'.DS.(empty($this->module)?'':$this->module.DS).AkInflector::underscore($model).'_installer.php');
            require_once(AK_MODELS_DIR.DS.AkInflector::underscore($model).'.php');
            $installer_name = $model.'Installer';
            $installer = new $installer_name();
            $installer->uninstall();
            $installer->install();
            if($this->insert_models_data || !empty($options['populate'])){
                $this->populateTables(AkInflector::tableize($model));
            }
            if($this->instantiate_models || !empty($options['instantiate'])){
                $this->instantiateModel($model);
            }
        }
        if(isset($_SESSION['__activeRecordColumnsSettingsCache'])){
            unset($_SESSION['__activeRecordColumnsSettingsCache']);
        }
    }
Пример #5
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';
     }
 }
Пример #6
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;
 }
Пример #7
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';
        }
    }
Пример #8
0
 function init($options = array())
 {
     $success = $this->_ensureIsActiveRecordInstance($this->_ActiveRecordInstance);
     $singularized_model_name = AkInflector::underscore(AkInflector::singularize($this->_ActiveRecordInstance->getTableName()));
     $default_options = array('class_name' => $this->_ActiveRecordInstance->getModelName() . 'IpGeocodeLookup');
     $this->options = array_merge($default_options, $options);
     return $success;
 }
Пример #9
0
 public function link_to_node($Node, $options = array())
 {
     $detault_options = array('display' => 'name', 'id' => $Node->id, 'controller' => AkInflector::underscore($Node->getModelName()), 'action' => 'edit');
     $options = array_merge($detault_options, $options);
     $display = $Node->get($options['display']);
     unset($options['display']);
     return $this->_controller->url_helper->link_to($display, $options);
 }
Пример #10
0
 public static function getUrlParamsForModel(AkBaseModel $Model)
 {
     $url_function = AkInflector::underscore($Model->getModelName()) . '_params';
     if (!function_exists($url_function)) {
         throw new Exception($url_function . ' function not found for AkRouterHelper::getUrlOptionsForModel');
     }
     return $url_function($Model);
 }
Пример #11
0
 public function init($options = array())
 {
     $success = $this->_ensureIsActiveRecordInstance($this->_ActiveRecordInstance);
     $singularized_model_name = AkInflector::underscore(AkInflector::singularize($this->_ActiveRecordInstance->getTableName()));
     $default_options = array('base_path' => AK_BASE_DIR . DS . 'index' . AK_ENVIRONMENT . DS);
     $this->options = array_merge($default_options, $options);
     return $success;
 }
Пример #12
0
 function _preloadPaths()
 {
     $this->class_name = AkInflector::camelize($this->class_name);
     $this->assignVarToTemplate('class_name', $this->class_name);
     $this->table_name = AkInflector::tableize($this->class_name);
     $this->underscored_model_name = AkInflector::underscore($this->class_name);
     $this->model_path = 'app' . DS . 'models' . DS . $this->underscored_model_name . '.php';
     $this->installer_path = 'app' . DS . 'installers' . DS . $this->underscored_model_name . '_installer.php';
 }
Пример #13
0
 function Test_of_underscore()
 {
     foreach ($this->CamelToUnderscore as $camel => $underscore) {
         $this->assertEqual($underscore, AkInflector::underscore($camel));
     }
     foreach ($this->CamelToUnderscoreWithoutReverse as $camel => $underscore) {
         $this->assertEqual($underscore, AkInflector::underscore($camel));
     }
 }
Пример #14
0
 /**
  * Returns a paginator object
  *
  * Options:
  * 'items_per_page' => 15, // Number of items per page
  * 'page_var_on_url' => 'page', // This var will be passed thru the url for pointing to current page
  * 'count_method' => 'count' // This method will be called on selected model to get the total number of items.
  * 'count_conditions' => null // A string that will be passed as the first parameter (conditions) to the count method
  * 'count_joins' => null // A string that will be passed as the seccond parameter (join options) to the count method.
  * 'column_dictionary' => array() // In case you need to map the sort key from the url to the database column you must define an array pair
  * 'include' => array() // In case current sort column is not found on current model or in the column_dictionary this helper will look for the first associated model witrh a column named like given sort parameter.
  */
 public function getPaginator(&$object, $options = array())
 {
     $default_options = array('items_per_page' => 15, 'page_var_on_url' => 'page', 'count_method' => 'count', 'count_conditions' => null, 'count_joins' => null);
     $options = array_merge($default_options, $options);
     $paginator_name = AkInflector::underscore($object->getModelName()) . '_pages';
     $this->{$paginator_name} = new AkPaginator($this->_controller, $object->{$options['count_method']}($options['count_conditions'], $options['count_joins']), $options['items_per_page'], @$this->_controller->params[$options['page_var_on_url']]);
     $this->{$paginator_name}->_ak_options =& $options;
     return $this->{$paginator_name};
 }
Пример #15
0
 /**
  * @return boolean
  */
 static function includeClass($search_path, $class_name)
 {
     $file_name = AkInflector::underscore($class_name) . '.php';
     if ($full_filename = self::searchFilenameInPath($search_path, $file_name)) {
         require_once $full_filename;
         return true;
     }
     return false;
 }
Пример #16
0
 function &recognize($Map = null)
 {
     AK_ENVIRONMENT != 'setup' ? $this->_connectToDatabase() : null;
     $this->_startSession();
     $this->_enableInternationalizationSupport();
     $this->_mapRoutes($Map);
     $params = $this->getParams();
     $module_path = $module_class_peffix = '';
     if (!empty($params['module'])) {
         $module_path = trim(str_replace(array('/', '\\'), DS, Ak::sanitize_include($params['module'], 'high')), DS) . DS;
         $module_shared_model = AK_CONTROLLERS_DIR . DS . trim($module_path, DS) . '_controller.php';
         $module_class_peffix = str_replace(' ', '_', AkInflector::titleize(str_replace(DS, ' ', trim($module_path, DS)))) . '_';
     }
     $controller_file_name = AkInflector::underscore($params['controller']) . '_controller.php';
     $controller_class_name = $module_class_peffix . AkInflector::camelize($params['controller']) . 'Controller';
     $controller_path = AK_CONTROLLERS_DIR . DS . $module_path . $controller_file_name;
     include_once AK_APP_DIR . DS . 'application_controller.php';
     if (!empty($module_path) && file_exists($module_shared_model)) {
         include_once $module_shared_model;
     }
     if (!is_file($controller_path) || !(include_once $controller_path)) {
         defined('AK_LOG_EVENTS') && AK_LOG_EVENTS && $this->Logger->error('Controller ' . $controller_path . ' not found.');
         if (AK_ENVIRONMENT == 'development') {
             trigger_error(Ak::t('Could not find the file /app/controllers/<i>%controller_file_name</i> for ' . 'the controller %controller_class_name', array('%controller_file_name' => $controller_file_name, '%controller_class_name' => $controller_class_name)), E_USER_ERROR);
         } elseif (@(include AK_PUBLIC_DIR . DS . '404.php')) {
             $response = new AkTestResponse();
             $response->addHeader('Status', 404);
             return false;
             //exit;
         } else {
             //header("HTTP/1.1 404 Not Found");
             $response = new AkResponse();
             $response->addHeader('Status', 404);
             return false;
             //die('404 Not found');
         }
     }
     if (!class_exists($controller_class_name)) {
         defined('AK_LOG_EVENTS') && AK_LOG_EVENTS && $this->Logger->error('Controller ' . $controller_path . ' does not implement ' . $controller_class_name . ' class.');
         if (AK_ENVIRONMENT == 'development') {
             trigger_error(Ak::t('Controller <i>%controller_name</i> does not exist', array('%controller_name' => $controller_class_name)), E_USER_ERROR);
         } elseif (@(include AK_PUBLIC_DIR . DS . '405.php')) {
             exit;
         } else {
             $response = new AkResponse();
             $response->addHeader('Status', 405);
             return false;
             //header("HTTP/1.1 405 Method Not Allowed");
             //die('405 Method Not Allowed');
         }
     }
     $Controller =& new $controller_class_name(array('controller' => true));
     $Controller->_module_path = $module_path;
     isset($_SESSION) ? $Controller->session =& $_SESSION : null;
     return $Controller;
 }
Пример #17
0
 public function _preloadPaths()
 {
     $this->api_name = AkInflector::camelize($this->api_name);
     $this->api_class_name = $this->api_name . 'Api';
     $this->assignVarToTemplate('api_class_name', $this->api_class_name);
     $this->service_class_name = $this->api_name . 'Service';
     $this->assignVarToTemplate('service_class_name', $this->service_class_name);
     $this->api_path = AkConfig::getDir('apis') . DS . AkInflector::underscore($this->api_class_name) . '.php';
     $this->underscored_service_name = AkInflector::underscore($this->api_name);
     $this->service_path = AkConfig::getDir('models') . DS . $this->underscored_service_name . '_service.php';
 }
Пример #18
0
 public function __construct($client_driver)
 {
     $client_driver = AkInflector::underscore($client_driver);
     if (in_array($client_driver, $this->_available_drivers)) {
         $client_class_name = 'Ak' . AkInflector::camelize($client_driver) . 'Client';
         require_once AK_ACTION_PACK_DIR . DS . 'action_web_service' . DS . 'clients' . DS . $client_driver . '.php';
         $this->_Client = new $client_class_name($this);
     } else {
         trigger_error(Ak::t('Invalid Web Service driver provided. Available Drivers are: %drivers', array('%drivers' => join(', ', $this->_available_drivers))), E_USER_WARNING);
     }
 }
Пример #19
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) . ') ';
 }
Пример #20
0
 function _preloadPaths()
 {
     $this->api_name = AkInflector::camelize($this->api_name);
     $this->api_class_name = $this->api_name . 'Api';
     $this->assignVarToTemplate('api_class_name', $this->api_class_name);
     $this->service_class_name = $this->api_name . 'Service';
     $this->assignVarToTemplate('service_class_name', $this->service_class_name);
     $this->api_path = AK_APIS_DIR . DS . AkInflector::underscore($this->api_class_name) . '.php';
     $this->underscored_service_name = AkInflector::underscore($this->api_name);
     $this->service_path = AK_MODELS_DIR . DS . $this->underscored_service_name . '_service.php';
 }
Пример #21
0
 public function hasCollisions()
 {
     $this->collisions = array();
     $this->namespace = AkInflector::underscore(Ak::first(explode(':', $this->task_name . ':')));
     $this->task_name = AkInflector::underscore(Ak::last(explode(':', ':' . $this->task_name)));
     $this->destination_path = AK_TASKS_DIR . DS . $this->namespace;
     if (file_exists($this->destination_path . DS . $this->task_name . '.task.php')) {
         $this->collisions[] = Ak::t('%path already exists', array('%path' => $this->destination_path . DS . $this->task_name . '.task.php'));
     }
     return count($this->collisions) > 0;
 }
Пример #22
0
function akelos_autoload($name, $path = null)
{
    static $paths = array(), $lib_paths = array(), $app_paths = array();
    if (!empty($path)) {
        $paths[$name] = $path;
        return;
    }
    if (empty($app_paths)) {
        $app_paths = array('BaseActionController' => 'controllers/base_action_controller.php', 'BaseActiveRecord' => 'models/base_active_record.php', 'ApplicationController' => 'controllers/application_controller.php', 'ActiveRecord' => 'models/active_record.php');
    }
    if (empty($lib_paths)) {
        $lib_paths = array('AkActionMailer' => 'action_mailer/base.php', 'AkMailComposer' => 'action_mailer/composer.php', 'AkMailEncoding' => 'action_mailer/encoding.php', 'AkMailBase' => 'action_mailer/mail_base.php', 'AkMailMessage' => 'action_mailer/message.php', 'AkMailParser' => 'action_mailer/parser.php', 'AkMailPart' => 'action_mailer/part.php', 'AkActionMailerQuoting' => 'action_mailer/quoting.php', 'AkActionController' => 'action_pack/action_controller.php', 'AkExceptionDispatcher' => 'action_pack/exception_dispatcher.php', 'AkActionView' => 'action_pack/action_view.php', 'AkBaseHelper' => 'action_pack/base_helper.php', 'AkActionViewHelper' => 'action_pack/base_helper.php', 'AkCacheHandler' => 'action_pack/cache_handler.php', 'AkCacheSweeper' => 'action_pack/cache_sweeper.php', 'AkActionControllerTest' => 'action_pack/testing.php', 'AkHelperTest' => 'action_pack/testing.php', 'AkDbSession' => 'action_pack/db_session.php', 'AkCookieStore' => 'action_pack/cookie_store.php', 'AkDispatcher' => 'action_pack/dispatcher.php', 'AkActiveRecordHelper' => 'action_pack/helpers/ak_active_record_helper.php', 'AkAssetTagHelper' => 'action_pack/helpers/ak_asset_tag_helper.php', 'AkFormHelperBuilder' => 'action_pack/helpers/ak_form_helper.php', 'AkFormHelperInstanceTag' => 'action_pack/helpers/ak_form_helper.php', 'AkFormHelper' => 'action_pack/helpers/ak_form_helper.php', 'AkFormHelperOptionsInstanceTag' => 'action_pack/helpers/ak_form_options_helper.php', 'AkFormTagHelper' => 'action_pack/helpers/ak_form_tag_helper.php', 'AkJavascriptHelper' => 'action_pack/helpers/ak_javascript_helper.php', 'AkJavascriptMacrosHelper' => 'action_pack/helpers/ak_javascript_macros_helper.php', 'AkMailHelper' => 'action_pack/helpers/ak_mail_helper.php', 'AkMenuHelper' => 'action_pack/helpers/ak_menu_helper.php', 'AkNumberHelper' => 'action_pack/helpers/ak_number_helper.php', 'AkPaginationHelper' => 'action_pack/helpers/ak_pagination_helper.php', 'AkPrototypeHelper' => 'action_pack/helpers/ak_prototype_helper.php', 'AkScriptaculousHelper' => 'action_pack/helpers/ak_scriptaculous_helper.php', 'AkTextHelper' => 'action_pack/helpers/ak_text_helper.php', 'AkUrlHelper' => 'action_pack/helpers/ak_url_helper.php', 'AkXmlHelper' => 'action_pack/helpers/ak_xml_helper.php', 'AkHelperLoader' => 'action_pack/helper_loader.php', 'AkPaginator' => 'action_pack/pagination.php', 'AkPhpCodeSanitizer' => 'action_pack/php_code_sanitizer.php', 'AkPhpTemplateHandler' => 'action_pack/php_template_handler.php', 'AkRequest' => 'action_pack/request.php', 'AkResponse' => 'action_pack/response.php', 'AkRouter' => 'action_pack/router/base.php', 'AkDynamicSegment' => 'action_pack/router/dynamic_segment.php', 'AkLangSegment' => 'action_pack/router/lang_segment.php', 'AkRoute' => 'action_pack/router/route.php', 'AkRouterConfig' => 'action_pack/router/router_config.php', 'AkRouterHelper' => 'action_pack/router/router_helper.php', 'AkSegment' => 'action_pack/router/segment.php', 'AkStaticSegment' => 'action_pack/router/static_segment.php', 'AkUrl' => 'action_pack/router/url.php', 'AkUrlWriter' => 'action_pack/router/url_writer.php', 'AkVariableSegment' => 'action_pack/router/variable_segment.php', 'AkWildcardSegment' => 'action_pack/router/wildcard_segment.php', 'AkResource' => 'action_pack/router/resources.php', 'AkResources' => 'action_pack/router/resources.php', 'AkSingletonResource' => 'action_pack/router/resources.php', 'AkSession' => 'action_pack/session.php', 'AkStream' => 'action_pack/stream.php', 'AkSintags' => 'action_pack/template_engines/sintags/base.php', 'AkSintagsLexer' => 'action_pack/template_engines/sintags/lexer.php', 'AkSintagsParser' => 'action_pack/template_engines/sintags/parser.php', 'AkXhtmlValidator' => 'action_pack/xhtml_validator.php', 'AkActionWebService' => 'action_pack/action_web_service.php', 'AkActionWebserviceApi' => 'action_pack/action_web_service/api.php', 'AkActionWebServiceClient' => 'action_pack/action_web_service/client.php', 'AkActionWebServiceServer' => 'action_pack/action_web_service/server.php', 'AkActiveRecord' => 'active_record/base.php', 'AkDbAdapter' => 'active_record/adapters/base.php', 'AkAssociatedActiveRecord' => 'active_record/associated_active_record.php', 'AkAssociation' => 'active_record/associations/base.php', 'AkBelongsTo' => 'active_record/associations/belongs_to.php', 'AkHasAndBelongsToMany' => 'active_record/associations/has_and_belongs_to_many.php', 'AkHasMany' => 'active_record/associations/has_many.php', 'AkHasOne' => 'active_record/associations/has_one.php', 'AkDbSchemaCache' => 'active_record/database_schema_cache.php', 'AkActiveRecordMock' => 'active_record/mock.php', 'AkObserver' => 'active_record/observer.php', 'AkHttpClient' => 'active_resource/http_client.php', 'AkAdodbCache' => 'active_support/cache/adodb.php', 'AkCache' => 'active_support/cache/base.php', 'AkMemcache' => 'active_support/cache/memcache.php', 'AkColor' => 'active_support/color/base.php', 'AkConsole' => 'active_support/console/base.php', 'AkAnsiColor' => 'active_support/console/ansi.php', 'AkConfig' => 'active_support/config/base.php', 'AkClassExtender' => 'active_support/core/class_extender.php', 'AkDebug' => 'active_support/core/debug.php', 'AkLazyObject' => 'active_support/core/lazy_object.php', 'AkArray' => 'active_support/core/types/array.php', 'AkType' => 'active_support/core/types/base.php', 'AkDate' => 'active_support/core/types/date.php', 'AkMimeType' => 'active_support/core/types/mime.php', 'AkNumber' => 'active_support/core/types/number.php', 'AkString' => 'active_support/core/types/string.php', 'AkTime' => 'active_support/core/types/time.php', 'AkFileSystem' => 'active_support/file_system/base.php', 'AkelosGenerator' => 'active_support/generator.php', 'AkCharset' => 'active_support/i18n/charset/base.php', 'AkCountries' => 'active_support/i18n/countries.php', 'AkLocaleManager' => 'active_support/i18n/locale_manager.php', 'AkTimeZone' => 'active_support/i18n/time_zone.php', 'AkImage' => 'active_support/image/base.php', 'AkImageColorScheme' => 'active_support/image/color_scheme.php', 'AkImageFilter' => 'active_support/image/filters/base.php', 'AkLogger' => 'active_support/logger.php', 'AkInstaller' => 'active_support/migrations/installer.php', 'AkBaseModel' => 'active_support/models/base.php', 'AkModelExtenssion' => 'active_support/models/base.php', 'AkFtp' => 'active_support/network/ftp.php', 'AkPlugin' => 'active_support/plugin/base.php', 'AkPluginLoader' => 'active_support/plugin/base.php', 'AkPluginInstaller' => 'active_support/plugin/installer.php', 'AkPluginManager' => 'active_support/plugin/manager.php', 'AkProfiler' => 'active_support/profiler.php', 'AkReflection' => 'active_support/reflection/base.php', 'AkReflectionClass' => 'active_support/reflection/class.php', 'AkReflectionDocBlock' => 'active_support/reflection/doc_block.php', 'AkReflectionFile' => 'active_support/reflection/file.php', 'AkReflectionFunction' => 'active_support/reflection/function.php', 'AkReflectionMethod' => 'active_support/reflection/method.php', 'AkTestApplication' => 'active_support/testing/application.php', 'AkelosTextReporter' => 'active_support/testing/base.php', 'AkelosVerboseTextReporter' => 'active_support/testing/base.php', 'AkXUnitXmlReporter' => 'active_support/testing/base.php', 'AkUnitTest' => 'active_support/testing/base.php', 'AkWebTestCase' => 'active_support/testing/base.php', 'AkTestDispatcher' => 'active_support/testing/dispatcher.php', 'AkTestRequest' => 'active_support/testing/request.php', 'AkTestResponse' => 'active_support/testing/response.php', 'AkUnitTestSuite' => 'active_support/testing/suite.php', 'AkRouterUnitTest' => 'active_support/testing/router.php', 'AkRouteUnitTest' => 'active_support/testing/route.php', 'AkControllerUnitTest' => 'active_support/testing/controller.php', 'AkInflector' => 'active_support/text/inflector.php', 'AkLexer' => 'active_support/text/lexer.php', 'AkError' => 'active_support/error_handlers/base.php', 'AkActiveDocument' => 'active_document/base.php', 'AkOdbAdapter' => 'active_document/adapters/base.php');
    }
    if (isset($lib_paths[$name])) {
        include AK_FRAMEWORK_DIR . DS . $lib_paths[$name];
        return;
    }
    if (isset($app_paths[$name])) {
        $file_path = AkConfig::getDir('app') . DS . $app_paths[$name];
        if (file_exists($file_path)) {
            include $file_path;
            return;
        }
    }
    if (isset($paths[$name])) {
        include $paths[$name];
    } elseif (file_exists(DS . $name . '.php')) {
        include DS . $name . '.php';
    } else {
        $underscored_name = AkInflector::underscore($name);
        if (!Ak::import($name)) {
            if (strstr($name, 'Helper')) {
                $file_path = AkConfig::getDir('helpers') . DS . $underscored_name . '.php';
                if (!file_exists($file_path)) {
                    $file_path = AK_ACTION_PACK_DIR . DS . 'helpers' . DS . $underscored_name . '.php';
                    if (!file_exists($file_path)) {
                        $file_path = AK_ACTION_PACK_DIR . DS . 'helpers' . DS . 'ak_' . $underscored_name . '.php';
                        if (include_once $file_path) {
                            eval('class ' . $name . ' extends Ak' . $name . '{}');
                            return;
                        }
                    }
                }
            } elseif (strstr($name, 'Installer')) {
                $file_path = AkConfig::getDir('app_installers') . DS . $underscored_name . '.php';
            } elseif (strstr($name, 'Controller')) {
                $file_path = AkInflector::toControllerFilename($name);
            }
        }
    }
    if (isset($file_path) && file_exists($file_path)) {
        include $file_path;
    }
}
Пример #23
0
 public function hasCollisions()
 {
     $this->collisions = array();
     $this->generator_name = AkInflector::underscore($this->generator_name);
     $this->class_name = AK_APP_LIB_DIR . DS . 'generators' . DS . $this->generator_name;
     $this->destination_path = AK_APP_LIB_DIR . DS . 'generators' . DS . $this->generator_name;
     if (is_dir($this->destination_path)) {
         $this->collisions[] = Ak::t('%path already exists', array('%path' => $this->destination_path));
     }
     return count($this->collisions) > 0;
 }
Пример #24
0
 public function &getDatabase($database_name = null)
 {
     $database_name = AkInflector::underscore(empty($database_name) ? $this->getOption('database') : $database_name);
     if (isset($this->_MongoDatabases[$this->_connetion_signature][$database_name])) {
         return $this->_MongoDatabases[$this->_connetion_signature][$database_name];
     }
     $Database = $this->getConnection()->selectDB($database_name);
     $this->_authenticateDatabase($Database);
     $this->_MongoDatabases[$this->_connetion_signature][$database_name] = $Database;
     return $Database;
 }
Пример #25
0
 public function _linkWebServiceApi($api)
 {
     $api_path = AkInflector::underscore($api);
     if (substr($api_path, -4) != '_api') {
         $api_name_space = $api_path;
         $api_path = $api_path . '_api';
     } else {
         $api_name_space = substr($api_path, 0, -4);
     }
     $api_class_name = AkInflector::camelize($api_path);
     require_once AkConfig::getDir('apis') . DS . $api_path . '.php';
     $this->_apis[$api_name_space] = new $api_class_name();
 }
Пример #26
0
 function _linkWebServiceApi($api)
 {
     $api_path = AkInflector::underscore($api);
     if (substr($api_path, -4) != '_api') {
         $api_name_space = $api_path;
         $api_path = $api_path . '_api';
     } else {
         $api_name_space = substr($api_path, 0, -4);
     }
     $api_class_name = AkInflector::camelize($api_path);
     require_once AK_LIB_DIR . DS . 'AkActionWebService' . DS . 'AkActionWebServiceApi.php';
     require_once AK_APIS_DIR . DS . $api_path . '.php';
     $this->_apis[$api_name_space] =& new $api_class_name();
 }
Пример #27
0
 function installAndIncludeModels($models = array())
 {
     foreach ($models as $model) {
         require_once AK_APP_DIR . DS . 'installers' . DS . AkInflector::underscore($model) . '_installer.php';
         require_once AK_MODELS_DIR . DS . AkInflector::underscore($model) . '.php';
         $installer_name = $model . 'Installer';
         $installer = new $installer_name();
         $installer->uninstall();
         $installer->install();
     }
     if (isset($_SESSION['__activeRecordColumnsSettingsCache'])) {
         unset($_SESSION['__activeRecordColumnsSettingsCache']);
     }
 }
Пример #28
0
 public function generate()
 {
     $this->_preloadPaths();
     $this->save(AkConfig::getDir('app') . DS . $this->controller_path, $this->render('controller'));
     $this->save(AkConfig::getDir('helpers') . DS . $this->underscored_controller_name . "_helper.php", $this->render('helper'));
     $this->save(AkConfig::getDir('test') . DS . 'functional' . DS . $this->controller_test_path, $this->render('functional_test'));
     $this->save(AkConfig::getDir('test') . DS . 'unit' . DS . 'helpers' . DS . $this->underscored_controller_name . "_helper_test.php", $this->render('helper_test'));
     @AkFileSystem::make_dir(AkConfig::getDir('views') . DS . $this->module_path . AkInflector::underscore($this->controller_name), $this->getFileOptions());
     foreach ($this->actions as $action) {
         //$this->action = $action;
         $this->assignVarToTemplate('action', $action);
         $this->assignVarToTemplate('path', 'app' . DS . 'views' . DS . $this->module_path . AkInflector::underscore($this->controller_name) . DS . $action . '.html.tpl');
         $this->save(AkConfig::getDir('views') . DS . $this->module_path . AkInflector::underscore($this->controller_name) . DS . $action . '.html.tpl', $this->render('view'));
     }
 }
Пример #29
0
 function generate()
 {
     $this->_preloadPaths();
     $this->save(AK_APP_DIR . DS . $this->controller_path, $this->render('controller'));
     $this->save(AK_HELPERS_DIR . DS . $this->underscored_controller_name . "_helper.php", $this->render('helper'));
     $this->save(AK_TEST_DIR . DS . 'functional' . DS . $this->controller_path, $this->render('functional_test'));
     $this->save(AK_TEST_DIR . DS . 'fixtures' . DS . 'app' . DS . $this->controller_path, $this->render('fixture'));
     $this->save(AK_TEST_DIR . DS . 'fixtures' . DS . 'app' . DS . 'helpers' . DS . $this->underscored_controller_name . "_helper.php", $this->render('helper_fixture'));
     foreach ((array) @$this->actions as $action) {
         //$this->action = $action;
         $this->assignVarToTemplate('action', $action);
         $this->assignVarToTemplate('path', 'AK_VIEWS_DIR.DS.\'' . AkInflector::underscore($this->class_name) . '/' . $action . '.tpl\'');
         $this->save(AK_VIEWS_DIR . DS . AkInflector::underscore($this->class_name) . DS . $action . '.tpl', $this->render('view'));
     }
 }
Пример #30
0
 public function &addAssociated($association_id, $options = array())
 {
     $default_options = array('class_name' => empty($options['class_name']) ? AkInflector::classify($association_id) : $options['class_name'], 'conditions' => false, 'order' => false, 'include_conditions_when_included' => true, 'include_order_when_included' => true, 'foreign_key' => false, 'dependent' => 'nullify', 'finder_sql' => false, 'counter_sql' => false, 'include' => false, 'instantiate' => false, 'group' => false, 'limit' => false, 'offset' => false, 'handler_name' => strtolower(AkInflector::underscore(AkInflector::singularize($association_id))), 'select' => false);
     $options = array_merge($default_options, $options);
     $options['foreign_key'] = empty($options['foreign_key']) ? AkInflector::underscore($this->Owner->getModelName()) . '_id' : $options['foreign_key'];
     $Collection =& $this->_setCollectionHandler($association_id, $options['handler_name']);
     $Collection->setOptions($association_id, $options);
     $this->addModel($association_id, $Collection);
     if ($options['instantiate']) {
         $associated =& $Collection->load();
     }
     $this->setAssociatedId($association_id, $options['handler_name']);
     $Collection->association_id = $association_id;
     return $Collection;
 }