Beispiel #1
0
 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));
 }
 /**
  * @param DOMNodeList $requirements
  * @throws SPException
  * @return bool
  */
 public function check($requirements)
 {
     if ($requirements && $requirements instanceof DOMNodeList) {
         for ($i = 0; $i < $requirements->length; $i++) {
             $reqVersion = null;
             if ($requirements->item($i)->attributes->getNamedItem('version') && $requirements->item($i)->attributes->getNamedItem('version')->nodeValue) {
                 $reqVersion = $this->parseVer($requirements->item($i)->attributes->getNamedItem('version')->nodeValue);
             }
             switch ($requirements->item($i)->nodeName) {
                 case 'core':
                     if (!$this->compareVersion($reqVersion, SPFactory::CmsHelper()->myVersion())) {
                         throw new SPException(SPLang::e('CANNOT_INSTALL_EXT_CORE', implode('.', $reqVersion), implode('.', SPFactory::CmsHelper()->myVersion())));
                     }
                     break;
                 case 'cms':
                     $cms = SPFactory::CmsHelper()->cmsVersion($requirements->item($i)->nodeValue);
                     if (!is_array($cms)) {
                         throw new SPException(SPLang::e('CANNOT_INSTALL_EXT_REQU_CMS', $requirements->item($i)->nodeValue, implode('.', $reqVersion), $cms));
                     }
                     if (!$this->compareVersion($reqVersion, $cms)) {
                         throw new SPException(SPLang::e('CANNOT_INSTALL_EXT_REQ', $requirements->item($i)->nodeValue, implode('.', $reqVersion), implode('.', SPFactory::CmsHelper()->cmsVersion())));
                     }
                     break;
                 case 'field':
                 case 'plugin':
                 case 'application':
                     $version = $this->extension($requirements->item($i)->nodeValue, $requirements->item($i)->nodeName);
                     if (!$version) {
                         // "Cannot install extension. This extension requires %s %s version >= %s, But this %s is not installed."
                         if ($reqVersion) {
                             throw new SPException(SPLang::e('CANNOT_INSTALL_EXT_PLG', $requirements->item($i)->nodeName, $requirements->item($i)->nodeValue, implode('.', $reqVersion), $requirements->item($i)->nodeName));
                         } else {
                             throw new SPException(SPLang::e('CANNOT_INSTALL_EXT_PLG_NO_VERSION', $requirements->item($i)->nodeName, $requirements->item($i)->nodeValue, $requirements->item($i)->nodeName));
                         }
                     }
                     if (isset($reqVersion) && !$this->compareVersion($reqVersion, $version)) {
                         throw new SPException(SPLang::e('CANNOT_INSTALL_EXT_FIELD', $requirements->item($i)->nodeName, $requirements->item($i)->nodeValue, implode('.', $reqVersion), implode('.', $version)));
                     }
                     break;
                 case 'php':
                     $version = $this->phpReq($requirements->item($i));
                     $type = 'PHP';
                     if ($requirements->item($i)->attributes->getNamedItem('type') && $requirements->item($i)->attributes->getNamedItem('type')->nodeValue) {
                         $type = $requirements->item($i)->attributes->getNamedItem('type');
                     }
                     if (strlen($version) && isset($reqVersion)) {
                         if (isset($reqVersion) && !$this->compareVersion($reqVersion, $version)) {
                             throw new SPException(SPLang::e('CANNOT_INSTALL_EXT_FIELD', $type, $requirements->item($i)->nodeValue, implode('.', $reqVersion), implode('.', $version)));
                         }
                     } elseif ($version == false) {
                         throw new SPException(SPLang::e('CANNOT_INSTALL_EXT_MISSING', $type, $requirements->item($i)->nodeValue, implode('.', $reqVersion), implode('.', $version)));
                     }
                     break;
             }
         }
     }
 }
