示例#1
0
	public static function _(){
		$isSaved = MRequest::getCookie("profilesissaved",0, MREQUEST_INT);
		
		if($isSaved){
			MRequest::setCookie("profilesissaved", 0);
			$css = _FM_IS_DEMO ? "rejectedAdvice" : "savedAdvice";
			$text = _FM_IS_DEMO ? "notfordemo" : "datasaved";
			echo '
				<div id="mSavedAdvice" class="'.$css.'"><div>'.MText::_($text).'</div></div>
				<script type="text/javascript">
					dojo.addOnLoad(function(){
							var node = dojo.byId("mSavedAdvice");
							dojo.style(node,{opacity: 0});
							_fx.fadeOpacity(node,300,0,1,function(){
								setTimeout(function(){
									var node = dojo.byId("mSavedAdvice");
									dojo.style(node,{opacity: 1});
									_fx.fadeOpacity(node,400,1,0,function(){
										 _removeNode(dojo.byId("mSavedAdvice"));
									});
								},2000);
							});
					});
				</script>
			';
		}
		
		
	}
示例#2
0
 public static function getInstance($handler = null, $options = array())
 {
     static $now = null;
     MCacheStorage::addIncludePath(MPATH_WP_CNT . '/miwi/framework/cache/storage');
     if (!isset($handler)) {
         $conf = MFactory::getConfig();
         $handler = $conf->get('cache_handler');
         if (empty($handler)) {
             return MError::raiseWarning(500, MText::_('MLIB_CACHE_ERROR_CACHE_HANDLER_NOT_SET'));
         }
     }
     if (is_null($now)) {
         $now = time();
     }
     $options['now'] = $now;
     $handler = strtolower(preg_replace('/[^A-Z0-9_\\.-]/i', '', $handler));
     $class = 'MCacheStorage' . ucfirst($handler);
     if (!class_exists($class)) {
         mimport('joomla.filesystem.path');
         if ($path = MPath::find(MCacheStorage::addIncludePath(), strtolower($handler) . '.php')) {
             include_once $path;
         } else {
             return MError::raiseWarning(500, MText::sprintf('MLIB_CACHE_ERROR_CACHE_STORAGE_LOAD', $handler));
         }
     }
     return new $class($options);
 }
示例#3
0
 protected function getOptions()
 {
     // Initialise variables
     $folder = $this->element['folder'];
     if (!empty($folder)) {
         // Get list of plugins
         $db = MFactory::getDbo();
         $query = $db->getQuery(true);
         $query->select('element AS value, name AS text');
         $query->from('#__extensions');
         $query->where('folder = ' . $db->q($folder));
         $query->where('enabled = 1');
         $query->order('ordering, name');
         $db->setQuery($query);
         $options = $db->loadObjectList();
         $lang = MFactory::getLanguage();
         foreach ($options as $i => $item) {
             $source = MPATH_PLUGINS . '/' . $folder . '/' . $item->value;
             $extension = 'plg_' . $folder . '_' . $item->value;
             $lang->load($extension . '.sys', MPATH_ADMINISTRATOR, null, false, false) || $lang->load($extension . '.sys', $source, null, false, false) || $lang->load($extension . '.sys', MPATH_ADMINISTRATOR, $lang->getDefault(), false, false) || $lang->load($extension . '.sys', $source, $lang->getDefault(), false, false);
             $options[$i]->text = MText::_($item->text);
         }
         if ($db->getErrorMsg()) {
             MError::raiseWarning(500, MText::_('MFRAMEWORK_FORM_FIELDS_PLUGINS_ERROR_FOLDER_EMPTY'));
             return '';
         }
     } else {
         MError::raiseWarning(500, MText::_('MFRAMEWORK_FORM_FIELDS_PLUGINS_ERROR_FOLDER_EMPTY'));
     }
     // Merge any additional options in the XML definition.
     $options = array_merge(parent::getOptions(), $options);
     return $options;
 }
示例#4
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);
 }
