Exemplo n.º 1
0
    public function hasCollisions()
    {
        $this->collisions = array();
        $user_answer = 5;
        foreach (array_values($this->files) as $file_name){
            if($user_answer != 3 && file_exists($file_name)){
                if($user_answer == 4){
                    $this->_skip_files[] = $file_name;
                    continue;
                }
                $message = Ak::t('%file_name file already exists',array('%file_name'=>$file_name));
                $user_answer = (int)AkInstaller::promptUserVar($message."\n".
                "Would you like to:\n".
                " 1) overwrite file\n".
                " 2) keep existing file\n".
                " 3) overwrite all\n".
                " 4) keep all\n".
                " 5) abort\n", array('default' => 5));

                if($user_answer == 2 || $user_answer == 4){
                    $this->_skip_files[] = $file_name;
                }elseif($user_answer == 5){
                    die("Aborted\n");
                }
            }
        }
        return count($this->collisions) > 0;
    }
Exemplo n.º 2
0
function prompt_var($question, $default_value = null, $cli_value = null)
{
    global $options;
    if (empty($options['interactive']) && isset($cli_value)) {
        return $cli_value;
    } else {
        return AkInstaller::promptUserVar($question, array('default' => $default_value, 'optional' => true));
    }
}
Exemplo n.º 3
0
 public function generate()
 {
     $Installer = new AkInstaller();
     $vars['github'] = $Installer->promptUserVar('Github user and project (optional) [user project]', array('optional' => true, 'default' => false));
     if (!empty($vars['github'])) {
         list($user, $project) = explode(' ', $vars['github'] . ' ');
         //$vars['git'] = "git@github.com:$user/$project.git";
         $vars['git'] = "git://github.com/{$user}/{$project}.git";
         $vars['github'] = "http://github.com/{$user}/{$project}/";
     }
     if (empty($vars['git'])) {
         $vars['git'] = $Installer->promptUserVar('Git repository (git@git.example.com:repository_name.git)');
     }
     $vars['email'] = $Installer->promptUserVar('Notification email');
     foreach ($vars as $k => $v) {
         $this->assignVarToTemplate($k, $v);
     }
     $this->save($this->destination_path . DS . 'config.xml', $this->render('config'));
     $this->save($this->destination_path . DS . 'nextBuildNumber', $this->render('nextBuildNumber'));
     @mkdir($this->destination_path . DS . 'builds');
     @mkdir($this->destination_path . DS . 'workspace');
 }
Exemplo n.º 4
0
    function relativizeStylesheetPaths()
    {
        $url_suffix = AkInstaller::promptUserVar('The admin plugin comes with some fancy CSS background images.

Your aplication might be accesible at /myapp, 
and your images folder might be at /myapp/public

Insert the relative path where your images folder is
so you don\'t need to manually edit the CSS files', array('default' => '/'));
        $url_suffix = trim(preg_replace('/\\/?images\\/admin\\/?$/', '', $url_suffix), '/');
        if (!empty($url_suffix)) {
            $stylesheets = array('admin/admin', 'admin/menu');
            foreach ($stylesheets as $stylesheet) {
                $filename = AK_PUBLIC_DIR . DS . 'stylesheets' . DS . $stylesheet . '.css';
                $relativized_css = preg_replace("/url\\((\\'|\")?\\/images/", "url(\$1/{$url_suffix}/images", @Ak::file_get_contents($filename));
                !empty($relativized_css) && @Ak::file_put_contents($filename, $relativized_css);
            }
        }
    }