Beispiel #3
0
 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 download()
 {
     //		$file = SPLoader::path( 'tmp.info', 'front', false, 'txt' );
     $cont = null;
     $settings = array();
     $settings['SobiPro'] = array('Version' => SPFactory::CmsHelper()->myVersion(true), 'Version_Num' => implode('.', SPFactory::CmsHelper()->myVersion()));
     $file = SPLoader::path('tmp.info', 'front', false, 'txt');
     //		if ( SPFs::exists( $file ) ) {
     //			$cont = SPFs::read( $file );
     //		}
     //		$cont = explode( "\n", $cont );
     //		if ( count( $cont ) ) {
     //			foreach ( $cont as $line ) {
     //				if ( strstr( $line, '=' ) ) {
     //					$line = explode( "=", $line );
     //					$line[ 1 ] = explode( ';', $line[ 1 ] );
     //					$settings[ $line[ 0 ] ] = array( 'key' => $line[ 0 ], 'response' => $line[ 1 ][ 0 ], 'status' => $line[ 1 ][ 1 ] );
     //				}
     //			}
     //		}
     $this->prepareStoredData($settings);
     $settings['env'] = array('PHP_OS' => PHP_OS, 'php_uname' => php_uname(), 'PHP_VERSION_ID' => PHP_VERSION_ID);
     $settings['ftp'] = $this->ftp();
     $settings['curl'] = $this->curlFull();
     $settings['exec']['response'] = $this->execResp();
     $settings['SOBI_SETTINGS'] = SPFactory::config()->getSettings();
     $c = SPFactory::db()->select('*', 'spdb_config')->loadObjectList();
     $sections = SPFactory::db()->select(array('nid', 'id'), 'spdb_object', array('oType' => 'section'))->loadAssocList('id');
     $as = array();
     foreach ($c as $key) {
         if ($key->section == 0 || !isset($sections[$key->section])) {
             continue;
         }
         $key->section = $sections[$key->section]['nid'];
         if (!isset($as[$key->section])) {
             $as[$key->section] = array();
         }
         if (!isset($as[$key->section][$key->cSection])) {
             $as[$key->section][$key->cSection] = array();
         }
         $_c = explode('_', $key->sKey);
         if ($_c[count($_c) - 1] == 'array') {
             $key->sValue = SPConfig::unserialize($key->sValue);
         }
         $as[$key->section][$key->cSection][$key->sKey] = $key->sValue;
     }
     $settings['SOBI_SETTINGS']['sections'] = $as;
     $apps = SPFactory::db()->select('*', 'spdb_plugins')->loadObjectList();
     foreach ($apps as $app) {
         $settings['Apps'][$app->pid] = get_object_vars($app);
     }
     $settings['SOBI_SETTINGS']['mail']['smtphost'] = $settings['SOBI_SETTINGS']['mail']['smtphost'] ? 'SET' : 0;
     $settings['SOBI_SETTINGS']['mail']['smtpuser'] = $settings['SOBI_SETTINGS']['mail']['smtpuser'] ? 'SET' : 0;
     $settings['SOBI_SETTINGS']['mail']['smtppass'] = $settings['SOBI_SETTINGS']['mail']['smtppass'] ? 'SET' : 0;
     $php = ini_get_all();
     unset($php['extension_dir']);
     unset($php['include_path']);
     unset($php['mysql.default_user']);
     unset($php['mysql.default_password']);
     unset($php['mysqli.default_pw']);
     unset($php['mysqli.default_user']);
     unset($php['open_basedir']);
     unset($php['pdo_mysql.default_socket']);
     unset($php['sendmail_path']);
     unset($php['session.name']);
     unset($php['session.save_path']);
     unset($php['soap.wsdl_cache_dir']);
     unset($php['upload_tmp_dir']);
     unset($php['doc_root']);
     unset($php['docref_ext']);
     unset($php['docref_root']);
     unset($php['mysql.default_socket']);
     $settings['PHP_SETTINGS'] = $php;
     $php = get_loaded_extensions();
     $settings['PHP_EXT'] = $php;
     $out = SPFactory::Instance('types.array');
     $data = $out->toXML($settings, 'settings');
     $data = str_replace(array(SOBI_ROOT, '></'), array('REMOVED', '>0</'), $data);
     $f = SPLang::nid($settings['SOBI_SETTINGS']['general']['site_name'] . '-' . date(DATE_RFC822));
     SPFactory::mainframe()->cleanBuffer();
     header('Cache-Control: no-cache, must-revalidate');
     header('Expires: Sat, 26 Jul 1997 05:00:00 GMT');
     header("Content-type: application/xml");
     header("Content-Disposition: attachment; filename=\"sobipro_system_{$f}.xml\"");
     header('Content-Length: ' . strlen($data));
     ob_clean();
     flush();
     echo $data;
     exit;
 }
