Example #1
0
 public static function display($name, $content, $hiddenField, $width, $height, $col, $row, $params)
 {
     $toolbar = isset($params['toolbar']) ? $params['toolbar'] : 'complete';
     $config = joosFile::exists(__DIR__ . '/toolbars/' . $toolbar . '.php') ? require_once __DIR__ . '/toolbars/' . $toolbar . '.php' : '';
     $code_on_ready = sprintf("\$().ready(function() { \$('#%s').wysiwyg(%s); })", $name, $config);
     joosDocument::$data['js_code'][] = $code_on_ready;
     return '<textarea name="' . $hiddenField . '" id="' . $hiddenField . '" cols="' . $col . '" rows="' . $row . '" style="width:' . $width . ';height:' . $height . ';">' . $content . '</textarea>';
 }
Example #2
0
 public static function load_by_name($module_name)
 {
     $module_file = JPATH_APP_BASE . DS . 'modules' . DS . $module_name . DS . $module_name . '.php';
     if (joosFile::exists($module_file)) {
         require_once $module_file;
     } else {
         throw new joosException('Файл :file_name для модуля :module_name не найден', array(':module_name' => $module_name, ':file_name' => $module_file));
     }
 }
Example #3
0
 /**
  * Исполнение указанного файла шаблона с указанными параметрами
  */
 public function render_file($template_file_name, $params = array())
 {
     extract($params, EXTR_OVERWRITE);
     if (!joosFile::exists($template_file_name)) {
         throw new joosModulesException("Не найден файл шаблона {$template_file_name}");
     }
     ob_start();
     require $template_file_name;
     $output = ob_get_contents();
     ob_end_clean();
     return $output;
 }
Example #4
0
 public static function optimize_and_save(array $files)
 {
     self::init();
     $cache_file = md5(serialize($files)) . '.js';
     $cache_file = self::$cache_folder . DS . $cache_file;
     if (!joosFile::exists($cache_file)) {
         foreach ($files as $file) {
             $file = explode('?', $file);
             $file = $file[0];
             $file = str_replace(JPATH_SITE, JPATH_BASE, $file);
             $file = str_replace('\\', '/', $file);
             self::$data[] = joosFile::exists($file) ? joosFile::get_content($file) : die($file);
         }
         $content = JSMin::minify(implode("\n;", self::$data));
         joosFile::create($cache_file, $content);
     }
     $cache_file_live = str_replace(JPATH_BASE, JPATH_SITE, $cache_file);
     $cache_file_live = str_replace('\\', '/', $cache_file_live);
     return array('live' => $cache_file_live, 'base' => $cache_file);
 }
Example #5
0
 /**
  * Инициализация редактора
  *
  * @param string $field_name название поля с текстом, на котором должен быть инициализирован редактоор
  * @param string $content    текст содержимого редактора
  * @param array  $params     массив настроек редактора
  *
  * @return mixed возвращает код инициализации редактора, либо полный код инициализации и комплекта необходимого HTML кода
  */
 public static function display($field_name, $content, array $params = array())
 {
     $hiddenField = isset($params['hiddenField']) ? $params['hiddenField'] : $field_name;
     $width = isset($params['width']) ? $params['width'] : '100%';
     $height = isset($params['height']) ? $params['height'] : 300;
     $col = isset($params['col']) ? $params['col'] : 10;
     $row = isset($params['row']) ? $params['row'] : 5;
     // попытаемся переопределить редактор если это указано в параметрах
     self::$editor = isset($params['editor']) ? $params['editor'] : self::$editor;
     // файл используемого визуального редактора
     $editor_file = JPATH_BASE . DS . 'app' . DS . 'plugins' . DS . 'editors' . DS . self::$editor . DS . self::$editor . '.php';
     if (joosFile::exists($editor_file)) {
         require_once $editor_file;
     } else {
         return sprintf('<!-- %s jooEditor::' . self::$editor . ' -->', 'Не найден редактор:');
     }
     $editor_class = 'pluginEditor' . joosInflector::camelize(self::$editor);
     // инициализация редактора
     !isset(self::$init[self::$editor]) ? call_user_func_array("{$editor_class}::init", array($params)) : null;
     self::$init[self::$editor] = true;
     // непосредственно область редактора
     return call_user_func_array("{$editor_class}::display", array($field_name, $content, $hiddenField, $width, $height, $col, $row, $params));
 }
Example #6
0
 public static function get_scheme($item)
 {
     $group = isset($item->params_group) ? $item->params_group : joosRequest::request('option');
     $file = 'app' . DS . 'components' . DS . $group . DS . 'params.' . $group . '.php';
     $file = JPATH_BASE . DS . $file;
     $model = 'params' . ucfirst($group);
     if (joosFile::exists($file)) {
         require_once $file;
         $params = array('notdefault' => array('name' => 'Использовать уникальные параметры', 'editable' => true, 'html_edit_element' => 'checkbox', 'html_edit_element_param' => array('text' => 'Использовать уникальные параметры')));
         $add_params = $model::get_params_scheme($item->params['subgroup']);
         if ($add_params) {
             $params += $model::get_params_scheme($item->params['subgroup']);
             return $params;
         }
         return false;
     } else {
         return false;
     }
 }
