Beispiel #1
0
 /**
  * Encodes the given string and returns the numeral representation.
  * @param $string
  * @return string
  */
 public function encode($string)
 {
     $result = "";
     foreach (str_split(strtoupper($string)) as $character) {
         $result .= $this->alphabet->getNumber($character);
     }
     return $result;
 }
Beispiel #2
0
 /**
  * Solvers the number string recursively.
  * Works only for max 2 space numbers.
  * @param array|int[]    $numbers
  * @param SolutionsStack $stack
  * @return array|string[]
  */
 private function solveNumbers(array $numbers, SolutionsStack $stack)
 {
     // Recursion stop
     if (empty($numbers)) {
         return $stack->getSolutions();
     }
     // Shift the first two numbers from the array
     $number1 = array_shift($numbers);
     $number2 = array_shift($numbers);
     // If the second number doesn't exist add the first and return the solutions
     if (!$number2 && $number2 !== 0) {
         $stack->addLetter($this->alphabet->getLetter($number1));
         return $stack->getSolutions();
     }
     // If the bigger number isn't in the alphabet add the first and return the solutions
     if (!$this->alphabet->hasNumber($number1 . $number2)) {
         array_unshift($numbers, $number2);
         $stack->addLetter($this->alphabet->getLetter($number1));
         return $this->solveNumbers($numbers, $stack);
     }
     // Taking both numbers and making a letter
     $stack1 = clone $stack;
     // Clone to keep original stack clean
     $stack1->addLetter($this->alphabet->getLetter($number1 . $number2));
     $solutions1 = $this->solveNumbers($numbers, new SolutionsStack($stack1->getSolutions()));
     // Taking only the first number and returning the second to the array
     array_unshift($numbers, $number2);
     $stack->addLetter($this->alphabet->getLetter($number1));
     $solutions2 = $this->solveNumbers($numbers, new SolutionsStack($stack->getSolutions()));
     // Return merged solutions
     return array_merge($solutions1, $solutions2);
 }
 /**
  * Remove alphabet from storage
  *
  * @param Alphabet $alphabet
  *
  * @return Storage
  */
 public function remove(Alphabet $alphabet)
 {
     unset($this->alphabets[$alphabet->getLanguage()]);
     return $this;
 }
Beispiel #4
0
<form class="heads" method="POST" action="<?php echo $_SERVER['PHP_SELF'] ?>">
<?php
//Получаем переменные для сортировки
@$_GET['sortcolumn']=($_GET['sortcolumn'])?$_GET['sortcolumn']:"ФИО";
@$_GET['sorttype']=($_GET['sorttype'])?$_GET['sorttype']:"ASC";
?>
<div class="heads">
<?php
if($BLOCK_VIS[$menu_marker]['birthdays'])
	include("./libs/birth.php");
if($BLOCK_VIS[$menu_marker]['search'])
	include("./libs/search.php");
if($BLOCK_VIS[$menu_marker]['profile'])	
	include("./libs/profile.php");
if($BLOCK_VIS[$menu_marker]['fast_move'])
	{
	echo"<br/>";
	Alphabet::printGeneralLetters(); //Печатаем буквы алфавита, для быстрого перехода на сотрудников
	}
?>
</div>
</form>
<?php
$ldap=new LDAP($LDAPServer, $LDAPUser, $LDAPPassword); //Соединяемся с сервером

// Делаем фильтр для выборки сотрудников нужных компаний
//-------------------------------------------------------------------------------------------------------------
$CompanyNameLdapFilter=Application::getCompanyNameLdapFilter();
//-------------------------------------------------------------------------------------------------------------
//Получаем переменные для сортировки
@($_GET['sortcolumn'] = $_GET['sortcolumn'] ? $_GET['sortcolumn'] : "ФИО");
@($_GET['sorttype'] = $_GET['sorttype'] ? $_GET['sorttype'] : "ASC");
?>

<div class="heads">
<?php 
if ($BLOCK_VIS[$menu_marker]['birthdays']) {
    include "./libs/birth.php";
}
if ($BLOCK_VIS[$menu_marker]['search']) {
    include "./libs/search.php";
}
if ($BLOCK_VIS[$menu_marker]['profile']) {
    include "./libs/profile.php";
}
if ($BLOCK_VIS[$menu_marker]['fast_move']) {
    echo "<br/>";
    Alphabet::printGeneralLetters();
    //Печатаем буквы алфавита, для быстрого перехода на сотрудников
}
?>
</div>
</form>
<?php 
$ldap = new LDAP($LDAPServer, $LDAPUser, $LDAPPassword);
//Соединяемся с сервером
// Делаем фильтр для выборки сотрудников нужных компаний
//-------------------------------------------------------------------------------------------------------------
$CompanyNameLdapFilter = Application::getCompanyNameLdapFilter();
//-------------------------------------------------------------------------------------------------------------
 /**
  * Test has common char in alphabet
  */
 public function testHasCommonChar()
 {
     $this->assertTrue($this->alphabet->hasCommonChar(11));
     $this->assertFalse($this->alphabet->hasCommonChar(1));
 }