Exemplo n.º 1
0
 public function testOrderDesc()
 {
     $this->assertTrue(CComparator::orderDesc(u("Hello there!"), u("Hello there!")) == 0);
     $this->assertTrue(CComparator::orderDesc(u("A"), u("B")) > 0);
     $this->assertTrue(CComparator::orderDesc(u("C"), u("B")) < 0);
     $this->assertTrue(CComparator::orderDesc(u("¡Hola señor!"), u("¡Hola señor!")) == 0);
     $this->assertTrue(CComparator::orderDesc(u("A"), u("B")) > 0);
     $this->assertTrue(CComparator::orderDesc(u("C"), u("B")) < 0);
     $this->assertTrue(CComparator::orderDesc(a("a", "b", "c"), a("a", "b", "c")) == 0);
     $this->assertTrue(CComparator::orderDesc(a("b", "b", "c"), a("a", "b", "c")) < 0);
     $this->assertTrue(CComparator::orderDesc(m(["one" => "a", "two" => "b", "three" => "c"]), m(["one" => "a", "two" => "b", "three" => "c"])) == 0);
     $this->assertTrue(CComparator::orderDesc(m(["one" => "b", "two" => "b", "three" => "c"]), m(["one" => "a", "two" => "b", "three" => "c"])) < 0);
     $this->assertTrue(CComparator::orderDesc(CTime::fromString("11/5/1955 12:00:00 PST"), CTime::fromString("11/5/1955 12:00:00 PST")) == 0);
     $this->assertTrue(CComparator::orderDesc(CTime::fromString("11/5/1955 12:00:00 PST"), CTime::fromString("11/5/1985 12:00:00 PST")) > 0);
     $this->assertTrue(CComparator::orderDesc(CTime::fromString("11/5/1985 12:00:01 PST"), CTime::fromString("11/5/1985 12:00:00 PST")) < 0);
     $this->assertTrue(CComparator::orderDesc(true, true) == 0);
     $this->assertTrue(CComparator::orderDesc(false, true) > 0);
     $this->assertTrue(CComparator::orderDesc(true, false) < 0);
     $this->assertTrue(CComparator::orderDesc(1234, 1234) == 0);
     $this->assertTrue(CComparator::orderDesc(1234, 5678) > 0);
     $this->assertTrue(CComparator::orderDesc(5678, 1234) < 0);
     $this->assertTrue(CComparator::orderDesc(12.34, 12.34) == 0);
     $this->assertTrue(CComparator::orderDesc(12.34, 56.78) > 0);
     $this->assertTrue(CComparator::orderDesc(56.78, 12.34) < 0);
     $this->assertTrue(CComparator::orderDesc(null, null) == 0);
     $this->assertTrue(CComparator::orderDesc("Hello there!", "Hello there!") == 0);
     $this->assertTrue(CComparator::orderDesc("A", "B") > 0);
     $this->assertTrue(CComparator::orderDesc("C", "B") < 0);
     $this->assertTrue(CComparator::orderDesc(CArray::fromElements("a", "b", "c"), CArray::fromElements("a", "b", "c")) == 0);
     $this->assertTrue(CComparator::orderDesc(CArray::fromElements("a", "b", "c"), CArray::fromElements("b", "b", "c")) > 0);
     $this->assertTrue(CComparator::orderDesc(CArray::fromElements("b", "b", "c"), CArray::fromElements("a", "b", "c")) < 0);
     $this->assertTrue(CComparator::orderDesc(["one" => "a", "two" => "b", "three" => "c"], ["one" => "a", "two" => "b", "three" => "c"]) == 0);
     $this->assertTrue(CComparator::orderDesc(["one" => "a", "two" => "b", "three" => "c"], ["one" => "b", "two" => "b", "three" => "c"]) > 0);
     $this->assertTrue(CComparator::orderDesc(["one" => "b", "two" => "b", "three" => "c"], ["one" => "a", "two" => "b", "three" => "c"]) < 0);
 }
