Ejemplo n.º 1
0
 function _getControllerViews()
 {
     $view_files = Ak::dir(AK_VIEWS_DIR.DS.$this->class_to_clone, array('dirs'=>false));
     foreach ($view_files as $k=>$view_file){
         $view_files[$k] = str_replace('.tpl','',$view_file);
     }
     return $view_files;
 }
Ejemplo n.º 2
0
 public function test_should_get_all_controllers_with_their_actions()
 {
     $available_controllers = (array) Ak::dir(AK_CONTROLLERS_DIR, array('dirs' => false));
     $got = $this->menu_helper->_get_default_full_menu();
     foreach ($available_controllers as $controller_filename) {
         $controller_name = str_replace('_controller.php', '', $controller_filename);
         $this->assertTrue(isset($got[$controller_name]));
     }
     $this->assertTrue(in_array('authenticate', $got['authentication']));
 }
Ejemplo n.º 3
0
 function up_1()
 {
     $this->files = Ak::dir(AK_ADMIN_PLUGIN_FILES_DIR, array('recurse'=> true));
     empty($this->options['force']) ? $this->checkForCollisions($this->files) : null;
     $this->copyAdminFiles();
     echo "\nWe need some details for setting up the admin.\n\n ";
     $this->modifyRoutes();
     $this->relativizeStylesheetPaths();
     $this->runMigration();
     echo "\n\nInstallation completed\n";
 }
Ejemplo n.º 4
0
 function clearAll($environment = AK_ENVIRONMENT)
 {
     $dummy = AkDbSchemaCache::_generateCacheFileName('dummy', $environment);
     $dir = dirname($dummy);
     $files = Ak::dir($dir);
     foreach ($files as $file) {
         if (is_file($dir.DS.$file)) {
             @unlink($dir.DS.$file);
         }
     }
 }
Ejemplo n.º 5
0
 function _getMenuOptionsForControllersInModule($type = 'admin')
 {
     $controllers = (Ak::dir(AK_CONTROLLERS_DIR.DS.$this->_controller->getModuleName(), array('dirs'=>false)));
     sort($controllers);
     $menu_options = array();
     foreach ($controllers as $controller){
         $controller_name = substr($controller,0,-15);
         $menu_options[AkInflector::titleize($controller_name)] = array('id'=>$controller_name, 'url'=> array('controller'=>$controller_name));
     }
     $options_file = $this->_getMenuOptionsFile($type);
     if(!file_exists($options_file)){
         Ak::file_put_contents(AK_CONFIG_DIR.DS.$options_file, Ak::convert('array', 'yaml', array('default'=>$menu_options)));
     }
     return $menu_options;
 }
Ejemplo n.º 6
0
 function _get_default_full_menu()
 {
     $controller_file_names = Ak::dir(AK_CONTROLLERS_DIR, array('files' => false));
     krsort($controller_file_names);
     $menu_options = array();
     foreach ($controller_file_names as $controller_file_name => $options) {
         $controller_file_name = array_pop($options);
         $controller_name = str_replace('.php', '', $controller_file_name);
         if (file_exists(AK_CONTROLLERS_DIR . DS . $controller_file_name)) {
             include_once AK_CONTROLLERS_DIR . DS . $controller_file_name;
             $controller_class_name = AkInflector::classify($controller_name);
             $menu_options[str_replace('_controller', '', $controller_name)] = $this->_get_this_class_methods($controller_class_name);
         }
     }
     return $menu_options;
 }
Ejemplo n.º 7
0
    function AkelosInstaller($options)
    {
        $default_options = array(
        'source' => $this->_absolutePath(dirname(__FILE__).DIRECTORY_SEPARATOR.'..'),
        'force' => false,
        'skip' => false,
        'quiet' => false,
        'public_html' => false,
        'dependencies' => false,
        'version'=>false
        );
        $this->options = array_merge($default_options, $options);
        if (isset($this->options['version']) && $this->options['version']!==false) {
            die(file_get_contents('version.txt')."\n");
        }
        $this->options['directory'] = $this->_absolutePath(@$this->options['directory']);

        if(empty($this->options['directory'])){
            trigger_error('You must supply a valid destination path', E_USER_ERROR);
        }

        $this->source_tree = Ak::dir($this->options['source'],array('dirs'=>true,'recurse'=>true));

        if(empty($this->options['dependencies'])){
            $this->framework_dirs = array('lib', 'vendor', 'test');

            foreach ($this->framework_dirs as $framework_dir){
                foreach ($this->source_tree as $k => $v){
                    if(isset($v[$framework_dir])){
                        unset($this->source_tree[$k]) ;
                    }
                }
            }
        }

        $this->destination_tree = Ak::dir($this->options['directory'],array('dirs'=>true,'recurse'=>true));
    }
Ejemplo n.º 8
0
 function autoInstallExtensions()
 {
     $path = AK_APP_PLUGINS_DIR . DS . $this->plugin_name . DS . 'extensions';
     $extensionFiles = Ak::dir($path, array('recurse' => true));
     foreach ($extensionFiles as $extensionFile) {
         $this->installExtensions('extensions' . DS . $extensionFile);
     }
 }
