Example #1
0
 /**
  * getExternalLinks
  * @author Thomas Schedler <*****@*****.**>
  * @return string
  */
 public function getExternalLinks()
 {
     $strReturn = '';
     $objMyMultiRegion = $this->objPage->getRegion(50);
     //50 is the default external linkk region
     if ($objMyMultiRegion instanceof GenericElementRegion) {
         $strReturn .= '<div class="links">';
         if ($this->objPage->getField('title_externe_links') && $this->objPage->getFieldValue('title_externe_links') != '') {
             $strReturn .= '<h2>' . htmlentities($this->objPage->getFieldValue('title_externe_links'), ENT_COMPAT, $this->core->sysConfig->encoding->default) . '</h2>';
         }
         foreach ($objMyMultiRegion->RegionInstanceIds() as $intRegionInstanceId) {
             $strTitle = htmlentities($objMyMultiRegion->getField('link_title')->getInstanceValue($intRegionInstanceId), ENT_COMPAT, $this->core->sysConfig->encoding->default);
             $strUrl = $objMyMultiRegion->getField('link_url')->getInstanceValue($intRegionInstanceId);
             if (filter_var($strUrl, FILTER_VALIDATE_URL)) {
                 $strReturn .= '<div class="item"><a href="' . $strUrl . '">' . $strTitle . '</a></div>';
             } else {
                 if (filter_var('http://' . $strUrl, FILTER_VALIDATE_URL)) {
                     $strReturn .= '<div class="item"><a href="http://' . $strUrl . '">' . $strTitle . '</a></div>';
                 }
             }
         }
         $strReturn .= '</div>';
     }
     return $strReturn;
 }
 public static function getSetting($strName, $strNode = "/config")
 {
     if (Page::isPage($strNode)) {
         $objConfig = new Page($strNode);
         return $objConfig->getField($strName)->getValue();
     }
     return "";
 }
Example #3
0
 public function regenerateCli()
 {
     $db = $this->db;
     $newPaths = array();
     $fields = array();
     // Default fields and value
     foreach ($this->dbFields as $field => $options) {
         if (!$options['inFile']) {
             $fields[$field] = $options['value'];
         }
     }
     //$tmpPaths = glob(PATH_PAGES.'*', GLOB_ONLYDIR);
     $tmpPaths = Filesystem::listDirectories(PATH_PAGES);
     foreach ($tmpPaths as $directory) {
         $key = basename($directory);
         if (file_exists($directory . DS . 'index.txt')) {
             // The key is the directory name
             $newPaths[$key] = true;
         }
         // Recovery pages from subdirectories
         //$subPaths = glob($directory.DS.'*', GLOB_ONLYDIR);
         $subPaths = Filesystem::listDirectories($directory . DS);
         foreach ($subPaths as $subDirectory) {
             $subKey = basename($subDirectory);
             if (file_exists($subDirectory . DS . 'index.txt')) {
                 // The key is composed by the directory/subdirectory
                 $newPaths[$key . '/' . $subKey] = true;
             }
         }
     }
     foreach ($newPaths as $key => $value) {
         if (!isset($this->db[$key])) {
             // Default values for the new pages.
             $fields['status'] = CLI_STATUS;
             $fields['date'] = Date::current(DB_DATE_FORMAT);
             $fields['username'] = '******';
             // Create the entry for the new page.
             $this->db[$key] = $fields;
         }
         $Page = new Page($key);
         // Update all fields from FILE to DATABASE.
         foreach ($fields as $f => $v) {
             // If the field exists on the FILE, update it.
             if ($Page->getField($f)) {
                 $valueFromFile = $Page->getField($f);
                 if ($f == 'tags') {
                     // Generate tags array.
                     $this->db[$key]['tags'] = $this->generateTags($valueFromFile);
                 } elseif ($f == 'date') {
                     // Validate Date from file
                     if (Valid::date($valueFromFile, DB_DATE_FORMAT)) {
                         $this->db[$key]['date'] = $valueFromFile;
                     }
                 } else {
                     // Sanitize the values from file.
                     $this->db[$key][$f] = Sanitize::html($valueFromFile);
                 }
             }
         }
     }
     // Remove old pages from db
     foreach (array_diff_key($db, $newPaths) as $key => $data) {
         unset($this->db[$key]);
     }
     // Save the database.
     if ($this->save() === false) {
         Log::set(__METHOD__ . LOG_SEP . 'Error occurred when trying to save the database file.');
         return false;
     }
     return $this->db != $db;
 }
