Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions _build/build.config.sample.php

This file was deleted.

4 changes: 2 additions & 2 deletions _build/data/transport.settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
$settings['tiny.custom_buttons1']= $modx->newObject('modSystemSetting');
$settings['tiny.custom_buttons1']->fromArray(array(
'key' => 'tiny.custom_buttons1',
'value' => 'undo,redo,selectall,separator,pastetext,pasteword,separator,search,replace,separator,nonbreaking,hr,charmap,separator,image,modxlink,unlink,anchor,media,separator,cleanup,removeformat,separator,fullscreen,print,code,help',
'value' => 'undo,redo,typograf,selectall,separator,pastetext,pasteword,separator,search,replace,separator,nonbreaking,hr,charmap,separator,image,modxlink,unlink,anchor,media,separator,cleanup,removeformat,separator,fullscreen,print,code,help',
'xtype' => 'textfield',
'namespace' => 'tinymce',
'area' => 'custom-buttons',
Expand Down Expand Up @@ -89,7 +89,7 @@
$settings['tiny.custom_plugins']= $modx->newObject('modSystemSetting');
$settings['tiny.custom_plugins']->fromArray(array(
'key' => 'tiny.custom_plugins',
'value' => 'style,advimage,advlink,modxlink,searchreplace,print,contextmenu,paste,fullscreen,noneditable,nonbreaking,xhtmlxtras,visualchars,media',
'value' => 'style,advimage,advlink,modxlink,searchreplace,print,contextmenu,paste,fullscreen,noneditable,nonbreaking,xhtmlxtras,visualchars,media,typograf',
'xtype' => 'textfield',
'namespace' => 'tinymce',
'area' => 'general',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php
/**
* Jare_Exception
*
* @copyright Copyright (c) 2009 E.Muravjev Studio (http://emuravjev.ru)
* @license http://emuravjev.ru/works/tg/eula/
* @version 2.0.0
* @author Arthur Rusakov <arthur@emuravjev.ru>
* @category Jare
* @package Jare_Typograph
*/
class Jare_Exception extends Exception
{
}
162 changes: 162 additions & 0 deletions assets/components/tinymce/jscripts/tiny_mce/engines/Jare/Typograph.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
<?php
/**
* Jare_Typograph
*
* @copyright Copyright (c) 2009 E.Muravjev Studio (http://emuravjev.ru)
* @license http://emuravjev.ru/works/tg/eula/
* @version 2.0.0
* @author Arthur Rusakov <arthur@emuravjev.ru>
* @category Jare
* @package Jare_Typograph
*/
class Jare_Typograph
{
/**
* Перечень названий тофов, идущих с дистрибутивом
*
* @var array
*/
protected $_baseTof = array('quote', 'dash', 'punctmark', 'number', 'space', 'etc');

/**
* Массив из тофов, где каждой паре-ключ соответствует название тофа
* и его объект
*
* @var array
*/
protected $_tof = array();

/**
* Конструктор
*
* @param string $text строка для типографирования
* @return void
*/
public function __construct($text)
{
$this->_text = $text;
$this->_text = trim($this->_text);
}

/**
* Метод для быстрого типографирования текста, при котором не нужно
* делать настройки тофов, их базовых параметров и т.п.
*
* @param string $text строка для типографирования
* @return string
*/
public static function quickParse($text)
{
$typograph = new self($text);
return $typograph->parse($typograph->getBaseTofsNames());
}

/**
* Возвращает массив из названий тофов, которые идут вместе с дистрибутивом
*
* @return array
*/
public function getBaseTofsNames()
{
return $this->_baseTof;
}

/**
* Добавление тофа в очередь на обработку текста
*
* @param string $name название тофа
* @param Jare_Typograph_Tof $object экземляр класса, унаследованного от 'Jare_Typograph_Tof'
* @throws Jare_Typograph_Exception
* @return void
*/
public function setTof($name, $object)
{
$name = strtolower($name);

if (!$object instanceof Jare_Typograph_Tof) {
require_once 'Pride/Typograph/Exception.php';
throw new Pride_Typograph_Exception("Tof '$name' class must be extend Jare_Typograph_Tof");
}

$this->_tof[$name] = $object;
$this->_tof[$name]->setStringToParse(&$this->_text);
}

/**
* Получение объекта тофа
*
* Если тоф не был раннее добавлен и при этом он является базовым, экземляр его класса
* будет создан автоматически
*
* @param string $name
* @throws Jare_Typograph_Exception
* @return Jare_Typograph_Tof
*/
public function getTof($name)
{
$name = strtolower($name);

if (!isset($this->_tof[$name])) {
if (!in_array($name, $this->_baseTof)) {
require_once 'Jare/Typograph/Exception.php';
throw new Jare_Typograph_Exception('Incorrect name of tof');
}

$fileName = 'Jare/Typograph/Tof/' . ucfirst($name) . '.php';
$className = 'Jare_Typograph_Tof_' . ucfirst($name);

require_once $fileName;

if (!class_exists($className, false)) {
require_once 'Jare/Typograph/Exception.php';
throw new Jare_Typograph_Exception('Class not exists');
}

$this->setTof($name, new $className);
}

return $this->_tof[$name];
}

/**
* Типографирование текста
*
* @param mixed $tofs строка или массив из названий тофов, которые будут применены при типографирование текста
* @throws Jare_Typograph_Exception
* @return string
*/
public function parse($tofs)
{
if (is_string($tofs)) {
$tofs = array($tofs);
}

if (!is_array($tofs)) {
require_once 'Jare/Typograph/Exception.php';
throw new Jare_Typograph_Exception('Incorrect type of tof-variable - try set array or string');
}

if (!count($tofs)) {
require_once 'Jare/Typograph/Exception.php';
throw new Jare_Typograph_Exception('You must set 1 or more tofs; your array is empty!');
}

require_once 'Jare/Typograph/Tool.php';
Jare_Typograph_Tool::addCustomBlocks('<pre>', '</pre>');
Jare_Typograph_Tool::addCustomBlocks('<script>', '</script>');
Jare_Typograph_Tool::addCustomBlocks('<style>', '</style>');

$this->_text = Jare_Typograph_Tool::safeCustomBlocks($this->_text, true);
$this->_text = Jare_Typograph_Tool::safeTagChars($this->_text, true);
$this->_text = Jare_Typograph_Tool::clearSpecialChars($this->_text);

foreach ($tofs as $tofName) {
$this->getTof($tofName)->parse();
}

$this->_text = Jare_Typograph_Tool::safeTagChars($this->_text, false);
$this->_text = Jare_Typograph_Tool::safeCustomBlocks($this->_text, false);

return $this->_text;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php
/**
* @see Jare_Exception
*/
require_once 'Jare/Exception.php';

/**
* Jare_Typograph_Exception
*
* @copyright Copyright (c) 2009 E.Muravjev Studio (http://emuravjev.ru)
* @license http://emuravjev.ru/works/tg/eula/
* @version 2.0.0
* @author Arthur Rusakov <arthur@emuravjev.ru>
* @category Jare
* @package Jare_Typograph
*/
class Jare_Typograph_Exception extends Jare_Exception
{
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
<?php
/**
* Jare_Typograph_Param
*
* @copyright Copyright (c) 2009 E.Muravjev Studio (http://emuravjev.ru)
* @license http://emuravjev.ru/works/tg/eula/
* @version 2.0.0
* @author Arthur Rusakov <arthur@emuravjev.ru>
* @category Jare
* @package Jare_Typograph
*/
class Jare_Typograph_Param
{
/**
* Ключи настроек
*/
const KEY_DISABLE_DEFAULT = '_disable';
const KEY_DISABLE_USER = 'user_disable';
const KEY_PARSE_PATTERN = 'pattern';
const KEY_PARSE_REPLACE = 'replacement';
const KEY_FUNCTION_LINK = 'function_link';
const KEY_POSITION = 'position';

/**
* Настройки
*
* @var array
*/
protected $_option = array();

/**
* Настройки, которые были заданы по умолчанию при создание экземпляра класса; невозможно изменить
*
* @var array
*/
protected $_defaultOption = array();

/**
* Конструктор
*
* @param array $option массив из настроек, которые будут заданы по умолчанию
* @return void
*/
public function __construct($option = array())
{
$this->_defaultOption = $option;
$this->_option = $option;
}

/**
* Отключение параметра
*
* @param bool $status
* @return Jare_Typograph_Param
*/
public function disable($status)
{
$this->_option[self::KEY_DISABLE_USER] = (bool) $status;
return $this;
}

/**
* Сброс заданных настроек к тем, которые были заданы при создание экземпляра класса
*
* @throws Jare_Typograph_Param_Exception
* @return Jare_Typograph_Param
*/
public function reset()
{
if (!count($this->_defaultOption)) {
require_once 'Jare/Typograph/Param/Exception.php';
throw new Jare_Typograph_Param_Exception('This parameter does not have default options');
}

$this->_option = $this->_defaultOption;

return $this;
}

/**
* Задание настройки
*
* @param string $name
* @param string $value
* @throws Jare_Typograph_Param_Exception
* @return Jare_Typograph_Param
*/
public function setOption($name, $value)
{
$name = strtolower($name);
$value = trim($value);

if ('_' === substr($name, 0, 1)) {
require_once 'Jare/Typograph/Param/Exception.php';
throw new Jare_Typograph_Param_Exception('Prefix "_" reserved for system option');
}

if (empty($value)) {
require_once 'Jare/Typograph/Param/Exception.php';
throw new Jare_Typograph_Param_Exception('Empty value. It\'s bad.');
}

switch ($name) {
case self::KEY_FUNCTION_LINK:
$this->_option[self::KEY_PARSE_PATTERN] = '';
$this->_option[self::KEY_PARSE_REPLACE] = '';
case self::KEY_PARSE_PATTERN:
case self::KEY_PARSE_REPLACE:
$this->_option[self::KEY_FUNCTION_LINK] = '';
}

$this->_option[$name] = $value;

return $this;
}

/**
* Возврат списка заданных настроек параметра
*
* @throws Jare_Typograph_Param_Exception
* @return array
*/
public function getOptions()
{
if (!count($this->_option)) {
require_once 'Jare/Typograph/Param/Exception.php';
throw new Jare_Typograph_Param_Exception('This parameter does not have options!');
}

if (!empty($this->_option[self::KEY_FUNCTION_LINK])) {
return $this->_option;
}

if (empty($this->_option[self::KEY_PARSE_PATTERN]) && !empty($this->_option[self::KEY_PARSE_REPLACE])) {
require_once 'Jare/Typograph/Param/Exception.php';
throw new Jare_Typograph_Param_Exception('You must set up pattern and replacement or function link');
}

return $this->_option;
}

/**
* Получение значения настройки
*
* @param string $name
* @throws Jare_Typograph_Param_Exception
* @return string
*/
public function getOption($name)
{
if (!in_array($name, $this->option)) {
require_once 'Jare/Typograph/Param/Exception.php';
throw new Jare_Typograph_Param_Exception("This option doesn't have value");
}

return $this->_option[$name];
}
}
Loading