示例#5
0
 protected function getInput()
 {
     // Initialize variables.
     $html = array();
     // Initialize some field attributes.
     $class = $this->element['class'] ? ' class="checkboxes ' . (string) $this->element['class'] . '"' : ' class="checkboxes"';
     // Start the checkbox field output.
     $html[] = '<fieldset id="' . $this->id . '"' . $class . '>';
     // Get the field options.
     $options = $this->getOptions();
     // Build the checkbox field output.
     $html[] = '<ul>';
     foreach ($options as $i => $option) {
         // Initialize some option attributes.
         $checked = in_array((string) $option->value, (array) $this->value) ? ' checked="checked"' : '';
         $class = !empty($option->class) ? ' class="' . $option->class . '"' : '';
         $disabled = !empty($option->disable) ? ' disabled="disabled"' : '';
         // Initialize some JavaScript option attributes.
         $onclick = !empty($option->onclick) ? ' onclick="' . $option->onclick . '"' : '';
         $html[] = '<li>';
         $html[] = '<input type="checkbox" id="' . $this->id . $i . '" name="' . $this->name . '"' . ' value="' . htmlspecialchars($option->value, ENT_COMPAT, 'UTF-8') . '"' . $checked . $class . $onclick . $disabled . '/>';
         $html[] = '<label for="' . $this->id . $i . '"' . $class . '>' . MText::_($option->text) . '</label>';
         $html[] = '</li>';
     }
     $html[] = '</ul>';
     // End the checkbox field output.
     $html[] = '</fieldset>';
     return implode($html);
 }
示例#6
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);
 }
示例#7
0
 public function __construct()
 {
     $isLoaded = MPluginHelper::importPlugin('authentication');
     if (!$isLoaded) {
         MError::raiseWarning('SOME_ERROR_CODE', MText::_('MLIB_USER_ERROR_AUTHENTICATION_LIBRARIES'));
     }
 }
示例#8
0
 protected function getOptions()
 {
     MLog::add('MFormFieldEditors is deprecated. Use MFormFieldPlugins instead (with folder="editors").', MLog::WARNING, 'deprecated');
     // Get the database object and a new query object.
     $db = MFactory::getDBO();
     $query = $db->getQuery(true);
     // Build the query.
     $query->select('element AS value, name AS text');
     $query->from('#__extensions');
     $query->where('folder = ' . $db->quote('editors'));
     $query->where('enabled = 1');
     $query->order('ordering, name');
     // Set the query and load the options.
     $db->setQuery($query);
     $options = $db->loadObjectList();
     $lang = MFactory::getLanguage();
     foreach ($options as $i => $option) {
         $lang->load('plg_editors_' . $option->value, MPATH_ADMINISTRATOR, null, false, false) || $lang->load('plg_editors_' . $option->value, MPATH_PLUGINS . '/editors/' . $option->value, null, false, false) || $lang->load('plg_editors_' . $option->value, MPATH_ADMINISTRATOR, $lang->getDefault(), false, false) || $lang->load('plg_editors_' . $option->value, MPATH_PLUGINS . '/editors/' . $option->value, $lang->getDefault(), false, false);
         $options[$i]->text = MText::_($option->text);
     }
     // Check for a database error.
     if ($db->getErrorNum()) {
         MError::raiseWarning(500, $db->getErrorMsg());
     }
     // Merge any additional options in the XML definition.
     $options = array_merge(parent::getOptions(), $options);
     return $options;
 }
示例#9
0
 public static function runSqlFile($sql_file)
 {
     $db = MFactory::getDbo();
     if (!file_exists($sql_file)) {
         return;
     }
     $buffer = file_get_contents($sql_file);
     if ($buffer === false) {
         return;
     }
     $queries = $db->splitSql($buffer);
     if (count($queries) == 0) {
         return;
     }
     foreach ($queries as $query) {
         $query = trim($query);
         if ($query != '' && $query[0] != '#') {
             $db->setQuery($query);
             if (!$db->query()) {
                 MError::raiseWarning(1, 'MInstaller::install: ' . MText::_('SQL Error') . " " . $db->stderr(true));
                 return;
             }
         }
     }
 }
