Exemplo n.º 1
0
 function initQuery($params)
 {
     $tables = Resources::getTables();
     $rltable = $tables['resource_labels']['columns'];
     $this->addSelectField($rltable['id'], 'id');
     $this->addSelectField($rltable['res_prefix'], 'prefix');
     $this->addSelectField($rltable['res_label'], 'label');
     $this->addSelectField($rltable['res_text'], 'def_value');
     $this->addSelectField('_ml_.value', 'value');
     $this->setMultiLangAlias('_ml_', 'resource_labels', $rltable['res_text'], $rltable['id'], 'Resources', '', true, $params['lng']);
     // filter conditions
     $where = array();
     if (isset($params['label'])) {
         if (isset($params['label']['exactly']) && $params['label']['exactly'] == 'Y') {
             $where[] = array($rltable['res_label'], DB_EQ, '\'' . $this->DBAddSlashes($params['label']['value']) . '\'');
         } else {
             $where[] = array($rltable['res_label'], DB_LIKE, '\'%' . str_replace('_', '\\_', $this->DBAddSlashes($params['label']['value'])) . '%\'');
         }
     }
     if (isset($params['pattern'])) {
         if (isset($params['pattern']['exactly']) && $params['pattern']['exactly'] == 'Y') {
             $where[] = array('(', $rltable['res_text'], DB_EQ, '\'' . $this->DBAddSlashes($params['pattern']['value']) . '\'', DB_OR, '_ml_.value', DB_EQ, '\'' . $this->DBAddSlashes($params['pattern']['value']) . '\'', ')');
         } else {
             $where[] = array('(', $rltable['res_text'], DB_LIKE, '\'%' . str_replace('_', '\\_', $this->DBAddSlashes($params['pattern']['value'])) . '%\'', DB_OR, '_ml_.value', DB_LIKE, '\'%' . str_replace('_', '\\_', $this->DBAddSlashes($params['pattern']['value'])) . '%\'', ')');
         }
     }
     if (isset($params['type'])) {
         switch ($params['type']) {
             case 'all':
                 break;
             case 'storefront':
                 $where[] = array($rltable['res_prefix'], DB_EQ, '\'CZ\'');
                 break;
             case 'storefront_cz':
                 $where[] = array($rltable['res_prefix'], DB_EQ, '\'CZ\'');
                 $where[] = array($rltable['res_label'], DB_NLIKE, '\'CUSTOM\\_%\'');
                 break;
             case 'admin':
                 $where[] = array($rltable['res_prefix'], DB_NEQ, '\'CZ\'');
                 break;
             case 'CZ_CUSTOM':
                 $where[] = array($rltable['res_prefix'], DB_EQ, '\'CZ\'');
                 $where[] = array($rltable['res_label'], DB_LIKE, '\'CUSTOM\\_%\'');
                 break;
             default:
                 $where[] = array($rltable['res_prefix'], DB_EQ, '\'' . $params['type'] . '\'');
                 break;
         }
     }
     if (isset($params['status'])) {
         if ($params['status'] == 'translated') {
             $where[] = array('_ml_.ml_id', DB_NNULL);
         } elseif ($params['status'] == 'nontranslated') {
             $where[] = array('_ml_.ml_id', DB_IS_NULL);
         }
     }
     if (isset($params['label_id'])) {
         $where[] = array($rltable['id'], DB_EQ, '\'' . $params['label_id'] . '\'');
     }
     // building the where condition
     if (!empty($where)) {
         foreach ($where as $k => $v) {
             if ($k != 0) {
                 array_push($this->WhereList, DB_AND);
             }
             foreach ($v as $vv) {
                 array_push($this->WhereList, $vv);
             }
         }
     }
     $this->SelectOrder($rltable['res_label']);
     if (isset($params['paginator']) && is_array($params['paginator'])) {
         list($offset, $count) = $params['paginator'];
         $this->SelectLimit($offset, $count);
     } elseif (isset($params['limit']) && is_array($params['limit'])) {
         list($offset, $count) = $params['limit'];
         $this->SelectLimit($offset, $count);
     }
 }
Exemplo n.º 2
0
 function addLabelsArrayToDB($data, $prefix)
 {
     global $application;
     if (empty($data)) {
         return false;
     }
     loadCoreFile('db_multiple_insert.php');
     $tables = Resources::getTables();
     $table = "resource_labels";
     $columns = $tables[$table]['columns'];
     $fields = array($columns['res_prefix'], $columns['res_label'], $columns['res_text']);
     $query = new DB_Multiple_Insert($table);
     $query->setInsertFields($fields);
     foreach ($data as $key => $value) {
         $params = array($columns['res_prefix'] => $prefix, $columns['res_label'] => $key, $columns['res_text'] => $value);
         $query->addInsertValuesArray($params);
     }
     $application->db->PrepareSQL($query);
     $application->db->DB_Exec();
     return true;
 }
Exemplo n.º 3
0
 function initQuery($params)
 {
     $tables = Resources::getTables();
     $p = $tables['resource_labels']['columns'];
     $this->addSelectField($p['res_prefix'], 'res_prefix');
     $this->addSelectField($p['res_label'], 'res_label');
     $this->setMultiLangAlias('_ml', 'resource_labels', $p['res_text'], $p['id'], 'Resources', 0, true, $params['res_lng']);
     $this->addSelectField($this->getMultiLangAlias('_ml'), 'res_text');
     $this->WhereValue($p['res_prefix'], DB_EQ, $params['prefix']);
     $this->WhereAnd();
     $this->WhereValue($p['res_label'], DB_EQ, $params['label']);
 }