Ejemplo n.º 1
0
 protected static function _loadBehavior($group, $params = array())
 {
     static $loaded = array();
     if (!array_key_exists((string) $group, $loaded)) {
         // Include MooTools framework
         MHtml::_('behavior.framework', true);
         $options = '{';
         $opt['onActive'] = isset($params['onActive']) ? $params['onActive'] : null;
         $opt['onBackground'] = isset($params['onBackground']) ? $params['onBackground'] : null;
         $opt['display'] = isset($params['startOffset']) ? (int) $params['startOffset'] : null;
         $opt['useStorage'] = isset($params['useCookie']) && $params['useCookie'] ? 'true' : 'false';
         $opt['titleSelector'] = "'dt.tabs'";
         $opt['descriptionSelector'] = "'dd.tabs'";
         foreach ($opt as $k => $v) {
             if ($v) {
                 $options .= $k . ': ' . $v . ',';
             }
         }
         if (substr($options, -1) == ',') {
             $options = substr($options, 0, -1);
         }
         $options .= '}';
         $js = ' jQuery(document).ready(function () {
                     $$(\'dl#' . $group . '.tabs\').each(function(tabs){
                         new MTabs(tabs, ' . $options . ');
                     });
                 });';
         $document = MFactory::getDocument();
         $document->addScriptDeclaration($js);
         MHtml::_('script', 'system/tabs.js', false, true);
         $loaded[(string) $group] = true;
     }
 }
Ejemplo n.º 2
0
 public function display($tpl = null)
 {
     $document = MFactory::getDocument();
     $document->addStyleSheet(MURL_MIWOSQL . '/admin/assets/css/miwosql.css');
     // Toolbar
     MToolBarHelper::title(MText::_('MiwoSQL') . ' - ' . MText::_('COM_MIWOSQL_RUN_QUERY'), 'miwosql');
     if (MiwosqlHelper::is30()) {
         MToolBarHelper::custom('run', 'play.png', 'play.png', MText::_('COM_MIWOSQL_RUN_QUERY'), false);
         MToolBarHelper::divider();
         MToolBarHelper::custom('savequery', 'folder-close.png', 'folder-close.png', MText::_('COM_MIWOSQL_SAVE_QUERY'), false);
         MToolBarHelper::divider();
         MToolBarHelper::custom('csv', 'upload.png', 'upload.png', MText::_('COM_MIWOSQL_EXPORT_CSV'), false);
     } else {
         MToolBarHelper::custom('run', 'run.png', 'run.png', MText::_('COM_MIWOSQL_RUN_QUERY'), false);
         MToolBarHelper::divider();
         MToolBarHelper::custom('savequery', 'savequery.png', 'savequery.png', MText::_('COM_MIWOSQL_SAVE_QUERY'), false);
         MToolBarHelper::divider();
         MToolBarHelper::custom('csv', 'csv.png', 'csv.png', MText::_('COM_MIWOSQL_EXPORT_CSV'), false);
     }
     // ACL
     if (version_compare(MVERSION, '1.6.0', 'ge') && MFactory::getUser()->authorise('core.admin', 'com_miwosql')) {
         MToolBarHelper::divider();
         MToolBarHelper::preferences('com_miwosql', '550');
     }
     $this->data = $this->get('Data');
     $this->tables = $this->get('Tables');
     $this->prefix = $this->get('Prefix');
     parent::display($tpl);
 }
Ejemplo n.º 3
0
 protected static function _loadBehavior($group, $params = array())
 {
     static $loaded = array();
     if (!array_key_exists($group, $loaded)) {
         $loaded[$group] = true;
         // Include mootools framework.
         MHtml::_('behavior.framework', true);
         $document = MFactory::getDocument();
         $display = isset($params['startOffset']) && isset($params['startTransition']) && $params['startTransition'] ? (int) $params['startOffset'] : null;
         $show = isset($params['startOffset']) && !(isset($params['startTransition']) && $params['startTransition']) ? (int) $params['startOffset'] : null;
         $options = '{';
         $opt['onActive'] = "function(toggler, i) {toggler.addClass('pane-toggler-down');" . "toggler.removeClass('pane-toggler');i.addClass('pane-down');i.removeClass('pane-hide');Cookie.write('jpanesliders_" . $group . "',\$\$('div#" . $group . ".pane-sliders > .panel > h3').indexOf(toggler));}";
         $opt['onBackground'] = "function(toggler, i) {toggler.addClass('pane-toggler');" . "toggler.removeClass('pane-toggler-down');i.addClass('pane-hide');i.removeClass('pane-down');if(\$\$('div#" . $group . ".pane-sliders > .panel > h3').length==\$\$('div#" . $group . ".pane-sliders > .panel > h3.pane-toggler').length) Cookie.write('jpanesliders_" . $group . "',-1);}";
         $opt['duration'] = isset($params['duration']) ? (int) $params['duration'] : 300;
         $opt['display'] = isset($params['useCookie']) && $params['useCookie'] ? MRequest::getInt('jpanesliders_' . $group, $display, 'cookie') : $display;
         $opt['show'] = isset($params['useCookie']) && $params['useCookie'] ? MRequest::getInt('jpanesliders_' . $group, $show, 'cookie') : $show;
         $opt['opacity'] = isset($params['opacityTransition']) && $params['opacityTransition'] ? 'true' : 'false';
         $opt['alwaysHide'] = isset($params['allowAllClose']) && !$params['allowAllClose'] ? 'false' : 'true';
         foreach ($opt as $k => $v) {
             if ($v) {
                 $options .= $k . ': ' . $v . ',';
             }
         }
         if (substr($options, -1) == ',') {
             $options = substr($options, 0, -1);
         }
         $options .= '}';
         $js = "jQuery(document).ready(function () { new Fx.Accordion(\$\$('div#" . $group . ".pane-sliders > .panel > h3.pane-toggler'), \$\$('div#" . $group . ".pane-sliders > .panel > div.pane-slider'), " . $options . "); });";
         $document->addScriptDeclaration($js);
     }
 }
