Beispiel #1
0
 /**
  * Метод возвращает столбцы таблицы
  */
 public function getColumns($table)
 {
     if (!$this->getCache()->has(self::CACHE_COLUMNS)) {
         $this->getCache()->set(self::CACHE_COLUMNS, $this->getObjects("\nselect LOWER(c.TABLE_NAME) as TABLE_NAME,\n       LOWER(c.COLUMN_NAME) as COLUMN_NAME,\n       \n       c.IS_NULLABLE,\n       c.DATA_TYPE,\n       c.CHARACTER_MAXIMUM_LENGTH,\n       LOWER(c.COLUMN_KEY) as COLUMN_KEY,\n       c.EXTRA,\n       c.COLUMN_COMMENT,\n       c.COLUMN_DEFAULT,\n       \n       if(upk.CONSTRAINT_TYPE is null, 0, 1) as IS_PK,\n       \n       if(ufk.CONSTRAINT_TYPE is null, 0, 1) as IS_FK,\n       LOWER(ufk.REFERENCED_TABLE_NAME) as REFERENCED_TABLE_NAME,\n       LOWER(ufk.REFERENCED_COLUMN_NAME) as REFERENCED_COLUMN_NAME\n\n  from information_schema.columns c\n\n  left join (select cpk.CONSTRAINT_TYPE,\n                    upk.TABLE_SCHEMA,\n                    upk.TABLE_NAME,\n                    upk.COLUMN_NAME,\n                    upk.TABLE_CATALOG\n               from information_schema.KEY_COLUMN_USAGE  upk,\n                    information_schema.TABLE_CONSTRAINTS cpk\n              where upk.REFERENCED_TABLE_SCHEMA is null\n                and upk.REFERENCED_TABLE_NAME is null\n                and upk.REFERENCED_COLUMN_NAME is null\n                and upk.TABLE_SCHEMA = cpk.TABLE_SCHEMA\n                and upk.TABLE_NAME = cpk.TABLE_NAME\n                and upk.CONSTRAINT_CATALOG = cpk.CONSTRAINT_CATALOG\n                and upk.CONSTRAINT_NAME = cpk.CONSTRAINT_NAME\n                and upk.CONSTRAINT_SCHEMA = cpk.CONSTRAINT_SCHEMA\n                and cpk.CONSTRAINT_TYPE is not null\n                and cpk.CONSTRAINT_TYPE = 'PRIMARY KEY') as upk\n    on c.TABLE_SCHEMA = upk.TABLE_SCHEMA\n   and c.TABLE_NAME = upk.TABLE_NAME\n   and c.COLUMN_NAME = upk.COLUMN_NAME\n   and c.TABLE_CATALOG = upk.TABLE_CATALOG\n\n  left join (select LOWER(upk.REFERENCED_TABLE_NAME) as REFERENCED_TABLE_NAME,\n                    LOWER(upk.REFERENCED_COLUMN_NAME) as REFERENCED_COLUMN_NAME,\n                    \n                    cpk.CONSTRAINT_TYPE,\n                    upk.TABLE_SCHEMA,\n                    upk.TABLE_NAME,\n                    upk.COLUMN_NAME,\n                    upk.TABLE_CATALOG,\n                    upk.REFERENCED_TABLE_SCHEMA\n               from information_schema.KEY_COLUMN_USAGE  upk,\n                    information_schema.TABLE_CONSTRAINTS cpk\n              where upk.REFERENCED_TABLE_SCHEMA is not null\n                and upk.REFERENCED_TABLE_NAME is not null\n                and upk.REFERENCED_COLUMN_NAME is not null\n                and upk.TABLE_SCHEMA = cpk.TABLE_SCHEMA\n                and upk.TABLE_NAME = cpk.TABLE_NAME\n                and upk.CONSTRAINT_CATALOG = cpk.CONSTRAINT_CATALOG\n                and upk.CONSTRAINT_NAME = cpk.CONSTRAINT_NAME\n                and upk.CONSTRAINT_SCHEMA = cpk.CONSTRAINT_SCHEMA\n                and cpk.CONSTRAINT_TYPE is not null\n                and cpk.CONSTRAINT_TYPE = 'FOREIGN KEY') as ufk\n    on c.TABLE_SCHEMA = ufk.TABLE_SCHEMA\n   and c.TABLE_SCHEMA = ufk.REFERENCED_TABLE_SCHEMA\n   and c.TABLE_NAME = ufk.TABLE_NAME\n   and c.COLUMN_NAME = ufk.COLUMN_NAME\n   and c.TABLE_CATALOG = ufk.TABLE_CATALOG\n\n where c.table_schema = DATABASE()\n   /*and c.table_name = ?*/\n\n order by c.TABLE_NAME, c.ORDINAL_POSITION", null, PsTableColumn::getClass(), null, null, function (PsTableColumn $col, &$result, $row) {
             $result[$col->getTableName()][$col->getName()] = $col;
         }));
     }
     return array_get_value(lowertrim($table), $this->getCache()->get(self::CACHE_COLUMNS), array());
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $subdomains = json_decode(file_get_contents(stryve_path() . '/Database/SeedData/reserved_subdomains.json'));
     $subdomains_array = [];
     foreach ($subdomains as $subdomain) {
         $subdomain = lowertrim($subdomain);
         if (isValidSubdomain($subdomain)) {
             $subdomains_array[] = ['subdomain' => $subdomain, 'created_at' => \Carbon\Carbon::now(), 'updated_at' => \Carbon\Carbon::now()];
         }
     }
     $this->reserved_subdomain->insert($subdomains_array);
 }
