示例#1
0
 /**
  * @param Document|Asset|Object_Abstract $element
  * @return array
  */
 public static function getDependencyForFrontend($element)
 {
     if ($element instanceof Document) {
         return array("id" => $element->getId(), "path" => $element->getFullPath(), "type" => "document", "subtype" => $element->getType());
     } else {
         if ($element instanceof Asset) {
             return array("id" => $element->getId(), "path" => $element->getFullPath(), "type" => "asset", "subtype" => $element->getType());
         } else {
             if ($element instanceof Object_Abstract) {
                 return array("id" => $element->getId(), "path" => $element->getFullPath(), "type" => "object", "subtype" => $element->geto_Type());
             }
         }
     }
 }
示例#2
0
 /**
  * Method to display a view.
  *
  * @param	boolean			If true, the view output will be cached
  * @param	array			An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}.
  *
  * @return	JController		This object to support chaining.
  * @since	1.5
  */
 public function display($cachable = false, $urlparams = false)
 {
     Plugin::import('content');
     $vName = Request::getCmd('view', 'images');
     switch ($vName) {
         case 'imagesList':
             $mName = 'list';
             $vLayout = Request::getCmd('layout', 'default');
             break;
         case 'images':
         default:
             $vLayout = Request::getCmd('layout', 'default');
             $mName = 'manager';
             $vName = 'images';
             break;
     }
     $vType = Document::getType();
     // Get/Create the view
     $view = $this->getView($vName, $vType);
     $view->addTemplatePath(JPATH_COMPONENT_ADMINISTRATOR . '/views/' . strtolower($vName) . '/tmpl');
     // Get/Create the model
     if ($model = $this->getModel($mName)) {
         // Push the model into the view (as default)
         $view->setModel($model, true);
     }
     // Set the layout
     $view->setLayout($vLayout);
     // Display the view
     $view->display();
     return $this;
 }
示例#3
0
 /**
  * @static
  * @param Document $doc
  * @return Document
  */
 public static function upperCastDocument(Document $doc)
 {
     $to_class = "Document_Hardlink_Wrapper_" . ucfirst($doc->getType());
     $old_serialized_prefix = "O:" . strlen(get_class($doc));
     $old_serialized_prefix .= ":\"" . get_class($doc) . "\":";
     $old_serialized_object = Pimcore_Tool_Serialize::serialize($doc);
     $new_serialized_object = 'O:' . strlen($to_class) . ':"' . $to_class . '":';
     $new_serialized_object .= substr($old_serialized_object, strlen($old_serialized_prefix));
     $document = Pimcore_Tool_Serialize::unserialize($new_serialized_object);
     return $document;
 }
示例#4
0
 /**
  * Method to display a view.
  *
  * @param	boolean			If true, the view output will be cached
  * @param	array			An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}.
  *
  * @return	JController		This object to support chaining.
  * @since	1.5
  */
 public function display($cachable = false, $urlparams = false)
 {
     Plugin::import('content');
     $vName = Request::getCmd('view', 'media');
     switch ($vName) {
         case 'images':
             $vLayout = Request::getCmd('layout', 'default');
             $mName = 'manager';
             break;
         case 'imagesList':
             $mName = 'list';
             $vLayout = Request::getCmd('layout', 'default');
             break;
         case 'mediaList':
             $mName = 'list';
             $vLayout = Request::getState('media.list.layout', 'layout', 'thumbs', 'word');
             break;
         case 'media':
         default:
             $vName = 'media';
             $vLayout = Request::getCmd('layout', 'default');
             $mName = 'manager';
             break;
     }
     $vType = Document::getType();
     // Get/Create the view
     $view = $this->getView($vName, $vType);
     // Get/Create the model
     if ($model = $this->getModel($mName)) {
         // Push the model into the view (as default)
         $view->setModel($model, true);
     }
     // Set the layout
     $view->setLayout($vLayout);
     // Display the view
     $view->display();
     return $this;
 }
示例#5
0
 /**
  * Method to catch the onAfterDispatch event.
  *
  * This is where we setup the click-through content highlighting for.
  * The highlighting is done with JavaScript so we just
  * need to check a few parameters and the JHtml behavior will do the rest.
  *
  * @return  boolean  True on success
  *
  * @since   2.5
  */
 public function onAfterDispatch()
 {
     // Check that we are in the site application.
     if (!App::isSite()) {
         return true;
     }
     // Set the variables
     $extension = Request::getCmd('option', '');
     // Check if the highlighter is enabled.
     if (!Component::params($extension)->get('highlight_terms', 1)) {
         return true;
     }
     // Check if the highlighter should be activated in this environment.
     if (Document::getType() !== 'html' || Request::getCmd('tmpl', '') === 'component') {
         return true;
     }
     // Get the terms to highlight from the request.
     $terms = Request::getVar('highlight', null, 'base64');
     $terms = $terms ? json_decode(base64_decode($terms)) : null;
     // Check the terms.
     if (empty($terms)) {
         return true;
     }
     // Clean the terms array
     $filter = JFilterInput::getInstance();
     $cleanTerms = array();
     foreach ($terms as $term) {
         $cleanTerms[] = htmlspecialchars($filter->clean($term, 'string'));
     }
     // Activate the highlighter.
     Html::behavior('highlighter', $cleanTerms);
     // Adjust the component buffer.
     $buf = Document::getBuffer('component');
     $buf = '<br id="highlighter-start" />' . $buf . '<br id="highlighter-end" />';
     Document::setBuffer($buf, 'component');
     return true;
 }
