示例#1
0
 public function assign_page()
 {
     Loader::model('section', 'multilingual');
     if (Loader::helper('validation/token')->validate('assign_page', $_POST['token'])) {
         if ($_REQUEST['destID'] == $_REQUEST['sourceID']) {
             print '<span class="ccm-error">' . t("You cannot assign this page to itself.") . '</span>';
             exit;
         }
         $destPage = Page::getByID($_POST['destID']);
         if (MultilingualSection::isMultilingualSection($destPage)) {
             $ms = MultilingualSection::getByID($destPage->getCollectionID());
         } else {
             $ms = MultilingualSection::getBySectionOfSite($destPage);
         }
         if (is_object($ms)) {
             $page = Page::getByID($_POST['sourceID']);
             // we need to assign/relate the source ID too, if it doesn't exist
             if (!MultilingualSection::isAssigned($page)) {
                 MultilingualSection::assignAdd($page);
             }
             MultilingualSection::relatePage($page, $destPage, $ms->getLocale());
             print '<a href="' . Loader::helper("navigation")->getLinkToCollection($destPage) . '">' . $destPage->getCollectionName() . '</a>';
         } else {
             print '<span class="ccm-error">' . t("The destination page doesn't appear to be in a valid multilingual section.") . '</span>';
         }
     }
     exit;
 }