当前位置: 首页>>代码示例>>PHP>>正文


PHP Sobi::My方法代码示例

本文整理汇总了PHP中Sobi::My方法的典型用法代码示例。如果您正苦于以下问题:PHP Sobi::My方法的具体用法?PHP Sobi::My怎么用?PHP Sobi::My使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Sobi的用法示例。


在下文中一共展示了Sobi::My方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: array

 /**
  * @param $action
  * @param int $sid
  * @param array $changes
  * @param $message
  * @return SPMessage
  */
 public function &logAction($action, $sid = 0, $changes = array(), $message = null)
 {
     if (Sobi::Cfg('entry.versioning', true)) {
         $log = array('revision' => microtime(true) . '.' . $sid . '.' . Sobi::My('id'), 'changedAt' => 'FUNCTION:NOW()', 'uid' => Sobi::My('id'), 'userName' => Sobi::My('name'), 'userEmail' => Sobi::My('mail'), 'change' => $action, 'site' => defined('SOBIPRO_ADM') ? 'adm' : 'site', 'sid' => $sid, 'changes' => SPConfig::serialize($changes), 'params' => null, 'reason' => $message, 'language' => Sobi::Lang());
         SPFactory::db()->insert('spdb_history', $log);
     }
     return $this;
 }
开发者ID:kishoreweblabs,项目名称:SobiPro,代码行数:15,代码来源:message.php

示例2: route

 /**
  * Try to find out what we have to do
  *     - If we have a task - parse task
  *  - If we don't have a task, but sid, we are going via default object task
  *  - Otherwise it could be only the frontpage
  * @throws SPException
  * @return void
  */
 private function route()
 {
     $cache = true;
     if (Sobi::Cfg('cache.xml_enabled')) {
         if ($this->_model instanceof stdClass && !($this->_model instanceof stdClass && $this->_model->owner == Sobi::My('id'))) {
             if (in_array($this->_model->owner, array('entry'))) {
                 $cache = false;
             }
         }
     }
     if ($cache && Sobi::Cfg('cache.xml_enabled')) {
         $this->_cache = SPFactory::cache()->view();
     }
     if (!$this->_cache) {
         /* if we have a task */
         if ($this->_task && $this->_task != 'panel') {
             if (!$this->routeTask()) {
                 throw new SPException(SPLang::e('Cannot interpret task "%s"', $this->_task));
             }
         } elseif ($this->_sid) {
             if (!$this->routeObj()) {
                 throw new SPException(SPLang::e('Cannot route object with id "%d"', $this->_sid));
             }
         } else {
             $this->frontpage();
         }
     } else {
         try {
             $task = $this->_task;
             if (!$task && $this->_sid) {
                 $ctrl = SPFactory::Controller($this->_model->oType);
                 $this->setController($ctrl);
                 $this->_model = SPFactory::object($this->_sid);
                 $model = SPLoader::loadModel($this->_model->oType, false, false);
                 if ($model) {
                     $this->_ctrl->setModel($model);
                     if ($this->_model instanceof stdClass) {
                         $this->_ctrl->extend($this->_model, true);
                     }
                 }
             }
             if (strstr($task, '.')) {
                 $task = explode('.', $task);
                 $obj = trim(array_shift($task));
                 if ($obj == 'list' || $obj == 'ls') {
                     $obj = 'listing';
                 }
                 $task = trim(implode('.', $task));
                 $ctrl = SPFactory::Controller($obj);
                 $this->setController($ctrl);
                 $model = SPLoader::loadModel($obj, false, false);
                 if ($model) {
                     $this->_ctrl->setModel($model);
                     if ($this->_model instanceof stdClass) {
                         $this->_ctrl->extend($this->_model, true);
                     }
                 } else {
                     $this->_ctrl->setModel(SPFactory::Section($this->_section));
                     if ($this->_model instanceof stdClass) {
                         $this->_ctrl->extend($this->_model, true);
                     }
                 }
             } elseif ($task) {
                 /** Special controllers not inherited from object and without model */
                 $ctrl = SPFactory::Controller($task);
                 $this->setController($ctrl);
                 $this->_ctrl->setModel(SPFactory::Section($this->_section));
                 if ($this->_model instanceof stdClass) {
                     $this->_ctrl->extend($this->_model, true);
                 }
             }
             $this->_ctrl->setTask($task);
             $this->_ctrl->visible();
         } catch (SPException $x) {
             Sobi::Error('CachedView', $x->getMessage());
             $this->_cache = null;
             $this->route();
         }
     }
 }