示例#6
0
文件: Href.php 项目: ngocanh/pimcore
 /**
  * @see Object_Class_Data::getDataForEditmode
  * @param Asset|Document|Object_Abstract $data
  * @param null|Object_Abstract $object
  * @return array
  */
 public function getDataForEditmode($data, $object = null)
 {
     if ($data) {
         $r = array("id" => $data->getId(), "path" => $data->getFullPath());
         if ($data instanceof Document) {
             $r["subtype"] = $data->getType();
             $r["type"] = "document";
         } else {
             if ($data instanceof Asset) {
                 $r["subtype"] = $data->getType();
                 $r["type"] = "asset";
             } else {
                 if ($data instanceof Object_Abstract) {
                     $r["subtype"] = $data->getO_Type();
                     $r["type"] = "object";
                 }
             }
         }
         return $r;
     }
     return;
 }
 /**
  * This method adds alternate meta tags for associated menu items
  *
  * @return	nothing
  * @since	1.7
  */
 public function onAfterDispatch()
 {
     if (App::isSite() && $this->params->get('alternate_meta') && Document::getType() == 'html') {
         // Get active menu item
         $active = App::get('menu')->getActive();
         if (!$active) {
             return;
         }
         // Get menu item link
         if (Config::get('sef')) {
             $active_link = Route::url('index.php?Itemid=' . $active->id, false);
         } else {
             $active_link = Route::url($active->link . '&Itemid=' . $active->id, false);
         }
         if ($active_link == JUri::base(true) . '/') {
             $active_link .= 'index.php';
         }
         // Get current link
         $current_link = Request::getUri();
         if ($current_link == Request::base(true) . '/') {
             $current_link .= 'index.php';
         }
         // Check the exact menu item's URL
         if ($active_link == $current_link) {
             // Get menu item associations
             JLoader::register('MenusHelper', PATH_CORE . '/components/com_menus/admin/helpers/menus.php');
             $associations = MenusHelper::getAssociations($active->id);
             // Remove current menu item
             unset($associations[$active->language]);
             // Associated menu items in other languages
             if ($associations && $this->params->get('menu_associations')) {
                 $menu = App::get('menu');
                 $server = JURI::getInstance()->toString(array('scheme', 'host', 'port'));
                 foreach (JLanguageHelper::getLanguages() as $language) {
                     if (isset($associations[$language->lang_code])) {
                         $item = $menu->getItem($associations[$language->lang_code]);
                         if ($item && Lang::exists($language->lang_code)) {
                             if (Config::get('sef')) {
                                 $link = Route::url('index.php?Itemid=' . $associations[$language->lang_code] . '&lang=' . $language->sef);
                             } else {
                                 $link = Route::url($item->link . '&Itemid=' . $associations[$language->lang_code] . '&lang=' . $language->sef);
                             }
                             // Check if language is the default site language and remove url language code is on
                             if ($language->sef == self::$default_sef && $this->params->get('remove_default_prefix') == '1') {
                                 $relLink = preg_replace('|/' . $language->sef . '/|', '/', $link, 1);
                                 Document::addHeadLink($server . $relLink, 'alternate', 'rel', array('hreflang' => $language->lang_code));
                             } else {
                                 Document::addHeadLink($server . $link, 'alternate', 'rel', array('hreflang' => $language->lang_code));
                             }
                         }
                     }
                 }
             } elseif ($active->home) {
                 $menu = App::get('menu');
                 $server = JURI::getInstance()->toString(array('scheme', 'host', 'port'));
                 foreach (JLanguageHelper::getLanguages() as $language) {
                     $item = $menu->getDefault($language->lang_code);
                     if ($item && $item->language != $active->language && $item->language != '*' && JLanguage::exists($language->lang_code)) {
                         if (Config::get('sef')) {
                             $link = Route::url('index.php?Itemid=' . $item->id . '&lang=' . $language->sef);
                         } else {
                             $link = Route::url($item->link . '&Itemid=' . $item->id . '&lang=' . $language->sef);
                         }
                         // Check if language is the default site language and remove url language code is on
                         if ($language->sef == self::$default_sef && $this->params->get('remove_default_prefix') == '1') {
                             $relLink = preg_replace('|/' . $language->sef . '/|', '/', $link, 1);
                             Document::addHeadLink($server . $relLink, 'alternate', 'rel', array('hreflang' => $language->lang_code));
                         } else {
                             Document::addHeadLink($server . $link, 'alternate', 'rel', array('hreflang' => $language->lang_code));
                         }
                     }
                 }
             }
         }
     }
 }
示例#8
0
 /**
  * Static helper to get a Document by it's id, only type Document is returned, not Document_Page, ... (see getConcreteById() )
  *
  * @param integer $id
  * @return Document
  */
 public static function getById($id)
 {
     $id = intval($id);
     if ($id < 1) {
         return null;
     }
     $cacheKey = "document_" . $id;
     try {
         $document = Zend_Registry::get($cacheKey);
         if (!$document) {
             throw new Exception("Document in registry is null");
         }
     } catch (Exception $e) {
         try {
             if (!($document = Pimcore_Model_Cache::load($cacheKey))) {
                 $document = new Document();
                 $document->getResource()->getById($id);
                 $typeClass = "Document_" . ucfirst($document->getType());
                 $typeClass = Pimcore_Tool::getModelClassMapping($typeClass);
                 if (Pimcore_Tool::classExists($typeClass)) {
                     $document = new $typeClass();
                     Zend_Registry::set($cacheKey, $document);
                     $document->getResource()->getById($id);
                     Pimcore_Model_Cache::save($document, $cacheKey);
                 }
             } else {
                 Zend_Registry::set($cacheKey, $document);
             }
         } catch (Exception $e) {
             Logger::warning($e);
             return null;
         }
     }
     if (!$document) {
         return null;
     }
     return $document;
 }
示例#9
0
/**
 * Функция вызывается перед тем как отдать содержимое файла
 * @param \Document $doc            Документ
 * @param string    $accessToken    Ключ доступа пользователя
 */
function getContent($doc, $accessToken)
{
    $ext = $doc->getType() == 1 ? ".p7s" : "";
    $doc->setName($doc->getName() . $ext);
}
示例#10
0
 /**
  * @param $item   Document object
  **/
 static function countForDocument(Document $item)
 {
     return countElementsInTable(array('glpi_documents_items'), ['glpi_documents_items.documents_id' => $item->getField('id'), 'NOT' => ['glpi_documents_items.itemtype' => $item->getType()]]);
 }
示例#11
0
 /**
  * @param $item   Document object
  **/
 static function countForDocument(Document $item)
 {
     $restrict = "`glpi_documents_items`.`documents_id` = '" . $item->getField('id') . "'\n                   AND `glpi_documents_items`.`itemtype` != '" . $item->getType() . "'";
     return countElementsInTable(array('glpi_documents_items'), $restrict);
 }
示例#12
0
 /**
  * Добавляет новый документ в БД
  * @global \TDataBase $DB
  * @param \Document $doc
  */
 static function insertDocument($doc)
 {
     global $DB;
     $parentId = $doc->getParentId();
     $childId = $doc->getChildId();
     if (is_null($parentId)) {
         $parentId = 'NULL';
     }
     if (is_null($childId)) {
         $childId = 'NULL';
     }
     $sql = 'INSERT INTO ' . TRUSTED_DB_TABLE_DOCUMENTS . '  ' . '(ORIGINAL_NAME, SYS_NAME, PATH, SIGNERS, TYPE, PARENT_ID, CHILD_ID)' . 'VALUES (' . '"' . $DB->EscapeString($doc->getName()) . '", ' . '"' . $DB->EscapeString($doc->getSysName()) . '", ' . '"' . $doc->getPath() . '", ' . "'" . $DB->EscapeString($doc->getSigners()) . "', " . $doc->getType() . ', ' . $parentId . ', ' . $childId . ')';
     $DB->Query($sql);
     $doc->setId($DB->LastID());
     TDataBaseDocument::saveDocumentParent($doc, $doc->getId());
 }
