예제 #1
0
function save_website($datas)
{
    global $templatesList;
    load_lib();
    //Etape 1 : sauvegarde du site
    require_once MODELS . DS . 'website.php';
    $websiteModel = new Website();
    $templateId = $datas['template_id'];
    $template = $templatesList[$templateId];
    $datas['tpl_layout'] = $template['layout'];
    $datas['tpl_code'] = $template['code'];
    $datas['search_engine_position'] = 'header';
    $datas['created_by'] = 1;
    $datas['modified_by'] = 1;
    $datas['online'] = 1;
    $websiteModel->save($datas);
    define('CURRENT_WEBSITE_ID', $websiteModel->id);
    //Etape 2 : sauvegarde du menu racine
    require_once MODELS . DS . 'category.php';
    $categoryModel = new Category();
    unset($categoryModel->searches_params);
    ////////////////////////////////////////////////////////
    //   INITIALISATION DE LA CATEGORIE PARENTE DU SITE   //
    $categorie = array('parent_id' => 0, 'type' => 3, 'name' => 'Racine Site ' . $websiteModel->id, 'slug' => 'racine-site-' . $websiteModel->id, 'online' => 1, 'redirect_category_id' => 0, 'display_contact_form' => 0, 'website_id' => $websiteModel->id);
    $categoryModel->save($categorie);
    return $websiteModel->id + $categoryModel->id;
}
 public function create()
 {
     $website = new Website();
     if ($this->post) {
         $website->name = $this->PostData('name');
         $website->description = $this->PostData('description');
         $website->url = $this->PostData('url');
         $website->loginurl = $this->PostData('loginurl');
         $website->triggerurl = $this->PostData('triggerurl');
         $website->code = $this->PostData('code');
         if ($website->save()) {
             Site::flash('notice', 'The site has been created');
             Redirect('admin/sites');
         }
     }
     $this->assign('website', $website);
     $this->title = 'New Site';
     $this->render('website/create.tpl');
 }
예제 #3
0
 /**
  * @before _secure, memberLayout
  */
 public function add()
 {
     $this->seo(array("title" => "Create a Trigger for your website", "view" => $this->getLayoutView()));
     $view = $this->getActionView();
     if (RequestMethods::post('action') == 'addWebsite') {
         $name = RequestMethods::post('name');
         $url = RequestMethods::post('url');
         $url = preg_replace('/^https?:\\/\\//', '', $url);
         $url = rtrim($url, "/");
         // Check if the domain already exists
         $website = Website::first(array("url = ?" => $url));
         if ($website) {
             $view->set("message", "Website Already exists");
         } else {
             $doc = array("title" => $name, "url" => $url, "user_id" => (int) $this->user->id, "live" => true);
             $website = new Website($doc);
             $website->save();
             $collection = Registry::get("MongoDB")->selectCollection("website");
             $collection->insert(array_merge($doc, array('website_id' => (int) $website->id)));
             $view->set("message", "Website Added Successfully");
         }
     }
 }