Ejemplo n.º 4
0
 function display($tpl = null)
 {
     $mainframe = MFactory::getApplication();
     $option = MRequest::getCmd('option');
     $document = MFactory::getDocument();
     $document->addStyleSheet(MURL_MIWOSQL . '/admin/assets/css/miwosql.css');
     MToolBarHelper::title(MText::_('MiwoSQL') . ' - ' . MText::_('COM_MIWOSQL_SAVED_QUERIES'), 'miwosql');
     MToolBarHelper::editList();
     MToolBarHelper::deleteList();
     // ACL
     if (version_compare(MVERSION, '1.6.0', 'ge') && MFactory::getUser()->authorise('core.admin', 'com_miwosql')) {
         MToolBarHelper::divider();
         MToolBarHelper::preferences('com_miwosql', '550');
     }
     $this->mainframe = MFactory::getApplication();
     $this->option = MRequest::getWord('option');
     $filter_order = $mainframe->getUserStateFromRequest($option . '.queries.filter_order', 'filter_order', 'title', 'string');
     $filter_order_Dir = $mainframe->getUserStateFromRequest($option . '.queries.filter_order_Dir', 'filter_order_Dir', '', 'word');
     $search = $mainframe->getUserStateFromRequest($option . '.queries.search', 'search', '', 'string');
     // table ordering
     $lists['order_Dir'] = $filter_order_Dir;
     $lists['order'] = $filter_order;
     // search filter
     $lists['search'] = $search;
     $this->lists = $lists;
     $this->items = $this->get('Data');
     $this->pagination = $this->get('Pagination');
     parent::display($tpl);
 }
Ejemplo n.º 5
0
 public function display($tpl = null)
 {
     $document = MFactory::getDocument();
     $document->addStyleSheet(MURL_MIWOSQL . '/admin/assets/css/miwosql.css');
     // Toolbar
     MToolBarHelper::title(MText::_('MiwoSQL'), 'miwosql');
     MToolBarHelper::save();
     MToolBarHelper::cancel();
     $this->row = $this->get('QueryData');
     parent::display($tpl);
 }
Ejemplo n.º 6
0
 public function display($tpl = null)
 {
     $db = MFactory::getDbo();
     $task = MRequest::getCmd('task');
     $table = MiwosqlHelper::getVar('tbl');
     $query = MiwosqlHelper::getVar('qry');
     $id = MRequest::getInt('id', MRequest::getInt('id', null, 'post'), 'get');
     $key = MRequest::getCmd('key', MRequest::getCmd('key', null, 'post'), 'get');
     $document = MFactory::getDocument();
     $document->addStyleSheet(MURL_MIWOSQL . '/admin/assets/css/miwosql.css');
     // Toolbar
     MToolBarHelper::title(MText::_('MiwoSQL') . ': <small><small> ' . $table . ' [ ' . $key . ' = ' . $id . ' ]' . ' </small></small>', 'miwosql');
     MToolBarHelper::apply();
     MToolBarHelper::save();
     MToolBarHelper::divider();
     MToolBarHelper::cancel();
     if ($task == 'edit') {
         $fld_value = '$value = $this->rows[$this->id][$field];';
     } else {
         $fld_value = '$value = "";';
     }
     list($rows, $last_key_vol) = $this->get('Data');
     $this->task = $task;
     $this->id = $id;
     $this->key = $key;
     $this->table = $table;
     $this->query = $query;
     $this->fld_value = $fld_value;
     $this->last_key_vol = $last_key_vol;
     $this->rows = $rows;
     $fields = $this->get('Fields');
     if (!MiwosqlHelper::is30()) {
         $fields = $fields[$this->table];
     }
     $this->fields = $fields;
     parent::display($tpl);
 }
Ejemplo n.º 7
0
        //MRequest::clean();  // miwisoft ticket 110
    }
}
MLoader::import('framework.object.object');
MLoader::import('framework.text.text');
MLoader::import('framework.route.route');
// Register the library base path for CMS libraries.
MLoader::registerPrefix('M', MPATH_MIWI . '/framework');
// Define the Miwi version if not already defined.
if (!defined('MVERSION')) {
    $Mversion = new MVersion();
    define('MVERSION', $Mversion->getShortVersion());
}
mimport('framework.application.menu');
mimport('framework.environment.uri');
mimport('framework.utilities.utility');
mimport('framework.event.dispatcher');
mimport('framework.utilities.arrayhelper');
mimport('framework.access.access');
mimport('framework.user.user');
mimport('framework.document.document');
mimport('phputf8.utf8');
mimport('framework.database.table');
if (is_admin()) {
    mimport('framework.html.toolbar');
    mimport('framework.html.toolbar.helper');
}
mimport('framework.application.component.helper');
// Base.css file
MFactory::getDocument()->addStyleSheet(MURL_WP_CNT . '/miwi/media/system/css/base.css');
Ejemplo n.º 8
0
 public function safelyAddScript()
 {
     $document = MFactory::getDocument();
     $scripts = $document->_scripts;
     foreach ($scripts as $script) {
         wp_enqueue_script($script, $script);
     }
     #inline scripts
     $script = $document->_script;
     if (empty($script)) {
         return;
     }
     global $wp_scripts;
     foreach ($script as $key => $_script) {
         wp_register_script($key, MURL_WP_CNT . '/miwi/media/system/js/miwiscript.js', array(), false, true);
         $wp_scripts->add_data($key, 'data', $_script);
         wp_enqueue_script($key);
     }
     #############
     return;
 }