示例#13
0
 /**
  * Show the debug info
  */
 public function __destruct()
 {
     if (!App::isAdmin() && !App::isSite()) {
         return;
     }
     // Do not render if debugging or language debug is not enabled
     if (!Config::get('debug') && !Config::get('debug_lang')) {
         return;
     }
     // Load the language
     $this->loadLanguage();
     // Capture output
     // [!] zooley Nov 03, 2014 - PHP 5.4 changed behavior for ob_end_clean().
     //     ob_end_clean(), called in JError, clears and stops buffering.
     //     On error, pages, there will be no buller to get so ob_get_contents()
     //     will be false.
     $contents = ob_get_contents();
     if ($contents) {
         ob_end_clean();
     } else {
         return;
     }
     // No debug for Safari and Chrome redirection
     if (isset($_SERVER['HTTP_USER_AGENT']) && strstr(strtolower($_SERVER['HTTP_USER_AGENT']), 'webkit') !== false && substr($contents, 0, 50) == '<html><head><meta http-equiv="refresh" content="0;') {
         echo $contents;
         return;
     }
     // Only render for HTML output
     if ('html' !== Document::getType()) {
         echo $contents;
         return;
     }
     // If the user is not allowed to view the output then end here
     $filterGroups = (array) $this->params->get('filter_groups', null);
     if (!empty($filterGroups)) {
         $userGroups = User::get('groups');
         if (!array_intersect($filterGroups, $userGroups)) {
             echo $contents;
             return;
         }
     } else {
         $filterUsers = $this->params->get('filter_users', null);
         if (!empty($filterUsers)) {
             $filterUsers = explode(',', $filterUsers);
             $filterUsers = array_map('trim', $filterUsers);
             if (!in_array(\User::get('username'), $filterUsers)) {
                 echo $contents;
                 return;
             }
         }
     }
     // Load language file
     $this->loadLanguage('plg_system_debug');
     $html = '';
     // Some "mousewheel protecting" JS
     $html .= '<div id="system-debug" class="' . $this->params->get('theme', 'dark') . ' profiler">';
     $html .= '<div class="debug-head" id="debug-head">';
     $html .= '<h1>' . Lang::txt('PLG_DEBUG_TITLE') . '</h1>';
     $html .= '<a class="debug-close-btn" href="javascript:" onclick="Debugger.close();"><span class="icon-remove">' . Lang::txt('PLG_DEBUG_CLOSE') . '</span></a>';
     if (Config::get('debug')) {
         if ($this->params->get('memory', 1)) {
             $html .= '<span class="debug-indicator"><span class="icon-memory text" data-hint="' . Lang::txt('PLG_DEBUG_MEMORY_USAGE') . '">' . $this->displayMemoryUsage() . '</span></span>';
         }
         if (\JError::getErrors()) {
             $html .= '<a href="javascript:" class="debug-tab debug-tab-errors" onclick="Debugger.toggleContainer(this, \'debug-errors\');"><span class="text">' . Lang::txt('PLG_DEBUG_ERRORS') . '</span><span class="badge">' . count(\JError::getErrors()) . '</span></a>';
         }
         $dumper = \Hubzero\Debug\Dumper::getInstance();
         if ($dumper->hasMessages()) {
             $html .= '<a href="javascript:" class="debug-tab debug-tab-console" onclick="Debugger.toggleContainer(this, \'debug-debug\');"><span class="text">' . Lang::txt('PLG_DEBUG_CONSOLE') . '</span>';
             $html .= '<span class="badge">' . count($dumper->messages()) . '</span>';
             $html .= '</a>';
         }
         $html .= '<a href="javascript:" class="debug-tab debug-tab-request" onclick="Debugger.toggleContainer(this, \'debug-request\');"><span class="text">' . Lang::txt('PLG_DEBUG_REQUEST_DATA') . '</span></a>';
         $html .= '<a href="javascript:" class="debug-tab debug-tab-session" onclick="Debugger.toggleContainer(this, \'debug-session\');"><span class="text">' . Lang::txt('PLG_DEBUG_SESSION') . '</span></a>';
         if ($this->params->get('profile', 1)) {
             $html .= '<a href="javascript:" class="debug-tab debug-tab-timeline" onclick="Debugger.toggleContainer(this, \'debug-profile_information\');"><span class="text">' . Lang::txt('PLG_DEBUG_PROFILE_TIMELINE') . '</span></a>';
         }
         if ($this->params->get('queries', 1)) {
             $html .= '<a href="javascript:" class="debug-tab debug-tab-database" onclick="Debugger.toggleContainer(this, \'debug-queries\');"><span class="text">' . Lang::txt('PLG_DEBUG_QUERIES') . '</span><span class="badge">' . \App::get('db')->getCount() . '</span></a>';
         }
     }
     if (Config::get('debug_lang')) {
         if ($this->params->get('language_errorfiles', 1)) {
             $html .= '<a href="javascript:" class="debug-tab debug-tab-lang-errors" onclick="Debugger.toggleContainer(this, \'debug-language_files_in_error\');"><span class="text">' . Lang::txt('PLG_DEBUG_LANGUAGE_FILE_ERRORS') . '</span>';
             $html .= '<span class="badge">' . count(\Lang::getErrorFiles()) . '</span>';
             $html .= '</a>';
         }
         if ($this->params->get('language_files', 1)) {
             $total = 0;
             foreach (\Lang::getPaths() as $extension => $files) {
                 $total += count($files);
             }
             $html .= '<a href="javascript:" class="debug-tab debug-tab-lang-files" onclick="Debugger.toggleContainer(this, \'debug-language_files_loaded\');"><span class="text">' . Lang::txt('PLG_DEBUG_LANGUAGE_FILES_LOADED') . '</span>';
             $html .= '<span class="badge">' . $total . '</span>';
             $html .= '</a>';
         }
         if ($this->params->get('language_strings')) {
             $html .= '<a href="javascript:" class="debug-tab debug-tab-lang-untranslated" onclick="Debugger.toggleContainer(this, \'debug-untranslated_strings\');"><span class="text">' . Lang::txt('PLG_DEBUG_UNTRANSLATED') . '</span>';
             $html .= '<span class="badge">' . count(\Lang::getOrphans()) . '</span>';
             $html .= '</a>';
         }
     }
     $html .= '</div>';
     $html .= '<div class="debug-body" id="debug-body">';
     if (Config::get('debug')) {
         if ($dumper->hasMessages()) {
             $html .= $this->display('debug');
         }
         $html .= $this->display('request');
         $html .= $this->display('session');
         if ($this->params->get('profile', 1)) {
             $html .= $this->display('profile_information');
         }
         if ($this->params->get('memory', 1)) {
             $html .= $this->display('memory_usage');
         }
         if ($this->params->get('queries', 1)) {
             $html .= $this->display('queries');
         }
     }
     if (Config::get('debug_lang')) {
         if ($this->params->get('language_errorfiles', 1)) {
             $languageErrors = Lang::getErrorFiles();
             $html .= $this->display('language_files_in_error', $languageErrors);
         }
         if ($this->params->get('language_files', 1)) {
             $html .= $this->display('language_files_loaded');
         }
         if ($this->params->get('language_strings')) {
             $html .= $this->display('untranslated_strings');
         }
     }
     $html .= '</div>';
     $html .= '</div>';
     $html .= "<script type=\"text/javascript\">\n\t\tif (!document.getElementsByClassName) {\n\t\t\tdocument.getElementsByClassName = (function() {\n\t\t\t\tfunction traverse (node, callback) {\n\t\t\t\t\tcallback(node);\n\t\t\t\t\tfor (var i=0;i < node.childNodes.length; i++) {\n\t\t\t\t\t\ttraverse(node.childNodes[i],callback);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn function (name) {\n\t\t\t\t\tvar result = [];\n\t\t\t\t\ttraverse(document.body,function(node) {\n\t\t\t\t\t\tif (node.className && (' ' + node.className + ' ').indexOf(' ' + name + ' ') > -1) {\n\t\t\t\t\t\t\tresult.push(node);\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t\treturn result;\n\t\t\t\t}\n\t\t\t})();\n\t\t}\n\t\tDebugger = {\n\t\t\ttoggleShortFull: function(id) {\n\t\t\t\tvar d = document.getElementById('debug-' + id + '-short');\n\t\t\t\tif (!Debugger.hasClass(d, 'open')) {\n\t\t\t\t\tDebugger.addClass(d, 'open');\n\t\t\t\t} else {\n\t\t\t\t\tDebugger.removeClass(d, 'open');\n\t\t\t\t}\n\n\t\t\t\tvar g = document.getElementById('debug-' + id + '-full');\n\t\t\t\tif (!Debugger.hasClass(g, 'open')) {\n\t\t\t\t\tDebugger.addClass(g, 'open');\n\t\t\t\t} else {\n\t\t\t\t\tDebugger.removeClass(g, 'open');\n\t\t\t\t}\n\t\t\t},\n\t\t\tclose: function() {\n\t\t\t\tvar d = document.getElementById('system-debug');\n\t\t\t\tif (Debugger.hasClass(d, 'open')) {\n\t\t\t\t\tDebugger.removeClass(d, 'open');\n\t\t\t\t}\n\n\t\t\t\tDebugger.deactivate();\n\t\t\t},\n\t\t\tdeactivate: function() {\n\t\t\t\tvar items = document.getElementsByClassName('debug-tab');\n\t\t\t\tfor (var i=0;i<items.length;i++)\n\t\t\t\t{\n\t\t\t\t\tif (Debugger.hasClass(items[i], 'active')) {\n\t\t\t\t\t\tDebugger.removeClass(items[i], 'active');\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tvar items = document.getElementsByClassName('debug-container');\n\t\t\t\tfor (var i=0;i<items.length;i++)\n\t\t\t\t{\n\t\t\t\t\tif (Debugger.hasClass(items[i], 'open')) {\n\t\t\t\t\t\tDebugger.removeClass(items[i], 'open');\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t\ttoggleContainer: function(el, name) {\n\t\t\t\tif (!Debugger.hasClass(el, 'active')) {\n\t\t\t\t\tvar d = document.getElementById('system-debug');\n\t\t\t\t\tif (!Debugger.hasClass(d, 'open')) {\n\t\t\t\t\t\tDebugger.addClass(d, 'open');\n\t\t\t\t\t}\n\n\t\t\t\t\tDebugger.deactivate();\n\t\t\t\t\tDebugger.addClass(el, 'active');\n\n\t\t\t\t\tvar e = document.getElementById(name);\n\t\t\t\t\tif (e) {\n\t\t\t\t\t\tDebugger.toggleClass(e, 'open');\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tDebugger.close();\n\t\t\t\t}\n\t\t\t},\n\t\t\thasClass: function(elem, className) {\n\t\t\t\treturn new RegExp(' ' + className + ' ').test(' ' + elem.className + ' ');\n\t\t\t},\n\t\t\taddClass: function(elem, className) {\n\t\t\t\tif (!Debugger.hasClass(elem, className)) {\n\t\t\t\t\telem.className += ' ' + className;\n\t\t\t\t}\n\t\t\t},\n\t\t\tremoveClass: function(elem, className) {\n\t\t\t\tvar newClass = ' ' + elem.className.replace( /[\\t\\r\\n]/g, ' ') + ' ';\n\t\t\t\tif (Debugger.hasClass(elem, className)) {\n\t\t\t\t\twhile (newClass.indexOf(' ' + className + ' ') >= 0 ) {\n\t\t\t\t\t\tnewClass = newClass.replace(' ' + className + ' ', ' ');\n\t\t\t\t\t}\n\t\t\t\t\telem.className = newClass.replace(/^\\s+|\\s+\$/g, '');\n\t\t\t\t}\n\t\t\t},\n\t\t\ttoggleClass: function(elem, className) {\n\t\t\t\tvar newClass = ' ' + elem.className.replace( /[\\t\\r\\n]/g, ' ') + ' ';\n\t\t\t\tif (Debugger.hasClass(elem, className)) {\n\t\t\t\t\twhile (newClass.indexOf(' ' + className + ' ') >= 0 ) {\n\t\t\t\t\t\tnewClass = newClass.replace(' ' + className + ' ', ' ');\n\t\t\t\t\t}\n\t\t\t\t\telem.className = newClass.replace(/^\\s+|\\s+\$/g, '');\n\t\t\t\t} else {\n\t\t\t\t\telem.className += ' ' + className;\n\t\t\t\t}\n\t\t\t},\n\t\t\taddEvent: function(obj, type, fn) {\n\t\t\t\tif (obj.attachEvent) {\n\t\t\t\t\tobj['e'+type+fn] = fn;\n\t\t\t\t\tobj[type+fn] = function() {\n\t\t\t\t\t\tobj['e'+type+fn]( window.event );\n\t\t\t\t\t};\n\t\t\t\t\tobj.attachEvent('on' + type, obj[type+fn]);\n\t\t\t\t} else {\n\t\t\t\t\tobj.addEventListener( type, fn, false );\n\t\t\t\t}\n\t\t\t},\n\t\t\tremoveEvent: function( obj, type, fn ) {\n\t\t\t\tif (obj.detachEvent) {\n\t\t\t\t\tobj.detachEvent('on' + type, obj[type+fn]);\n\t\t\t\t\tobj[type+fn] = null;\n\t\t\t\t} else {\n\t\t\t\t\tobj.removeEventListener(type, fn, false);\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\n\t\tFunction.prototype.bindD = function(obj) {\n\t\t\tvar _method = this;\n\t\t\treturn function() {\n\t\t\t\treturn _method.apply(obj, arguments);\n\t\t\t};\n\t\t}\n\n\t\tfunction debugDrag(id) {\n\t\t\tthis.id = 'id';\n\t\t\tthis.direction = 'y';\n\t\t}\n\t\tdebugDrag.prototype = {\n\t\t\tinit: function(settings) {\n\t\t\t\tfor (var i in settings)\n\t\t\t\t{\n\t\t\t\t\tthis[i] = settings[i];\n\n\t\t\t\t\tfor (var j in settings[i])\n\t\t\t\t\t{\n\t\t\t\t\t\tthis[i][j] = settings[i][j];\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tthis.elem = (this.id.tagName==undefined) ? document.getElementById(this.id) : this.id;\n\t\t\t\tthis.container = this.elem.parentNode;\n\t\t\t\tthis.elem.onmousedown = this._mouseDown.bindD(this);\n\t\t\t},\n\n\t\t\t_mouseDown: function(e) {\n\t\t\t\te = e || window.event;\n\n\t\t\t\tthis.elem.onselectstart=function() {return false};\n\n\t\t\t\tthis._event_docMouseMove = this._docMouseMove.bindD(this);\n\t\t\t\tthis._event_docMouseUp = this._docMouseUp.bindD(this);\n\n\t\t\t\tif (this.onstart) this.onstart();\n\n\t\t\t\tthis.x = e.clientX || e.PageX;\n\t\t\t\tthis.y = e.clientY || e.PageY;\n\n\t\t\t\t//this.left = parseInt(this._getstyle(this.elem, 'left'));\n\t\t\t\t//this.top = parseInt(this._getstyle(this.elem, 'top'));\n\t\t\t\tthis.top = parseInt(this._getstyle(this.container, 'height'));\n\n\t\t\t\tDebugger.addEvent(document, 'mousemove', this._event_docMouseMove);\n\t\t\t\tDebugger.addEvent(document, 'mouseup', this._event_docMouseUp);\n\n\t\t\t\treturn false;\n\t\t\t},\n\n\t\t\t_getstyle: function(elem, prop) {\n\t\t\t\tif (document.defaultView) {\n\t\t\t\t\treturn document.defaultView.getComputedStyle(elem, null).getPropertyValue(prop);\n\t\t\t\t} else if (elem.currentStyle) {\n\t\t\t\t\tvar prop = prop.replace(/-(\\w)/gi, function(\$0,\$1)\n\t\t\t\t\t{\n\t\t\t\t\t\treturn \$1.toUpperCase();\n\t\t\t\t\t});\n\t\t\t\t\treturn elem.currentStyle[prop];\n\t\t\t\t} else {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t\t},\n\n\t\t\t_docMouseMove: function(e) {\n\t\t\t\tthis.setValuesClick(e);\n\t\t\t\tif (this.ondrag) this.ondrag();\n\t\t\t},\n\n\t\t\t_docMouseUp: function(e) {\n\t\t\t\tDebugger.removeEvent(document, 'mousemove', this._event_docMouseMove);\n\n\t\t\t\tif (this.onstop) this.onstop();\n\n\t\t\t\tDebugger.removeEvent(document, 'mouseup', this._event_docMouseUp);\n\t\t\t},\n\n\t\t\tsetValuesClick: function(e) {\n\t\t\t\tif (!Debugger.hasClass(this.container, 'open')) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tthis.mouseX = e.clientX || e.PageX;\n\t\t\t\tthis.mouseY = e.clientY || e.pageY;\n\n\t\t\t\tthis.Y = this.top + this.y - this.mouseY - parseInt(this._getstyle(document.getElementById('debug-head'), 'height')); //this.top + this.mouseY - this.y;\n\n\t\t\t\t//this.container.style.height = (this.Y + 6) +'px';\n\t\t\t\tdocument.getElementById('debug-body').style.height = (this.Y + 6) +'px';\n\t\t\t},\n\n\t\t\t_limit: function(val, mn, mx) {\n\t\t\t\treturn Math.min(Math.max(val, Math.min(mn, mx)), Math.max(mn, mx));\n\t\t\t}\n\t\t}\n\t\tvar dragBar = new debugDrag();\n\t\tdragBar.init({id:'debug-head'});\n\t\t</script>";
     echo str_replace('</body>', $html . '</body>', $contents);
 }