Exemplo n.º 5
0
 function _checkUninstallDependencies()
 {
     $dependencyFile = AK_PLUGINS_DIR . DS . $this->plugin_name . DS . 'dependent_plugins';
     if (file_exists($dependencyFile)) {
         $dependendPlugins = file($dependencyFile);
         if (!empty($dependendPlugins)) {
             if (empty($this->options['force'])) {
                 echo "\n";
                 echo Ak::t("The following %plugin %dependent depend on the plugin you are about to uninstall.", array('%plugin' => AkT('plugin', 'quantify(' . count($dependendPlugins) . ')'), '%dependent' => AkT($dependendPlugins, 'toSentence')));
                 echo Ak::t("Please uninstall the dependent %plugin first.", array('%plugin' => AkT('plugin', 'quantify(' . count($dependendPlugins) . ')')));
                 echo "\n";
                 $this->transactionFail();
                 die;
             } else {
                 echo "\n";
                 echo Ak::t("The following %plugin %dependent depend on the plugin you are about to uninstall.", array('%plugin' => AkT('plugin', 'quantify(' . count($dependendPlugins) . ')'), '%dependent' => AkT($dependendPlugins, 'toSentence')));
                 echo "\n";
                 $uninstall = AkInstaller::promptUserVar('Are you sure you want to continue uninstalling (Answer with Yes)? The other plugins will malfunction.', array('default' => 'N'));
                 if ($uninstall != 'Yes') {
                     echo Ak::t('Uninstall cancelled.');
                     echo "\n";
                     $this->transactionFail();
                     die;
                 } else {
                     return true;
                 }
             }
         }
         return true;
     }
 }
Exemplo n.º 6
0
    /**
     * Promts for a variable on console scripts
     */
    function promptUserVar($message, $options = array())
    {
        $f = fopen("php://stdin","r");
        $default_options = array(
        'default' => null,
        'optional' => false,
        );

        $options = array_merge($default_options, $options);

        echo "\n".$message.(empty($options['default'])?'': ' ['.$options['default'].']').': ';
        $user_input = fgets($f, 25600);
        $value = trim($user_input,"\n\r\t ");
        $value = empty($value) ? $options['default'] : $value;
        if(empty($value) && empty($options['optional'])){
            echo "\n\nThis setting is not optional.";
            fclose($f);
            return AkInstaller::promptUserVar($message, $options);
        }
        fclose($f);
        return empty($value) ? $options['default'] : $value;
    }
Exemplo n.º 7
0
<?php

error_reporting(E_ALL);
defined('DS') ? null : define('DS', DIRECTORY_SEPARATOR);
require_once(dirname(__FILE__).str_repeat(DS.'..', 5).DS.'test'.DS.'fixtures'.DS.'config'.DS.'config.php');
require_once(AK_LIB_DIR.DS.'AkActionView'.DS.'AkActionViewHelper.php');

require_once(AK_LIB_DIR.DS.'AkInstaller.php');


!defined('AK_AKISMET_API_KEY') && define('AK_AKISMET_API_KEY', (!empty($argv[1])?$argv[1]:AkInstaller::promptUserVar('Akismet API key')));
!defined('AK_AKISMET_SITE_URL') && define('AK_AKISMET_SITE_URL', (!empty($argv[2])?$argv[2]:AkInstaller::promptUserVar('Akismet site URL')));

require_once(dirname(__FILE__).DS.'..'.DS.'lib'.DS.'akismet_helper.php');

class AkismetHelperTestCase extends AkUnitTest
{
    function test_setup()
    {
        $this->akismet_helper =& new AkismetHelper();
    }

    function test_should_verify_key()
    {
        $this->assertTrue($this->akismet_helper->verifyKey());
    }

    function test_should_detect_spam()
    {
        $this->assertTrue($this->akismet_helper->isSpam(
        'this author triggers known spam' , array(
Exemplo n.º 8
0
<?php

# This file is part of the Akelos Framework
# (Copyright) 2004-2010 Bermi Ferrer bermi a t bermilabs com
# See LICENSE and CREDITS for details
$Installer = new AkInstaller();
$Installer->copyFilesIntoApp(dirname(__FILE__) . DS . 'website_files', array('relative_url' => $Installer->promptUserVar("Relative url path for serving images on CSS files\n    (ie. /public /akelos/public or /)\n hit enter if your application is served from the base of hostname\n", '/')));
echo "\nYou can now browse your documentation from localhost at: \n\n    " . AK_SITE_URL . "/docs\n\nPlease configure access settings by editing docs_controller.php\n";