public function import(\SimpleXMLElement $sx)
 {
     if (isset($sx->sociallinks)) {
         foreach ($sx->sociallinks->link as $l) {
             $site = \Core::make('site')->getSite();
             $sociallink = Link::getByServiceHandle((string) $l['service']);
             if (!is_object($sociallink)) {
                 $sociallink = new \Concrete\Core\Entity\Sharing\SocialNetwork\Link();
                 $sociallink->setURL((string) $l['url']);
                 $sociallink->setSite($site);
                 $sociallink->setServiceHandle((string) $l['service']);
                 $sociallink->save();
             }
         }
     }
 }
Example #2
0
 public function add_link()
 {
     $r = $this->validatePageRequest('add_link');
     list($ssHandle, $url, $existingLink) = $r;
     if ($existingLink) {
         $this->error->add(t('This social link already exists.'));
     }
     if (!$this->error->has()) {
         $link = new \Concrete\Core\Entity\Sharing\SocialNetwork\Link();
         $link->setServiceHandle($ssHandle);
         $link->setSite($this->getSite());
         $link->setURL($url);
         $link->save();
         $this->redirect('/dashboard/system/basics/social', 'link_added');
     }
     $this->add();
 }