Beispiel #3
0
 /**
  * Метод проверяет, работаем ли мы в контексте ajax
  */
 public static function isAjax()
 {
     /*
      * Определена ли специальная константа, которая определяется в AjaxTools
      * Парамер HTTP_X_REQUESTED_WITH может быть не установлен, например, при загрузке файла с помощью flash.
      */
     if (defined('PS_AJAX_CONTEXT') && !!PS_AJAX_CONTEXT) {
         return true;
         //---
     }
     /*
      * Проверим наличие переменной HTTP_X_REQUESTED_WITH в глобальном массиве $_SERVER
      */
     return 'xmlhttprequest' == lowertrim(array_get_value('HTTP_X_REQUESTED_WITH', $_SERVER, ''));
 }
 /**
  * Determines whether or not the provided subdomain
  * meets subdomain length and character requirements.
  * 
  * @param string $subdomain
  * @return bool
  */
 public function isValidSubdomain($subdomain)
 {
     $subdomain = lowertrim($subdomain);
     $min_length = Config::get('stryve.tenant.subdomain-min-length');
     $max_length = Config::get('stryve.tenant.subdomain-max-length');
     $subdomain_length = strlen($subdomain);
     // check subdomain is of valid characters
     if (!isValidSubdomain($subdomain)) {
         return false;
     }
     // check subdomain meets length requirements
     if ($subdomain_length < $min_length || $subdomain_length > $max_length) {
         return false;
     }
     return true;
 }
Beispiel #5
0
    $content = get_the_content();
    $contents = explode("\n", $content);
    $menu_head = get_the_title();
    $ownUrl = types_render_field('url-slug');
    $ownUrl = trim(strtolower($ownUrl)) == 'home' ? site_url() : site_url() . '/' . $ownUrl;
    if (lowertrim(types_render_field('url-slug')) == 'project') {
        $menu_head = get_the_title();
        $contents = get_menu_post('project');
    } elseif (lowertrim(types_render_field('url-slug')) == 'resources') {
        $menu_head = get_the_title();
        $contents = get_menu_post('resource');
    } elseif (lowertrim(types_render_field('url-slug')) == 'news') {
    } elseif (lowertrim(types_render_field('url-slug')) == 'shop') {
        $menu_head = get_the_title();
        $contents = get_menu_post('product');
    } elseif (lowertrim(types_render_field('url-slug')) == 'about') {
        $menu_head = get_the_title();
        $contents = get_menu_post('about');
    }
    $j = 0;
    ?>


 <li class="dropdown yamm-fw first " ><a  class="dropdown-toggle <?php 
    echo current_url() == $ownUrl ? 'active' : null;
    ?>
 topMenu" href="<?php 
    echo $ownUrl;
    ?>