Ejemplo n.º 9
0
 function getApplicationHelpers()
 {
     $helper_names = array();
     if ($this->app_helpers == 'all') {
         $available_helpers = Ak::dir(AK_HELPERS_DIR, array('dirs' => false));
         $helper_names = array();
         foreach ($available_helpers as $available_helper) {
             $helper_names[AK_HELPERS_DIR . DS . $available_helper] = AkInflector::classify(substr($available_helper, 0, -10));
         }
     } elseif (!empty($this->app_helpers)) {
         foreach (Ak::toArray($this->app_helpers) as $helper_name) {
             $helper_names[AK_HELPERS_DIR . DS . AkInflector::underscore($helper_name) . '_helper.php'] = AkInflector::camelize($helper_name);
         }
     }
     return $helper_names;
 }
Ejemplo n.º 10
0
 /**
  * Loads a list of existing plugins to $this->_available_plugins by inspecting the plugins directory.
  * 
  * @return void   
  * @access private
  */
 function _findPlugins()
 {
     $plugin_dirs = Ak::dir(AK_PLUGINS_DIR, array('dirs' => true, 'files' => false));
     $this->_available_plugins = array();
     foreach ($plugin_dirs as $plugin_dir){
         $plugin_dir = array_pop($plugin_dir);
         if($plugin_dir[0] != '.'){
             $this->_available_plugins[] = $plugin_dir;
         }
     }
 }
Ejemplo n.º 11
0
 function _getAvailableGenerators()
 {
     $generators = array();
     foreach (Ak::dir(AK_SCRIPT_DIR . DS . 'generators', array('files' => false, 'dirs' => true)) as $folder) {
         $generator = array_shift(array_keys($folder));
         if (strstr($generator, '.php')) {
             continue;
         }
         $generators[] = $generator;
     }
     return $generators;
 }
Ejemplo n.º 12
0
 public function _getAvailableTemplates()
 {
     $path = $this->ActionMailer->getTemplatePath();
     if (!isset($templates[$path])) {
         $templates[$path] = array_map('basename', Ak::dir($path, array('dirs' => false)));
     }
     return $templates[$path];
 }