示例#14
0
 /**
  * This method convert a document into document link
  *
  * @param Document $document The document
  *
  * @return Fragment\Link\DocumentLink The document link
  */
 private function asLink($document)
 {
     return new Fragment\Link\DocumentLink($document->getId(), $document->getUid(), $document->getType(), $document->getTags(), $document->getSlug(), $document->getFragments(), false);
 }
示例#15
0
 /**
  * Method to display a view.
  *
  * @param	boolean			If true, the view output will be cached
  * @param	array			An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}.
  *
  * @return	JController		This object to support chaining.
  * @since	1.5
  */
 public function display($cachable = false, $urlparams = false)
 {
     // Get the document object.
     $document = Document::instance();
     // Set the default view name and format from the Request.
     $vName = Request::getCmd('view', 'login');
     $vFormat = Document::getType();
     $lName = Request::getCmd('layout', 'default');
     if ($view = $this->getView($vName, $vFormat)) {
         // Do any specific processing by view.
         switch ($vName) {
             case 'registration':
                 App::abort(403, Lang::txt('JLIB_APPLICATION_ERROR_ACCESS_FORBIDDEN'));
                 return;
                 // If the user is already logged in, redirect to the profile page.
                 if (User::get('guest') != 1) {
                     // Redirect to profile page.
                     $this->setRedirect(Route::url('index.php?option=com_users&view=profile', false));
                     return;
                 }
                 // Check if user registration is enabled
                 if (Component::params('com_users')->get('allowUserRegistration') == 0) {
                     // Registration is disabled - Redirect to login page.
                     $this->setRedirect(Route::url('index.php?option=com_users&view=login', false));
                     return;
                 }
                 // The user is a guest, load the registration model and show the registration page.
                 $model = $this->getModel('Registration');
                 break;
                 // Handle view specific models.
             // Handle view specific models.
             case 'profile':
                 App::abort(403, Lang::txt('JLIB_APPLICATION_ERROR_ACCESS_FORBIDDEN'));
                 return;
                 // If the user is a guest, redirect to the login page.
                 if (User::get('guest') == 1) {
                     // Redirect to login page.
                     $this->setRedirect(Route::url('index.php?option=com_users&view=login', false));
                     return;
                 }
                 $model = $this->getModel($vName);
                 break;
                 // Handle the default views.
             // Handle the default views.
             case 'login':
                 $model = $this->getModel($vName);
                 break;
             case 'reset':
                 // If the user is already logged in, redirect to the profile page.
                 if (User::get('guest') != 1) {
                     // Redirect to profile page.
                     $this->setRedirect(Route::url('index.php?option=com_members&task=myaccount', false));
                     return;
                 }
                 $model = $this->getModel($vName);
                 break;
             case 'remind':
                 // If the user is already logged in, redirect to the profile page.
                 if (User::get('guest') != 1) {
                     // Redirect to profile page.
                     $this->setRedirect(Route::url('index.php?option=com_members&task=myaccount', false));
                     return;
                 }
                 $model = $this->getModel($vName);
                 break;
             default:
                 $model = $this->getModel('Login');
                 break;
         }
         // Push the model into the view (as default).
         $view->setModel($model, true);
         $view->setLayout($lName);
         // Push document object into the view.
         $view->assignRef('document', $document);
         $view->display();
     }
 }
