1
0
Эх сурвалжийг харах

Ticket #2103 - Related changes in core.

AntonLV 7 жил өмнө
parent
commit
080e9936b3

+ 11 - 0
inc/classes/BxDolLanguages.php

@@ -136,6 +136,17 @@ class BxDolLanguages extends BxDolFactory implements iBxDolSingleton
     {
         return $this->oDb->getLanguages($bIdAsKey, $bActiveOnly);
     }
+    
+    function getLanguagesExt($bIdAsKey = false, $bActiveOnly = false)
+    {
+        $aParams = array('type' => 'all_key_' . ($bIdAsKey ? 'id' : 'name'));
+        if($bActiveOnly)
+            $aParams['enabled'] = 1;
+
+        $aResults = array();
+        $this->oDb->getLanguagesBy($aParams, $aResults, false);
+        return $aResults;
+    }
 
     function getLanguageCategory($sName)
     {

+ 31 - 8
inc/classes/BxDolLanguagesQuery.php

@@ -139,16 +139,16 @@ class BxDolLanguagesQuery extends BxDolDb implements iBxDolSingleton
 
             case 'all_by_id':
             	$aMethod['params'][1] = array(
-                	'id' => $aParams['value']
+                    'id' => $aParams['value']
                 );
 
                 $sWhereClause .= " AND `tl`.`ID`=:id";
                 $sOrderClause = " `tl`.`Name` ASC ";
                 break;
 
-			case 'all_by_name':
-				$aMethod['params'][1] = array(
-                	'name' => $aParams['value']
+            case 'all_by_name':
+                $aMethod['params'][1] = array(
+                    'name' => $aParams['value']
                 );
 
                 $sWhereClause .= " AND `tl`.`Name`=:name";
@@ -158,14 +158,37 @@ class BxDolLanguagesQuery extends BxDolDb implements iBxDolSingleton
             case 'all_key_id':
                 $aMethod['name'] = 'getAllWithKey';
                 $aMethod['params'][1] = 'id';
+                $aMethod['params'][2] = array();
 
-                if(isset($aParams['language']) && (int)$aParams['language'] != 0) {
-                	$aMethod['params'][2] = array(
-	                	'id' => $aParams['language']
-	                );
+                if(!empty($aParams['language'])) {
+                    $aMethod['params'][2]['id'] = $aParams['language'];
 
                     $sWhereClause .= " AND `tl`.`ID`=:id";
                 }
+
+                if(isset($aParams['enabled'])) {
+                    $aMethod['params'][2]['enabled'] = (int)$aParams['enabled'];
+
+                    $sWhereClause .= " AND `tl`.`Enabled`=:enabled";
+                }
+                break;
+
+            case 'all_key_name':
+                $aMethod['name'] = 'getAllWithKey';
+                $aMethod['params'][1] = 'name';
+                $aMethod['params'][2] = array();
+
+                if(!empty($aParams['language'])) {
+                    $aMethod['params'][2]['name'] = $aParams['language'];
+
+                    $sWhereClause .= " AND `tl`.`Name`=:name";
+                }
+
+                if(isset($aParams['enabled'])) {
+                    $aMethod['params'][2]['enabled'] = (int)$aParams['enabled'];
+
+                    $sWhereClause .= " AND `tl`.`Enabled`=:enabled";
+                }
                 break;
         }
 

+ 10 - 10
inc/utils.inc.php

@@ -584,9 +584,9 @@ function clear_xss($val)
 
 //--------------------------------------- friendly permalinks --------------------------------------//
 //------------------------------------------- main functions ---------------------------------------//
-function uriGenerate ($s, $sTable, $sField, $sEmpty = '-')
+function uriGenerate ($s, $sTable, $sField, $sEmpty = '-', $sDivider = '-')
 {
-    $s = uriFilter($s, $sEmpty);
+    $s = uriFilter($s, $sEmpty, $sDivider);
     if(uriCheckUniq($s, $sTable, $sField))
         return $s;
 
@@ -595,27 +595,27 @@ function uriGenerate ($s, $sTable, $sField, $sEmpty = '-')
         $s = get_mb_substr($s, 0, 240);
 
     // try to add date
-    $s .= '-' . date('Y-m-d');
+    $s .= $sDivider . date('Y-m-d');
     if(uriCheckUniq($s, $sTable, $sField))
         return $s;
 
     // try to add number
     for($i = 0 ; $i < 999 ; ++$i)
-        if(uriCheckUniq($s . '-' . $i, $sTable, $sField))
-            return ($s . '-' . $i);
+        if(uriCheckUniq($s . $sDivider . $i, $sTable, $sField))
+            return ($s . $sDivider . $i);
 
     return rand(0, 999999999);
 }
 
-function uriFilter ($s, $sEmpty = '-')
+function uriFilter ($s, $sEmpty = '-', $sDivider = '-')
 {
     if (BxTemplConfig::getInstance()->bAllowUnicodeInPreg)
-        $s = get_mb_replace ('/[^\pL^\pN]+/u', '-', $s); // unicode characters
+        $s = get_mb_replace ('/[^\pL^\pN]+/u', $sDivider, $s); // unicode characters
     else
-        $s = get_mb_replace ('/([^\d^\w]+)/u', '-', $s); // latin characters only
+        $s = get_mb_replace ('/([^\d^\w]+)/u', $sDivider, $s); // latin characters only
 
-    $s = get_mb_replace ('/([-^]+)/', '-', $s);
-    $s = get_mb_replace ('/([-]+)$/', '', $s); // remove trailing dash
+    $s = get_mb_replace ('/([' . $sDivider . '^]+)/', $sDivider, $s);
+    $s = get_mb_replace ('/([' . $sDivider . ']+)$/', '', $s); // remove trailing dash
     if (!$s) $s = $sEmpty;
     return $s;
 }

+ 0 - 38
modules/boonex/directory/classes/BxDirCronPublishing.php

@@ -1,38 +0,0 @@
-<?php defined('BX_DOL') or die('hack attempt');
-/**
- * Copyright (c) UNA, Inc - https://una.io
- * MIT License - https://opensource.org/licenses/MIT
- *
- * @defgroup    Directory Directory
- * @ingroup     UnaModules
- *
- * @{
- */
-
-require_once(BX_DIRECTORY_PATH_INC . "design.inc.php");
-
-class BxDirCronPublishing extends BxDolCron
-{
-	protected $_sModule;
-	protected $_oModule;
-
-	public function __construct()
-    {
-        parent::__construct();
-
-    	$this->_sModule = 'bx_directory';
-    	$this->_oModule = BxDolModule::getInstance($this->_sModule);
-    }
-
-    function processing()
-    {
-        $mixedIds = $this->_oModule->_oDb->publish();
-        if($mixedIds === false)
-            return;
-
-        foreach($mixedIds as $iId)
-            $this->_oModule->onPublished($iId);
-    }
-}
-
-/** @} */