"><?php 
    echo $menu_head;
 /**
  * Метод создаёт новый фолдинг
  */
 public function makeNewFolding(ArrayAdapter $adapter)
 {
     $ifaces = $adapter->arr('ifaces');
     $rtypes = $adapter->arr('rtypes');
     $type = lowertrim($adapter->str('FoldingType'));
     $subtype = lowertrim($adapter->str('FoldingSubType'));
     $group = $adapter->str('FoldingGroup');
     $classPrefix = $adapter->str('FoldingClassPrefix');
     check_condition($type, 'Не передан тип фолдинга');
     check_condition($group, 'Не передана группа для фолдинга');
     check_condition($classPrefix, 'Не передан префикс для классов фолдинга');
     //TODO - определять директорию для воздания менеджера фолдингов.
     die('Folding dir is not deffined.');
     $classesDi = DirItem::inst(array('sdk/kit', 'folded'), $group);
     check_condition(!$classesDi->isDir(), "Директория {$classesDi} уже существует");
     check_condition(!$classesDi->isFile(), "Элемент {$classesDi} не может быть файлом");
     $rtypes = array_intersect(array_keys(PsUtil::getClassConsts('FoldedResources', 'RTYPE_')), $rtypes);
     $rtypesArr = trim(implode(', self::', $rtypes));
     $rtypesArr = $rtypesArr ? "self::{$rtypesArr}" : '';
     $hasPhp = in_array('RTYPE_PHP', $rtypes);
     $classesDm = DirManager::inst($classesDi->getRelPath())->makePath();
     $resourcesPatternDmTo = DirManager::resources(array('folded', $group, FoldedResources::PATTERN_NAME));
     check_condition(!$resourcesPatternDmTo->isDir(), "Целевая директория {$resourcesPatternDmTo} существует");
     $resourcesPatternDmFrom = DirManager::resources(array('folded', FoldedResources::PATTERN_NAME));
     check_condition($resourcesPatternDmFrom->isDir(), "Некорректна директория-источник {$resourcesPatternDmFrom}");
     $interfaces = array();
     foreach ($this->getFoldedInterfaces($ifaces) as $name => $ifaceClass) {
         $ctt = $ifaceClass->getClassBody();
         if ($ctt) {
             $interfaces[] = "/****************\n\t * {$name}\n\t ****************/\n" . $ctt;
         }
     }
     $smParams = $adapter->getData();
     $smParams['rtypes'] = $rtypesArr;
     $smParams['funique'] = FoldedResources::unique($type, $subtype);
     $smParams['BaseClass'] = 'Base' . $classPrefix;
     $smParams['ManagerClass'] = $classPrefix . 'Manager';
     $smParams['ResourcesClass'] = $classPrefix . 'Resources';
     $smParams['implements'] = $ifaces ? 'implements ' . implode(', ', $ifaces) . ' ' : '';
     $smParams['interfaces'] = $interfaces ? implode("\n\n\t", $interfaces) : '';
     try {
         //КЛАССЫ
         //Resources
         $tpl = PSSmarty::template(DirItem::inst(array(__DIR__, 'tpls'), 'resources.tpl'), $smParams);
         $di = $classesDm->getDirItem(null, $smParams['ResourcesClass'], 'php');
         $di->writeToFile(trim($tpl->fetch()), true);
         //Manager
         $tpl = PSSmarty::template(DirItem::inst(array(__DIR__, 'tpls'), 'manager.tpl'), $smParams);
         $di = $classesDm->getDirItem(null, $smParams['ManagerClass'], 'php');
         $di->writeToFile(trim($tpl->fetch()), true);
         if ($hasPhp) {
             //BaseClass
             $tpl = PSSmarty::template(DirItem::inst(array(__DIR__, 'tpls'), 'baseclass.tpl'), $smParams);
             $di = $classesDm->getDirItem(null, $smParams['BaseClass'], 'php');
             $di->writeToFile(trim($tpl->fetch()), true);
         }
         //ШАБЛОН ДЛЯ СУЩНОСТЕЙ
         $resourcesPatternDmTo->makePath();
         foreach ($rtypes as $rtype) {
             $ext = FoldedResources::resourceTypeToExt(PsUtil::newReflectionClass('FoldedResources')->getConstant($rtype));
             $diTo = $resourcesPatternDmTo->getDirItem(null, FoldedResources::PATTERN_NAME, $ext);
             $diFrom = $resourcesPatternDmFrom->getDirItem(null, FoldedResources::PATTERN_NAME, $ext);
             if ($ext == PsConst::EXT_PHP) {
                 $diTo->writeToFile(str_replace('eclassnamebase', $smParams['BaseClass'], $diFrom->getFileContents()));
                 continue;
             }
             $diFrom->copyTo($diTo);
         }
     } catch (Exception $ex) {
         $classesDm->clearDir(null, true);
         $resourcesPatternDmTo->clearDir(null, true);
         throw $ex;
     }
 }
Beispiel #7
0
 /**
  * Метод валидирует и извлекает тип поста
  */
 public function extractPostType($postType, $assert = true)
 {
     $type = lowertrim($postType);
     if (!$type) {
         check_condition(!$assert, 'Передан пустой тип поста');
         return null;
         //---
     }
     if (!in_array($type, $this->postTypes)) {
         check_condition(!$assert, "Некорректный тип поста: [{$postType}]");
         return null;
         //---
     }
     return $type;
 }
Beispiel #8
0
 /**
  * Получает mime-тип
  * 
  * @param mixed $type - тип|расширение|mime
  * @return type
  */
 public static function getMime($type)
 {
     if (self::hasMime($type)) {
         return lowertrim($type);
     }
     return strtolower(image_type_to_mime_type(self::getType($type)));
 }
 /**
  * Returns a subdomain record if exists, or NULL if not
  * 
  * @param string $subdomain 
  * @return mixed 
  */
 public function findBySubdomain($subdomain)
 {
     return $this->where('subdomain', lowertrim($subdomain))->first();
 }
 public static function HTTP_HOST()
 {
     return cut_string_start(lowertrim(basename(self::CONST_STR(__FUNCTION__))), 'www.');
 }