コード例 #1
0
 /**
  *	Instantiate a search page, should one not exist.
  */
 public function requireDefaultRecords()
 {
     parent::requireDefaultRecords();
     $mode = Versioned::get_reading_mode();
     Versioned::reading_stage('Stage');
     // Determine whether pages should be created.
     if (self::config()->create_default_pages) {
         // Determine whether an extensible search page already exists.
         if (!ExtensibleSearchPage::get()->first()) {
             // Instantiate an extensible search page.
             $page = ExtensibleSearchPage::create();
             $page->Title = 'Search Page';
             $page->write();
             DB::alteration_message('"Default" Extensible Search Page', 'created');
         }
     } else {
         if (ClassInfo::exists('Multisites')) {
             foreach (Site::get() as $site) {
                 // Determine whether an extensible search page already exists.
                 if (!ExtensibleSearchPage::get()->filter('SiteID', $site->ID)->first()) {
                     // Instantiate an extensible search page.
                     $page = ExtensibleSearchPage::create();
                     $page->ParentID = $site->ID;
                     $page->Title = 'Search Page';
                     $page->write();
                     DB::alteration_message("\"{$site->Title}\" Extensible Search Page", 'created');
                 }
             }
         }
     }
     Versioned::set_reading_mode($mode);
 }
コード例 #2
0
 /**
  * Create default blog setup
  */
 function requireDefaultRecords()
 {
     parent::requireDefaultRecords();
     if (!DataObject::get_one('UserAgreementPage')) {
         if (class_exists('Site') && ($sites = Site::get())) {
             if ($sites->first()) {
                 foreach ($sites as $site) {
                     $page = new UserAgreementPage();
                     $page->Title = "User Agreement";
                     $page->URLSegment = "user-agreement";
                     $page->Status = "Published";
                     $page->ShowInMenus = 0;
                     $page->ParentID = $site->ID;
                     $page->write();
                     $page->publish("Stage", "Live");
                     DB::alteration_message("User Agreement Page Created", "created");
                 }
             }
         } else {
             $page = new UserAgreementPage();
             $page->Title = "User Agreement";
             $page->URLSegment = "user-agreement";
             $page->Status = "Published";
             $page->ShowInMenus = 0;
             $page->write();
             $page->publish("Stage", "Live");
             DB::alteration_message("User Agreement Page Created", "created");
         }
     }
 }
コード例 #3
0
ファイル: DataApplication.php プロジェクト: diasbruno/stc
 /**
  * @constructor
  */
 public function __construct($data_folder = '')
 {
     // load the config file.
     $this->config = new Config();
     $this->config->load($data_folder);
     // load the templates.
     $this->templates = new Templates();
     $this->templates->load($data_folder);
     // loading data files.
     $this->files = new Files();
     $this->files->load($data_folder, $this->config->get('pages_data'));
     // initialize database.
     $this->db = new Database();
     //
     $this->renders = new Renders();
 }
 public static function getSiteParameterField()
 {
     $source = Site::get()->map('ID', 'Title')->toArray();
     $source = array('0' => 'All') + $source;
     // works around ajax bug
     return DropdownField::create('Site', 'Site', $source)->setHasEmptyDefault(false);
 }
 /**
  * Adds a dropdown field to the search form to filter searches by Site
  **/
 public function updateSearchForm(Form $form)
 {
     $cms = $this->owner;
     $req = $cms->getRequest();
     $sites = Site::get()->sort(array('IsDefault' => 'DESC', 'Title' => 'ASC'));
     $site = new DropdownField('q[SiteID]', _t('Multisites.SITE', 'Site'), $sites->map(), isset($req['q']['SiteID']) ? $req['q']['SiteID'] : null);
     $site->setEmptyString(_t('Multisites.ALLSITES', 'All sites'));
     $form->Fields()->insertAfter($site, 'q[Term]');
 }
