Exemple #1
0
 static function GetTrail($start = null)
 {
     $obj = utopia::GetInstance('uCMS_List');
     $arr = $obj->GetNestedArray();
     $out = array();
     //TODO: add (Search Results) to end of title if current page is filtered.
     $out[$_SERVER['REQUEST_URI']] = '{utopia.title}';
     // '<a href="'.$_SERVER['REQUEST_URI'].'">{utopia.title}</a>';
     foreach (self::$extras as $a) {
         $out[$a[1]] = $a[0];
         //'<a href="'.$a[1].'">'.$a[0].'</a>';
     }
     $obj = utopia::GetInstance('uCMS_View');
     $row = uCMS_View::findPage();
     do {
         if (!$row) {
             break;
         }
         $url = $obj->GetURL($row['cms_id']);
         $title = $row['nav_text'] ? $row['nav_text'] : $row['title'];
         $out[$url] = $title;
     } while ($row['parent'] && ($row = uCMS_List::findKey($arr, $row['parent'])));
     $build = array();
     foreach ($out as $k => $v) {
         $build[] = '<a href="' . $k . '">' . $v . '</a>';
     }
     $build = array_unique($build);
     if ($start) {
         $build[] = $start;
     }
     if (count($build) < 1) {
         return '';
     }
     return implode(' &gt; ', array_reverse($build));
 }
Exemple #2
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;
 }