Ejemplo n.º 9
0
 public function redirect($url, $msg = '', $msgType = 'message', $moved = false)
 {
     // Check for relative internal links.
     if (preg_match('#^index2?\\.php#', $url)) {
         $url = MUri::base() . $url;
     }
     // Strip out any line breaks.
     $url = preg_split("/[\r\n]/", $url);
     $url = $url[0];
     // If we don't start with a http we need to fix this before we proceed.
     // We could validly start with something else (e.g. ftp), though this would
     // be unlikely and isn't supported by this API.
     if (!preg_match('#^http#i', $url)) {
         $uri = MUri::getInstance();
         $prefix = $uri->toString(array('scheme', 'user', 'pass', 'host', 'port'));
         if ($url[0] == '/') {
             // We just need the prefix since we have a path relative to the root.
             $url = $prefix . $url;
         } else {
             // It's relative to where we are now, so lets add that.
             $parts = explode('/', $uri->toString(array('path')));
             array_pop($parts);
             $path = implode('/', $parts) . '/';
             $url = $prefix . $path . $url;
         }
     }
     // If the message exists, enqueue it.
     if (trim($msg)) {
         $this->enqueueMessage($msg, $msgType);
     }
     // Persist messages if they exist.
     if (count($this->_messageQueue)) {
         $session = MFactory::getSession();
         $session->set('application.queue', $this->_messageQueue);
     }
     // WP redirect
     if ($this->isAdmin()) {
         $option = str_replace('com_', '', MRequest::getCmd('option'));
         $url = str_replace('index.php?', 'admin.php?page=' . $option . '&', $url);
     }
     // If the headers have been sent, then we cannot send an additional location header
     // so we will output a javascript redirect statement.
     if (headers_sent()) {
         echo "<script>document.location.href='" . str_replace("'", "&apos;", $url) . "';</script>\n";
     } else {
         mimport('phputf8.utils.ascii');
         mimport('framework.environment.browser');
         $document = MFactory::getDocument();
         $navigator = MBrowser::getInstance();
         if ($navigator->isBrowser('msie') && !utf8_is_ascii($url)) {
             // MSIE type browser and/or server cause issues when url contains utf8 character,so use a javascript redirect method
             echo '<html><head><meta http-equiv="content-type" content="text/html; charset=' . $document->getCharset() . '" />' . '<script>document.location.href=\'' . str_replace("'", "&apos;", $url) . '\';</script></head></html>';
         } elseif (!$moved and $navigator->isBrowser('konqueror')) {
             // WebKit browser (identified as konqueror by Joomla!) - Do not use 303, as it causes subresources
             // reload (https://bugs.webkit.org/show_bug.cgi?id=38690)
             echo '<html><head><meta http-equiv="content-type" content="text/html; charset=' . $document->getCharset() . '" />' . '<meta http-equiv="refresh" content="0; url=' . str_replace("'", "&apos;", $url) . '" /></head></html>';
         } else {
             // All other browsers, use the more efficient HTTP header method
             header($moved ? 'HTTP/1.1 301 Moved Permanently' : 'HTTP/1.1 303 See other');
             header('Location: ' . $url);
             header('Content-Type: text/html; charset=' . $document->getCharset());
         }
     }
     $this->close();
 }