예제 #4
0
 public function createWebsite()
 {
     $user_id = Auth::user()->id;
     $rules = array('title' => 'required', 'type' => 'required', 'account_id' => 'required');
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         return Redirect::to('/websites/new')->withErrors($validator)->withInput();
     } else {
         $client = new GuzzleHttp\Client();
         $title = Input::get('title');
         $tagline = Input::get('tagline');
         $about = Input::get('about');
         $type = Input::get('type');
         $account_id = Input::get('account_id');
         $domain_name = Input::get('domain_name');
         $is_public = 0;
         if (Input::has('public')) {
             $is_public = 1;
         }
         $website = new Website();
         $website->user_id = $user_id;
         $website->long_id = Str::slug(substr($title, 0, 160) . '-' . str_random(6));
         $website->type = $type;
         $website->domain_name = $domain_name;
         $website->title = $title;
         $website->tagline = $tagline;
         $website->about = $about;
         $website->public = $is_public;
         $website->save();
         $website_id = $website->id;
         if ($type == 'youtube') {
             $youtube = new Youtube(array('key' => Config::get('keys.youtube')));
             $youtube_channel = $youtube->getChannelByName($account_id);
             $site_channel_id = $youtube_channel->id;
             $site_channel_title = $youtube_channel->snippet->title;
             $site_channel_description = $youtube_channel->snippet->description;
             $site_channel_thumbnail = $youtube_channel->snippet->thumbnails->high->url;
         } else {
             if ($type == 'vimeo') {
                 $vimeo = $client->get("http://vimeo.com/api/v2/{$account_id}/info.json");
                 $vimeo_channel = json_decode($vimeo->getBody(), true);
                 $site_channel_id = $vimeo_channel['id'];
                 $site_channel_title = $vimeo_channel['display_name'];
                 $site_channel_description = strip_tags($vimeo_channel['bio']);
                 $site_channel_thumbnail = $vimeo_channel['portrait_huge'];
             }
         }
         $channel = new Channel();
         $channel->user_id = $user_id;
         $channel->website_id = $website_id;
         $channel->channel_id = $site_channel_id;
         $channel->title = $site_channel_title;
         $channel->description = $site_channel_description;
         $channel->thumbnail = $site_channel_thumbnail;
         $channel->save();
         $channel_id = $channel->id;
         $next_playlisttoken = '';
         if ($type == 'youtube') {
             do {
                 $playlists = $youtube->getPlaylistsByChannelId($youtube_channel->id, array('maxResults' => 50, 'pageToken' => $next_playlisttoken));
                 $next_playlisttoken = $youtube->page_info;
                 if (!empty($playlists)) {
                     foreach ($playlists as $pl) {
                         //only cached playlists that are public
                         if ($pl->status->privacyStatus == 'public') {
                             $playlist_id = $pl->id;
                             $playlist_params['body'] = array('id' => $playlist_id, 'user_id' => $user_id, 'website_id' => $website_id, 'channel_id' => $channel_id, 'title' => $pl->snippet->title, 'playlist_type' => 'youtube', 'description' => $pl->snippet->description, 'thumbnail' => $pl->snippet->thumbnails->high->url, 'published_at' => $pl->snippet->publishedAt);
                             $playlist_params['index'] = 'video-websites';
                             $playlist_params['type'] = 'playlist';
                             $playlist_params['id'] = $playlist_id;
                             $ret = Es::index($playlist_params);
                             $next_videostoken = '';
                             do {
                                 $playlist_items = $youtube->getPlaylistItemsByPlaylistId($playlist_id, array('maxResults' => 50, 'pageToken' => $next_videostoken));
                                 $next_videostoken = $youtube->page_info;
                                 if (!empty($playlist_items)) {
                                     foreach ($playlist_items as $video) {
                                         if ($video->status->privacyStatus == 'public') {
                                             $video_id = $video->id;
                                             $video_params['body'] = array('id' => $video_id, 'video_id' => $video->contentDetails->videoId, 'user_id' => $user_id, 'website_id' => $website_id, 'channel_id' => $channel_id, 'playlist_id' => $playlist_id, 'video_type' => 'youtube', 'position' => $video->snippet->position, 'title' => $video->snippet->title, 'description' => $video->snippet->description, 'thumbnails' => array('small' => $video->snippet->thumbnails->default->url, 'medium' => $video->snippet->thumbnails->medium->url, 'large' => $video->snippet->thumbnails->high->url), 'published_at' => $video->snippet->publishedAt);
                                             $video_params['index'] = 'video-websites';
                                             $video_params['type'] = 'video';
                                             $video_params['id'] = $video_id;
                                             $ret = Es::index($video_params);
                                         }
                                     }
                                 }
                             } while (is_string($next_videostoken));
                         }
                     }
                 }
             } while (is_string($next_playlisttoken));
         } else {
             if ($type == 'vimeo') {
                 $playlists_response = $client->get("http://vimeo.com/api/v2/{$account_id}/channels.json");
                 $playlists = json_decode($playlists_response->getBody(), true);
                 if (!empty($playlists)) {
                     foreach ($playlists as $pl) {
                         $playlist_id = $pl['id'];
                         $playlist_params['body'] = array('id' => $playlist_id, 'user_id' => $user_id, 'website_id' => $website_id, 'channel_id' => $channel_id, 'title' => $pl['name'], 'playlist_type' => 'vimeo', 'description' => $pl['description'], 'thumbnail' => $pl['logo'], 'published_at' => $pl['created_on']);
                         $playlist_params['index'] = 'video-websites';
                         $playlist_params['type'] = 'playlist';
                         $playlist_params['id'] = $playlist_id;
                         $ret = Es::index($playlist_params);
                         $video_page = 1;
                         $video_index = 0;
                         do {
                             $videos_response = $client->get("http://vimeo.com/api/v2/{$playlist_id}/videos.json?page={$video_page}");
                             $videos = json_decode($videos_response->getBody(), true);
                             if (!empty($videos)) {
                                 foreach ($videos as $video) {
                                     if ($video['embed_privacy'] == 'anywhere') {
                                         $video_id = $video['id'];
                                         $video_params['body'] = array('id' => $video_id, 'video_id' => $video_id, 'user_id' => $user_id, 'website_id' => $website_id, 'channel_id' => $channel_id, 'playlist_id' => $playlist_id, 'video_type' => 'vimeo', 'position' => $video_index, 'title' => $video['title'], 'description' => strip_tags($video['description']), 'thumbnails' => array('small' => $video['thumbnail_small'], 'medium' => $video['thumbnail_medium'], 'large' => $video['thumbnail_large']), 'published_at' => date('Y-m-d', strtotime($video['upload_date'])));
                                         $video_params['index'] = 'video-websites';
                                         $video_params['type'] = 'video';
                                         $video_params['id'] = $video_id;
                                         $ret = Es::index($video_params);
                                     }
                                     $video_index += 1;
                                 }
                             }
                             $video_page += 1;
                         } while (!empty($videos) && $video_page <= 3);
                     }
                 } else {
                     $video_page = 1;
                     $video_index = 0;
                     do {
                         $allvideos_response = $client->get("http://vimeo.com/api/v2/{$account_id}/all_videos.json?page={$video_page}");
                         $videos = json_decode($allvideos_response->getBody(), true);
                         if (!empty($videos)) {
                             foreach ($videos as $video) {
                                 if ($video['embed_privacy'] == 'anywhere') {
                                     $video_id = $video['id'];
                                     $video_params['body'] = array('id' => $video_id, 'video_id' => $video_id, 'user_id' => $user_id, 'website_id' => $website_id, 'channel_id' => $channel_id, 'video_type' => 'vimeo', 'position' => $video_index, 'title' => $video['title'], 'description' => strip_tags($video['description']), 'thumbnails' => array('small' => $video['thumbnail_small'], 'medium' => $video['thumbnail_medium'], 'large' => $video['thumbnail_large']), 'published_at' => date('Y-m-d', strtotime($video['upload_date'])));
                                     $video_params['index'] = 'video-websites';
                                     $video_params['type'] = 'video';
                                     $video_params['id'] = $video_id;
                                     $ret = Es::index($video_params);
                                 }
                                 $video_index += 1;
                             }
                         }
                         $video_page += 1;
                     } while (!empty($videos) && $video_page <= 3);
                 }
             }
         }
         return Redirect::to('/websites/new')->with('message', array('type' => 'success', 'text' => 'You have successfully created a website!'));
     }
 }