Beispiel #5
0
 /**
  */
 public function execute()
 {
     switch ($this->_task) {
         case 'panel':
             $this->getSections();
             /** @var $view SPAdmPanelView */
             $view = SPFactory::View('front', true)->assign($acl, 'acl')->assign($this->_sections, 'sections')->assign($this->getNews(), 'news')->assign(Sobi::GetUserState('sections.order', 'order', 'name.asc'), 'order')->assign(SPFactory::CmsHelper()->myVersion(true), 'version')->assign(Sobi::Cfg('cpanel.show_entries', false), 'show-entries')->assign($this->getState(), 'system-state');
             if (Sobi::Cfg('cpanel.show_entries', false)) {
                 $view->assign($this->getEntries(), 'entries');
             }
             SPLang::load('com_sobipro.about');
             $view->determineTemplate('front', 'cpanel');
             Sobi::Trigger('Panel', 'View', array(&$view));
             $view->display();
             break;
         default:
             /* case 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;
     }
 }
Beispiel #6
0
 public function templatesList($params = null)
 {
     $cms = SPFactory::CmsHelper()->templatesPath();
     $dir = new SPDirectoryIterator(SPLoader::dirPath('usr.templates'));
     $templates = array();
     foreach ($dir as $file) {
         if ($file->isDir()) {
             if ($file->isDot() || in_array($file->getFilename(), array('common', 'front'))) {
                 continue;
             }
             if (SPFs::exists($file->getPathname() . DS . 'template.xml') && ($tname = $this->templateName($file->getPathname() . DS . 'template.xml'))) {
                 $templates[$file->getFilename()] = $tname;
             } else {
                 $templates[$file->getFilename()] = $file->getFilename();
             }
         }
     }
     if (is_array($cms) && isset($cms['name']) && isset($cms['data']) && is_array($cms['data']) && count($cms['data'])) {
         $templates[$cms['name']] = array();
         foreach ($cms['data'] as $name => $path) {
             $templates[$cms['name']][$name] = array();
             $dir = new SPDirectoryIterator($path);
             foreach ($dir as $file) {
                 if ($file->isDot()) {
                     continue;
                 }
                 $fpath = 'cms:' . str_replace(SOBI_ROOT . DS, null, $file->getPathname());
                 $fpath = str_replace(DS, '.', $fpath);
                 if (SPFs::exists($file->getPathname() . DS . 'template.xml') && ($tname = $this->templateName($file->getPathname() . DS . 'template.xml'))) {
                     $templates[$cms['name']][$name][$fpath] = $tname;
                 } else {
                     $templates[$cms['name']][$name][$fpath] = $file->getFilename();
                 }
             }
         }
     }
     if ($params) {
         $p = array('select', 'spcfg_' . $params[1], $templates, Sobi::Cfg('section.template', SPC::DEFAULT_TEMPLATE), false, $params[3]);
     } else {
         $p = $templates;
     }
     return $p;
 }
Beispiel #7
0
 protected function listTemplates($tpl = null, $cmsOv = true)
 {
     SPFactory::header()->addJsFile('dtree')->addCssFile('dtree', true);
     SPLoader::loadClass('base.fs.directory_iterator');
     $ls = Sobi::Cfg('live_site') . 'media/sobipro/tree';
     $nodes = null;
     $count = 0;
     $tpl = Sobi::FixPath($tpl ? $tpl : SPLoader::dirPath('usr.templates'));
     if (Sobi::Section()) {
         $realName = Sobi::Txt('TP.INFO');
         $iTask = Sobi::Url(array('task' => 'template.info', 'template' => basename($tpl), 'sid' => Sobi::Section()));
         $nodes .= "spTpl.add( -123, 0,'{$realName}','{$iTask}', '', '', '{$ls}/info.png' );\n";
         if (file_exists("{$tpl}/config.xml")) {
             $realName = Sobi::Txt('TP.SETTINGS');
             $iTask = Sobi::Url(array('task' => 'template.settings', 'template' => basename($tpl), 'sid' => Sobi::Section()));
             $nodes .= "spTpl.add( -120, 0,'{$realName}','{$iTask}', '', '', '{$ls}/settings.png' );\n";
         }
     }
     $this->travelTpl(new SPDirectoryIterator($tpl), $nodes, 0, $count);
     if ($cmsOv) {
         $cms = SPFactory::CmsHelper()->templatesPath();
         if (is_array($cms) && isset($cms['name']) && isset($cms['data']) && is_array($cms['data']) && count($cms['data'])) {
             $count++;
             if (isset($cms['icon'])) {
                 $nodes .= "spTpl.add( {$count}, 0, '{$cms['name']}', '', '', '', '{$cms['icon']}', '{$cms['icon']}' );\n";
             } else {
                 $nodes .= "spTpl.add( {$count}, 0, '{$cms['name']}' );\n";
             }
             $current = $count;
             foreach ($cms['data'] as $name => $path) {
                 $count++;
                 $nodes .= "spTpl.add( {$count}, {$current},'{$name}' );\n";
                 $this->travelTpl(new SPDirectoryIterator($path), $nodes, $count, $count, true);
             }
         }
     }
     if (Sobi::Section()) {
         $file = SPLoader::path('usr.templates.' . Sobi::Cfg('section.template', SPC::DEFAULT_TEMPLATE) . '.template', 'front', true, 'xml');
         $def = new DOMDocument();
         $def->load($file);
         $xdef = new DOMXPath($def);
         $t = $xdef->query('/template/name')->item(0)->nodeValue;
     } else {
         $t = Sobi::Txt('GB.TEMPLATES');
     }
     SPFactory::header()->addJsCode("\n\t\t\ticons = {\n\t\t\t\t\t\troot : '{$ls}/base.gif',\n\t\t\t\t\t\tfolder : '{$ls}/folder.gif',\n\t\t\t\t\t\tfolderOpen : '{$ls}/folderopen.gif',\n\t\t\t\t\t\tnode : '{$ls}/page.gif',\n\t\t\t\t\t\tempty : '{$ls}/empty.gif',\n\t\t\t\t\t\tline : '{$ls}/line.gif',\n\t\t\t\t\t\tjoin : '{$ls}/join.gif',\n\t\t\t\t\t\tjoinBottom : '{$ls}/joinbottom.gif',\n\t\t\t\t\t\tplus : '{$ls}/plus.gif',\n\t\t\t\t\t\tplusBottom : '{$ls}/plusbottom.gif',\n\t\t\t\t\t\tminus : '{$ls}/minus.gif',\n\t\t\t\t\t\tminusBottom\t: '{$ls}/minusbottom.gif',\n\t\t\t\t\t\tnlPlus : '{$ls}/nolines_plus.gif',\n\t\t\t\t\t\tnlMinus : '{$ls}/nolines_minus.gif'\n\t\t\t};\n\t\t\tvar spTpl = new dTree( 'spTpl', icons );\t\n\n\t\t\tSobiPro.jQuery( document ).ready( function ()\n\t\t\t{\n\t\t\t\tspTpl.add(0, -1, '{$t}' );\n\n\t\t\t\t{$nodes} \n\n\t\t\t\ttry { document.getElementById( 'spTpl' ).innerHTML = spTpl } catch( e ) {}\n\t\t\t} );\n\t\t");
     /** for some reason jQuery is not able to add the tree  */
     return "<div id=\"spTpl\"></div>";
 }
Beispiel #8
0
    /**
     */
    private function editForm()
    {
        $sid = SPRequest::int('pid');
        $sid = $sid ? $sid : SPRequest::sid();
        $view = SPFactory::View('entry', true);
        $this->checkTranslation();
        /* if adding new */
        if (!$this->_model) {
            $this->setModel(SPLoader::loadModel('entry'));
        }
        $this->_model->formatDatesToEdit();
        $id = $this->_model->get('id');
        if (!$id) {
            $this->_model->set('state', 1);
            $this->_model->set('approved', 1);
        } else {
            $view->assign($view->languages(), 'languages-list');
        }
        $this->_model->loadFields(Sobi::Reg('current_section'), true);
        $this->_model->formatDatesToEdit();
        if ($this->_model->isCheckedOut()) {
            SPFactory::message()->error(Sobi::Txt('EN.IS_CHECKED_OUT', $this->_model->get('name')), false);
        } else {
            /* check out the model */
            $this->_model->checkOut();
        }
        /* get fields for this section */
        /* @var SPEntry $this ->_model */
        $fields = $this->_model->get('fields');
        if (!count($fields)) {
            throw new SPException(SPLang::e('CANNOT_GET_FIELDS_IN_SECTION', Sobi::Reg('current_section')));
        }
        $revisionChange = false;
        $rev = SPRequest::cmd('revision');
        $revisionsDelta = array();
        if ($rev) {
            $revision = SPFactory::message()->getRevision(SPRequest::cmd('revision'));
            if (isset($revision['changes']) && count($revision['changes'])) {
                SPFactory::message()->warning(Sobi::Txt('HISTORY_REVISION_WARNING', $revision['changedAt']), false);
                foreach ($fields as $i => $field) {
                    if ($field->get('enabled') && $field->enabled('form')) {
                        if (isset($revision['changes']['fields'][$field->get('nid')])) {
                            $revisionData = $revision['changes']['fields'][$field->get('nid')];
                        } else {
                            $revisionData = null;
                        }
                        $currentData = $field->getRaw();
                        if (is_array($revisionData) && !is_array($currentData)) {
                            try {
                                $currentData = SPConfig::unserialize($currentData);
                            } catch (SPException $x) {
                            }
                        }
                        if ($revisionData || $currentData) {
                            if (md5(serialize($currentData)) != md5(serialize($revisionData))) {
                                $field->revisionChanged()->setRawData($revisionData);
                            }
                        }
                        $fields[$i] = $field;
                    }
                }
                unset($revision['changes']['fields']);
                foreach ($revision['changes'] as $attr => $value) {
                    if ($value != $this->_model->get($attr)) {
                        $revisionsDelta[$attr] = $value;
                        $this->_model->setRevData($attr, $value);
                    }
                }
                $revisionChange = true;
            } else {
                SPFactory::message()->error(Sobi::Txt('HISTORY_REVISION_NOT_FOUND'), false)->setSystemMessage();
            }
        }
        $f = array();
        foreach ($fields as $field) {
            if ($field->get('enabled') && $field->enabled('form')) {
                $f[] = $field;
            }
        }
        /* create the validation script to check if required fields are filled in and the filters, if any, match */
        $this->createValidationScript($fields);
        $view->assign($this->_model, 'entry');
        /* get the categories */
        $cats = $this->_model->getCategories(true);
        if (count($cats)) {
            $tCats = array();
            foreach ($cats as $cid) {
                /* ROTFL ... damn I like arrays ;-) */
                $tCats2 = SPFactory::config()->getParentPath($cid, true);
                if (is_array($tCats2) && count($tCats2)) {
                    $tCats[] = implode(Sobi::Cfg('string.path_separator'), $tCats2);
                }
            }
            if (count($tCats)) {
                $view->assign(implode("\n", $tCats), 'parent_path');
            }
            $view->assign(implode(", ", $cats), 'parents');
        } elseif ($this->_model->get('valid')) {
            $parent = $sid == Sobi::Reg('current_section') ? 0 : $sid;
            if ($parent) {
                $view->assign(implode(Sobi::Cfg('string.path_separator', ' > '), SPFactory::config()->getParentPath($parent, true)), 'parent_path');
            }
            $view->assign($parent, 'parents');
        } else {
            $n = null;
            $view->assign($n, 'parents');
            $view->assign($n, 'parent_path');
        }
        $history = array();
        $messages = SPFactory::message()->getHistory($id);
        if (count($messages)) {
            foreach ($messages as $message) {
                $message['change'] = Sobi::Txt('HISTORY_CHANGE_TYPE_' . str_replace('-', '_', strtoupper($message['change'])));
                $message['site'] = Sobi::Txt('HISTORY_CHANGE_AREA_' . strtoupper($message['site']));
                if (strlen($message['reason'])) {
                    $message['status'] = 1;
                } else {
                    $message['status'] = 0;
                }
                $history[] = $message;
            }
        }
        $versioningAdminBehaviour = Sobi::Cfg('entry.versioningAdminBehaviour', 1);
        if ($versioningAdminBehaviour || !Sobi::Cfg('entry.versioning', true)) {
            SPFactory::header()->addJsCode('
				SobiPro.jQuery( document ).ready( function () { SobiPro.jQuery( "[rel=\'entry.saveWithRevision\']" ).parent().css( "display", "none" ); } );
			');
        }
        $view->assign($this->_task, 'task')->assign($f, 'fields')->assign($id, 'id')->assign($history, 'history')->assign($revisionChange, 'revision-change')->assign($revisionsDelta, 'revision')->assign($versioningAdminBehaviour, 'history-behaviour')->assign(SPFactory::CmsHelper()->userSelect('entry.owner', $this->_model->get('owner') ? $this->_model->get('owner') : ($this->_model->get('id') ? 0 : Sobi::My('id')), true), 'owner')->assign(Sobi::Reg('current_section'), 'sid')->determineTemplate('entry', 'edit')->addHidden($rev, 'revision')->addHidden($sid, 'pid');
        $view->display();
    }
Beispiel #9
0
 private function install($file = null)
 {
     $arch = SPFactory::Instance('base.fs.archive');
     $ajax = strlen(SPRequest::cmd('ident', null, 'post'));
     if (!$file && SPRequest::string('root')) {
         $file = str_replace('.xml', null, SPRequest::string('root'));
         $file = SPLoader::path('tmp.install.' . $file, 'front', true, 'xml');
     }
     if (!$file) {
         $ident = SPRequest::cmd('ident', null, 'post');
         $data = SPRequest::file($ident);
         $name = str_replace(array('.' . SPFs::getExt($data['name']), '.'), null, $data['name']);
         $path = SPLoader::dirPath('tmp.install.' . $name, 'front', false);
         $c = 0;
         while (SPFs::exists($path)) {
             $path = SPLoader::dirPath('tmp.install.' . $name . '_' . ++$c, 'front', false);
         }
         /*
          * temp directory - will be removed later but it needs to be writable for apache and Joomla! fs (FTP mode)
          */
         try {
             if (Sobi::Cfg('ftp_mode')) {
                 SPFs::mkdir($path, 0777);
             } else {
                 SPFs::mkdir($path);
             }
         } catch (SPException $x) {
             return $this->ajaxResponse($ajax, $x->getMessage(), false, SPC::ERROR_MSG);
         }
         $file = $path . '/' . $data['name'];
         try {
             $arch->upload($data['tmp_name'], $file);
         } catch (SPException $x) {
             return $this->ajaxResponse($ajax, $x->getMessage(), false, SPC::ERROR_MSG);
         }
     } elseif (SPRequest::string('root') && $file) {
         $path = dirname($file);
     } else {
         $arch->setFile($file);
         $name = str_replace(array('.' . SPFs::getExt($file), '.'), null, basename($file));
         $path = SPLoader::dirPath('tmp.install.' . $name, 'front', false);
         $c = 0;
         while (SPFs::exists($path)) {
             $path = SPLoader::dirPath('tmp.install.' . $name . '_' . ++$c, 'front', false);
         }
         /*
          * temp directory - will be removed later but it needs to  writable for apache and Joomla! fs (FTP mode)
          */
         try {
             if (Sobi::Cfg('ftp_mode')) {
                 SPFs::mkdir($path, 0777);
             } else {
                 SPFs::mkdir($path);
             }
         } catch (SPException $x) {
             return $this->ajaxResponse($ajax, $x->getMessage(), false, SPC::ERROR_MSG);
         }
     }
     if ($path) {
         if (!SPRequest::string('root')) {
             if (!$arch->extract($path)) {
                 return $this->ajaxResponse($ajax, SPLang::e('CANNOT_EXTRACT_ARCHIVE', basename($file), $path), false, SPC::ERROR_MSG);
             }
         }
         $dir =& SPFactory::Instance('base.fs.directory', $path);
         $xml = array_keys($dir->searchFile('.xml', false, 2));
         if (!count($xml)) {
             return $this->ajaxResponse($ajax, SPLang::e('NO_INSTALL_FILE_IN_PACKAGE'), false, SPC::ERROR_MSG);
         }
         $definition = $this->searchInstallFile($xml);
         if (!$definition) {
             if (SPFactory::CmsHelper()->installerFile($xml)) {
                 try {
                     $message = SPFactory::CmsHelper()->install($xml, $path);
                     return $this->ajaxResponse($ajax, $message['msg'], $ajax, $message['msgtype']);
                 } catch (SPException $x) {
                     return $this->ajaxResponse($ajax, $x->getMessage(), $ajax, SPC::ERROR_MSG);
                 }
             } else {
                 return $this->ajaxResponse($ajax, SPLang::e('NO_INSTALL_FILE_IN_PACKAGE'), false, SPC::ERROR_MSG);
             }
         }
         /** @var $installer SPInstaller */
         $installer =& SPFactory::Instance('services.installers.' . trim(strtolower($definition->documentElement->tagName)), $xml[0], trim($definition->documentElement->tagName));
         try {
             $installer->validate();
             $msg = $installer->install();
             return $this->ajaxResponse($ajax, $msg, true, SPC::SUCCESS_MSG);
         } catch (SPException $x) {
             return $this->ajaxResponse($ajax, $x->getMessage(), false, SPC::ERROR_MSG);
         }
     } else {
         return $this->ajaxResponse($ajax, SPLang::e('NO_FILE_HAS_BEEN_UPLOADED'), false, SPC::ERROR_MSG);
     }
 }
Beispiel #10
0
 public function languages()
 {
     $subMenu = array();
     if (Sobi::Cfg('lang.multimode', false)) {
         $availableLanguages = SPFactory::CmsHelper()->availableLanguages();
         $sectionLength = 30;
         if (count($availableLanguages)) {
             $sid = SPRequest::sid();
             if (!$sid) {
                 $sid = Sobi::Section();
             }
             $subMenu = array();
             $task = SPRequest::task();
             $url = array('sid' => $sid, 'task' => $task, 'sp-language' => null);
             if ($task == 'field.edit') {
                 $url = array('sid' => $sid, 'task' => $task, 'fid' => SPRequest::int('fid'), 'sp-language' => null);
             }
             foreach ($availableLanguages as $language) {
                 $url['sp-language'] = $language['tag'];
                 $subMenu[] = array('type' => 'url', 'task' => '', 'url' => $url, 'label' => strlen($language['name']) < $sectionLength ? $language['name'] : substr($language['name'], 0, $sectionLength - 3) . ' ...', 'icon' => 'file', 'element' => 'button', 'selected' => $language['tag'] == Sobi::Lang());
             }
         }
     }
     return $subMenu;
 }
Beispiel #11
0
 /**
  */
 private function editForm()
 {
     /* if adding new */
     if (!$this->_model || $this->_task == 'add') {
         $this->setModel(SPLoader::loadModel('category'));
     }
     $this->checkTranslation();
     $this->_model->formatDatesToEdit();
     $id = $this->_model->get('id');
     if (!$id) {
         $this->_model->set('state', 1);
         $this->_model->set('parent', SPRequest::sid());
     }
     if ($this->_model->isCheckedOut()) {
         SPFactory::message()->error(Sobi::Txt('CAT.IS_CHECKED_OUT'), false);
     } else {
         $this->_model->checkOut();
     }
     $view = SPFactory::View('category', true);
     $view->assign($this->_model, 'category')->assign($this->_task, 'task')->assign(SPFactory::CmsHelper()->userSelect('category.owner', $this->_model->get('owner') ? $this->_model->get('owner') : ($this->_model->get('id') ? 0 : Sobi::My('id')), true), 'owner')->assign($id, 'cid')->addHidden(Sobi::Section(), 'pid');
     Sobi::Trigger('Category', 'EditView', array(&$view));
     $view->display();
 }
Beispiel #12
0
 public function install()
 {
     $log = array();
     $type = strlen($this->xGetString('type')) ? $this->xGetString('type') : ($this->xGetString('fieldType') ? 'field' : null);
     $id = $this->xGetString('id');
     if ($this->installed($id, $type)) {
         SPFactory::db()->delete('spdb_plugins', array('pid' => $id, 'type' => $type));
     }
     Sobi::Trigger('Before', 'InstallPlugin', array($id));
     $requirements = $this->xGetChilds('requirements/*');
     if ($requirements && $requirements instanceof DOMNodeList) {
         $reqCheck =& SPFactory::Instance('services.installers.requirements');
         $reqCheck->check($requirements);
     }
     $permissions = $this->xGetChilds('permissions/*');
     if ($permissions && $permissions instanceof DOMNodeList) {
         $permsCtrl =& SPFactory::Instance('ctrl.adm.acl');
         for ($i = 0; $i < $permissions->length; $i++) {
             $perm = explode('.', $permissions->item($i)->nodeValue);
             $permsCtrl->addPermission($perm[0], $perm[1], $perm[2]);
             $log['permissions'][] = $permissions->item($i)->nodeValue;
         }
     }
     $actions = $this->xGetChilds('actions/*');
     if ($actions && $actions instanceof DOMNodeList) {
         $log['actions'] = $this->actions($actions, $id);
     }
     $dir = SPLoader::dirPath('etc.installed.' . $type . 's', 'front', false);
     if (!SPFs::exists($dir)) {
         SPFs::mkdir($dir);
         SPFs::mkdir("{$dir}/{$id}/backup");
     }
     $files = $this->xGetChilds('files');
     $date = str_replace(array(':', ' '), array('-', '_'), SPFactory::config()->date(time()));
     if ($files && $files instanceof DOMNodeList && $files->length) {
         $log['files'] = $this->files($files, $id, "{$dir}/{$id}/backup/{$date}");
         if (count($log['files'])) {
             foreach ($log['files'] as $i => $f) {
                 $log['files'][$i] = str_replace(SOBI_ROOT, null, $f);
             }
         }
     }
     $languages = $this->xGetChilds('language');
     if ($languages->length) {
         $langFiles = array();
         foreach ($languages as $language) {
             $folder = $language->attributes->getNamedItem('folder')->nodeValue;
             foreach ($language->childNodes as $file) {
                 $adm = false;
                 if (strstr($file->nodeName, '#')) {
                     continue;
                 }
                 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);
             }
         }
         $log['files']['created'] = array_merge($log['files']['created'], SPFactory::CmsHelper()->installLang($langFiles, false));
     }
     $sql = $this->xGetString('sql');
     if ($sql && SPFs::exists("{$this->root}/{$sql}")) {
         try {
             $log['sql'] = SPFactory::db()->loadFile("{$this->root}/{$sql}");
         } catch (SPException $x) {
             Sobi::Error('installer', SPLang::e('CANNOT_EXECUTE_QUERIES', $x->getMessage()), SPC::WARNING, 500, __LINE__, __FILE__);
             return false;
         }
     }
     if (!strlen($this->xGetString('type')) && strlen($this->xGetString('fieldType'))) {
         $log['field'] = $this->field();
     }
     $exec = $this->xGetString('exec');
     if ($exec && SPFs::exists("{$this->root}/{$exec}")) {
         include_once "{$this->root}/{$exec}";
     }
     $this->plugin($id, $type);
     $this->log($log);
     $this->definition->formatOutput = true;
     $this->definition->preserveWhiteSpace = false;
     $this->definition->normalizeDocument();
     $path = "{$dir}/{$id}.xml";
     $file = SPFactory::Instance('base.fs.file', $path);
     //		$file->content( $this->definition->saveXML() );
     // why the hell DOM cannot format it right. Try this
     $outXML = $this->definition->saveXML();
     $xml = new DOMDocument();
     $xml->preserveWhiteSpace = false;
     $xml->formatOutput = true;
     $xml->loadXML($outXML);
     $file->content($xml->saveXML());
     $file->save();
     switch ($type) {
         case 'SobiProApp':
             $type = 'plugin';
         default:
         case 'update':
         case 'plugin':
         case 'field':
             $t = Sobi::Txt('EX.' . strtoupper($type) . '_TYPE');
             break;
         case 'payment':
             $t = Sobi::Txt('EX.PAYMENT_METHOD_TYPE');
             break;
     }
     Sobi::Trigger('After', 'InstallPlugin', array($id));
     $dir =& SPFactory::Instance('base.fs.directory', SPLoader::dirPath('tmp.install'));
     $dir->deleteFiles();
     return Sobi::Txt('EX.EXTENSION_HAS_BEEN_INSTALLED', array('type' => $t, 'name' => $this->xGetString('name')));
 }
Beispiel #13
0
 protected function checkTranslation()
 {
     $lang = SPRequest::cmd('sp-language', false, 'get');
     if ($lang && $lang != Sobi::DefLang()) {
         $languages = SPFactory::CmsHelper()->availableLanguages();
         SPFactory::message()->info(Sobi::Txt('INFO_DIFFERENT_LANGUAGE', $this->_type, $languages[$lang]['name']), false);
     }
 }