コード例 #6
0
 /**
  * Provide a Site filter
  **/
 public function updateSearchForm($form)
 {
     if (singleton($this->owner->getList()->dataClass())->hasExtension('MultisitesAware')) {
         $managedSites = Multisites::inst()->sitesManagedByMember();
         $source = Site::get()->filter('ID', Multisites::inst()->sitesManagedByMember())->map('ID', 'Title')->toArray();
         $plural = singleton($this->owner->modelClass)->plural_name();
         if (count($source)) {
             $form->Fields()->push(DropdownField::create('SiteID', "Site: ", $source, Session::get('MultisitesModelAdmin_SiteID')));
         }
     }
 }
 public function index()
 {
     $site = Multisites::inst()->getCurrentSiteId();
     if (!$site) {
         return $this->httpError(404);
     }
     $page = Site::get()->filter(array('ID' => $site));
     $page = $page->first();
     if (!$page) {
         return $this->httpError(404);
     }
     /*
      * Trim the RobotsTxt field because it may be an empty string.
      * and since SilverStripe doesn't ship with a default robots.txt
      * file, we'll want to return a 404 if there isn't any text for
      * the site's robots.txt file.
      */
     $text = trim($page->RobotsTxt);
     if (empty($text)) {
         return $this->httpError(404);
     }
     $this->getResponse()->addHeader('Content-Type', 'text/plain; charset="utf-8"');
     return $text;
 }
コード例 #8
0
 /**
  * Make sure there is a site record.
  */
 public function requireDefaultRecords()
 {
     parent::requireDefaultRecords();
     if (!Site::get()->count()) {
         $site = new Site();
         $site->Title = _t('Multisites.DEFAULTSITE', 'Default Site');
         $site->IsDefault = true;
         $site->write();
         DB::alteration_message('Default site created', 'created');
         $pages = SiteTree::get()->exclude('ID', $site->ID)->filter('ParentID', 0);
         $count = count($pages);
         foreach ($pages as $page) {
             $page->ParentID = $site->ID;
             $page->write();
             if ($page->isPublished()) {
                 $page->publish('Stage', 'Live');
             }
         }
         DB::alteration_message("Moved {$count} existing pages under new default site.", 'changed');
     }
 }
コード例 #9
0
 /**
  * Validates that the environment's connection mode is appropriately set
  *
  * @param Site $site
  * @param Environment $environment
  */
 protected function validateEnvironment($site, $environment)
 {
     $this->validateConnectionMode($environment->get('connection_mode'));
     $this->validateFramework($site->get('framework'));
 }
 public function __construct()
 {
     parent::__construct();
     // Put extension checks into hash maps
     foreach (ClassInfo::subclassesFor('DataObject') as $class) {
         if ($class::has_extension('ElementPageExtension')) {
             $this->_classes_using_elemental[$class] = true;
         }
         if ($class::has_extension('WordpressImportDataExtension')) {
             $this->_classes_using_wordpress_extension[$class] = true;
         }
     }
     // If Elemental is on the base SiteTree or Page type, use the elemental callback by default.
     if (isset($this->_classes_using_elemental['SiteTree']) || isset($this->_classes_using_elemental['Page'])) {
         $this->setContentCallbacks('setElementalContent', 'getElementalContent');
     }
     // Set default root parent ID
     if (class_exists('Multisites') && $this->root_parent_id == 0) {
         $site = null;
         $sites = Site::get()->toArray();
         if (count($sites) == 1) {
             $site = $sites[0];
         } else {
             foreach ($sites as $it) {
                 if ($site->IsDefault) {
                     $site = $it;
                     break;
                 }
             }
         }
         if ($site) {
             $this->root_parent_id = $site->ID;
         }
     }
 }
 /**
  * get the active site for this model admin
  *
  * @return Site
  **/
 public function getActiveSite()
 {
     if ($this->owner->config()->use_active_site_session) {
         return Multisites::inst()->getActiveSite();
     } else {
         if ($this->modelIsMultiSitesAware()) {
             if ($active = Session::get($this->getActiveSiteSessionKey())) {
                 return Site::get()->byID($active);
             }
         }
     }
 }
コード例 #12
0
ファイル: RgController.php プロジェクト: wangfeilong321/myosg
 private function process_rglist_addsc(&$rg_ids, $sc_id)
 {
     $site_ids = array();
     //load all site id under the requested sc
     $model = new Site();
     $sites = $model->get(array("sc_id" => $sc_id, "filter_disabled" => false));
     foreach ($sites as $site) {
         if (!in_array($site->id, $site_ids)) {
             $site_ids[] = $site->id;
         }
     }
     foreach ($site_ids as $site_id) {
         $this->process_rglist_addsite($rg_ids, $site_id);
     }
 }