开发者ID:ranrolls,项目名称:ras-full-portal,代码行数:88,代码来源:sobipro.php

示例3: checkbox

 public function checkbox($cell)
 {
     /** First let's check if it is not checked out */
     if (isset($cell['attributes']['checked-out-by']) && isset($cell['attributes']['checked-out-time']) && $cell['attributes']['checked-out-by'] && $cell['attributes']['checked-out-by'] != Sobi::My('id') && strtotime($cell['attributes']['checked-out-time']) > gmdate('U')) {
         if (isset($cell['attributes']['checked-out-ico']) && $cell['attributes']['checked-out-ico']) {
             $icon = $cell['attributes']['checked-out-ico'];
         } else {
             $icon = $this->_checkedOutIcon;
         }
         $user = SPUser::getInstance($cell['attributes']['checked-out-by']);
         $txt = Sobi::Txt('CHECKED_OUT', $user->get('name'), $cell['attributes']['checked-out-time']);
         $this->_out[] = '<a href="#" rel="sp-tooltip" data-original-title="' . $txt . '" class="checkedout">';
         $this->_out[] = '<i class="icon-' . $icon . '"></i>';
         $this->_out[] = '</a>';
         return $cell;
     } elseif ($this->istSet($cell['attributes'], 'locked', true)) {
         $icon = $this->istSet($cell['attributes'], 'locked-icon') ? $cell['attributes']['locked-icon'] : $this->_checkedOutIcon;
         $text = $this->istSet($cell['attributes'], 'locked-text') ? $cell['attributes']['locked-text'] : $this->_checkedOutIcon;
         $this->_out[] = '<a href="#" rel="sp-tooltip" data-original-title="' . $text . '" class="checkedout">';
         $this->_out[] = '<i class="icon-' . $icon . '"></i>';
         $this->_out[] = '</a>';
         return $cell;
     }
     $type = $this->istSet($cell['attributes'], 'input-type') ? $cell['attributes']['input-type'] : 'checkbox';
     if (isset($cell['attributes']['rel']) && $cell['attributes']['rel']) {
         $this->_out[] = '<input type="' . $type . '" name="spToggle" value="1" rel="' . $cell['attributes']['rel'] . '"/>';
         return $cell;
     } else {
         $multiple = $this->istSet($cell['attributes'], 'multiple', 'false') ? null : '[]';
         $this->_out[] = '<input type="' . $type . '" name="' . $cell['attributes']['name'] . $multiple . '" value="' . $cell['content'] . '"/>';
         return $cell;
     }
 }
开发者ID:pelloq1,项目名称:SobiPro,代码行数:33,代码来源:parser.php