示例#16
0
 /**
  * @param  User $user
  * @param  Document $childDocument
  * @param  Document $parentDocument
  * @param boolean $expanded
  * @return
  */
 protected function getTreeNodePermissionConfig($user, $childDocument, $parentDocument, $expanded)
 {
     $userGroup = $user->getParent();
     if ($userGroup instanceof User) {
         $childDocument->getPermissionsForUser($userGroup);
         $lock_list = $childDocument->isAllowed("list");
         $lock_view = $childDocument->isAllowed("view");
         $lock_save = $childDocument->isAllowed("save");
         $lock_publish = $childDocument->isAllowed("publish");
         $lock_unpublish = $childDocument->isAllowed("unpublish");
         $lock_delete = $childDocument->isAllowed("delete");
         $lock_rename = $childDocument->isAllowed("rename");
         $lock_create = $childDocument->isAllowed("create");
         $lock_permissions = $childDocument->isAllowed("permissions");
         $lock_settings = $childDocument->isAllowed("settings");
         $lock_versions = $childDocument->isAllowed("versions");
         $lock_properties = $childDocument->isAllowed("properties");
         $lock_properties = $childDocument->isAllowed("properties");
     }
     if ($parentDocument) {
         $parentDocument->getPermissionsForUser($user);
     }
     $documentPermission = $childDocument->getPermissionsForUser($user);
     $generallyAllowed = $user->isAllowed("documents");
     $parentId = (int) $childDocument->getParentId();
     $parentAllowedList = true;
     if ($parentDocument instanceof Document) {
         $parentAllowedList = $parentDocument->isAllowed("list") and $generallyAllowed;
     }
     $tmpDocument = array("_parent" => $parentId > 0 ? $parentId : null, "_id" => (int) $childDocument->getId(), "text" => $childDocument->getKey(), "type" => $childDocument->getType(), "path" => $childDocument->getFullPath(), "basePath" => $childDocument->getPath(), "elementType" => "document", "permissionSet" => $documentPermission->getId() > 0 and $documentPermission->getCid() === $childDocument->getId(), "list" => $childDocument->isAllowed("list"), "list_editable" => $parentAllowedList and $generallyAllowed and !$lock_list and !$user->isAdmin(), "view" => $childDocument->isAllowed("view"), "view_editable" => $childDocument->isAllowed("list") and $generallyAllowed and !$lock_view and !$user->isAdmin(), "save" => $childDocument->isAllowed("save"), "save_editable" => $childDocument->isAllowed("list") and $generallyAllowed and !$lock_save and !$user->isAdmin(), "publish" => $childDocument->isAllowed("publish"), "publish_editable" => $childDocument->isAllowed("list") and $generallyAllowed and !$lock_publish and !$user->isAdmin(), "unpublish" => $childDocument->isAllowed("unpublish"), "unpublish_editable" => $childDocument->isAllowed("list") and $generallyAllowed and !$lock_unpublish and !$user->isAdmin(), "delete" => $childDocument->isAllowed("delete"), "delete_editable" => $childDocument->isAllowed("list") and $generallyAllowed and !$lock_delete and !$user->isAdmin(), "rename" => $childDocument->isAllowed("rename"), "rename_editable" => $childDocument->isAllowed("list") and $generallyAllowed and !$lock_rename and !$user->isAdmin(), "create" => $childDocument->isAllowed("create"), "create_editable" => $childDocument->isAllowed("list") and $generallyAllowed and !$lock_create and !$user->isAdmin(), "permissions" => $childDocument->isAllowed("permissions"), "permissions_editable" => $childDocument->isAllowed("list") and $generallyAllowed and !$lock_permissions and !$user->isAdmin(), "settings" => $childDocument->isAllowed("settings"), "settings_editable" => $childDocument->isAllowed("list") and $generallyAllowed and !$lock_settings and !$user->isAdmin(), "versions" => $childDocument->isAllowed("versions"), "versions_editable" => $childDocument->isAllowed("list") and $generallyAllowed and !$lock_versions and !$user->isAdmin(), "properties" => $childDocument->isAllowed("properties"), "properties_editable" => $childDocument->isAllowed("list") and $generallyAllowed and !$lock_properties and !$user->isAdmin());
     $tmpDocument["expanded"] = $expanded;
     $tmpDocument["iconCls"] = "pimcore_icon_" . $childDocument->getType();
     // set type specific settings
     if ($childDocument->getType() == "page") {
         $tmpDocument["_is_leaf"] = $childDocument->hasNoChilds();
         $tmpDocument["iconCls"] = "pimcore_icon_page";
         // test for a site
         try {
             $site = Site::getByRootId($childDocument->getId());
             $tmpDocument["iconCls"] = "pimcore_icon_site";
             $tmpDocument["site"] = $site;
         } catch (Exception $e) {
         }
     } else {
         if ($childDocument->getType() == "folder") {
             $tmpDocument["_is_leaf"] = $childDocument->hasNoChilds();
             if ($childDocument->hasNoChilds()) {
                 $tmpDocument["iconCls"] = "pimcore_icon_folder";
             }
         } else {
             if ($childDocument->getType() == "link") {
                 $tmpDocument["_is_leaf"] = $childDocument->hasNoChilds();
                 if ($childDocument->hasNoChilds()) {
                     $tmpDocument["iconCls"] = "pimcore_icon_link";
                 }
             } else {
                 $tmpDocument["leaf"] = true;
                 $tmpDocument["_is_leaf"] = true;
             }
         }
     }
     if (!$childDocument->isPublished()) {
         $tmpDocument["cls"] = "pimcore_unpublished";
     }
     return $tmpDocument;
 }