Example #4
0
$aryFields = array();
$aryValues = array();
$numFields = stripslashes($_REQUEST["numFields"]);
$blnActive = stripslashes($_REQUEST["active"]);
$blnOldActive = stripslashes($_REQUEST["old-active"]);
/* Get fields */
for ($i = 0; $i < $numFields; $i++) {
    $aryFields[] = stripslashes($_REQUEST["field_{$i}"]);
    if (array_key_exists("value_{$i}", $_FILES)) {
        $aryValues[] = $_FILES["value_{$i}"];
    } else {
        $aryValues[] = stripslashes($_REQUEST["value_{$i}"]);
    }
}
/* Create Instance */
$objPage = new Page($strNode);
/* Validate */
for ($i = 0; $i < count($aryFields); $i++) {
    $field = $objPage->getField($aryFields[$i]);
    $field->setValue($aryValues[$i]);
    $isValid = $field->validate();
    if ($isValid != true) {
        $aryInvalid[$aryFields[$i]] = $isValid;
    }
}
/* Set mode */
if (count($aryInvalid) == 0) {
    $mode = "save";
} else {
    $mode = "form";
}
Example #5
0
 /**
  * loadInstanceDataNow
  * @param string $strKey
  * @param array $arrGenFormPageIds
  * @return void
  * @author Thomas Schedler <*****@*****.**>
  */
 protected function loadInstanceDataNow($strKey, $arrGenFormPageIds, $strImgFieldIds = '5,55')
 {
     $intImgFilterTag = $this->objParentPage instanceof Page && $this->objParentPage->getField('entry_pic_tag') !== null && (int) $this->objParentPage->getFieldValue('entry_pic_tag') > 0 ? $this->objParentPage->getFieldValue('entry_pic_tag') : 0;
     $objPageRowset = $this->objModel->loadItemInstanceDataByIds($strKey, $arrGenFormPageIds, $intImgFilterTag, $strImgFieldIds);
     /**
      * overwrite page entries
      */
     if (isset($objPageRowset) && count($objPageRowset) > 0) {
         foreach ($objPageRowset as $objPageRow) {
             if (array_key_exists($objPageRow->id, $this->arrPageEntries)) {
                 if (is_array($this->arrPageEntries[$objPageRow->id])) {
                     $arrPageEntryContainers = $this->arrPageEntries[$objPageRow->id];
                 } else {
                     $arrPageEntryContainers = array($this->arrPageEntries[$objPageRow->id]);
                 }
                 foreach ($arrPageEntryContainers as $intContainerId) {
                     if (array_key_exists($intContainerId, $this->arrContainer)) {
                         $objPageEntry = $this->arrContainer[$intContainerId]->getPageEntry('entry_' . $objPageRow->id);
                         $objPageEntry->datetime = isset($objPageRow->datetime) ? strtotime($objPageRow->datetime) : '';
                         $objPageEntry->shortdescription = isset($objPageRow->shortdescription) ? $objPageRow->shortdescription : '';
                         $objPageEntry->description = isset($objPageRow->description) ? $objPageRow->description : '';
                         $objPageEntry->slogan = isset($objPageRow->slogan) ? $objPageRow->slogan : '';
                         $objPageEntry->filename = isset($objPageRow->filename) ? $objPageRow->filename : '';
                         $objPageEntry->fileversion = isset($objPageRow->fileversion) ? $objPageRow->fileversion : '';
                         $objPageEntry->filepath = isset($objPageRow->filepath) ? $objPageRow->filepath : '';
                         $objPageEntry->filetitle = isset($objPageRow->filetitle) ? $objPageRow->filetitle : '';
                         $objPageEntry->start_datetime = isset($objPageRow->start_datetime) ? $objPageRow->start_datetime : '';
                         $objPageEntry->end_datetime = isset($objPageRow->end_datetime) ? $objPageRow->end_datetime : '';
                         $objPageEntry->external = isset($objPageRow->external) ? $objPageRow->external : '';
                         if (isset($objPageRow->tagfilename) && $objPageRow->tagfilename !== null) {
                             $objPageEntry->filename = $objPageRow->tagfilename;
                         }
                         if (isset($objPageRow->tagfileversion) && $objPageRow->tagfileversion !== null) {
                             $objPageEntry->fileversion = $objPageRow->tagfileversion;
                         }
                         if (isset($objPageRow->tagfilepath) && $objPageRow->tagfilepath !== null) {
                             $objPageEntry->filepath = $objPageRow->tagfilepath;
                         }
                         if (isset($objPageRow->tagfiletitle) && $objPageRow->tagfiletitle !== null) {
                             $objPageEntry->filetitle = $objPageRow->tagfiletitle;
                         }
                         if (isset($objPageRow->categoryId) && $objPageRow->categoryId !== null) {
                             if ($objPageEntry->categories === null) {
                                 $objPageEntry->categories = new stdClass();
                                 $objPageEntry->categories->arr = array($objPageRow->categoryId => $objPageRow->category);
                             } else {
                                 $objPageEntry->categories->arr[$objPageRow->categoryId] = $objPageRow->category;
                             }
                         }
                         if (isset($objPageRow->courseId) && $objPageRow->courseId !== null && date('Ymd', strtotime($objPageRow->start_datetime)) >= date('Ymd')) {
                             if ($objPageEntry->courses === null) {
                                 $objPageEntry->courses = new stdClass();
                                 $objPageEntry->courses->arr = array();
                             }
                             if (!array_key_exists($objPageRow->courseId, $objPageEntry->courses->arr)) {
                                 $objCourse = new stdClass();
                                 $objCourse->id = $objPageRow->courseId;
                                 $objCourse->title = $objPageRow->courseTitle;
                                 $objCourse->start_datetime = strtotime($objPageRow->start_datetime);
                                 $objCourse->location = $objPageRow->location;
                                 $objCourse->speakers = array($objPageRow->speakerId => $objPageRow->speaker);
                                 $objCourse->categories = array($objPageRow->categoryId => $objPageRow->category);
                                 $objPageEntry->courses->arr[$objPageRow->courseId] = $objCourse;
                             } else {
                                 $objPageEntry->courses->arr[$objPageRow->courseId]->speakers[$objPageRow->speakerId] = $objPageRow->speaker;
                                 $objPageEntry->courses->arr[$objPageRow->courseId]->categories[$objPageRow->categoryId] = $objPageRow->category;
                             }
                         }
                         $this->arrContainer[$intContainerId]->addPageEntry($objPageEntry, 'entry_' . $objPageRow->id);
                     }
                 }
             }
         }
     }
 }
Example #6
0
 public static function renderField(Page $objPage, $field)
 {
     echo $objPage->getField($field)->render();
 }