Exemplo n.º 2
0
 function avatar($id)
 {
     $this->autoRender = false;
     App::import('Component', 'File');
     $file = new FileComponent();
     if (!is_dir(PRODUCTIMAGES . DS . 'tmp')) {
         $file->makeDir(PRODUCTIMAGES . DS . 'tmp');
     } else {
         $oldies = glob(PRODUCTIMAGES . DS . 'tmp' . DS . '*');
         foreach ($oldies as $o) {
             unlink($o);
         }
     }
     if (!empty($this->params['form']['Filedata'])) {
         if (strpos(strtolower(env('HTTP_USER_AGENT')), 'flash') === false || !$this->RequestHandler->isPost()) {
             exit;
         }
     }
     if (!empty($this->params['form']['Filedata'])) {
         $tmp = $this->params['form']['Filedata'];
         $ext = $file->returnExt($this->params['form']['Filedata']['name']);
         $fn = 'original.' . $ext;
         $the_temp = $this->params['form']['Filedata']['tmp_name'];
         $temp_path = PRODUCTIMAGES . DS . 'tmp' . DS . $fn;
         if (!is_dir(dirname($temp_path))) {
             $file->makeDir(dirname($temp_path));
         }
         if (in_array($ext, a('jpg', 'jpeg', 'jpe', 'gif', 'png'))) {
             if (is_uploaded_file($the_temp)) {
                 move_uploaded_file($the_temp, $temp_path);
             }
         }
     }
     exit(' ');
 }
Exemplo n.º 3
0
/**
 * Sets and shows an alert
 *
 * @param string  $message
 * @param string  $type = "Error"
 * @param boolean $URL = NULL
 * @return string value
 */
function getAlert($message, $type = "error", $URL = NULL)
{
    if (!is_null($URL)) {
        $message = a(__(_($message)), encode($URL), TRUE);
    }
    if ($type === "error") {
        return '<div id="alert-message" class="alert alert-error">
    				<a class="close">×</a>
					' . __(_($message)) . '
				</div>';
    } elseif ($type === "success") {
        unset($_POST);
        return '<div id="alert-message" class="alert alert-success">
    				<a class="close">×</a>
					' . __(_($message)) . '
				</div>';
    } elseif ($type === "warning") {
        return '<div id="alert-message" class="alert alert-warning">
    				<a class="close">×</a>
					' . __(_($message)) . '
				</div>';
    } elseif ($type === "notice") {
        return '<div id="alert-message" class="alert alert-info">
    				<a class="close">×</a>
					' . __(_($message)) . '
				</div>';
    }
}
 function testBeforeRender()
 {
     $params = array('foo' => 'bar', 'baz' => array(1, 2, 3));
     $this->_init($params);
     $this->p->expectOnce('options', a(array('url' => array('?' => $params))));
     $this->h->beforeRender();
 }
Exemplo n.º 5
0
 public function testAddField()
 {
     $urlQuery = new CUrlQuery();
     $urlQuery->addField("name0", "value");
     $urlQuery->addField("name1", true);
     $urlQuery->addField("name2", 1234);
     $urlQuery->addField("name3", 56.78);
     $this->assertTrue($urlQuery->queryString()->equals("name0=value&name1=1&name2=1234&name3=56.78"));
     $urlQuery = new CUrlQuery("name0=value0&name1=value1");
     $urlQuery->addField("name2", "value2");
     $this->assertTrue($urlQuery->queryString()->equals("name0=value0&name1=value1&name2=value2"));
     $urlQuery = new CUrlQuery("name0=value0&name1=value1");
     $urlQuery->addField("name2", a("elem0", "elem1"));
     $this->assertTrue($urlQuery->queryString()->equals("name0=value0&name1=value1&name2[]=elem0&name2[]=elem1"));
     $urlQuery = new CUrlQuery("name0=value0&name1=value1");
     $urlQuery->addField("name2", m(["key0" => "value0", "key1" => "value1"]));
     $this->assertTrue($urlQuery->queryString()->equals("name0=value0&name1=value1&name2[key0]=value0&name2[key1]=value1"));
     $urlQuery = new CUrlQuery("name0=value0&name1=value1");
     $urlQuery->addField("name2", a(true, false));
     $this->assertTrue($urlQuery->queryString()->equals("name0=value0&name1=value1&name2[]=1&name2[]=0"));
     $urlQuery = new CUrlQuery("name0=value0&name1=value1");
     $urlQuery->addField("name2", a(1234, 5678));
     $this->assertTrue($urlQuery->queryString()->equals("name0=value0&name1=value1&name2[]=1234&name2[]=5678"));
     $urlQuery = new CUrlQuery("name0=value0&name1=value1");
     $urlQuery->addField("name2", a(12.34, 56.78));
     $this->assertTrue($urlQuery->queryString()->equals("name0=value0&name1=value1&name2[]=12.34&name2[]=56.78"));
     $urlQuery = new CUrlQuery();
     $urlQuery->addField("arr", a("one", "two"));
     $urlQuery->addField("map", m(["key0" => "one", "key1" => a("one", "two")]));
     $this->assertTrue($urlQuery->queryString()->equals("arr[]=one&arr[]=two&map[key0]=one&map[key1][]=one&map[key1][]=two"));
 }
