/** * Constructor. * initializes the page if the id is given. * * @param integer $id DB id * @return void * @access public */ function __construct($id = 0) { $this->_remindedEditors = new CMS_stack(); $this->_lastReminder = new CMS_date(); $this->_lastFileCreation = new CMS_date(); if ($id) { if (!SensitiveIO::isPositiveInteger($id)) { $this->raiseError("Id is not a positive integer"); return; } $sql = "\n\t\t\t\tselect\n\t\t\t\t\t*\n\t\t\t\tfrom\n\t\t\t\t\tpages,\n\t\t\t\t\tresources,\n\t\t\t\t\tresourceStatuses\n\t\t\t\twhere\n\t\t\t\t\tid_pag='{$id}' and\n\t\t\t\t\tresource_pag = id_res and\n\t\t\t\t\tstatus_res = id_rs\n\t\t\t"; $q = new CMS_query($sql); if ($q->getNumRows()) { $data = $q->getArray(); $this->_pageID = $id; $this->_remindedEditors->setTextDefinition($data["remindedEditorsStack_pag"]); $this->_lastReminder->setFromDBValue($data["lastReminder_pag"]); $this->_templateID = $data["template_pag"]; $this->_lastFileCreation->setFromDBValue($data["lastFileCreation_pag"]); $this->_pageURL = $data["url_pag"]; $this->_protected = $data["protected_pag"] ? true : false; $this->_https = $data["https_pag"] ? true : false; //initialize super-class parent::__construct($data); } else { //display this error only if we are in HTTP mode (not cli) because it is only relevant in this mode if (!defined('APPLICATION_EXEC_TYPE') || APPLICATION_EXEC_TYPE == 'http') { $this->raiseError("Unknown ID :" . $id . ' from ' . io::getCallInfos(3)); } else { $this->raiseError(); } } } else { //initialize super-class parent::__construct(); } }
/** * Constructor. * * @return void * @access public */ function __construct($id = 0, $user = false) { // Loads up CMS_log with Id from database or with DB array if ($id) { if (SensitiveIO::isPositiveInteger($id)) { $sql = "\n\t\t\t\t\tselect\n\t\t\t\t\t\t*\n\t\t\t\t\tfrom\n\t\t\t\t\t\tlog\n\t\t\t\t\twhere\n\t\t\t\t\t\tid_log='" . $id . "'\n\t\t\t\t"; $q = new CMS_query($sql); if ($q->getNumRows()) { $this->_id = $id; $data = $q->getArray(); } else { $this->raiseError("Unknown DB ID : " . $id); return; } } elseif (is_array($id)) { $data = $id; $this->_id = $data['id_log']; } else { $this->raiseError("Id is not a positive integer nor array"); return; } if (is_array($data) && $data) { if ($user === false) { $this->_user = new CMS_profile_user($data["user_log"]); } else { $this->_user = $user; } $this->_action = $data["action_log"]; $date = new CMS_date(); $date->setFromDBValue($data["datetime_log"]); $this->_datetime = $date; $this->_textData = $data["textData_log"]; $this->_label = $data["label_log"]; $this->_module = $data["module_log"]; $this->_resource = $data["resource_log"]; // Create resource objects and populate $this->_resourceStatusAfter = new CMS_resourceStatus(); $this->_resourceStatusAfter->setDebug(false); $this->_resourceStatusAfter->setLog(false); $this->_resourceStatusAfter->setLocation($data["rsAfterLocation_log"]); $this->_resourceStatusAfter->setProposedFor($data["rsAfterProposedFor_log"]); $this->_resourceStatusAfter->setAllEditions($data["rsAfterEditions_log"]); $this->_resourceStatusAfter->setAllValidationsRefused($data["rsAfterValidationsRefused_log"]); $this->_resourceStatusAfter->setPublication($data["rsAfterPublication_log"]); //specific draft status if ($this->_action == CMS_log::LOG_ACTION_RESOURCE_EDIT_DRAFT) { $this->_resourceStatusAfter->setDraft(true); } } } else { $this->_user = new CMS_profile_user(); $this->_resourceStatusAfter = new CMS_resourceStatus(); $this->_datetime = new CMS_date(); } }
/** * Return the needed form field tag for current object field * * @param array $values : parameters values array(parameterName => parameterValue) in : * id : the form field id to set * @param multidimentionnal array $tags : xml2Array content of atm-function tag * @return string : the form field HTML tag * @access public */ function getInput($fieldID, $language, $inputParams) { //hidden field : use parent method if (isset($inputParams['hidden']) && ($inputParams['hidden'] == 'true' || $inputParams['hidden'] == 1)) { return parent::getInput($fieldID, $language, $inputParams); } if (isset($inputParams['prefix'])) { $prefixName = $inputParams['prefix']; unset($inputParams['prefix']); } else { $prefixName = ''; } $params = $this->getParamsValues(); //serialize all htmlparameters $htmlParameters = $this->serializeHTMLParameters($inputParams); $html = ''; //instanciate sending date object $sendingDate = new CMS_date(); $sendingDate->setFromDBValue($this->_subfieldValues[1]->getValue()); //append field id to html field parameters (if not already exists) $htmlParameters .= !isset($inputParams['id']) ? ' id="' . $prefixName . $this->_field->getID() . '_0"' : ''; if ($params['chooseSendEmail']) { $checked = $this->_subfieldValues[0]->getValue() == '1' ? 'checked="checked"' : ''; $html .= ' <input' . $htmlParameters . ' type="checkbox" ' . $checked . ' name="' . $prefixName . $this->_field->getID() . '_0" value="1" /> <input type="hidden" name="' . $prefixName . $this->_field->getID() . '_1" value="' . $sendingDate->getLocalizedDate($language->getDateFormat()) . '" /> <input type="hidden" name="' . $prefixName . $this->_field->getID() . '_2" value="0" />'; } else { $html .= ' <input type="hidden" name="' . $prefixName . $this->_field->getID() . '_0" value="1" /> <input type="hidden" name="' . $prefixName . $this->_field->getID() . '_1" value="' . $sendingDate->getLocalizedDate($language->getDateFormat()) . '" /> <input type="hidden" name="' . $prefixName . $this->_field->getID() . '_2" value="0" />'; } //append html hidden field which store field name if ($html) { $html .= '<input type="hidden" name="polymodFields[' . $this->_field->getID() . ']" value="' . $this->_field->getID() . '" />'; } if (POLYMOD_DEBUG) { $html .= '<span class="admin_text_alert"> (Field : ' . $fieldID . ' - Value : ' . $this->_subfieldValues[0]->getValue() . ' - ' . $this->_subfieldValues[1]->getValue() . ')</span>'; } return $html; }
$cms_message .= $cms_language->getMessage(MESSAGE_PAGE_SEARCH_ORDERTYPE_ERROR, array($searchName, $row->getLabel(), $orderName), MOD_POLYMOD_CODENAME) . "\n"; } } $searchParamContent[] = array('title' => $cms_language->getMessage(MESSAGE_PAGE_FIELD_ORDER, false, MOD_POLYMOD_CODENAME), 'xtype' => 'fieldset', 'autoHeight' => true, 'defaults' => array('anchor' => '97%'), 'items' => $searchOrderContent); } break; case 'searchType': //nothing, this is not a search parameter break; case 'publication date after': case 'publication date before': // Dates //create object CMS_date $date = new CMS_date(); if (isset($data["value"]['search'][$searchName][$paramType])) { $date->setFromDBValue($data["value"]['search'][$searchName][$paramType]); } $label = $paramType == 'publication date after' ? MESSAGE_PAGE_FIELD_PUBLISHED_FROM : MESSAGE_PAGE_FIELD_PUBLISHED_TO; //$date_mask = $cms_language->getDateFormatMask(); $value = $date->getLocalizedDate($cms_language->getDateFormat()) ? $date->getLocalizedDate($cms_language->getDateFormat()) : ''; $mandatory = $paramValue == true ? '<span class="atm-red">*</span> ' : ''; $searchParamContent[] = array('fieldLabel' => $mandatory . $cms_language->getMessage($label, false, MOD_POLYMOD_CODENAME), 'name' => 'value[search][' . $searchName . '][' . $paramType . ']', 'width' => 100, 'format' => $cms_language->getDateFormat(), 'anchor' => false, 'xtype' => 'datefield', 'allowBlank' => !$mandatory, 'value' => $value); break; default: $paramType = trim($paramType, '()'); //remove bracket around field id if (sensitiveIO::isPositiveInteger($paramType)) { //subobjects $field = $objectFields[$paramType]; if (is_object($field)) { //check if field has a method to provide a list of names
/** * Get object publication date * If object is a primary resource, return resource pub date else, try to find a date field with creation date * * @return CMS_date, the publication date object if any (false otherwise) * @access public */ function getPublicationDate() { static $pubFieldIDForObjectType; if ($this->getObjectResourceStatus() == 1) { return $this->getPublicationDateStart(); } else { //find creation date field for this type of object if (!isset($pubFieldIDForObjectType[$this->_objectID])) { $pubFieldIDForObjectType[$this->_objectID] = false; foreach (array_keys($this->_subObjectsDefinitions) as $fieldID) { $type = $this->_objectFieldsDefinition[$fieldID]->getValue('type'); if ($type == 'CMS_object_date' && $this->_objectFieldsDefinition[$fieldID]->getParameter('creationDate')) { //date field $pubFieldIDForObjectType[$this->_objectID] = $fieldID; } } } if ($pubFieldIDForObjectType[$this->_objectID] === false) { return false; } //then get field value $value = $this->_objectValues[$pubFieldIDForObjectType[$this->_objectID]]->getValue('value'); $date = new CMS_date(); $date->setFromDBValue($value); return $date; } }
define("MESSAGE_PAGE_SCRIPTS_IN_PROGRESS_PID_OK", 736); define("MESSAGE_PAGE_NO_SCRIPTS_PID_OK", 737); define("MESSAGE_PAGE_SCRIPTS_END_PID_OK", 738); define("MESSAGE_PAGE_NO_SCRIPTS_IN_PROGRESS", 739); define("MESSAGE_PAGE_NO_SCRIPTS_QUEUED", 740); //Controler vars $details = sensitiveIO::request('details') == 'true' ? true : false; $queue = sensitiveIO::request('queue') == 'true' ? true : false; $xmlcontent = $detailsContent = $queueContent = ''; if ($details) { $runningScripts = processManager::getRunningScript(); if (is_array($runningScripts) && sizeof($runningScripts)) { $detailsContent = '<ul class="atm-server">'; foreach ($runningScripts as $runningScript) { $date = new CMS_date(); $date->setFromDBValue($runningScript["Date"]); switch ($runningScript["PIDFile"]) { case '0': $detailsContent .= '<li class="atm-pic-question" ext:qtip="' . $cms_language->getMessage(MESSAGE_PAGE_SCRIPTS_IN_PROGRESS) . '">' . $runningScript["Title"] . ' (' . $date->getLocalizedDate($cms_language->getDateFormat() . " H:i:s") . ')</li>'; break; case '1': $detailsContent .= '<li class="atm-pic-ok" ext:qtip="' . $cms_language->getMessage(MESSAGE_PAGE_SCRIPTS_IN_PROGRESS_PID_OK) . '">' . $runningScript["Title"] . ' (' . $date->getLocalizedDate($cms_language->getDateFormat() . " H:i:s") . ')</li>'; break; case '2': $detailsContent .= '<li class="atm-pic-cancel" ext:qtip="' . $cms_language->getMessage(MESSAGE_PAGE_NO_SCRIPTS_PID_OK) . '">' . $runningScript["Title"] . ' (' . $date->getLocalizedDate($cms_language->getDateFormat() . " H:i:s") . ')</li>'; break; case '3': $detailsContent .= '<li class="atm-pic-cancel" ext:qtip="' . $cms_language->getMessage(MESSAGE_PAGE_SCRIPTS_END_PID_OK) . '">' . $runningScript["Title"] . ' (' . $date->getLocalizedDate($cms_language->getDateFormat() . " H:i:s") . ')</li>'; break; } }
if (is_array($archives) && $archives) { $content .= ' <table border="0" cellpadding="2" cellspacing="2"> <tr> <th class="admin">' . $cms_language->getMessage(MESSAGE_PAGE_FIELD_REFERENCE) . '</th> <th class="admin">' . $cms_language->getMessage(MESSAGE_PAGE_FIELD_TITLE) . '</th> <th class="admin">' . $cms_language->getMessage(MESSAGE_PAGE_FIELD_LASTCREATION) . '</th> <th class="admin" colspan="2">' . $cms_language->getMessage(MESSAGE_PAGE_ACTIONS) . '</th> </tr> '; $count = 0; foreach ($archives as $archive) { $count++; $td_class = $count % 2 == 0 ? "admin_lightgreybg" : "admin_darkgreybg"; $last_creation = new CMS_date(); $last_creation->setFromDBValue($archive["lastFileCreation"]); $href = PATH_ADMIN_SPECIAL_TREE_WR; $content .= ' <tr> <td class="' . $td_class . '">' . $archive["id"] . '</td> <td class="' . $td_class . '">' . htmlspecialchars($archive["title"]) . '</td> <td class="' . $td_class . '">' . $last_creation->getLocalizedDate($cms_language->getDateFormat()) . '</td> <form action="' . $_SERVER["SCRIPT_NAME"] . '" method="get" onSubmit="return confirm(\'' . addslashes($cms_language->getMessage(MESSAGE_PAGE_ACTION_DELETECONFIRM, array(htmlspecialchars($archive["title"])))) . '\')"> <input type="hidden" name="cms_action" value="delete" /> <input type="hidden" name="action_page" value="' . $archive["id"] . '" /> <td class="' . $td_class . '"> <input type="submit" class="admin_input_' . $td_class . '" value="' . $cms_language->getMessage(MESSAGE_PAGE_ACTION_DELETE) . '" /> </td> </form> <form action="' . $href . '" method="get"> <td class="' . $td_class . '">
/** * Constructor. * initializes the resourceStatus if the id is given * * @param integer $id DB id * @return void * @access public */ function __construct($id = 0) { if ($id) { if (SensitiveIO::isPositiveInteger($id)) { $sql = "\n\t\t\t\t\tselect\n\t\t\t\t\t\t*\n\t\t\t\t\tfrom\n\t\t\t\t\t\tresourceStatuses\n\t\t\t\t\twhere\n\t\t\t\t\t\tid_rs='{$id}'\n\t\t\t\t"; $q = new CMS_query($sql); if ($q->getNumRows()) { $data = $q->getArray(); $this->_id = $id; $this->_location = $data["location_rs"]; $this->_proposedFor = $data["proposedFor_rs"]; $this->_editions = $data["editions_rs"]; $this->_validationsRefused = $data["validationsRefused_rs"]; $this->_publicationDateStart = new CMS_date(); $this->_publicationDateStart->setFromDBValue($data["publicationDateStart_rs"]); $this->_publicationDateEnd = new CMS_date(); $this->_publicationDateEnd->setFromDBValue($data["publicationDateEnd_rs"]); $this->_publicationDateStartEdited = new CMS_date(); $this->_publicationDateStartEdited->setFromDBValue($data["publicationDateStartEdited_rs"]); $this->_publicationDateEndEdited = new CMS_date(); $this->_publicationDateEndEdited->setFromDBValue($data["publicationDateEndEdited_rs"]); $this->_publication = $data["publication_rs"]; //We must adjust the publication because of the publication dates $this->_adjustPublication(); } else { $this->raiseError("Unknown ID :" . $id); } } elseif (is_array($id)) { $data = $id; $this->_id = $data["status_res"]; $this->_location = $data["location_rs"]; $this->_proposedFor = $data["proposedFor_rs"]; $this->_editions = $data["editions_rs"]; $this->_validationsRefused = $data["validationsRefused_rs"]; $this->_publicationDateStart = new CMS_date(); $this->_publicationDateStart->setFromDBValue($data["publicationDateStart_rs"]); $this->_publicationDateEnd = new CMS_date(); $this->_publicationDateEnd->setFromDBValue($data["publicationDateEnd_rs"]); $this->_publicationDateStartEdited = new CMS_date(); $this->_publicationDateStartEdited->setFromDBValue($data["publicationDateStartEdited_rs"]); $this->_publicationDateEndEdited = new CMS_date(); $this->_publicationDateEndEdited->setFromDBValue($data["publicationDateEndEdited_rs"]); $this->_publication = $data["publication_rs"]; //We must adjust the publication because of the publication dates $this->_adjustPublication(); } else { $this->raiseError("Id is not a positive integer"); return; } } else { $this->_publicationDateStart = new CMS_date(); $this->_publicationDateEnd = new CMS_date(); $this->_publicationDateStartEdited = new CMS_date(); $this->_publicationDateEndEdited = new CMS_date(); } }
/** * Return options tag list (for a select tag) of all float values for this field * * @param array $values : parameters values array(parameterName => parameterValue) in : * selected : the float value which is selected (optional) * @param multidimentionnal array $tags : xml2Array content of atm-function tag (nothing for this one) * @return string : options tag list * @access public */ function selectOptions($values, $tags) { global $cms_language; $return = ""; $fieldID = $this->_field->getID(); $allValues = array(); $status = $this->_public ? 'public' : 'edited'; $supportedOperator = array('>=', '<=', '>', '<', '>= or null', '<= or null', '> or null', '< or null', '>= and not null', '<= and not null', '> and not null', '< and not null'); $sqlOperator = ''; if (isset($values['operator']) && isset($values['boundary']) && $values['operator'] && $values['boundary'] && in_array(htmlspecialchars_decode($values['operator']), $supportedOperator)) { $operator = htmlspecialchars_decode($values['operator']); $boundary = $values['boundary']; // canBeNull $operators = explode('or', $operator); $operator = trim($operators[0]); $canBeNull = isset($operators[1]) ? ' or value is NULL' : ''; // cantBeNull $operators = explode('and', $operator); $operator = trim($operators[0]); $cantBeNull = isset($operators[1]) ? ' and value is not NULL and value != \'0000-00-00\' and value != \'0000-00-00 00:00:00\'' : ''; //boundary $date = new CMS_date(); $date->setFormat($cms_language->getDateFormat()); $date->setLocalizedDate($boundary); $sqlOperator = " and (value " . $operator . " '" . SensitiveIO::sanitizeSQLString($date->getDBValue()) . "'" . $canBeNull . $cantBeNull . ")"; } // Search all values for this field $sql = "select\n distinct value\n from\n mod_subobject_date_" . $status . "\n where\n objectFieldID='" . $fieldID . "'\n " . $sqlOperator . "\n\t\t"; $q = new CMS_query($sql); $date = new CMS_date(); while (($value = $q->getValue('value')) !== false) { if ($value) { $date->setFromDBValue($value); if (isset($values['format']) && $values['format']) { $dateValue = date($values['format'], $date->getTimeStamp()); } else { $dateValue = $date->getLocalizedDate($cms_language->GetDateFormat()); } $allValues[$date->getTimeStamp()] = $dateValue; } } if (is_array($allValues) && $allValues) { ksort($allValues); foreach ($allValues as $id => $label) { $selected = $id == $values['selected'] ? ' selected="selected"' : ''; $return .= '<option title="' . io::htmlspecialchars($label) . '" value="' . $id . '"' . $selected . '>' . $label . '</option>'; } } return $return; }