示例#10
0
 public function loadButtonType($type, $new = false)
 {
     $signature = md5($type);
     if (isset($this->_buttons[$signature]) && $new === false) {
         return $this->_buttons[$signature];
     }
     if (!class_exists('MButton')) {
         MError::raiseWarning('SOME_ERROR_CODE', MText::_('MLIB_HTML_BUTTON_BASE_CLASS'));
         return false;
     }
     $buttonClass = 'MButton' . $type;
     if (!class_exists($buttonClass)) {
         if (isset($this->_buttonPath)) {
             $dirs = $this->_buttonPath;
         } else {
             $dirs = array();
         }
         $file = MFilterInput::getInstance()->clean(str_replace('_', DIRECTORY_SEPARATOR, strtolower($type)) . '.php', 'path');
         mimport('framework.filesystem.path');
         if ($buttonFile = MPath::find($dirs, $file)) {
             include_once $buttonFile;
         } else {
             MError::raiseWarning('SOME_ERROR_CODE', MText::sprintf('MLIB_HTML_BUTTON_NO_LOAD', $buttonClass, $buttonFile));
             return false;
         }
     }
     if (!class_exists($buttonClass)) {
         //return	MError::raiseError('SOME_ERROR_CODE', "Module file $buttonFile does not contain class $buttonClass.");
         return false;
     }
     $this->_buttons[$signature] = new $buttonClass($this);
     return $this->_buttons[$signature];
 }
示例#11
0
文件: gzip.php 项目: vanie3/appland
 public function _getFilePosition()
 {
     // gzipped file... unpack it first
     $position = 0;
     $info = @unpack('CCM/CFLG/VTime/CXFL/COS', substr($this->_data, $position + 2));
     if (!$info) {
         $this->set('error.message', MText::_('MLIB_FILESYSTEM_GZIP_UNABLE_TO_DECOMPRESS'));
         return false;
     }
     $position += 10;
     if ($info['FLG'] & $this->_flags['FEXTRA']) {
         $XLEN = unpack('vLength', substr($this->_data, $position + 0, 2));
         $XLEN = $XLEN['Length'];
         $position += $XLEN + 2;
     }
     if ($info['FLG'] & $this->_flags['FNAME']) {
         $filenamePos = strpos($this->_data, "", $position);
         $position = $filenamePos + 1;
     }
     if ($info['FLG'] & $this->_flags['FCOMMENT']) {
         $commentPos = strpos($this->_data, "", $position);
         $position = $commentPos + 1;
     }
     if ($info['FLG'] & $this->_flags['FHCRC']) {
         $hcrc = unpack('vCRC', substr($this->_data, $position + 0, 2));
         $hcrc = $hcrc['CRC'];
         $position += 2;
     }
     return $position;
 }
示例#12
0
 protected function getOptions()
 {
     // Initialize variables.
     // This gets the connectors available in the platform and supported by the server.
     $available = MDatabase::getConnectors();
     $supported = $this->element['supported'];
     if (!empty($supported)) {
         $supported = explode(',', $supported);
         foreach ($supported as $support) {
             if (in_array($support, $available)) {
                 $options[$support] = ucfirst($support);
             }
         }
     } else {
         foreach ($available as $support) {
             $options[$support] = ucfirst($support);
         }
     }
     // This will come into play if an application is installed that requires
     // a database that is not available on the server.
     if (empty($options)) {
         $options[''] = MText::_('MNONE');
     }
     return $options;
 }
示例#13
0
文件: spacer.php 项目: vanie3/appland
 protected function getLabel()
 {
     $html = array();
     $class = $this->element['class'] ? (string) $this->element['class'] : '';
     $html[] = '<span class="spacer">';
     $html[] = '<span class="before"></span>';
     $html[] = '<span class="' . $class . '">';
     if ((string) $this->element['hr'] == 'true') {
         $html[] = '<hr class="' . $class . '" />';
     } else {
         $label = '';
         // Get the label text from the XML element, defaulting to the element name.
         $text = $this->element['label'] ? (string) $this->element['label'] : (string) $this->element['name'];
         $text = $this->translateLabel ? MText::_($text) : $text;
         // Build the class for the label.
         $class = !empty($this->description) ? 'hasTip' : '';
         $class = $this->required == true ? $class . ' required' : $class;
         // Add the opening label tag and main attributes attributes.
         $label .= '<label id="' . $this->id . '-lbl" class="' . $class . '"';
         // If a description is specified, use it to build a tooltip.
         if (!empty($this->description)) {
             $label .= ' title="' . htmlspecialchars(trim($text, ':') . '::' . ($this->translateDescription ? MText::_($this->description) : $this->description), ENT_COMPAT, 'UTF-8') . '"';
         }
         // Add the label text and closing tag.
         $label .= '>' . $text . '</label>';
         $html[] = $label;
     }
     $html[] = '</span>';
     $html[] = '<span class="after"></span>';
     $html[] = '</span>';
     return implode('', $html);
 }
