Exemplo n.º 1
0
 $domdocument = new CMS_DOMDocument();
 try {
     $domdocument->loadXML("<dummy>" . $_POST["source_" . $item->getID()] . "</dummy>");
 } catch (DOMException $e) {
     $cms_message .= $cms_language->getMessage(MESSAGE_ACTION_ERROR_INVALID_XHTML, false, MOD_CMS_FORMS_CODENAME) . " : " . $e->getMessage();
 }
 if (!$cms_message) {
     //check inputs tags (sometimes, IE remove type="text" ...)
     //then save source
     $item->setAttribute('source', $item->checkInputs($_POST["source_" . $item->getID()]));
 }
 // Categories
 // Write item relations with categories
 $ids = $_POST["ids"] ? @array_unique(@explode(';', $_POST["ids"])) : array();
 if (!$cms_message && $item->writeToPersistence()) {
     $item_relations = new CMS_forms_formularCategories($item);
     if (sizeof($ids) <= 0) {
         $cms_message .= $cms_language->getMessage(MESSAGE_ACTION_ERROR_CATEGORIES_EMPTY, false, MOD_CMS_FORMS_CODENAME) . "\n";
     } else {
         $item_relations->init();
         foreach ($ids as $id) {
             $cat = CMS_moduleCategories_catalog::getByID($id);
             if ($cat->hasError() || !$item_relations->categoryExists($cat) && !$item_relations->addCategory($cat)) {
                 $cms_message .= $cms_language->getMessage(MESSAGE_ACTION_ERROR_ADD_CATEGORY, array($cat->getLabel($cms_language)), MOD_CMS_FORMS_CODENAME) . "\n";
             }
         }
         if (!$item_relations->writeToPersistence()) {
             $cms_message .= $cms_language->getMessage(MESSAGE_ACTION_ERROR_ADD_CATEGORIES, false, MOD_CMS_FORMS_CODENAME) . "\n";
         }
     }
 }
Exemplo n.º 2
0
//
$content .= '
	<tr>
		<td width="150" class="admin">
			' . $cms_language->getMessage(MESSAGE_PAGE_FIELD_LANGUAGE) . ' :</td>	
		<td width="350" class="admin">';
$all_languages = CMS_languagesCatalog::getAllLanguages(MOD_CMS_FORMS_CODENAME);
foreach ($all_languages as $aLanguage) {
    $checked = $aLanguage->getCode() == $items_language->getCode() ? ' checked="checked"' : '';
    $content .= '
			<label><input name="items_language" type="radio" value="' . $aLanguage->getCode() . '"' . $checked . ' onclick="submit();" /> ' . $aLanguage->getLabel() . '</label>';
}
$content .= '</td>
	</tr>';
// Categories
$a_all_categories = CMS_forms_formularCategories::getAllCategoriesAsArray($cms_language, true);
if (sizeof($a_all_categories)) {
    $s_categories_listbox = CMS_moduleCategories_catalog::getListBox(array('field_name' => 'items_ctg', 'items_possible' => $a_all_categories, 'default_value' => CMS_session::getSessionVar("items_ctg"), 'attributes' => 'class="admin_input_text" style="width:250px;"'));
    $content .= '
		<tr>
			<td class="admin">' . $cms_language->getMessage(MESSAGE_PAGE_FIELD_CATEGORY, false, MOD_CMS_FORMS_CODENAME) . '&nbsp;:</td>
			<td class="admin">' . $s_categories_listbox . '</td>
		</tr>';
}
$content .= '
	<tr>
		<td class="admin" colspan="2">
			<input type="submit" class="admin_input_submit" value="' . $cms_language->getMessage(MESSAGE_PAGE_ACTION_SHOW) . '" /></td>
	</tr>
</form>
</table></fieldset><br />';
Exemplo n.º 3
0
 /**
  * Returns each category ID and label in a module given user can see
  *
  * @access public
  * @param CMS_language $cms_language, the language of the labels
  * @param boolean $restrictToUsedCat, restrict returned categories to used ones only (default false)
  * @return array(string) the statements or false if profile hasn't any access to any categories
  */
 function getAllCategoriesAsArray($language = false, $restrictToUsedCat = false)
 {
     global $cms_user;
     $categories = CMS_moduleCategories_catalog::getAllCategoriesAsArray($cms_user, MOD_CMS_FORMS_CODENAME, $language);
     //pr($categories);
     if (!$restrictToUsedCat) {
         return $categories;
     } else {
         //Get all used categories IDS for this object field
         $usedCategories = CMS_forms_formularCategories::getAllUsedCategoriesForField($language);
         if (sizeof($usedCategories)) {
             //get all categories lineage
             $catArbo = CMS_moduleCategories_catalog::getViewvableCategoriesForProfile($cms_user, MOD_CMS_FORMS_CODENAME, true);
             //pr($catArbo);
             //need to remove all unused categories from list
             $categoriesToKeep = array();
             foreach ($usedCategories as $catID) {
                 $cats = explode(';', $catArbo[$catID]);
                 foreach ($cats as $aCat) {
                     $categoriesToKeep[$aCat] = $aCat;
                 }
             }
             //pr($categoriesToKeep);
             //then remove unused categories from initial list
             foreach ($categories as $catID => $catLabel) {
                 if (!isset($categoriesToKeep[$catID])) {
                     unset($categories[$catID]);
                 }
             }
             //pr($categories);
             return $categories;
         } else {
             //no categories used
             return array();
         }
     }
 }