Ejemplo n.º 10
0
    public static function behavior()
    {
        static $loaded;
        if (!$loaded) {
            // Build the behavior script.
            $js = '
		jQuery(document).ready(function () {
			actions = $$(\'a.move_up\');
			actions.combine($$(\'a.move_down\'));
			actions.combine($$(\'a.grid_true\'));
			actions.combine($$(\'a.grid_false\'));
			actions.combine($$(\'a.grid_trash\'));
			actions.each(function(a){
				a.addEvent(\'click\', function(){
					args = JSON.decode(this.rel);
					listItemTask(args.id, args.task);
				});
			});
			$$(\'input.check-all-toggle\').each(function(el){
				el.addEvent(\'click\', function(){
					if (el.checked) {
						document.id(this.form).getElements(\'input[type=checkbox]\').each(function(i){
							i.checked = true;
						})
					}
					else {
						document.id(this.form).getElements(\'input[type=checkbox]\').each(function(i){
							i.checked = false;
						})
					}
				});
			});
		});';
            // Add the behavior to the document head.
            $document = MFactory::getDocument();
            $document->addScriptDeclaration($js);
            $loaded = true;
        }
    }
Ejemplo n.º 11
0
 public static function setWorkarounds($data, $options = array())
 {
     $loptions = array();
     $loptions['nopathway'] = 0;
     $loptions['nohead'] = 0;
     $loptions['nomodules'] = 0;
     $loptions['modulemode'] = 0;
     if (isset($options['nopathway'])) {
         $loptions['nopathway'] = $options['nopathway'];
     }
     if (isset($options['nohead'])) {
         $loptions['nohead'] = $options['nohead'];
     }
     if (isset($options['nomodules'])) {
         $loptions['nomodules'] = $options['nomodules'];
     }
     if (isset($options['modulemode'])) {
         $loptions['modulemode'] = $options['modulemode'];
     }
     $app = MFactory::getApplication();
     $document = MFactory::getDocument();
     $buffer1 = $document->getBuffer();
     if (!is_array($buffer1)) {
         $buffer1 = array();
     }
     if (!isset($buffer1['module']) || !is_array($buffer1['module'])) {
         $buffer1['module'] = array();
     }
     $cached['body'] = $data;
     if ($loptions['nohead'] != 1 && method_exists($document, 'getHeadData')) {
         if ($loptions['modulemode'] == 1) {
             $headnow = $document->getHeadData();
             $unset = array('title', 'description', 'link', 'links', 'metaTags');
             foreach ($unset as $un) {
                 unset($headnow[$un]);
                 unset($options['headerbefore'][$un]);
             }
             $cached['head'] = array();
             foreach ($headnow as $now => $value) {
                 if (isset($options['headerbefore'][$now])) {
                     $nowvalue = array_map('serialize', $headnow[$now]);
                     $beforevalue = array_map('serialize', $options['headerbefore'][$now]);
                     $newvalue = array_diff_assoc($nowvalue, $beforevalue);
                     $newvalue = array_map('unserialize', $newvalue);
                     if (($now == 'script' || $now == 'style') && is_array($newvalue) && is_array($options['headerbefore'][$now])) {
                         foreach ($newvalue as $type => $currentScriptStr) {
                             if (isset($options['headerbefore'][$now][strtolower($type)])) {
                                 $oldScriptStr = $options['headerbefore'][$now][strtolower($type)];
                                 if ($oldScriptStr != $currentScriptStr) {
                                     $newvalue[strtolower($type)] = MString::substr($currentScriptStr, MString::strlen($oldScriptStr));
                                 }
                             }
                         }
                     }
                 } else {
                     $newvalue = $headnow[$now];
                 }
                 if (!empty($newvalue)) {
                     $cached['head'][$now] = $newvalue;
                 }
             }
         } else {
             $cached['head'] = $document->getHeadData();
         }
     }
     if ($app->isSite() && $loptions['nopathway'] != 1) {
         $pathway = $app->getPathWay();
         $cached['pathway'] = isset($data['pathway']) ? $data['pathway'] : $pathway->getPathway();
     }
     if ($loptions['nomodules'] != 1) {
         $buffer2 = $document->getBuffer();
         if (!is_array($buffer2)) {
             $buffer2 = array();
         }
         if (!isset($buffer2['module']) || !is_array($buffer2['module'])) {
             $buffer2['module'] = array();
         }
         $cached['module'] = array_diff_assoc($buffer2['module'], $buffer1['module']);
     }
     return $cached;
 }
Ejemplo n.º 12
0
 protected function getInput()
 {
     $assetField = $this->element['asset_field'] ? (string) $this->element['asset_field'] : 'asset_id';
     $authorField = $this->element['created_by_field'] ? (string) $this->element['created_by_field'] : 'created_by';
     $asset = $this->form->getValue($assetField) ? $this->form->getValue($assetField) : (string) $this->element['asset_id'];
     if ($asset == '') {
         $asset = MRequest::getCmd('option');
     }
     $link = (string) $this->element['link'];
     if (!self::$initialised) {
         // Load the modal behavior script.
         MHtml::_('behavior.modal');
         // Build the script.
         $script = array();
         $script[] = '	function jInsertFieldValue(value, id) {';
         $script[] = '		var old_value = document.id(id).value;';
         $script[] = '		if (old_value != value) {';
         $script[] = '			var elem = document.id(id);';
         $script[] = '			elem.value = value;';
         $script[] = '			elem.fireEvent("change");';
         $script[] = '			if (typeof(elem.onchange) === "function") {';
         $script[] = '				elem.onchange();';
         $script[] = '			}';
         $script[] = '			jMediaRefreshPreview(id);';
         $script[] = '		}';
         $script[] = '	}';
         $script[] = '	function jMediaRefreshPreview(id) {';
         $script[] = '		var value = document.id(id).value;';
         $script[] = '		var img = document.id(id + "_preview");';
         $script[] = '		if (img) {';
         $script[] = '			if (value) {';
         $script[] = '				img.src = "' . MURI::root() . '" + value;';
         $script[] = '				document.id(id + "_preview_empty").setStyle("display", "none");';
         $script[] = '				document.id(id + "_preview_img").setStyle("display", "");';
         $script[] = '			} else { ';
         $script[] = '				img.src = ""';
         $script[] = '				document.id(id + "_preview_empty").setStyle("display", "");';
         $script[] = '				document.id(id + "_preview_img").setStyle("display", "none");';
         $script[] = '			} ';
         $script[] = '		} ';
         $script[] = '	}';
         $script[] = '	function jMediaRefreshPreviewTip(tip)';
         $script[] = '	{';
         $script[] = '		tip.setStyle("display", "block");';
         $script[] = '		var img = tip.getElement("img.media-preview");';
         $script[] = '		var id = img.getProperty("id");';
         $script[] = '		id = id.substring(0, id.length - "_preview".length);';
         $script[] = '		jMediaRefreshPreview(id);';
         $script[] = '	}';
         // Add the script to the document head.
         MFactory::getDocument()->addScriptDeclaration(implode("\n", $script));
         self::$initialised = true;
     }
     // Initialize variables.
     $html = array();
     $attr = '';
     // Initialize some field attributes.
     $attr .= $this->element['class'] ? ' class="' . (string) $this->element['class'] . '"' : '';
     $attr .= $this->element['size'] ? ' size="' . (int) $this->element['size'] . '"' : '';
     // Initialize JavaScript field attributes.
     $attr .= $this->element['onchange'] ? ' onchange="' . (string) $this->element['onchange'] . '"' : '';
     // The text field.
     $html[] = '<div class="fltlft">';
     $html[] = '	<input type="text" name="' . $this->name . '" id="' . $this->id . '"' . ' value="' . htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8') . '"' . ' readonly="readonly"' . $attr . ' />';
     $html[] = '</div>';
     $directory = (string) $this->element['directory'];
     if ($this->value && file_exists(MPATH_ROOT . '/' . $this->value)) {
         $folder = explode('/', $this->value);
         array_shift($folder);
         array_pop($folder);
         $folder = implode('/', $folder);
     } elseif (file_exists(MPATH_ROOT . '/' . MComponentHelper::getParams('com_media')->get('image_path', 'images') . '/' . $directory)) {
         $folder = $directory;
     } else {
         $folder = '';
     }
     // The button.
     $html[] = '<div class="button2-left">';
     $html[] = '	<div class="blank">';
     $html[] = '		<a class="modal" title="' . MText::_('MLIB_FORM_BUTTON_SELECT') . '"' . ' href="' . ($this->element['readonly'] ? '' : ($link ? $link : 'index.php?option=com_media&amp;view=images&amp;tmpl=component&amp;asset=' . $asset . '&amp;author=' . $this->form->getValue($authorField)) . '&amp;fieldid=' . $this->id . '&amp;folder=' . $folder) . '"' . ' rel="{handler: \'iframe\', size: {x: 800, y: 500}}">';
     $html[] = MText::_('MLIB_FORM_BUTTON_SELECT') . '</a>';
     $html[] = '	</div>';
     $html[] = '</div>';
     $html[] = '<div class="button2-left">';
     $html[] = '	<div class="blank">';
     $html[] = '		<a title="' . MText::_('MLIB_FORM_BUTTON_CLEAR') . '"' . ' href="#" onclick="';
     $html[] = 'jInsertFieldValue(\'\', \'' . $this->id . '\');';
     $html[] = 'return false;';
     $html[] = '">';
     $html[] = MText::_('MLIB_FORM_BUTTON_CLEAR') . '</a>';
     $html[] = '	</div>';
     $html[] = '</div>';
     // The Preview.
     $preview = (string) $this->element['preview'];
     $showPreview = true;
     $showAsTooltip = false;
     switch ($preview) {
         case 'false':
         case 'none':
             $showPreview = false;
             break;
         case 'true':
         case 'show':
             break;
         case 'tooltip':
         default:
             $showAsTooltip = true;
             $options = array('onShow' => 'jMediaRefreshPreviewTip');
             MHtml::_('behavior.tooltip', '.hasTipPreview', $options);
             break;
     }
     if ($showPreview) {
         if ($this->value && file_exists(MPATH_ROOT . '/' . $this->value)) {
             $src = MURI::root() . $this->value;
         } else {
             $src = '';
         }
         $attr = array('id' => $this->id . '_preview', 'class' => 'media-preview', 'style' => 'max-width:160px; max-height:100px;');
         $img = MHtml::image($src, MText::_('MLIB_FORM_MEDIA_PREVIEW_ALT'), $attr);
         $previewImg = '<div id="' . $this->id . '_preview_img"' . ($src ? '' : ' style="display:none"') . '>' . $img . '</div>';
         $previewImgEmpty = '<div id="' . $this->id . '_preview_empty"' . ($src ? ' style="display:none"' : '') . '>' . MText::_('MLIB_FORM_MEDIA_PREVIEW_EMPTY') . '</div>';
         $html[] = '<div class="media-preview fltlft">';
         if ($showAsTooltip) {
             $tooltip = $previewImgEmpty . $previewImg;
             $options = array('title' => MText::_('MLIB_FORM_MEDIA_PREVIEW_SELECTED_IMAGE'), 'text' => MText::_('MLIB_FORM_MEDIA_PREVIEW_TIP_TITLE'), 'class' => 'hasTipPreview');
             $html[] = MHtml::tooltip($tooltip, $options);
         } else {
             $html[] = ' ' . $previewImgEmpty;
             $html[] = ' ' . $previewImg;
         }
         $html[] = '</div>';
     }
     return implode("\n", $html);
 }
Ejemplo n.º 13
0
 public static function noframes()
 {
     // Only load once
     if (isset(self::$loaded[__METHOD__])) {
         return;
     }
     // Include MooTools framework
     self::framework();
     // Include jQuery
     MHtml::_('jquery.framework');
     $js = "jQuery(function () {if (top == self) {document.documentElement.style.display = 'block'; }" . " else {top.location = self.location; }});";
     $document = MFactory::getDocument();
     $document->addStyleDeclaration('html { display:none }');
     $document->addScriptDeclaration($js);
     MFactory::getApplication()->setHeader('X-Frames-Options', 'SAMEORIGIN');
     self::$loaded[__METHOD__] = true;
 }
Ejemplo n.º 14
0
 public function __construct()
 {
     $this->document = MFactory::getDocument();
 }
Ejemplo n.º 15
0
 public function display($cachable = false, $urlparams = false)
 {
     $document = MFactory::getDocument();
     $viewType = $document->getType();
     $viewName = MRequest::getCmd('view', $this->default_view);
     $viewLayout = MRequest::getCmd('layout', 'default');
     $view = $this->getView($viewName, $viewType, '', array('base_path' => $this->basePath, 'layout' => $viewLayout));
     // Get/Create the model
     if ($model = $this->getModel($viewName)) {
         // Push the model into the view (as default)
         $view->setModel($model, true);
     }
     $view->document = $document;
     $conf = MFactory::getConfig();
     // Display the view
     if ($cachable && $viewType != 'feed' && $conf->get('caching') >= 1) {
         $option = MRequest::getCmd('option');
         $cache = MFactory::getCache($option, 'view');
         if (is_array($urlparams)) {
             $app = MFactory::getApplication();
             if (!empty($app->registeredurlparams)) {
                 $registeredurlparams = $app->registeredurlparams;
             } else {
                 $registeredurlparams = new stdClass();
             }
             foreach ($urlparams as $key => $value) {
                 // Add your safe url parameters with variable type as value {@see MFilterInput::clean()}.
                 $registeredurlparams->{$key} = $value;
             }
             $app->registeredurlparams = $registeredurlparams;
         }
         $cache->get($view, 'display');
     } else {
         $view->display();
     }
     return $this;
 }
Ejemplo n.º 16
0
 public function get($callback, $args = array(), $id = false, $wrkarounds = false, $woptions = array())
 {
     if (is_array($callback)) {
         // We have a standard php callback array -- do nothing
     } elseif (strstr($callback, '::')) {
         list($class, $method) = explode('::', $callback);
         $callback = array(trim($class), trim($method));
     } elseif (strstr($callback, '->')) {
         list($object_123456789, $method) = explode('->', $callback);
         global ${$object_123456789};
         $callback = array(${$object_123456789}, $method);
     } else {
         // We have just a standard function -- do nothing
     }
     if (!$id) {
         $id = $this->_makeId($callback, $args);
     }
     $data = false;
     $data = $this->cache->get($id);
     $locktest = new stdClass();
     $locktest->locked = null;
     $locktest->locklooped = null;
     if ($data === false) {
         $locktest = $this->cache->lock($id);
         if ($locktest->locked == true && $locktest->locklooped == true) {
             $data = $this->cache->get($id);
         }
     }
     $coptions = array();
     if ($data !== false) {
         $cached = unserialize(trim($data));
         $coptions['mergehead'] = isset($woptions['mergehead']) ? $woptions['mergehead'] : 0;
         $output = $wrkarounds == false ? $cached['output'] : MCache::getWorkarounds($cached['output'], $coptions);
         $result = $cached['result'];
         if ($locktest->locked == true) {
             $this->cache->unlock($id);
         }
     } else {
         if (!is_array($args)) {
             $Args = !empty($args) ? array(&$args) : array();
         } else {
             $Args =& $args;
         }
         if ($locktest->locked == false) {
             $locktest = $this->cache->lock($id);
         }
         if (isset($woptions['modulemode'])) {
             $document = MFactory::getDocument();
             $coptions['modulemode'] = $woptions['modulemode'];
             $coptions['headerbefore'] = $document->getHeadData();
         } else {
             $coptions['modulemode'] = 0;
         }
         ob_start();
         ob_implicit_flush(false);
         $result = call_user_func_array($callback, $Args);
         $output = ob_get_contents();
         ob_end_clean();
         $cached = array();
         $coptions['nopathway'] = isset($woptions['nopathway']) ? $woptions['nopathway'] : 1;
         $coptions['nohead'] = isset($woptions['nohead']) ? $woptions['nohead'] : 1;
         $coptions['nomodules'] = isset($woptions['nomodules']) ? $woptions['nomodules'] : 1;
         $cached['output'] = $wrkarounds == false ? $output : MCache::setWorkarounds($output, $coptions);
         $cached['result'] = $result;
         $this->cache->store(serialize($cached), $id);
         if ($locktest->locked == true) {
             $this->cache->unlock($id);
         }
     }
     echo $output;
     return $result;
 }
Ejemplo n.º 17
0
 protected function getInput()
 {
     MHtml::_('behavior.tooltip');
     // Initialise some field attributes.
     $section = $this->element['section'] ? (string) $this->element['section'] : '';
     $component = $this->element['component'] ? (string) $this->element['component'] : '';
     $assetField = $this->element['asset_field'] ? (string) $this->element['asset_field'] : 'asset_id';
     // Get the actions for the asset.
     $actions = MAccess::getActions($component, $section);
     // Iterate over the children and add to the actions.
     foreach ($this->element->children() as $el) {
         if ($el->getName() == 'action') {
             $actions[] = (object) array('name' => (string) $el['name'], 'title' => (string) $el['title'], 'description' => (string) $el['description']);
         }
     }
     // Get the explicit rules for this asset.
     if ($section == 'component') {
         // Need to find the asset id by the name of the component.
         $db = MFactory::getDbo();
         $query = $db->getQuery(true);
         $query->select($db->quoteName('id'));
         $query->from($db->quoteName('#__assets'));
         $query->where($db->quoteName('name') . ' = ' . $db->quote($component));
         $db->setQuery($query);
         $assetId = (int) $db->loadResult();
         if ($error = $db->getErrorMsg()) {
             MError::raiseNotice(500, $error);
         }
     } else {
         // Find the asset id of the content.
         // Note that for global configuration, com_config injects asset_id = 1 into the form.
         $assetId = $this->form->getValue($assetField);
     }
     // Use the compact form for the content rules (deprecated).
     //if (!empty($component) && $section != 'component') {
     //	return MHtml::_('rules.assetFormWidget', $actions, $assetId, $assetId ? null : $component, $this->name, $this->id);
     //}
     // Full width format.
     // Get the rules for just this asset (non-recursive).
     $assetRules = MAccess::getAssetRules($assetId);
     // Get the available user groups.
     $groups = $this->getUserGroups();
     // Build the form control.
     $curLevel = 0;
     // Prepare output
     $html = array();
     $html[] = '<div id="permissions-sliders" class="pane-sliders">';
     $html[] = '<p class="rule-desc">' . MText::_('MLIB_RULES_SETTINGS_DESC') . '</p>';
     $html[] = '<ul id="rules">';
     // Start a row for each user group.
     foreach ($groups as $group) {
         $difLevel = $group->level - $curLevel;
         if ($difLevel > 0) {
             $html[] = '<li><ul>';
         } elseif ($difLevel < 0) {
             $html[] = str_repeat('</ul></li>', -$difLevel);
         }
         $html[] = '<li>';
         $html[] = '<div class="panel">';
         $html[] = '<h3 class="pane-toggler title"><a href="javascript:void(0);"><span>';
         $html[] = str_repeat('<span class="level">|&ndash;</span> ', $curLevel = $group->level) . $group->text;
         $html[] = '</span></a></h3>';
         $html[] = '<div class="pane-slider content pane-hide">';
         $html[] = '<div class="mypanel">';
         $html[] = '<table class="group-rules">';
         $html[] = '<thead>';
         $html[] = '<tr>';
         $html[] = '<th class="actions" id="actions-th' . $group->value . '">';
         $html[] = '<span class="acl-action">' . MText::_('MLIB_RULES_ACTION') . '</span>';
         $html[] = '</th>';
         $html[] = '<th class="settings" id="settings-th' . $group->value . '">';
         $html[] = '<span class="acl-action">' . MText::_('MLIB_RULES_SELECT_SETTING') . '</span>';
         $html[] = '</th>';
         // The calculated setting is not shown for the root group of global configuration.
         $canCalculateSettings = $group->parent_id || !empty($component);
         if ($canCalculateSettings) {
             $html[] = '<th id="aclactionth' . $group->value . '">';
             $html[] = '<span class="acl-action">' . MText::_('MLIB_RULES_CALCULATED_SETTING') . '</span>';
             $html[] = '</th>';
         }
         $html[] = '</tr>';
         $html[] = '</thead>';
         $html[] = '<tbody>';
         foreach ($actions as $action) {
             $html[] = '<tr>';
             $html[] = '<td headers="actions-th' . $group->value . '">';
             $html[] = '<label class="hasTip" for="' . $this->id . '_' . $action->name . '_' . $group->value . '" title="' . htmlspecialchars(MText::_($action->title) . '::' . MText::_($action->description), ENT_COMPAT, 'UTF-8') . '">';
             $html[] = MText::_($action->title);
             $html[] = '</label>';
             $html[] = '</td>';
             $html[] = '<td headers="settings-th' . $group->value . '">';
             $html[] = '<select name="' . $this->name . '[' . $action->name . '][' . $group->value . ']" id="' . $this->id . '_' . $action->name . '_' . $group->value . '" title="' . MText::sprintf('MLIB_RULES_SELECT_ALLOW_DENY_GROUP', MText::_($action->title), trim($group->text)) . '">';
             $inheritedRule = MAccess::checkGroup($group->value, $action->name, $assetId);
             // Get the actual setting for the action for this group.
             $assetRule = $assetRules->allow($action->name, $group->value);
             // Build the dropdowns for the permissions sliders
             // The parent group has "Not Set", all children can rightly "Inherit" from that.
             $html[] = '<option value=""' . ($assetRule === null ? ' selected="selected"' : '') . '>' . MText::_(empty($group->parent_id) && empty($component) ? 'MLIB_RULES_NOT_SET' : 'MLIB_RULES_INHERITED') . '</option>';
             $html[] = '<option value="1"' . ($assetRule === true ? ' selected="selected"' : '') . '>' . MText::_('MLIB_RULES_ALLOWED') . '</option>';
             $html[] = '<option value="0"' . ($assetRule === false ? ' selected="selected"' : '') . '>' . MText::_('MLIB_RULES_DENIED') . '</option>';
             $html[] = '</select>&#160; ';
             // If this asset's rule is allowed, but the inherited rule is deny, we have a conflict.
             if ($assetRule === true && $inheritedRule === false) {
                 $html[] = MText::_('MLIB_RULES_CONFLICT');
             }
             $html[] = '</td>';
             // Build the Calculated Settings column.
             // The inherited settings column is not displayed for the root group in global configuration.
             if ($canCalculateSettings) {
                 $html[] = '<td headers="aclactionth' . $group->value . '">';
                 // This is where we show the current effective settings considering currrent group, path and cascade.
                 // Check whether this is a component or global. Change the text slightly.
                 if (MAccess::checkGroup($group->value, 'core.admin', $assetId) !== true) {
                     if ($inheritedRule === null) {
                         $html[] = '<span class="icon-16-unset">' . MText::_('MLIB_RULES_NOT_ALLOWED') . '</span>';
                     } elseif ($inheritedRule === true) {
                         $html[] = '<span class="icon-16-allowed">' . MText::_('MLIB_RULES_ALLOWED') . '</span>';
                     } elseif ($inheritedRule === false) {
                         if ($assetRule === false) {
                             $html[] = '<span class="icon-16-denied">' . MText::_('MLIB_RULES_NOT_ALLOWED') . '</span>';
                         } else {
                             $html[] = '<span class="icon-16-denied"><span class="icon-16-locked">' . MText::_('MLIB_RULES_NOT_ALLOWED_LOCKED') . '</span></span>';
                         }
                     }
                 } elseif (!empty($component)) {
                     $html[] = '<span class="icon-16-allowed"><span class="icon-16-locked">' . MText::_('MLIB_RULES_ALLOWED_ADMIN') . '</span></span>';
                 } else {
                     // Special handling for  groups that have global admin because they can't  be denied.
                     // The admin rights can be changed.
                     if ($action->name === 'core.admin') {
                         $html[] = '<span class="icon-16-allowed">' . MText::_('MLIB_RULES_ALLOWED') . '</span>';
                     } elseif ($inheritedRule === false) {
                         // Other actions cannot be changed.
                         $html[] = '<span class="icon-16-denied"><span class="icon-16-locked">' . MText::_('MLIB_RULES_NOT_ALLOWED_ADMIN_CONFLICT') . '</span></span>';
                     } else {
                         $html[] = '<span class="icon-16-allowed"><span class="icon-16-locked">' . MText::_('MLIB_RULES_ALLOWED_ADMIN') . '</span></span>';
                     }
                 }
                 $html[] = '</td>';
             }
             $html[] = '</tr>';
         }
         $html[] = '</tbody>';
         $html[] = '</table></div>';
         $html[] = '</div></div>';
         $html[] = '</li>';
     }
     $html[] = str_repeat('</ul></li>', $curLevel);
     $html[] = '</ul><div class="rule-notes">';
     if ($section == 'component' || $section == null) {
         $html[] = MText::_('MLIB_RULES_SETTING_NOTES');
     } else {
         $html[] = MText::_('MLIB_RULES_SETTING_NOTES_ITEM');
     }
     $html[] = '</div></div>';
     $js = "jQuery(document).ready(function () { new Fx.Accordion(\$\$('div#permissions-sliders.pane-sliders .panel h3.pane-toggler')," . "\$\$('div#permissions-sliders.pane-sliders .panel div.pane-slider'), {onActive: function(toggler, i) {toggler.addClass('pane-toggler-down');" . "toggler.removeClass('pane-toggler');i.addClass('pane-down');i.removeClass('pane-hide');Cookie.write('jpanesliders_permissions-sliders" . $component . "',\$\$('div#permissions-sliders.pane-sliders .panel h3').indexOf(toggler));}," . "onBackground: function(toggler, i) {toggler.addClass('pane-toggler');toggler.removeClass('pane-toggler-down');i.addClass('pane-hide');" . "i.removeClass('pane-down');}, duration: 300, display: " . MRequest::getInt('jpanesliders_permissions-sliders' . $component, 0, 'cookie') . ", show: " . MRequest::getInt('jpanesliders_permissions-sliders' . $component, 0, 'cookie') . ", alwaysHide:true, opacity: false}); });";
     MFactory::getDocument()->addScriptDeclaration($js);
     return implode("\n", $html);
 }
Ejemplo n.º 18
0
function modChrome_outline($module, &$params, &$attribs)
{
    static $css = false;
    if (!$css) {
        $css = true;
        mimport('framework.environment.browser');
        $doc = MFactory::getDocument();
        $browser = MBrowser::getInstance();
        $doc->addStyleDeclaration(".mod-preview-info { padding: 2px 4px 2px 4px; border: 1px solid black; position: absolute; background-color: white; color: red;}");
        $doc->addStyleDeclaration(".mod-preview-wrapper { background-color:#eee; border: 1px dotted black; color:#700;}");
        if ($browser->getBrowser() == 'msie') {
            if ($browser->getMajor() <= 7) {
                $doc->addStyleDeclaration(".mod-preview-info {filter: alpha(opacity=80);}");
                $doc->addStyleDeclaration(".mod-preview-wrapper {filter: alpha(opacity=50);}");
            } else {
                $doc->addStyleDeclaration(".mod-preview-info {-ms-filter: alpha(opacity=80);}");
                $doc->addStyleDeclaration(".mod-preview-wrapper {-ms-filter: alpha(opacity=50);}");
            }
        } else {
            $doc->addStyleDeclaration(".mod-preview-info {opacity: 0.8;}");
            $doc->addStyleDeclaration(".mod-preview-wrapper {opacity: 0.5;}");
        }
    }
    ?>
	<div class="mod-preview">
		<div class="mod-preview-info"><?php 
    echo $module->position . "[" . $module->style . "]";
    ?>
</div>
		<div class="mod-preview-wrapper">
			<?php 
    echo $module->content;
    ?>
		</div>
	</div>
	<?php 
}
Ejemplo n.º 19
0
 public static function calendar($value, $name, $id, $format = 'Y-m-d', $attribs = null)
 {
     static $done;
     if ($done === null) {
         $done = array();
     }
     $readonly = isset($attribs['readonly']) && $attribs['readonly'] == 'readonly';
     $disabled = isset($attribs['disabled']) && $attribs['disabled'] == 'disabled';
     if (is_array($attribs)) {
         $attribs = MArrayHelper::toString($attribs);
     }
     if (!$readonly && !$disabled) {
         // Load the calendar behavior
         self::_('behavior.calendar');
         self::_('behavior.tooltip');
         // Only display the triggers once for each control.
         if (!in_array($id, $done)) {
             $document = MFactory::getDocument();
             $document->addScriptDeclaration('jQuery(document).ready(function () {
                         Calendar.setup({
                             // Id of the input field
                             inputField: "' . $id . '",
                             // Format of the input field
                             ifFormat: "' . $format . '",
                             // Trigger for the calendar (button ID)
                             button: "' . $id . '_img",
                             // Alignment (defaults to "Bl")
                             align: "Tl",
                             singleClick: true,
                             firstDay: ' . MFactory::getLanguage()->getFirstDay() . '
                         });
                     });');
             $done[] = $id;
         }
         return '<input type="text" title="' . (0 !== (int) $value ? self::_('date', $value, null, null) : '') . '" name="' . $name . '" id="' . $id . '" value="' . htmlspecialchars($value, ENT_COMPAT, 'UTF-8') . '" ' . $attribs . ' />' . self::_('image', 'system/calendar.png', MText::_('MLIB_HTML_CALENDAR'), array('class' => 'calendar', 'id' => $id . '_img'), true);
     } else {
         return '<input type="text" title="' . (0 !== (int) $value ? self::_('date', $value, null, null) : '') . '" value="' . (0 !== (int) $value ? self::_('date', $value, 'Y-m-d H:i:s', null) : '') . '" ' . $attribs . ' /><input type="hidden" name="' . $name . '" id="' . $id . '" value="' . htmlspecialchars($value, ENT_COMPAT, 'UTF-8') . '" />';
     }
 }