Exemplo n.º 6
0
/**
 * @author Tõnis, Kaia * 
 * @param number $yks = 1
 * @param number $kaks = 1
 * @return string 
 */
function a($yks, $kaks)
{
    $c = 'B1234566';
    // muutuja ja väärtus
    $d = '<br />' . 'EHEE' . '<br />';
    // muutuja ja väärtus
    $x = $c - $d;
    // muutuja milles lahutatakse eelnevalt määratud muutujad
    // kui funktsiooni esimene parameeter on suurem kui üks ja teine parameeter väiksem kui kümme
    if ($yks > 1 && $kaks < 10) {
        $count = strlen(trim($x));
        // loeta
        $midagi = ucfirst($c);
        // muutuja $c väärusel tehakse esimene täht suureks ja kirjutakse muutuja $midagi väärtuseks
    }
    $x .= ' (' . $yks . ', ' . $kaks . ')';
    if ($c === $yks) {
        $kaks = $c;
    } else {
        if (strlen($yks) > strlen($kaks)) {
            echo "vale info on ikka äge";
        } else {
            $kaks = a($yks, $kaks);
        }
    }
    $m = 567;
    // while (1 > 0){ echo 'sure arvuti';}
    return $x;
}
Exemplo n.º 7
0
 function __construct(Thread $thread)
 {
     parent::__construct($thread->getBoard());
     $topLinks = div('', 'topLinks navLinks')->append('[' . a('Home', '/index') . ']')->append(' [' . a('Return', '/' . $this->board->getName() . '/') . ']');
     if (!$thread->getBoard()->isSwfBoard()) {
         $topLinks->append(' [' . a('Catalog', '/' . $this->board->getName() . '/catalog') . ']');
     }
     if (!$thread->getBoard()->isArchive() && $thread->isActive()) {
         if ($thread->isClosed()) {
             $this->appendToBody(el('h2', 'Thread is closed.'));
         } else {
             if (!isset($_SESSION['captcha'])) {
                 $_SESSION['captcha'] = rand(100000, 999999);
             }
             $this->appendToBody(Site::parseHtmlFragment('postForm.html', ['_board_', '_resto_', '_password_'], [$thread->getBoard()->getName(), $thread->getThreadId(), 'password']));
         }
     }
     $this->appendToBody($topLinks);
     $thread->loadAll();
     $dur = secsToDHMS($thread->getPost($thread->getPosts() - 1)->getTime() - $thread->getPost(0)->getTime());
     $board = div('', 'board');
     if ($thread->getBoard()->isArchive()) {
         $threadStats = Site::parseHtmlFragment("threadStats.html", ["__threadid__", "__posts__", "__posts_actual__", "__images__", "__images_actual__", "__lifetime__", "__deleted__", "<!--4chanLink-->", "<!--tag-->"], [$thread->getThreadId(), $thread->getChanPosts(), $thread->getPosts() - 1, $thread->getChanImages(), $thread->getImages() - 1, "{$dur[0]}d {$dur[1]}h {$dur[2]}m {$dur[3]}s", $thread->getDeleted(), $thread->isActive() ? "<a target='_blank' href='//boards.4chan.org/{$this->board->getName()}/thread/{$thread->getThreadId()}'>View on 4chan</a>" : "Thread is dead.", $thread->getTag() != null ? "<br>Tagged as: " . $thread->getTag() : ""]);
         $board->append($threadStats);
     } else {
         $board->append('<hr>');
     }
     $this->appendToBody($board->append(div($thread->displayThread(), 'thread')));
     $bottomLinks = $topLinks;
     $this->appendToBody("<hr>" . $bottomLinks);
 }
