Example #1
0
 private function initialise()
 {
     static $loaded = false;
     if (!$loaded || true) {
         defined('DS') || define('DS', DIRECTORY_SEPARATOR);
         require_once JPATH_SITE . '/components/com_sobipro/lib/sobi.php';
         Sobi::Initialise();
         if (SOBI_CMS == 'joomla3') {
             SPFactory::header()->initBase(true)->addJsFile(array('sobipro', 'jqnc', 'adm.sobipro', 'adm.jnmenu', 'jquery-base64'));
         } else {
             SPFactory::header()->initBase(true)->addJsFile(array('sobipro', 'jquery', 'adm.sobipro', 'adm.jnmenu', 'jquery-migrate', 'jquery-base64'))->addCSSCode('#toolbar-box { display: block }');
         }
         $loaded = true;
         SPLoader::loadClass('mlo.input');
         SPLoader::loadClass('models.datamodel');
         SPLoader::loadClass('models.dbobject');
         SPLoader::loadModel('section');
         $model = JModelLegacy::getInstance('MenusModelItem')->getItem();
         self::$mid = $model->id;
         if (isset($model->params['SobiProSettings']) && strlen($model->params['SobiProSettings'])) {
             $this->params = json_decode(base64_decode($model->params['SobiProSettings']));
         }
         $jsString = json_encode(array('component' => Sobi::Txt('SOBI_NATIVE_TASKS'), 'buttonLabel' => Sobi::Txt('SOBI_SELECT_FUNCTIONALITY')));
         SPFactory::header()->addJsCode("SpStrings = {$jsString}; ");
     }
 }
Example #2
0
 public function __construct($task = null, $sid = 0)
 {
     SPFactory::header()->addCSSFile('menu', true)->addJsFile('menu', true);
     $this->_task = $task ? $task : SPRequest::task();
     $this->_sid = $sid;
     SPFactory::registry()->set('adm_menu', $this);
 }
Example #3
0
 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();
     }
 }
Example #4
0
 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 . '") } );');
 }
Example #5
0
 /**
  * @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');
 }
Example #6
0
 /**
  * @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');
 }
Example #7
0
 /**
  */
 protected function view()
 {
     /* determine template package */
     $tplPackage = Sobi::Cfg('section.template', SPC::DEFAULT_TEMPLATE);
     Sobi::ReturnPoint();
     /* 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));
     $cInLine = $this->tKey($this->template, 'categories_in_line', Sobi::Cfg('list.categories_in_line', 2));
     $cLim = $this->tKey($this->template, 'categories_limit', -1);
     $entriesRecursive = $this->tKey($this->template, 'entries_recursive', Sobi::Cfg('list.entries_recursive', false));
     /* get the site to display */
     $site = SPRequest::int('site', 1);
     $eLimStart = ($site - 1) * $eLimit;
     /* get the right ordering */
     $eOrder = $this->parseOrdering('entries', 'eorder', $this->tKey($this->template, 'entries_ordering', Sobi::Cfg('list.entries_ordering', 'name.asc')));
     $cOrder = $this->parseOrdering('categories', 'corder', $this->tKey($this->template, 'categories_ordering', Sobi::Cfg('list.categories_ordering', 'name.asc')));
     $orderings = array('entries' => $eOrder, 'categories' => $cOrder);
     /* get entries */
     $eCount = count($this->getEntries($eOrder, 0, 0, true, null, $entriesRecursive));
     $entries = $this->getEntries($eOrder, $eLimit, $eLimStart, false, null, $entriesRecursive);
     $categories = array();
     if ($cLim) {
         $categories = $this->getCats($cOrder, $cLim);
     }
     /* create page navigation */
     $url = array('sid' => SPRequest::sid(), 'title' => Sobi::Cfg('sef.alias', true) ? $this->_model->get('nid') : $this->_model->get('name'));
     if (SPRequest::cmd('sptpl')) {
         $url['sptpl'] = SPRequest::cmd('sptpl');
     }
     $pnc = SPLoader::loadClass('helpers.pagenav_' . $this->tKey($this->template, 'template_type', 'xslt'));
     /* @var SPPageNavXSLT $pn */
     $pn = new $pnc($eLimit, $eCount, $site, array('sid' => SPRequest::sid(), 'title' => Sobi::Cfg('sef.alias', true) ? $this->_model->get('nid') : $this->_model->get('name')));
     /* handle meta data */
     SPFactory::header()->objMeta($this->_model);
     /* add pathway */
     SPFactory::mainframe()->addObjToPathway($this->_model, array(ceil($eCount / $eLimit), $site));
     $this->_model->countVisit();
     /* get view class */
     //		$class = SPLoader::loadView( $this->_type );
     $view = SPFactory::View($this->_type);
     //		$view = new $class( $this->template );
     $view->assign($eLimit, '$eLimit')->assign($eLimStart, '$eLimStart')->assign($eCount, '$eCount')->assign($cInLine, '$cInLine')->assign($eInLine, '$eInLine')->assign($this->_task, 'task')->assign($this->_model, $this->_type)->setConfig($this->_tCfg, $this->template)->setTemplate($tplPackage . '.' . $this->templateType . '.' . $this->template)->assign($categories, 'categories')->assign($pn->get(), 'navigation')->assign(SPFactory::user()->getCurrent(), 'visitor')->assign($entries, 'entries')->assign($orderings, 'orderings');
     Sobi::Trigger($this->name(), 'View', array(&$view));
     $view->display($this->_type);
 }
