Пример #1
0
 public static function ShowNotices()
 {
     // is redirect issued?  If so, don't draw now.
     foreach (headers_list() as $h) {
         if (preg_match('/^location:/i', $h)) {
             return;
         }
     }
     if (!utopia::UsingTemplate() && !AjaxEcho()) {
         return;
     }
     if (!isset($_SESSION['notices'])) {
         return;
     }
     $scripts = implode(PHP_EOL, $_SESSION['notices']);
     $_SESSION['notices'] = array();
     if (!AjaxEcho($scripts)) {
         uJavascript::AddText('$(function(){' . $scripts . '});');
     }
 }
Пример #2
0
 public function UpdateField($fieldAlias, $newValue, &$pkVal = NULL)
 {
     $oldPkVal = $pkVal;
     $ret = parent::UpdateField($fieldAlias, $newValue, $pkVal);
     if ($ret === NULL) {
         AjaxEcho("window.location.reload(false);");
     } elseif ($oldPkVal !== $pkVal) {
         // updated PK
         $filters = $_GET;
         unset($filters['_n_' . $this->GetModuleId()]);
         $f = $this->FindFilter($this->GetPrimaryKey());
         if ($f) {
             $filters['_f_' . $f['uid']] = $pkVal;
         } else {
             $filters[$this->GetPrimaryKey()] = $filters;
         }
         $url = $this->GetURL($filters);
         AjaxEcho("window.location.replace('{$url}');");
     }
     return $ret;
 }
Пример #3
0
function ErrorLog($text)
{
    return;
    AjaxEcho('ErrorLog("' . addcslashes(str_replace("\n", '', $text), '"') . '")');
    if (utopia::UsingTemplate()) {
        echo $text;
    }
    $cLog = utopia::GetVar('error_log');
    if (array_key_exists('__ajax', $_REQUEST)) {
        if (!empty($cLog)) {
            utopia::AppendVar('error_log', "\n");
        }
        utopia::AppendVar('error_log', 'ErrorLog("' . $text . '");');
    } else {
        if (!empty($cLog)) {
            utopia::AppendVar('error_log', '<br/>');
        }
        utopia::AppendVar('error_log', '<span><b>*</b> ' . $text . '</span>');
        //    utopia::AppendVar('error_log','<span style="color:#EE3333; border-style:solid; border-width:1px; background-color:#DDDDDD; padding:3px">'.$text.'</span>');
    }
}
Пример #4
0
 static function AjaxUpdateElement($eleName, $html)
 {
     if (is_object($html)) {
         return;
     }
     $enc = base64_encode($html);
     AjaxEcho('utopia.RedrawField("' . $eleName . '","' . $enc . '")');
 }
Пример #5
0
 public function UpdateField($fieldAlias, $newValue, &$pkVal = NULL)
 {
     $rec = $this->LookupRecord($pkVal);
     $this->InitInstance($rec['block_type']);
     $ret = parent::UpdateField($fieldAlias, $newValue, $pkVal);
     if ($fieldAlias == 'block_type') {
         AjaxEcho("window.location.reload(false);");
     }
     return $ret;
 }
Пример #6
0
 public function UpdateField($fieldAlias, $newValue, &$pkVal = NULL)
 {
     if ($fieldAlias == 'cms_id' && !$newValue) {
         return;
     }
     if ($pkVal == NULL && $fieldAlias == 'title') {
         $this->UpdateField('cms_id', UrlReadable($newValue), $pkVal);
     }
     if ($fieldAlias == 'revert') {
         $rec = $this->LookupRecord($pkVal);
         $this->UpdateField('content', $rec['content_published'], $pkVal);
         $this->UpdateFieldRaw('content_published_time', '`content_time`', $pkVal);
         AjaxEcho('window.location.reload();');
         return;
     }
     if ($fieldAlias == 'publish') {
         $rec = $this->LookupRecord($pkVal);
         $this->UpdateField('content_published', $rec['content'], $pkVal);
         return;
     }
     if ($fieldAlias == 'unpublish') {
         $this->UpdateField('is_published', 0, $pkVal);
         $this->UpdateField('content_published_time', null, $pkVal);
         return;
     }
     if ($fieldAlias == 'cms_id') {
         $newValue = UrlReadable($newValue);
         // also update children's "parent" to this value
         if ($pkVal !== NULL) {
             $dataset = $this->GetDataset(array('parent' => $pkVal), true);
             while ($child = $dataset->fetch()) {
                 $this->UpdateField('parent', $newValue, $child['cms_id']);
             }
         }
     }
     if (substr($fieldAlias, 0, 8) == 'content:') {
         $rec = $this->LookupRecord($pkVal);
         $contentarr = utopia::jsonTryDecode($rec['content']);
         if (!is_array($contentarr)) {
             $contentarr = array('' => $contentarr);
         }
         $id = substr($fieldAlias, 8);
         if (!$id) {
             $id = '';
         }
         $contentarr[$id] = (string) $newValue;
         $fieldAlias = 'content';
         $newValue = $contentarr;
         $this->SetFieldType('content_time', ftRAW);
         $this->UpdateField('content_time', 'NOW()', $pkVal);
     }
     if ($fieldAlias == 'content_published') {
         $this->SetFieldType('content_published_time', ftRAW);
         $this->UpdateFieldRaw('content_published_time', '`content_time`', $pkVal);
         $this->UpdateField('is_published', 1, $pkVal);
     }
     $oPk = $pkVal;
     $ret = parent::UpdateField($fieldAlias, $newValue, $pkVal);
     if ($pkVal !== $oPk) {
         $o = utopia::GetInstance('uCMS_View');
         $url = $o->GetURL(array('cms_id' => $pkVal, 'edit' => 1));
         AjaxEcho("window.location.replace('{$url}');");
     }
     // update cms list to reflect published status
     uCMS_List::RefreshList();
     return $ret;
 }
Пример #7
0
 public static function checkLogin($object)
 {
     if (flag_is_set($object->GetOptions(), PERSISTENT)) {
         return;
     }
     if (uEvents::TriggerEvent('CanAccessModule', $object) !== FALSE) {
         return;
     }
     if (self::IsLoggedIn()) {
         uNotices::AddNotice('Sorry, you do not have access to this feature.', NOTICE_TYPE_WARNING);
         return FALSE;
     }
     $parent = get_class($object);
     if ($parent == utopia::GetCurrentModule() && $parent !== __CLASS__ && !AjaxEcho('window.location.reload();')) {
         utopia::QueueLauncher(__CLASS__);
         //$obj = utopia::GetInstance(__CLASS__);
         //$obj->_RunModule();
     }
     return FALSE;
 }