Author: : Vyacheslav Oliyanchuk (miripiruni)
Esempio n. 1
0
 function tool($argc, $argv)
 {
     $this->init($argc, $argv);
     if ($this->argc == 1 || in_array($this->argv[1], array('--help', '-help', '-h', '-?'))) {
         $this->man();
         exit(1);
     } else {
         if ($this->in != null) {
             if ($this->sort) {
                 $sort = file_get_contents($this->sort);
             } else {
                 $sort = 'zen';
             }
             $c = new csscomb('', false, $sort);
             $mime_type = '';
             if (is_file($this->in)) {
                 if (function_exists('finfo_open')) {
                     $finfo = finfo_open(FILEINFO_MIME_TYPE);
                     $mime_type = finfo_file($finfo, $this->in);
                     finfo_close($finfo);
                 } else {
                     $mime_type = mime_content_type($this->in);
                 }
             }
             if (is_dir($this->in)) {
                 $files = $this->getArrayOfCssFilenames($this->in);
                 foreach ($files as $file) {
                     echo "Sorting " . $file . "...\n";
                     $result = $c->csscomb(file_get_contents($file), false, $sort);
                     file_put_contents($file, $result);
                 }
             } elseif (is_file($this->in) && preg_match('/^text/', $mime_type)) {
                 echo "Sorting " . $this->in . "...\n";
                 $result = $c->csscomb(file_get_contents($this->in), false, $sort);
                 if ($this->out == null) {
                     $this->out = $this->in;
                 }
                 file_put_contents($this->out, $result);
             } elseif (!preg_match('/^text/', $mime_type)) {
                 echo "Wrong input file mime type.";
                 exit(1);
             } else {
                 echo "Error with input file.";
                 exit(1);
             }
             echo "Done.\n";
             exit(0);
         } else {
             echo "No input file\n";
             $this->man();
             exit(1);
         }
     }
 }
Esempio n. 2
0
#!/usr/bin/php
<?php 
/**
 * CSScomb
 * @version: 2.11 (build 4d71dea-1210271349)
 * @author: Vyacheslav Oliyanchuk (miripiruni)
 * @web: http://csscomb.com/
 */
require_once getenv('TM_BUNDLE_SUPPORT') . '/csscomb.php';
$input = file_get_contents('php://stdin');
$c = new csscomb();
echo $c->csscomb($input);
Esempio n. 3
0
function tool($argc, $argv){
    $this->init($argc, $argv);

    if($this->argc == 1 || in_array($this->argv[1], array('--help', '-help', '-h', '-?'))) {
        $this->man();
        exit(1);
    }
    else {

        if($this->in != null) {

            $c = new csscomb('', false, 'yandex');

            if(is_dir($this->in)) {
                $files = $this->getArrayOfCssFilenames($this->in);

                foreach($files as $file) {
                    echo "Sorting ".$file."...\n";
                    $result = $c->csscomb(file_get_contents($file));
                    file_put_contents($file, $result);
                }
            }
            elseif($this->out != null){
                echo "Sorting ".$this->in."...\n";
                if (preg_match('/^text/', mime_content_type($this->in))) {
                    $result = $c->csscomb(file_get_contents($this->in));
                    file_put_contents($this->out, $result);
                } else {
                    echo("Wrong input file mime type.");
                    exit(1);
                }
            }
            echo "Done.\n";
            exit(0);


        } else {
            echo "No input file\n";
            $this->man();
            exit(1);
        }
    }
}
Esempio n. 4
0
<?php

/* Обертка для вызова CSScomb */
$csscomb = new csscomb();
$sort_type = is_file($argv[2]) ? file_get_contents($argv[2]) : $argv[2];
$input = $csscomb->csscomb(file_get_contents($argv[1]), false, $sort_type);
file_put_contents($argv[1], $input);
Esempio n. 5
0
<?php

/* Обертка для вызова CSScomb из WebStorm/IntelliJ IDEA */
$csscomb = new csscomb();
if (is_dir($argv[1])) {
    foreach (glob("{$argv[1]}/*.css") as $path) {
        $cssfiles[] = $path;
    }
}
foreach (isset($cssfiles) ? $cssfiles : array($argv[1]) as $path) {
    file_put_contents($path, $csscomb->csscomb(file_get_contents($path), false, 'yandex'));
}
Esempio n. 6
0
<?php

if ($_SERVER['HTTP_REFERER'] != 'http://csscomb.com/online/' and $_SERVER['HTTP_REFERER'] != 'http://dev.csscomb.ru/online/' and $_SERVER['HTTP_REFERER'] != 'http://dev.csscomb.com/online/' and $_SERVER['HTTP_REFERER'] != 'http://csscomb.ru/online/') {
    die('Error 0');
}
require_once '../src/csscomb.php';
if ($_POST['code'] and $_POST['code'] != '') {
    $c = new csscomb();
    if ($_POST['order'] and $_POST['order'] != '') {
        $order = stripslashes($_POST['order']);
        echo $c->csscomb($_POST['code'], false, $order);
    } else {
        echo $c->csscomb($_POST['code'], false);
    }
}
if ($_POST['get_order'] and $_POST['get_order'] != '') {
    $c = new csscomb();
    echo $c->get_sort_order($_POST['get_order']);
}
<?php

require_once 'csscomb.php';
/* Обертка для вызова CSScomb */
$csscomb = new csscomb();
/*$sort_type = is_file($argv[2]) ? file_get_contents($argv[2]) : $argv[2];*/
$input = $csscomb->csscomb($argv[1], false, $argv[2]);
echo $input;
Esempio n. 8
0
<?php

$title['en'] = $h1['en'] = 'Tests';
$title['ru'] = $h1['ru'] = 'Тесты';
$module = 'tests';
require_once '../common/header.php';
require_once 'cases.php';
require_once '../src/csscomb.php';
$c = new csscomb();
$test_count = $errors = $warnings = 0;
$case_groups_nav = $tests_list = '';
// Строим навигацию по группам
$case_groups_nav .= '<div class="groups-nav"><h2>' . $loc['tests-category'] . '</h2><ol>';
foreach ($case_groups as $group_key => $group) {
    $case_groups_nav .= '<li><a href="#' . $group["group-id"] . '">';
    if ($lang == 'en') {
        $case_groups_nav .= $group['group-name-en'];
    } else {
        $case_groups_nav .= $group['group-name'];
    }
    $case_groups_nav .= '</a></li>';
}
$case_groups_nav .= '</ol></div>';
// Строим список тестов
foreach ($case_groups as $group_key => $group) {
    $tests_list .= '<h3 id="' . $group["group-id"] . '">' . ($group_key + 1) . '. ';
    if ($lang == 'en') {
        $tests_list .= $group['group-name-en'];
    } else {
        $tests_list .= $group['group-name'];
    }
Esempio n. 9
0
#!/usr/bin/env php
<?php 
/**
 * CSScomb 2.11 (build 3ded73c-1208080145)
 * http://CSScomb.com
 * http://twitter.com/CSScomb
 */
require dirname(__FILE__) . '/../../SharedSupport/csscomb/csscomb.php';
$input = file_get_contents('php://stdin');
$c = new csscomb();
echo trim($c->csscomb($input), "\n\r");
Esempio n. 10
0
<?php

require_once 'csscomb.php';
/* Обертка для вызова CSScomb */
$csscomb = new csscomb();
/*$sort_type = is_file($argv[2]) ? file_get_contents($argv[2]) : $argv[2];*/
$input = $csscomb->csscomb($argv[1], false, null);
echo $input;