Exemplo n.º 8
0
function f(&$n, &$b, $t)
{
    foreach ($n as $p => $i) {
        if (!is_array($i)) {
            continue;
        }
        $o = [a($i)];
        $l = $t($p);
        foreach ($l as $h) {
            if ($h == $p) {
                continue;
            }
            if (!is_array($n[$h])) {
                continue;
            }
            $o[] = a($n[$h]);
        }
        if (count($o) < 2) {
            $n = $b;
            $b = null;
            return true;
        }
        $m = call_user_func_array('array_diff', $o);
        if (count($m) == 1) {
            l($p, reset($m));
            return true;
        }
    }
    return false;
}
Exemplo n.º 9
0
 /**
  */
 function show()
 {
     $deepness = 3;
     $ext = '.stpl';
     $ext_len = strlen($ext);
     foreach ((array) $this->_dir_array as $gname => $glob) {
         foreach (range(1, $deepness) as $deep) {
             $glob_pattern = $glob . '*' . str_repeat('/*', $deep) . $ext;
             foreach (glob($glob_pattern) as $path) {
                 $name = substr(implode('/', array_reverse(array_slice(array_reverse(explode('/', $path)), 0, $deep))), 0, -$ext_len);
                 $names[$name][$path] = $path;
                 $theme = implode(array_slice(array_reverse(explode('/', $path)), $deep, 1));
                 $found_in[$path] = $gname . ' | ' . $theme;
             }
         }
     }
     ksort($names);
     foreach ((array) $names as $name => $paths) {
         $links = [];
         foreach ($paths as $path) {
             $links[] = a('/file_manager/edit/' . urlencode($path), 'Edit ' . $path, 'fa fa-edit', $found_in[$path]);
         }
         $body['<b>' . $name . '</b>'] = implode(' ', $links);
     }
     return html()->simple_table($body, ['condensed' => 1]);
 }
Exemplo n.º 10
0
 public function __construct(Board $board, array $path)
 {
     parent::__construct($board);
     $topLinks = div('', 'topLinks')->append('[' . a('Home', '/index') . ']')->append(' [' . a('Return', '/' . $this->board->getName() . '/') . ']');
     if (!$board->isSwfBoard()) {
         $topLinks->append(' [' . a('Catalog', '/' . $this->board->getName() . '/catalog') . ']');
     }
     $this->appendToBody($topLinks);
     $this->appendToBody(el('h2', 'Board Search'));
     try {
         $method = $path[3] ?? "";
         if (method_exists(self::class, $method)) {
             $this->perPage = (int) get('perpage', 250);
             $this->page = (int) get('page', 0);
             $this->start = $this->perPage * $this->page;
             $result = $this->{$path[3]}($path[4] ?? NULL);
             $this->appendToBody(div($result->count . ' results.', 'centertext'));
             $pages = $this->makePageSelector($result->count);
             $this->appendToBody($pages);
             $i = $this->start + 1;
             foreach ($result->result as $post) {
                 $this->appendToBody(div($i++ . " >>", 'sideArrows') . PostRenderer::renderPost($post));
             }
             $this->appendToBody($pages);
         } else {
             $this->appendToBody("<h3>Invalid search parameter '{$method}' provided</h3>");
         }
     } catch (Exception $e) {
         $this->appendToBody("<h3>Error: {$e->getMessage()}</h3>");
     }
     $this->appendToBody('<hr>' . $topLinks);
 }
