/** * @param string $to - path where the archive should be extracted to * @return bool */ public function extract($to) { $r = false; $ext = SPFs::getExt($this->_filename); switch ($ext) { case 'zip': $zip = new ZipArchive(); if ($zip->open($this->_filename) === true) { SPException::catchErrors(SPC::WARNING); try { $zip->extractTo($to); $zip->close(); $r = true; } catch (SPException $x) { $t = Sobi::FixPath(Sobi::Cfg('fs.temp') . DS . md5(microtime())); SPFs::mkdir($t, 0777); $dir = SPFactory::Instance('base.fs.directory', $t); if ($zip->extractTo($t)) { $zip->close(); $dir->moveFiles($to); $r = true; } SPFs::delete($dir->getPathname()); } SPException::catchErrors(0); } break; } return $r; }
private function save() { $data = $this->get('pdata'); if (!$data) { $data = SPFactory::payment()->summary(); } $methods = SPFactory::payment()->getMethods($this->get('entry'), $data); $visitor = $this->get('visitor'); $xml = $this->payment(); if (count($methods)) { $xml['payment_methods'] = array(); foreach ($methods as $mid => $mout) { $params = array(); if (is_array($mout)) { $params = $mout; $mout = $mout['content']; unset($params['content']); } $xml['payment_methods'][$mid] = array('_complex' => 1, '_xml' => 1, '_data' => $mout, '_attributes' => $params); } } $xml['visitor'] = $this->visitorArray($visitor); $this->_attr = $xml; Sobi::Trigger('PaymentView', ucfirst(__FUNCTION__), array(&$this->_attr)); }
protected function crawlSobiSection($sid) { $done = false; $task = $this->cleanCache ? 'crawler.restart' : 'crawler.init'; $connection = SPFactory::Instance('services.remote'); while (!$done && time() - $this->start < $this->timeLimit) { $url = $this->liveURL . "/index.php?option=com_sobipro&task={$task}&sid={$sid}&format=raw&tmpl=component&timeLimit={$this->loopTimeLimit}&fullFormat=1"; list($content, $response) = $this->SpConnect($connection, $url); $task = 'crawler'; if ($response['http_code'] == 303) { preg_match('/Location: (http.*)/', $content, $newUrl); list($content, $response) = $this->SpConnect($connection, $newUrl[1]); } if ($response['http_code'] == 200) { $content = substr($content, $response['header_size']); $data = json_decode($content); $done = $data->status == 'done'; $this->SpOut(''); $this->SpOut('============'); $this->SpOut("[ " . date(DATE_RFC2822) . " ] {$data->message}"); $this->SpOut('============'); foreach ($data->data as $row) { $u = strip_tags($row->url); $this->SpOut("{$u}\t{$row->count}\t{$row->code}\t{$row->time}"); } } else { $done = true; $this->out('[ERROR] Invalid return code: ' . $response['http_code']); } } }
/** * Gets basic data from the CMS (e.g Joomla) and stores in the #SPConfig instance */ public function getBasicCfg() { parent::getBasicCfg(); if (defined('SOBIPRO_ADM')) { SPFactory::config()->change('adm_img_folder_live', Sobi::FixPath(JURI::root() . '/' . SOBI_ADM_FOLDER . '/templates/' . JFactory::getApplication()->getTemplate() . '/images/admin'), 'general'); } }
public function onBeforeCompileHead() { // if the class exists it means something initialised it so we can send the header if (class_exists('SPFactory')) { SPFactory::header()->sendHeader(); } }
public function save(&$attr) { parent::save($attr); if ($attr['method'] == 'fixed') { if (!$attr['fixedCid']) { throw new SPException(SPLang::e('FIELD_FIXED_CID_MISSING')); } else { $cids = explode(',', $attr['fixedCid']); if (count($cids)) { foreach ($cids as $cid) { $catId = (int) $cid; if (!$catId) { throw new SPException(SPLang::e('FIELD_FIXED_CID_INVALID', $cid)); } if ($catId == Sobi::Section()) { throw new SPException(SPLang::e('FIELD_FIXED_CID_INVALID', $cid)); } else { $parents = SPFactory::config()->getParentPath($catId); if (!isset($parents[0]) || $parents[0] != Sobi::Section()) { throw new SPException(SPLang::e('FIELD_FIXED_CID_INVALID_SECTION', $catId)); } } } } else { throw new SPException(SPLang::e('FIELD_FIXED_CID_MISSING')); } } } }
private function edit() { $jsFiles = array('codemirror.codemirror'); $ext = $this->get('file_ext'); $mode = null; switch (strtolower($ext)) { case 'xsl': case 'xml': $jsFiles[] = 'codemirror.mode.xml.xml'; break; case 'less': $jsFiles[] = 'codemirror.mode.less.less'; break; case 'css': $jsFiles[] = 'codemirror.mode.css.css'; break; case 'js': $jsFiles[] = 'codemirror.mode.javascript.javascript'; break; case 'php': $jsFiles[] = 'codemirror.mode.clike.clike'; $jsFiles[] = 'codemirror.mode.php.php'; $jsFiles[] = 'codemirror.mode.htmlmixed.htmlmixed'; $jsFiles[] = 'codemirror.mode.xml.xml'; $jsFiles[] = 'codemirror.mode.javascript.javascript'; $jsFiles[] = 'codemirror.mode.css.css'; $mode = 'application/x-httpd-php'; break; case 'ini': $jsFiles[] = 'codemirror.mode.properties.properties'; break; } SPFactory::header()->addJsFile($jsFiles)->addCssFile('codemirror.codemirror')->addJsCode('SobiPro.jQuery( document ).ready( function () { SPInitTplEditor( "' . $mode . '") } );'); }
/** * @param bool $useCookies * @param string $cssFile - separate CSS file * @param string $prefix * @return sobiTabs * @deprecated */ public function __construct($useCookies = true, $cssFile = 'tabs', $prefix = null) { $this->useCookies = $useCookies ? 1 : 0; $this->prefix = $prefix; if ($cssFile) { SPFactory::header()->addCssFile($cssFile); } SPFactory::header()->addJsFile('tabs'); }
/** */ public function execute() { SPFactory::mainframe()->cleanBuffer()->customHeader(); if (SPFs::exists($this->file)) { echo SPFs::read($this->file); } else { echo json_encode(array('progress' => 0, 'message' => '', 'interval' => 100, 'type' => '')); } exit; }
public function execute() { $method = explode('.', $this->_task); $this->nid = 'field_' . $method[0]; $method = 'Proxy' . ucfirst($method[1]); $this->fid = SPFactory::db()->select('fid', 'spdb_field', array('nid' => $this->nid, 'section' => Sobi::Section()))->loadResult(); $this->field = SPFactory::Model('field'); $this->field->init($this->fid); $this->field->{$method}(); return true; }
/** * Return min or recommend Joomla! version * @param $recommended * @return array */ public static function minCmsVersion($recommended = false) { $updater = JUpdater::getInstance(); $updater->findUpdates(700, 0); $version = SPFactory::db()->select('version', '#__updates', array('extension_id' => 700))->loadResult(); $recommendedVersion = array('major' => 3, 'minor' => 2, 'build' => 3); if ($version) { $version = explode('.', $version); $recommendedVersion = array('major' => $version[0], 'minor' => $version[1], 'build' => $version[2]); } return $recommended ? $recommendedVersion : array('major' => 3, 'minor' => 2, 'build' => 0); }
private function view() { $type = $this->key('template_type', 'xslt'); if ($type != 'php' && Sobi::Cfg('global.disable_xslt', false)) { $type = 'php'; } if ($type == 'xslt') { $visitor = $this->get('visitor'); $current = $this->get('section'); $categories = $this->get('categories'); $entries = $this->get('entries'); $data = array(); $data['id'] = $current->get('id'); $data['section'] = array('_complex' => 1, '_data' => Sobi::Section(true), '_attributes' => array('id' => Sobi::Section(), 'lang' => Sobi::Lang(false))); $data['name'] = array('_complex' => 1, '_data' => $this->get('listing_name'), '_attributes' => array('lang' => Sobi::Lang(false))); if (Sobi::Cfg('category.show_desc')) { $desc = $current->get('description'); if (Sobi::Cfg('category.parse_desc')) { Sobi::Trigger('prepare', 'Content', array(&$desc, $current)); } $data['description'] = array('_complex' => 1, '_cdata' => 1, '_data' => $desc, '_attributes' => array('lang' => Sobi::Lang(false))); } $data['meta'] = array('description' => $current->get('metaDesc'), 'keys' => $this->metaKeys($current), 'author' => $current->get('metaAuthor'), 'robots' => $current->get('metaRobots')); $data['entries_in_line'] = $this->get('$eInLine'); $data['categories_in_line'] = $this->get('$cInLine'); $this->menu($data); $this->alphaMenu($data); $data['visitor'] = $this->visitorArray($visitor); if (count($categories)) { foreach ($categories as $category) { if (is_numeric($category)) { $category = SPFactory::Category($category); } $data['categories'][] = array('_complex' => 1, '_attributes' => array('id' => $category->get('id'), 'nid' => $category->get('nid')), '_data' => $this->category($category)); unset($category); } } if (count($entries)) { $this->loadNonStaticData($entries); $manager = Sobi::Can('entry', 'edit', '*', Sobi::Section()) ? true : false; foreach ($entries as $eid) { $en = $this->entry($eid, $manager); $data['entries'][] = array('_complex' => 1, '_attributes' => array('id' => $en['id']), '_data' => $en); } $this->navigation($data); } $this->_attr = $data; } // general listing trigger Sobi::Trigger('Listing', ucfirst(__FUNCTION__), array(&$this->_attr)); // specific lisitng trigger Sobi::Trigger($this->_type, ucfirst(__FUNCTION__), array(&$this->_attr)); }
private function screen() { $data = SPFactory::registry()->loadDBSection('paypal_' . Sobi::Section())->get('paypal_' . Sobi::Section()); if (!count($data)) { $data = SPFactory::registry()->loadDBSection('paypal')->get('paypal'); } $ppexpl = SPLang::getValue('ppexpl', 'application', Sobi::Section()); $ppsubj = SPLang::getValue('ppsubject', 'application', Sobi::Section()); if (!strlen($ppsubj)) { $ppsubj = SPLang::getValue('ppsubject', 'application'); } $this->getView('paypal')->assign($tile, 'title')->assign($data['ppurl']['value'], 'ppurl')->assign($data['ppemail']['value'], 'ppemail')->assign($data['pprurl']['value'], 'pprurl')->assign($data['ppcc']['value'], 'ppcc')->assign($ppexpl, 'ppexpl')->assign($ppsubj, 'ppsubject')->determineTemplate('extensions', 'paypal')->display(); }
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'); }
public function addSection($name, $section) { Sobi::Trigger('addSection', 'SPAdmSiteMenu', array($name, $section)); if ($name == 'AMN.APPS_HEAD' || $name == 'AMN.APPS_SECTION_HEAD') { $p = SPFactory::Controller('extensions', true); $links = $p->appsMenu(); if (is_array($links)) { $section = array_merge($section, $links); } } elseif ($name == 'AMN.APPS_SECTION_TPL' && Sobi::Section() && Sobi::Cfg('section.template', SPC::DEFAULT_TEMPLATE)) { $p = SPFactory::Controller('template', true); $this->_custom[$name]['after'][] = $p->getTemplateTree(Sobi::Cfg('section.template', SPC::DEFAULT_TEMPLATE)); } $this->_sections[$name] =& $section; }
public function __construct() { $cfg = SPFactory::config(); $this->setSender(array($cfg->get('mail.mailfrom'), $cfg->get('mail.fromname'))); switch ($cfg->get('mail.mailer')) { case 'smtp': $this->useSMTP((int) ($cfg->get('mail.smtpauth') != 0), $cfg->get('mail.smtphost'), $cfg->get('mail.smtpuser'), $cfg->get('mail.smtppass'), $cfg->get('mail.smtpsecure'), $cfg->get('mail.smtpport')); break; case 'sendmail': $this->IsSendmail(); break; default: $this->IsMail(); break; } }
protected function save() { if (!SPFactory::mainframe()->checkToken()) { Sobi::Error('Token', SPLang::e('UNAUTHORIZED_ACCESS_TASK', SPRequest::task()), SPC::ERROR, 403, __LINE__, __FILE__); } $data = SPRequest::string('bankdata', null, true); $data = array('key' => 'bankdata', 'value' => $data, 'type' => 'application', 'id' => Sobi::Section(), 'section' => Sobi::Section()); try { 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 js() { $lang = SPLang::jsLang(true); if (count($lang)) { foreach ($lang as $term => $text) { unset($lang[$term]); $term = str_replace('SP.JS_', null, $term); $lang[$term] = $text; } } if (!SPRequest::int('deb')) { SPFactory::mainframe()->cleanBuffer(); header('Content-type: text/javascript'); } echo 'SobiPro.setLang( ' . json_encode($lang) . ' );'; exit; }
/** * This function have to add own string into the given array * Basically: $methods[ $this->id ] = "Some String To Output"; * Optionally the value can be also SobiPro Arr2XML array. * Check the documentation for more information * @param array $methods * @param SPEntry $entry * @param array $payment * @param bool $message * @return void */ public function PaymentMethodView(&$methods, $entry, &$payment, $message = false) { $data = SPFactory::registry()->loadDBSection('paypal_' . Sobi::Section())->get('paypal_' . Sobi::Section()); if (!count($data)) { $data = SPFactory::registry()->loadDBSection('paypal')->get('paypal'); } $cfg = SPLoader::loadIniFile('etc.paypal'); $rp = $cfg['general']['replace']; $to = $cfg['general']['replace'] == ',' ? '.' : ','; $amount = str_replace($rp, $to, $payment['summary']['sum_brutto']); $values = array('entry' => $entry, 'amount' => preg_replace('/[^0-9\\.,]/', null, $amount), 'ppurl' => SPLang::replacePlaceHolders($data['ppurl']['value'], $entry), 'ppemail' => SPLang::replacePlaceHolders($data['ppemail']['value'], $entry), 'pprurl' => SPLang::replacePlaceHolders($data['pprurl']['value'], $entry), 'ppcc' => SPLang::replacePlaceHolders($data['ppcc']['value'], $entry)); $expl = SPLang::replacePlaceHolders(SPLang::getValue('ppexpl', 'plugin', Sobi::Section()), $values); $subject = SPLang::replacePlaceHolders(SPLang::getValue('ppsubject', 'plugin', Sobi::Section()), $values); $values['expl'] = $expl; $values['subject'] = $subject; $values['ip'] = SPRequest::ip('REMOTE_ADDR', 0, 'SERVER'); $methods[$this->id] = array('content' => $message ? $this->raw($cfg, $values) : $this->content($cfg, $values), 'title' => Sobi::Txt('APP.PPP.PAY_TITLE')); }
public function validate() { $type = $this->type == 'SobiProApp' ? 'application' : $this->type; $schemaDef = SPLoader::path('lib.services.installers.schemas.' . $type, 'front', false, 'xsd'); if (!SPFs::exists($schemaDef) || time() - filemtime($schemaDef) > 60 * 60 * 24 * 7) { $connection = SPFactory::Instance('services.remote'); $def = "https://xml.sigsiu.net/SobiPro/{$type}.xsd"; $connection->setOptions(array('url' => $def, 'connecttimeout' => 10, 'header' => false, 'returntransfer' => true, 'ssl_verifypeer' => false, 'ssl_verifyhost' => 2)); $schema =& SPFactory::Instance('base.fs.file', SPLoader::path('lib.services.installers.schemas.' . $type, 'front', false, 'xsd')); $file = $connection->exec(); if (!strlen($file)) { throw new SPException(SPLang::e('CANNOT_ACCESS_SCHEMA_DEF', $def)); } $schema->content($file); $schema->save(); $schemaDef = $schema->filename(); } if (!$this->definition->schemaValidate($schemaDef)) { throw new SPException(SPLang::e('CANNOT_VALIDATE_SCHEMA_DEF_AT', str_replace(SOBI_ROOT . DS, null, $this->xmlFile), $def)); } }
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(); }
/** * legacy function * @deprecated * @param string $tooltip * @param string $title * @param int $width * @param string $image * @param string $text * @param string $href * @param bool $link * @param string $position * @return string */ public static function toolTip($tooltip, $title = null, $image = null, $width = null, $text = null, $href = null, $target = '_blank') { $class = SPFactory::config()->key('html.tooltip_class', 'editlinktip hasTip'); while (strstr($text, "\\'")) { $text = stripcslashes($text); } while (strstr($text, "\\'")) { $text = stripcslashes($text); } while (strstr($title, "\\'")) { $title = stripcslashes($title); } if (!$text || $image) { $tip = "<img src=\"{$image}\" alt=\"{$title}\"/>"; $tip = "<span class=\"{$class}\" title=\"{$title}::{$tooltip}\">{$tip}</span>"; } else { $tip = "<span class=\"{$class}\" title=\"{$title}::{$tooltip}\">{$text}</span>"; } if ($href) { $tip = "<a href=\"{$href}\" target=\"{$target}\">{$tip}</a>"; } return $tip; }
/** */ public function execute() { /* parent class executes the plugins */ SPRequest::set('task', $this->_type . '.' . $this->_task); switch ($this->_task) { case 'front': $this->getSections(); /** @var $view SPAdmPanelView */ $view = SPFactory::View('front'); /* load template config */ // $this->tplCfg( 'front' ); // $view->setConfig( $this->_tCfg, 'general' ); $view->determineTemplate('front', SPC::DEFAULT_TEMPLATE); $view->assign($this->_sections, 'sections'); $view->display(); break; default: /* case parents or plugin didn't registered this task, it was an error */ if (!parent::execute()) { Sobi::Error($this->name(), SPLang::e('SUCH_TASK_NOT_FOUND', SPRequest::task()), SPC::NOTICE, 404, __LINE__, __FILE__); } break; } }
public function connect() { if ($this->definition instanceof DOMDocument && $this->xGetString('url')) { $connection = SPFactory::Instance('services.remote'); $ssl = $connection->certificate($this->xGetString('url')); if (isset($ssl['err'])) { throw new SPException($ssl['msg']); } if ($ssl['serialNumber'] != $this->xGetString('certificate/serialnumber')) { throw new SPException(SPLang::e('SSL validation error: stored serial number is %s but the serial number for the repository at %s has the number %s.', $this->xGetString('certificate/serialnumber'), $this->xGetString('url'), $ssl['serialNumber'])); } // for some reason on some servers the hash is being indeed modified // although it has been correctly transferred // it seems that it is depend on the protocol used (TSL/SSL) // if ( $ssl[ 'hash' ] != $this->xGetString( 'certificate/hash' ) ) { // throw new SPException( // SPLang::e( // 'SSL validation error: stored hash does not accords the hash for the repository at %s. %s != %s', // $this->xGetString( 'url' ), $ssl[ 'hash' ], $this->xGetString( 'certificate/hash' ) // ) // ); // } if ($ssl['validTo'] < time()) { throw new SPException(SPLang::e('SSL validation error: SSL certificate for %s is expired.', $this->xGetString('url'))); } $this->_server = SPFactory::Instance('services.soap', null, array('location' => $this->xGetString('url'))); } else { throw new SPException(SPLang::e('No repository definition file at %s or the definition is invalid.', $this->xmlFile)); } }
/** * @todo Enter description here... * * @param array $ordering * @param string $type * @param string $id * @param string $fname * @return string */ public static function tableHeader($ordering, $type, $id = 'sid', $fname = 'order', $def = 'position.asc') { $header = array(); $current = SPFactory::user()->getUserState($type . '.order', $fname, $def); if (strstr($current, '.')) { $current = explode('.', $current); $newDirect = trim($current[1]) == 'asc' ? 'desc' : 'asc'; $current = $current[0]; } $sid = SPRequest::sid() ? SPRequest::sid() : SPRequest::int('pid'); if (is_array($ordering) && count($ordering)) { foreach ($ordering as $order => $active) { $class = null; $params = array(); if (is_array($active)) { $params = $active; $active = $active['type']; } switch ($active) { case SP_TBL_HEAD_RAW: $header[$order] = Sobi::Txt($type . '.header_' . $order); break; case 1: case 3: case 4: case 5: case 6: $direction = 'asc'; $ico = null; $aico = null; if (isset($params['order'])) { $sortBy = $params['order']; } else { $sortBy = $order; } $label = Sobi::Txt($type . '.header_' . $order); $title = Sobi::Txt($type . '.header_order_by_' . $order); if ($sortBy == $current) { $class = "class=\"selected\""; $ico = Sobi::Cfg('list_icons.sort_direction_' . ($newDirect == 'asc' ? 'desc' : 'asc')); $ico = " <img src=\"{$ico}\"/> "; $direction = $newDirect; } if ($active == SP_TBL_HEAD_SORTABLE_FIELD) { $label = $params['label']; $title = Sobi::Txt('LIST.ORDER_BY_FIELD', array('field' => $label)); } if ($active == SP_TBL_HEAD_STATE) { SPLoader::loadClass('html.tooltip'); $msg = Sobi::Txt('LIST.MAKE_SELECTION'); $onclk = " onclick=\"if( document.adminForm.boxchecked.value == 0 ) { alert( '{$msg}' ); } else { submitbutton( '{$type}.publish' ); }\""; $url = "#"; $ai = Sobi::Cfg('list_icons.enable'); $s = Sobi::Txt('LIST.ENABLE_S', array('type' => Sobi::Txt(strtoupper($type)))); $a = Sobi::Txt($type . '.enable_expl'); $aico = SPTooltip::toolTip($a, $s, $ai); $aico = " <span class=\"headerStateIcons\"><a href=\"{$url}\"{$onclk}>{$aico}</a></span>"; $ui = Sobi::Cfg('list_icons.disable'); $s = Sobi::Txt('LIST.DISABLE_S', array('type' => Sobi::Txt(strtoupper($type)))); $a = Sobi::Txt($type . '.disable_expl'); $uico = SPTooltip::toolTip($a, $s, $ui); $onclk = " onclick=\"if( document.adminForm.boxchecked.value == 0 ) { alert( '{$msg}' ); } else { submitbutton( '{$type}.hide' ); }\""; $uico = " <span class=\"headerStateIcons\"><a href=\"{$url}\"{$onclk}>{$uico}</a></span>"; $aico .= $uico; } if ($active == SP_TBL_HEAD_APPROVAL) { SPLoader::loadClass('html.tooltip'); $msg = Sobi::Txt('LIST.MAKE_SELECTION'); $onclk = " onclick=\"if( document.adminForm.boxchecked.value == 0 ) { alert( '{$msg}' ); } else { submitbutton( '{$type}.approve' ); }\""; $url = "#"; $ai = Sobi::Cfg('list_icons.approve'); $s = Sobi::Txt($type . '.approve'); $a = Sobi::Txt($type . '.approve_expl'); $aico = SPTooltip::toolTip($a, $s, $ai); $aico = " <span class=\"headerAppIcons\"><a href=\"{$url}\"{$onclk}>{$aico}</a></span>"; $ui = Sobi::Cfg('list_icons.disable'); $s = Sobi::Txt($type . '.unapprove'); $a = Sobi::Txt($type . '.unapprove_expl'); $uico = SPTooltip::toolTip($a, $s, $ui); $onclk = " onclick=\"if( document.adminForm.boxchecked.value == 0 ) { alert( '{$msg}' ); } else { submitbutton( '{$type}.unapprove' ); }\""; $uico = " <span class=\"headerAppIcons\"><a href=\"{$url}\"{$onclk}>{$uico}</a></span>"; $aico .= $uico; } if ($active == SP_TBL_HEAD_ORDER) { SPLoader::loadClass('html.tooltip'); $url = "#"; $onclk = " onclick=\"SPReorder( '{$type}', {$sid} );\" "; $aico = " <span class=\"headerStateIcons\"><a href=\"{$url}\" title=\"{$a}\">{$aico}</a></span>"; $ui = Sobi::Cfg('list_icons.order'); $s = Sobi::Txt($type . '.save_order'); $a = Sobi::Txt($type . '.save_order_expl'); $uico = SPTooltip::toolTip($a, $s, $ui); $uico = " <span class=\"headerOrderIcon\"><a href=\"{$url}\"{$onclk}>{$uico}</a></span>"; $aico .= $uico; } $header[$order] = "<a {$class} href=\"javascript:SPOrdering( '{$sortBy}','{$direction}', '{$fname}', {$sid} );\" title=\"{$title}\">{$label}</a> {$ico}{$aico}"; break; case SP_TBL_HEAD_SELECTION_BOX: $name = Sobi::Txt($type . '.header_toggle'); $header[$order] = "<input type=\"checkbox\" name=\"toggle\" id=\"toggel_{$id}\" title=\"{$name}\" value=\"1\" onclick=\"SPCheckListElements('{$id}', this );\"/>"; break; } } } return $header; }
protected function message($data) { $class = isset($data['attributes']['class']) && $data['attributes']['class'] ? $data['attributes']['class'] : null; if ($this->istSet($data['attributes'], 'label')) { $type = isset($data['attributes']['type']) && $data['attributes']['type'] ? 'alert-' . $data['attributes']['type'] : null; $icon = null; if (isset($data['attributes']['icon']) && $data['attributes']['icon'] == 'true') { if ($type == 'alert-success') { $icon = 'icon-thumbs-up'; } elseif ($type == 'alert-info') { $icon = 'icon-lightbulb'; } else { $icon = 'icon-thumbs-down'; } $icon = "<i class=\"{$icon}\"></i> "; } $this->_out[] = "<div class=\"alert {$type} {$class}\">"; if (isset($data['attributes']['dismiss-button']) && $data['attributes']['dismiss-button'] == 'true') { $this->_out[] = '<button type="button" class="close" data-dismiss="alert">×</button>'; } $this->_out[] = $icon . $data['attributes']['label']; $this->_out[] = '</div>'; } else { $attr = array(); if (isset($data['attributes']['type'])) { unset($data['attributes']['type']); } if (count($data['attributes'])) { foreach ($data['attributes'] as $n => $v) { $attr[] = "{$n}=\"{$v}\""; } } $attr = implode(' ', $attr); $messages = SPFactory::message()->getMessages(); if (count($messages)) { foreach ($messages as $type => $texts) { if (count($texts)) { $this->_out[] = "<div class=\"alert alert-{$type} spSystemAlert\">"; $this->_out[] = '<button type="button" class="close" data-dismiss="alert">×</button>'; foreach ($texts as $text) { $this->_out[] = "<div>{$text}</div>"; } $this->_out[] = '</div>'; } } } $this->_out[] = "<div {$attr}></div>"; } }
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); }
/** * @param string $task */ public function setTask($task) { $this->_task = strlen($task) ? $task : $this->_defTask; $helpTask = $this->_type . '.' . $this->_task; Sobi::Trigger($this->name(), __FUNCTION__, array(&$this->_task)); SPFactory::registry()->set('task', $helpTask); }
/** * @return array */ public function struct() { $baseData = $this->getRaw(); $list = array(); $struct = array(); $order = SPFactory::cache()->getVar('order_' . $this->nid); if (!$order) { $order = SPFactory::db()->select('optValue', 'spdb_field_option', array('fid' => $this->id), 'optPos')->loadResultArray(); SPFactory::cache()->addVar($order, 'order_' . $this->nid); } if (is_array($baseData) && count($baseData)) { $this->cssClass = strlen($this->cssClass) ? $this->cssClass : 'spFieldsData'; $this->cssClass = $this->cssClass . ' ' . $this->nid; $this->cleanCss(); foreach ($order as $opt) { if (isset($baseData[$opt])) { $list[] = array('_tag' => 'li', '_value' => SPLang::clean($baseData[$opt]), '_class' => $opt); } } foreach ($this->options as $opt) { $struct[] = array('_complex' => 1, '_data' => $opt['label'], '_attributes' => array('selected' => isset($baseData[$opt['id']]) ? 'true' : 'false', 'id' => $opt['id'], 'position' => $opt['position'])); } $data = array('ul' => array('_complex' => 1, '_data' => $list, '_attributes' => array('class' => $this->cssClass))); } if (count($list)) { return array('_complex' => 1, '_data' => $data, '_attributes' => array('lang' => $this->lang, 'class' => $this->cssClass), '_options' => $struct); } }
protected function loadSection() { $sections = array(); $sectionsOutput = array(); try { $sections = SPFactory::db()->select('*', 'spdb_object', array('oType' => 'section'), 'id')->loadObjectList(); } catch (SPException $x) { Sobi::Error($this->name(), $x->getMessage(), SPC::ERROR, 500, __LINE__, __FILE__); } if (count($sections)) { $sectionsOutput[] = Sobi::Txt('SOBI_SELECT_SECTION'); foreach ($sections as $section) { if (Sobi::Can('section', 'access', 'valid', $section->id)) { $s = new SPSection(); $s->extend($section); $sectionsOutput[$s->get('id')] = $s->get('name'); } } } $params = array('id' => 'SobiSection', 'class' => 'required'); return SPHtml_Input::select('section', $sectionsOutput, self::$section, false, $params); }