コード例 #13
0
 private function process_site_filter_disable()
 {
     $sites_to_keep = array();
     $model = new Site();
     $sites = $model->get();
     $disable_value = $_REQUEST["disable_value"];
     foreach ($sites as $site) {
         if ($site->disable == $disable_value) {
             if (!in_array($site->id, $sites_to_keep)) {
                 $sites_to_keep[] = $site->id;
             }
         }
     }
     return $sites_to_keep;
 }
 /**
  * get the active site for this model admin
  *
  * @return Site
  **/
 public function getActiveSite()
 {
     if ($this->owner->config()->use_active_site_session) {
         return Multisites::inst()->getActiveSite();
     } else {
         if ($this->getListDataClass()->hasExtension('MultisitesAware')) {
             if ($active = Session::get($this->getActiveSiteSessionKey())) {
                 return Site::get()->byID($active);
             }
         }
     }
 }
コード例 #15
0
ファイル: SettingsUI.php プロジェクト: Hassanj343/candidats
    public function showSite()
    {
        /* Bail out if the user doesn't have SA permissions. */
        if ($this->_siteID > 1 || $this->_realAccessLevel < ACCESS_LEVEL_DEMO)
        {
            CommonErrors::fatal(COMMONERROR_PERMISSION, $this);
            return;
            //$this->fatal(ERROR_NO_PERMISSION);
        }
        $privledged = true;

        $siteID = $_GET['siteID'];

        $site = new Site($this->_siteID);
        $data = $site->get($siteID);

        if (empty($data))
        {
            CommonErrors::fatal(COMMONERROR_BADINDEX, $this, 'No Site found with selected ID.');
        }
        $this->_template->assign('site_id', $siteID);
        $this->_template->assign('active', $this);
        $this->_template->assign('subActive', '');
        $this->_template->assign('data', $data);
        $this->_template->display('./modules/settings/ShowSite.php');
    }
コード例 #16
0
 public function site($id)
 {
     $site = new Site($this, array("Id" => $id));
     $site->get();
     return $site;
 }
コード例 #17
0
 /**
  * Finds sites that the given member is a "Manager" of
  * A manager is currently defined by a Member who has edit access to a Site Object
  * @var Member $member
  * @return array - Site IDs
  **/
 public function sitesManagedByMember($member = null)
 {
     $member = $member ?: Member::currentUser();
     if (!$member) {
         return array();
     }
     $sites = Site::get();
     if (Permission::check('ADMIN')) {
         return $sites->column('ID');
     }
     $memberGroups = $member->Groups()->column('ID');
     $sites = $sites->filter("EditorGroups.ID:ExactMatch", $memberGroups);
     return $sites->column('ID');
 }
コード例 #18
0
ファイル: Site.php プロジェクト: rasstroen/baby-album
 function processRequest()
 {
     if (isset($_POST['method'])) {
         return $this->execAjaxQuery();
     }
     $www_folder = Config::need('www_folder', '');
     $request_uri = explode('?', $_SERVER['REQUEST_URI']);
     $get_params_string = isset($request_uri[1]) ? $request_uri[1] : '';
     $get_params = array();
     parse_str($get_params_string, $get_params);
     self::$get = $get_params;
     $request_uri = $request_uri[0];
     $request_uri = explode('/', $request_uri);
     $request_uri_array = array();
     foreach ($request_uri as $uripart) {
         $trimmed = trim($uripart);
         if ($trimmed !== '') {
             $request_uri_array[] = $trimmed;
         }
     }
     $cleared_request_uri = implode('/', $request_uri_array);
     if ($www_folder && strpos($cleared_request_uri, $www_folder) === 0) {
         $cleared_request_uri = substr($cleared_request_uri, strlen($www_folder));
         array_shift($request_uri_array);
     }
     self::$request_uri = $cleared_request_uri;
     self::$request_uri_array = $request_uri_array;
 }