Ejemplo n.º 13
0
$file = AK_APP_DIR . DS . 'installers' . DS . rtrim(join('/', array_map(array('AkInflector', 'underscore'), explode('/', $installer . '/'))), '/') . '_installer.php';
function ak_print_available_installers($files, $preffix = '')
{
    foreach ($files as $k => $file) {
        if (is_string($file)) {
            if (preg_match('/(.*)_installer\\.php$/', $file, $match)) {
                echo ' * ' . $preffix . $match[1] . "\n";
            }
        } else {
            ak_print_available_installers($file, $k . '::');
        }
    }
    echo "\n";
}
if ($installer_class_name == 'Installer') {
    $files = Ak::dir(AK_APP_DIR . DS . 'installers', array('recurse' => true));
    if (empty($files)) {
        echo Ak::t("\n  Could not find installers at %dir  \n", array('%dir' => AK_APP_DIR . DS . 'installers'));
    } else {
        echo Ak::t("\n  You must supply a valid installer name like : \n");
        echo Ak::t("\n  > ./script/migrate my_installer_name install\n\n");
        echo Ak::t("  Available installers are:  \n\n");
        ak_print_available_installers($files);
    }
} elseif (!file_exists($file)) {
    echo Ak::t("\n\n  Could not locate the installer file %file\n\n", array('%file' => $file));
} else {
    require_once $file;
    if (!class_exists($installer_class_name)) {
        echo Ak::t("\n\n  Could not find load the installer. Class doesn't exists\n\n");
    } else {
Ejemplo n.º 14
0
 function up_1()
 {
     $this->files = Ak::dir(AK_SIFR_HELPER_PLUGIN_FILES_DIR, array('recurse' => true));
     empty($this->options['force']) ? $this->checkForCollisions($this->files) : null;
     $this->copySifrHelperFiles();
 }
Ejemplo n.º 15
0
Archivo: Ak.php Proyecto: joeymetal/v1
 function dir($path, $options = array())
 {
     $result = array();
     $path = rtrim($path, '/\\');
     $default_options = array('files' => true, 'dirs' => true, 'recurse' => false);
     $options = array_merge($default_options, $options);
     if (is_file($path)) {
         $result = array($path);
     } elseif (is_dir($path)) {
         if ($id_dir = opendir($path)) {
             while (false !== ($file = readdir($id_dir))) {
                 if ($file != "." && $file != ".." && $file != '.svn') {
                     if (!empty($options['files']) && !is_dir($path . DS . $file)) {
                         $result[] = $file;
                     } elseif (!empty($options['dirs'])) {
                         $result[][$file] = !empty($options['recurse']) ? Ak::dir($path . DS . $file, $options) : $file;
                     }
                 }
             }
             closedir($id_dir);
         }
     }
     return array_reverse($result);
 }
Ejemplo n.º 16
0
 /**
  * Initialize the mailer via the given +method_name+. The body will be
  * rendered and a new AkMail object created.
  */
 function &create($method_name, $parameters, $content_type = '')
 {
     $args = func_get_args();
     $method_name = array_shift($args);
     $this->_initializeDefaults($method_name);
     if (method_exists($this, $method_name)) {
         call_user_func_array(array(&$this, $method_name), $args);
     } else {
         trigger_error(Ak::t('Could not find the method %method on the model %model', array('%method' => $method_name, '%model' => $this->getModelName())), E_USER_ERROR);
     }
     $parameters = @array_shift($args);
     $content_type = @array_shift($args);
     $Mail =& $this->_MailDriver;
     if (!is_string($Mail->body)) {
         if (empty($Mail->parts)) {
             $Mail->_avoid_multipart_propagation = true;
             $templates = array_map('basename', Ak::dir($this->getTemplatePath() . DS, array('dirs' => false)));
             foreach ($templates as $template_name) {
                 if (preg_match('/^([^\\.]+)\\.([^\\.]+\\.[^\\.]+)\\.(tpl)$/', $template_name, $match)) {
                     if ($this->template == $match[1]) {
                         $content_type = str_replace('.', '/', $match[2]);
                         $Mail->setPart(array('content_type' => $content_type, 'disposition' => 'inline', 'charset' => @$Mail->charset, 'body' => $this->renderMessage($this->getTemplatePath() . DS . $template_name, $Mail->body)));
                     }
                 }
             }
             if (!empty($Mail->parts)) {
                 $Mail->content_type = 'multipart/alternative';
                 $Mail->parts = $Mail->getSortedParts($Mail->parts, $Mail->implicit_parts_order);
             }
         }
         $template_exists = empty($Mail->parts);
         if (!$template_exists) {
             $templates = array_map('basename', Ak::dir($this->getTemplatePath(), array('dirs' => false)));
             foreach ($templates as $template) {
                 $parts = explode('.', $template);
                 if (count($parts) == 2 && $parts[0] == $this->template) {
                     $template_exists = true;
                 }
             }
         }
         if ($template_exists) {
             $Mail->setBody($this->renderMessage($this->template, $Mail->body));
         }
         if (!empty($Mail->parts) && is_string($Mail->body)) {
             array_unshift($Mail->parts, array('charset' => $Mail->charset, 'body' => $Mail->body));
             $this->body = null;
         }
     }
     $Mail->setMimeVersion(empty($Mail->mime_version) && !empty($Mail->parts) ? '1.0' : $Mail->mime_version);
     $this->Mail =& $Mail;
     return $Mail;
 }
Ejemplo n.º 17
0
 public function test_dir_should_not_recurse_when_set_to_false()
 {
     $files_and_dirs = Ak::dir(AK_LIB_DIR . DS . 'AkActionView', array('dirs' => true, 'recurse' => false));
     foreach ($files_and_dirs as $k => $file_or_dir) {
         if (is_array($file_or_dir)) {
             $this->assertEqual(count($files_and_dirs[$k]), 1);
         }
     }
 }
Ejemplo n.º 18
0
<?php

defined('ALL_TESTS_CALL') ? null : define("ALL_TESTS_CALL", true);
defined('AK_ENABLE_PROFILER') ? null : define('AK_ENABLE_PROFILER', true);
defined('AK_TEST_DATABASE_ON') ? null : define('AK_TEST_DATABASE_ON', true);
require_once dirname(__FILE__) . '/../../fixtures/config/config.php';
if (!defined('ALL_TESTS_RUNNER') && empty($test)) {
    $test = new GroupTest('Akelos Framework Active Record Tests');
    define('ALL_TESTS_RUNNER', false);
    @session_start();
}
//these partials are not refactored yet. so they must be run in sequence!
$partial_tests = array('_AkActiveRecord_1.php', '_AkActiveRecord_2.php', '_AkActiveRecord_3.php');
foreach ($partial_tests as $partial_test) {
    $test->addTestFile(AK_LIB_TESTS_DIRECTORY . DS . 'AkActiveRecord' . DS . $partial_test);
}
foreach (Ak::dir(AK_LIB_TESTS_DIRECTORY . DS . 'AkActiveRecord') as $active_record_test) {
    if (!is_array($active_record_test) && !in_array($active_record_test, $partial_tests)) {
        if (!ALL_TESTS_RUNNER || $active_record_test[0] == '_') {
            $test->addTestFile(AK_LIB_TESTS_DIRECTORY . DS . 'AkActiveRecord' . DS . $active_record_test);
        }
    }
}
if (!ALL_TESTS_RUNNER) {
    if (TextReporter::inCli()) {
        exit($test->run(new TextReporter()) ? 0 : 1);
    }
    $test->run(new HtmlReporter());
}
Ejemplo n.º 19
0
 function _getGeneratorsInsidePath($path)
 {
     $generators = array();
     if(is_dir($path)){
         foreach (Ak::dir($path,array('files'=>false,'dirs'=>true)) as $folder){
             $generator = array_shift(array_keys($folder));
             if(strstr($generator,'.php')){
                 continue;
             }
             $generators[$path.DS.$generator.DS.$generator.'_generator.php'] = $generator;
         }
     }
     return $generators;
 }