コード例 #1
0
 function index()
 {
     list($params, $id) = $this->parse_params(func_get_args());
     $theme = new Theme();
     $themes = $theme->read(true);
     if ($this->method == 'post' && isset($_POST['theme'])) {
         $t = $_POST['theme'];
         if (isset($themes[$t])) {
             $d = new Draft();
             $d->where('draft', 1)->update('draft', 0);
             $d->where('path', $t)->get();
             $d->path = $t;
             $d->draft = 1;
             if (isset($_POST['refresh'])) {
                 $d->init_draft_nav($_POST['refresh']);
             }
             $d->save();
             $this->redirect('/drafts');
         } else {
             // error
         }
     } else {
         if ($this->method == 'delete' && isset($_POST['theme'])) {
             $d = new Draft();
             $d->where('path', $_POST['theme'])->get();
             if ($d->exists()) {
                 $d->delete();
             }
             exit;
         }
     }
     $final = array();
     $d = new Draft();
     $drafts = $d->get_iterated();
     foreach ($drafts as $d) {
         if (isset($themes[$d->path])) {
             $final[] = array('id' => $d->id, 'theme' => $themes[$d->path], 'published' => (bool) $d->current, 'active' => (bool) $d->draft, 'created_on' => (int) $d->created_on, 'modified_on' => (int) $d->modified_on);
         }
     }
     $this->set_response_data($final);
 }
コード例 #2
0
ファイル: koken.php プロジェクト: Atomox/benhelmerphotography
 public function form_urls()
 {
     if ($this->urls) {
         return $this->urls;
     }
     $d = new Draft();
     $context = defined('DRAFT_CONTEXT') ? DRAFT_CONTEXT : false;
     $path = '';
     if (!$context) {
         $d->where('current', 1)->get();
         $path = $d->path;
     } else {
         if (is_numeric(DRAFT_CONTEXT)) {
             $d->get_by_id(DRAFT_CONTEXT);
             $path = $d->path;
         } else {
             $path = DRAFT_CONTEXT;
         }
     }
     list($this->urls, $this->url_data, , $this->segments) = $d->setup_urls(FCPATH . 'storage' . DIRECTORY_SEPARATOR . 'themes' . DIRECTORY_SEPARATOR . $path . DIRECTORY_SEPARATOR);
     return $this->urls;
 }
コード例 #3
0
ファイル: sites.php プロジェクト: Caldis/htdocs
 function publish($draft_id = false)
 {
     if (!$draft_id) {
         $this->error('400', 'Draft ID parameter not present.');
         return;
     }
     if ($this->method === 'post') {
         $draft = new Draft();
         $draft->where('id', $draft_id)->get();
         if ($draft->exists()) {
             $draft->where('current', 1)->update('current', 0);
             $draft->live_data = $draft->data;
             $draft->current = 1;
             $draft->save();
             $guid = FCPATH . 'storage' . DIRECTORY_SEPARATOR . 'themes' . DIRECTORY_SEPARATOR . $draft->path . DIRECTORY_SEPARATOR . 'koken.guid';
             if (file_exists($guid)) {
                 $s = new Setting();
                 $s->where('name', 'uuid')->get();
                 $curl = curl_init();
                 curl_setopt($curl, CURLOPT_URL, KOKEN_STORE_URL . '/register?uuid=' . $s->value . '&theme=' . trim(file_get_contents($guid)));
                 curl_setopt($curl, CURLOPT_HEADER, 0);
                 curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 10);
                 curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
                 curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
                 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
                 $r = curl_exec($curl);
                 curl_close($curl);
             }
             exit;
         } else {
             $this->error('404', "Draft not found.");
             return;
         }
     } else {
         $this->error('400', 'This endpoint only accepts tokenized POST requests.');
         return;
     }
 }
コード例 #4
0
ファイル: draft.php プロジェクト: Atomox/benhelmerphotography
 function init_draft_nav($refresh = true)
 {
     if ($refresh === 'nav') {
         $this->data = json_decode($this->data, true);
     } else {
         $this->data = array();
     }
     $ds = DIRECTORY_SEPARATOR;
     $template_path = FCPATH . 'storage' . $ds . 'themes' . $ds;
     $theme_root = $template_path . $this->path . $ds;
     $template_info = json_decode(file_get_contents($theme_root . 'info.json'), true);
     list($urls, $data, $routes) = $this->setup_urls($theme_root);
     $this->data['navigation'] = array('items' => array());
     $this->data['navigation']['groups'] = $groups = array();
     $defaults = array('timeline', 'albums', 'contents', 'essays');
     $used_autos = array();
     $user = new User();
     $user->get();
     $front = array('auto' => 'home', 'front' => true);
     if (isset($template_info['default_front_page']) && in_array($template_info['default_front_page'], array('timeline', 'albums', 'contents', 'essays', 'archives')) && isset($urls[$template_info['default_front_page']])) {
         $defaults = array_diff($defaults, array($template_info['default_front_page']));
         $front['path'] = $urls[$template_info['default_front_page']];
         $front['auto'] = $template_info['default_front_page'];
         $used_autos[] = $template_info['default_front_page'];
     } else {
         $front['path'] = '/home/';
     }
     $this->data['navigation']['items'][] = $front;
     foreach ($defaults as $default) {
         if (file_exists($theme_root . $default . '.lens')) {
             $used_autos[] = $default;
             $this->data['navigation']['items'][] = array('auto' => $default);
         }
     }
     if (isset($template_info['navigation_groups'])) {
         foreach ($template_info['navigation_groups'] as $key => $info) {
             $items = array();
             if (isset($info['defaults'])) {
                 foreach ($info['defaults'] as $def) {
                     if (is_array($def)) {
                         $def['path'] = $def['url'];
                         unset($def['url']);
                         $items[] = $def;
                     } else {
                         if ($def === 'front') {
                             $items[] = $front;
                         } else {
                             if (in_array($def, array('twitter', 'facebook', 'gplus'))) {
                                 $def = $def === 'gplus' ? 'google' : $def;
                                 if (!empty($user->{$def})) {
                                     $items[] = array('auto' => 'profile', 'id' => $def);
                                 }
                             } else {
                                 if (file_exists($theme_root . $def . '.lens')) {
                                     $items[] = array('auto' => $def);
                                 }
                             }
                         }
                     }
                 }
             }
             $this->data['navigation']['groups'][] = array('key' => $key, 'label' => $info['label'], 'items' => $items);
         }
     }
     if ($refresh === 'nav') {
         $this->data['routes'] = $routes;
     } else {
         $p = new Draft();
         $p->where('current', 1)->get();
         $pub_data = json_decode($p->live_data, true);
         foreach ($pub_data['navigation']['items'] as $item) {
             if ((!isset($item['front']) || !$item['front']) && !in_array($item, $this->data['navigation']['items']) && (isset($item['custom']) || isset($item['auto']) && isset($urls[$item['auto']]) && !in_array($item['auto'], $used_autos))) {
                 $this->data['navigation']['items'][] = $item;
             }
         }
     }
     $this->data = json_encode($this->data);
 }
コード例 #5
0
 public function fetchDraftText($msg_id)
 {
     $thisMessage = Draft::where('id', '=', $msg_id)->first();
     $thisMessageText = $thisMessage->message;
     return $thisMessageText;
 }