示例#14
0
文件: sql.php 项目: vanie3/appland
 protected function getOptions()
 {
     // Initialize variables.
     $options = array();
     // Initialize some field attributes.
     $key = $this->element['key_field'] ? (string) $this->element['key_field'] : 'value';
     $value = $this->element['value_field'] ? (string) $this->element['value_field'] : (string) $this->element['name'];
     $translate = $this->element['translate'] ? (string) $this->element['translate'] : false;
     $query = (string) $this->element['query'];
     // Get the database object.
     $db = MFactory::getDBO();
     // Set the query and get the result list.
     $db->setQuery($query);
     $items = $db->loadObjectlist();
     // Check for an error.
     if ($db->getErrorNum()) {
         MError::raiseWarning(500, $db->getErrorMsg());
         return $options;
     }
     // Build the field options.
     if (!empty($items)) {
         foreach ($items as $item) {
             if ($translate == true) {
                 $options[] = MHtml::_('select.option', $item->{$key}, MText::_($item->{$value}));
             } else {
                 $options[] = MHtml::_('select.option', $item->{$key}, $item->{$value});
             }
         }
     }
     // Merge any additional options in the XML definition.
     $options = array_merge(parent::getOptions(), $options);
     return $options;
 }
示例#15
0
文件: help.php 项目: vanie3/appland
 protected function _getCommand($ref, $com, $override, $component)
 {
     // Get Help URL
     mimport('framework.language.help');
     $url = MHelp::createURL($ref, $com, $override, $component);
     $url = htmlspecialchars($url, ENT_QUOTES);
     $cmd = "Miwi.popupWindow('{$url}', '" . MText::_('MHELP', true) . "', 700, 500, 1)";
     return $cmd;
 }
示例#16
0
文件: email.php 项目: vanie3/appland
 public static function cloak($mail, $mailto = true, $text = '', $email = true)
 {
     // Convert text
     $mail = self::_convertEncoding($mail);
     // Split email by @ symbol
     $mail = explode('@', $mail);
     $mail_parts = explode('.', $mail[1]);
     // Random number
     $rand = rand(1, 100000);
     $replacement = "<script type='text/javascript'>";
     $replacement .= "\n <!--";
     $replacement .= "\n var prefix = '&#109;a' + 'i&#108;' + '&#116;o';";
     $replacement .= "\n var path = 'hr' + 'ef' + '=';";
     $replacement .= "\n var addy" . $rand . " = '" . @$mail[0] . "' + '&#64;';";
     $replacement .= "\n addy" . $rand . " = addy" . $rand . " + '" . implode("' + '&#46;' + '", $mail_parts) . "';";
     if ($mailto) {
         // Special handling when mail text is different from mail address
         if ($text) {
             if ($email) {
                 // Convert text
                 $text = self::_convertEncoding($text);
                 // Split email by @ symbol
                 $text = explode('@', $text);
                 $text_parts = explode('.', $text[1]);
                 $replacement .= "\n var addy_text" . $rand . " = '" . @$text[0] . "' + '&#64;' + '" . implode("' + '&#46;' + '", @$text_parts) . "';";
             } else {
                 $replacement .= "\n var addy_text" . $rand . " = '" . $text . "';";
             }
             $replacement .= "\n document.write('<a ' + path + '\\'' + prefix + ':' + addy" . $rand . " + '\\'>');";
             $replacement .= "\n document.write(addy_text" . $rand . ");";
             $replacement .= "\n document.write('<\\/a>');";
         } else {
             $replacement .= "\n document.write('<a ' + path + '\\'' + prefix + ':' + addy" . $rand . " + '\\'>');";
             $replacement .= "\n document.write(addy" . $rand . ");";
             $replacement .= "\n document.write('<\\/a>');";
         }
     } else {
         $replacement .= "\n document.write(addy" . $rand . ");";
     }
     $replacement .= "\n //-->";
     $replacement .= '\\n </script>';
     // XHTML compliance no Javascript text handling
     $replacement .= "<script type='text/javascript'>";
     $replacement .= "\n <!--";
     $replacement .= "\n document.write('<span style=\\'display: none;\\'>');";
     $replacement .= "\n //-->";
     $replacement .= "\n </script>";
     $replacement .= MText::_('MLIB_HTML_CLOAKING');
     $replacement .= "\n <script type='text/javascript'>";
     $replacement .= "\n <!--";
     $replacement .= "\n document.write('</');";
     $replacement .= "\n document.write('span>');";
     $replacement .= "\n //-->";
     $replacement .= "\n </script>";
     return $replacement;
 }