Example #7
0
 /**
  * Подключение шаблона
  *
  * @static
  * @param string $controller название контроллера
  * @param string $action     выполняемое действие
  * @param string $template   название шаблона оформления
  * @param array  $params     массив параметров, которые могут переданы в шаблон
  * @param array  $params
  */
 public static function get_view($controller, $action, $template = 'default', $params = array())
 {
     extract($params, EXTR_OVERWRITE);
     $viewfile = JPATH_BASE . DS . 'app' . DS . 'components' . DS . $controller . DS . 'views' . DS . $action . DS . $template . '.php';
     joosFile::exists($viewfile) ? require $viewfile : null;
 }
Example #8
0
 public static function get_edit_html_element($element_param, $key, $value, $obj_data, $params)
 {
     $class_file = JPATH_BASE . '/app/plugins/autoadmin/edit.' . $element_param['html_edit_element'] . '.php';
     $class_name = 'pluginAutoadminEdit' . self::get_plugin_name($element_param['html_edit_element']);
     if (!joosFile::exists($class_file)) {
         throw new joosAutoadminFilePluginNotFoundException(sprintf('Файл плагина joosAutoadmin %s  для редактирования элемента %s не найден', $class_file, $class_name));
     }
     require_once $class_file;
     if (!class_exists($class_name)) {
         throw new joosAutoadminClassPlugionNotFoundException(sprintf('Класс для обработки %s средствами joosAutoadmin в файле %s не найден', $class_file, $class_name));
     }
     return call_user_func_array($class_name . '::render', array($element_param, $key, $value, $obj_data, $params));
 }
 public function filegenerator()
 {
     $codes = self::codegenerator();
     $files = $codes['files_body'];
     $name = $codes['component_name'];
     if (!joosFile::is_writable(JPATH_APP_BASE . '/components/')) {
         return array('success' => false, 'message' => 'Не хватает прав для создания каталога компонента');
     }
     $component_root = JPATH_APP_BASE . '/components/' . $name;
     if (joosFile::exists($component_root)) {
         return array('success' => false, 'message' => 'Каталог компонента уже существует');
     }
     $dir_structure = array('{app}/components/{name}', '{app}/components/{name}/helpers', '{app}/components/{name}/media', '{app}/components/{name}/media/js', '{app}/components/{name}/media/css', '{app}/components/{name}/models', '{app}/components/{name}/views', '{app}/components/{name}/views_admin');
     $oldumask = umask(0);
     foreach ($dir_structure as $dir) {
         $create_dir = strtr($dir, array('{app}' => JPATH_APP_BASE, '{name}' => $name));
         joosFolder::create($create_dir, 0777);
     }
     foreach ($files as $file_name => $file_body) {
         echo $file_name . "\n";
         joosFile::put_content(sprintf('%s/components/%s/%s.php', JPATH_APP_BASE, $name, $file_name), $file_body);
     }
     umask($oldumask);
     //_xdump($files);
 }
Example #10
0
 /**
  * Создание GD-ресурса из файла
  *
  * @param  string $filename Имя файла.
  *
  * @return mixed GD image resource или FALSE при неудаче.
  * @access public
  * @static
  */
 public static function imageCreateFromFile($filename)
 {
     if (!joosFile::exists($filename) || !joosFile::is_readable($filename)) {
         throw new joosImageLibrariesException('Unable to open file "' . $filename . '"');
     }
     // determine image format
     list(, , $type) = getimagesize($filename);
     switch ($type) {
         case IMAGETYPE_JPEG:
             return imagecreatefromjpeg($filename);
             break;
         case IMAGETYPE_GIF:
             return imagecreatefromgif($filename);
             break;
         case IMAGETYPE_PNG:
             return imagecreatefrompng($filename);
             break;
     }
     throw new joosImageLibrariesException('Unsupport image type for file :file', array(':file' => $filename));
 }
Example #11
0
 private function root_xml_create()
 {
     $map_count = ceil($this->counters / $this->config['max_elemets_in_map']);
     $sitemap = array();
     for ($index = 1; $index < $map_count + 1; $index++) {
         $sitemap[] = sprintf('<sitemap><loc>%s/cache/sitemaps/sitemap-%s.xml</loc></sitemap>', JPATH_SITE, $index);
     }
     $xml = array();
     $xml[] = '<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
     $xml[] = implode("\n", $sitemap);
     $xml[] = "</sitemapindex>";
     joosFile::exists(JPATH_BASE . DS . 'sitemap.xml') ? unlink(JPATH_BASE . DS . 'sitemap.xml') : null;
     joosFile::put_content(JPATH_BASE . DS . 'sitemap.xml', implode("\n", $xml));
 }
Example #12
0
 /**
  *  Предстартовая загрузка необходимого списка
  *
  * @tutorial joosAutoloader( array('text','array','acl') )
  *
  * @static
  * @param  array                                      $names
  * @throws joosAutoloaderOnStartFileNotFoundException
  */
 public static function libraries_load_on_start(array $names = array())
 {
     foreach ($names as $name) {
         $file = JPATH_BASE . DS . 'core' . DS . 'libraries' . DS . $name . '.php';
         if (!joosFile::exists($file)) {
             throw new joosAutoloaderOnStartFileNotFoundException(sprintf('Автозагрузчки не смог найти файл %s для автозагружаемой библиотеки %', $file, $name));
         }
         require_once $file;
     }
 }
Example #13
0
 /**
  * Внутренний метод проверки существования файла
  * В случае ошибки выбрасывает исключение joosFileLibrariesException
  *
  * @static
  * @param $file_name путь к файлу
  * @throws joosFileLibrariesException
  */
 private static function exception_if_file_not_exists($file_name)
 {
     if (!joosFile::exists($file_name)) {
         throw new joosFileLibrariesException('Файл :file не существует', array(':file' => $file_name));
     }
 }