示例4: saveData

 /**
  * Gets the data for a field and save it in the database
  * @param SPEntry $entry
  * @param string $request
  * @return bool
  */
 public function saveData(&$entry, $request = 'POST')
 {
     if (!$this->enabled) {
         return false;
     }
     /* @var SPdb $db */
     $db = SPFactory::db();
     $save = $this->verify($entry, $request);
     $time = SPRequest::now();
     $IP = SPRequest::ip('REMOTE_ADDR', 0, 'SERVER');
     $uid = Sobi::My('id');
     /* collect the needed params */
     $params = array();
     $params['publishUp'] = $entry->get('publishUp');
     $params['publishDown'] = $entry->get('publishDown');
     $params['fid'] = $this->fid;
     $params['sid'] = $entry->get('id');
     $params['section'] = Sobi::Reg('current_section');
     $params['lang'] = Sobi::Lang();
     $params['enabled'] = $entry->get('state');
     $params['baseData'] = $db->escape(SPConfig::serialize($save));
     $params['approved'] = $entry->get('approved');
     $params['confirmed'] = $entry->get('confirmed');
     /* if it is the first version, it is new entry */
     if ($entry->get('version') == 1) {
         $params['createdTime'] = $time;
         $params['createdBy'] = $uid;
         $params['createdIP'] = $IP;
     }
     $params['updatedTime'] = $time;
     $params['updatedBy'] = $uid;
     $params['updatedIP'] = $IP;
     $params['copy'] = !$entry->get('approved');
     if (Sobi::My('id') == $entry->get('owner')) {
         --$this->editLimit;
     }
     $params['editLimit'] = $this->editLimit;
     /* save it */
     try {
         /* Notices:
          * If it was new entry - insert
          * If it was an edit and the field wasn't filled before - insert
          * If it was an edit and the field was filled before - update
          *     " ... " and changes are not autopublish it should be insert of the copy .... but
          * " ... " if a copy already exist it is update again
          * */
         $db->insertUpdate('spdb_field_data', $params);
     } catch (SPException $x) {
         Sobi::Error(__CLASS__, SPLang::e('CANNOT_SAVE_DATA', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
     }
     /* if it wasn't edited in the default language, we have to try to insert it also for def lang */
     if (Sobi::Lang() != Sobi::DefLang()) {
         $params['lang'] = Sobi::DefLang();
         try {
             $db->insert('spdb_field_data', $params, true, true);
         } catch (SPException $x) {
             Sobi::Error(__CLASS__, SPLang::e('CANNOT_SAVE_DATA', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
         }
     }
 }
开发者ID:kishoreweblabs,项目名称:SobiPro,代码行数:66,代码来源:email.php

示例5: display

 /**
  *
  */
 public function display($o = null)
 {
     if (SPRequest::cmd('format') == 'json' && Sobi::Cfg('output.json_enabled', false)) {
         return $this->jsonDisplay();
     }
     $type = $this->key('template_type', 'xslt');
     $f = null;
     $task = SPRequest::task();
     if ($this->key('functions')) {
         $f = $this->registerFunctions();
     }
     $out = null;
     if ($type != 'php' && Sobi::Cfg('global.disable_xslt', false)) {
         $type = 'php';
     }
     $parserClass = SPLoader::loadClass('mlo.template_' . $type);
     if ($parserClass) {
         /** @var $parser SPTemplateXSLT */
         $parser = new $parserClass();
     } else {
         throw new SPException(SPLang::e('CANNOT_LOAD_PARSER', $type));
     }
     $this->_attr['template_path'] = Sobi::FixPath(str_replace(SOBI_ROOT, Sobi::Cfg('live_site'), $this->_templatePath));
     $messages = SPFactory::message()->getMessages();
     if (count($messages)) {
         foreach ($messages as $type => $content) {
             $this->_attr['messages'][$type] = array_values($content);
         }
     }
     $parser->setProxy($this);
     $parser->setData($this->_attr);
     $parser->setXML($this->_xml);
     $parser->setCacheData(array('hidden' => $this->_hidden));
     $parser->setType($this->_type);
     $parser->setTemplate($this->_template);
     Sobi::Trigger('Display', $this->name(), array($type, &$this->_attr));
     $o = $o ? $o : strtolower($this->key('output', $this->key('output', 'html'), $this->tTask));
     $action = $this->key('form.action');
     if ($action) {
         $opt = SPFactory::mainframe()->form();
         if (is_array($opt) && count($opt)) {
             foreach ($opt as $l => $v) {
                 $this->addHidden($v, $l);
             }
         }
         $form = $this->csection('form');
         $form['method'] = isset($form['method']) && $form['method'] ? $form['method'] : 'post';
         $out .= "\n<form ";
         foreach ($form as $p => $v) {
             $out .= $p . '="' . $v . '" ';
         }
         $out .= ">\n";
     }
     $out .= $parser->display($o, $f);
     $hidden = null;
     if (count($this->_hidden)) {
         $this->_hidden[SPFactory::mainframe()->token()] = 1;
         foreach ($this->_hidden as $name => $value) {
             $hidden .= "\n<input type=\"hidden\" id=\"SP_{$name}\" name=\"{$name}\" value=\"{$value}\"/>";
         }
         // xhtml strict valid
         $hidden = "<div>{$hidden}</div>";
         $out .= $hidden;
     }
     $out .= $action ? "\n</form>\n" : null;
     /* SobiPro type specific content parser */
     Sobi::Trigger('ContentDisplay', $this->name(), array(&$out));
     /* common content parser */
     $cParse = $this->key('parse', -1);
     /* if it was specified in the template config file or it was set in the section config and not disabled in the template config */
     if (!(strstr($task, '.edit') || strstr($task, '.add') || in_array($task, Sobi::Cfg('plugins.content_disable', array())))) {
         if ($cParse == 1 || Sobi::Cfg('parse_template_content', false) && $cParse == -1) {
             Sobi::Trigger('Parse', 'Content', array(&$out));
         }
     }
     header('SobiPro: ' . Sobi::Section());
     if ($o == 'html' && (!strlen(SPRequest::cmd('format')) || SPRequest::cmd('format') == 'html' || SPRequest::int('crawl'))) {
         $out .= $this->pb();
         if ((SPRequest::cmd('dbg') || Sobi::Cfg('debug')) && Sobi::My('id')) {
             $start = Sobi::Reg('start');
             $mem = $start[0];
             $time = $start[1];
             $queries = SPFactory::db()->getCount();
             $mem = number_format(memory_get_usage() - $mem);
             $time = microtime(true) - $time;
             SPConfig::debOut("Memory: {$mem}<br/>Time: {$time}<br/> Queries: {$queries}");
         }
         echo "\n<!-- Start of SobiPro component-->\n<div id=\"SobiPro\" class=\"SobiPro\">\n{$out}\n</div>\n<!-- End of SobiPro component Copyright (C) 2011-2014 Sigsiu.NET GmbH -->\n";
     } else {
         $this->customOutput($out);
     }
     Sobi::Trigger('AfterDisplay', $this->name());
 }
开发者ID:vstorm83,项目名称:propertease,代码行数:96,代码来源:view.php

示例6: userSelector

 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";
 }
开发者ID:ranrolls,项目名称:ras-full-portal,代码行数:66,代码来源:input.php

示例7: checkCopy

 private function checkCopy()
 {
     return !(in_array(SPRequest::task(), array('entry.approve', 'entry.edit', 'entry.save', 'entry.submit', 'entry.payment')) || Sobi::Can('entry.access.unapproved_any') || $this->owner == Sobi::My('id') && Sobi::Can('entry.manage.own') || $this->owner == Sobi::My('id') && Sobi::Can('entry.access.unpublished_own') || Sobi::Can('entry.manage.*'));
 }
开发者ID:ranrolls,项目名称:ras-full-portal,代码行数:4,代码来源:entry.php

示例8: entryData

 protected function entryData($getFields = true)
 {
     /** @var SPEntry $entry */
     $entry = $this->get('entry');
     $visitor = $this->get('visitor');
     $data = array();
     $data['section'] = array('_complex' => 1, '_data' => Sobi::Section(true), '_attributes' => array('id' => Sobi::Section(), 'lang' => Sobi::Lang(false)));
     $en = array();
     $en['name'] = array('_complex' => 1, '_data' => $entry->get('name'), '_attributes' => array('lang' => Sobi::Lang(false)));
     $en['created_time'] = $entry->get('createdTime');
     $en['updated_time'] = $entry->get('updatedTime');
     $en['valid_since'] = $entry->get('validSince');
     $en['valid_until'] = $entry->get('validUntil');
     $en['author'] = $entry->get('owner');
     $en['counter'] = $entry->get('counter');
     $en['approved'] = $entry->get('approved');
     $this->fixTimes($en);
     //       $mytime = date( 'Y-m-d H:i:s', time());
     if ($entry->get('state') == 0) {
         $en['state'] = 'unpublished';
     } else {
         if (strtotime($entry->get('validUntil')) != 0 && strtotime($entry->get('validUntil')) < time()) {
             $en['state'] = 'expired';
         } elseif (strtotime($entry->get('validSince')) != 0 && strtotime($entry->get('validSince')) > time()) {
             $en['state'] = 'pending';
         } else {
             $en['state'] = 'published';
         }
     }
     $en['url'] = Sobi::Url(array('pid' => $entry->get('parent'), 'sid' => $entry->get('id'), 'title' => Sobi::Cfg('sef.alias', true) ? $entry->get('nid') : $entry->get('name')), true, true, true);
     if (Sobi::Can('entry', 'edit', '*') || Sobi::My('id') == $entry->get('owner') && Sobi::Can('entry', 'edit', 'own')) {
         $en['edit_url'] = Sobi::Url(array('task' => 'entry.edit', 'sid' => $entry->get('id')));
     }
     if (Sobi::Can('entry', 'manage', '*')) {
         $en['approve_url'] = Sobi::Url(array('task' => $entry->get('approved') ? 'entry.unapprove' : 'entry.approve', 'sid' => $entry->get('id')));
     }
     if ($entry->get('owner') == Sobi::My('id') && Sobi::Can('entry', 'delete', 'own') || Sobi::Can('entry', 'delete', '*')) {
         $en['delete_url'] = Sobi::Url(array('task' => 'entry.delete', 'sid' => $entry->get('id')));
     }
     if (Sobi::Can('entry', 'publish', '*') || Sobi::My('id') == $entry->get('owner') && Sobi::Can('entry', 'publish', 'own')) {
         $en['publish_url'] = Sobi::Url(array('task' => $entry->get('state') ? 'entry.unpublish' : 'entry.publish', 'sid' => $entry->get('id')));
     }
     $cats = $entry->get('categories');
     $categories = array();
     if (count($cats)) {
         $cn = SPLang::translateObject(array_keys($cats), array('name', 'alias'), 'category');
     }
     $primaryCat = $entry->get('parent');
     foreach ($cats as $cid => $cat) {
         $cAttr = array('lang' => Sobi::Lang(false), 'id' => $cat['pid'], 'alias' => $cat['alias'], 'position' => $cat['position'], 'url' => Sobi::Url(array('sid' => $cat['pid'], 'title' => Sobi::Cfg('sef.alias', true) ? $cat['alias'] : $cat['name'])));
         if ($cat['pid'] == $primaryCat) {
             $cAttr['primary'] = 'true';
         }
         $categories[] = array('_complex' => 1, '_data' => SPLang::clean($cn[$cid]['value']), '_attributes' => $cAttr);
     }
     $en['categories'] = $categories;
     $en['meta'] = array('description' => $entry->get('metaDesc'), 'keys' => $this->metaKeys($entry), 'author' => $entry->get('metaAuthor'), 'robots' => $entry->get('metaRobots'));
     if ($getFields) {
         $fields = $entry->getFields();
         if (count($fields)) {
             $en['fields'] = $this->fieldStruct($fields, 'details');
         }
     }
     $this->menu($data);
     $this->alphaMenu($data);
     $data['entry'] = array('_complex' => 1, '_data' => $en, '_attributes' => array('id' => $entry->get('id'), 'nid' => $entry->get('nid'), 'version' => $entry->get('version')));
     $data['visitor'] = $this->visitorArray($visitor);
     return $data;
 }
开发者ID:pelloq1,项目名称:SobiPro,代码行数:69,代码来源:entry.php

示例9: loadTemplate

 protected function loadTemplate($field, $view)
 {
     $nid = '/' . Sobi::Section('nid') . '/';
     $disableOverrides = null;
     if (is_array(Sobi::My('groups'))) {
         $disableOverrides = array_intersect(Sobi::My('groups'), Sobi::Cfg('templates.disable-overrides', array()));
     }
     if (SPLoader::translatePath('field.' . $field->get('fieldType'), 'adm', true, 'xml')) {
         /** Case we have also override  */
         /** section override */
         if (!$disableOverrides && SPLoader::translatePath('field.' . $nid . $field->get('fieldType'), 'adm', true, 'xml')) {
             $view->loadDefinition('field.' . $nid . $field->get('fieldType'));
         } elseif (SPLoader::translatePath('field.' . $field->get('fieldType') . '_override', 'adm', true, 'xml')) {
             $view->loadDefinition('field.' . $field->get('fieldType') . '_override');
         } else {
             $view->loadDefinition('field.' . $field->get('fieldType'));
         }
         if (SPLoader::translatePath('field.templates.' . $field->get('fieldType') . '_override', 'adm')) {
             $view->setTemplate('field.templates.' . $field->get('fieldType') . '_override');
         } elseif (SPLoader::translatePath('field.templates.' . $nid . $field->get('fieldType'), 'adm')) {
             $view->setTemplate('field.templates.' . $nid . $field->get('fieldType'));
         } else {
             $view->setTemplate('default');
         }
         return true;
     }
     return false;
 }
开发者ID:kishoreweblabs,项目名称:SobiPro,代码行数:28,代码来源:field.php

示例10: saveData

 /**
  * Gets the data for a field and save it in the database
  * @param SPEntry $entry
  * @param string $request
  * @throws SPException
  * @return bool
  */
 public function saveData(&$entry, $request = 'POST')
 {
     if (!$this->enabled) {
         return false;
     }
     if ($this->method == 'fixed') {
         $fixed = $this->fixedCid;
         $fixed = explode(',', $fixed);
         $data = array();
         if (count($fixed)) {
             foreach ($fixed as $cid) {
                 $data[] = trim($cid);
             }
         }
         if (!count($data)) {
             throw new SPException(SPLang::e('FIELD_CC_FIXED_CID_NOT_SELECTED', $this->name));
         }
     } else {
         $data = $this->verify($entry, $request);
     }
     $time = SPRequest::now();
     $IP = SPRequest::ip('REMOTE_ADDR', 0, 'SERVER');
     $uid = Sobi::My('id');
     /* if we are here, we can save these data */
     /* @var SPdb $db */
     $db = SPFactory::db();
     /* collect the needed params */
     $params = array();
     $params['publishUp'] = $entry->get('publishUp');
     $params['publishDown'] = $entry->get('publishDown');
     $params['fid'] = $this->fid;
     $params['sid'] = $entry->get('id');
     $params['section'] = Sobi::Reg('current_section');
     $params['lang'] = Sobi::Lang();
     $params['enabled'] = $entry->get('state');
     $params['params'] = null;
     $params['options'] = null;
     $params['baseData'] = SPConfig::serialize($data);
     $params['approved'] = $entry->get('approved');
     $params['confirmed'] = $entry->get('confirmed');
     /* if it is the first version, it is new entry */
     if ($entry->get('version') == 1) {
         $params['createdTime'] = $time;
         $params['createdBy'] = $uid;
         $params['createdIP'] = $IP;
     }
     $params['updatedTime'] = $time;
     $params['updatedBy'] = $uid;
     $params['updatedIP'] = $IP;
     $params['copy'] = !$entry->get('approved');
     if (Sobi::My('id') == $entry->get('owner')) {
         --$this->editLimit;
     }
     $params['editLimit'] = $this->editLimit;
     /* save it */
     try {
         /* Notices:
          * If it was new entry - insert
          * If it was an edit and the field wasn't filled before - insert
          * If it was an edit and the field was filled before - update
          *     " ... " and changes are not autopublish it should be insert of the copy .... but
          * " ... " if a copy already exist it is update again
          * */
         $db->insertUpdate('spdb_field_data', $params);
     } catch (SPException $x) {
         Sobi::Error(__CLASS__, SPLang::e('CANNOT_SAVE_DATA', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
     }
     /* if it wasn't edited in the default language, we have to try to insert it also for def lang */
     if (Sobi::Lang() != Sobi::DefLang()) {
         $params['lang'] = Sobi::DefLang();
         try {
             $db->insert('spdb_field_data', $params, true, true);
         } catch (SPException $x) {
             Sobi::Error(__CLASS__, SPLang::e('CANNOT_SAVE_DATA', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
         }
     }
     /** Last important thing - join selected categories  */
     $cats = SPFactory::registry()->get('request_categories', array());
     $cats = array_unique(array_merge($cats, $data));
     SPFactory::registry()->set('request_categories', $cats);
     if ($this->method == 'select' && $this->isPrimary) {
         $db->update('spdb_object', array('parent' => $data[0]), array('id' => $params['sid']));
     }
 }
开发者ID:ranrolls,项目名称:ras-full-portal,代码行数:91,代码来源:category.php

示例11: editForm

 /**
  */
 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();
 }
开发者ID:ranrolls,项目名称:ras-full-portal,代码行数:25,代码来源:category.php

示例12: entries


//.........这里部分代码省略.........
     }
     $sid = $params->get('sid');
     $section = $params->get('section');
     $this->setModel($sid == $section ? 'section' : 'category');
     $this->_model->init($sid);
     $catId = SPRequest::int('pid');
     $catId = $catId ? $catId : SPRequest::sid();
     if ($params->get('autoListing', false) && $catId && $catId != Sobi::Section()) {
         $entries = Sobi::GetUserData('currently-displayed-entries', array());
         if (!count($entries) && $catId) {
             $entries = SPFactory::Category($catId)->getChilds('entry', true, 1);
             $entries = array_unique($entries);
         }
         if (count($entries)) {
             $conditions['spo.id'] = $entries;
         }
     } else {
         if ($entriesRecursive) {
             $pids = $this->_model->getChilds('category', true);
             // getChilds doesn't includes the category id itself
             $pids[$this->_model->get('id')] = $this->_model->get('id');
             if (is_array($pids)) {
                 $pids = array_keys($pids);
             }
             $conditions['sprl.pid'] = $pids;
         } else {
             $conditions['sprl.pid'] = $sid;
         }
         if ($sid == -1) {
             unset($conditions['sprl.pid']);
         }
     }
     if (count($conditions)) {
         /* sort by field */
         if (is_numeric($eOrder)) {
             static $fields = array();
             $specificMethod = false;
             $field = isset($fields[$sid]) ? $fields[$sid] : null;
             if (!$field) {
                 try {
                     $fType = $db->select('fieldType', 'spdb_field', array('fid' => $eOrder))->loadResult();
                 } catch (SPException $x) {
                     Sobi::Error($this->name(), SPLang::e('CANNOT_DETERMINE_FIELD_TYPE', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
                 }
                 if ($fType) {
                     $field = SPLoader::loadClass('opt.fields.' . $fType);
                 }
                 $fields[$sid] = $field;
             }
             if ($field && method_exists($field, 'sortBy')) {
                 $table = null;
                 $oPrefix = null;
                 $specificMethod = call_user_func_array(array($field, 'sortBy'), array(&$table, &$conditions, &$oPrefix, &$eOrder, &$eDir));
             }
             if (!$specificMethod) {
                 $table = $db->join(array(array('table' => 'spdb_field', 'as' => 'fdef', 'key' => 'fid'), array('table' => 'spdb_field_data', 'as' => 'fdata', 'key' => 'fid'), array('table' => 'spdb_object', 'as' => 'spo', 'key' => array('fdata.sid', 'spo.id')), array('table' => 'spdb_relations', 'as' => 'sprl', 'key' => array('fdata.sid', 'sprl.id'))));
                 $oPrefix = 'spo.';
                 $conditions['spo.oType'] = 'entry';
                 $conditions['fdef.fid'] = $eOrder;
                 $eOrder = 'baseData.' . $eDir;
             }
         } else {
             $table = $db->join(array(array('table' => 'spdb_relations', 'as' => 'sprl', 'key' => 'id'), array('table' => 'spdb_object', 'as' => 'spo', 'key' => 'id')));
             $conditions['spo.oType'] = 'entry';
             if ($eOrder == 'validUntil') {
                 $eOrder = 'spo.validUntil';
             }
             $eOrder = $eOrder . '.' . $eDir;
             $oPrefix = 'spo.';
         }
         /* check user permissions for the visibility */
         if (Sobi::My('id')) {
             $this->userPermissionsQuery($conditions, $oPrefix);
         } else {
             $conditions = array_merge($conditions, array($oPrefix . 'state' => '1', '@VALID' => $db->valid($oPrefix . 'validUntil', $oPrefix . 'validSince')));
         }
         $conditions['sprl.copy'] = '0';
         try {
             if (!$count) {
                 $results = $db->select($oPrefix . 'id', $table, $conditions, $eOrder, $eLimit, $eLimStart, true)->loadResultArray();
             } else {
                 $results = $db->select("COUNT( DISTINCT {$oPrefix}id )", $table, $conditions, $eOrder)->loadResult();
             }
         } catch (SPException $x) {
             Sobi::Error($this->name(), SPLang::e('DB_REPORTS_ERR', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
         }
         if ($count) {
             return $results;
         }
         $entries = array();
         if (count($results)) {
             foreach ($results as $i => $sid) {
                 $entries[$i] = $sid;
             }
         }
         return $entries;
     } else {
         return array();
     }
 }
开发者ID:kidaa30,项目名称:lojinha,代码行数:101,代码来源:emod.php

示例13: storeView

 /**
  */
 public function storeView($head)
 {
     if (!Sobi::Cfg('cache.xml_enabled') || $this->_cachedView || Sobi::My('id') && Sobi::Cfg('cache.xml_no_reg')) {
         return false;
     }
     if ($this->view['xml']) {
         $xml = $this->view['xml'];
         $template = Sobi::Reg('cache_view_template');
         if (!$template) {
             $template = $this->view['template'];
             $template = str_replace(SPLoader::translateDirPath(Sobi::Cfg('section.template'), 'templates'), null, $template);
         }
         $root = $xml->documentElement;
         $root->removeChild($root->getElementsByTagName('visitor')->item(0));
         if ($root->getElementsByTagName('messages')->length) {
             $root->removeChild($root->getElementsByTagName('messages')->item(0));
         }
         /** @var $header DOMDocument */
         $header = SPFactory::Instance('types.array')->toXML($head, 'header', true);
         $root->appendChild($xml->importNode($header->documentElement, true));
         if ($this->view['data'] && count($this->view['data'])) {
             $data = SPFactory::Instance('types.array')->toXML($this->view['data'], 'cache-data', true);
             $root->appendChild($xml->importNode($data->documentElement, true));
         }
         $request = $this->viewRequest();
         $request['template'] = $template;
         $configFiles = SPFactory::registry()->get('template_config');
         $request['configFile'] = str_replace('"', "'", json_encode($configFiles));
         $request['cid'] = 'NULL';
         $request['created'] = 'FUNCTION:NOW()';
         $fileName = md5(serialize($request));
         $request['fileName'] = $fileName;
         $filePath = SPLoader::path('var.xml.' . $fileName, 'front', false, 'xml');
         $content = $xml->saveXML();
         $content = str_replace('&nbsp;', '&#160;', $content);
         $content = preg_replace('/[^\\x{0009}\\x{000a}\\x{000d}\\x{0020}-\\x{D7FF}\\x{E000}-\\x{FFFD}]+/u', null, $content);
         $matches = array();
         preg_match_all('/<(category|entry|subcategory)[^>]*id="(\\d{1,})"/', $content, $matches);
         try {
             $cid = SPFactory::db()->insert('spdb_view_cache', $request, false, true)->insertid();
             $relations = array(SPRequest::sid() => array('cid' => $cid, 'sid' => SPRequest::sid()));
             if (isset($matches[2])) {
                 $ids = array_unique($matches[2]);
                 foreach ($ids as $sid) {
                     $relations[$sid] = array('cid' => $cid, 'sid' => $sid);
                 }
             }
             SPFactory::db()->insertArray('spdb_view_cache_relation', $relations);
             SPFs::write($filePath, $content);
         } catch (SPException $x) {
             Sobi::Error('XML-Cache', $x->getMessage());
         }
     }
 }
开发者ID:pelloq1,项目名称:SobiPro,代码行数:56,代码来源:cache.php

示例14: visible

 /**
  */
 public function visible()
 {
     $type = $this->_model->get('oType');
     if (Sobi::Can($type, 'access', '*')) {
         return true;
     }
     $error = false;
     $owner = $this->_model->get('owner');
     $state = $this->_model->get('state');
     Sobi::Trigger($type, 'CheckVisibility', array(&$state, &$owner));
     /* if it's unpublished */
     if (!$state) {
         if ($owner == Sobi::My('id')) {
             if (!Sobi::Can($type, 'access', 'unpublished_own')) {
                 $error = true;
             }
         } else {
             if (!Sobi::Can($type, 'access', 'unpublished_any')) {
                 $error = true;
             }
         }
     } else {
         if (!Sobi::Can($type, 'access', 'valid')) {
             $error = true;
         }
     }
     /** if not approved */
     /** and unapproved entry can be accessed
      * because then the previously created version
      * should be displayed
      */
     if ($type == 'category') {
         $approved = $this->_model->get('approved');
         if (!$approved) {
             if (!Sobi::Can($type, 'access', 'unapproved_any')) {
                 $error = true;
             }
         }
     }
     /* if it's expired or not valid yet  */
     $va = $this->_model->get('validUntil');
     $va = $va ? strtotime($va . ' UTC') : 0;
     if (!$error) {
         if (strtotime($this->_model->get('validSince') . ' UTC') > gmdate('U')) {
             if ($owner == Sobi::My('id')) {
                 if (!Sobi::Can($type, 'access', 'unpublished_own')) {
                     $error = true;
                 }
             } else {
                 if (!Sobi::Can($type, 'access', 'unpublished_any')) {
                     $error = true;
                 }
             }
         } elseif ($va > 0 && $va < gmdate('U')) {
             if ($owner == Sobi::My('id')) {
                 if (!Sobi::Can($type, 'access', 'unpublished_own')) {
                     $error = true;
                 }
             } else {
                 if (!Sobi::Can($type, 'access', 'unpublished_any')) {
                     $error = true;
                 }
             }
         }
     }
     if ($error) {
         $redirect = Sobi::Cfg('redirects.' . $type . '_access_url', null);
         if (Sobi::Cfg('redirects.' . $type . '_access_enabled', false) && strlen($redirect)) {
             $this->escape($redirect, Sobi::Cfg('redirects.' . $type . '_access_msg', SPLang::e('UNAUTHORIZED_ACCESS', SPRequest::task())), Sobi::Cfg('redirects.' . $type . '_access_msgtype', 'message'));
             exit;
         } else {
             Sobi::Error($this->name(), SPLang::e('UNAUTHORIZED_ACCESS', SPRequest::task()), SPC::ERROR, 403, __LINE__, __FILE__);
         }
     }
 }
开发者ID:pelloq1,项目名称:SobiPro,代码行数:77,代码来源:controller.php

示例15: isCheckedOut

 /**
  * @return bool
  */
 public function isCheckedOut()
 {
     if ($this->cout && $this->cout != Sobi::My('id') && strtotime($this->coutTime) > time()) {
         return true;
     } else {
         return false;
     }
 }
开发者ID:kishoreweblabs,项目名称:SobiPro,代码行数:11,代码来源:dbobject.php


注:本文中的Sobi::My方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。