示例#17
0
文件: link.php 项目: vanie3/appland
 public function fetchButton($type = 'Link', $name = 'back', $text = '', $url = null)
 {
     $text = MText::_($text);
     $class = $this->fetchIconClass($name);
     $doTask = $this->_getCommand($url);
     $html = "<a class=\"add-new-h2\" href=\"{$doTask}\">\n";
     $html .= "{$text}\n";
     $html .= "</a>\n";
     return $html;
 }
示例#18
0
文件: batch.php 项目: vanie3/appland
 public static function user($noUser = true)
 {
     $optionNo = '';
     if ($noUser) {
         $optionNo = '<option value="0">' . MText::_('MLIB_HTML_BATCH_USER_NOUSER') . '</option>';
     }
     // Create the batch selector to select a user on a selection list.
     $lines = array('<label id="batch-user-lbl" for="batch-user" class="hasTip"' . ' title="' . MText::_('MLIB_HTML_BATCH_USER_LABEL') . '::' . MText::_('MLIB_HTML_BATCH_USER_LABEL_DESC') . '">', MText::_('MLIB_HTML_BATCH_USER_LABEL'), '</label>', '<select name="batch[user_id]" class="inputbox" id="batch-user-id">', '<option value="">' . MText::_('MLIB_HTML_BATCH_USER_NOCHANGE') . '</option>', $optionNo, MHtml::_('select.options', MHtml::_('user.userlist'), 'value', 'text'), '</select>');
     return implode("\n", $lines);
 }
示例#19
0
 protected function getOptions()
 {
     // Initialize variables.
     $options = array();
     // Convert to name => name array.
     foreach (MCache::getStores() as $store) {
         $options[] = MHtml::_('select.option', $store, MText::_('MLIB_FORM_VALUE_CACHE_' . $store), 'value', 'text');
     }
     $options = array_merge(parent::getOptions(), $options);
     return $options;
 }
示例#20
0
 protected function getOptions()
 {
     // Initialise variables.
     $options = array();
     $extension = $this->element['extension'] ? (string) $this->element['extension'] : (string) $this->element['scope'];
     $published = (string) $this->element['published'];
     $name = (string) $this->element['name'];
     // Load the category options for a given extension.
     if (!empty($extension)) {
         // Filter over published state or not depending upon if it is present.
         if ($published) {
             $options = MHtml::_('category.options', $extension, array('filter.published' => explode(',', $published)));
         } else {
             $options = MHtml::_('category.options', $extension);
         }
         // Verify permissions.  If the action attribute is set, then we scan the options.
         if ((string) $this->element['action']) {
             // Get the current user object.
             $user = MFactory::getUser();
             // For new items we want a list of categories you are allowed to create in.
             if (!$this->form->getValue($name)) {
                 foreach ($options as $i => $option) {
                     // To take save or create in a category you need to have create rights for that category
                     // unless the item is already in that category.
                     // Unset the option if the user isn't authorised for it. In this field assets are always categories.
                     if ($user->authorise('core.create', $extension . '.category.' . $option->value) != true) {
                         unset($options[$i]);
                     }
                 }
             } else {
                 $categoryOld = $this->form->getValue($name);
                 foreach ($options as $i => $option) {
                     // If you are only allowed to edit in this category but not edit.state, you should not get any
                     // option to change the category.
                     if ($user->authorise('core.edit.state', $extension . '.category.' . $categoryOld) != true) {
                         if ($option->value != $categoryOld) {
                             unset($options[$i]);
                         }
                     } elseif ($user->authorise('core.create', $extension . '.category.' . $option->value) != true && $option->value != $categoryOld) {
                         unset($options[$i]);
                     }
                 }
             }
         }
         if (isset($this->element['show_root'])) {
             array_unshift($options, MHtml::_('select.option', '0', MText::_('MGLOBAL_ROOT')));
         }
     } else {
         MError::raiseWarning(500, MText::_('MLIB_FORM_ERROR_FIELDS_CATEGORY_ERROR_EXTENSION_EMPTY'));
     }
     // Merge any additional options in the XML definition.
     $options = array_merge(parent::getOptions(), $options);
     return $options;
 }