Exemplo n.º 11
0
function foo()
{
    global $y;
    $a = array('x' => a());
    $a['b'] =& $y;
    return $a;
}
Exemplo n.º 12
0
function GetPartialImage($url)
{
	$W = 150;
	$H = 130;
	$F = 80;
	$STEP = 1.0 / $F;
	$im = imagecreatefromjpeg($url);
	$dest = imagecreatetruecolor($W, $H);
	imagecopy($dest, $im, 0, 0, 35, 40, $W, $H);
	
	$a = 1;
	for( $y = $H - $F; $y < $H; $y++ )
	{
		for ( $x = 0; $x < $W; $x++ )
		{
			$i = imagecolorat($dest, $x, $y);
			$c = imagecolorsforindex($dest, $i);
			$c = imagecolorallocate($dest, 
				a($c['red'], $a),
				a($c['green'], $a), 
				a($c['blue'], $a)
			);
			imagesetpixel($dest, $x, $y, $c);
		}
		$a -= $STEP;
	}
	
	header('Content-type: image/png');
	imagepng($dest);
	imagedestroy($dest);
	imagedestroy($im);
}
Exemplo n.º 13
0
 function edit()
 {
     if (!empty($this->data)) {
         $this->Queries->retrieve_query($this->params['query_id'], true);
         $query = $this->data['Query'];
         $query['project'] = empty($this->Query->data['Project']) ? a() : array('Project' => $this->Query->data['Project']);
         $query['project_id'] = $this->Query->data['Project']['id'];
         $query['user_id'] = $this->Query->data['User']['id'];
         $query['filters'] = array();
         foreach ($this->params['form']['fields'] as $field) {
             $this->Query->add_filter($field, $this->params['form']['operators'][$field], $this->params['form']['values'][$field]);
         }
         # @query.attributes = params[:query]
         if (!empty($query['query_is_for_all'])) {
             $query['project_id'] = null;
         }
         $query['is_public'] = $query['project'] && $this->User->is_allowed_to($this->current_user, ':manage_public_queries', $query['project']) || $this->current_user['admin'] ? true : false;
         # @query.column_names = nil if params[:default_columns]
         $this->Query->save($query);
         if (empty($this->Query->validationErrors)) {
             $this->Session->setFlash(__('Successful creation.', true), 'default', array('class' => 'flash flash_notice'));
             $this->redirect(array('controller' => 'issues', 'action' => 'index', 'project_id' => $this->params['project_id']));
         }
         return;
     } elseif (isset($this->params['query_id'])) {
         $this->Queries->retrieve_query($this->params['query_id'], true);
         $this->data['Query'] = $this->Query->data['Query'];
         $this->data['Query']['default_columns'] = true;
         if (empty($this->Query->data['Query']['project_id'])) {
             $this->data['Query']['query_is_for_all'] = "1";
         }
         return;
     }
     $this->cakeError('error404');
 }
Exemplo n.º 14
0
function foo()
{
    $x = array(a());
    $y =& $x[];
    $y = 'asd';
    return $x;
}
Exemplo n.º 15
0
function foo()
{
    $x = array(a());
    $y = null;
    $x[] =& $y;
    $y = 'asd';
    return $x;
}
Exemplo n.º 16
0
function set_financial_aid($clientid, $aidid, $amount)
{
    $s = q("insert into family_to_aid values('" . clean_query($clientid) . "', '" . clean_query($aidid) . "', '" . clean_query($amount) . "');");
    if (a() > 0) {
        return true;
    }
    return false;
}
Exemplo n.º 17
0
function new_dropoff_transaction_food_source($transid, $sourceid, $weight, $price)
{
    $s = q("insert into transaction_to_food_source values('" . $transid . "', '" . $sourceid . "', '" . $weight . "', '" . $price . "');");
    if (a() > 0) {
        return true;
    }
    return false;
}
Exemplo n.º 18
0
 /**
  *	@fn permalink
  *	@short Creates a permalink anchor for this book.
  *	@details This method should be refactored to make use of the canonical relative_url / permalink pair.
  */
 public function permalink()
 {
     if (empty($this->bol_id) || empty($this->bol_category)) {
         echo $this->long_description();
     } else {
         print a($this->long_description(), array('href' => $this->bol_url(), 'class' => 'external'));
     }
 }