Example #8
0
 /**
  * Enter description here...
  *
  */
 protected function fields()
 {
     SPLoader::loadClass('html.tabs');
     SPFactory::header()->addCssFile('tabs', true);
     $t = new SPHtml_Tabs(true, null);
     $tabs = $this->get('fields');
     if (count($tabs)) {
         $t->startPane('fields_' . $this->get('task'));
         foreach ($tabs as $tab => $keys) {
             $t->startTab(Sobi::Txt($tab), str_replace(' ', '_', $tab));
             echo '<table  class="admintable" style="width: 100%;">';
             $c = 0;
             foreach ($keys as $key => $params) {
                 $class = $c % 2;
                 $c++;
                 $params = explode('|', $params);
                 $p = array();
                 /* at first we need the label */
                 $label = Sobi::Txt(array_shift($params));
                 $label2 = null;
                 if (strstr($label, ':')) {
                     $label = explode(':', $label);
                     $label2 = $label[1];
                     $label = $label[0];
                 }
                 /* get the field type */
                 $p[0] = array_shift($params);
                 if (preg_match('/^section.*/', $key)) {
                     /* put the field name */
                     $p[1] = $key;
                     /* get the current value */
                     $p[2] = $this->get($key);
                 } elseif (!strstr($key, 'spacer')) {
                     /* put the field name */
                     $p[1] = 'spcfg_' . $key;
                     /* get the current value */
                     $p[2] = Sobi::Cfg($key, '');
                 }
                 if (strstr($key, 'spacer')) {
                     if ($key == 'spacer_pby') {
                         $this->pby();
                     } else {
                         echo "<tr class=\"row{$class}\">";
                         echo '<th colspan="2" class="spConfigTableHeader">';
                         $this->txt($label);
                         echo '</th>';
                         echo '</tr>';
                     }
                 } else {
                     if (strstr($key, '_array') && count($p[2]) && $p[2]) {
                         $p[2] = implode(',', $p[2]);
                     }
                     /* and all other parameters */
                     if (count($params)) {
                         foreach ($params as $param) {
                             $p[] = $param;
                         }
                     }
                     echo "<tr class=\"row{$class}\">";
                     echo '<td class="key" style="min-width:200px;">';
                     $this->txt($label);
                     echo '</td>';
                     echo '<td>';
                     $this->parseField($p);
                     if ($label2) {
                         $this->txt($label2);
                     }
                     echo '</td>';
                     echo '</tr>';
                 }
             }
             echo '</table>';
             $t->endTab();
         }
         $t->endPane();
     }
 }