示例#21
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);
 }
示例#22
0
文件: bzip2.php 项目: vanie3/appland
 public function extract($archive, $destination, $options = array())
 {
     // Initialise variables.
     $this->_data = null;
     if (!extension_loaded('bz2')) {
         $this->set('error.message', MText::_('MLIB_FILESYSTEM_BZIP_NOT_SUPPORTED'));
         return MError::raiseWarning(100, $this->get('error.message'));
     }
     if (!isset($options['use_streams']) || $options['use_streams'] == false) {
         // Old style: read the whole file and then parse it
         if (!($this->_data = MFile::read($archive))) {
             $this->set('error.message', 'Unable to read archive');
             return MError::raiseWarning(100, $this->get('error.message'));
         }
         $buffer = bzdecompress($this->_data);
         unset($this->_data);
         if (empty($buffer)) {
             $this->set('error.message', 'Unable to decompress data');
             return MError::raiseWarning(100, $this->get('error.message'));
         }
         if (MFile::write($destination, $buffer) === false) {
             $this->set('error.message', 'Unable to write archive');
             return MError::raiseWarning(100, $this->get('error.message'));
         }
     } else {
         // New style! streams!
         $input = MFactory::getStream();
         $input->set('processingmethod', 'bz');
         // use bzip
         if (!$input->open($archive)) {
             $this->set('error.message', MText::_('MLIB_FILESYSTEM_BZIP_UNABLE_TO_READ'));
             return MError::raiseWarning(100, $this->get('error.message'));
         }
         $output = MFactory::getStream();
         if (!$output->open($destination, 'w')) {
             $this->set('error.message', MText::_('MLIB_FILESYSTEM_BZIP_UNABLE_TO_WRITE'));
             $input->close();
             // close the previous file
             return MError::raiseWarning(100, $this->get('error.message'));
         }
         do {
             $this->_data = $input->read($input->get('chunksize', 8196));
             if ($this->_data) {
                 if (!$output->write($this->_data)) {
                     $this->set('error.message', MText::_('MLIB_FILESYSTEM_BZIP_UNABLE_TO_WRITE_FILE'));
                     return MError::raiseWarning(100, $this->get('error.message'));
                 }
             }
         } while ($this->_data);
         $output->close();
         $input->close();
     }
     return true;
 }
示例#23
0
 public function delete()
 {
     // Check for request forgeries
     //MRequest::checkToken() or mexit('Invalid Token');
     if ($this->_model->delete($this->_table)) {
         $msg = MText::_('COM_MIWOSQL_DELETE_TRUE');
     } else {
         $msg = MText::_('COM_MIWOSQL_DELETE_FALSE');
     }
     $vars = 'ja_tbl_g=' . base64_encode($this->_table) . '&ja_qry_g=' . base64_encode($this->_query);
     $this->setRedirect('index.php?option=com_miwosql&' . $vars, $msg);
 }
示例#24
0
 public function _default()
 {
     if (_FM_IS_DEMO) {
         return $this->view->add2Content('<div style="display:block; padding: 10px; font-size: 16px; font-weight: bold;">' . MText::_("notfordemo") . '</div>');
     }
     $this->includeLanguage();
     MDiagHelper::start();
     $this->view->add2Menu("");
     $this->view->add2Content(MDiagHelper::generate());
     MDiagHelper::save();
     // 		$this->view->addPreToContent(MDiagHelper::getTests());
 }
示例#25
0
 protected function _getCommand($msg, $name, $task, $list)
 {
     MHtml::_('behavior.framework');
     $message = MText::_('MLIB_HTML_PLEASE_MAKE_A_SELECTION_FROM_THE_LIST');
     $message = addslashes($message);
     if ($list) {
         $cmd = "if (document.adminForm.boxchecked.value==0){alert('{$message}');}else{if (confirm('{$msg}')){Miwi.submitbutton('{$task}');}}";
     } else {
         $cmd = "if (confirm('{$msg}')){Miwi.submitbutton('{$task}');}";
     }
     return $cmd;
 }