Exemplo n.º 19
0
function f()
{
    for ($i = 0; $i < 4; ++$i) {
        a($i < 3);
        $tmp = $i;
        $i = $tmp;
    }
}
Exemplo n.º 20
0
function f()
{
    for ($i = 0; $i < 4; ++$i) {
        a($i < 3);
        $GLOBALS['tmp'] = $i;
        $i = $GLOBALS['tmp'];
    }
}
Exemplo n.º 21
0
 function should_provide_enumeration_methods()
 {
     //FIXME: uses asort which maintain index association, make sense here?
     # Enumerable#sort
     expect(array_values(a(3, 2, 1)->sort()->array))->should_be(array(1, 2, 3));
     $e = a(1, 2, 3, a(4, 5, 6, a(7, 8, 9)));
     expect($e->flatten()->array)->should_be(array(1, 2, 3, 4, 5, 6, 7, 8, 9));
 }
Exemplo n.º 22
0
function main()
{
    var_dump(a() === 'bar');
    var_dump(b() === 24);
    var_dump(c() === 42);
    var_dump(d() === 42);
    var_dump(e() === null);
}
Exemplo n.º 23
0
 function defaults($model)
 {
     $results = aa($model->name, a());
     foreach ($model->_schema as $k => $v) {
         $results[$model->name][$k] = $v['default'];
     }
     $results = $model->afterFind(array($results), true);
     return $results[0][$model->name];
 }
Exemplo n.º 24
0
 public function actionMSDS($args)
 {
     $cas_no = $args[0];
     $msds = a('chemical/msds', ['cas_no' => $cas_no]);
     if (!$msds->id) {
         die("MSDS not found for {$cas_no}!\n");
     }
     echo yaml_emit($msds->getData()['_extra'], YAML_UTF8_ENCODING);
 }
Exemplo n.º 25
0
function a($ap1, $ap2)
{
    ~_hotspot0;
    // 1st context:  u{ (a.ap1, a.ap1_fs) (a.ap2 a.ap2_fs) }  a{ }
    // 2nd context:  u{ (a.ap1, a.ap2, a.ap1_fs, a.ap2_fs) }  a{ }
    if ($u) {
        a(&$ap1, &$ap1);
    }
}
Exemplo n.º 26
0
function c($param1)
{
    if ($param1 > 5) {
        $p = put_string("funkcia c() vola funkciu a()\n");
        $p = a($param1 - 1);
    } else {
        return 0;
    }
}
Exemplo n.º 27
0
	 * @var string
	 */
    private $type;
    /**
	 * @var string
	 */
    private $tmp_name;
    /**
	 * @var int
	 */
Exemplo n.º 28
0
function f_array_a_minus_b($a, $b)
{
    $outp = a();
    foreach ($a as $i) {
        if (!in($i, $b)) {
            $outp[] = $i;
        }
    }
    return $outp;
}
Exemplo n.º 29
0
function delete_product($productid)
{
    $s = q("delete from product where productid = '" . clean_query($productid) . "' limit 1;");
    $a = a();
    $s = q("delete from bag_to_product where productid = '" . clean_query($productid) . "' limit 1;");
    if ($a > 0 || a() > 0) {
        return true;
    }
    return false;
}
function a($m, $n)
{
    if ($m == 0) {
        return $n + 1;
    } elseif ($n == 0 && $m > 0) {
        return a($m - 1, 1);
    } elseif ($n > 0 && $m > 0) {
        return a($m - 1, a($m, $n - 1));
    }
}