예제 #5
0
파일: init_data.php 프로젝트: kotow/work
function InitData($project_name)
{
    $listPageType = 'list_types';
    $c = new Criteria();
    $c->add(ListsPeer::LIST_ID, $listPageType);
    $listExist = ListsPeer::doSelectOne($c);
    if (!$listExist) {
        echo "Creating list 'list_type'...\n";
        $newList = new Lists();
        $newList->setLabel('List Types');
        $newList->setListid($listPageType);
        $newList->setListtype('system');
        $newList->save();
        $newItem = new Listitem();
        $newItem->setLabel('System list');
        $newItem->setValue('system');
        $newItem->save(null, $newList);
        $newItem = new Listitem();
        $newItem->setLabel('Static list');
        $newItem->setValue('static');
        $newItem->save(null, $newList);
        $newItem = new Listitem();
        $newItem->setLabel('Editable list');
        $newItem->setValue('editable');
        $newItem->save(null, $newList);
    }
    $listPageType = 'page_types';
    $c = new Criteria();
    $c->add(ListsPeer::LIST_ID, $listPageType);
    $listExist = ListsPeer::doSelectOne($c);
    if (!$listExist) {
        echo "Creating list 'page_types'...\n";
        $newList = new Lists();
        $newList->setLabel('Page Types');
        $newList->setListid($listPageType);
        $newList->setListtype('system');
        $newList->save();
        $newItem = new Listitem();
        $newItem->setLabel('Content page');
        $newItem->setValue('CONTENT');
        $newItem->save(null, $newList);
        $newItem = new Listitem();
        $newItem->setLabel('Page reference');
        $newItem->setValue('REFERENCE');
        $newItem->save(null, $newList);
        $newItem = new Listitem();
        $newItem->setLabel('External page');
        $newItem->setValue('EXTERNAL');
        $newItem->save(null, $newList);
    }
    $cultureType = 'culture';
    $c = new Criteria();
    $c->add(ListsPeer::LIST_ID, $cultureType);
    $listExist = ListsPeer::doSelectOne($c);
    if (!$listExist) {
        echo "Creating list 'culture'...\n";
        $newList = new Lists();
        $newList->setLabel('Culture');
        $newList->setListid($cultureType);
        $newList->setListtype('system');
        $newList->save();
        $newItem = new Listitem();
        $newItem->setLabel('english');
        $newItem->setValue('en');
        $newItem->save(null, $newList);
        /*		$newItem = new Listitem();
        		$newItem->setLabel('български');
        		$newItem->setValue('bg');
        		$newItem->save(null, $newList);*/
    }
    $userType = 'usertype';
    $c = new Criteria();
    $c->add(ListsPeer::LIST_ID, $userType);
    $listExist = ListsPeer::doSelectOne($c);
    if (!$listExist) {
        echo "Creating list 'user types'...\n";
        $newList = new Lists();
        $newList->setLabel('User Types');
        $newList->setListid($userType);
        $newList->setListtype('system');
        $newList->save();
        $newItem = new Listitem();
        $newItem->setLabel('Administrator (all rights)');
        $newItem->setValue('admin');
        $newItem->save(null, $newList);
        $newItem = new Listitem();
        $newItem->setLabel('Editor (no access to administration modules)');
        $newItem->setValue('editor');
        $newItem->save(null, $newList);
        $newItem = new Listitem();
        $newItem->setLabel('Editor (edit and save existing items)');
        $newItem->setValue('restricted_editor');
        $newItem->save(null, $newList);
    }
    $Mailinglist_Folder = Document::getDocumentByExclusiveTag('newsletter_folder_mailinglist');
    if (!$Mailinglist_Folder) {
        $Newsletter_Root = Rootfolder::getRootfolderByModule('Newsletter');
        $Mailinglist_Folder = new Folder();
        $Mailinglist_Folder->setLabel('Mailing lists');
        $Mailinglist_Folder->save(null, $Newsletter_Root);
        Document::addTag($Mailinglist_Folder, 'newsletter_folder_mailinglist');
    }
    $def_site = Document::getDocumentByExclusiveTag('website_website_default');
    if (!$def_site) {
        $website_root = Rootfolder::getRootfolderByModule('Website');
        $def_site = new Website();
        $def_site->setLabel(UtilsHelper::mb_ucfirst($project_name));
        $def_site->save(null, $website_root);
        Document::addTag($def_site, 'website_website_default');
    }
    $homePage = Document::getDocumentByExclusiveTag('website_page_home');
    if (!$homePage) {
        $homePage = new Page();
        $homePage->setLabel('Home');
        $homePage->setPageType('CONTENT');
        $homePage->setNavigationTitle('Home');
        $homePage->setTemplate('default');
        $homePage->save(null, $def_site);
        Document::addTag($homePage, 'website_page_home');
    }
}
예제 #6
0
            $websites = Website::where('environmentId', '=', $environmentId)->get();
            $response = array();
            $response['success'] = 1;
            $response['websites'] = $websites->toArray();
            echo json_encode($response);
        }
    }
});
$app->post('/website', function () {
    session_start();
    session_regenerate_id();
    if (isset($_SESSION['userId'])) {
        $url = $_POST['url'];
        $environmentId = $_POST['environmentId'];
        $website = new Website(array('userId' => $_SESSION['userId'], 'domainName' => $url, 'environmentId' => $environmentId));
        $website->save();
        $response['success'] = 1;
        $response['website'] = $website->toArray();
        echo json_encode($response);
    } else {
        echo json_encode(array('success' => 0));
    }
});
$app->post('/task-goal', function () {
    session_start();
    session_regenerate_id();
    if (isset($_SESSION['userId'])) {
        $userId = $_SESSION['userId'];
        $name = $_POST['name'];
        $startDate = $_POST['startDate'];
        $endDate = $_POST['endDate'];