Exemple #1
0
 public static function getScanDir($directory)
 {
     $content = scandir($directory);
     array_shift($content);
     array_shift($content);
     $result = ['folders' => [], 'files' => []];
     $temp = '';
     foreach ($content as $some) {
         $temp = \Str\Str::load($directory)->setEnding(DIRECTORY_SEPARATOR)->append($some);
         if (is_file($temp)) {
             $result['files'][] = $temp;
         } else {
             $result['folders'][] = $temp;
         }
     }
     return $content;
 }
<?php

echo '<?php';
?>

class Model_<?php 
echo \Str\Str::load($table)->toLowerCase()->toUpperCaseFirst()->get();
?>
 extends ORM
{

protected $_table_name = '<?php 
echo \Str\Str::load($table)->toLowerCase()->get();
?>
';
    
}
Exemple #3
0
 public static function getManyToManyRelationArray($label, $options, $table, $own_key, $foreign_key, $type = 'multiselect', $mergeParams = [])
 {
     //creating table in database if need
     $createIfNotExists = '
       CREATE TABLE IF NOT EXISTS `' . $table . '` (
         `' . $own_key . '` INT UNSIGNED NOT NULL ,
         `' . $foreign_key . '` INT UNSIGNED NOT NULL ,
         UNIQUE (`' . $own_key . '`, `' . $foreign_key . '`)) ENGINE = InnoDB';
     DB::query(Database::INSERT, $createIfNotExists)->execute();
     $modelClassName = \Str\Str::load($table)->remove('^[^_]+_')->toLowerCase()->toUpperCaseFirst()->prepend('Model_')->get();
     //creating model file if need
     if (!class_exists($modelClassName)) {
         $modelPath = APPPATH . 'classes' . DIRECTORY_SEPARATOR . 'Model' . DIRECTORY_SEPARATOR . \Zver\StringHelper::load($modelClassName)->remove('^[^_]+_')->get() . '.php';
         if (!file_exists($modelPath)) {
             file_put_contents($modelPath, View::factory('system/ORM_Template')->set('table', \Zver\StringHelper::load($table)->remove('^[^_]+_')->toLowerCase()->toUpperCaseFirst()->get()));
         }
     }
     $params = ['dont_select' => true, 'label' => $label, 'type' => $type, 'options' => $options, 'get_current_value' => function () use($table, $own_key, $foreign_key) {
         $request = Request::initial();
         $id = $request->param('primary');
         $current = DB::select($foreign_key)->from($table)->where($own_key, '=', $id)->execute()->as_array($foreign_key, $foreign_key);
         return $current;
     }];
     return array_merge($params, $mergeParams);
 }
Exemple #4
0
<?php

$prevHref = HTML::chars($page->url($previous_page));
$nextHref = HTML::chars($page->url($next_page));
$info = \Str\Str::getScrollPaginationInfo($total_items, $items_per_page, $offset, ', ', '-', ' из ');
?>

<div class="pagination-scroll">
    
    <div class="pagination-scroll-prev">
        <?php 
if ($previous_page !== false) {
    ?>
            <a href="<?php 
    echo $prevHref;
    ?>
" class="pagination-scroll-link">
                <svg version="1.1"
                     class="pagination-scroll-link-img"
                     xmlns="http://www.w3.org/2000/svg"
                     xmlns:xlink="http://www.w3.org/1999/xlink"
                     x="0px"
                     y="0px"
                     viewBox="0 0 25 50"
                     style="enable-background:new 0 0 25 50;"
                     xml:space="preserve">
                    <polyline points="25.3,-0.6 3,22.2 25.3,50.3 "/>
                </svg>
                <span class="pagination-scroll-link-text">
                    Назад
                </span>
Exemple #5
0
 public function testTrimRight()
 {
     $str = new Str("   Hello   ");
     $this->assertTrue($str->trimRight()->equals("   Hello"));
 }