Example #9
0
 private function getNews()
 {
     $out = array();
     $path = SPLoader::path('etc.news', 'front', false, 'xml');
     if (SPFs::exists($path) && time() - filemtime($path) < 60 * 60 * 12) {
         $content = SPFs::read(SPLoader::path('etc.news', 'front', false, 'xml'));
     } else {
         try {
             $connection = SPFactory::Instance('services.remote');
             $news = 'http://rss.sigsiu.net';
             $connection->setOptions(array('url' => $news, 'connecttimeout' => 10, 'header' => false, 'returntransfer' => true));
             $file = SPFactory::Instance('base.fs.file', $path);
             $content = $connection->exec();
             $cinf = $connection->info();
             if (isset($cinf['http_code']) && $cinf['http_code'] != 200) {
                 return Sobi::Error('about', sprintf('CANNOT_GET_NEWS', $news, $cinf['http_code']), SPC::WARNING, 0, __LINE__, __FILE__);
             }
             $file->content($content);
             $file->save();
         } catch (SPException $x) {
             return Sobi::Error('about', SPLang::e('CANNOT_LOAD_NEWS', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
         }
     }
     try {
         if (strlen($content)) {
             $news = new DOMXPath(DOMDocument::loadXML($content));
             $atom = false;
             if ($atom) {
                 //Atom
                 $news->registerNamespace('atom', 'http://www.w3.org/2005/Atom');
                 $out['title'] = $news->query('/atom:feed/atom:title')->item(0)->nodeValue;
                 $items = $news->query('/atom:feed/atom:entry[*]');
                 $c = 5;
                 $open = false;
                 foreach ($items as $item) {
                     $date = $item->getElementsByTagName('updated')->item(0)->nodeValue;
                     if (!$open && time() - strtotime($date) < 60 * 60 * 24) {
                         $open = true;
                     }
                     $feed = array('url' => $item->getElementsByTagName('link')->item(0)->nodeValue, 'title' => $item->getElementsByTagName('title')->item(0)->nodeValue, 'content' => $item->getElementsByTagName('content')->item(0)->nodeValue);
                     if (!$c--) {
                         break;
                     }
                     $out['feeds'][] = $feed;
                 }
             } else {
                 //RSS
                 $out['title'] = $news->query('/rss/channel/title')->item(0)->nodeValue;
                 $items = $news->query('/rss/channel/item[*]');
                 $c = 5;
                 $open = false;
                 foreach ($items as $item) {
                     $date = $item->getElementsByTagName('pubDate')->item(0)->nodeValue;
                     if (!$open && time() - strtotime($date) < 60 * 60 * 24) {
                         $open = true;
                     }
                     $feed = array('url' => $item->getElementsByTagName('link')->item(0)->nodeValue, 'title' => $item->getElementsByTagName('title')->item(0)->nodeValue, 'content' => $item->getElementsByTagName('description')->item(0)->nodeValue, 'image' => $item->getElementsByTagName('enclosure')->item(0)->attributes->getNamedItem('url')->nodeValue);
                     if (!$c--) {
                         break;
                     }
                     $out['feeds'][] = $feed;
                 }
             }
         }
         if ($open) {
             SPFactory::header()->addJsCode('SobiPro.jQuery( document ).ready( function () { SobiPro.jQuery( \'#SobiProNews\' ).trigger(\'click\'); } );');
         }
     } catch (DOMException $x) {
         return Sobi::Error('about', SPLang::e('CANNOT_LOAD_NEWS', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
     }
     return $out;
 }
Example #10
0
 protected function details()
 {
     $this->_type = 'entry_details';
     $type = $this->key('template_type', 'xslt');
     if ($type != 'php' && Sobi::Cfg('global.disable_xslt', false)) {
         $type = 'php';
     }
     if ($type == 'xslt') {
         $this->_attr = $this->entryData();
         SPFactory::header()->addCanonical($this->_attr['entry']['_data']['url']);
         Sobi::Trigger('EntryView', ucfirst(__FUNCTION__), array(&$this->_attr));
     }
 }
Example #11
0
 protected function view()
 {
     /* determine template package */
     $tplPckg = Sobi::Cfg('section.template', SPC::DEFAULT_TEMPLATE);
     Sobi::ReturnPoint();
     $this->_task = 'alpha';
     if (!$this->_model) {
         $this->setModel('section');
         $this->_model->init(Sobi::Section());
     }
     $this->visible();
     /* load template config */
     $this->template();
     $this->tplCfg($tplPckg);
     /* 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));
     /* get the site to display */
     $site = SPRequest::int('site', 1);
     $eLimStart = ($site - 1) * $eLimit;
     $eCount = count($this->getEntries(0, 0, true));
     $entries = $this->getEntries($eLimit, $site);
     $compare = $this->_field ? $this->_field : $this->_nid;
     if (strlen($compare) && $compare != Sobi::Cfg('alphamenu.primary_field')) {
         $t = 'list.alpha.' . strtolower($this->_letter) . '.' . $this->_nid;
     } else {
         $t = 'list.alpha.' . strtolower($this->_letter);
     }
     $pn = SPFactory::Instance('helpers.pagenav_' . $this->tKey($this->template, 'template_type', 'xslt'), $eLimit, $eCount, $site, array('sid' => SPRequest::sid(), 'task' => $t));
     $cUrl = array('sid' => SPRequest::sid(), 'task' => $t);
     if (SPRequest::int('site', 0)) {
         $cUrl['site'] = SPRequest::int('site', 0);
     }
     SPFactory::header()->addCanonical(Sobi::Url($cUrl, true, true, true));
     /* handle meta data */
     SPFactory::header()->objMeta($this->_model);
     $letter = urldecode(SPRequest::cmd('letter'));
     /* add pathway */
     if (!$this->_fieldType) {
         SPFactory::mainframe()->addToPathway(Sobi::Txt('AL.PATH_TITLE', array('letter' => $letter)), Sobi::Url('current'));
         SPFactory::header()->addTitle(Sobi::Txt('AL.TITLE', array('letter' => $letter, 'section' => $this->_model->get('name'))), array(ceil($eCount / $eLimit), $site));
     } else {
         $field = SPFactory::Model('field');
         $field->init($this->_field);
         SPFactory::mainframe()->addToPathway(Sobi::Txt('AL.PATH_TITLE_FIELD', array('letter' => $letter, 'field' => $field->get('name'))), Sobi::Url('current'));
         SPFactory::header()->addTitle(Sobi::Txt('AL.TITLE_FIELD', array('letter' => $letter, 'section' => $this->_model->get('name'), 'field' => $field->get('name'))), array(ceil($eCount / $eLimit), $site));
     }
     /* 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->assign(Sobi::Txt('AL.PATH_TITLE', array('letter' => $this->_letter)), 'listing_name');
     $view->setConfig($this->_tCfg, $this->template);
     $view->setTemplate($tplPckg . '.' . $this->templateType . '.' . $this->template);
     $view->assign($pn->get(), 'navigation');
     $view->assign(SPFactory::user()->getCurrent(), 'visitor');
     $view->assign($entries, 'entries');
     Sobi::Trigger('AlphaListing', 'View', array(&$view));
     $view->display();
 }
Example #12
0
 /**
  * @param SPField[] $fields
  * @return void
  */
 protected function createValidationScript($fields)
 {
     /* get input filters */
     $registry =& SPFactory::registry();
     $registry->loadDBSection('fields_filter');
     $filters = $registry->get('fields_filter');
     $validate = array();
     foreach ($fields as $field) {
         $filter = $field->get('filter');
         if ($filter && isset($filters[$filter])) {
             $f = new stdClass();
             $f->name = $field->get('nid');
             $f->filter = base64_decode($filters[$filter]['params']);
             $f->msg = Sobi::Txt('[JS]' . $filters[$filter]['description']);
             $validate[] = $f;
         }
     }
     if (count($validate)) {
         Sobi::Trigger($this->name(), __FUNCTION__, array(&$validate));
         $validate = json_encode($validate);
         $header =& SPFactory::header();
         $header->addJsVarFile('efilter', md5($validate), array('OBJ' => addslashes($validate)));
     }
 }
Example #13
0
 private function startScript($current)
 {
     $path = SPFactory::config()->getParentPath($current);
     if (!$this->getChilds($path[count($path) - 1])) {
         unset($path[count($path) - 1]);
     }
     unset($path[0]);
     $func = $this->_id . '_stmExpand';
     $script = null;
     if (count($path)) {
         foreach ($path as $i => $cid) {
             $retard = $i * 150;
             $script .= "\t\twindow.setTimeout( '{$func}( {$cid}, {$i}, 0 )', {$retard} );\n";
         }
         SPFactory::header()->addJsCode("\tSobiPro.onReady( function () { \n{$script}\n \t} );");
     }
 }
Example #14
0
 * Name: Sigrid Suski & Radek Suski, Sigsiu.NET GmbH
 * Email: sobi[at]sigsiu.net
 * Url: http://www.Sigsiu.NET
 * @copyright Copyright (C) 2006 - 2015 Sigsiu.NET GmbH (http://www.sigsiu.net). All rights reserved.
 * @license GNU/GPL Version 3
 * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License version 3 as published by the Free Software Foundation, and under the additional terms according section 7 of GPL v3.
 * See http://www.gnu.org/licenses/gpl.html and http://sobipro.sigsiu.net/licenses.
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
 * $Date$
 * $Revision$
 * $Author$
 * $HeadURL$
 */
defined('SOBIPRO') || exit('Restricted access');
SPFactory::header()->addCSSCode('legend { color: #0b55c4; font-size: 12px!important; font-weight: bold;}');
SPFactory::header()->addCSSCode('.sigsiuTree {height: 330px;}');
?>
<script language="javascript" type="text/javascript">
    var selectedCat = 0;
    var selectedCatName = '';
    var selectedCats = new Array();
    var selectedCatNames = new Array();
    var selectedPath = '';
    var selCid = 0;
    if( parent.document.getElementById( 'category.path' ) ) {
    	var SPObjType = 'category';
    }
    else {
    	var SPObjType = 'entry';
    }
    var maxCat = <?php 
Example #15
0
 /**
  * @param string $title
  * @return string
  */
 public function setTitle($title)
 {
     if (strstr($title, '{')) {
         $title = (array) SPFactory::config()->structuralData('json://' . $title);
         $task = SPRequest::task();
         $title = $title[$task];
     }
     $title = $this->parseValue(Sobi::Txt($title));
     Sobi::Trigger('setTitle', $this->name(), array(&$title));
     SPFactory::header()->setTitle($title);
     $this->set($title, 'site_title');
     return $title;
 }
Example #16
0
 /**
  *
  * @param string $title
  */
 public function setTitle($title)
 {
     Sobi::Trigger('setTitle', $this->name(), array(&$title));
     SPFactory::header()->setTitle(Sobi::Txt($title));
 }
Example #17
0
 /**
  * Shows the field in the search form
  * @param bool $return return or display directly
  * @return string
  */
 public function searchForm($return = false)
 {
     if ($this->searchMethod == 'general') {
         return false;
     }
     $hidden = null;
     $d = $this->getValues(false);
     $data = array('' => Sobi::Txt('FD.SEARCH_SELECT_LIST', array('name' => $this->name)));
     foreach ($d as $k => $v) {
         $data[$k] = $v;
     }
     $params = array('id' => $this->nid, 'size' => $this->ssize, 'class' => $this->cssClass . ' ' . Sobi::Cfg('search.form_list_def_css', 'SPSearchSelect'));
     //still there for compatibility reason
     if ($this->swidth) {
         $params['style'] = "width: {$this->swidth}px;";
     }
     if ($this->dependency) {
         SPFactory::header()->addJsFile('opt.field_select');
         $request = json_decode(SPLang::clean(SPRequest::raw($this->nid . '_path', null, 'requestcache')), true);
         $params['class'] .= ' ctrl-dependency-field';
         $hidden = $this->travelDependencyPath($request, $params);
         $this->_selected = isset($request[1]) ? $request[1] : null;
         $hiddenValue = str_replace('"', "'", json_encode((object) $request));
         $hidden .= SPHtml_Input::hidden($this->nid . '_path', $hiddenValue, null, array('data' => array('selected' => '', 'section' => Sobi::Section())));
         $params['data'] = array('order' => '1');
     }
     return SPHtml_Input::select($this->nid, $data, $this->_selected, $this->searchMethod == 'mselect', $params) . $hidden;
 }
Example #18
0
 protected function view()
 {
     /* determine template package */
     $tplPackage = Sobi::Cfg('section.template', SPC::DEFAULT_TEMPLATE);
     Sobi::ReturnPoint();
     $this->_task = 'date';
     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));
     $date = explode('.', SPRequest::cmd('date'));
     $this->date['year'] = isset($date[0]) && $date[0] ? $date[0] : null;
     $this->date['month'] = isset($date[1]) && $date[1] ? $date[1] : null;
     $this->date['day'] = isset($date[2]) && $date[2] ? $date[2] : null;
     if (!$this->date['year'] || !(int) $this->date['year']) {
         throw new SPException(SPLang::e('INVALID_DATE_GIVEN'));
     }
     /* get the site to display */
     $site = SPRequest::int('site', 1);
     $eLimStart = ($site - 1) * $eLimit;
     $conditions = array('spo.oType' => 'entry', 'year(createdTime)' => $this->date['year']);
     $listing = 'year';
     if ($this->date['month'] && $this->date['month'] < 13 && $this->date['month'] > 0) {
         $conditions['month(createdTime)'] = $this->date['month'];
         $listing = 'month';
     }
     if ($this->date['day'] && $this->date['day'] < 13 && $this->date['day'] > 0) {
         $conditions['day(createdTime)'] = $this->date['day'];
         $listing = 'date';
     }
     $eOrder = 'createdTime';
     $eCount = count($this->getEntries($eOrder, 0, 0, true, $conditions, true, Sobi::Section()));
     $entries = $this->getEntries($eOrder, $eLimit, $eLimStart, true, $conditions, true, Sobi::Section());
     $url = array('sid' => SPRequest::sid(), 'task' => 'list.date', 'date' => SPRequest::cmd('date'));
     $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);
     $date = $this->date;
     $monthsNames = explode(',', Sobi::Txt('JS_CALENDAR_MONTHS'));
     $date['month'] = isset($monthsNames[$date['month'] - 1]) ? trim($monthsNames[$date['month'] - 1]) : null;
     SPFactory::mainframe()->addToPathway(Sobi::Txt('DL.PATH_TITLE_' . strtoupper($listing), $date), Sobi::Url('current'));
     SPFactory::header()->addTitle(Sobi::Txt('DL.TITLE_' . strtoupper($listing), $date), array(ceil($eCount / $eLimit), $site));
     /* 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();
 }
Example #19
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($this->_type);
         $orderings = $this->get('orderings');
         $categories = $this->get('categories');
         $entries = $this->get('entries');
         $cUrl = array('title' => Sobi::Cfg('sef.alias', true) ? $current->get('nid') : $current->get('name'), 'sid' => $current->get('id'));
         if (SPRequest::int('site', 0)) {
             $cUrl['site'] = SPRequest::int('site', 0);
         }
         SPFactory::header()->addCanonical(Sobi::Url($cUrl, true, true, true));
         $data = array();
         $data['id'] = $current->get('id');
         $data['counter'] = $current->get('counter');
         $data['section'] = array('_complex' => 1, '_data' => Sobi::Section(true), '_attributes' => array('id' => Sobi::Section(), 'lang' => Sobi::Lang(false)));
         $data['name'] = array('_complex' => 1, '_data' => $current->get('name'), '_attributes' => array('lang' => Sobi::Lang(false)));
         if (Sobi::Cfg('category.show_desc') || $current->get('oType') == 'section') {
             $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)));
         }
         $showIcon = $current->get('showIcon');
         if ($showIcon == SPC::GLOBAL_SETTING) {
             $showIcon = Sobi::Cfg('category.show_icon', true);
         }
         if ($showIcon && $current->get('icon')) {
             if (SPFs::exists(Sobi::Cfg('images.category_icons') . '/' . $current->get('icon'))) {
                 $data['icon'] = Sobi::FixPath(Sobi::Cfg('images.category_icons_live') . $current->get('icon'));
             }
         }
         $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');
         $data['number_of_subcats'] = Sobi::Cfg('list.num_subcats');
         $this->menu($data);
         $this->alphaMenu($data);
         $data['visitor'] = $this->visitorArray($visitor);
         if (count($categories)) {
             $this->loadNonStaticData($categories);
             foreach ($categories as $category) {
                 $cat = $this->category($category);
                 $data['categories'][] = array('_complex' => 1, '_attributes' => array('id' => $cat['id'], 'nid' => $cat['nid']), '_data' => $cat);
             }
             if (strstr($orderings['categories'], 'name') && Sobi::Cfg('lang.multimode', false)) {
                 usort($data['categories'], 'self::orderByName');
                 if ($orderings['categories'] == 'name.desc') {
                     $data['categories'] = array_reverse($data['categories']);
                 }
             }
         }
         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'], 'nid' => $en['nid']), '_data' => $en);
             }
             if (strstr($orderings['entries'], 'name') && Sobi::Cfg('lang.multimode', false)) {
                 usort($data['entries'], 'self::orderByName');
                 if ($orderings['entries'] == 'name.desc') {
                     $data['entries'] = array_reverse($data['entries']);
                 }
             }
             $this->navigation($data);
         }
         $this->fixTimes($data);
         $this->_attr = $data;
     }
     Sobi::Trigger($this->_type, ucfirst(__FUNCTION__), array(&$this->_attr));
 }
Example #20
0
 /**
  * @return array
  */
 public function struct()
 {
     $data = SPConfig::unserialize($this->getRaw());
     if (isset($data['url']) && strlen($data['url'])) {
         $counter = -1;
         if ($data['protocol'] == 'relative') {
             $url = $data['url'];
         } else {
             $url = $data['protocol'] . '://' . $data['url'];
         }
         if (!(isset($data['label']) && strlen($data['label']))) {
             $data['label'] = $url;
         }
         $this->cssClass = strlen($this->cssClass) ? $this->cssClass : 'spFieldsData';
         $this->cssClass = $this->cssClass . ' ' . $this->nid;
         $attributes = array('href' => $url, 'class' => $this->cssClass);
         if ($this->countClicks) {
             SPFactory::header()->addJsFile('opt.field_url');
             $this->cssClass = $this->cssClass . ' ctrl-visit-countable';
             $counter = $this->getCounter();
             $attributes['data-sid'] = $this->sid;
             if (Sobi::Cfg('cache.xml_enabled')) {
                 $attributes['data-counter'] = $counter;
                 $attributes['data-refresh'] = 'true';
             }
             $attributes['class'] = $this->cssClass;
             if ($this->counterToLabel) {
                 $data['label'] = Sobi::Txt('FM.URL.COUNTER_WITH_LABEL', array('label' => $data['label'], 'counter' => $counter));
             }
         }
         $this->cleanCss();
         if (strlen($url)) {
             if ($this->newWindow) {
                 $attributes['target'] = '_blank';
             }
             if ($this->noFollow) {
                 $attributes['rel'] = 'nofollow';
             }
             $data = array('_complex' => 1, '_data' => SPLang::clean($data['label']), '_attributes' => $attributes);
             return array('_complex' => 1, '_data' => array('a' => $data), '_attributes' => array('lang' => Sobi::Lang(false), 'class' => $this->cssClass, 'counter' => $counter));
         }
     }
 }
Example #21
0
 public static function userSelector($name, $value, $groups = null, $params = null, $icon = 'user', $header = 'USER_SELECT_HEADER', $format = '%user', $orderBy = 'id')
 {
     static $count = 0;
     static $session = null;
     if (!$session) {
         $session = SPFactory::user()->getUserState('userSelector', null, array());
     }
     $params = self::checkArray($params);
     if (!isset($params['id'])) {
         $params['id'] = SPLang::nid($name);
     }
     $user = null;
     SPFactory::header()->addJsFile('user_selector');
     $user = SPUser::getBaseData((int) $value);
     $settings = array('groups' => $groups, 'format' => $format, 'user' => Sobi::My('id'), 'ordering' => $orderBy, 'time' => microtime(true));
     if (count($session)) {
         foreach ($session as $id => $data) {
             if (microtime(true) - $data['time'] > 3600) {
                 unset($session[$id]);
             }
         }
     }
     $ssid = md5(microtime() . Sobi::My('id') . ++$count);
     $session[$ssid] =& $settings;
     SPFactory::user()->setUserState('userSelector', $session);
     $userData = null;
     if ($user) {
         $replacements = array();
         preg_match_all('/\\%[a-z]*/', $format, $replacements);
         $placeholders = array();
         if (isset($replacements[0]) && count($replacements[0])) {
             foreach ($replacements[0] as $placeholder) {
                 $placeholders[] = str_replace('%', null, $placeholder);
             }
         }
         if (count($replacements)) {
             foreach ($placeholders as $attribute) {
                 if (isset($user->{$attribute})) {
                     $format = str_replace('%' . $attribute, $user->{$attribute}, $format);
                 }
             }
             $userData = $format;
         }
     }
     $modal = '<div class="response btn-group" data-toggle="buttons-radio"></div><br/><button class="btn btn-block hide more" type="button">' . Sobi::Txt('LOAD_MORE') . '</button>';
     $filter = '<input type="text" placeholder="' . Sobi::Txt('FILTER') . '" class="search pull-right spDisableEnter" name="q">';
     $id = $params['id'];
     $params = self::params($params);
     $f = "\n";
     $f .= '<div class="spUserSelector">';
     $f .= '<div class="input-append">';
     $f .= "\n\t";
     $f .= '<input type="text" value="' . $userData . '" ' . $params . ' name="' . $name . 'Holder" readonly="readonly" class="trigger user-name"/>';
     $f .= '<span class="add-on trigger"><i class="icon-' . $icon . '"></i></span>';
     $f .= '</div>';
     $f .= '<input type="hidden" value="' . $value . '" name="' . $name . '" rel="selected"/>';
     $f .= '<input type="hidden" value="' . $ssid . '" name="' . $name . 'Ssid"/>';
     $f .= '<input type="hidden" value="1" name="' . SPFactory::mainframe()->token() . '"/>';
     $f .= "\n\t";
     $f .= "\n";
     $f .= self::modalWindow(Sobi::Txt($header) . $filter, $id . '-window', $modal);
     $f .= '</div>';
     $f .= "\n";
     Sobi::Trigger('Field', ucfirst(__FUNCTION__), array(&$f));
     return "\n<!-- User Picker '{$name}' Output -->{$f}<!-- User Picker '{$name}' End -->\n\n";
 }
Example #22
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();
    }
Example #23
0
 /**
  * Adds object to the pathway
  * @param SPDBObject $obj
  * @param array $site
  * @return void
  */
 public function &addObjToPathway($obj, $site = array())
 {
     if (defined('SOBI_ADM_PATH')) {
         return true;
     }
     $menu = JSite::getMenu()->getActive()->query;
     $sid = isset($menu['sid']) ? $menu['sid'] : 0;
     $resetPathway = false;
     if ($obj->get('oType') == 'entry') {
         $id = SPRequest::int('pid');
         /** if the entry isn't linked directly in the menu */
         if (!($obj->get('id') == $sid)) {
             /* if we didn't entered this entry via category */
             if (!$id || $id == Sobi::Section() || Sobi::Cfg('entry.primary_path_always')) {
                 $id = $obj->get('parent');
                 $resetPathway = true;
             }
         } else {
             /** ok - here is the weird thing:
              * When it is accessed via menu we have to force cache to create another version
              * because the pathway is stored in the cache
              * @todo find better solution for it
              */
             $mid = true;
             SPFactory::registry()->set('cache_view_recreate_request', $mid)->set('cache_view_add_itemid', JSite::getMenu()->getActive()->id);
             return $this;
         }
     } else {
         $id = $obj->get('id');
     }
     $path = SPFactory::cache()->getVar('parent_path', $id);
     if (!$path) {
         $path = SPFactory::config()->getParentPath($id, true, false, true);
         SPFactory::cache()->addVar($path, 'parent_path', $id);
     }
     if (count($path)) {
         /* skip everything above the linked sid */
         $rpath = array_reverse($path);
         $path = array();
         foreach ($rpath as $part) {
             if ($part['id'] == $sid) {
                 break;
             }
             $path[] = $part;
         }
         $path = array_reverse($path);
         /* ^^ skip everything above the linked sid */
     }
     $title = array();
     // if there was an active menu - add its title to the browser title as well
     if ($sid) {
         $title[] = JFactory::getDocument()->getTitle();
     }
     /**
      * Mon, Jul 16, 2012
      * I would relay like to know why I've added the "htmlentities" call here.
      * The second param of the 'addItem' method is URL so there should be definitely no such thing
      * Related to Bug #692
      */
     if (count($path)) {
         if ($resetPathway) {
             /** we have to reset the J! pathway in case:
              *  - we are entering an entry and we want to show the pathway corresponding to the main parent if of the entry
              *    but we have also an Itemid and Joomla! set already the pathway partialy so we need to override it
              *    It wouldn't be normally a problem but when SEF is enabled we do not have the pid so we don't know how it has been enetered
              */
             JFactory::getApplication()->getPathway()->setPathway(array());
         }
         foreach ($path as $data) {
             if (!(isset($data['name']) || isset($data['id'])) || !$data['id']) {
                 continue;
             }
             $title[] = $data['name'];
             $this->addToPathway($data['name'], self::url(array('title' => Sobi::Cfg('sef.alias', true) ? $data['alias'] : $data['name'], 'sid' => $data['id'])));
         }
     }
     if ($obj->get('oType') == 'entry') {
         $this->addToPathway($obj->get('name'), self::url(array('task' => 'entry.details', 'title' => Sobi::Cfg('sef.alias', true) ? $obj->get('nid') : $obj->get('name'), 'sid' => $obj->get('id'))));
         $title[] = $obj->get('name');
     }
     //		if ( count( $site ) && $site[ 0 ] ) {
     //			$title[ ] = Sobi::Txt( 'SITES_COUNTER', $site[ 1 ], $site[ 0 ] );
     //		}
     SPFactory::header()->addTitle($title, $site);
     return $this;
 }
Example #24
0
 /**
  * Executes the controller task
  * @return void
  */
 public function execute()
 {
     try {
         if (is_array($this->_ctrl)) {
             foreach ($this->_ctrl as &$c) {
                 $c->execute();
             }
         } else {
             if ($this->_ctrl instanceof SPControl) {
                 $this->_ctrl->execute();
             } else {
                 Sobi::Error('CoreCtrl', SPLang::e('No controller to execute'), SPC::ERROR, 500, __LINE__, __FILE__);
             }
         }
     } catch (SPException $x) {
         Sobi::Error('CoreCtrl', SPLang::e('No controller to execute %s', $x->getMessage()), SPC::ERROR, 500, __LINE__, __FILE__);
         //			Sobi::Error( 'CoreCtrl', SPLang::e( 'No controller to execute. %s', $x->getMessage() ), SPC::WARNING, 0, __LINE__, __FILE__ );
         //			Sobi::Redirect( Sobi::GetUserState( 'back_url', Sobi::Url() ), $x->getMessage(), SPC::ERROR_MSG );
     }
     /* send header data etc ...*/
     SPFactory::header()->send();
     SPFactory::mainframe()->endOut();
     /* redirect if any redirect has been set */
     SPFactory::mainframe()->redirect();
     error_reporting($this->_deb);
     restore_error_handler();
 }
Example #25
0
 /**
  * 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;
     }
     $class = $this->required ? $this->cssClass . ' required' : $this->cssClass;
     $show = null;
     $field = null;
     static $js = false;
     $params = array('id' => $this->nid, 'class' => $class);
     if ($this->width) {
         $params['style'] = "width: {$this->width}px;";
     }
     $files = $this->getExistingFiles();
     if (is_array($files) && count($files)) {
         if (isset($files['ico'])) {
             $show = $files['ico'];
         } elseif (isset($files['thumb'])) {
             $show = $files['thumb'];
         }
     }
     $noncropsize = "";
     $icoSize = explode(':', Sobi::Cfg('image.ico_size', '80:80'));
     if ($show) {
         $img = Sobi::Cfg('live_site') . $show;
         if (!$this->crop) {
             $noncropsize = "style=\"width: {$icoSize[0]}px; height: {$icoSize[1]}px;\"";
         }
     }
     $field .= "\n<div class=\"spImageField\">";
     $field .= "\n<div>";
     $field .= "\n<div id=\"{$this->nid}_img_preview\" class=\"spEditImage\">";
     $field .= "\n<div class=\"spEditImagePreview\" >";
     if ($show) {
         $field .= "\n\t<img src=\"{$img}\" alt=\"{$this->name}\" {$noncropsize} />";
     }
     $field .= "\n</div>";
     $field .= "\n</div>";
     $field .= "\n</div>";
     $field .= "\n<div class=\"spImageUpDelete\">";
     if ($show) {
         $field .= SPHtml_Input::checkbox($this->nid . '_delete', 1, Sobi::Txt('FD.IMG_DELETE_CURRENT_IMAGE'), $this->nid . '_delete', false, array('class' => $this->cssClass));
     }
     $field .= SPHtml_Input::fileUpload($this->nid, 'image/*', null, 'spImageUpload', str_replace('field_', 'field.', $this->nid) . '.upload');
     $field .= "\n</div>";
     $field .= "\n</div>";
     if (!$js) {
         SPFactory::header()->addJsFile('opt.field_image_edit')->addJsCode('SobiPro.jQuery( document ).ready( function () { SobiPro.jQuery( ".spImageUpload" ).SPFileUploader(); } );');
         $js = true;
     }
     if ($this->crop) {
         $modalclass = 'modal hide';
         if (Sobi::Cfg('template.bootstrap3-styles') && !defined('SOBIPRO_ADM')) {
             $modalclass = 'modal fade';
         }
         SPFactory::header()->addJsFile('cropper')->addCssFile('cropper');
         $field .= SPHtml_Input::modalWindow(Sobi::Txt('IMAGE_CROP_HEADER'), $this->nid . '_modal', null, $modalclass, 'CLOSE', 'SAVE');
     }
     if (!$return) {
         echo $field;
     } else {
         return $field;
     }
 }
Example #26
0
 * Name: Sigrid Suski & Radek Suski, Sigsiu.NET GmbH
 * Email: sobi[at]sigsiu.net
 * Url: http://www.Sigsiu.NET
 * @copyright Copyright (C) 2006 - 2015 Sigsiu.NET GmbH (http://www.sigsiu.net). All rights reserved.
 * @license GNU/GPL Version 3
 * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License version 3 as published by the Free Software Foundation, and under the additional terms according section 7 of GPL v3.
 * See http://www.gnu.org/licenses/gpl.html and http://sobipro.sigsiu.net/licenses.
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
 * $Date: 2015-02-19 13:24:35 +0100 (Thu, 19 Feb 2015) $
 * $Revision: 4387 $
 * $Author: Radek Suski $
 * $HeadURL: file:///opt/svn/SobiPro/Component/branches/SobiPro-1.1/Admin/field/edit.php $
 */
defined('SOBIPRO') || exit('Restricted access');
SPRequest::set('hidemainmenu', 1);
SPFactory::header()->addCSSCode('body { min-width: 1200px; }')->addJsCode("\n\t\t\tvar SPErrMsg = SobiPro.Txt( 'Please fill in all required fields!' );\n\t        function submitbutton( task )\n\t        {\n\t            var form = document.adminForm;\n\t            if ( task == 'field.cancel' || SPValidateForm() ) {\n\t                if ( SP_id( 'field.nid' ).value == '' ) {\n\t                    SP_id( 'field.nid' ).value = SP_id( 'field.name' ).value;\n\t                }\n\t                var nid = SP_id( 'field.nid' ).value;\n\t                nid = nid.replace( /(\\s+)/g, '_' );\n\t                nid = nid.replace( /[^\\w_]/g, '' );\n\t                SP_id( 'field.nid' ).value = nid.toLowerCase();\n\t                if ( SP_id( 'field.nid' ).value.indexOf( 'field_' ) != 0 ) {\n\t                    SP_id( 'field.nid' ).value = 'field_' + SP_id( 'field.nid' ).value;\n\t                }\n\t                submitform( task );\n\t            }\n\t        }\n\t        SobiPro.jQuery( document ).ready( function ()\n\t        {\n\t        \tJoomla.submitform = function ( task )\n\t            {\n\t                submitbutton( task );\n\t            }\n\t         } );\n        ");
$row = 0;
$this->trigger('OnStart');
?>

<div>
    <fieldset class="adminform">
        <table class="admintable">
            <tr class="row<?php 
echo ++$row % 2;
?>
">
                <td class="key">
					<?php 
$this->txt('FM.FIELD_LABEL');
?>
Example #27
0
 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();
 }
Example #28
0
    /**
     * @param SPAdmJoomlaMenuView $view
     * @param stdClass $menu
     */
    public function category(&$view, $menu)
    {
        $section = SPRequest::int('section');
        $tree = $this->initialiseTree();
        $tree->disable($section);
        $tree->init($section);
        $view->assign($tree, 'tree');
        $this->addTemplates($view, $menu, 'category');
        SPFactory::header()->addJsCode('SobiPro.jQuery( ".ctrl-save", window.parent.document )
					.click( function( e )
						{
							if( SobiPro.jQuery( "#SP_function-name" ).val() == "MENU_LINK_TO_SELECTED_CATEGORY" ) {
								e.preventDefault();
								e.stopPropagation();
								alert( "' . Sobi::Txt('MENU_CAT_FUNCTION_SELECT_CAT_FIRST') . '" );
								SobiPro.jQuery( "#SobiProSelectedFunction", window.parent.document ).html( "' . Sobi::Txt('SOBI_SELECT_FUNCTIONALITY') . '" );
						}
					} ); ');
    }
Example #29
0
 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);
 }
Example #30
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>";
 }