示例#17
0
 /**
  * Build a config object
  *
  * @return  object stdClass
  */
 private function _buildConfig($params = array())
 {
     static $template;
     // merge incoming params with
     $this->params->merge($params);
     // object to hold our final config
     $config = new stdClass();
     $config->startupMode = 'wysiwyg';
     $config->tabSpaces = 4;
     $config->height = '200px';
     $config->hubzeroAutogrow_autoStart = true;
     $config->hubzeroAutogrow_minHeight = 200;
     $config->hubzeroAutogrow_maxHeight = 1000;
     $config->toolbarCanCollapse = true;
     $config->extraPlugins = 'tableresize,iframedialog,hubzeroequation,hubzerogrid,hubzeromacro,hubzerohighlight';
     $config->removePlugins = '';
     $config->resize_enabled = true;
     $config->emailProtection = '';
     $config->protectedSource = array('/<group:include([^>]*)\\/>/g', '/{xhub:([^}]*)}/gi', '/<map[^>]*>(.|\\n)*<\\/map>/ig', '/<area([^>]*)\\/?>/ig');
     $config->extraAllowedContent = 'img(*)[*]; style(*)[*]; mark(*)[*]; span(*)[*]; map(*)[*]; area(*)[*]; *(*)[*]{*}';
     $config->specialChars = array('!', '&quot;', '#', '$', '%', '&amp;', "'", '(', ')', '*', '+', '-', '.', '/', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '&lt;', '=', '&gt;', '?', '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', ']', '^', '_', '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '|', '}', '~', "&euro;", "&lsquo;", "&rsquo;", "&ldquo;", "&rdquo;", "&ndash;", "&mdash;", "&iexcl;", "&cent;", "&pound;", "&curren;", "&yen;", "&brvbar;", "&sect;", "&uml;", "&copy;", "&ordf;", "&laquo;", "&not;", "&reg;", "&macr;", "&deg;", "&sup2;", "&sup3;", "&acute;", "&micro;", "&para;", "&middot;", "&cedil;", "&sup1;", "&ordm;", "&raquo;", "&frac14;", "&frac12;", "&frac34;", "&iquest;", "&Agrave;", "&Aacute;", "&Acirc;", "&Atilde;", "&Auml;", "&Aring;", "&AElig;", "&Ccedil;", "&Egrave;", "&Eacute;", "&Ecirc;", "&Euml;", "&Igrave;", "&Iacute;", "&Icirc;", "&Iuml;", "&ETH;", "&Ntilde;", "&Ograve;", "&Oacute;", "&Ocirc;", "&Otilde;", "&Ouml;", "&times;", "&Oslash;", "&Ugrave;", "&Uacute;", "&Ucirc;", "&Uuml;", "&Yacute;", "&THORN;", "&szlig;", "&agrave;", "&aacute;", "&acirc;", "&atilde;", "&auml;", "&aring;", "&aelig;", "&ccedil;", "&egrave;", "&eacute;", "&ecirc;", "&euml;", "&igrave;", "&iacute;", "&icirc;", "&iuml;", "&eth;", "&ntilde;", "&ograve;", "&oacute;", "&ocirc;", "&otilde;", "&ouml;", "&divide;", "&oslash;", "&ugrave;", "&uacute;", "&ucirc;", "&uuml;", "&yacute;", "&thorn;", "&yuml;", "&OElig;", "&oelig;", "&#372;", "&#374", "&#373", "&#375;", "&sbquo;", "&#8219;", "&bdquo;", "&hellip;", "&trade;", "&#9658;", "&bull;", "&rarr;", "&rArr;", "&hArr;", "&diams;", "&asymp;", "&Omega;");
     $config->disableNativeSpellChecker = false;
     $config->scayt_autoStartup = false;
     $config->scayt_contextCommands = 'all';
     $config->scayt_maxSuggestions = 5;
     $config->scayt_moreSuggestions = 'off';
     $config->bodyClass = 'ckeditor-body';
     $config->contentsCss = array();
     $config->templates = array('hubzero');
     $config->templates_files = array('/core/plugins/editors/ckeditor/assets/templates/hub.js');
     $config->templates_replaceContent = false;
     $config->filebrowserBrowseUrl = '';
     $config->filebrowserImageBrowseUrl = '';
     $config->filebrowserImageBrowseLinkUrl = '';
     $config->filebrowserUploadUrl = '';
     $config->filebrowserWindowWidth = 400;
     $config->filebrowserWindowHeight = 600;
     $config->toolbar = array(array('Find', 'Replace', '-', 'Scayt', 'Maximize', 'ShowBlocks'), array('Image', 'Table', 'HorizontalRule', 'Smiley', 'SpecialChar', 'PageBreak', 'Iframe', 'HubzeroEquation', 'HubzeroGrid', 'Templates'), array('Link', 'Unlink', 'Anchor'), '/', array('Format', 'Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript'), array('NumberedList', 'BulletedList', '-', 'Blockquote', 'CreateDiv', '-', 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock'), array('HubzeroMacro'));
     // if minimal toolbar
     if (in_array('minimal', $this->params->get('class'))) {
         $config->toolbar = array(array('Link', 'Unlink', 'Anchor'), array('Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript'), array('NumberedList', 'BulletedList'));
         $config->toolbarCanCollapse = false;
         // [QUBES][#561] SPW: always show resize, even in minimal mode
         //$config->resize_enabled = false;
         //$config->hubzeroAutogrow_autoStart = false;
     }
     // image plugin if in minimal mode
     if (in_array('minimal', $this->params->get('class')) && in_array('images', $this->params->get('class'))) {
         // push after links section
         $config->toolbar = array_merge(array_splice($config->toolbar, 0, 1), array(array('Image')), $config->toolbar);
     }
     // macros popup
     if (in_array('macros', $this->params->get('class'))) {
         $config->toolbar[] = array('HubzeroMacro');
     }
     // if no footer
     if (in_array('no-footer', $this->params->get('class'))) {
         $config->removePlugins = 'elementspath';
     }
     // setup codemirror
     $config->codemirror = new stdClass();
     $config->codemirror->autoFormatOnModeChange = false;
     $config->codemirror->autoCloseTags = false;
     $config->codemirror->autoCloseBrackets = false;
     // startup mode
     if (in_array($this->params->get('startupMode'), array('wysiwyg', 'source'))) {
         $config->startupMode = $this->params->get('startupMode');
     }
     // show source button
     if ($this->params->get('sourceViewButton')) {
         array_unshift($config->toolbar[0], 'Source', '-');
         $config->extraPlugins .= ',codemirror';
     }
     // height
     if ($this->params->get('height')) {
         $config->height = $this->params->get('height', '200px');
     }
     // // autogrow auto-start
     // if (is_bool($this->params->get('autoGrowAutoStart')))
     // {
     // 	$config->hubzeroAutogrow_autoStart = $this->params->get('autoGrowAutoStart');
     // }
     // // auto grow min height
     // if (is_numeric($this->params->get('autoGrowMinHeight')))
     // {
     // 	$config->hubzeroAutogrow_minHeight = $this->params->get('autoGrowMinHeight');
     // }
     // // autogrow max height
     // if (is_numeric($this->params->get('autoGrowMaxHeight')))
     // {
     // 	$config->hubzeroAutogrow_maxHeight = $this->params->get('autoGrowMaxHeight');
     // }
     // auto start spell check
     if (is_bool($this->params->get('spellCheckAutoStart'))) {
         $config->scayt_autoStartup = $this->params->get('spellCheckAutoStart');
     }
     // spell check max suggesstions
     if (is_numeric($this->params->get('spellCheckMaxSuggesstions'))) {
         $config->scayt_maxSuggestions = $this->params->get('spellCheckMaxSuggesstions');
     }
     // class to add to ckeditor body
     if ($this->params->get('contentBodyClass')) {
         $config->bodyClass = $this->params->get('contentBodyClass');
     }
     // add stylesheets to ckeditor content
     if (is_array($this->params->get('contentCss')) && count($this->params->get('contentCss'))) {
         $config->contentsCss = $this->params->get('contentCss');
     } else {
         // always get front end template
         if (!$template) {
             $db = App::get('db');
             $db->setQuery("SELECT `template` FROM `#__template_styles` WHERE `client_id`='0' AND `home`='1'");
             $template = $db->loadResult();
         }
         $app = substr(PATH_APP, strlen(PATH_ROOT));
         // vars to hold css
         $css = array();
         $siteCss = $app . '/cache/site/site.css';
         $templateCssA = $app . '/templates/' . $template . '/css/main.css';
         $templateCssC = '/core/templates/' . $template . '/css/main.css';
         // do we have a site.css
         if (file_exists(PATH_APP . $siteCss)) {
             array_push($css, $siteCss);
         }
         // do we have a template main.css
         if (file_exists(PATH_ROOT . $templateCssA)) {
             array_push($css, $templateCssA);
         } else {
             if (file_exists(PATH_ROOT . $templateCssC)) {
                 array_push($css, $templateCssC);
             }
         }
         if (Document::getType() == 'html') {
             $head = Document::getHeadData();
             // add already added stylesheets
             foreach ($head['styleSheets'] as $sheet => $attribs) {
                 array_push($css, $sheet);
             }
         }
         // set the content css
         $config->contentsCss = $css;
     }
     // file browsing
     if ($this->params->get('fileBrowserBrowseUrl')) {
         $config->filebrowserBrowseUrl = $this->params->get('fileBrowserBrowseUrl');
     }
     // image browsing
     if ($this->params->get('fileBrowserImageBrowseUrl')) {
         $config->filebrowserImageBrowseUrl = $this->params->get('fileBrowserImageBrowseUrl');
     }
     // file upload
     if ($this->params->get('fileBrowserUploadUrl')) {
         $config->filebrowserUploadUrl = $this->params->get('fileBrowserUploadUrl');
     }
     // file browse popup size
     if ($this->params->get('fileBrowserWindowWidth')) {
         $config->filebrowserWindowWidth = $this->params->get('fileBrowserWindowWidth');
     }
     if ($this->params->get('fileBrowserWindowHeight')) {
         $config->filebrowserWindowHeight = $this->params->get('fileBrowserWindowHeight');
     }
     // page templates
     if ($this->params->get('templates_files') && is_object($this->params->get('templates_files'))) {
         foreach ($this->params->get('templates_files') as $name => $template) {
             //make sure templates exists
             if (file_exists(PATH_ROOT . $template)) {
                 // do we want to replace original ones
                 if ($this->params->get('templates_replace')) {
                     $config->templates = array();
                     $config->templates_files = array();
                 }
                 array_push($config->templates, $name);
                 array_push($config->templates_files, $template);
             }
         }
     }
     // make template definition a string
     $config->templates = implode(',', $config->templates);
     // allow scripts
     if ($this->params->get('allowScriptTags')) {
         $config->protectedSource[] = '/<script[^>]*>(.|\\n)*<\\/script>/ig';
     }
     // allow php
     if ($this->params->get('allowPhpTags')) {
         $config->protectedSource[] = '/<\\?[\\s\\S]*?\\?>/g';
         $config->codemirror->mode = 'application/x-httpd-php';
     }
     // set editor skin
     $config->skin = $this->params->get('skin', 'moono');
     if (User::authorise('core.manage', 'com_system')) {
         $config->allowedContent = true;
     }
     return $config;
 }
示例#18
0
 /**
  *
  * Checks if an document is an allowed relation
  * @param Document $document
  * @return boolean
  */
 protected function allowDocumentRelation($document)
 {
     $allowedDocumentTypes = $this->getDocumentTypes();
     $allowed = true;
     if (!$this->getDocumentsAllowed()) {
         $allowed = false;
     } else {
         if ($this->getDocumentsAllowed() and is_array($allowedDocumentTypes) and count($allowedDocumentTypes) > 0) {
             //check for allowed asset types
             foreach ($allowedDocumentTypes as $t) {
                 $allowedTypes[] = $t['documentTypes'];
             }
             if (!in_array($document->getType(), $allowedTypes)) {
                 $allowed = false;
             }
         } else {
             //don't check if no allowed document types set
         }
     }
     \Logger::debug("checked object relation to target document [" . $document->getId() . "] in field [" . $this->getName() . "], allowed:" . $allowed);
     return $allowed;
 }