protected function menu(&$data) { if (Sobi::Cfg('general.top_menu', true)) { $data['menu'] = array('front' => array('_complex' => 1, '_data' => Sobi::Reg('current_section_name'), '_attributes' => array('lang' => Sobi::Lang(false), 'url' => Sobi::Url(array('sid' => Sobi::Section()))))); if (Sobi::Can('section.search')) { $data['menu']['search'] = array('_complex' => 1, '_data' => Sobi::Txt('MN.SEARCH'), '_attributes' => array('lang' => Sobi::Lang(false), 'url' => Sobi::Url(array('task' => 'search', 'sid' => Sobi::Section())))); } if (Sobi::Can('entry', 'add', 'own', Sobi::Section())) { $data['menu']['add'] = array('_complex' => 1, '_data' => Sobi::Txt('MN.ADD_ENTRY'), '_attributes' => array('lang' => Sobi::Lang(false), 'url' => Sobi::Url(array('task' => 'entry.add', 'sid' => SPRequest::sid())))); } } }
protected function upload() { $ident = SPRequest::cmd('ident', null, 'post'); $data = SPRequest::file($ident, 'tmp_name'); $secret = md5(Sobi::Cfg('secret')); if ($data) { $properties = SPRequest::file($ident); $fileName = md5(SPRequest::file($ident, 'name') . time() . $secret); $path = SPLoader::dirPath("tmp.files.{$secret}", 'front', false) . '/' . $fileName; /** @var $file SPFile */ $file = SPFactory::Instance('base.fs.file'); if (!$file->upload($data, $path)) { $this->message(array('type' => 'error', 'text' => SPLang::e('CANNOT_UPLOAD_FILE'), 'id' => '')); } $path = $file->getPathname(); $type = $this->check($path); $properties['tmp_name'] = $path; SPFs::write($path . '.var', SPConfig::serialize($properties)); $response = array('type' => 'success', 'text' => Sobi::Txt('FILE_UPLOADED', $properties['name'], $type), 'id' => 'file://' . $fileName, 'data' => array('name' => $properties['name'], 'type' => $properties['type'], 'size' => $properties['size'])); } else { $response = array('type' => 'error', 'text' => SPLang::e('CANNOT_UPLOAD_FILE_NO_DATA'), 'id' => ''); } // $field = SPRequest::cmd( 'field', null ); $this->message($response); }
/** * Shows the field in the edit entry or add entry form * @param bool $return return or display directly * @return string */ public function field($return = false) { if (!$this->enabled) { return false; } $field = null; $fdata = Sobi::Reg('editcache'); if ($fdata && is_array($fdata)) { $raw = $this->fromCache($fdata); } else { $raw = SPConfig::unserialize($this->getRaw()); } if ($this->ownLabel) { $fieldTitle = null; $params = array('id' => $this->nid, 'size' => $this->labelWidth, 'class' => $this->cssClass . 'Title'); if ($this->labelMaxLength) { $params['maxlength'] = $this->labelMaxLength; } if ($this->labelWidth) { $params['style'] = "width: {$this->labelWidth}px;"; } if (strlen($this->labelsLabel)) { $this->labelsLabel = SPLang::clean($this->labelsLabel); //$fieldTitle .= "<label for=\"{$this->nid}\" class=\"{$this->cssClass}Title\">{$this->labelsLabel}</label>\n"; $params['placeholder'] = $this->labelsLabel; } $fieldTitle .= SPHtml_Input::text($this->nid, is_array($raw) && isset($raw['label']) ? SPLang::clean($raw['label']) : null, $params); } $class = $this->required ? $this->cssClass . ' required' : $this->cssClass; $this->nid .= '_url'; $params = array('id' => $this->nid, 'size' => $this->width, 'class' => $class); if ($this->maxLength) { $params['maxlength'] = $this->maxLength; } if ($this->width) { $params['style'] = "width: {$this->width}px;"; } $label = Sobi::Txt('FD.MAIL_EMAIL_ADDRESS'); if (!$this->ownLabel && $this->labelAsPlaceholder) { // the field label will be shown only if labelAsPlaceholder is true and no own label for the email is selected $label = $this->__get('name'); //get the field's label from the model } $params['placeholder'] = $label; $value = is_array($raw) && isset($raw['url']) ? $raw['url'] : null; if ($value == null) { if ($this->defaultValue) { $value = $this->defaultValue; } } $field .= SPHtml_Input::text($this->nid, $value, $params); if ($this->ownLabel) { $field = "\n<div class=\"spFieldEmailLabel\">{$fieldTitle}</div><div class=\"spFieldEmail\">{$field}</div>"; } if (!$return) { echo $field; } else { return $field; } }
public static function getGroupsField() { $db =& JFactory::getDbo(); $db->setQuery(' SELECT a.id AS value, a.title AS text, COUNT(DISTINCT b.id) AS level FROM #__usergroups AS a LEFT JOIN `#__usergroups` AS b ON a.lft > b.lft AND a.rgt < b.rgt GROUP BY a.id ORDER BY a.lft ASC'); $options = $db->loadObjectList(); // Check for a database error. if ($db->getErrorNum()) { JError::raiseNotice(500, $db->getErrorMsg()); return null; } for ($i = 0, $n = count($options); $i < $n; $i++) { $options[$i]->text = str_repeat('- ', $options[$i]->level) . $options[$i]->text; } $gids = array(); foreach ($options as $k => $v) { $gids[] = get_object_vars($v); } $gids[0] = array('value' => 0, 'text' => Sobi::Txt('ACL.REG_VISITOR'), 'level' => 0); return $gids; }
protected function translate() { $term = Sobi::Txt(SPRequest::cmd('term')); Sobi::Trigger('Translate', 'Text', array(&$term)); SPFactory::mainframe()->cleanBuffer()->customHeader(); echo json_encode(array('translation' => $term)); exit; }
public function install() { $id = $this->xGetString('id'); $name = $this->xGetString('name'); if (SPLoader::dirPath('usr.templates.' . $id) && !SPRequest::bool('force')) { throw new SPException(SPLang::e('TEMPLATE_INST_DUPLICATE', $name) . ' ' . Sobi::Txt('FORCE_TPL_UPDATE', Sobi::Url(array('task' => 'extensions.install', 'force' => 1, 'root' => basename($this->root) . '/' . basename($this->xmlFile))))); } $requirements = $this->xGetChilds('requirements/*'); if ($requirements && $requirements instanceof DOMNodeList) { SPFactory::Instance('services.installers.requirements')->check($requirements); } $language = $this->xGetChilds('language/file'); $folder = @$this->xGetChilds('language/@folder')->item(0)->nodeValue; if ($language && $language instanceof DOMNodeList && $language->length) { $langFiles = array(); foreach ($language as $file) { $adm = false; if ($file->attributes->getNamedItem('admin')) { $adm = $file->attributes->getNamedItem('admin')->nodeValue == 'true' ? true : false; } $langFiles[$file->attributes->getNamedItem('lang')->nodeValue][] = array('path' => Sobi::FixPath("{$this->root}/{$folder}/" . trim($file->nodeValue)), 'name' => $file->nodeValue, 'adm' => $adm); } SPFactory::CmsHelper()->installLang($langFiles, false, true); } $path = SPLoader::dirPath('usr.templates.' . $id, 'front', false); if (SPRequest::bool('force')) { /** @var $from SPDirectory */ $from = SPFactory::Instance('base.fs.directory', $this->root); $from->moveFiles($path); } else { if (!SPFs::move($this->root, $path)) { throw new SPException(SPLang::e('CANNOT_MOVE_DIRECTORY', $this->root, $path)); } } if (!SPRequest::bool('force')) { $section = $this->xGetChilds('install'); if ($section instanceof DOMNodeList && $section->length) { $this->section($id); } } //05 Oct 2015 Kishore $exec = $this->xGetString('exec'); if ($exec && SPFs::exists($path . DS . $exec)) { include_once "{$path}/{$exec}"; } /** @var $dir SPDirectory */ $dir =& SPFactory::Instance('base.fs.directory', $path); $zip = array_keys($dir->searchFile('.zip', false)); if (count($zip)) { foreach ($zip as $file) { SPFs::delete($file); } } Sobi::Trigger('After', 'InstallTemplate', array($id)); $dir =& SPFactory::Instance('base.fs.directory', SPLoader::dirPath('tmp.install')); $dir->deleteFiles(); return Sobi::Txt('TP.TEMPLATE_HAS_BEEN_INSTALLED', array('template' => $name)); }
private function screen() { $bankData = SPLang::getValue('bankdata', 'application', Sobi::Section()); if (!strlen($bankData)) { SPLang::getValue('bankdata', 'application'); } $tile = Sobi::Txt('APP.BANK_TRANSFER_NAME'); $this->getView('bank_transfer')->assign($tile, 'title')->assign($bankData, 'bankdata')->determineTemplate('extensions', 'bank-transfer')->display(); }
/** * @param string $title * @return string */ public function setTitle($title) { $name = $this->get('entry.name'); Sobi::Trigger('setTitle', $this->name(), array(&$title)); $title = Sobi::Txt($title, array('entry_name' => $name)); $this->set($name, 'entry_name'); $title = parent::setTitle($title); return $title; }
/** * @param string $title * @return string|void */ public function setTitle($title) { if (strstr(SPRequest::task(), '.add')) { $title = str_replace('EDIT', 'ADD', $title); } $title = Sobi::Txt($title, array('field' => $this->get('field.name'), 'field_type' => $this->get('field.fieldType'))); Sobi::Trigger('setTitle', $this->name(), array(&$title)); SPFactory::header()->setTitle($title); $this->set($title, 'site_title'); }
public static function getGroupsField() { $acl =& JFactory::getACL(); $g = $acl->get_group_children_tree(null, 'USERS', false); $gids = array(); foreach ($g as $k => $v) { $gids[] = get_object_vars($v); } array_unshift($gids, array('value' => '0', 'text' => Sobi::Txt('ACL.REG_VISITOR'), 'disable' => null)); return $gids; }
/** * @param string $title * @return void */ public function setTitle($title) { $name = $this->get('template_name'); if (!strlen($name)) { $name = $this->get('file_name'); $title = Sobi::Txt($title, array('path' => $name)); } else { $title = Sobi::Txt($title, array('template' => $name)); } Sobi::Trigger('setTitle', $this->name(), array(&$title)); SPFactory::header()->setTitle($title); $this->set($title, 'site_title'); }
public function remove($def) { $eid = $def->getElementsByTagName('id')->item(0)->nodeValue; $name = $def->getElementsByTagName('name')->item(0)->nodeValue; $type = $def->getElementsByTagName('type')->item(0)->nodeValue; $id = SPFactory::db()->select('extension_id', '#__extensions', array('type' => $type, 'element' => $eid))->loadResult(); jimport('joomla.installer.installer'); if (JInstaller::getInstance()->uninstall($type, $id)) { SPFactory::db()->delete('spdb_plugins', array('pid' => $eid, 'type' => $type), 1); return Sobi::Txt('CMS_EXT_REMOVED', $name); } return array('msg' => Sobi::Txt('CMS_EXT_NOT_REMOVED', $name), 'msgtype' => 'error'); }
/** * @param array $config * @param array $values * @return string */ private function raw($config, $values) { $out = "\n"; $out .= $values['expl']; $out .= Sobi::Txt('APP.PPP.PAY_TITLE') . ': '; $out .= $config['message']['url']; array_shift($config['message']); $v = array(); foreach ($config['message'] as $field => $value) { $v[] = $field . '=' . urlencode(SPLang::replacePlaceHolders($value, $values)); } $out .= implode('&', $v); return SPLang::clean($out); }
public function execute() { $this->start = microtime(true); $sites = $this->getSites(); $responses = array(); $status = 'working'; $message = null; $this->format = SPRequest::bool('fullFormat') ? self::FORMAT_FULL : self::FORMAT; // $this->format = SPRequest::bool( 'fullFormat' ) ? self::FORMAT_FULL : self::FORMAT_FULL; $task = SPRequest::task(); if (in_array($task, array('crawler.init', 'crawler.restart'))) { if ($task == 'crawler.restart') { SPFactory::cache()->cleanSection(Sobi::Section()); } SPFactory::db()->truncate(self::DB_TABLE); $multiLang = Sobi::Cfg('lang.multimode', false); if ($multiLang) { $langs = SPFactory::CmsHelper()->getLanguages(); if ($multiLang && $langs) { foreach ($langs as $lang) { $responses[] = $this->getResponse(Sobi::Cfg('live_site') . 'index.php?option=com_sobipro&sid=' . Sobi::Section() . '&lang=' . $lang); } } } $responses[] = $this->getResponse(Sobi::Cfg('live_site') . 'index.php?option=com_sobipro&sid=' . Sobi::Section()); $sites = $this->getSites(); } if (!count($sites) && !in_array($task, array('crawler.init', 'crawler.restart'))) { $message = Sobi::Txt('CRAWL_URL_PARSED_DONE', SPFactory::db()->select('count(*)', self::DB_TABLE)->loadResult()); SPFactory::db()->truncate(self::DB_TABLE); $this->response(array('status' => 'done', 'data' => array(), 'message' => $message)); } if (count($sites)) { $i = 0; $timeLimit = SPRequest::int('timeLimit', self::TIME_LIMIT, 'get', true); foreach ($sites as $site) { if (!strlen($site)) { continue; } $responses[] = $this->getResponse($site); $i++; if (microtime(true) - $this->start > $timeLimit) { break; } } $message = Sobi::Txt('CRAWL_URL_PARSED_WORKING', $i, count($sites)); } $this->response(array('status' => $status, 'data' => $responses, 'message' => $message)); }
private function status($message, $progress = 0, $interval = 0, $type = SPC::INFO_MSG) { if (!strlen($message)) { $message = Sobi::Txt('PROGRESS_WORKING'); } $progress = $progress ? $progress : $this->progress; $interval = $interval ? $interval : $this->interval; $type = $type ? $type : $this->type; $this->progress = $progress; $this->message = $message; $this->interval = $interval; $this->type = $type; $typeText = Sobi::Txt('STATUS_' . $type); SPFs::write($this->file, json_encode(array('progress' => $progress, 'message' => $message, 'interval' => $interval, 'type' => $type, 'typeText' => $typeText))); }
/** * Shows the field in the edit entry or add entry form * @param bool $return return or display directly * @return string */ public function field($return = false) { if (!$this->enabled) { return false; } $field = null; $fdata = Sobi::Reg('editcache'); if ($fdata && is_array($fdata)) { $raw = $this->fromCache($fdata); } else { $raw = SPConfig::unserialize($this->getRaw()); } if ($this->ownLabel) { $fieldTitle = null; $params = array('id' => $this->nid, 'size' => $this->labelWidth, 'class' => $this->cssClass . 'Title'); if ($this->labelMaxLength) { $params['maxlength'] = $this->labelMaxLength; } if ($this->labelWidth) { $params['style'] = "width: {$this->labelWidth}px;"; } if (strlen($this->labelsLabel)) { $this->labelsLabel = SPLang::clean($this->labelsLabel); $fieldTitle .= "<label for=\"{$this->nid}\" class=\"{$this->cssClass}Title\">{$this->labelsLabel}</label>\n"; } $fieldTitle .= SPHtml_Input::text($this->nid, is_array($raw) && isset($raw['label']) ? SPLang::clean($raw['label']) : null, $params); } $class = $this->required ? $this->cssClass . ' required' : $this->cssClass; $this->nid .= '_url'; $params = array('id' => $this->nid, 'size' => $this->width, 'class' => $class); if ($this->maxLength) { $params['maxlength'] = $this->maxLength; } if ($this->width) { $params['style'] = "width: {$this->width}px;"; } $field .= SPHtml_Input::text($this->nid, is_array($raw) && isset($raw['url']) ? $raw['url'] : null, $params); if ($this->ownLabel) { $label = Sobi::Txt('FD.MAIL_EMAIL_ADDRESS'); $field = "\n<div class=\"spFieldEmailLabel\">{$fieldTitle}</div>\n<div class=\"spFieldEmail\"><label for=\"{$this->nid}_url\" class=\"{$this->cssClass}Title\">{$label}</label>\n{$field}</div>"; } if (!$return) { echo $field; } else { return $field; } }
public function install() { $id = $this->xGetString('id'); $name = $this->xGetString('name'); if (SPLoader::dirPath('usr.templates.' . $id) && !SPRequest::bool('force')) { throw new SPException(SPLang::e('TEMPLATE_INST_DUPLICATE', $name) . ' ' . Sobi::Txt('FORCE_TPL_UPDATE', Sobi::Url(array('task' => 'extensions.install', 'force' => 1, 'root' => basename($this->root) . '/' . basename($this->xmlFile))))); } $requirements = $this->xGetChilds('requirements/*'); if ($requirements && $requirements instanceof DOMNodeList) { SPFactory::Instance('services.installers.requirements')->check($requirements); } $path = SPLoader::dirPath('usr.templates.' . $id, 'front', false); if (SPRequest::bool('force')) { /** @var $from SPDirectory */ $from = SPFactory::Instance('base.fs.directory', $this->root); $from->moveFiles($path); } else { if (!SPFs::move($this->root, $path)) { throw new SPException(SPLang::e('CANNOT_MOVE_DIRECTORY', $this->root, $path)); } } if (!SPRequest::bool('force')) { $section = $this->xGetChilds('install'); if ($section instanceof DOMNodeList && $section->length) { $this->section($id); } } $exec = $this->xGetString('exec'); if ($exec && SPFs::exists($this->root . DS . $exec)) { include_once "{$this->root}/{$exec}"; } /** @var $dir SPDirectory */ $dir =& SPFactory::Instance('base.fs.directory', $path); $zip = array_keys($dir->searchFile('.zip', false)); if (count($zip)) { foreach ($zip as $file) { SPFs::delete($file); } } Sobi::Trigger('After', 'InstallTemplate', array($id)); $dir =& SPFactory::Instance('base.fs.directory', SPLoader::dirPath('tmp.install')); $dir->deleteFiles(); return Sobi::Txt('TP.TEMPLATE_HAS_BEEN_INSTALLED', array('template' => $name)); }
/** */ public function delete() { $childs = $this->getChilds('all', true); Sobi::Trigger('Section', ucfirst(__FUNCTION__), array(&$this->id)); if (count($childs)) { Sobi::Redirect(Sobi::GetUserState('back_url', Sobi::Url()), Sobi::Txt('SEC.DEL_WARN'), SPC::ERROR_MSG, true); } else { Sobi::Trigger('delete', $this->name(), array(&$this)); $db = SPFactory::db(); try { $db->delete('spdb_relations', "id = {$this->id} OR pid = {$this->id}"); } catch (SPException $x) { Sobi::Error($this->name(), SPLang::e('DB_REPORTS_ERR', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__); } try { $db->delete('spdb_config', array('section' => $this->id)); $db->delete('spdb_plugin_section', array('section' => $this->id)); } catch (SPException $x) { Sobi::Error($this->name(), SPLang::e('DB_REPORTS_ERR', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__); } try { $fids = $db->select('fid', 'spdb_field', array('section' => $this->id))->loadResultArray(); if (count($fids)) { foreach ($fids as $fid) { try { $db->select('*', $db->join(array(array('table' => 'spdb_field', 'as' => 'sField', 'key' => 'fieldType'), array('table' => 'spdb_field_types', 'as' => 'sType', 'key' => 'tid'))), array('fid' => $fid)); $f = $db->loadObject(); } catch (SPException $x) { Sobi::Error($this->name(), SPLang::e('DB_REPORTS_ERR', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__); } $field =& SPFactory::Model('field', true); $field->extend($f); $field->delete(); } } } catch (SPException $x) { Sobi::Error($this->name(), SPLang::e('DB_REPORTS_ERR', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__); } parent::delete(); Sobi::Trigger('afterDelete', $this->name(), array(&$this)); } }
protected function save() { if (!SPFactory::mainframe()->checkToken()) { Sobi::Error('Token', SPLang::e('UNAUTHORIZED_ACCESS_TASK', SPRequest::task()), SPC::ERROR, 403, __LINE__, __FILE__); } $this->validate('extensions.paypal', array('task' => 'paypal', 'pid' => Sobi::Section())); SPFactory::registry()->saveDBSection(array(array('key' => 'ppurl', 'value' => SPRequest::string('ppurl')), array('key' => 'ppemail', 'value' => SPRequest::string('ppemail')), array('key' => 'ppcc', 'value' => SPRequest::string('ppcc')), array('key' => 'pprurl', 'value' => SPRequest::string('pprurl'))), 'paypal_' . Sobi::Section()); $data = array('key' => 'ppexpl', 'value' => SPRequest::string('ppexpl', null, true), 'type' => 'application', 'id' => Sobi::Section(), 'section' => Sobi::Section()); try { SPLang::saveValues($data); $data['key'] = 'ppsubject'; $data['value'] = SPRequest::string('ppsubject', true); SPLang::saveValues($data); } catch (SPException $x) { $message = SPLang::e('DB_REPORTS_ERR', $x->getMessage()); Sobi::Error('SPPaymentBt', $message, SPC::WARNING, 0, __LINE__, __FILE__); $this->response(Sobi::Back(), $message, false, 'error'); } $this->response(Sobi::Back(), Sobi::Txt('MSG.ALL_CHANGES_SAVED'), false, 'success'); }
protected function iconChooser() { if (!Sobi::Can('category.edit')) { Sobi::Error('category', 'You have no permission to access this site', SPC::ERROR, 403, __LINE__, __FILE__); } if (strlen(SPRequest::cmd('font'))) { return $this->iconFont(); } $folder = SPRequest::cmd('iconFolder', null); $callback = SPRequest::cmd('callback', 'SPSelectIcon'); $dir = $folder ? Sobi::Cfg('images.category_icons') . str_replace('.', '/', $folder) . '/' : Sobi::Cfg('images.category_icons'); $files = array(); $dirs = array(); if ($folder) { $up = explode('.', $folder); unset($up[count($up) - 1]); $dirs[] = array('name' => Sobi::Txt('FOLEDR_UP'), 'count' => count(scandir($dir . '..')) - 2, 'url' => Sobi::Url(array('task' => 'category.icon', 'out' => 'html', 'iconFolder' => count($up) ? implode('.', $up) : null))); } $ext = array('png', 'jpg', 'jpeg', 'gif'); if (is_dir($dir) && ($dh = opendir($dir))) { while (($file = readdir($dh)) !== false) { if (filetype($dir . $file) == 'file' && in_array(strtolower(SPFs::getExt($file)), $ext)) { $files[] = array('name' => $folder ? str_replace('.', '/', $folder) . '/' . $file : $file, 'path' => str_replace('\\', '/', str_replace(SOBI_ROOT, Sobi::Cfg('live_site'), str_replace('//', '/', $dir . $file)))); } elseif (filetype($dir . $file) == 'dir' && !($file == '.' || $file == '..')) { $dirs[] = array('name' => $file, 'count' => count(scandir($dir . $file)) - 2, 'path' => str_replace('\\', '/', str_replace(SOBI_ROOT, Sobi::Cfg('live_site'), str_replace('//', '/', $dir . $file))), 'url' => Sobi::Url(array('task' => 'category.icon', 'out' => 'html', 'iconFolder' => $folder ? $folder . '.' . $file : $file))); } } closedir($dh); } sort($files); sort($dirs); $view = SPFactory::View('category'); $view->setTemplate('category.icon'); $view->assign($this->_task, 'task'); $view->assign($callback, 'callback'); $view->assign($files, 'files'); $view->assign(Sobi::Cfg('images.folder_ico'), 'folder'); $view->assign($dirs, 'directories'); $view->icon(); }
private function screen() { $view =& SPFactory::View('view', true); $view->setTemplate('config.help'); if (SPLoader::path('etc.repos.sobipro_core.repository', 'front', true, 'xml')) { $repository = SPFactory::Instance('services.installers.repository'); $repository->loadDefinition(SPLoader::path("etc.repos.sobipro_core.repository", 'front', true, 'xml')); try { $repository->connect(); } catch (SPException $x) { $view->assign(SPLang::e('REPO_ERR', $x->getMessage()), 'message'); } try { $response = $repository->help($repository->get('token'), SPRequest::cmd('mid')); $view->assign($response, 'message'); } catch (SPException $x) { $view->assign(SPLang::e('REPO_ERR', $x->getMessage()), 'message'); } } else { $view->assign(Sobi::Txt('MSG.HELP_ADD_CORE_REPO'), 'message'); } $view->display(); }
/** * Enter description here... * * @param unknown_type $row * @param unknown_type $id * @return unknown */ public static function checkedOut($row, $id = 'sid') { $state = $row->get('cout'); if ($state && $state != Sobi::My('id') && strtotime($row->get('coutTime')) > time()) { /* translate alternative text */ $user = SPUser::getInstance($state); $uname = $user->get('name'); $img = Sobi::Cfg('list_icons.checked_out'); $s = Sobi::Txt($row->get('oType') . '.checked_out'); $a = Sobi::Txt($row->get('oType') . '.checked_out_by', array('user' => $uname, 'time' => $row->get('coutTime'))); $r = SPTooltip::toolTip($a, $s, $img); } else { $sid = $row->get('id'); $r = "<input type=\"checkbox\" name=\"{$id}[]\" value=\"{$sid}\" onclick=\"SPCheckListElement( this )\" />"; } return $r; }
public function checkbox($cell) { /** First let's check if it is not checked out */ if (isset($cell['attributes']['checked-out-by']) && isset($cell['attributes']['checked-out-time']) && $cell['attributes']['checked-out-by'] && $cell['attributes']['checked-out-by'] != Sobi::My('id') && strtotime($cell['attributes']['checked-out-time']) > gmdate('U')) { if (isset($cell['attributes']['checked-out-ico']) && $cell['attributes']['checked-out-ico']) { $icon = $cell['attributes']['checked-out-ico']; } else { $icon = $this->_checkedOutIcon; } $user = SPUser::getInstance($cell['attributes']['checked-out-by']); $txt = Sobi::Txt('CHECKED_OUT', $user->get('name'), $cell['attributes']['checked-out-time']); $this->_out[] = '<a href="#" rel="sp-tooltip" data-original-title="' . $txt . '" class="checkedout">'; $this->_out[] = '<i class="icon-' . $icon . '"></i>'; $this->_out[] = '</a>'; return $cell; } elseif ($this->istSet($cell['attributes'], 'locked', true)) { $icon = $this->istSet($cell['attributes'], 'locked-icon') ? $cell['attributes']['locked-icon'] : $this->_checkedOutIcon; $text = $this->istSet($cell['attributes'], 'locked-text') ? $cell['attributes']['locked-text'] : $this->_checkedOutIcon; $this->_out[] = '<a href="#" rel="sp-tooltip" data-original-title="' . $text . '" class="checkedout">'; $this->_out[] = '<i class="icon-' . $icon . '"></i>'; $this->_out[] = '</a>'; return $cell; } $type = $this->istSet($cell['attributes'], 'input-type') ? $cell['attributes']['input-type'] : 'checkbox'; if (isset($cell['attributes']['rel']) && $cell['attributes']['rel']) { $this->_out[] = '<input type="' . $type . '" name="spToggle" value="1" rel="' . $cell['attributes']['rel'] . '"/>'; return $cell; } else { $multiple = $this->istSet($cell['attributes'], 'multiple', 'false') ? null : '[]'; $this->_out[] = '<input type="' . $type . '" name="' . $cell['attributes']['name'] . $multiple . '" value="' . $cell['content'] . '"/>'; return $cell; } }
public function display() { $this->_type = 'search'; $type = $this->key('template_type', 'xslt'); if ($type != 'php' && Sobi::Cfg('global.disable_xslt', false)) { $type = 'php'; } if ($type == 'xslt') { $searchData = array(); $fields = $this->get('fields'); $visitor = $this->get('visitor'); $p = $this->get('priorities'); $priorities = array(); if (is_array($p) && count($p)) { foreach ($p as $priority => $eids) { if (is_array($eids) && count($eids)) { foreach ($eids as $sid) { $priorities[$sid] = $priority; } } } } $entries = $this->get('entries'); $searchData['section'] = array('_complex' => 1, '_data' => Sobi::Section(true), '_attributes' => array('id' => Sobi::Section(), 'lang' => Sobi::Lang(false))); $searchPhrase = $this->get('search_for'); $phrase = $this->get('search_phrase'); $searchPhrase = strlen($searchPhrase) ? $searchPhrase : Sobi::Txt('SH.SEARCH_FOR_BOX'); SPFactory::header()->addJsCode('var spSearchDefStr = "' . Sobi::Txt('SH.SEARCH_FOR_BOX') . '"'); if ($this->get('$eInLine')) { $searchData['entries_in_line'] = $this->get('$eInLine'); } if ($this->get('$eCount') >= 0) { $searchData['message'] = Sobi::Txt('SH.SEARCH_FOUND_RESULTS', array('count' => $this->get('$eCount'))); } $this->menu($searchData); $this->alphaMenu($searchData); $fData = array(); if (Sobi::Cfg('search.show_searchbox', true)) { $fData['searchbox'] = array('_complex' => 1, '_data' => array('label' => array('_complex' => 1, '_data' => Sobi::Txt('SH.SEARCH_FOR'), '_attributes' => array('lang' => Sobi::Lang(false))), 'data' => array('_complex' => 1, '_xml' => 1, '_data' => SPHtml_Input::text('sp_search_for', $searchPhrase, array('class' => Sobi::Cfg('search.form_box_def_css', 'SPSearchBox'), 'id' => 'SPSearchBox')))), '_attributes' => array('position' => 1, 'css_class' => 'SPSearchBox')); } if (Sobi::Cfg('search.top_button', true)) { $fData['top_button'] = array('_complex' => 1, '_data' => array('label' => array('_complex' => 1, '_data' => Sobi::Txt('SH.SEARCH_START'), '_attributes' => array('lang' => Sobi::Lang())), 'data' => array('_complex' => 1, '_xml' => 1, '_data' => SPHtml_Input::submit('search', Sobi::Txt('SH.START'), array('id' => 'top_button')))), '_attributes' => array('position' => 1, 'css_class' => 'SPSearchButton')); } if (Sobi::Cfg('search.show_phrase', true)) { $fData['phrase'] = array('_complex' => 1, '_data' => array('label' => array('_complex' => 1, '_data' => Sobi::Txt('SH.FIND_ENTRIES_THAT_HAVE'), '_attributes' => array('lang' => Sobi::Lang(false))), 'data' => array('_complex' => 1, '_xml' => 1, '_data' => SPHtml_Input::radioList('spsearchphrase', array('all' => Sobi::Txt('SH.FIND_ENTRIES_THAT_HAVE_ALL_WORDS'), 'any' => Sobi::Txt('SH.FIND_ENTRIES_THAT_HAVE_ANY_WORDS'), 'exact' => Sobi::Txt('SH.FIND_ENTRIES_THAT_HAVE_EXACT_PHRASE')), 'spsearchphrase', strlen($phrase) ? $phrase : Sobi::Cfg('search.form_searchphrase_def', 'all'), null, 'right'))), '_attributes' => array('position' => 1, 'css_class' => 'SPSearchPhrase')); } if (count($fields)) { foreach ($fields as $field) { $data = $field->searchForm(); $suffix = $field->get('searchMethod') != 'range' ? $field->get('suffix') : null; if (strlen($data)) { $fData[$field->get('nid')] = array('_complex' => 1, '_data' => array('label' => array('_complex' => 1, '_data' => $field->get('name'), '_attributes' => array('lang' => Sobi::Lang())), 'data' => array('_complex' => 1, '_xml' => 1, '_data' => $data)), '_attributes' => array('id' => $field->get('id'), 'type' => $field->get('type'), 'suffix' => $suffix, 'position' => $field->get('position'), 'css_class' => strlen($field->get('cssClass')) ? $field->get('cssClass') : 'spField')); } } } if (Sobi::Cfg('search.bottom_button', false)) { $fData['bottom_button'] = array('_complex' => 1, '_data' => array('label' => array('_complex' => 1, '_data' => Sobi::Txt('SH.SEARCH_START'), '_attributes' => array('lang' => Sobi::Lang(false))), 'data' => array('_complex' => 1, '_xml' => 1, '_data' => SPHtml_Input::submit('search', Sobi::Txt('SH.START')))), '_attributes' => array('position' => 1, 'css_class' => 'SPSearchButton')); } $searchData['fields'] = $fData; if (count($entries)) { $this->loadNonStaticData($entries); $manager = Sobi::Can('entry', 'edit', '*', Sobi::Section()) ? true : false; foreach ($entries as $entry) { $en = $this->entry($entry, $manager); $searchData['entries'][] = array('_complex' => 1, '_attributes' => array('id' => $en['id'], 'search-priority' => isset($priorities[$en['id']]) ? $priorities[$en['id']] : 'undefined'), '_data' => $en); } $this->navigation($searchData); } $searchData['visitor'] = $this->visitorArray($visitor); $this->_attr = $searchData; } Sobi::Trigger($this->_type, ucfirst(__FUNCTION__), array(&$this->_attr)); parent::display($this->_type); }
protected function loadAdvanced() { $label = self::$functionsLabel ? self::$functionsLabel : JText::_('SP.SOBI_SELECT_FUNCTIONALITY'); return '<div class="SobiPro">' . ' <div id="SobiProSelector" class="btn btn-primary" data-mid="' . self::$mid . '">' . ' <i class="icon-expand"></i> <span id="SobiProSelectedFunction">' . $label . '</span>' . ' </div>' . ' <div class="modal hide" id="SobiProModal" >' . ' <div class="modal-header"><button type="button" class="close" data-dismiss="modal">×</button>' . ' <h3>' . Sobi::Txt('SOBI_SELECT_FUNCTIONALITY') . '</h3>' . ' </div>' . ' <div class="modal-body">' . ' <i class="icon-spinner icon-spin icon-large"></i>' . ' </div>' . ' <div class="modal-footer">' . ' <a href="#" class="btn btn-danger pull-left ctrl-clear" data-dismiss="modal">' . Sobi::Txt('SOBI_MENU_CLEAR') . '</a>' . ' <a href="#" class="btn" data-dismiss="modal">' . Sobi::Txt('SOBI_CLOSE_WINDOW') . '</a>' . ' <a href="#" class="btn btn-primary ctrl-save" data-dismiss="modal">' . Sobi::Txt('SOBI.JMENU_SAVE') . '</a>' . ' </div>' . ' </div>' . ' <input type="hidden" id="selectedSid" name="jform[request][sid]" value="' . self::$sid . '"/>' . '</div>'; }
protected function view() { /* determine template package */ $tplPackage = Sobi::Cfg('section.template', SPC::DEFAULT_TEMPLATE); Sobi::ReturnPoint(); $this->_task = 'user'; if (!$this->_model) { $this->setModel('section'); $this->_model->init(Sobi::Section()); } $this->visible(); /* load template config */ $this->template(); $this->tplCfg($tplPackage); /* get limits - if defined in template config - otherwise from the section config */ $eLimit = $this->tKey($this->template, 'entries_limit', Sobi::Cfg('list.entries_limit', 2)); $eInLine = $this->tKey($this->template, 'entries_in_line', Sobi::Cfg('list.entries_in_line', 2)); $url = array('sid' => SPRequest::sid(), 'task' => 'list.user'); if (SPRequest::int('uid')) { $url['uid'] = SPRequest::int('uid'); $this->uid = (int) SPRequest::int('uid'); } else { $this->uid = (int) Sobi::My('id'); } $this->user = SPJoomlaUser::getBaseData((int) $this->uid); if (!$this->user) { throw new SPException(SPLang::e('UNAUTHORIZED_ACCESS')); } /* get the site to display */ $site = SPRequest::int('site', 1); $eLimStart = ($site - 1) * $eLimit; $eOrder = $this->parseOrdering('entries', 'eorder', $this->tKey($this->template, 'entries_ordering', Sobi::Cfg('list.entries_ordering', 'name.asc'))); $eCount = count($this->getEntries($eOrder, 0, 0, true, array('spo.owner' => $this->uid), true, Sobi::Section())); $entries = $this->getEntries($eOrder, $eLimit, $eLimStart, true, array('spo.owner' => $this->uid), true, Sobi::Section()); // $eCount = count( $this->_getEntries( 0, 0, true ) ); // $entries = $this->_getEntries( $eLimit, $site ); $pn = SPFactory::Instance('helpers.pagenav_' . $this->tKey($this->template, 'template_type', 'xslt'), $eLimit, $eCount, $site, $url); if (SPRequest::int('site', 0)) { $url['site'] = SPRequest::int('site', 0); } SPFactory::header()->addCanonical(Sobi::Url($url, true, true, true)); /* handle meta data */ SPFactory::header()->objMeta($this->_model); SPFactory::mainframe()->addToPathway(Sobi::Txt('UL.PATH_TITLE', array('username' => $this->user->username, 'user' => $this->user->name)), Sobi::Url('current')); SPFactory::header()->addTitle(Sobi::Txt('UL.TITLE', array('username' => $this->user->username, 'user' => $this->user->name, 'section' => $this->_model->get('name'))), array(ceil($eCount / $eLimit), $site)); /* add pathway */ /* get view class */ $view = SPFactory::View('listing'); $view->assign($eLimit, '$eLimit'); $view->assign($eLimStart, '$eLimStart'); $view->assign($eCount, '$eCount'); $view->assign($eInLine, '$eInLine'); $view->assign($this->_task, 'task'); $view->assign($this->_model, 'section'); $view->setConfig($this->_tCfg, $this->template); $view->setTemplate($tplPackage . '.' . $this->templateType . '.' . $this->template); $view->assign($pn->get(), 'navigation'); $view->assign(SPFactory::user()->getCurrent(), 'visitor'); $view->assign($entries, 'entries'); Sobi::Trigger('UserListing', 'View', array(&$view)); $view->display(); }
private function getLabel($button) { if ($button['type'] == 'url') { $button['type'] = $button['task']; return $this->getLabel($button); } if (isset($this->labels[$button['type']])) { $label = Sobi::Txt('TB.' . $this->labels[$button['type']]); } else { $label = Sobi::Txt('TB.' . $button['type']); } return $label; }
/** * */ public function ProxyUpload() { $ident = SPRequest::cmd('ident', null, 'post'); $data = SPRequest::file($ident, 'tmp_name'); $secret = md5(Sobi::Cfg('secret')); if ($data) { $properties = SPRequest::file($ident); $orgFileName = $properties['name']; $extension = SPFs::getExt($orgFileName); $orgFileName = str_replace('.' . $extension, '.' . strtolower($extension), $orgFileName); if ($properties['size'] > $this->maxSize) { $this->message(array('type' => 'error', 'text' => SPLang::e('FIELD_IMG_TOO_LARGE', $this->name, $properties['size'], $this->maxSize), 'id' => '')); } $dirNameHash = md5($orgFileName . time() . $secret); $dirName = SPLoader::dirPath("tmp.files.{$secret}.{$dirNameHash}", 'front', false); SPFs::mkdir($dirName); $path = $dirName . $orgFileName; /** @var $file SPImage */ $orgImage = SPFactory::Instance('base.fs.image'); if (!$orgImage->upload($data, $path)) { $this->message(array('type' => 'error', 'text' => SPLang::e('CANNOT_UPLOAD_FILE'), 'id' => '')); } if (Sobi::Cfg('image_field.fix_rotation', true)) { if ($orgImage->fixRotation()) { $orgImage->save(); } } if ($this->crop) { $croppedImage = clone $orgImage; list($originalWidth, $originalHeight) = getimagesize($path); $aspectRatio = $this->resizeWidth / $this->resizeHeight; $width = $aspectRatio * $originalHeight > $originalWidth ? $originalWidth : $aspectRatio * $originalHeight; $height = $originalWidth / $aspectRatio > $originalHeight ? $originalHeight : $originalWidth / $aspectRatio; try { $croppedImage->crop($width, $height); $croppedImage->saveAs($dirName . 'cropped_' . $orgFileName); $ico = SPFactory::Instance('base.fs.image', $dirName . 'cropped_' . $orgFileName); } catch (SPException $x) { $this->message(array('type' => 'error', 'text' => SPLang::e('FIELD_IMG_CANNOT_CROP', $x->getMessage()), 'id' => '')); } } else { $ico = clone $orgImage; } $image = clone $orgImage; try { $previewSize = explode(':', Sobi::Cfg('image.preview_size', '500:500')); $image->resample($previewSize[0], $previewSize[1], false); $image->saveAs($dirName . 'resized_' . $orgFileName); } catch (SPException $x) { $image->delete(); $this->message(array('type' => 'error', 'text' => SPLang::e('FIELD_IMG_CANNOT_RESAMPLE', $x->getMessage()), 'id' => '')); } try { $icoSize = explode(':', Sobi::Cfg('image.ico_size', '80:80')); $ico->resample($icoSize[0], $icoSize[1], false); $ico->saveAs($dirName . 'icon_' . $orgFileName); } catch (SPException $x) { $ico->delete(); $this->message(array('type' => 'error', 'text' => SPLang::e('FIELD_IMG_CANNOT_RESAMPLE', $x->getMessage()), 'id' => '')); } $path = $orgImage->getPathname(); $type = $this->check($path); $properties['tmp_name'] = $path; SPFs::write(SPLoader::dirPath("tmp.files.{$secret}", 'front', false) . '/' . $orgFileName . '.var', SPConfig::serialize($properties)); $response = array('type' => 'success', 'text' => $this->crop ? Sobi::Txt('IMAGE_UPLOADED_CROP', $properties['name'], $type) : Sobi::Txt('FILE_UPLOADED', $properties['name']), 'id' => 'directory://' . $dirNameHash, 'data' => array('name' => $properties['name'], 'type' => $properties['type'], 'size' => $properties['size'], 'original' => $dirNameHash . '/' . $properties['name'], 'icon' => $dirNameHash . '/' . 'icon_' . $orgFileName, 'crop' => $this->crop, 'height' => $this->resizeHeight, 'width' => $this->resizeWidth)); } else { $response = array('type' => 'error', 'text' => SPLang::e('CANNOT_UPLOAD_FILE_NO_DATA'), 'id' => ''); } $this->message($response); }
/** * @param $url * @return bool */ protected function getItemid(&$url) { $sid = isset($url['pid']) && $url['pid'] ? $url['pid'] : $url['sid']; if (!(int) $sid) { return false; } $url['Itemid'] = 0; // Thu, Feb 27, 2014 16:28:22 - iy is probably the right solution // but NTaRS $menu = JFactory::getApplication('site')->getMenu('site'); // Thu, Mar 6, 2014 12:42:01 - let's check // $menu = JApplication::getMenu( 'site' ); if (isset($url['task'])) { $task = $url['task'] == 'search.results' ? 'search' : $url['task']; $link = 'index.php?option=com_sobipro&task=' . $task . '&sid=' . $sid; } else { $link = 'index.php?option=com_sobipro&sid=' . $sid; } $item = $menu->getItems('link', $link, true); if ($item && count($item)) { $url['Itemid'] = $item->id; } else { $path = SPFactory::config()->getParentPath($sid); if (count($path)) { foreach ($path as $sid) { $item = $menu->getItems('link', 'index.php?option=com_sobipro&sid=' . $sid, true); if ($item && count($item)) { $url['Itemid'] = $item->id; } } } } // if we still don't have an Itemid it means that there is no link to SobiPro section if (!$url['Itemid'] && !defined('SOBIPRO_ADM')) { SPFactory::message()->warning(Sobi::Txt('ITEMID_MISSING_WARN', 'https://www.sigsiu.net/help_screen/joomla.menu', $sid), false, false)->setSystemMessage('SEF-URL'); } }
private function editFile() { if (Sobi::Section() && Sobi::Cfg('section.template') == SPC::DEFAULT_TEMPLATE) { SPFactory::message()->warning(Sobi::Txt('TP.DEFAULT_WARN', 'https://www.sigsiu.net/help_screen/template.info'), false)->setSystemMessage(); } $file = SPRequest::cmd('file'); $file = $this->file($file); $ext = SPFs::getExt($file); $fileContent = SPFs::read($file); $path = str_replace('\\', '/', SOBI_PATH); if (strstr($file, $path)) { $filename = str_replace($path . '/usr/templates/', null, $file); } else { $filename = str_replace(SOBI_ROOT, null, $file); } $menu = $this->createMenu(); if (Sobi::Section()) { $menu->setOpen('AMN.APPS_SECTION_TPL'); } else { $menu->setOpen('GB.CFG.GLOBAL_TEMPLATES'); } /** @var $view SPAdmTemplateView */ $view = SPFactory::View('template', true)->assign($fileContent, 'file_content')->assign($filename, 'file_name')->assign($ext, 'file_ext')->assign($menu, 'menu')->assign($this->_task, 'task')->assign(Sobi::Section(), 'sid')->addHidden(SPRequest::cmd('file'), 'fileName')->addHidden($filename, 'filePath')->determineTemplate('template', 'edit'); Sobi::Trigger('Edit', $this->name(), array(&$file, &$view)); $view->display(); }