示例#26
0
 protected function getOptions()
 {
     // Initialize variables.
     $options = array();
     // Get the options from MSession.
     foreach (MSession::getStores() as $store) {
         $options[] = MHtml::_('select.option', $store, MText::_('MLIB_FORM_VALUE_SESSION_' . $store), 'value', 'text');
     }
     // Merge any additional options in the XML definition.
     $options = array_merge(parent::getOptions(), $options);
     return $options;
 }
示例#27
0
文件: task.php 项目: utopszkij/lmp
 protected function authAndDie($rule = null)
 {
     $rule = trim($rule);
     if (!$rule || !MRights::can($rule)) {
         $errorText = $rule !== null ? MText::_("rights_noauth_" . $rule) : MText::_("noauth");
         $goBackUrl = MURL::_();
         ob_start();
         include _FM_HOME_FOLDER . DS . "templates" . DS . "noaccess.php";
         $dieOut = ob_get_clean();
         ob_get_clean();
         die($dieOut);
     }
 }
示例#28
0
 public function save()
 {
     // Check for request forgeries
     MRequest::checkToken() or jexit('Invalid Token');
     $post = MRequest::get('post');
     $post['query'] = base64_encode(MRequest::getVar('ja_query', '', 'post', 'string', MREQUEST_ALLOWRAW));
     unset($post['ja_query']);
     if ($this->_model->saveQuery($post)) {
         $msg = MText::_('COM_MIWOSQL_SAVE_TRUE');
     } else {
         $msg = MText::_('COM_MIWOSQL_SAVE_FALSE');
     }
     $this->setRedirect('index.php?option=com_miwosql&controller=queries', $msg);
 }
示例#29
0
文件: format.php 项目: vanie3/appland
 public static function getInstance($type)
 {
     // Sanitize format type.
     $type = strtolower(preg_replace('/[^A-Z0-9_]/i', '', $type));
     // Only instantiate the object if it doesn't already exist.
     if (!isset(self::$instances[$type])) {
         // Only load the file the class does not exist.
         $class = 'MRegistryFormat' . $type;
         if (!class_exists($class)) {
             $path = dirname(__FILE__) . '/format/' . $type . '.php';
             if (is_file($path)) {
                 include_once $path;
             } else {
                 throw new MException(MText::_('MLIB_REGISTRY_EXCEPTION_LOAD_FORMAT_CLASS'), 500, E_ERROR);
             }
         }
         self::$instances[$type] = new $class();
     }
     return self::$instances[$type];
 }
示例#30
0
文件: date.php 项目: vanie3/appland
 public static function relative($date, $unit = null, $time = null)
 {
     if (is_null($time)) {
         // Get now
         $time = MFactory::getDate('now');
     }
     // Get the difference in seconds between now and the time
     $diff = strtotime($time) - strtotime($date);
     // Less than a minute
     if ($diff < 60) {
         return MText::_('MLIB_HTML_DATE_RELATIVE_LESSTHANAMINUTE');
     }
     // Round to minutes
     $diff = round($diff / 60);
     // 1 to 59 minutes
     if ($diff < 60 || $unit == 'minute') {
         return MText::plural('MLIB_HTML_DATE_RELATIVE_MINUTES', $diff);
     }
     // Round to hours
     $diff = round($diff / 60);
     // 1 to 23 hours
     if ($diff < 24 || $unit == 'hour') {
         return MText::plural('MLIB_HTML_DATE_RELATIVE_HOURS', $diff);
     }
     // Round to days
     $diff = round($diff / 24);
     // 1 to 6 days
     if ($diff < 7 || $unit == 'day') {
         return MText::plural('MLIB_HTML_DATE_RELATIVE_DAYS', $diff);
     }
     // Round to weeks
     $diff = round($diff / 7);
     // 1 to 4 weeks
     if ($diff <= 4 || $unit == 'week') {
         return MText::plural('MLIB_HTML_DATE_RELATIVE_WEEKS', $diff);
     }
     // Over a month, return the absolute time
     return MHtml::_('date', $date);
 }